2023-03-27 14:44:14 +08:00
|
|
|
package ai
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-08 16:11:32 +08:00
|
|
|
"encoding/json"
|
2024-07-03 09:46:33 +08:00
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/ai"
|
|
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
2025-07-08 16:11:32 +08:00
|
|
|
algorithm "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/ai"
|
2024-03-26 10:24:00 +08:00
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
2025-07-08 16:11:32 +08:00
|
|
|
"io"
|
2024-03-26 10:24:00 +08:00
|
|
|
"net/http"
|
2023-03-27 14:44:14 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func CreateAlgorithmHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
2025-07-08 16:11:32 +08:00
|
|
|
var req algorithm.CreateAlgorithmReq
|
|
|
|
|
|
|
|
|
|
body, err := io.ReadAll(r.Body)
|
|
|
|
|
if err != nil {
|
|
|
|
|
result.ParamErrorResult(r, w, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err = json.Unmarshal(body, &req); err != nil {
|
2024-03-26 10:24:00 +08:00
|
|
|
result.ParamErrorResult(r, w, err)
|
2023-03-27 14:44:14 +08:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
l := ai.NewCreateAlgorithmLogic(r.Context(), svcCtx)
|
|
|
|
|
resp, err := l.CreateAlgorithm(&req)
|
2024-03-26 10:24:00 +08:00
|
|
|
result.HttpResult(r, w, resp, err)
|
2023-03-27 14:44:14 +08:00
|
|
|
}
|
|
|
|
|
}
|