From 4fda025cbd1b143c28b60a7e4ba050f150f18bba Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 30 Nov 2021 15:09:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9Eerror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/ai_model_manage.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 4f07996fe..90d537031 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -110,6 +110,16 @@ func SaveModel(ctx *context.Context) { label := ctx.Query("Label") description := ctx.Query("Description") + if JobId == "" || VersionName == "" { + ctx.Error(500, fmt.Sprintf("JobId or VersionName is null.")) + return + } + + if name == "" || version == "" { + ctx.Error(500, fmt.Sprintf("name or version is null.")) + return + } + err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx.User.ID) if err != nil { From b217b20472067c396ea3e49e9b888ec71d8eb1bb Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 30 Nov 2021 17:25:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/ai_model_manage.go | 1 + routers/repo/ai_model_manage.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index a982e565a..711ffd53d 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -52,6 +52,7 @@ func SaveModelToDb(model *AiModelManage) error { re, err := sess.Insert(model) if err != nil { + log.Info("insert error." + err.Error()) return err } log.Info("success to save db.re=" + fmt.Sprint((re))) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 90d537031..a5a1a7d9c 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -89,8 +89,10 @@ func saveModelByParameters(jobId string, versionName string, name string, versio Accuracy: string(accuracyJson), } - models.SaveModelToDb(model) - + err = models.SaveModelToDb(model) + if err != nil { + return err + } if len(lastNewModelId) > 0 { //udpate status and version count models.ModifyModelNewProperty(lastNewModelId, MODEL_NOT_LATEST, 0)