123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "strconv"
- )
- type IndustrialManagementList struct {
- Paging *paging.PagingItem
- List []*IndustrialManagement
- }
- type IndustrialManagement struct {
- IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
- IndustryName string `description:"产业名称"`
- ChartPermissionId int `description:"权限id"`
- ChartPermissionName string `description:"权限名称"`
- LayoutTime string `description:"布局时间"`
- UpdateTime string `description:"更新时间"`
- IsRed bool `description:"是否标记红点"`
- IsHot bool `description:"是否是热门"`
- IsFollow bool `description:"是否关注"`
- IsNew bool `description:"是否展示 NEW 标签"`
- IsShowRoadshow bool `description:"是否展示 微路演 标签"`
- ArticleReadNum int `description:"文章阅读数量"`
- ArticleId int `description:"文章id"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
- MinReportTime string `description:"报告最早发布时间"`
- IndustryVideo *MicroVideoSimpleInfo
- AuthInfo *UserPermissionAuthInfo
- }
- type MicroVideoSimpleInfo struct {
- Id int `description:"视频ID"`
- Title string `description:"标题"`
- ResourceUrl string `description:"链接"`
- BackgroundImg string `description:"背景图"`
- PlaySeconds int `description:"音视频时长"`
- DetailImgUrl string `description:"产业详情页背景图"`
- ChartPermissionId int `description:"行业ID"`
- ChartPermissionName string `description:"行业名称"`
- }
- type TacticsListResp struct {
- Paging *paging.PagingItem
- MatchTypeName string `description:"匹配类型"`
- CategoryImgUrlPc string `description:"图片"`
- List []*HomeArticle
- }
- //报告搜索start
- type ReoprtSearchResp struct {
- Paging *paging.PagingItem
- ListHz []*ArticleCollectionResp `description:"弘则报告"`
- }
- //搜索资源包 start
- type SearchResourceResp struct {
- ListHz []*IndustrialManagement `description:"弘则"`
- }
- //用户收藏榜start
- //type IndustrialManagementHotResp struct {
- // IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
- // IndustryName string `description:"产业名称"`
- // IsFollw bool `description:"是否关注"`
- // FllowNum int `description:"关注数量"`
- // IsNew bool `description:"是否新标签"`
- // IsHot bool `description:"是否新标签"`
- // PublishDate string `description:"发布时间"`
- // ArticleReadNum int `description:"文章阅读数量"`
- // Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- // IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
- //}
- //获取列表数量
- func GetReoprtSearchCount(condition string) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT( 1 ) AS count
- FROM
- cygx_article AS a
- WHERE
- 1 = 1
- AND a.article_id < 1000000 `
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- //列表
- func GetReoprtSearchList(condition string, userId, startSize, pageSize int) (items []*ArticleCollectionResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.body,
- a.abstract,
- a.annotation,
- a.category_id,
- a.category_name,
- date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
- m.industry_name,
- m.industrial_management_id,
- ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
- FROM
- cygx_article AS a
- LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- WHERE
- 1 = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
- return
- } //end
- //列表
- func GetSearchResourceList(condition string) (items []*IndustrialManagement, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.industry_name,
- m.chart_permission_id,
- m.industrial_management_id,
- MAX( a.publish_date ) as publish_date_order,
- date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
- FROM
- cygx_industrial_management AS m
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
- INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
- WHERE
- 1 = 1
- AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- //标的列表
- func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.subject_name,
- m.industrial_management_id,
- m.industrial_subject_id
- FROM
- cygx_article AS a
- INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
- INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
- WHERE
- 1 = 1`
- if condition != "" {
- sql += condition
- }
- sql += ` AND publish_status = 1
- GROUP BY
- m.industrial_subject_id
- ORDER BY
- publish_date DESC`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- } //end
- //产业下所关联的文章分类列表
- func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
- o := orm.NewOrm()
- sql := `SELECT map.match_type_name,map.category_id
- FROM cygx_report_mapping AS map
- INNER JOIN cygx_article AS art ON art.category_id = map.category_id
- INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
- WHERE map.report_type = 2
- AND map.is_report = 1
- AND art.is_report = 1
- AND art.publish_status = 1
- AND man_g.industrial_management_id =?
- AND map.chart_permission_id = ?
- GROUP BY map.match_type_name`
- _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
- return
- }
- //判断用户是否阅读该产业下,某一分类的文章
- func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT(1) count
- FROM
- cygx_article_history_record
- WHERE
- article_id = ( SELECT article_id FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND category_id = ? ORDER BY publish_date DESC LIMIT 0, 1 )
- AND user_id = ? `
- err = o.Raw(sql, industrialManagementId, categoryId, userId).QueryRow(&count)
- return
- }
- //获取最新文章
- func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
- err = o.Raw(sql, industrialManagementId, categoryId).QueryRow(&item)
- return
- }
- //列表
- func GetReoprtSearchListHz(condition string, userId int) (items []*ArticleCollectionResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.annotation,
- date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
- m.industry_name,
- m.industrial_management_id,
- ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
- FROM
- cygx_article AS a
- LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- WHERE
- 1 = 1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, userId).QueryRows(&items)
- return
- } //end
- //产业列表
- func GetSearchResourceListHz(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.industry_name,
- m.industrial_management_id,
- MAX( a.publish_date ) as publish_date_order,
- date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
- FROM
- cygx_industrial_management AS m
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
- INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
- WHERE
- 1 = 1
- AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
- if startSize > 0 || pageSize > 0 {
- sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
- }
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- //用户收藏榜start
- type IndustrialManagementHotResp struct {
- IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
- IndustryName string `description:"产业名称"`
- IsFollw bool `description:"是否关注"`
- FllowNum int `description:"关注数量"`
- IsNew bool `description:"是否新标签"`
- IsHot bool `description:"是否新标签"`
- PublishDate string `description:"发布时间"`
- ArticleReadNum int `description:"文章阅读数量"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
- }
- //搜索资源包 start
- type SearchReportAndResourceResp struct {
- ListHzResource []*IndustrialManagement `description:"弘则资源包"`
- ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
- Paging *paging.PagingItem `description:"弘则报告分页"`
- }
- //报告收藏榜单列表
- func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*HomeArticle, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- ac.id,
- a.article_id,
- a.title,
- date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
- m.chart_permission_name AS permission_name,
- COUNT(ac.id) AS collection_num
- FROM
- cygx_article AS a
- INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
- INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
- WHERE
- 1 = 1
- AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
- sql += ` LIMIT ?`
- _, err = o.Raw(sql, pars, limit).QueryRows(&items)
- return
- }
|