forked from JointCloud/pcm-coordinator
33 lines
812 B
Go
33 lines
812 B
Go
package ai
|
|
|
|
import (
|
|
"encoding/json"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
Model "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/ai"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func CreateModelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req Model.CreateModelReq
|
|
|
|
body, err := io.ReadAll(r.Body)
|
|
if err != nil {
|
|
result.ParamErrorResult(r, w, err)
|
|
return
|
|
}
|
|
|
|
if err = json.Unmarshal(body, &req); err != nil {
|
|
result.ParamErrorResult(r, w, err)
|
|
return
|
|
}
|
|
|
|
l := ai.NewCreateModelLogic(r.Context(), svcCtx)
|
|
resp, err := l.CreateModel(&req)
|
|
result.HttpResult(r, w, resp, err)
|
|
}
|
|
}
|