From 13ad54470d3420575006637bef35ae05b01d15e9 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 13 Dec 2022 16:25:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8F=8A=E6=A8=A1=E5=9E=8B=E8=BD=AC=E6=8D=A2=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=90=8D=E7=A7=B0=E6=9F=A5=E8=AF=A2=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=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 | 12 ++++++++++++ routers/api/v1/api.go | 2 ++ routers/api/v1/repo/modelmanage.go | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 4fe74e555..02f6b12c9 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -221,6 +221,18 @@ func SaveModelToDb(model *AiModelManage) error { return nil } +func QueryModelConvertByName(name string) ([]*AiModelConvert, error) { + sess := x.NewSession() + defer sess.Close() + sess.Select("*").Table(new(AiModelConvert)).Where("name='" + name + "'") + aiModelManageConvertList := make([]*AiModelConvert, 0) + err := sess.Find(&aiModelManageConvertList) + if err == nil { + return aiModelManageConvertList, nil + } + return nil, err +} + func QueryModelConvertById(id string) (*AiModelConvert, error) { sess := x.NewSession() defer sess.Close() diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index d8ad9fdbc..3e50b00fc 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1021,6 +1021,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Delete("/delete_model", repo.DeleteModel) m.Get("/downloadall", repo.DownloadModel) m.Get("/query_model_byId", repo.QueryModelById) + m.Get("/query_model_byName", repo.QueryModelByName) m.Get("/query_model_for_predict", repo.QueryModelListForPredict) m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) m.Get("/query_train_model", repo.QueryTrainModelList) @@ -1028,6 +1029,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/convert_stop", repo.StopModelConvert) m.Get("/show_model_convert_page", repo.ShowModelConvertPage) m.Get("/query_model_convert_byId", repo.QueryModelConvertById) + m.Get("/query_model_convert_byName", repo.QueryModelConvertByName) m.Get("/:id", repo.GetCloudbrainModelConvertTask) m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) diff --git a/routers/api/v1/repo/modelmanage.go b/routers/api/v1/repo/modelmanage.go index a8166732d..3b0aed0d5 100644 --- a/routers/api/v1/repo/modelmanage.go +++ b/routers/api/v1/repo/modelmanage.go @@ -43,6 +43,11 @@ func QueryModelById(ctx *context.APIContext) { routerRepo.QueryModelById(ctx.Context) } +func QueryModelByName(ctx *context.APIContext) { + log.Info("QueryModelByName by api.") + routerRepo.ShowSingleModel(ctx.Context) +} + func QueryModelListForPredict(ctx *context.APIContext) { log.Info("QueryModelListForPredict by api.") ctx.Context.SetParams("isOnlyThisRepo", "true") @@ -119,3 +124,12 @@ func QueryModelConvertById(ctx *context.APIContext) { ctx.JSON(http.StatusOK, nil) } } + +func QueryModelConvertByName(ctx *context.APIContext) { + modelResult, err := routerRepo.GetModelConvertByName(ctx.Context) + if err == nil { + ctx.JSON(http.StatusOK, modelResult) + } else { + ctx.JSON(http.StatusOK, nil) + } +}