12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_clpt/utils"
- "strconv"
- "time"
- )
- 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:"布局时间"`
- PublishDate string `description:"发布时间"`
- UpdateTime string `description:"更新时间"`
- IsRed bool `description:"是否标记红点"`
- IsHot bool `description:"是否是热门"`
- IsFollow bool `description:"是否关注"`
- FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
- 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"`
- Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
- 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
- }
- type TacticsListTimeResp struct {
- Paging *paging.PagingItem
- MatchTypeName string `description:"匹配类型"`
- CategoryImgUrlPc string `description:"图片"`
- List []*TimeLineReportItem
- }
- // 报告搜索start
- type ReoprtSearchResp struct {
- Paging *paging.PagingItem
- ListHz []*ArticleResearchResp `description:"弘则报告"`
- ListYx []*ArticleResearchResp `description:"研选报告"`
- }
- // 搜索资源包 start
- type SearchResourceResp struct {
- ListHz []*IndustrialManagement `description:"弘则"`
- ListYx []*IndustrialManagement `description:"研选"`
- }
- type ArticleIdReq struct {
- ArticleId int `description:"文章id"`
- PlaySeconds int `description:"播放时长"`
- PageRouter string `description:"页面路径"`
- ReportType int `description:"2本周研究汇总、3上周纪要汇总"`
- }
- // 获取列表数量
- 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 GetReoprtSearchCountYx(condition string) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT( 1 ) AS count
- FROM
- cygx_article AS a
- WHERE
- 1 = 1`
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- func GetReoprtSearchCountHz(condition string) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- COUNT( 1 ) AS count
- FROM
- cygx_article AS a
- WHERE
- 1 = 1`
- 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 GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- art.article_id,
- art.title,
- art.publish_date,
- 1 AS resource
- FROM
- cygx_article AS art
- WHERE
- art.publish_status = 1
- AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
- SELECT
- art.product_interior_id AS article_id,
- art.title,
- art.publish_time AS publish_date,
- 2 AS resource
- FROM
- cygx_product_interior AS art
- WHERE
- art.STATUS = 1
- AND art.visible_range = 1
- AND art.match_type_id = ` + strconv.Itoa(categoryId)
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql).QueryRow(&total)
- sql += ` ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
- return
- }
- // 获取行业报告列表
- func GetReportAndproductIndustrylListimg(categoryId, userId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- art.article_id,
- art.report_id,
- art.body,
- art.annotation,
- art.abstract,
- art.category_id,
- art.title,
- art.publish_date,
- 1 AS resource ,
- ( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = art.article_id ) AS readnum
- FROM
- cygx_article AS art
- WHERE
- art.publish_status = 1
- AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
- UNION ALL
- SELECT
- art.product_interior_id AS article_id,
- 0 AS report_id,
- art.body,
- "",
- art.abstract,
- 0 as category_id,
- art.title,
- art.publish_time AS publish_date,
- 2 AS resource ,
- ( SELECT COUNT( 1 ) FROM cygx_product_interior_history AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.product_interior_id = art.product_interior_id ) AS readnum
- FROM
- cygx_product_interior AS art
- WHERE
- art.STATUS = 1
- AND art.visible_range = 1
- AND art.match_type_id = ` + strconv.Itoa(categoryId)
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql).QueryRow(&total)
- sql += ` ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
- return
- }
- // 列表
- 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,
- MIN( a.publish_date ) AS min_report_time,
- 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
- }
- // 产业下所关联的文章、产品内测分类列表 2023-04-14
- func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- map.match_type_name,
- map.sort,
- map.id,
- map.id AS category_id
- FROM
- cygx_report_mapping_cygx AS map
- INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
- INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
- INNER JOIN cygx_article AS art ON art.category_id = cl.category_id
- INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
- WHERE
- 1 = 1
- AND 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 = ?
- GROUP BY
- map.match_type_name UNION ALL
- SELECT
- map.match_type_name,
- map.sort,
- map.id,
- map.id AS category_id
- FROM
- cygx_report_mapping_cygx AS map
- INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
- INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id
- INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
- WHERE
- 1 = 1
- AND art.STATUS = 1
- AND art.visible_range = 1
- AND man_g.industrial_management_id = ?
- GROUP BY
- map.match_type_name ORDER BY id ASC , sort DESC `
- _, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
- return
- }
- // 获取产业报告列表
- func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- art.article_id,
- art.body,
- art.annotation,
- art.abstract,
- art.category_id,
- art.title,
- art.publish_date,
- ( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = art.article_id ) AS readnum ,
- 1 AS resource
- FROM
- cygx_article AS art
- INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
- WHERE
- art.publish_status = 1
- AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
- AND art.is_class = 1
- AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + `
- GROUP BY
- art.article_id UNION ALL
- SELECT
- art.product_interior_id AS article_id,
- art.body,
- "",
- art.abstract,
- 0 as category_id,
- art.title,
- art.publish_time AS publish_date,
- ( SELECT COUNT( 1 ) FROM cygx_product_interior_history AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.product_interior_id = art.product_interior_id ) AS readnum ,
- 2 AS resource
- FROM
- cygx_product_interior AS art
- INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
- WHERE
- art.STATUS = 1
- AND art.visible_range = 1
- AND art.match_type_id = ` + strconv.Itoa(categoryId) + `
- AND man_g.industrial_management_id = ` + strconv.Itoa(industrialManagementId) + `
- GROUP BY
- art.product_interior_id `
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql, pars).QueryRow(&total)
- sql += ` ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).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 article_id < 1000000 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 = ? )
- AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
- AND user_id = ? `
- err = o.Raw(sql, industrialManagementId, categoryId, 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 IN (SELECT
- category_id
- FROM
- cygx_report_mapping
- WHERE
- chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
- AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
- err = o.Raw(sql, industrialManagementId, categoryId, 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:"产业名称"`
- IsFollow bool `description:"是否关注"`
- FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
- FllowNum int `description:"关注数量"`
- IsNew bool `description:"是否新标签"`
- IsHot bool `description:"是否新标签"`
- PublishDate string `description:"发布时间"`
- ArticleReadNum int `description:"文章阅读数量"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- MinReportTime string `description:"报告最早发布时间"`
- 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 []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- ac.id,
- a.article_id,
- a.category_id,
- a.title,
- a.annotation,
- a.publish_date,
- a.article_type_id,
- m.chart_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_two
- 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
- }
- // 研选报告收藏榜单列表
- func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- ac.id,
- a.category_id,
- '买方研选' as chart_permission_name,
- a.article_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.article_type_id,
- d.nick_name,
- d.department_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 DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collection_num
- FROM
- cygx_article AS a
- INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1
- AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, a.publish_date DESC`
- sql += ` LIMIT ?`
- _, err = o.Raw(sql, pars, limit).QueryRows(&items)
- return
- }
- // 获取产业报告+晨会点评列表
- func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.id,
- a.article_id,
- a.title,
- a.publish_date
- 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 a.is_class = 1
- AND man_g.industrial_management_id = ? GROUP BY a.article_id UNION ALL
- SELECT
- mmc.id,
- 0,
- mmc.content AS title,
- mm.meeting_time AS publish_data
- FROM
- cygx_morning_meeting_review_chapter AS mmc
- INNER JOIN cygx_morning_meeting_reviews AS mm
- WHERE
- mm.id = mmc.meeting_id
- AND mm.STATUS = 1
- AND mmc.industry_id = ? `
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql, industrialManagementId, industrialManagementId).QueryRow(&total)
- sql += ` ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
- return
- }
- type TimeLineReportItem struct {
- Id int `description:"文章或晨报点评id"`
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- //PublishTime string `description:"发布时间"`
- PublishDate string `description:"发布时间"`
- Content string `description:"内容"`
- VideoUrl string `description:"视频链接"`
- VoiceUrl string `description:"音频链接"`
- IsHaveVideo bool `description:"是否包含视频"`
- ImgUrlPc string `description:"pc图片"`
- SubCategoryName string `description:"二级分类"`
- IsRed bool `description:"是否标红"`
- Readnum int `description:"阅读数量"`
- Resource int `description:"来源类型,1:文章、2:产品内测、3:晨报点评 4:活动回放视频 5:活动回放音频 "`
- Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
- LinkArticleId int `description:"晨会精华报告ID链接"`
- ListSubject []*CygxIndustrialSubject `description:"标的列表"`
- }
- // 获取产业报告+晨会点评列表
- func GetTimeLineReportIndustrialListTime(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- *
- FROM
- (
- SELECT
- a.article_id AS id,
- a.article_id,
- a.title,
- a.publish_date,
- a.video_url,
- '' AS mi,
- a.sub_category_name,
- '' AS content,
- 1 AS resource,
- 0 AS type,
- ( 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 a.is_class = 1
- AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
- SELECT
- mmc.id,
- 0 as article_id,
- mmc.title,
- mm.publish_time AS publish_date,
- '' AS video_url,
- '' AS voice_url,
- '时间线' AS sub_category_name,
- mmc.content,
- 3 AS resource,
- 0 AS type,
- 0 AS readnum
- FROM
- cygx_morning_meeting_review_chapter AS mmc
- INNER JOIN cygx_morning_meeting_reviews AS mm
- WHERE
- mm.id = mmc.meeting_id
- AND mm.STATUS = 1
- AND mmc.industry_id = ? UNION ALL
- SELECT
- p.product_interior_id AS id,
- p.product_interior_id as article_id,
- p.title,
- p.publish_time AS publish_date,
- '' AS video_url,
- '' AS voice_url,
- '' AS sub_category_name,
- '' AS content,
- 2 AS resource,
- 0 AS type,
- 0 AS readnum
- FROM
- cygx_product_interior AS p
- INNER JOIN cygx_product_interior_industrial_group_management AS pm
- WHERE
- p.product_interior_id = pm.product_interior_id
- AND p.visible_range = 1
- AND pm.industrial_management_id = ? UNION ALL
- SELECT
- cav.video_id AS id,
- 0 as article_id,
- cav.video_name AS title,
- ca.activity_time AS publish_time,
- cav.video_url AS video_url,
- '' AS voice_url,
- '' AS sub_category_name,
- '' AS content,
- 4 AS resource,
- 2 AS type,
- ( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.activity_id = ca.activity_id ) AS readnum
- FROM
- cygx_activity AS ca
- INNER JOIN cygx_activity_video AS cav ON ca.activity_id = cav.activity_id
- INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
- WHERE
- cam.industrial_management_id = ? AND cam.source = 1 UNION ALL
- SELECT
- ca.activity_id AS id,
- 0 as article_id,
- cavo.voice_name AS title,
- ca.activity_time AS publish_time,
- '' AS video_url,
- cavo.voice_url AS voice_url,
- '' AS sub_category_name,
- '' AS content,
- 5 AS resource,
- 1 AS type,
- ( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.activity_id = ca.activity_id ) AS readnum
- FROM
- cygx_activity AS ca
- INNER JOIN cygx_activity_voice AS cavo ON ca.activity_id = cavo.activity_id
- INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
- WHERE
- cam.industrial_management_id = ? AND cam.source = 1
- ) AS t`
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&total)
- sql += ` ORDER BY
- t.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
- return
- }
- // 获取产业报告+晨会点评列表
- func GetTimeLineReportIndustrialListRed(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- *
- FROM
- (
- SELECT
- a.article_id AS id,
- a.title,
- a.publish_date ,
- a.video_url,
- a.sub_category_name,
- '' AS content,
- ( 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 a.is_class = 1
- AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
- SELECT
- mmc.id,
- '' AS title,
- mm.publish_time AS publish_date,
- '' AS video_url,
- '时间线' AS sub_category_name,
- mmc.content,
- 0 AS readnum
- FROM
- cygx_morning_meeting_review_chapter AS mmc
- INNER JOIN cygx_morning_meeting_reviews AS mm
- WHERE
- mm.id = mmc.meeting_id
- AND mm.STATUS = 1
- AND mmc.industry_id = ?
- ) AS t
- `
- sql += ` ORDER BY
- t.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
- return
- }
- type IndustrialPublishdate struct {
- PublishDate string `description:"发布时间"`
- IndustrialManagementId int `description:"产业D"`
- }
- // 标的列表
- func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialPublishdate, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- mmc.id,
- 0,
- mmc.industry_id AS industrial_management_id,
- mmc.content AS title,
- MAX( mm.meeting_time ) AS publish_date
- FROM
- cygx_morning_meeting_review_chapter AS mmc
- INNER JOIN cygx_morning_meeting_reviews AS mm
- WHERE
- mm.id = mmc.meeting_id
- AND mm.STATUS = 1
- AND mmc.industry_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)
- GROUP BY industrial_management_id ORDER BY publish_date DESC `
- _, err = o.Raw(sql, industrialIdArr).QueryRows(&items)
- return
- }
- // 报告榜单start
- type ArticleReportBillboardResp struct {
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- PublishDate string `description:"发布时间"`
- PermissionName string `description:"行业名称"`
- DepartmentId int `description:"作者Id"`
- NickName string `description:"作者昵称"`
- IsCollect bool `description:"本人是否收藏"`
- Pv int `description:"PV"`
- CollectNum int `description:"收藏人数"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- ArticleTypeId int `description:"文章类型ID判断是否是研选使用"`
- IsResearch bool `description:"是否属于研选"`
- ArticleTypeName string `description:"文章类型名称"`
- IsSpecial bool `description:"是否为研选专栏"`
- IsSpecialInt int `description:"是否为研选专栏"`
- SpecialTags string `description:"研选专栏标签"`
- MyCollectNum int `description:"本人是否收藏"`
- SpecialType int `description:"专栏类型 1:笔记,2:观点"`
- UserId int `description:"作者id"`
- IndustryTagStr string `description:"研选专栏行业标签"`
- CompanyTagsStr string `description:"研选专栏公司标签"`
- IndustryTags []string `description:"研选专栏行业标签"`
- CompanyTags []string `description:"研选专栏公司标签"`
- SpecialColumnId int `description:"专栏栏目id"`
- List []*IndustrialManagementIdInt
- }
- type ArticleReportBillboardLIstPageResp struct {
- List []*ArticleReportBillboardResp
- Paging *paging.PagingItem
- }
- type ArticleResearchListResp struct {
- Paging *paging.PagingItem
- List []*ArticleResearchResp
- }
- type ArticleResearchResp struct {
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- Annotation string `description:"核心观点"`
- Abstract string `description:"摘要"`
- PublishDate string `description:"发布时间"`
- DepartmentId int `description:"作者Id"`
- NickName string `description:"作者昵称"`
- IsCollect bool `description:"本人是否收藏"`
- Pv int `description:"PV"`
- CollectNum int `description:"收藏人数"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- ArticleTypeId int `description:"文章类型ID"`
- ArticleTypeName string `description:"类型名称"`
- ButtonStyle string `description:"按钮展示样式"`
- ImgUrlPc string `description:"图片链接"`
- List []*IndustrialManagementIdInt `description:"产业列表"`
- ListSubject []*IndustrialSubject `description:"标的列表"`
- IsSpecial bool `description:"是否为研选专栏"`
- IndustryTags []string `description:"研选专栏行业标签"`
- CompanyTags []string `description:"研选专栏公司标签"`
- SpecialColumnId int `description:"专栏栏目id"`
- TopTime int `description:"置顶时间"`
- Resource int `description:"来源类型,1:文章、2:产品内测、3:FICC研报"`
- ReportId int `description:"FICC研报ID"`
- }
- // 获取数量
- func GetArticleResearchCount(condition string, pars []interface{}, needYanxuanSpecial bool) (count int, err error) {
- o := orm.NewOrm()
- sqlCount := `SELECT COUNT( 1 ) AS count FROM
- cygx_article AS a
- WHERE
- 1 = 1 AND a.publish_status = 1` + condition
- if needYanxuanSpecial {
- sqlCount = `SELECT SUM(count) AS count FROM (` + sqlCount + `
- UNION ALL
- SELECT COUNT( 1 ) AS count FROM
- cygx_yanxuan_special AS a WHERE
- 1 = 1 AND a.status = 3) AS c`
- }
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.article_type_id,
- d.nick_name,
- d.department_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 DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
- 0 AS is_special,
- 0 AS special_type,
- 0 AS special_column_id,
- '' AS company_tags,
- '' AS industry_tags,
- a.top_time
- 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
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1 AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- if needYanxuanSpecial {
- sql += `UNION ALL
- SELECT
- a.id AS article_id,
- a.title AS title,
- '' AS body,
- a.content AS annotation,
- '' AS abstract,
- a.publish_time AS publish_date,
- -1 AS article_type_id,
- b.nick_name AS nick_name,
- 0 AS department_id,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
- 0 AS collect_num_order,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
- 1 AS is_special,
- a.type AS special_type,
- b.id AS special_column_id,
- a.company_tags AS company_tags,
- a.industry_tags AS industry_tags,
- 0 as top_time
- FROM
- cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
- WHERE
- 1 = 1 AND a.status = 3 `
- sql += ` GROUP BY article_id ORDER BY top_time DESC , publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
- } else {
- sql += ` GROUP BY a.article_id ORDER BY top_time DESC , a.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
- }
- return
- }
- func GetArticleResearchListYx(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.article_type_id,
- d.nick_name,
- d.department_id,
- 0 AS is_special,
- 0 as pv,
- 0 as collect_num,
- 0 AS special_type,
- 0 AS special_column_id,
- '' AS company_tags,
- '' AS industry_tags,
- a.top_time
- FROM
- cygx_article AS a
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1 AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- if needYanxuanSpecial {
- sql += `UNION ALL
- SELECT
- a.id AS article_id,
- a.title AS title,
- '' AS body,
- a.content AS annotation,
- '' AS abstract,
- a.publish_time AS publish_date,
- -1 AS article_type_id,
- b.nick_name AS nick_name,
- 0 AS department_id,
- 1 AS is_special,
- a.pv,
- a.article_collect_num as collect_num,
- a.type AS special_type,
- b.id AS special_column_id,
- a.company_tags AS company_tags,
- a.industry_tags AS industry_tags,
- 0 as top_time
- FROM
- cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
- WHERE
- 1 = 1 AND a.status = 3 `
- }
- sql += ` GROUP BY article_id ORDER BY top_time DESC , publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (total int, items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.article_type_id,
- d.nick_name,
- d.department_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 DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
- 0 AS is_special,
- 0 AS special_type,
- 0 AS special_column_id,
- '' AS company_tags,
- '' AS industry_tags
- 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
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1 AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- if needYanxuanSpecial {
- sql += `UNION ALL
- SELECT
- a.id AS article_id,
- a.title AS title,
- '' AS body,
- a.content AS annotation,
- '' AS abstract,
- a.publish_time AS publish_date,
- -1 AS article_type_id,
- b.nick_name AS nick_name,
- 0 AS department_id,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
- 0 AS collect_num_order,
- ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
- 1 AS is_special,
- a.type AS special_type,
- b.id AS special_column_id,
- a.company_tags AS company_tags,
- a.industry_tags AS industry_tags
- FROM
- cygx_yanxuan_special AS a
- JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
- WHERE
- 1 = 1 AND a.status = 3 ` + conditionYxSpecial
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql, userId, userId, pars).QueryRow(&total)
- sql += ` GROUP BY article_id ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
- } else {
- sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
- }
- return
- }
- func GetArticleResearchListHz(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.report_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.category_id,
- a.article_type_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 DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
- ( 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 AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type IndustrialManagementHotListResp struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*IndustrialManagementHotResp
- }
- // 获取数量
- func GetThemeHeatListCount(condition string) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
- cygx_industrial_management AS m
- LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
- LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
- LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
- WHERE
- 1 = 1 AND a.publish_status = 1 ` + condition
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- // 产业列表
- func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.industry_name,
- m.industrial_management_id,
- m.article_read_num,
- MAX( a.publish_date ) AS publish_date,
- MIN(a.publish_date) AS min_report_time,
- IFNULL( f.follow_type_order, 0 ) AS follow_type_order,
- ( SELECT count( 1 ) FROM cygx_industry_fllow AS f WHERE f.industrial_management_id = m.industrial_management_id AND user_id =? AND f.type = 1 ) AS fllow_num,
- m.yanxuan_article_read_num + m.activity_num AS sum_num
- FROM
- cygx_industrial_management AS m
- LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
- LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
- LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
- LEFT JOIN cygx_industry_fllow AS f ON f.industrial_management_id = m.industrial_management_id AND f.user_id = ?
- WHERE
- 1 = 1
- AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
- _, err = o.Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
- return
- }
- type GetThemeAericleListResp struct {
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- PublishDate string `description:"发布时间"`
- SubjectName string `description:"标的名称"`
- IndustrialSubjectId int `description:"标的ID"`
- DepartmentId int `description:"作者Id"`
- NickName string `description:"作者昵称"`
- Pv int `description:"PV"`
- CollectNum int `description:"收藏人数"`
- FllowNum int `description:"关注数量"`
- MyCollectNum int `description:"本人是否收藏"`
- IsCollect bool `description:"本人是否收藏"`
- }
- // 主题详情start
- type GetThemeDetailResp struct {
- IndustrialManagementId int `description:"产业Id"`
- IndustryName string `description:"产业名称"`
- IsFollow bool `description:"是否关注"`
- FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
- ListSubject []*IndustrialSubject `description:"标的列表"`
- List []*ArticleResearchResp
- }
- // 主题详情start
- type GetThemeDetailListResp struct {
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- PublishDate string `description:"发布时间"`
- SubjectName string `description:"标的名称"`
- IndustrialSubjectId int `description:"标的id"`
- DepartmentId int `description:"作者Id"`
- NickName string `description:"作者昵称"`
- Pv int `description:"PV"`
- CollectNum int `description:"收藏人数"`
- IndustrialManagementId int `description:"产业Id"`
- IndustryName string `description:"产业名称"`
- FllowNum int `description:"关注数量"`
- MyCollectNum int `description:"本人是否收藏"`
- IsCollect bool `description:"本人是否收藏"`
- }
- type GetThemeAericleListBuSubjectResp struct {
- SubjectName string `description:"标的名称"`
- List []*GetThemeAericleListResp
- }
- // 列表
- func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*ArticleListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- a.body,
- a.annotation,
- a.abstract,
- a.publish_date,
- a.article_type_id,
- d.nick_name,
- d.department_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
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1
- AND m.industrial_management_id = ?
- AND publish_status = 1 ` + condition + `
- ORDER BY
- publish_date DESC`
- _, err = o.Raw(sql, userId, industrialManagementId).QueryRows(&items)
- return
- } //end
- func GetDepartmentlistCount(condition string) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- count(*) AS count
- FROM
- (
- SELECT
- COUNT( 1 ) AS count
- FROM
- cygx_article_department AS d
- INNER JOIN cygx_article AS a ON d.department_id = a.department_id
- WHERE
- 1 = 1
- AND a.article_type_id > 0
- AND publish_status = 1
- GROUP BY
- d.department_id
- ) c `
- err = o.Raw(sql).QueryRow(&count)
- return
- }
- type IndustrialReadNum struct {
- IndustrialManagementId int `description:"产业id"`
- Readnum int `description:"阅读次数"`
- }
- // 获取该产业下文章的用户阅读次数-小红点用
- func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
- o := orm.NewOrm()
- sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
- SELECT man_g.industrial_management_id,( 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 a.is_class = 1
- AND man_g.industrial_management_id IN (` + industrialIds + `)
- AND a.publish_date > ?
- GROUP BY a.article_id ORDER BY publish_date DESC
- ) AS a GROUP BY industrial_management_id`
- _, err = o.Raw(sql, createtime).QueryRows(&items)
- return
- }
- // 获取行业报告列表
- func GetReportAndproductIndustrylListimgZhouqi(condition string, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- art.article_id,
- art.report_id,
- art.body,
- art.annotation,
- art.abstract,
- art.category_id,
- art.title,
- art.publish_date,
- 1 AS resource
- FROM
- cygx_article AS art
- WHERE
- art.publish_status = 1 AND category_name = '周期' ` + condition
- totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSql).QueryRow(&total)
- sql += ` ORDER BY publish_date DESC LIMIT ?,? `
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
- return
- }
|