package models import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "strconv" ) type HomeArtAndChartListResp struct { Paging *paging.PagingItem List []*HomeArticle `description:"文章列表"` ChartList []*HomeChartListResp `description:"图表列表"` } type HomeArticleListResp struct { Paging *paging.PagingItem List []*ArticleListResp `description:"文章列表"` } type ReportBillboardListResp struct { List []*ArticleListResp `description:"文章列表"` } type HomeArticle struct { ArticleId int `description:"文章id"` Title string `description:"标题"` TitleEn string `description:"英文标题 "` PublishDate string `description:"发布时间"` Body string `description:"内容"` BodyHtml string `description:"内容带有HTML标签"` Abstract string `description:"摘要"` CategoryName string `description:"一级分类"` SubCategoryName string `description:"二级分类"` IsResearch bool `description:"是否属于研选"` Pv int `description:"PV"` ImgUrlPc string `description:"图片链接"` CategoryId string `description:"文章分类"` HttpUrl string `description:"文章链接跳转地址"` IsNeedJump bool `description:"是否需要跳转链接地址"` Source int `description:"来源 1:文章, 2:图表"` Annotation string `description:"核心观点"` ArticleTypeId int `description:"文章类型ID判断是否是研选使用"` HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"` Readnum int `description:"阅读数量"` IsRed bool `description:"是否标红"` Resource int `description:"来源类型,1:文章、2:产品内测"` MicroAudio *MicroAudioUnionList `description:"微路演音频"` List []*IndustrialManagementIdInt IsCollect bool `description:"本人是否收藏"` CollectNum int `description:"收藏人数"` ReportId int `description:"FICC研报ID"` } type ArticleListResp struct { ArticleId int `description:"文章id"` Title string `description:"标题"` TitleEn string `description:"英文标题 "` PublishDate string `description:"发布时间"` Body string `description:"内容"` Abstract string `description:"摘要"` ExpertBackground string `description:"专家背景"` IsResearch bool `description:"是否属于研选"` Pv int `description:"PV"` ImgUrlPc string `description:"图片链接"` CategoryId string `description:"文章分类"` HttpUrl string `description:"文章链接跳转地址"` IsNeedJump bool `description:"是否需要跳转链接地址"` Source int `description:"来源 1:文章, 2:图表"` Annotation string `description:"核心观点"` ChartPermissionName string `description:"权限名称"` ArticleTypeId int `description:"文章类型ID判断是否是研选使用"` BodyImg string `description:"文章封面图片"` DepartmentId int `description:"作者Id"` NickName string `description:"作者昵称"` IsCollect bool `description:"本人是否收藏"` IsRed bool `description:"是否标红"` CollectNum int `description:"收藏人数"` MyCollectNum int `description:"我收藏的数量"` Resource int `description:"来源类型,1:文章、2:产品内测"` Cover string `description:"封面图片"` BodyHighlight []string `description:"搜索高亮展示结果"` IsSpecial int `description:"是否为研选专栏"` IndustryTags string `description:"研选专栏行业标签"` CompanyTags string `description:"研选专栏公司标签"` SpecialColumnId int `description:"专栏栏目id"` SpecialType int `description:"专栏类型 1:笔记,2:观点"` List []*IndustrialManagementIdInt TopTime int `description:"置顶时间"` ReportId int `description:"FICC研报ID"` } type HomeChartListResp struct { ChartId int `description:"图表ID"` Title string `description:"标题"` TitleEn string `description:"英文标题 "` CreateDate string `description:"创建时间"` PtagName string `description:"父类名称"` CtagName string `description:"子类名称"` PtagNameTwo string `description:"父类名称"` CtagNameTwo string `description:"子类名称"` CtagNamePc string `description:"Pc端所有的分类名称"` BodyHtml string `orm:"column(cover)";description:"图片链接"` HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"` IsNeedJump bool `description:"是否需要跳转链接地址"` IsTop bool `description:"是否置顶"` NumTop int `description:"置顶数量"` Source int `description:"来源 1:文章, 2:图表"` LabelList []*LabelList `description:"图表标签列表"` } type LabelList struct { PtagName string `description:"父类名称"` CtagName string `description:"子类名称"` } func GetHomeCount(condition string, pars []interface{}) (count int, err error) { o := orm.NewOrm() sql := `SELECT COUNT(1) AS count FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } err = o.Raw(sql, pars).QueryRow(&count) return } func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) { o := orm.NewOrm() sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } func GetHomeListNew(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) { o := orm.NewOrm() sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } // 获取产业报告列表 func GetReportIndustrialList(condition string, pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*HomeArticle, err error) { o := orm.NewOrm() sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum FROM cygx_article AS a INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id WHERE a.publish_status = 1 AND category_id IN (SELECT category_id FROM cygx_report_mapping WHERE chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) ) AND a.is_class = 1 AND man_g.industrial_management_id = ?` + condition sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items) return } func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) { o := orm.NewOrm() sql := ` SELECT * FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeArticle, err error) { o := orm.NewOrm() sql := ` SELECT * FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_date DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return }