Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.21.12.1^2
zouap 3 years ago
parent
commit
1b9c667271
4 changed files with 53 additions and 0 deletions
  1. +16
    -0
      models/ai_model_manage.go
  2. +1
    -0
      routers/private/internal.go
  3. +11
    -0
      routers/private/tool.go
  4. +25
    -0
      routers/repo/ai_model_manage.go

+ 16
- 0
models/ai_model_manage.go View File

@@ -86,6 +86,22 @@ func DeleteModelById(id string) error {

}

func ModifyModelDescription(id string, description string) error {
sess := x.NewSession()
defer sess.Close()

re, err := sess.Update(&AiModelManage{
ID: id,
Description: description,
})
if err != nil {
return err
}
log.Info("success to update description from db.re=" + fmt.Sprint((re)))
return nil

}

func QueryModelByName(name string, uid int64) []*AiModelManage {
sess := x.NewSession()
defer sess.Close()


+ 1
- 0
routers/private/internal.go View File

@@ -47,5 +47,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/tool/create_model", CreateModel)
m.Delete("/tool/delete_model", DeleteModel)
m.Get("/tool/show_model", ShowModel)
m.Put("/tool/modify_model", ModifyModel)
}, CheckInternalToken)
}

+ 11
- 0
routers/private/tool.go View File

@@ -76,3 +76,14 @@ func ShowModel(ctx *macaron.Context) {
ctx.JSON(500, "query error.")
}
}

func ModifyModel(ctx *macaron.Context) {
id := ctx.Query("id")
description := ctx.Query("Description")
err := repo.ModifyModel(id, description)
if err == nil {
ctx.JSON(200, "Success.")
} else {
ctx.JSON(500, "Failed.")
}
}

+ 25
- 0
routers/repo/ai_model_manage.go View File

@@ -199,3 +199,28 @@ func ShowModelInfo(ctx *context.Context) {
ctx.Data["Tasks"] = modelResult
ctx.HTML(200, "")
}

func ModifyModel(id string, description string) error {
err := models.ModifyModelDescription(id, description)
if err == nil {
log.Info("modify success.")
} else {
log.Info("Failed to modify.id=" + id + " desc=" + description)
}
return err
}

func ModifyModelInfo(ctx *context.Context) {
log.Info("delete model start.")
id := ctx.Query("ID")
description := ctx.Query("Description")

err := ModifyModel(id, description)

if err == nil {
ctx.HTML(200, "success")
} else {
ctx.HTML(500, "Failed.")
}

}

Loading…
Cancel
Save