fix:err msg formatted
This commit is contained in:
parent
fae1868bd5
commit
c0ecc9299d
|
@ -39,12 +39,12 @@ func (a *aiApi) TrainAlgorithmsHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", nil)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
algorithms, err := a.service.TrainAlgorithms(c, pfId)
|
algorithms, err := a.service.TrainAlgorithms(c, pfId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "failed to get train algorithms", err.Error())
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", algorithms)
|
model.Response(c, http.StatusOK, "success", algorithms)
|
||||||
|
@ -54,7 +54,7 @@ func (a *aiApi) TrainAlgorithmsHandler(c *gin.Context) {
|
||||||
func (a *aiApi) AllTrainAlgorithmsHandler(c *gin.Context) {
|
func (a *aiApi) AllTrainAlgorithmsHandler(c *gin.Context) {
|
||||||
algorithms, err := a.service.AllTrainAlgorithms(c)
|
algorithms, err := a.service.AllTrainAlgorithms(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to get all train algorithms", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", algorithms)
|
model.Response(c, http.StatusOK, "success", algorithms)
|
||||||
|
@ -65,7 +65,7 @@ func (a *aiApi) CreateAlgorithmHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", nil)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func (a *aiApi) CreateAlgorithmHandler(c *gin.Context) {
|
||||||
|
|
||||||
resp, err := a.service.CreateAlgorithm(c.Request.Context(), pfId, ¶m)
|
resp, err := a.service.CreateAlgorithm(c.Request.Context(), pfId, ¶m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to create algorithm", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func (a *aiApi) CreateDatasetHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", nil)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,14 +107,14 @@ func (a *aiApi) CreateDatasetHandler(c *gin.Context) {
|
||||||
for _, e := range ve {
|
for _, e := range ve {
|
||||||
errorMsg = append(errorMsg, fmt.Sprintf("字段 %s 验证失败: %s", e.Field(), e.Tag()))
|
errorMsg = append(errorMsg, fmt.Sprintf("字段 %s 验证失败: %s", e.Field(), e.Tag()))
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusBadRequest, "请求体格式错误: "+strings.Join(errorMsg, "; "), err)
|
model.Response(c, http.StatusBadRequest, errorMsg, nil)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := a.service.CreateDataset(c.Request.Context(), pfId, ¶m)
|
resp, err := a.service.CreateDataset(c.Request.Context(), pfId, ¶m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to create algorithm", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ func (a *aiApi) CreateModelHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,14 +138,14 @@ func (a *aiApi) CreateModelHandler(c *gin.Context) {
|
||||||
for _, e := range ve {
|
for _, e := range ve {
|
||||||
errorMsg = append(errorMsg, fmt.Sprintf("字段 %s 验证失败: %s", e.Field(), e.Tag()))
|
errorMsg = append(errorMsg, fmt.Sprintf("字段 %s 验证失败: %s", e.Field(), e.Tag()))
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusBadRequest, "请求体格式错误: "+strings.Join(errorMsg, "; "), err)
|
model.Response(c, http.StatusBadRequest, "请求体格式错误: "+strings.Join(errorMsg, "; "), nil)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := a.service.CreateModel(c.Request.Context(), pfId, ¶m)
|
resp, err := a.service.CreateModel(c.Request.Context(), pfId, ¶m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to create algorithm", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,12 +158,12 @@ func (a *aiApi) GetResourceSpecsHandler(c *gin.Context) {
|
||||||
rtype := c.Query("rType")
|
rtype := c.Query("rType")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = a.service.GetResourceSpecs(c, pfId, rtype)
|
_, err = a.service.GetResourceSpecs(c, pfId, rtype)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -175,12 +175,12 @@ func (a *aiApi) TrainResourcesHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resources, err := a.service.TrainResources(c, pfId)
|
resources, err := a.service.TrainResources(c, pfId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to get train resources", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", resources)
|
model.Response(c, http.StatusOK, "success", resources)
|
||||||
|
@ -190,7 +190,7 @@ func (a *aiApi) TrainResourcesHandler(c *gin.Context) {
|
||||||
func (a *aiApi) AllTrainResourcesHandler(c *gin.Context) {
|
func (a *aiApi) AllTrainResourcesHandler(c *gin.Context) {
|
||||||
resources, err := a.service.AllTrainResources(c)
|
resources, err := a.service.AllTrainResources(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusInternalServerError, "failed to get all train resources", err)
|
model.Response(c, http.StatusInternalServerError, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", resources)
|
model.Response(c, http.StatusOK, "success", resources)
|
||||||
|
@ -200,12 +200,12 @@ func (a *aiApi) AllTrainResourcesHandler(c *gin.Context) {
|
||||||
func (a *aiApi) CreateTrainTaskHandler(c *gin.Context) {
|
func (a *aiApi) CreateTrainTaskHandler(c *gin.Context) {
|
||||||
var param service.CreateTrainTaskParam
|
var param service.CreateTrainTaskParam
|
||||||
if err := c.ShouldBindJSON(¶m); err != nil {
|
if err := c.ShouldBindJSON(¶m); err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid request body", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, err := a.service.CreateTrainTask(c, ¶m)
|
resp, err := a.service.CreateTrainTask(c, ¶m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "failed to create train task", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", resp)
|
model.Response(c, http.StatusOK, "success", resp)
|
||||||
|
@ -216,17 +216,17 @@ func (a *aiApi) TaskResultSyncHandler(c *gin.Context) {
|
||||||
pfIdStr := c.Query("pfId")
|
pfIdStr := c.Query("pfId")
|
||||||
var param task.ResultSyncParam
|
var param task.ResultSyncParam
|
||||||
if err := c.ShouldBindJSON(¶m); err != nil {
|
if err := c.ShouldBindJSON(¶m); err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid request body", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = a.service.TaskResultSync(c, pfId, ¶m)
|
err = a.service.TaskResultSync(c, pfId, ¶m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "task Sync failed", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", err)
|
model.Response(c, http.StatusOK, "success", err)
|
||||||
|
@ -239,12 +239,12 @@ func (a *aiApi) TaskLogHandler(c *gin.Context) {
|
||||||
|
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = a.service.TaskLog(c, pfId, taskId)
|
_, err = a.service.TaskLog(c, pfId, taskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "get task log failed", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", err)
|
model.Response(c, http.StatusOK, "success", err)
|
||||||
|
@ -257,12 +257,12 @@ func (a *aiApi) TrainTaskDetailHandler(c *gin.Context) {
|
||||||
|
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = a.service.GetTrainingTask(c, pfId, taskId)
|
_, err = a.service.GetTrainingTask(c, pfId, taskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "get task detail failed", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", err)
|
model.Response(c, http.StatusOK, "success", err)
|
||||||
|
@ -275,12 +275,12 @@ func (a *aiApi) InferTaskDetailHandler(c *gin.Context) {
|
||||||
|
|
||||||
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "invalid pfId", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = a.service.GetInferenceTask(c, pfId, taskId)
|
_, err = a.service.GetInferenceTask(c, pfId, taskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
model.Response(c, http.StatusBadRequest, "get infer task detail failed", err)
|
model.Response(c, http.StatusBadRequest, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model.Response(c, http.StatusOK, "success", err)
|
model.Response(c, http.StatusOK, "success", err)
|
||||||
|
|
Loading…
Reference in New Issue