// @Author gmy 2024/9/19 14:53:00 package models import ( "github.com/beego/beego/v2/client/orm" ) type OutsideReport struct { OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"` Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"` Title string `orm:"column(title)" description:"报告标题"` Abstract string `orm:"column(abstract)" description:"摘要"` ClassifyId int `orm:"column(classify_id)" description:"所属分类id"` ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"` Content string `orm:"column(content)" description:"报告富文本内容"` SysUserId int `orm:"column(sys_user_id)" description:"创建人id"` SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"` EmailMessageUid int `orm:"column(email_message_uid)" description:"该邮件在邮箱中的唯一id"` ReportUpdateTime string `orm:"column(report_update_time)" description:"报告更新时间,如果来源于邮件,那么取邮件的收件时间"` ModifyTime string `orm:"column(modify_time)" description:"最近一次修改时间"` CreateTime string `orm:"column(create_time)" description:"创建时间"` ReportCode string `orm:"column(report_code)" description:"报告唯一编码"` } type OutsideReportBO struct { OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"` Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"` Title string `orm:"column(title)" description:"报告标题"` Abstract string `orm:"column(abstract)" description:"摘要"` ClassifyId int `orm:"column(classify_id)" description:"所属分类id"` ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"` Content string `orm:"column(content)" description:"报告富文本内容"` SysUserId int `orm:"column(sys_user_id)" description:"创建人id"` SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"` ReportCode string `orm:"column(report_code)" description:"报告唯一编码"` AttachmentList []*OutsideReportAttachment } type OutsideReportResp struct { OutsideReportBO *OutsideReportBO `description:"报告"` Disclaimer string `description:"免责声明"` H5ShareName string `description:"研报分享抬头"` H5ReportShareImg string `description:"研报分享图片"` WatermarkChart string `description:"图表是否需要水印"` WatermarkReport string `description:"报告是否需要水印"` Hz int ReportLogo string `description:"报告logo"` } // 在 init 函数中注册模型 func init() { orm.RegisterModel(new(OutsideReport)) } // GetOutsideReportListByConditionCount 根据条件查询列表条数 func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) { o := orm.NewOrm() sql := `select count(distinct t1.outside_report_id) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 ` sql += condition err = o.Raw(sql, pars).QueryRow(&count) if err != nil { return 0, err } return count, err } // GetOutsideReportByReportCode 根据Code获取报告 func GetOutsideReportByReportCode(reportCode string) (outsideReport *OutsideReport, err error) { o := orm.NewOrm() sql := `SELECT * FROM outside_report WHERE report_code=?` err = o.Raw(sql, reportCode).QueryRow(&outsideReport) return outsideReport, err }