1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package models
- import (
- "fmt"
- "hongze/hongze_task/utils"
- "rdluck_tools/orm"
- "time"
- )
- type Report struct {
- Id int `orm:"column(id)" description:"报告Id"`
- AddType int `description:"新增方式:1:新增报告,2:继承报告"`
- ClassifyIdFirst int `description:"一级分类id"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- CreateTime string `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- State int `description:"1:未发布,2:已发布"`
- PublishTime time.Time `description:"发布时间"`
- Stage int `description:"期数"`
- MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
- Content string `description:"内容"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- ContentSub string `description:"内容前两个章节"`
- }
- func GetReportById(reportId int) (item *Report, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `SELECT * FROM report WHERE id=?`
- err = o.Raw(sql, reportId).QueryRow(&item)
- return
- }
- func GetReport() (items []*Report, err error) {
- sql := `SELECT * FROM report ORDER BY id ASC `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func ModifyReportContentSub(id int, contentSub string) (err error) {
- sql := `UPDATE report SET content_sub=? WHERE id=? `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql, contentSub, id).Exec()
- return
- }
- func GetReportLimit() (items []*Report, err error) {
- sql := `SELECT * FROM report WHERE state=2 ORDER BY id DESC LIMIT 50 `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func EditReportContent(reportId int, content, contentSub string) (err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
- _, err = o.Raw(sql, content, contentSub, reportId).Exec()
- return
- }
- //删除报告日志记录-保留3个月
- func DeleteReportSaveLog() {
- startDateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDateTime)
- fmt.Println(startDateTime)
- }
- func EditReportContentHtml(reportId int, content string) (err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := ` UPDATE report SET content=?,modify_time=NOW() WHERE id=? `
- _, err = o.Raw(sql, content, reportId).Exec()
- return
- }
|