report.go 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "strconv"
  6. "time"
  7. //"github.com/rdlucklib/rdluck_tools/paging"
  8. )
  9. type IndustrialManagementList struct {
  10. Paging *paging.PagingItem
  11. List []*IndustrialManagement
  12. }
  13. type IndustrialManagement struct {
  14. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  15. IndustryName string `description:"产业名称"`
  16. RecommendedIndex int `description:"推荐指数"`
  17. CategoryId int `description:"文章分类ID"`
  18. LayoutTime string `description:"布局时间"`
  19. UpdateTime string `description:"更新时间"`
  20. MinReportTime string `description:"报告最早发布时间"`
  21. IsRed bool `description:"是否标记红点"`
  22. IsTop bool `description:"是否置顶"`
  23. IsHot bool `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
  24. IsFollow int `description:"是否关注"`
  25. IsNew bool `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
  26. Analyst string `description:"分析师"`
  27. ArticleReadNum int `description:"文章阅读数量"`
  28. OneMonFollowNum int `description:"近一个月关注增量"`
  29. AnalystList []*IndustrialAnalyst `description:"分析师列表"`
  30. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  31. ChartPermissionId int `description:"行业ID"`
  32. PermissionName string `description:"行业名称"`
  33. IndustryVideo *MicroVideoSimpleInfo
  34. AuthInfo *UserPermissionAuthInfo
  35. ArticleId int `description:"文章id"`
  36. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  37. }
  38. type MicroVideoSimpleInfo struct {
  39. Id int `description:"视频ID"`
  40. Title string `description:"标题"`
  41. ResourceUrl string `description:"链接"`
  42. BackgroundImg string `description:"背景图"`
  43. PlaySeconds int `description:"音视频时长"`
  44. DetailImgUrl string `description:"产业详情页背景图"`
  45. ChartPermissionId int `description:"行业ID"`
  46. ChartPermissionName string `description:"行业名称"`
  47. }
  48. type IndustrialAnalyst struct {
  49. AnalystName string `description:"分析师名称"`
  50. IndustrialManagementId int `description:"产业id"`
  51. }
  52. type IndustrialSubject struct {
  53. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  54. IndustrialManagementId int `description:"产业id"`
  55. SubjectName string `description:"标的名称"`
  56. IndustryName string `description:"产业名称"`
  57. LayoutTime string `description:"产业布局时间"`
  58. }
  59. // 获取产业报告数量
  60. func GetReportIndustrialCount(categoryId, industrialManagementId int) (count int, err error) {
  61. o := orm.NewOrm()
  62. sql := `SELECT COUNT(1) count
  63. FROM
  64. cygx_article AS a
  65. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  66. WHERE
  67. a.publish_status = 1
  68. AND category_id IN (SELECT
  69. category_id
  70. FROM
  71. cygx_report_mapping
  72. WHERE
  73. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  74. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  75. AND a.is_class = 1
  76. AND man_g.industrial_management_id = ? `
  77. err = o.Raw(sql, industrialManagementId).QueryRow(&count)
  78. return
  79. }
  80. // 获取产业报告列表
  81. func GetReportIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
  82. o := orm.NewOrm()
  83. 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
  84. FROM
  85. cygx_article AS a
  86. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  87. WHERE
  88. a.publish_status = 1
  89. AND category_id IN (SELECT
  90. category_id
  91. FROM
  92. cygx_report_mapping
  93. WHERE
  94. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  95. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  96. AND a.is_class = 1
  97. AND man_g.industrial_management_id = ?`
  98. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  99. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  100. return
  101. }
  102. // 获取产业报告列表
  103. func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
  104. o := orm.NewOrm()
  105. sql := `SELECT
  106. art.article_id,
  107. art.title,
  108. art.publish_date,
  109. ( 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 ,
  110. 1 AS resource
  111. FROM
  112. cygx_article AS art
  113. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  114. WHERE
  115. art.publish_status = 1
  116. AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
  117. AND art.is_class = 1
  118. AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + `
  119. GROUP BY
  120. art.article_id UNION ALL
  121. SELECT
  122. art.product_interior_id AS article_id,
  123. art.title,
  124. art.publish_time AS publish_date,
  125. ( 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 ,
  126. 2 AS resource
  127. FROM
  128. cygx_product_interior AS art
  129. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  130. WHERE
  131. art.STATUS = 1
  132. AND art.visible_range = 1
  133. AND art.match_type_id = ` + strconv.Itoa(categoryId) + `
  134. AND man_g.industrial_management_id = ` + strconv.Itoa(industrialManagementId) + `
  135. GROUP BY
  136. art.product_interior_id `
  137. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  138. err = o.Raw(totalSql, pars).QueryRow(&total)
  139. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  140. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  141. return
  142. }
  143. // 产业下所关联的文章分类列表
  144. func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  145. o := orm.NewOrm()
  146. sql := `SELECT map.match_type_name,map.category_id
  147. FROM cygx_report_mapping AS map
  148. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  149. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  150. WHERE map.report_type = 2
  151. AND map.is_report = 1
  152. AND art.is_report = 1
  153. AND art.publish_status = 1
  154. AND man_g.industrial_management_id =?
  155. AND map.chart_permission_id = ?
  156. GROUP BY map.match_type_name`
  157. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  158. return
  159. }
  160. // 产业下所关联的文章分类列表 2022-10-13
  161. func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  162. o := orm.NewOrm()
  163. sql := `SELECT map.match_type_name,map.category_id
  164. FROM cygx_report_mapping AS map
  165. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  166. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  167. WHERE map.report_type = 2
  168. AND map.is_report = 1
  169. AND art.is_report = 1
  170. AND art.publish_status = 1
  171. AND man_g.industrial_management_id =?
  172. GROUP BY map.match_type_name`
  173. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  174. return
  175. }
  176. // 产业下所关联的文章、产品内测分类列表 2023-04-14
  177. func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  178. o := orm.NewOrm()
  179. sql := `SELECT
  180. map.match_type_name,
  181. map.id AS category_id
  182. FROM
  183. cygx_report_mapping_cygx AS map
  184. INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
  185. INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
  186. INNER JOIN cygx_article AS art ON art.category_id = cl.category_id
  187. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  188. WHERE
  189. 1 = 1
  190. AND map.report_type = 2
  191. AND map.is_report = 1
  192. AND art.is_report = 1
  193. AND art.publish_status = 1
  194. AND man_g.industrial_management_id = ?
  195. GROUP BY
  196. map.match_type_name UNION ALL
  197. SELECT
  198. map.match_type_name,
  199. map.id AS category_id
  200. FROM
  201. cygx_report_mapping_cygx AS map
  202. INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
  203. INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id
  204. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  205. WHERE
  206. 1 = 1
  207. AND art.STATUS = 1
  208. AND art.visible_range = 1
  209. AND man_g.industrial_management_id = ?
  210. GROUP BY
  211. map.match_type_name`
  212. _, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
  213. return
  214. }
  215. // 判断用户是否阅读该产业下,某一分类的文章
  216. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  217. o := orm.NewOrm()
  218. sql := `SELECT
  219. COUNT(1) count
  220. FROM
  221. cygx_article_history_record
  222. WHERE
  223. 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 IN (SELECT
  224. category_id
  225. FROM
  226. cygx_report_mapping
  227. WHERE
  228. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  229. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  230. AND user_id = ? `
  231. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  232. return
  233. }
  234. // 获取最新文章
  235. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  236. o := orm.NewOrm()
  237. //sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_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`
  238. 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
  239. category_id
  240. FROM
  241. cygx_report_mapping
  242. WHERE
  243. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  244. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  245. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  246. return
  247. }
  248. // 获取最新文章
  249. func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
  250. o := orm.NewOrm()
  251. sql := ` SELECT * FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
  252. err = o.Raw(sql, categoryId).QueryRow(&item)
  253. return
  254. }
  255. func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagementIds string, err error) {
  256. sql := `SELECT GROUP_CONCAT(DISTINCT industrial_management_id SEPARATOR ',') AS industrial_management_ids FROM cygx_industrial_management WHERE` + condition
  257. o := orm.NewOrm()
  258. err = o.Raw(sql).QueryRow(&industrialManagementIds)
  259. return
  260. }
  261. type ReportArticleWhichIndustrial struct {
  262. ArticleId int `description:"文章id"`
  263. Title string `description:"标题"`
  264. PublishDate string `description:"发布时间"`
  265. IndustryName string `description:"产业名称"`
  266. SubjectName string `description:"标的名称"`
  267. NickName string `description:"作者昵称"`
  268. IsRed bool `description:"是否标记红点"`
  269. Readnum int `description:"阅读数量"`
  270. IsResearch bool `description:"是否属于研选"`
  271. Pv int `description:"PV"`
  272. ImgUrlPc string `description:"图片链接"`
  273. }
  274. type ReportArticleWhichIndustrialRepList struct {
  275. HaveResearch bool `description:"是否有研选权限"`
  276. Paging *paging.PagingItem `description:"分页数据"`
  277. NickName string `description:"作者昵称"`
  278. IndustryName string `description:"产业名称"`
  279. List []*ReportArticleWhichIndustrial
  280. }
  281. // 列表
  282. func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
  283. o := orm.NewOrm()
  284. sql := `SELECT
  285. art.* ,m.industry_name,d.nick_name,
  286. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  287. ( SELECT COUNT( 1 ) FROM cygx_article_history_record_newpv AS rec WHERE rec.user_id = ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum
  288. FROM
  289. cygx_article AS art
  290. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  291. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  292. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  293. WHERE 1 = 1
  294. AND art.publish_status = 1`
  295. if condition != "" {
  296. sql += condition
  297. }
  298. sql += ` LIMIT ?,?`
  299. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  300. return
  301. }
  302. func GetWhichDepartmentCount(condition string) (count int, err error) {
  303. o := orm.NewOrm()
  304. sql := `SELECT COUNT(1) count
  305. FROM
  306. cygx_article AS art
  307. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  308. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  309. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  310. WHERE 1 = 1
  311. AND art.publish_status = 1`
  312. if condition != "" {
  313. sql += condition
  314. }
  315. err = o.Raw(sql).QueryRow(&count)
  316. return
  317. }
  318. type IsShow struct {
  319. IsShow bool `description:"绝密内参按钮是否展示"`
  320. IsShowFreeButton bool `description:"免费送月卡按钮是否展示"`
  321. IsShowResearch bool `description:"研选是否展示限免"`
  322. IsShowChart bool `description:"图表是否展示限免"`
  323. IsShowList bool `description:"榜单是否展示"`
  324. LinkWxExplain string `description:"关注微信公众号链接说明地址"`
  325. YanXuan_Explain bool `description:"研选说明"`
  326. ActivitySpecialExplain string `description:"专项调研活动"`
  327. SearchTxtList SearchTxt `description:"搜索栏回显内容说明"`
  328. IsBelongRai bool `description:"是否属于权益内部人员"`
  329. }
  330. type SearchTxt struct {
  331. SummarySearch string `description:"素材库搜索说明"`
  332. ReportSearch string `description:"报告搜索说明"`
  333. YanXuanSearch string `description:"研选搜索说明"`
  334. ActivitySearch string `description:"活动搜索说明"`
  335. TabSearch string `description:"素材库搜索说明"`
  336. }
  337. // 获取用户是否有查看权限
  338. func GetUserIsAdminCount(mobile string) (count int, err error) {
  339. o := orm.NewOrm()
  340. sql := `SELECT COUNT(1) count FROM admin
  341. WHERE
  342. mobile = ?
  343. AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 ) AND enabled = 1`
  344. err = o.Raw(sql, mobile).QueryRow(&count)
  345. return
  346. }
  347. type ReportDetailRoadshow struct {
  348. ArticleId int `description:"报告Id"`
  349. Title string `description:"标题"`
  350. Department string `orm:"column(seller_and_mobile)"description:"作者"`
  351. PublishDate string `description:"发布时间"`
  352. VideoUrl string `description:"链接"`
  353. VideoPlaySeconds string `description:"时长"`
  354. VideoName string `description:"音频名称"`
  355. Abstract string `description:"摘要"`
  356. Body string `description:"内容"`
  357. CategoryName string `description:"行业名称"`
  358. ReportLink string `orm:"column(link_article_id)"description:"报告链接"`
  359. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  360. IsRoadShow bool `description:"是否是路演精华"`
  361. CategoryId int `description:"文章分类ID"`
  362. VisibleRange int `description:"设置可见范围1全部,0内部"`
  363. }
  364. type RoadshowDetailResp struct {
  365. Detail *ReportDetailRoadshow
  366. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  367. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  368. IsShow bool `description:"是否展示"`
  369. }
  370. func GetReportRoadshowDetailById(articleId int) (item *ReportDetailRoadshow, err error) {
  371. o := orm.NewOrm()
  372. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  373. err = o.Raw(sql, articleId).QueryRow(&item)
  374. return
  375. }
  376. type CygxIndustryAndArticleList struct {
  377. ArticleId int `orm:"column(article_id);pk"description:"报告id"`
  378. Title string `description:"标题"`
  379. PublishDate string `description:"发布时间"`
  380. IndustryName string `description:"产业名称"`
  381. SubjectName string `description:"标的名称"`
  382. }
  383. type CygxIndustrySearchList struct {
  384. ArtList []*CygxIndustryAndArticleList `description:"文章列表"`
  385. IndList []*IndustrialManagement `description:"产业列表"`
  386. }
  387. type CygxIndustrySearchListPc struct {
  388. DepartmentList []*CygxArticleDepartmentRepPc
  389. IndList []*IndustrialManagement `description:"产业列表"`
  390. }
  391. // 列表
  392. func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
  393. o := orm.NewOrm()
  394. sql := `SELECT
  395. art.title,
  396. art.article_id,
  397. art.publish_date
  398. FROM
  399. cygx_article AS art
  400. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  401. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = mg.article_id
  402. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  403. WHERE
  404. category_name LIKE '%研选%'
  405. AND art.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) GROUP BY sg.article_id )
  406. OR ( art.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management AS mg WHERE mg.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) GROUP BY mg.article_id ) AND category_name LIKE '%研选%' )
  407. GROUP BY
  408. art.article_id`
  409. _, err = o.Raw(sql).QueryRows(&items)
  410. return
  411. }
  412. func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
  413. o := orm.NewOrm()
  414. sql := `SELECT GROUP_CONCAT( DISTINCT a.article_id SEPARATOR ',' ) AS articleIds
  415. FROM cygx_article AS a
  416. WHERE subject_ids LIKE '%` + subjectId + `%'`
  417. err = o.Raw(sql).QueryRow(&articleIds)
  418. return
  419. } //end
  420. // 用户收藏榜start
  421. type ArticleCollectionResp struct {
  422. ArticleId int `description:"文章id"`
  423. Title string `description:"标题"`
  424. PublishDate string `description:"发布时间"`
  425. IndustrialManagementId int `description:"产业Id"`
  426. IndustryName string `description:"产业名称"`
  427. DepartmentId int `description:"作者Id"`
  428. NickName string `description:"作者昵称"`
  429. MyCollectNum int `description:"本人是否收藏"`
  430. IsCollect bool `description:"本人是否收藏"`
  431. Pv int `description:"PV"`
  432. CollectNum int `description:"收藏人数"`
  433. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  434. ArticleTypeId int `description:"文章类型ID"`
  435. List []*IndustrialManagementResp `description:"产业列表"`
  436. }
  437. type IndustrialManagementResp struct {
  438. IndustrialManagementId int `description:"产业Id"`
  439. IndustryName string `description:"产业名称"`
  440. ChartPermissionId int `description:"权限id"`
  441. }
  442. type ArticleCollectionLIstResp struct {
  443. List []*ArticleCollectionResp
  444. }
  445. // 研选报告收藏榜单列表
  446. func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleCollectionResp, err error) {
  447. o := orm.NewOrm()
  448. sql := `SELECT
  449. ac.id,
  450. a.category_id,
  451. a.article_id,
  452. a.title,
  453. a.body,
  454. a.annotation,
  455. a.abstract,
  456. a.publish_date,
  457. a.article_type_id,
  458. d.nick_name,
  459. d.department_id,
  460. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  461. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id ) AS collect_num,
  462. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collection_num
  463. FROM
  464. cygx_article AS a
  465. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  466. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  467. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  468. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  469. WHERE
  470. 1 = 1
  471. AND a.publish_status = 1 `
  472. if condition != "" {
  473. sql += condition
  474. }
  475. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, a.publish_date DESC`
  476. sql += ` LIMIT ?`
  477. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  478. return
  479. }
  480. // 列表
  481. func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  482. o := orm.NewOrm()
  483. sql := `SELECT
  484. a.article_id,
  485. a.title,
  486. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  487. m.industry_name,
  488. m.industrial_management_id,
  489. d.nick_name,
  490. d.department_id,
  491. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  492. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id ) AS collect_num,
  493. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
  494. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  495. FROM
  496. cygx_article AS a
  497. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  498. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  499. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  500. WHERE
  501. 1 = 1 AND a.publish_status = 1 `
  502. if condition != "" {
  503. sql += condition
  504. }
  505. _, err = o.Raw(sql, userId).QueryRows(&items)
  506. return
  507. } //end
  508. type ArticleResearchListResp struct {
  509. Paging *paging.PagingItem
  510. List []*ArticleResearchResp
  511. }
  512. type ArticleResearchResp struct {
  513. ArticleId int `description:"文章id"`
  514. Title string `description:"标题"`
  515. PublishDate string `description:"发布时间"`
  516. DepartmentId int `description:"作者Id"`
  517. NickName string `description:"作者昵称"`
  518. IsCollect bool `description:"本人是否收藏"`
  519. Pv int `description:"PV"`
  520. CollectNum int `description:"收藏人数"`
  521. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  522. ArticleTypeId int `description:"文章类型ID"`
  523. ArticleTypeName string `description:"类型名称"`
  524. ButtonStyle string `description:"按钮展示样式"`
  525. List []*IndustrialManagementResp `description:"产业列表"`
  526. }
  527. // 获取我的日程数量
  528. func GetArticleResearchCount(condition string, pars []interface{}) (count int, err error) {
  529. o := orm.NewOrm()
  530. sqlCount := `SELECT COUNT( 1 ) AS count FROM
  531. cygx_article AS a
  532. WHERE
  533. 1 = 1 AND a.publish_status = 1` + condition
  534. err = o.Raw(sqlCount, pars).QueryRow(&count)
  535. return
  536. }
  537. func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleCollectionResp, err error) {
  538. o := orm.NewOrm()
  539. sql := `SELECT
  540. a.article_id,
  541. a.title,
  542. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  543. a.article_type_id,
  544. d.nick_name,
  545. d.department_id,
  546. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  547. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id ) AS collect_num,
  548. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
  549. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  550. FROM
  551. cygx_article AS a
  552. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  553. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  554. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  555. WHERE
  556. 1 = 1 AND a.publish_status = 1 `
  557. if condition != "" {
  558. sql += condition
  559. }
  560. sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
  561. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  562. return
  563. }
  564. // 用户收藏榜start
  565. type IndustrialManagementHotResp struct {
  566. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  567. IndustryName string `description:"产业名称"`
  568. IsFollw bool `description:"是否关注"`
  569. FllowNum int `description:"关注数量"`
  570. IsNew bool `description:"是否新标签"`
  571. IsHot bool `description:"是否新标签"`
  572. IsRed bool `description:"是否标记红点"`
  573. Readnum int `description:"阅读数量"`
  574. PublishDate string `description:"发布时间"`
  575. MinReportTime string `description:"报告最早发布时间"`
  576. ArticleReadNum int `description:"文章阅读数量"`
  577. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  578. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  579. IndustryVideo *MicroVideoSimpleInfo `description:"产业视频"`
  580. AuthInfo *UserPermissionAuthInfo
  581. }
  582. type IndustrialManagementHotListResp struct {
  583. Paging *paging.PagingItem `description:"分页数据"`
  584. List []*IndustrialManagementHotResp
  585. }
  586. // 产业列表
  587. func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  588. o := orm.NewOrm()
  589. sql := `SELECT
  590. m.industry_name,
  591. m.industrial_management_id,
  592. m.article_read_num,
  593. MAX( a.publish_date ) AS publish_date,
  594. MIN(a.publish_date) AS min_report_time,
  595. ( 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,
  596. m.yanxuan_article_read_num + m.activity_num AS sum_num
  597. FROM
  598. cygx_industrial_management AS m
  599. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  600. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  601. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  602. WHERE
  603. 1 = 1
  604. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  605. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  606. return
  607. }
  608. // 获取数量
  609. func GetThemeHeatListCount(condition string) (count int, err error) {
  610. o := orm.NewOrm()
  611. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  612. cygx_industrial_management AS m
  613. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  614. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  615. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  616. WHERE
  617. 1 = 1
  618. AND a.publish_status = 1 ` + condition
  619. err = o.Raw(sql).QueryRow(&count)
  620. return
  621. }
  622. // 标的列表
  623. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  624. o := orm.NewOrm()
  625. sql := `SELECT
  626. m.subject_name,
  627. m.industrial_management_id,
  628. m.industrial_subject_id
  629. FROM
  630. cygx_article AS a
  631. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  632. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  633. WHERE
  634. 1 = 1`
  635. if condition != "" {
  636. sql += condition
  637. }
  638. sql += ` AND publish_status = 1
  639. GROUP BY
  640. m.industrial_subject_id
  641. ORDER BY
  642. publish_date DESC`
  643. _, err = o.Raw(sql).QueryRows(&items)
  644. return
  645. } //end
  646. // Kol sratr
  647. type DepartmentResp struct {
  648. DepartmentId int `description:"作者Id"`
  649. NickName string `description:"作者昵称"`
  650. ImgUrl string `description:"图片链接"`
  651. IsFollw bool `description:"是否关注"`
  652. IsHot bool `description:"是否关注"`
  653. FllowNum int `description:"关注数量"`
  654. List []*IndustrialDepartmentListResp
  655. }
  656. type DepartmentListResp struct {
  657. Paging *paging.PagingItem `description:"分页数据"`
  658. List []*DepartmentResp
  659. }
  660. type IndustrialDepartmentListResp struct {
  661. IndustrialManagementId int `description:"产业Id"`
  662. IndustryName string `description:"产业名称"`
  663. DepartmentId int `description:"作者Id"`
  664. }
  665. // 作者列表
  666. func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
  667. o := orm.NewOrm()
  668. sql := `SELECT
  669. d.nick_name,
  670. d.department_id,
  671. d.img_url,
  672. MAX( a.publish_date ) AS publish_date,
  673. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND user_id =? AND f.type= 1 ) AS fllow_num,
  674. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND f.type= 1 ) AS sum_num
  675. FROM
  676. cygx_article_department AS d
  677. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  678. WHERE
  679. 1 = 1
  680. AND publish_status = 1 ` + condition + `
  681. GROUP BY
  682. d.department_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  683. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  684. return
  685. }
  686. // 获取数量
  687. func GetDepartmentlistCount(condition string) (count int, err error) {
  688. o := orm.NewOrm()
  689. sql := `SELECT
  690. count(*) AS count
  691. FROM
  692. (
  693. SELECT
  694. COUNT( 1 ) AS count
  695. FROM
  696. cygx_article_department AS d
  697. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  698. WHERE
  699. 1 = 1
  700. AND a.article_type_id > 0
  701. AND publish_status = 1
  702. GROUP BY
  703. d.department_id
  704. ) c `
  705. err = o.Raw(sql).QueryRow(&count)
  706. return
  707. }
  708. // 作者文章所关联的产业列表
  709. func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
  710. o := orm.NewOrm()
  711. sql := `SELECT
  712. m.industrial_management_id,
  713. m.industry_name,
  714. d.department_id
  715. FROM
  716. cygx_article_department AS d
  717. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  718. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  719. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  720. WHERE
  721. 1 = 1
  722. AND a.article_type_id > 0
  723. AND publish_status = 1
  724. ORDER BY
  725. a.publish_date DESC`
  726. _, err = o.Raw(sql).QueryRows(&items)
  727. return
  728. }
  729. // 主题详情start
  730. type GetThemeDetailListResp struct {
  731. ArticleId int `description:"文章id"`
  732. Title string `description:"标题"`
  733. PublishDate string `description:"发布时间"`
  734. SubjectName string `description:"标的名称"`
  735. IndustrialSubjectId int `description:"标的id"`
  736. DepartmentId int `description:"作者Id"`
  737. NickName string `description:"作者昵称"`
  738. Pv int `description:"PV"`
  739. CollectNum int `description:"收藏人数"`
  740. IndustrialManagementId int `description:"产业Id"`
  741. IndustryName string `description:"产业名称"`
  742. FllowNum int `description:"关注数量"`
  743. MyCollectNum int `description:"本人是否收藏"`
  744. IsCollect bool `description:"本人是否收藏"`
  745. }
  746. type GetThemeAericleListResp struct {
  747. ArticleId int `description:"文章id"`
  748. Title string `description:"标题"`
  749. PublishDate string `description:"发布时间"`
  750. SubjectName string `description:"标的名称"`
  751. IndustrialSubjectId int `description:"标的ID"`
  752. DepartmentId int `description:"作者Id"`
  753. NickName string `description:"作者昵称"`
  754. Pv int `description:"PV"`
  755. CollectNum int `description:"收藏人数"`
  756. FllowNum int `description:"关注数量"`
  757. MyCollectNum int `description:"本人是否收藏"`
  758. IsCollect bool `description:"本人是否收藏"`
  759. }
  760. type GetThemeAericleListBuSubjectResp struct {
  761. SubjectName string `description:"标的名称"`
  762. List []*GetThemeAericleListResp
  763. }
  764. // 主题详情start
  765. type GetThemeDetailResp struct {
  766. IndustrialManagementId int `description:"产业Id"`
  767. IndustryName string `description:"产业名称"`
  768. IsFollw bool `description:"是否关注"`
  769. ListSubject []*IndustrialSubject `description:"标的列表"`
  770. List []*GetThemeAericleListResp
  771. }
  772. // 列表
  773. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
  774. o := orm.NewOrm()
  775. sql := `SELECT
  776. a.article_id,
  777. a.title,
  778. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  779. m.industry_name,
  780. m.industrial_management_id,
  781. d.nick_name,
  782. d.department_id,
  783. s.industrial_subject_id,
  784. s.subject_name,
  785. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  786. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  787. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
  788. ( SELECT count( 1 ) FROM cygx_industry_fllow AS ac WHERE user_id = ? AND ac.industrial_management_id = m.industrial_management_id AND ac.type= 1) AS fllow_num
  789. FROM
  790. cygx_article AS a
  791. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  792. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  793. LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id
  794. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
  795. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  796. WHERE
  797. 1 = 1
  798. AND m.industrial_management_id = ?
  799. AND publish_status = 1 ` + condition + ` GROUP BY article_id
  800. ORDER BY
  801. publish_date DESC`
  802. _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
  803. return
  804. } //end
  805. // 用户收藏榜start
  806. type DepartmentDetailResp struct {
  807. DepartmentId int `description:"作者Id"`
  808. NickName string `description:"作者昵称"`
  809. ImgUrl string `description:"图片链接"`
  810. FllowNum int `description:"多少人关注"`
  811. ArticleNum int `description:"文章数量"`
  812. CollectNum int `description:"收藏人数"`
  813. IsFllow bool `description:"是否关注"`
  814. List []*ArticleCollectionResp
  815. ListIndustrial []*IndustrialManagementNewResp
  816. }
  817. type DepartmentDetail struct {
  818. DepartmentId int `description:"作者Id"`
  819. NickName string `description:"作者昵称"`
  820. ImgUrl string `description:"图片链接"`
  821. FllowNum int `description:"多少人关注"`
  822. ArticleNum int `description:"文章数量"`
  823. CollectNum int `description:"收藏人数"`
  824. IsFllow bool `description:"是否关注"`
  825. MyFllowNum int `description:"本人是否关注"`
  826. }
  827. // 列表
  828. func GetDepartmentDetail(userId, departmentId int, condition string) (item DepartmentDetail, err error) {
  829. o := orm.NewOrm()
  830. sql := `SELECT
  831. d.department_id,
  832. d.nick_name,
  833. d.img_url,
  834. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.user_id = ? AND af.department_id = d.department_id AND af.type= 1 ) AS my_fllow_num,
  835. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user as u ON u.user_id = f.user_id WHERE f.department_id = d.department_id AND f.type= 1 ) AS fllow_num,
  836. ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + ` ) AS article_num,
  837. ( SELECT count( 1 ) FROM cygx_article_collect AS c INNER JOIN wx_user as u ON u.user_id = c.user_id WHERE c.article_id IN (SELECT article_id FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + ` )) AS collect_num
  838. FROM
  839. cygx_article_department AS d
  840. WHERE
  841. d.department_id = ?`
  842. err = o.Raw(sql, userId, departmentId).QueryRow(&item)
  843. return
  844. } //end
  845. // 报告搜索start
  846. type ReoprtSearchResp struct {
  847. ListYx []*ArticleCollectionResp `description:"研选报告"`
  848. ListHz []*ArticleCollectionResp `description:"弘则报告"`
  849. }
  850. // 列表
  851. func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  852. o := orm.NewOrm()
  853. sql := `SELECT
  854. a.article_id,
  855. a.title,
  856. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  857. m.industry_name,
  858. m.industrial_management_id,
  859. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  860. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  861. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  862. FROM
  863. cygx_article AS a
  864. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  865. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  866. WHERE
  867. 1 = 1 `
  868. if condition != "" {
  869. sql += condition
  870. }
  871. _, err = o.Raw(sql, userId).QueryRows(&items)
  872. return
  873. } //end
  874. // 搜索资源包 start
  875. type SearchResourceResp struct {
  876. ListHz []*IndustrialManagementHotResp `description:"弘则"`
  877. ListYx []*IndustrialManagementHotResp `description:"研选"`
  878. }
  879. // 搜索资源包 start
  880. type SearchReportAndResourceResp struct {
  881. ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
  882. ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
  883. ListYxReport []*ArticleCollectionResp `description:"研选报告"`
  884. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  885. }
  886. // 产业列表
  887. func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  888. o := orm.NewOrm()
  889. sql := `SELECT
  890. m.industry_name,
  891. m.industrial_management_id,
  892. MAX( a.publish_date ) as publish_date_order,
  893. MIN(a.publish_date) AS min_report_time,
  894. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  895. (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
  896. FROM
  897. cygx_industrial_management AS m
  898. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  899. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  900. WHERE
  901. 1 = 1
  902. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  903. if startSize > 0 || pageSize > 0 {
  904. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  905. }
  906. _, err = o.Raw(sql).QueryRows(&items)
  907. return
  908. }
  909. // 切换列表
  910. type ReportBillboardTableResp struct {
  911. Name string `description:"名称"`
  912. Source int `description:"类型"`
  913. List []*ChartPermission
  914. }
  915. // 切换列表
  916. type ReportBillboardTableListResp struct {
  917. List []*ReportBillboardTableResp
  918. }
  919. // 报告榜单start
  920. type ArticleReportBillboardResp struct {
  921. ArticleId int `description:"文章id"`
  922. Title string `description:"标题"`
  923. PublishDate string `description:"发布时间"`
  924. PermissionName string `description:"行业名称"`
  925. DepartmentId int `description:"作者Id"`
  926. NickName string `description:"作者昵称"`
  927. IsCollect bool `description:"本人是否收藏"`
  928. Pv int `description:"PV"`
  929. CollectNum int `description:"收藏人数"`
  930. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  931. IsRoadShow bool `description:"是否是路演精华"`
  932. CategoryId int `description:"分类ID"`
  933. List []*IndustrialManagementIdInt
  934. }
  935. type ArticleReportBillboardLIstResp struct {
  936. List []*ArticleReportBillboardResp
  937. }
  938. type ArticleReportBillboardLIstPageResp struct {
  939. List []*ArticleReportBillboardResp
  940. Paging *paging.PagingItem
  941. }
  942. // 报告收藏榜单列表
  943. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  944. o := orm.NewOrm()
  945. sql := `SELECT
  946. ac.id,
  947. a.article_id,
  948. a.title,
  949. date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
  950. m.chart_permission_name AS permission_name,
  951. COUNT(ac.id) AS collection_num
  952. FROM
  953. cygx_article AS a
  954. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  955. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  956. WHERE
  957. 1 = 1
  958. AND a.publish_status = 1 `
  959. if condition != "" {
  960. sql += condition
  961. }
  962. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  963. sql += ` LIMIT ?`
  964. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  965. return
  966. }
  967. // 报告阅读榜单列表
  968. func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  969. o := orm.NewOrm()
  970. sql := `SELECT
  971. a.article_id,
  972. a.title,
  973. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date
  974. FROM
  975. cygx_article AS a
  976. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  977. WHERE
  978. 1 = 1
  979. AND a.publish_status = 1 `
  980. if condition != "" {
  981. sql += condition
  982. }
  983. _, err = o.Raw(sql, pars).QueryRows(&items)
  984. return
  985. }
  986. // 获取产业报告+晨会点评数量
  987. func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
  988. o := orm.NewOrm()
  989. sql := `SELECT SUM(count) AS count FROM (
  990. SELECT
  991. COUNT( 1 ) count
  992. FROM
  993. cygx_article AS a
  994. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  995. WHERE
  996. a.publish_status = 1
  997. AND a.is_class = 1
  998. AND man_g.industrial_management_id = ?
  999. UNION ALL
  1000. SELECT
  1001. COUNT( 1 ) count
  1002. FROM
  1003. cygx_morning_meeting_review_chapter AS mmc
  1004. INNER JOIN cygx_morning_meeting_reviews AS mm
  1005. WHERE
  1006. mm.id = mmc.meeting_id
  1007. AND mm.status = 1
  1008. AND mmc.industry_id = ? ) AS t `
  1009. err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRow(&count)
  1010. return
  1011. }
  1012. type TimeLineReportItem struct {
  1013. Id int `description:"文章或晨报点评id"`
  1014. Title string `description:"标题"`
  1015. PublishTime string `description:"发布时间"`
  1016. Content string `description:"内容"`
  1017. VideoUrl string `description:"视频链接"`
  1018. IsHaveVideo bool `description:"是否包含视频"`
  1019. ImgUrlPc string `description:"pc图片"`
  1020. SubCategoryName string `description:"二级分类"`
  1021. IsRed bool `description:"是否标红"`
  1022. Readnum int `description:"阅读数量"`
  1023. }
  1024. // 获取产业报告+晨会点评列表
  1025. func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  1026. o := orm.NewOrm()
  1027. sql := `SELECT
  1028. *
  1029. FROM
  1030. (
  1031. SELECT
  1032. a.article_id AS id,
  1033. a.title,
  1034. a.publish_date AS publish_time,
  1035. a.video_url,
  1036. a.sub_category_name,
  1037. '' AS content,
  1038. ( 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
  1039. FROM
  1040. cygx_article AS a
  1041. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  1042. WHERE
  1043. a.publish_status = 1
  1044. AND a.is_class = 1
  1045. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  1046. SELECT
  1047. mmc.id,
  1048. '' AS title,
  1049. mm.publish_time AS publish_time,
  1050. '' AS video_url,
  1051. '时间线' AS sub_category_name,
  1052. mmc.content,
  1053. 0 AS readnum
  1054. FROM
  1055. cygx_morning_meeting_review_chapter AS mmc
  1056. INNER JOIN cygx_morning_meeting_reviews AS mm
  1057. WHERE
  1058. mm.id = mmc.meeting_id
  1059. AND mm.STATUS = 1
  1060. AND mmc.industry_id = ?
  1061. ) AS t
  1062. `
  1063. sql += ` ORDER BY
  1064. t.publish_time DESC LIMIT ?,? `
  1065. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  1066. return
  1067. }
  1068. type ArticleIdReq struct {
  1069. ArticleId int `description:"文章id"`
  1070. PlaySeconds int `description:"播放时长"`
  1071. PageRouter string `description:"页面路径"`
  1072. }
  1073. type IndustrialReadNum struct {
  1074. IndustrialManagementId int `description:"产业id"`
  1075. Readnum int `description:"阅读次数"`
  1076. }
  1077. // 获取该产业下文章的用户阅读次数-小红点用
  1078. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  1079. o := orm.NewOrm()
  1080. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  1081. 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
  1082. FROM
  1083. cygx_article AS a
  1084. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  1085. WHERE
  1086. a.publish_status = 1
  1087. AND a.is_class = 1
  1088. AND man_g.industrial_management_id IN (` + industrialIds + `)
  1089. AND a.publish_date > ?
  1090. GROUP BY a.article_id ORDER BY publish_date DESC
  1091. ) AS a GROUP BY industrial_management_id`
  1092. _, err = o.Raw(sql, createtime).QueryRows(&items)
  1093. return
  1094. }