123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package models
- import (
- "eta_gn/eta_task/global"
- "fmt"
- "time"
- )
- // SmartReport 智能研报
- type SmartReport struct {
- SmartReportId int `orm:"column(smart_report_id)" description:"智能研报ID"`
- ReportCode string `description:"报告唯一编码"`
- ClassifyIdFirst int `description:"一级分类ID"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类ID"`
- ClassifyNameSecond string `description:"二级分类名称"`
- AddType int `description:"新增方式:1-新增报告;2-继承报告"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- Stage int `description:"期数"`
- Content string `description:"内容"`
- ContentSub string `description:"内容前两个章节"`
- ContentStruct string `description:"内容组件"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- VideoSize string `description:"音频文件大小,单位M"`
- AdminId int `description:"创建者ID"`
- AdminRealName string `description:"创建者姓名"`
- State int `description:"发布状态:1-待发布;2-已发布"`
- PublishTime time.Time `description:"发布时间"`
- PrePublishTime time.Time `description:"预发布时间"`
- PreMsgSend int `description:"定时发布后是否推送模版消息:0-否;1-是"`
- MsgIsSend int `description:"消息是否已发送:0-否;1-是"`
- MsgSendTime time.Time `description:"模版消息发送时间"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func (m *SmartReport) TableName() string {
- return "smart_report"
- }
- func (m *SmartReport) PrimaryId() string {
- return "smart_report_id"
- }
- func (m *SmartReport) Update(cols []string) (err error) {
- //o := orm.NewOrmUsingDB("rddp")
- //_, err = o.Update(m, cols...)
- err = global.DmSQL["rddp"].Select(cols).Updates(m).Error
- return
- }
- func (m *SmartReport) GetItemById(id int) (item *SmartReport, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- //sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- //err = o.Raw(sql, id).QueryRow(&item)
- sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
- err = global.DmSQL["rddp"].Raw(sql, id).Find(&item).Error
- return
- }
- // GetPrePublishSmartReports 获取定时发布时间为当前时间的未发布的报告列表
- func GetPrePublishSmartReports(startTime, endTime string) (list []*SmartReport, err error) {
- //o := orm.NewOrmUsingDB("rddp")
- //sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
- //_, err = o.Raw(sql, startTime, endTime).QueryRows(&list)
- sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
- err = global.DmSQL["rddp"].Raw(sql, startTime, endTime).Find(&list).Error
- return
- }
- // PublishSmartReportById 发布智能报告
- func PublishSmartReportById(reportId int, publishTime time.Time) (err error) {
- //o := orm.NewOrmUsingDB("rddp")
- //sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
- //_, err = o.Raw(sql, publishTime, reportId).Exec()
- sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
- err = global.DmSQL["rddp"].Exec(sql, publishTime, reportId).Error
- return
- }
- // ElasticSmartReport 智能研报es
- type ElasticSmartReport struct {
- SmartReportId int `description:"智能研报ID"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- BodyContent string `description:"内容"`
- PublishTime string `description:"发布时间"`
- PublishState int `description:"发布状态 1-未发布 2-已发布"`
- Author string `description:"作者"`
- ClassifyIdFirst int `description:"一级分类ID"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类ID"`
- ClassifyNameSecond string `description:"二级分类名称"`
- StageStr string `description:"报告期数"`
- Frequency string `description:"频度"`
- }
- // Report2ImgQueueReq 报告详情生成长图队列请求体
- type Report2ImgQueueReq struct {
- ReportType int `description:"报告类型: 1-研报; 2-智能研报"`
- ReportCode string `description:"报告唯一编码"`
- }
|