| @@ -221,6 +221,18 @@ func SaveModelToDb(model *AiModelManage) error { | |||||
| return nil | 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) { | func QueryModelConvertById(id string) (*AiModelConvert, error) { | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| defer sess.Close() | defer sess.Close() | ||||
| @@ -1021,6 +1021,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Delete("/delete_model", repo.DeleteModel) | m.Delete("/delete_model", repo.DeleteModel) | ||||
| m.Get("/downloadall", repo.DownloadModel) | m.Get("/downloadall", repo.DownloadModel) | ||||
| m.Get("/query_model_byId", repo.QueryModelById) | 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_model_for_predict", repo.QueryModelListForPredict) | ||||
| m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) | m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) | ||||
| m.Get("/query_train_model", repo.QueryTrainModelList) | m.Get("/query_train_model", repo.QueryTrainModelList) | ||||
| @@ -1028,6 +1029,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Post("/convert_stop", repo.StopModelConvert) | m.Post("/convert_stop", repo.StopModelConvert) | ||||
| m.Get("/show_model_convert_page", repo.ShowModelConvertPage) | m.Get("/show_model_convert_page", repo.ShowModelConvertPage) | ||||
| m.Get("/query_model_convert_byId", repo.QueryModelConvertById) | m.Get("/query_model_convert_byId", repo.QueryModelConvertById) | ||||
| m.Get("/query_model_convert_byName", repo.QueryModelConvertByName) | |||||
| m.Get("/:id", repo.GetCloudbrainModelConvertTask) | m.Get("/:id", repo.GetCloudbrainModelConvertTask) | ||||
| m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) | m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) | ||||
| @@ -43,6 +43,11 @@ func QueryModelById(ctx *context.APIContext) { | |||||
| routerRepo.QueryModelById(ctx.Context) | routerRepo.QueryModelById(ctx.Context) | ||||
| } | } | ||||
| func QueryModelByName(ctx *context.APIContext) { | |||||
| log.Info("QueryModelByName by api.") | |||||
| routerRepo.ShowSingleModel(ctx.Context) | |||||
| } | |||||
| func QueryModelListForPredict(ctx *context.APIContext) { | func QueryModelListForPredict(ctx *context.APIContext) { | ||||
| log.Info("QueryModelListForPredict by api.") | log.Info("QueryModelListForPredict by api.") | ||||
| ctx.Context.SetParams("isOnlyThisRepo", "true") | ctx.Context.SetParams("isOnlyThisRepo", "true") | ||||
| @@ -119,3 +124,12 @@ func QueryModelConvertById(ctx *context.APIContext) { | |||||
| ctx.JSON(http.StatusOK, nil) | 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) | |||||
| } | |||||
| } | |||||