report.go 49 KB

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