report.go 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_web_mfyx/utils"
  6. "strconv"
  7. "time"
  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. ChartPermissionId int `description:"权限id"`
  17. ChartPermissionName string `description:"权限名称"`
  18. LayoutTime string `description:"布局时间"`
  19. PublishDate string `description:"发布时间"`
  20. UpdateTime string `description:"更新时间"`
  21. IsRed bool `description:"是否标记红点"`
  22. IsHot bool `description:"是否是热门"`
  23. IsFollow bool `description:"是否关注"`
  24. IsNew bool `description:"是否展示 NEW 标签"`
  25. IsShowRoadshow bool `description:"是否展示 微路演 标签"`
  26. ArticleReadNum int `description:"文章阅读数量"`
  27. ArticleId int `description:"文章id"`
  28. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  29. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  30. MinReportTime string `description:"报告最早发布时间"`
  31. IndustryVideo *MicroVideoSimpleInfo
  32. AuthInfo *UserPermissionAuthInfo
  33. }
  34. type MicroVideoSimpleInfo struct {
  35. Id int `description:"视频ID"`
  36. Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
  37. Title string `description:"标题"`
  38. ResourceUrl string `description:"链接"`
  39. BackgroundImg string `description:"背景图"`
  40. PlaySeconds int `description:"音视频时长"`
  41. DetailImgUrl string `description:"产业详情页背景图"`
  42. ChartPermissionId int `description:"行业ID"`
  43. ChartPermissionName string `description:"行业名称"`
  44. }
  45. type TacticsListResp struct {
  46. Paging *paging.PagingItem
  47. MatchTypeName string `description:"匹配类型"`
  48. CategoryImgUrlPc string `description:"图片"`
  49. List []*HomeArticle
  50. }
  51. type TacticsListTimeResp struct {
  52. Paging *paging.PagingItem
  53. MatchTypeName string `description:"匹配类型"`
  54. CategoryImgUrlPc string `description:"图片"`
  55. List []*TimeLineReportItem
  56. }
  57. // 报告搜索start
  58. type ReoprtSearchResp struct {
  59. Paging *paging.PagingItem
  60. ListHz []*ArticleResearchResp `description:"弘则报告"`
  61. ListYx []*ArticleResearchResp `description:"研选报告"`
  62. }
  63. // 搜索资源包 start
  64. type SearchResourceResp struct {
  65. ListHz []*IndustrialManagement `description:"弘则"`
  66. ListYx []*IndustrialManagement `description:"研选"`
  67. }
  68. type ArticleIdReq struct {
  69. ArticleId int `description:"文章id"`
  70. PlaySeconds int `description:"播放时长"`
  71. PageRouter string `description:"页面路径"`
  72. ReportType int `description:"2本周研究汇总、3上周纪要汇总"`
  73. }
  74. // 获取列表数量
  75. func GetReoprtSearchCount(condition string) (count int, err error) {
  76. o := orm.NewOrm()
  77. sql := `SELECT
  78. COUNT( 1 ) AS count
  79. FROM
  80. cygx_article AS a
  81. WHERE
  82. 1 = 1
  83. AND a.article_id < 1000000 `
  84. if condition != "" {
  85. sql += condition
  86. }
  87. err = o.Raw(sql).QueryRow(&count)
  88. return
  89. }
  90. func GetReoprtSearchCountYx(condition string) (count int, err error) {
  91. o := orm.NewOrm()
  92. sql := `SELECT
  93. COUNT( 1 ) AS count
  94. FROM
  95. cygx_article AS a
  96. WHERE
  97. 1 = 1`
  98. if condition != "" {
  99. sql += condition
  100. }
  101. err = o.Raw(sql).QueryRow(&count)
  102. return
  103. }
  104. func GetReoprtSearchCountHz(condition string) (count int, err error) {
  105. o := orm.NewOrm()
  106. sql := `SELECT
  107. COUNT( 1 ) AS count
  108. FROM
  109. cygx_article AS a
  110. WHERE
  111. 1 = 1`
  112. if condition != "" {
  113. sql += condition
  114. }
  115. err = o.Raw(sql).QueryRow(&count)
  116. return
  117. }
  118. // 列表
  119. func GetReoprtSearchList(condition string, userId, startSize, pageSize int) (items []*ArticleCollectionResp, err error) {
  120. o := orm.NewOrm()
  121. sql := `SELECT
  122. a.article_id,
  123. a.title,
  124. a.body,
  125. a.abstract,
  126. a.annotation,
  127. a.category_id,
  128. a.category_name,
  129. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  130. m.industry_name,
  131. m.industrial_management_id,
  132. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  133. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  134. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  135. FROM
  136. cygx_article AS a
  137. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  138. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  139. WHERE
  140. 1 = 1 `
  141. if condition != "" {
  142. sql += condition
  143. }
  144. sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
  145. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  146. return
  147. } //end
  148. // 获取行业报告列表
  149. func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
  150. o := orm.NewOrm()
  151. sql := `SELECT
  152. art.article_id,
  153. art.title,
  154. art.publish_date,
  155. 1 AS resource
  156. FROM
  157. cygx_article AS art
  158. WHERE
  159. art.publish_status = 1
  160. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
  161. SELECT
  162. art.product_interior_id AS article_id,
  163. art.title,
  164. art.publish_time AS publish_date,
  165. 2 AS resource
  166. FROM
  167. cygx_product_interior AS art
  168. WHERE
  169. art.STATUS = 1
  170. AND art.visible_range = 1
  171. AND art.match_type_id = ` + strconv.Itoa(categoryId)
  172. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  173. err = o.Raw(totalSql).QueryRow(&total)
  174. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  175. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  176. return
  177. }
  178. // 获取行业报告列表
  179. func GetReportAndproductIndustrylListimg(categoryId, userId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
  180. o := orm.NewOrm()
  181. sql := `SELECT
  182. art.article_id,
  183. art.body,
  184. art.annotation,
  185. art.abstract,
  186. art.category_id,
  187. art.title,
  188. art.publish_date,
  189. 1 AS resource ,
  190. ( 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
  191. FROM
  192. cygx_article AS art
  193. WHERE
  194. art.publish_status = 1
  195. AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
  196. SELECT
  197. art.product_interior_id AS article_id,
  198. art.body,
  199. "",
  200. art.abstract,
  201. 0 as category_id,
  202. art.title,
  203. art.publish_time AS publish_date,
  204. 2 AS resource ,
  205. ( 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
  206. FROM
  207. cygx_product_interior AS art
  208. WHERE
  209. art.STATUS = 1
  210. AND art.visible_range = 1
  211. AND art.match_type_id = ` + strconv.Itoa(categoryId)
  212. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  213. err = o.Raw(totalSql).QueryRow(&total)
  214. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  215. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  216. return
  217. }
  218. // 列表
  219. func GetSearchResourceList(condition string) (items []*IndustrialManagement, err error) {
  220. o := orm.NewOrm()
  221. sql := `SELECT
  222. m.industry_name,
  223. m.chart_permission_id,
  224. m.industrial_management_id,
  225. MAX( a.publish_date ) as publish_date_order,
  226. MIN( a.publish_date ) AS min_report_time,
  227. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
  228. FROM
  229. cygx_industrial_management AS m
  230. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  231. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  232. WHERE
  233. 1 = 1
  234. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  235. _, err = o.Raw(sql).QueryRows(&items)
  236. return
  237. }
  238. // 标的列表
  239. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  240. o := orm.NewOrm()
  241. sql := `SELECT
  242. m.subject_name,
  243. m.industrial_management_id,
  244. m.industrial_subject_id
  245. FROM
  246. cygx_article AS a
  247. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  248. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  249. WHERE
  250. 1 = 1`
  251. if condition != "" {
  252. sql += condition
  253. }
  254. sql += ` AND publish_status = 1
  255. GROUP BY
  256. m.industrial_subject_id
  257. ORDER BY
  258. publish_date DESC`
  259. _, err = o.Raw(sql).QueryRows(&items)
  260. return
  261. } //end
  262. // 产业下所关联的文章分类列表
  263. func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  264. o := orm.NewOrm()
  265. sql := `SELECT map.match_type_name,map.category_id
  266. FROM cygx_report_mapping AS map
  267. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  268. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  269. WHERE map.report_type = 2
  270. AND map.is_report = 1
  271. AND art.is_report = 1
  272. AND art.publish_status = 1
  273. AND man_g.industrial_management_id =?
  274. AND map.chart_permission_id = ?
  275. GROUP BY map.match_type_name`
  276. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  277. return
  278. }
  279. // 产业下所关联的文章、产品内测分类列表 2023-04-14
  280. func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  281. o := orm.NewOrm()
  282. sql := `SELECT
  283. map.match_type_name,
  284. map.id AS category_id
  285. FROM
  286. cygx_report_mapping_cygx AS map
  287. INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
  288. INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
  289. INNER JOIN cygx_article AS art ON art.category_id = cl.category_id
  290. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  291. WHERE
  292. 1 = 1
  293. AND map.report_type = 2
  294. AND map.is_report = 1
  295. AND art.is_report = 1
  296. AND art.publish_status = 1
  297. AND man_g.industrial_management_id = ?
  298. GROUP BY
  299. map.match_type_name UNION ALL
  300. SELECT
  301. map.match_type_name,
  302. map.id AS category_id
  303. FROM
  304. cygx_report_mapping_cygx AS map
  305. INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
  306. INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id
  307. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  308. WHERE
  309. 1 = 1
  310. AND art.STATUS = 1
  311. AND art.visible_range = 1
  312. AND man_g.industrial_management_id = ?
  313. GROUP BY
  314. map.match_type_name`
  315. _, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
  316. return
  317. }
  318. // 获取产业报告列表
  319. func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
  320. o := orm.NewOrm()
  321. sql := `SELECT
  322. art.article_id,
  323. art.body,
  324. art.annotation,
  325. art.abstract,
  326. art.category_id,
  327. art.title,
  328. art.publish_date,
  329. ( 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 ,
  330. 1 AS resource
  331. FROM
  332. cygx_article AS art
  333. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  334. WHERE
  335. art.publish_status = 1
  336. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
  337. AND art.is_class = 1
  338. AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + `
  339. GROUP BY
  340. art.article_id UNION ALL
  341. SELECT
  342. art.product_interior_id AS article_id,
  343. art.body,
  344. "",
  345. art.abstract,
  346. 0 as category_id,
  347. art.title,
  348. art.publish_time AS publish_date,
  349. ( 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 ,
  350. 2 AS resource
  351. FROM
  352. cygx_product_interior AS art
  353. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  354. WHERE
  355. art.STATUS = 1
  356. AND art.visible_range = 1
  357. AND art.match_type_id = ` + strconv.Itoa(categoryId) + `
  358. AND man_g.industrial_management_id = ` + strconv.Itoa(industrialManagementId) + `
  359. GROUP BY
  360. art.product_interior_id `
  361. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  362. err = o.Raw(totalSql, pars).QueryRow(&total)
  363. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  364. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  365. return
  366. }
  367. // 判断用户是否阅读该产业下,某一分类的文章
  368. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  369. o := orm.NewOrm()
  370. sql := `SELECT
  371. COUNT(1) count
  372. FROM
  373. cygx_article_history_record
  374. WHERE
  375. 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
  376. category_id
  377. FROM
  378. cygx_report_mapping
  379. WHERE
  380. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  381. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  382. AND user_id = ? `
  383. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  384. return
  385. }
  386. // 获取最新文章
  387. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  388. o := orm.NewOrm()
  389. 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
  390. category_id
  391. FROM
  392. cygx_report_mapping
  393. WHERE
  394. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  395. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  396. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  397. return
  398. }
  399. // 列表
  400. func GetReoprtSearchListHz(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  401. o := orm.NewOrm()
  402. sql := `SELECT
  403. a.article_id,
  404. a.title,
  405. a.annotation,
  406. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  407. m.industry_name,
  408. m.industrial_management_id,
  409. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  410. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  411. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  412. FROM
  413. cygx_article AS a
  414. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  415. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  416. WHERE
  417. 1 = 1 `
  418. if condition != "" {
  419. sql += condition
  420. }
  421. _, err = o.Raw(sql, userId).QueryRows(&items)
  422. return
  423. } //end
  424. // 产业列表
  425. func GetSearchResourceListHz(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  426. o := orm.NewOrm()
  427. sql := `SELECT
  428. m.industry_name,
  429. m.industrial_management_id,
  430. MAX( a.publish_date ) as publish_date_order,
  431. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
  432. FROM
  433. cygx_industrial_management AS m
  434. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  435. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  436. WHERE
  437. 1 = 1
  438. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  439. if startSize > 0 || pageSize > 0 {
  440. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  441. }
  442. _, err = o.Raw(sql).QueryRows(&items)
  443. return
  444. }
  445. // 用户收藏榜start
  446. type IndustrialManagementHotResp struct {
  447. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  448. IndustryName string `description:"产业名称"`
  449. IsFollow bool `description:"是否关注"`
  450. FllowNum int `description:"关注数量"`
  451. IsNew bool `description:"是否新标签"`
  452. IsHot bool `description:"是否新标签"`
  453. PublishDate string `description:"发布时间"`
  454. ArticleReadNum int `description:"文章阅读数量"`
  455. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  456. MinReportTime string `description:"报告最早发布时间"`
  457. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  458. }
  459. // 搜索资源包 start
  460. type SearchReportAndResourceResp struct {
  461. ListHzResource []*IndustrialManagement `description:"弘则资源包"`
  462. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  463. Paging *paging.PagingItem `description:"弘则报告分页"`
  464. }
  465. // 报告收藏榜单列表
  466. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleListResp, err error) {
  467. o := orm.NewOrm()
  468. sql := `SELECT
  469. ac.id,
  470. a.article_id,
  471. a.category_id,
  472. a.title,
  473. a.annotation,
  474. a.publish_date,
  475. a.article_type_id,
  476. m.chart_permission_name,
  477. COUNT(ac.id) AS collection_num
  478. FROM
  479. cygx_article AS a
  480. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id_two
  481. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  482. WHERE
  483. 1 = 1
  484. AND a.publish_status = 1 `
  485. if condition != "" {
  486. sql += condition
  487. }
  488. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  489. sql += ` LIMIT ?`
  490. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  491. return
  492. }
  493. // 研选报告收藏榜单列表
  494. func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleListResp, err error) {
  495. o := orm.NewOrm()
  496. sql := `SELECT
  497. ac.id,
  498. a.category_id,
  499. '买方研选' as chart_permission_name,
  500. a.article_id,
  501. a.title,
  502. a.body,
  503. a.annotation,
  504. a.abstract,
  505. a.publish_date,
  506. a.article_type_id,
  507. d.nick_name,
  508. d.department_id,
  509. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  510. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  511. ( 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
  512. FROM
  513. cygx_article AS a
  514. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  515. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  516. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  517. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  518. WHERE
  519. 1 = 1
  520. AND a.publish_status = 1 `
  521. if condition != "" {
  522. sql += condition
  523. }
  524. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, a.publish_date DESC`
  525. sql += ` LIMIT ?`
  526. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  527. return
  528. }
  529. // 获取产业报告+晨会点评列表
  530. func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
  531. o := orm.NewOrm()
  532. sql := `SELECT
  533. a.id,
  534. a.article_id,
  535. a.title,
  536. a.publish_date
  537. FROM
  538. cygx_article AS a
  539. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  540. WHERE
  541. a.publish_status = 1
  542. AND a.is_class = 1
  543. AND man_g.industrial_management_id = ? GROUP BY a.article_id UNION ALL
  544. SELECT
  545. mmc.id,
  546. 0,
  547. mmc.content AS title,
  548. mm.meeting_time AS publish_data
  549. FROM
  550. cygx_morning_meeting_review_chapter AS mmc
  551. INNER JOIN cygx_morning_meeting_reviews AS mm
  552. WHERE
  553. mm.id = mmc.meeting_id
  554. AND mm.STATUS = 1
  555. AND mmc.industry_id = ? `
  556. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  557. err = o.Raw(totalSql, industrialManagementId, industrialManagementId).QueryRow(&total)
  558. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  559. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  560. return
  561. }
  562. type TimeLineReportItem struct {
  563. Id int `description:"文章或晨报点评id"`
  564. ArticleId int `description:"文章id"`
  565. Title string `description:"标题"`
  566. //PublishTime string `description:"发布时间"`
  567. PublishDate string `description:"发布时间"`
  568. Content string `description:"内容"`
  569. VideoUrl string `description:"视频链接"`
  570. VoiceUrl string `description:"音频链接"`
  571. IsHaveVideo bool `description:"是否包含视频"`
  572. ImgUrlPc string `description:"pc图片"`
  573. SubCategoryName string `description:"二级分类"`
  574. IsRed bool `description:"是否标红"`
  575. Readnum int `description:"阅读数量"`
  576. Resource int `description:"来源类型,1:文章、2:产品内测、3:晨报点评 4:活动回放视频 5:活动回放音频 "`
  577. Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
  578. LinkArticleId int `description:"晨会精华报告ID链接"`
  579. ListSubject []*CygxIndustrialSubject `description:"标的列表"`
  580. }
  581. // 获取产业报告+晨会点评列表
  582. func GetTimeLineReportIndustrialListTime(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, total int, err error) {
  583. o := orm.NewOrm()
  584. sql := `SELECT
  585. *
  586. FROM
  587. (
  588. SELECT
  589. a.article_id AS id,
  590. a.article_id,
  591. a.title,
  592. a.publish_date,
  593. a.video_url,
  594. '' AS mi,
  595. a.sub_category_name,
  596. '' AS content,
  597. 1 AS resource,
  598. 0 AS type,
  599. ( 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
  600. FROM
  601. cygx_article AS a
  602. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  603. WHERE
  604. a.publish_status = 1
  605. AND a.is_class = 1
  606. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  607. SELECT
  608. mmc.id,
  609. 0 as article_id,
  610. mmc.title,
  611. mm.publish_time AS publish_date,
  612. '' AS video_url,
  613. '' AS voice_url,
  614. '时间线' AS sub_category_name,
  615. mmc.content,
  616. 3 AS resource,
  617. 0 AS type,
  618. 0 AS readnum
  619. FROM
  620. cygx_morning_meeting_review_chapter AS mmc
  621. INNER JOIN cygx_morning_meeting_reviews AS mm
  622. WHERE
  623. mm.id = mmc.meeting_id
  624. AND mm.STATUS = 1
  625. AND mmc.industry_id = ? UNION ALL
  626. SELECT
  627. p.product_interior_id AS id,
  628. p.product_interior_id as article_id,
  629. p.title,
  630. p.publish_time AS publish_date,
  631. '' AS video_url,
  632. '' AS voice_url,
  633. '' AS sub_category_name,
  634. '' AS content,
  635. 2 AS resource,
  636. 0 AS type,
  637. 0 AS readnum
  638. FROM
  639. cygx_product_interior AS p
  640. INNER JOIN cygx_product_interior_industrial_group_management AS pm
  641. WHERE
  642. p.product_interior_id = pm.product_interior_id
  643. AND p.visible_range = 1
  644. AND pm.industrial_management_id = ? UNION ALL
  645. SELECT
  646. cav.video_id AS id,
  647. 0 as article_id,
  648. cav.video_name AS title,
  649. ca.activity_time AS publish_time,
  650. cav.video_url AS video_url,
  651. '' AS voice_url,
  652. '' AS sub_category_name,
  653. '' AS content,
  654. 4 AS resource,
  655. 2 AS type,
  656. ( 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
  657. FROM
  658. cygx_activity AS ca
  659. INNER JOIN cygx_activity_video AS cav ON ca.activity_id = cav.activity_id
  660. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  661. WHERE
  662. cam.industrial_management_id = ? AND cam.source = 1 UNION ALL
  663. SELECT
  664. ca.activity_id AS id,
  665. 0 as article_id,
  666. cavo.voice_name AS title,
  667. ca.activity_time AS publish_time,
  668. '' AS video_url,
  669. cavo.voice_url AS voice_url,
  670. '' AS sub_category_name,
  671. '' AS content,
  672. 5 AS resource,
  673. 1 AS type,
  674. ( 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
  675. FROM
  676. cygx_activity AS ca
  677. INNER JOIN cygx_activity_voice AS cavo ON ca.activity_id = cavo.activity_id
  678. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  679. WHERE
  680. cam.industrial_management_id = ? AND cam.source = 1
  681. ) AS t`
  682. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  683. err = o.Raw(totalSql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&total)
  684. sql += ` ORDER BY
  685. t.publish_date DESC LIMIT ?,? `
  686. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  687. return
  688. }
  689. // 获取产业报告+晨会点评列表
  690. func GetTimeLineReportIndustrialListRed(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  691. o := orm.NewOrm()
  692. sql := `SELECT
  693. *
  694. FROM
  695. (
  696. SELECT
  697. a.article_id AS id,
  698. a.title,
  699. a.publish_date ,
  700. a.video_url,
  701. a.sub_category_name,
  702. '' AS content,
  703. ( 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
  704. FROM
  705. cygx_article AS a
  706. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  707. WHERE
  708. a.publish_status = 1
  709. AND a.is_class = 1
  710. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  711. SELECT
  712. mmc.id,
  713. '' AS title,
  714. mm.publish_time AS publish_date,
  715. '' AS video_url,
  716. '时间线' AS sub_category_name,
  717. mmc.content,
  718. 0 AS readnum
  719. FROM
  720. cygx_morning_meeting_review_chapter AS mmc
  721. INNER JOIN cygx_morning_meeting_reviews AS mm
  722. WHERE
  723. mm.id = mmc.meeting_id
  724. AND mm.STATUS = 1
  725. AND mmc.industry_id = ?
  726. ) AS t
  727. `
  728. sql += ` ORDER BY
  729. t.publish_date DESC LIMIT ?,? `
  730. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  731. return
  732. }
  733. type IndustrialPublishdate struct {
  734. PublishDate string `description:"发布时间"`
  735. IndustrialManagementId int `description:"产业D"`
  736. }
  737. // 标的列表
  738. func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialPublishdate, err error) {
  739. o := orm.NewOrm()
  740. sql := `SELECT
  741. mmc.id,
  742. 0,
  743. mmc.industry_id AS industrial_management_id,
  744. mmc.content AS title,
  745. MAX( mm.meeting_time ) AS publish_date
  746. FROM
  747. cygx_morning_meeting_review_chapter AS mmc
  748. INNER JOIN cygx_morning_meeting_reviews AS mm
  749. WHERE
  750. mm.id = mmc.meeting_id
  751. AND mm.STATUS = 1
  752. AND mmc.industry_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)
  753. GROUP BY industrial_management_id ORDER BY publish_date DESC `
  754. _, err = o.Raw(sql, industrialIdArr).QueryRows(&items)
  755. return
  756. }
  757. // 报告榜单start
  758. type ArticleReportBillboardResp struct {
  759. ArticleId int `description:"文章id"`
  760. Title string `description:"标题"`
  761. PublishDate string `description:"发布时间"`
  762. PermissionName string `description:"行业名称"`
  763. DepartmentId int `description:"作者Id"`
  764. NickName string `description:"作者昵称"`
  765. IsCollect bool `description:"本人是否收藏"`
  766. Pv int `description:"PV"`
  767. CollectNum int `description:"收藏人数"`
  768. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  769. ArticleTypeId int `description:"文章类型ID判断是否是研选使用"`
  770. IsResearch bool `description:"是否属于研选"`
  771. ArticleTypeName string `description:"文章类型名称"`
  772. IsSpecial bool `description:"是否为研选专栏"`
  773. IsSpecialInt int `description:"是否为研选专栏"`
  774. SpecialTags string `description:"研选专栏标签"`
  775. MyCollectNum int `description:"本人是否收藏"`
  776. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  777. UserId int `description:"作者id"`
  778. IndustryTagStr string `description:"研选专栏行业标签"`
  779. CompanyTagsStr string `description:"研选专栏公司标签"`
  780. IndustryTags []string `description:"研选专栏行业标签"`
  781. CompanyTags []string `description:"研选专栏公司标签"`
  782. SpecialColumnId int `description:"专栏栏目id"`
  783. ImgUrlPc string `description:"图片链接"`
  784. LabelKeywordImgLink string `description:"标签关键词ico"`
  785. List []*IndustrialManagementIdInt
  786. }
  787. type ArticleReportBillboardLIstPageResp struct {
  788. List []*ArticleReportBillboardResp
  789. Paging *paging.PagingItem
  790. }
  791. type ArticleResearchListResp struct {
  792. Paging *paging.PagingItem
  793. List []*ArticleResearchResp
  794. }
  795. type ArticleResearchResp struct {
  796. ArticleId int `description:"文章id"`
  797. Title string `description:"标题"`
  798. Annotation string `description:"核心观点"`
  799. Abstract string `description:"摘要"`
  800. PublishDate string `description:"发布时间"`
  801. DepartmentId int `description:"作者Id"`
  802. NickName string `description:"作者昵称"`
  803. IsCollect bool `description:"本人是否收藏"`
  804. Pv int `description:"PV"`
  805. CollectNum int `description:"收藏人数"`
  806. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  807. ArticleTypeId int `description:"文章类型ID"`
  808. ArticleTypeName string `description:"类型名称"`
  809. ButtonStyle string `description:"按钮展示样式"`
  810. ImgUrlPc string `description:"图片链接"`
  811. List []*IndustrialManagementIdInt `description:"产业列表"`
  812. ListSubject []*IndustrialSubject `description:"标的列表"`
  813. IsSpecial bool `description:"是否为研选专栏"`
  814. IndustryTags []string `description:"研选专栏行业标签"`
  815. CompanyTags []string `description:"研选专栏公司标签"`
  816. SpecialColumnId int `description:"专栏栏目id"`
  817. TopTime int `description:"置顶时间"`
  818. }
  819. // 获取数量
  820. func GetArticleResearchCount(condition string, pars []interface{}, needYanxuanSpecial bool) (count int, err error) {
  821. o := orm.NewOrm()
  822. sqlCount := `SELECT COUNT( 1 ) AS count FROM
  823. cygx_article AS a
  824. WHERE
  825. 1 = 1 AND a.publish_status = 1` + condition
  826. if needYanxuanSpecial {
  827. sqlCount = `SELECT SUM(count) AS count FROM (` + sqlCount + `
  828. UNION ALL
  829. SELECT COUNT( 1 ) AS count FROM
  830. cygx_yanxuan_special AS a WHERE
  831. 1 = 1 AND a.status = 3) AS c`
  832. }
  833. err = o.Raw(sqlCount, pars).QueryRow(&count)
  834. return
  835. }
  836. func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
  837. o := orm.NewOrm()
  838. sql := `SELECT
  839. a.article_id,
  840. a.title,
  841. a.body,
  842. a.annotation,
  843. a.abstract,
  844. a.publish_date,
  845. a.article_type_id,
  846. d.nick_name,
  847. d.department_id,
  848. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  849. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  850. ( 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,
  851. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
  852. 0 AS is_special,
  853. 0 AS special_type,
  854. 0 AS special_column_id,
  855. '' AS company_tags,
  856. '' AS industry_tags,
  857. a.top_time
  858. FROM
  859. cygx_article AS a
  860. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  861. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  862. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  863. WHERE
  864. 1 = 1 AND a.publish_status = 1 `
  865. if condition != "" {
  866. sql += condition
  867. }
  868. if needYanxuanSpecial {
  869. sql += `UNION ALL
  870. SELECT
  871. a.id AS article_id,
  872. a.title AS title,
  873. '' AS body,
  874. a.content AS annotation,
  875. '' AS abstract,
  876. a.publish_time AS publish_date,
  877. -1 AS article_type_id,
  878. b.nick_name AS nick_name,
  879. 0 AS department_id,
  880. ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
  881. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  882. 0 AS collect_num_order,
  883. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
  884. 1 AS is_special,
  885. a.type AS special_type,
  886. b.id AS special_column_id,
  887. a.company_tags AS company_tags,
  888. a.industry_tags AS industry_tags,
  889. 0 as top_time
  890. FROM
  891. cygx_yanxuan_special AS a
  892. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  893. WHERE
  894. 1 = 1 AND a.status = 3 `
  895. sql += ` GROUP BY article_id ORDER BY top_time DESC , publish_date DESC LIMIT ?,? `
  896. _, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
  897. } else {
  898. sql += ` GROUP BY a.article_id ORDER BY top_time DESC , a.publish_date DESC LIMIT ?,? `
  899. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  900. }
  901. return
  902. }
  903. func GetArticleResearchListYx(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
  904. o := orm.NewOrm()
  905. sql := `SELECT
  906. a.article_id,
  907. a.title,
  908. a.body,
  909. a.annotation,
  910. a.abstract,
  911. a.publish_date,
  912. a.article_type_id,
  913. d.nick_name,
  914. d.department_id,
  915. 0 AS is_special,
  916. 0 as pv,
  917. 0 as collect_num,
  918. 0 AS special_type,
  919. 0 AS special_column_id,
  920. '' AS company_tags,
  921. '' AS industry_tags,
  922. a.top_time
  923. FROM
  924. cygx_article AS a
  925. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  926. WHERE
  927. 1 = 1 AND a.publish_status = 1 `
  928. if condition != "" {
  929. sql += condition
  930. }
  931. if needYanxuanSpecial {
  932. sql += `UNION ALL
  933. SELECT
  934. a.id AS article_id,
  935. a.title AS title,
  936. '' AS body,
  937. a.content AS annotation,
  938. '' AS abstract,
  939. a.publish_time AS publish_date,
  940. -1 AS article_type_id,
  941. b.nick_name AS nick_name,
  942. 0 AS department_id,
  943. 1 AS is_special,
  944. a.pv,
  945. a.article_collect_num as collect_num,
  946. a.type AS special_type,
  947. b.id AS special_column_id,
  948. a.company_tags AS company_tags,
  949. a.industry_tags AS industry_tags,
  950. 0 as top_time
  951. FROM
  952. cygx_yanxuan_special AS a
  953. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  954. WHERE
  955. 1 = 1 AND a.status = 3 `
  956. }
  957. sql += ` GROUP BY article_id ORDER BY top_time DESC , publish_date DESC LIMIT ?,? `
  958. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  959. return
  960. }
  961. func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (total int, items []*ArticleListResp, err error) {
  962. o := orm.NewOrm()
  963. sql := `SELECT
  964. a.article_id,
  965. a.title,
  966. a.body,
  967. a.annotation,
  968. a.abstract,
  969. a.publish_date,
  970. a.article_type_id,
  971. d.nick_name,
  972. d.department_id,
  973. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  974. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  975. ( 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,
  976. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
  977. 0 AS is_special,
  978. 0 AS special_type,
  979. 0 AS special_column_id,
  980. '' AS company_tags,
  981. '' AS industry_tags
  982. FROM
  983. cygx_article AS a
  984. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  985. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  986. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  987. WHERE
  988. 1 = 1 AND a.publish_status = 1 `
  989. if condition != "" {
  990. sql += condition
  991. }
  992. if needYanxuanSpecial {
  993. sql += `UNION ALL
  994. SELECT
  995. a.id AS article_id,
  996. a.title AS title,
  997. '' AS body,
  998. a.content AS annotation,
  999. '' AS abstract,
  1000. a.publish_time AS publish_date,
  1001. -1 AS article_type_id,
  1002. b.nick_name AS nick_name,
  1003. 0 AS department_id,
  1004. ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
  1005. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  1006. 0 AS collect_num_order,
  1007. ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
  1008. 1 AS is_special,
  1009. a.type AS special_type,
  1010. b.id AS special_column_id,
  1011. a.company_tags AS company_tags,
  1012. a.industry_tags AS industry_tags
  1013. FROM
  1014. cygx_yanxuan_special AS a
  1015. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  1016. WHERE
  1017. 1 = 1 AND a.status = 3 ` + conditionYxSpecial
  1018. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1019. err = o.Raw(totalSql, userId, userId, pars).QueryRow(&total)
  1020. sql += ` GROUP BY article_id ORDER BY publish_date DESC LIMIT ?,? `
  1021. _, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
  1022. } else {
  1023. sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
  1024. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  1025. }
  1026. return
  1027. }
  1028. func GetArticleResearchListHz(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
  1029. o := orm.NewOrm()
  1030. sql := `SELECT
  1031. a.article_id,
  1032. a.title,
  1033. a.body,
  1034. a.annotation,
  1035. a.abstract,
  1036. a.publish_date,
  1037. a.category_id,
  1038. a.article_type_id,
  1039. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1040. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1041. ( 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,
  1042. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  1043. FROM
  1044. cygx_article AS a
  1045. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1046. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1047. WHERE
  1048. 1 = 1 AND a.publish_status = 1 `
  1049. if condition != "" {
  1050. sql += condition
  1051. }
  1052. sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
  1053. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  1054. return
  1055. }
  1056. type IndustrialManagementHotListResp struct {
  1057. Paging *paging.PagingItem `description:"分页数据"`
  1058. List []*IndustrialManagementHotResp
  1059. }
  1060. // 获取数量
  1061. func GetThemeHeatListCount(condition string) (count int, err error) {
  1062. o := orm.NewOrm()
  1063. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  1064. cygx_industrial_management AS m
  1065. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1066. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  1067. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  1068. WHERE
  1069. 1 = 1 AND a.publish_status = 1 ` + condition
  1070. err = o.Raw(sql).QueryRow(&count)
  1071. return
  1072. }
  1073. // 产业列表
  1074. func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  1075. o := orm.NewOrm()
  1076. sql := `SELECT
  1077. m.industry_name,
  1078. m.industrial_management_id,
  1079. m.article_read_num,
  1080. MAX( a.publish_date ) AS publish_date,
  1081. MIN(a.publish_date) AS min_report_time,
  1082. ( 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,
  1083. m.yanxuan_article_read_num + m.activity_num AS sum_num
  1084. FROM
  1085. cygx_industrial_management AS m
  1086. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1087. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  1088. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  1089. WHERE
  1090. 1 = 1
  1091. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  1092. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  1093. return
  1094. }
  1095. type GetThemeAericleListResp struct {
  1096. ArticleId int `description:"文章id"`
  1097. Title string `description:"标题"`
  1098. PublishDate string `description:"发布时间"`
  1099. SubjectName string `description:"标的名称"`
  1100. IndustrialSubjectId int `description:"标的ID"`
  1101. DepartmentId int `description:"作者Id"`
  1102. NickName string `description:"作者昵称"`
  1103. Pv int `description:"PV"`
  1104. CollectNum int `description:"收藏人数"`
  1105. FllowNum int `description:"关注数量"`
  1106. MyCollectNum int `description:"本人是否收藏"`
  1107. IsCollect bool `description:"本人是否收藏"`
  1108. }
  1109. // 主题详情start
  1110. type GetThemeDetailResp struct {
  1111. IndustrialManagementId int `description:"产业Id"`
  1112. IndustryName string `description:"产业名称"`
  1113. IsFollow bool `description:"是否关注"`
  1114. ListSubject []*IndustrialSubject `description:"标的列表"`
  1115. List []*ArticleResearchResp
  1116. }
  1117. // 主题详情start
  1118. type GetThemeDetailListResp struct {
  1119. ArticleId int `description:"文章id"`
  1120. Title string `description:"标题"`
  1121. PublishDate string `description:"发布时间"`
  1122. SubjectName string `description:"标的名称"`
  1123. IndustrialSubjectId int `description:"标的id"`
  1124. DepartmentId int `description:"作者Id"`
  1125. NickName string `description:"作者昵称"`
  1126. Pv int `description:"PV"`
  1127. CollectNum int `description:"收藏人数"`
  1128. IndustrialManagementId int `description:"产业Id"`
  1129. IndustryName string `description:"产业名称"`
  1130. FllowNum int `description:"关注数量"`
  1131. MyCollectNum int `description:"本人是否收藏"`
  1132. IsCollect bool `description:"本人是否收藏"`
  1133. }
  1134. type GetThemeAericleListBuSubjectResp struct {
  1135. SubjectName string `description:"标的名称"`
  1136. List []*GetThemeAericleListResp
  1137. }
  1138. // 列表
  1139. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*ArticleListResp, err error) {
  1140. o := orm.NewOrm()
  1141. sql := `SELECT
  1142. a.article_id,
  1143. a.title,
  1144. a.body,
  1145. a.annotation,
  1146. a.abstract,
  1147. a.publish_date,
  1148. a.article_type_id,
  1149. d.nick_name,
  1150. d.department_id,
  1151. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1152. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1153. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num
  1154. FROM
  1155. cygx_article AS a
  1156. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1157. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1158. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  1159. WHERE
  1160. 1 = 1
  1161. AND m.industrial_management_id = ?
  1162. AND publish_status = 1 ` + condition + `
  1163. ORDER BY
  1164. publish_date DESC`
  1165. _, err = o.Raw(sql, userId, industrialManagementId).QueryRows(&items)
  1166. return
  1167. } //end
  1168. func GetDepartmentlistCount(condition string) (count int, err error) {
  1169. o := orm.NewOrm()
  1170. sql := `SELECT
  1171. count(*) AS count
  1172. FROM
  1173. (
  1174. SELECT
  1175. COUNT( 1 ) AS count
  1176. FROM
  1177. cygx_article_department AS d
  1178. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  1179. WHERE
  1180. 1 = 1
  1181. AND a.article_type_id > 0
  1182. AND publish_status = 1
  1183. GROUP BY
  1184. d.department_id
  1185. ) c `
  1186. err = o.Raw(sql).QueryRow(&count)
  1187. return
  1188. }
  1189. type IndustrialReadNum struct {
  1190. IndustrialManagementId int `description:"产业id"`
  1191. Readnum int `description:"阅读次数"`
  1192. }
  1193. // 获取该产业下文章的用户阅读次数-小红点用
  1194. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  1195. o := orm.NewOrm()
  1196. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  1197. 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
  1198. FROM
  1199. cygx_article AS a
  1200. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  1201. WHERE
  1202. a.publish_status = 1
  1203. AND a.is_class = 1
  1204. AND man_g.industrial_management_id IN (` + industrialIds + `)
  1205. AND a.publish_date > ?
  1206. GROUP BY a.article_id ORDER BY publish_date DESC
  1207. ) AS a GROUP BY industrial_management_id`
  1208. _, err = o.Raw(sql, createtime).QueryRows(&items)
  1209. return
  1210. }