package models import ( "eta/eta_report/utils" "fmt" "github.com/beego/beego/v2/client/orm" "html" "time" ) // SmartReport 智能研报 type SmartReport struct { SmartReportId int `orm:"column(smart_report_id);pk" 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 float64 `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` AdminId int `description:"创建者ID"` AdminRealName string `description:"创建者姓名"` State int `description:"发布状态:1-待发布;2-已发布"` LastModifyAdminId int `description:"最后更新人ID"` LastModifyAdminName string `description:"最后更新人姓名"` ContentModifyTime time.Time `description:"内容更新时间"` Pv int `description:"pv"` Uv int `description:"uv"` PublishTime time.Time `description:"发布时间"` PrePublishTime time.Time `description:"预发布时间"` PreMsgSend int `description:"定时发布后是否推送模版消息:0-否;1-是"` MsgIsSend int `description:"消息是否已发送:0-否;1-是"` MsgSendTime time.Time `description:"模版消息发送时间"` DetailImgUrl string `description:"报告详情长图地址"` DetailPdfUrl string `description:"报告详情PDF地址"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` HeadImg string `description:"报告头图地址"` EndImg string `description:"报告尾图地址"` CanvasColor string `description:"画布颜色"` NeedSplice int `description:"0-不需要 1-需要"` HeadResourceId int `description:"版头资源ID"` EndResourceId int `description:"版尾资源ID"` HeadStyle string `description:"版头样式"` EndStyle string `description:"版尾样式"` } func (m *SmartReport) TableName() string { return "smart_report" } func (m *SmartReport) PrimaryId() string { return "smart_report_id" } func (m *SmartReport) Create() (err error) { o := orm.NewOrm() id, err := o.Insert(m) if err != nil { return } m.SmartReportId = int(id) return } func (m *SmartReport) Update(cols []string) (err error) { o := orm.NewOrm() _, err = o.Update(m, cols...) return } func (m *SmartReport) GetItemById(id int) (item *SmartReport, err error) { o := orm.NewOrm() sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId()) err = o.Raw(sql, id).QueryRow(&item) return } func (m *SmartReport) GetItemByCondition(condition string, pars []interface{}) (item *SmartReport, err error) { o := orm.NewOrm() sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition) err = o.Raw(sql, pars).QueryRow(&item) return } // SmartReportItem 智能研报信息 type SmartReportItem struct { SmartReportId int `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 float64 `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` AdminId int `description:"创建者姓名"` AdminRealName string `description:"创建者姓名"` Pv int `description:"pv"` Uv int `description:"uv"` State int `description:"发布状态:1-待发布;2-已发布"` PublishTime string `description:"发布时间"` PrePublishTime string `description:"预发布时间"` MsgIsSend int `description:"消息是否已发送:0-否;1-是"` DetailImgUrl string `description:"报告详情长图地址"` DetailPdfUrl string `description:"报告详情PDF地址"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` CanEdit bool `description:"是否可编辑"` Editor string `description:"当前编辑人"` HeadImg string `description:"报告头图地址"` EndImg string `description:"报告尾图地址"` CanvasColor string `description:"画布颜色"` NeedSplice int `description:"0-不需要 1-需要"` HeadResourceId int `description:"版头资源ID"` EndResourceId int `description:"版尾资源ID"` HeadStyle string `description:"版头样式"` EndStyle string `description:"版尾样式"` } // FormatSmartReport2Item 格式化智能研报数据格式 func FormatSmartReport2Item(origin *SmartReport) (item *SmartReportItem) { item = new(SmartReportItem) if origin == nil { return } item.SmartReportId = origin.SmartReportId item.ReportCode = origin.ReportCode item.ClassifyIdFirst = origin.ClassifyIdFirst item.ClassifyNameFirst = origin.ClassifyNameFirst item.ClassifyIdSecond = origin.ClassifyIdSecond item.ClassifyNameSecond = origin.ClassifyNameSecond item.AddType = origin.AddType item.Title = origin.Title item.Abstract = origin.Abstract item.Author = origin.Author item.Frequency = origin.Frequency item.Stage = origin.Stage item.Content = html.UnescapeString(origin.Content) item.ContentSub = html.UnescapeString(origin.ContentSub) item.ContentStruct = html.UnescapeString(origin.ContentStruct) item.VideoUrl = origin.VideoUrl item.VideoName = origin.VideoName item.VideoPlaySeconds = origin.VideoPlaySeconds item.VideoSize = origin.VideoSize item.AdminId = origin.AdminId item.AdminRealName = origin.AdminRealName item.Pv = origin.Pv item.Uv = origin.Uv item.State = origin.State item.PublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PublishTime) item.PrePublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PrePublishTime) item.MsgIsSend = origin.MsgIsSend item.DetailImgUrl = origin.DetailImgUrl item.DetailPdfUrl = origin.DetailPdfUrl item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime) item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime) item.CanvasColor = origin.CanvasColor item.HeadImg = origin.HeadImg item.EndImg = origin.EndImg item.NeedSplice = origin.NeedSplice item.HeadResourceId = origin.HeadResourceId item.EndResourceId = origin.EndResourceId return } // SmartReportShareDetailResp 智能研报分享详情响应体 type SmartReportShareDetailResp struct { Report *SmartReportItem `description:"智能研报"` Disclaimer string `description:"免责声明"` H5ShareName string `description:"研报分享抬头"` H5ReportShareImg string `description:"研报分享图片"` Hz int } // UpdateSmartReportPv 研报pv自增 func UpdateSmartReportPv(reportId int) (err error) { o := orm.NewOrm() sql := `UPDATE smart_report SET pv = pv + 1 WHERE smart_report_id = ?` _, err = o.Raw(sql, reportId).Exec() return } type SmartReportResource struct { ResourceId int `orm:"column(resource_id);pk" description:"智能研报资源ID"` ImgUrl string // 图片链接 Style string // 版图样式 ImgName string // 图片名称 Type int // 类型 1-版头 2-版尾 CreateTime time.Time // 创建时间 } func GetResourceItemById(id int) (item *SmartReportResource, err error) { o := orm.NewOrm() sql := fmt.Sprintf(`SELECT * FROM smart_report_resource WHERE resource_id = ? LIMIT 1`) err = o.Raw(sql, id).QueryRow(&item) return } type SmartReportWechatShareDetailResp struct { H5ShareName string `description:"研报分享抬头"` H5ShareTitle string `description:"研报分享抬头"` H5ReportShareImg string `description:"研报分享图片"` }