package models import ( "eta/eta_task/global" "eta/eta_task/utils" "gorm.io/gorm" ) type EnglishReport struct { Id int `gorm:"column:id;primaryKey;autoIncrement" 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 string `description:"修改时间"` State int `description:"1:未发布,2:已发布"` PublishTime string `description:"发布时间"` PrePublishTime string `description:"预发布时间"` Stage int `description:"期数"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `description:"内容前两个章节"` ReportCode string `description:"报告唯一编码"` Pv int `description:"Pv"` PvEmail int `description:"邮箱PV"` EmailState int `description:"群发邮件状态: 0-未发送; 1-已发送"` Overview string `description:"英文概述部分"` KeyTakeaways string `description:"关键点"` FromReportId int `description:"继承的报告ID(英文策略报告ID)"` AdminId int `description:"创建者账号"` AdminRealName string `description:"创建者姓名"` } func (m *EnglishReport) AfterFind(tx *gorm.DB) (err error) { m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime) m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime) m.PublishTime = utils.GormDateStrToDateTimeStr(m.PublishTime) m.PrePublishTime = utils.GormDateStrToDateTimeStr(m.PrePublishTime) return } type EnglishReportDetail struct { Id int `gorm:"column:id;primaryKey;autoIncrement" 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 string `description:"修改时间"` State int `description:"1:未发布,2:已发布"` PublishTime string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` ReportCode string `description:"报告唯一编码"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` ContentSub string `description:"内容前两个章节"` Pv int `description:"Pv"` Overview string `description:"英文概述部分"` FromReportId int `description:"继承的报告ID(英文策略报告ID)"` KeyTakeaways string `description:"关键点"` } func (m *EnglishReportDetail) ConvertTimeStr() { m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime) m.ModifyTime = utils.GormDateStrToDateTimeStr(m.ModifyTime) m.PublishTime = utils.GormDateStrToDateTimeStr(m.PublishTime) return } type ElasticEnglishReportDetail struct { Id string `description:"报告id或者线上路演Id"` ReportId int `description:"报告id"` VideoId int `description:"线上路演Id"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` StageStr string `description:"报告期数"` Title string `description:"标题"` Abstract string `description:"摘要"` Author string `description:"作者"` Frequency string `description:"频度"` PublishState int `description:"状态:1:未发布,2:已发布"` BodyContent string `description:"内容"` ContentSub string `description:"前两段内容"` CreateTime string `description:"创建时间"` PublishTime string `description:"发布时间"` ReportCode string `description:"报告唯一编码"` Overview string `description:"英文概述部分"` } // GetPrePublishedEnglishReports 获取定时发布时间为当前时间的未发布的英文报告列表 func GetPrePublishedEnglishReports(startTime, endTime, afterDate string) (list []*EnglishReport, err error) { o := global.DbMap[utils.DbNameReport] sql := `SELECT * FROM english_report WHERE state = 1 and pre_publish_time >= ? and pre_publish_time <= ? and modify_time >= ?` err = o.Raw(sql, startTime, endTime, afterDate).Find(&list).Error return } // PublishEnglishReportById 发布报告 func PublishEnglishReportById(reportId int, publishTime string) (err error) { o := global.DbMap[utils.DbNameReport] sql := `UPDATE english_report SET state=2, publish_time=?, modify_time=NOW() WHERE id = ? ` err = o.Exec(sql, publishTime, reportId).Error return } func GetEnglishReportById(reportId int) (item *EnglishReportDetail, err error) { o := global.DbMap[utils.DbNameReport] sql := `SELECT * FROM english_report WHERE id=?` err = o.Raw(sql, reportId).First(&item).Error if err != nil { return } if item != nil && item.Id > 0 { item.ConvertTimeStr() } return } // GetReportByReportId 主键获取报告 func GetReportByReportId(reportId int) (item *Report, err error) { o := global.DbMap[utils.DbNameReport] sql := `SELECT * FROM report WHERE id = ?` err = o.Raw(sql, reportId).First(&item).Error return }