package models import ( "time" "github.com/beego/beego/v2/client/orm" ) type ReportPushStatus struct { ReportPushStatusId int `orm:"pk"` ReportId int `description:"报告id"` State int `description:"报告状态:0-未推送,1-已推送"` Title string `description:"报告标题"` Abstract string `description:"报告摘要"` Stage int `description:"期数"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` ClassifyIdThird int `description:"三级分类id"` ClassifyNameThird string `description:"三级分类名称"` Author string `description:"报告作者"` ReportType int `description:"报告类型:1-eta报告"` PublishTime time.Time `description:"报告发布时间"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` PushTime time.Time `description:"推送时间"` } type ReportPushView struct { ReportPushStatusId int `orm:"pk"` ReportId int `description:"报告id"` Title string `description:"报告标题"` Abstract string `description:"报告摘要"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` ClassifyIdThird int `description:"二级分类id"` ClassifyNameThird string `description:"二级分类名称"` Author string `description:"报告作者"` Stage int `description:"期数"` State int `description:"报告状态:0-未推送,1-已推送"` PushTime string `description:"推送时间"` PublishTime string `description:"报告发布时间"` ReportType int `description:"报告类型:1-eta报告"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` } func GetReportPushStatusByReportId(reportId int, reportType int) (item *ReportPushStatus, err error) { o := orm.NewOrm() sql := `SELECT * FROM report_push_status WHERE report_id = ? AND report_type = ?` err = o.Raw(sql, reportId, reportType).QueryRow(&item) return } func GetReportPushStatusCountByCondition(condition string, pars []interface{}) (count int, err error) { o := orm.NewOrm() sql := `SELECT COUNT(*) AS count FROM report_push_status WHERE 1=1 AND state=1 ` if condition != "" { sql += condition } err = o.Raw(sql, pars...).QueryRow(&count) return } func GetReportPushStatusByCondition(condition string, pars []interface{}, startSize int, pageSize int) (items []*ReportPushStatus, err error) { o := orm.NewOrm() sql := `SELECT * FROM report_push_status WHERE 1=1 AND state=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_time DESC LIMIT ?,?` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } func DeleteReportPushStatusByReportId(reportId int, reportType int) (err error) { o := orm.NewOrm() sql := `DELETE FROM report_push_status WHERE report_id = ? AND report_type = ?` _, err = o.Raw(sql, reportId, reportType).Exec() return }