From 7bb947cebd7202c31c4baa28b57ec008e0f5b3c8 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 14 Jul 2022 15:22:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9C=80=E6=96=B0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=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 | 16 ++++++++++++++++ options/locale/locale_zh-CN.ini | 2 +- routers/repo/ai_model_convert.go | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 59f4fc625..0ea01d6e5 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -397,6 +397,22 @@ func QueryModelConvertByRepoID(repoId int64) ([]*AiModelConvert, error) { return aiModelManageConvert, nil } +func QueryModelConvertByUserID(userID int64) ([]*AiModelConvert, error) { + sess := x.NewSession() + defer sess.Close() + var cond = builder.NewCond() + cond = cond.And( + builder.Eq{"ai_model_convert.user_id": userID}, + ) + sess.OrderBy("ai_model_convert.created_unix DESC") + aiModelManageConvert := make([]*AiModelConvert, 0) + if err := sess.Table(new(AiModelConvert)).Where(cond). + Find(&aiModelManageConvert); err != nil { + return nil, fmt.Errorf("Find: %v", err) + } + return aiModelManageConvert, nil +} + func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelConvert, int64, error) { sess := x.NewSession() defer sess.Close() diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index a362c1d29..976446643 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1234,7 +1234,7 @@ model.list=模型列表 model.manage.create_new_convert_task=创建模型转换任务 modelconvert.manage.create_error1=相同的名称模型转换任务已经存在。 -modelconvert.manage.create_error2=只能创建一个在运行的模型转换任务。 +modelconvert.manage.create_error2=只能创建一个正在运行的模型转换任务。 modelconvert.manage.model_not_exist=选择的模型不存在。 modelconvert.manage.no_operate_right=无操作权限。 diff --git a/routers/repo/ai_model_convert.go b/routers/repo/ai_model_convert.go index 13ef1293c..9a5874956 100644 --- a/routers/repo/ai_model_convert.go +++ b/routers/repo/ai_model_convert.go @@ -108,6 +108,12 @@ func SaveModelConvert(ctx *context.Context) { }) return } + } + } + + convertList, err = models.QueryModelConvertByUserID(ctx.User.ID) + if err == nil { + for _, convert := range convertList { if isRunningTask(convert.Status) { log.Info("convert.Status=" + convert.Status + " convert.id=" + convert.ID) ctx.JSON(200, map[string]string{