no message

master
DESKTOP-4RNDQIC\29019 2021-03-04 21:21:12 +08:00
parent 368751fbf6
commit 5b9ec97933
3 changed files with 32 additions and 11 deletions

View File

@ -1,10 +1,11 @@
package config package config
import ( import (
"gopkg.in/yaml.v2"
"log" "log"
"os" "os"
"runtime" "runtime"
"gopkg.in/yaml.v2"
) )
var ostype = runtime.GOOS var ostype = runtime.GOOS

View File

@ -172,6 +172,19 @@ func UpdateArtilce(c *gin.Context) {
defer func() { defer func() {
c.JSON(200, rsp) c.JSON(200, rsp)
}() }()
query := fmt.Sprintf("select * from doc where doc.id = '%d'", id)
docs := []model.Doc{}
e := db.GetMysqlClient().Query2(query, &docs)
if nil != e {
log.Print(e.Error())
return
}
if len(docs) == 0 {
rsp.Msg = "不存在该"
return
}
er := c.BindJSON(&req) er := c.BindJSON(&req)
if nil != er { if nil != er {
logs.Error(er.Error()) logs.Error(er.Error())
@ -181,14 +194,15 @@ func UpdateArtilce(c *gin.Context) {
rsp.Msg = "title required" rsp.Msg = "title required"
return return
} }
e := model.UpdateDoc( e = model.UpdateDoc(
model.Doc{ model.Doc{
Type: req.Type, Type: int32(req.Type),
Title: req.Title, Title: req.Title,
Content: req.Content, Content: req.Content,
Author: req.author, Author: req.author,
ID: req.Id, ID: req.Id,
IsPublic: req.IsPublic, IsPublic: int32(req.IsPublic),
Version: (docs[0].Version + 1),
}, },
) )
if nil != e { if nil != e {

View File

@ -12,12 +12,18 @@ import (
) )
type Doc struct { type Doc struct {
ID int64 `sql:"id" json:"id"` ID int64 `json:"id" gorm:"column:id" sql:"id"`
Title string `sql:"title" json:"title"` Title string `json:"title" gorm:"column:title" sql:"title"`
Type int64 `sql:"type" json:"type"` Type int32 `json:"type" gorm:"column:type" sql:"type"`
Content string `sql:"content" json:"content"` Content string `json:"content" gorm:"column:content" sql:"content"`
Author string `sql:"author" json:"author"` Author string `json:"author" gorm:"column:author" sql:"author"`
IsPublic int `sql:"is_public" json:"is_public"` CreateTime time.Time `json:"create_time" gorm:"column:create_time" sql:"create_time"`
UpdateTime time.Time `json:"update_time" gorm:"column:update_time" sql:"update_time"`
DeleteTime time.Time `json:"delete_time" gorm:"column:delete_time" sql:"delete_time"`
Version int32 `json:"version" gorm:"column:version" sql:"version"`
IsPublic int32 `json:"is_public" gorm:"column:is_public" sql:"is_public"`
Deleted int32 `json:"deleted" gorm:"column:deleted" sql:"deleted"`
OriginUrl string `json:"origin_url" gorm:"column:origin_url" sql:"origin_url"`
} }
type DocGroup struct { type DocGroup struct {