perf: 优化模型自动更新表字段

This commit is contained in:
zhanzhenping
2024-07-05 16:08:43 +08:00
parent f3846cc431
commit 1dd82a67fb
4 changed files with 16 additions and 1 deletions

View File

@@ -122,6 +122,7 @@ func (c *BookController) Setting() {
if book.PrivateToken != "" {
book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
}
fmt.Println("book.PrintState", book.PrintState)
c.Data["Model"] = book
}
@@ -153,6 +154,7 @@ func (c *BookController) SaveBook() {
isUseFirstDocument := strings.TrimSpace(c.GetString("is_use_first_document")) == "on"
autoSave := strings.TrimSpace(c.GetString("auto_save")) == "on"
itemId, _ := c.GetInt("itemId")
pringState := strings.TrimSpace(c.GetString("print_state")) == "on"
if strings.Count(description, "") > 500 {
c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips"))
@@ -211,6 +213,11 @@ func (c *BookController) SaveBook() {
} else {
book.AutoSave = 0
}
if pringState {
book.PrintSate = 1
} else {
book.PrintSate = 0
}
if err := book.Update(); err != nil {
c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed"))
}