package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type Report struct { Id int `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 string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `description:"内容前两个章节"` IsShowNewLabel int `description:"是否显示新标签"` IsCurrentDate int `description:"是否当前日期"` ClassifyName string `description:"分类名称"` } type ReportList struct { Id int `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 string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` HasPermission int `description:"是否拥有报告权限,1:拥有,0:没有"` TitleType string `description:"标题类型,FICC或者权益"` IsCurrentDate int `description:"是否当前日期:1是,0不是"` ClassifyDetail } type ReportListResp struct { List []*ReportList Paging *PagingItem `description:"分页数据"` } func GetReportListCount(classifyId int) (count int, err error) { o := orm.NewOrmUsingDB("rddp") sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 AND classify_id_second=? ` err = o.Raw(sql, classifyId).QueryRow(&count) return } func GetReportList(classifyId, startSize, pageSize int) (items []*ReportList, err error) { o := orm.NewOrmUsingDB("rddp") sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency, a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript, b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size, CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date FROM report AS a INNER JOIN classify AS b ON a.classify_id_second=b.id WHERE a.state=2 AND a.classify_id_second=? ORDER BY a.publish_time DESC LIMIT ?,? ` _, err = o.Raw(sql, classifyId, startSize, pageSize).QueryRows(&items) return } func GetReportPermission(userId int, classifyNameSecond string) (count int, err error) { o := orm.NewOrm() sql := ` SELECT COUNT(1) AS count FROM company_report_permission AS crp INNER JOIN chart_permission_chapter_mapping AS cpcm ON crp.chart_permission_id = cpcm.chart_permission_id INNER JOIN chart_permission_search_key_word_mapping AS cskwm ON cskwm.chart_permission_id=crp.chart_permission_id INNER JOIN wx_user wu ON wu.company_id = crp.company_id WHERE wu.user_id = ? AND cpcm.research_type = 'rddp' AND cskwm.from='rddp' AND cskwm.key_word=? ` err = o.Raw(sql, userId, classifyNameSecond).QueryRow(&count) return } type ReportDetail struct { Id int `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:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `description:"内容前两个章节"` IsShowNewLabel int `description:"是否显示新标签"` IsCurrentDate int `description:"是否当前日期"` ClassifyName string `description:"分类名称"` TitleType string `description:"标题类型,FICC或者权益"` } func GetReportById(reportId int) (item *ReportDetail, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM report WHERE id=?` err = o.Raw(sql, reportId).QueryRow(&item) return } type ReportVarietyList struct { ReportChapterTypeId int } func GetReportVarietyListByUserIdExt(userId int, reportType string) (list []*ReportVarietyList, err error) { o := orm.NewOrm() sql := `SELECT cpcm.report_chapter_type_id FROM company_report_permission crp INNER JOIN chart_permission_chapter_mapping cpcm ON crp.chart_permission_id = cpcm.chart_permission_id INNER JOIN wx_user wu ON wu.company_id = crp.company_id WHERE wu.user_id = ? AND cpcm.research_type = ? GROUP BY cpcm.report_chapter_type_id` _, err = o.Raw(sql, userId, reportType).QueryRows(&list) return } type ReportDetailResp struct { Report *ReportDetail `description:"报告"` RecommendList []*RecommendReport `description:"推荐报告列表"` Status int `description:"状态:0:正常展示,1:报告不存在,2:无权限"` Msg string `description:"提示信息"` Classify *ClassifyDetail `description:"对应专栏"` PermissionCheckInfo PermissionCheckInfoResp `description:"权限相关"` } // PermissionCheckInfo 权限校验完成后的结果 type PermissionCheckInfoResp struct { Name string `description:"销售名称"` Mobile string `description:"销售手机号"` Type string `description:"校验失败,没有权限,需要让前端处理的类型,枚举值:apply,contact"` Status string `description:"客户状态"` HasApply bool `description:"是否有申请过"` CompanyName string `description:"公司名称"` RealName string `description:"联系人姓名"` } type ReportRecordReq struct { ReportId int `description:"报告Id"` } type RecommendReport struct { Id int `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 string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `description:"内容前两个章节"` ClassifyName string `description:"分类名称"` HasPermission int `description:"报告权限:0:无权限,1:有权限"` TitleType string `description:"标题类型,FICC或者权益"` } func GetRecommendList(reportId, reportType int) (items []*RecommendReport, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM report WHERE state=2 AND id<>? ` if reportType == 1 { sql += ` AND classify_name_first='权益研报' ` } else { sql += ` AND classify_name_first<>'权益研报' ` } sql += ` ORDER BY publish_time DESC LIMIT 3` _, err = o.Raw(sql, reportId).QueryRows(&items) return } func GetReportByCode(reportCode string) (item *Report, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM report WHERE report_code=?` err = o.Raw(sql, reportCode).QueryRow(&item) return } type ReportShareDetailResp struct { Report *Report `description:"报告"` Disclaimer string `description:"免责声明"` H5ShareName string `description:"研报分享抬头"` H5ReportShareImg string `description:"研报分享图片"` Hz int } type PcReport struct { Id int `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 string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `json:"-" description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` VideoSize string `description:"音频文件大小,单位M"` ContentSub string `json:"-" description:"内容前两个章节"` IsShowNewLabel int `description:"是否显示新标签,等于0不显示,大于0显示"` IsCurrentDate int `description:"是否当前日期:1是,0不是"` ClassifyName string `description:"分类名称"` TitleType string `description:"标题类型,FICC或者权益"` } type ReportAuthor struct { ReportAuthor string `description:"报告作者名称"` } func GetReportAuthor(reportAuthor string) (item *ReportAuthor, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM report_author WHERE report_author=? ` err = o.Raw(sql, reportAuthor).QueryRow(&item) return } // GetTrialReportByCode ETA试用-根据编码获取报告 func GetTrialReportByCode(reportCode string) (item *Report, err error) { o := orm.NewOrmUsingDB("rddp_trial") sql := `SELECT * FROM report WHERE report_code=?` err = o.Raw(sql, reportCode).QueryRow(&item) return }