数据库添加文件修改历史记录。

master
zcy 2022-04-01 03:27:07 +08:00
parent 398a9c2772
commit c120287aa2
1 changed files with 18 additions and 2 deletions

View File

@ -26,6 +26,14 @@ type Doc struct {
OriginUrl string `json:"origin_url" gorm:"column:origin_url" sql:"origin_url"` OriginUrl string `json:"origin_url" gorm:"column:origin_url" sql:"origin_url"`
} }
type DocHistory struct{
ID int32 `json:"id" gorm:"column:id" sql:"id"`
Title string `json:"title" gorm:"column:title" sql:"title"`
DocId int32 `json:"doc_id" gorm:"column:doc_id" sql:"doc_id"`
Content []byte `json:"content" gorm:"column:content" sql:"content"`
EditTime time.Time `json:"edit_time" gorm:"column:edit_time" sql:"edit_time"`
}
type DocGroup struct { type DocGroup struct {
Int int32 `sql:"int"` Int int32 `sql:"int"`
Name string `sql:"name"` Name string `sql:"name"`
@ -96,6 +104,13 @@ func UpdateDoc(doc Doc) error {
logs.Error(e.Error()) logs.Error(e.Error())
return e return e
} }
sql = fmt.Sprintf(`insert into doc(title,doc_id,content,edit_time) values('%s',%d,'%s','%s');`,
doc.Title,doc.ID,strings.Replace(doc.Content, "'", "\\'", -1), time.Now().Format("2006-01-02 15:04:05"))
_, er := db.GetMysqlClient().Query(sql)
if nil != er {
logs.Error(e.Error())
return e
}
return nil return nil
} }
@ -162,8 +177,9 @@ func GetAllDocs() ([]Doc, error) {
return nil, e return nil, e
} }
return ret, nil return ret, nil
} }
func GetAllGroup() ([]DocGroup, error) { func GetAllGroup() ([]DocGroup, error) {
ret := []DocGroup{} ret := []DocGroup{}
sql := fmt.Sprintf("select * from doc_group") sql := fmt.Sprintf("select * from doc_group")