123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package models
- import (
- "eta_gn/eta_task/global"
- "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:"内容前两个章节"`
- HasChapter int `description:"是否有章节 0-否 1-是"`
- ChapterType string `description:"章节类型 day-晨报 week-周报"`
- OldReportId int `description:"research_report表ID(后续一两个版本过渡需要,之后可移除)"`
- PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
- AdminId int
- AdminName string `description:"系统用户名称"`
- ClassifyIdThird int `description:"三级分类id"`
- ClassifyNameThird string `description:"三级分类名称"`
- }
- func GetPrePublishedReports(startTime, endTime, afterDate string) (list []*Report, err error) {
- sql := `SELECT * FROM report WHERE state = 1 and pre_publish_time >= ? and pre_publish_time <=? and modify_time >= ?`
- err = global.DmSQL["rddp"].Raw(sql, startTime, endTime, afterDate).Find(&list).Error
- return
- }
- func PublishReportById(reportId int, publishTime time.Time) (err error) {
- sql := `UPDATE report SET state = 2, publish_time = ?, modify_time = NOW() WHERE id = ? `
- err = global.DmSQL["rddp"].Exec(sql, publishTime, reportId).Error
- return
- }
- type ReportDetail 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 string `description:"修改时间"`
- State int `description:"1:未发布,2:已发布"`
- PublishTime string `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:"内容前两个章节"`
- ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
- HasChapter int `description:"是否有章节 0-否 1-是"`
- ChapterType string `description:"章节类型 day-晨报 week-周报"`
- OldReportId int `description:"research_report表ID(后续一两个版本过渡需要,之后可移除)"`
- PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
- }
- func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
- sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? `
- err = global.DmSQL["rddp"].Exec(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Error
- return
- }
- type ReportChapterTypePermission struct {
- Id int `gorm:"column:id;primaryKey"` // `orm:"column(id);pk" description:"主键ID"`
- ReportChapterTypeId int `description:"报告章节类型ID"`
- ReportChapterTypeName string `description:"章节名称"`
- ChartPermissionId int `description:"大分类ID"`
- PermissionName string `description:"权限名称"`
- ResearchType string `description:"研报类型"`
- CreatedTime time.Time `description:"创建时间"`
- }
- type ElasticReportDetail struct {
- ReportId int `description:"报告ID"`
- ReportChapterId 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:"二级分类名称"`
- ClassifyId int `description:"最小单元的分类ID"`
- ClassifyName string `description:"最小单元的分类名称"`
- Categories string `description:"关联的品种名称(包括品种别名)"`
- StageStr string `description:"报告期数"`
- }
- type ChartPermissionMappingIdName struct {
- PermissionId int
- PermissionName string
- }
- func GetChartPermissionNameFromMappingByKeyword(source string, classifyId int) (list []*ChartPermissionMappingIdName, err error) {
- sql := " SELECT b.chart_permission_id AS permission_id,b.permission_name FROM chart_permission_search_key_word_mapping AS a INNER JOIN chart_permission AS b ON a.chart_permission_id = b.chart_permission_id WHERE a.`from` = ? AND a.classify_id = ? "
- err = global.DmSQL["rddp"].Raw(sql, source, classifyId).Find(&list).Error
- return
- }
- func UpdateReportPublishTime(reportId int, videoNameDate string) (err error) {
- sql1 := ` UPDATE report SET publish_time = NOW() WHERE id = ? `
- err = global.DmSQL["rddp"].Exec(sql1, reportId).Error
- if err != nil {
- return
- }
- sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !='' and video_name is not null)`
- err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
- return
- }
- func UpdateReportChapterPublishTime(reportId int, videoNameDate string) (err error) {
- sql1 := ` UPDATE report_chapter SET publish_time = NOW() WHERE report_id = ? `
- err = global.DmSQL["rddp"].Exec(sql1, reportId).Error
- if err != nil {
- return
- }
- sql2 := ` UPDATE report_chapter SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE report_id = ? and (video_name !='' and video_name is not null)`
- err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
- return
- }
- func ModifyReportMsgIsSend(reportId int) (err error) {
- sql := `UPDATE report SET msg_is_send = 1, msg_send_time=NOW() WHERE id = ? and msg_is_send=0`
- err = global.DmSQL["rddp"].Exec(sql, reportId).Error
- return
- }
- func ClearReportSaveLog(date string) (err error) {
- sql := `DELETE FROM report_save_log WHERE create_time <= ?`
- err = global.DmSQL["rddp"].Exec(sql, date).Error
- return
- }
- func PublishReportAndChapter(reportInfo *Report, isPublishReport bool, cols []string) (err error) {
- to := global.DmSQL["rddp"].Begin()
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- if isPublishReport {
- err = to.Select(cols).Updates(reportInfo).Error
- if err != nil {
- return
- }
- }
- sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? `
- err = to.Exec(sql, reportInfo.PublishTime, reportInfo.Id).Error
- return
- }
|