report.go 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  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. IsShowOpen bool `description:"是否展示展开字段"`
  13. IsInterested bool `description:"是否属于感兴趣部分"`
  14. }
  15. type IndustrialManagement struct {
  16. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  17. IndustryName string `description:"产业名称"`
  18. RecommendedIndex int `description:"推荐指数"`
  19. CategoryId int `description:"文章分类ID"`
  20. LayoutTime string `description:"布局时间"`
  21. UpdateTime string `description:"更新时间"`
  22. MinReportTime string `description:"报告最早发布时间"`
  23. IsRed bool `description:"是否标记红点"`
  24. IsTop bool `description:"是否置顶"`
  25. IsHot bool `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
  26. IsFollow int `description:"是否关注"`
  27. FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
  28. IsNew bool `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
  29. Analyst string `description:"分析师"`
  30. ArticleReadNum int `description:"文章阅读数量"`
  31. OneMonFollowNum int `description:"近一个月关注增量"`
  32. AnalystList []*IndustrialAnalyst `description:"分析师列表"`
  33. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  34. ChartPermissionId int `description:"行业ID"`
  35. PermissionName string `description:"行业名称"`
  36. TimeLineData string `description:"时间线所关联最新三篇文章的json数据"`
  37. ListTimeLine []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
  38. IndustryVideo *MicroVideoSimpleInfo
  39. AuthInfo *UserPermissionAuthInfo
  40. ArticleId int `description:"文章id"`
  41. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  42. }
  43. type TimeLineReportResp struct {
  44. Title string `description:"标题"`
  45. PublishDate string `description:"发布时间"`
  46. }
  47. type MicroVideoSimpleInfo struct {
  48. Id int `description:"视频ID"`
  49. Title string `description:"标题"`
  50. ResourceUrl string `description:"链接"`
  51. BackgroundImg string `description:"背景图"`
  52. PlaySeconds int `description:"音视频时长"`
  53. DetailImgUrl string `description:"产业详情页背景图"`
  54. ChartPermissionId int `description:"行业ID"`
  55. ChartPermissionName string `description:"行业名称"`
  56. }
  57. type IndustrialAnalyst struct {
  58. AnalystName string `description:"分析师名称"`
  59. IndustrialManagementId int `description:"产业id"`
  60. }
  61. type IndustrialSubject struct {
  62. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  63. IndustrialManagementId int `description:"产业id"`
  64. SubjectName string `description:"标的名称"`
  65. IndustryName string `description:"产业名称"`
  66. LayoutTime string `description:"产业布局时间"`
  67. }
  68. // 获取产业报告数量
  69. func GetReportIndustrialCount(categoryId, industrialManagementId int) (count int, err error) {
  70. o := orm.NewOrm()
  71. sql := `SELECT COUNT(1) count
  72. FROM
  73. cygx_article AS a
  74. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  75. WHERE
  76. a.publish_status = 1
  77. AND category_id IN (SELECT
  78. category_id
  79. FROM
  80. cygx_report_mapping
  81. WHERE
  82. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  83. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  84. AND a.is_class = 1
  85. AND man_g.industrial_management_id = ? `
  86. err = o.Raw(sql, industrialManagementId).QueryRow(&count)
  87. return
  88. }
  89. // 获取产业报告列表
  90. func GetReportIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
  91. o := orm.NewOrm()
  92. 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
  93. FROM
  94. cygx_article AS a
  95. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  96. WHERE
  97. a.publish_status = 1
  98. AND category_id IN (SELECT
  99. category_id
  100. FROM
  101. cygx_report_mapping
  102. WHERE
  103. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  104. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  105. AND a.is_class = 1
  106. AND man_g.industrial_management_id = ?`
  107. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  108. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  109. return
  110. }
  111. // 获取产业报告列表
  112. func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
  113. o := orm.NewOrm()
  114. sql := `SELECT
  115. art.article_id,
  116. art.title,
  117. art.publish_date,
  118. ( 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 ,
  119. 1 AS resource
  120. FROM
  121. cygx_article AS art
  122. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  123. WHERE
  124. art.publish_status = 1
  125. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
  126. AND art.is_class = 1
  127. AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + `
  128. GROUP BY
  129. art.article_id UNION ALL
  130. SELECT
  131. art.product_interior_id AS article_id,
  132. art.title,
  133. art.publish_time AS publish_date,
  134. ( 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 ,
  135. 2 AS resource
  136. FROM
  137. cygx_product_interior AS art
  138. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  139. WHERE
  140. art.STATUS = 1
  141. AND art.visible_range = 1
  142. AND art.match_type_id = ` + strconv.Itoa(categoryId) + `
  143. AND man_g.industrial_management_id = ` + strconv.Itoa(industrialManagementId) + `
  144. GROUP BY
  145. art.product_interior_id `
  146. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  147. err = o.Raw(totalSql, pars).QueryRow(&total)
  148. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  149. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  150. return
  151. }
  152. // 获取行业报告列表
  153. func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
  154. o := orm.NewOrm()
  155. sql := `SELECT
  156. art.article_id,
  157. art.report_id,
  158. art.title,
  159. art.abstract,
  160. art.publish_date,
  161. 1 AS resource
  162. FROM
  163. cygx_article AS art
  164. WHERE
  165. art.publish_status = 1
  166. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
  167. SELECT
  168. art.product_interior_id AS article_id,
  169. 0 AS report_id,
  170. art.title,
  171. "" as abstract,
  172. art.publish_time AS publish_date,
  173. 2 AS resource
  174. FROM
  175. cygx_product_interior AS art
  176. WHERE
  177. art.STATUS = 1
  178. AND art.visible_range = 1
  179. AND art.match_type_id = ` + strconv.Itoa(categoryId)
  180. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  181. err = o.Raw(totalSql).QueryRow(&total)
  182. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  183. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  184. return
  185. }
  186. // 产业下所关联的文章分类列表
  187. func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  188. o := orm.NewOrm()
  189. sql := `SELECT map.match_type_name,map.category_id
  190. FROM cygx_report_mapping AS map
  191. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  192. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  193. WHERE map.report_type = 2
  194. AND map.is_report = 1
  195. AND art.is_report = 1
  196. AND art.publish_status = 1
  197. AND man_g.industrial_management_id =?
  198. AND map.chart_permission_id = ?
  199. GROUP BY map.match_type_name`
  200. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  201. return
  202. }
  203. // 产业下所关联的文章分类列表 2022-10-13
  204. func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  205. o := orm.NewOrm()
  206. sql := `SELECT map.match_type_name,map.category_id
  207. FROM cygx_report_mapping AS map
  208. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  209. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  210. WHERE map.report_type = 2
  211. AND map.is_report = 1
  212. AND art.is_report = 1
  213. AND art.publish_status = 1
  214. AND man_g.industrial_management_id =?
  215. GROUP BY map.match_type_name`
  216. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  217. return
  218. }
  219. // 产业下所关联的文章、产品内测分类列表 2023-04-14
  220. func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  221. o := orm.NewOrm()
  222. sql := `SELECT
  223. map.match_type_name,
  224. map.sort,
  225. map.id,
  226. map.id AS category_id
  227. FROM
  228. cygx_report_mapping_cygx AS map
  229. INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
  230. INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
  231. INNER JOIN cygx_article AS art ON art.category_id = cl.category_id
  232. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  233. WHERE
  234. 1 = 1
  235. AND map.report_type = 2
  236. AND map.is_report = 1
  237. AND art.is_report = 1
  238. AND art.publish_status = 1
  239. AND man_g.industrial_management_id = ?
  240. GROUP BY
  241. map.match_type_name UNION ALL
  242. SELECT
  243. map.match_type_name,
  244. map.sort,
  245. map.id,
  246. map.id AS category_id
  247. FROM
  248. cygx_report_mapping_cygx AS map
  249. INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
  250. INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id
  251. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  252. WHERE
  253. 1 = 1
  254. AND art.STATUS = 1
  255. AND art.visible_range = 1
  256. AND man_g.industrial_management_id = ?
  257. GROUP BY
  258. map.match_type_name ORDER BY id ASC , sort DESC `
  259. _, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
  260. return
  261. }
  262. // 判断用户是否阅读该产业下,某一分类的文章
  263. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  264. o := orm.NewOrm()
  265. sql := `SELECT
  266. COUNT(1) count
  267. FROM
  268. cygx_article_history_record
  269. WHERE
  270. 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
  271. category_id
  272. FROM
  273. cygx_report_mapping
  274. WHERE
  275. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  276. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  277. AND user_id = ? `
  278. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  279. return
  280. }
  281. // 获取最新文章
  282. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  283. o := orm.NewOrm()
  284. //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`
  285. 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
  286. category_id
  287. FROM
  288. cygx_report_mapping
  289. WHERE
  290. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  291. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  292. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  293. return
  294. }
  295. // 获取最新文章
  296. func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
  297. o := orm.NewOrm()
  298. 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 `
  299. err = o.Raw(sql, categoryId).QueryRow(&item)
  300. return
  301. }
  302. func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagementIds string, err error) {
  303. sql := `SELECT GROUP_CONCAT(DISTINCT industrial_management_id SEPARATOR ',') AS industrial_management_ids FROM cygx_industrial_management WHERE` + condition
  304. o := orm.NewOrm()
  305. err = o.Raw(sql).QueryRow(&industrialManagementIds)
  306. return
  307. }
  308. type ReportArticleWhichIndustrial struct {
  309. ArticleId int `description:"文章id"`
  310. Title string `description:"标题"`
  311. PublishDate string `description:"发布时间"`
  312. IndustryName string `description:"产业名称"`
  313. SubjectName string `description:"标的名称"`
  314. NickName string `description:"作者昵称"`
  315. IsRed bool `description:"是否标记红点"`
  316. Readnum int `description:"阅读数量"`
  317. IsResearch bool `description:"是否属于研选"`
  318. Pv int `description:"PV"`
  319. ImgUrlPc string `description:"图片链接"`
  320. }
  321. type ReportArticleWhichIndustrialRepList struct {
  322. HaveResearch bool `description:"是否有研选权限"`
  323. Paging *paging.PagingItem `description:"分页数据"`
  324. NickName string `description:"作者昵称"`
  325. IndustryName string `description:"产业名称"`
  326. List []*ReportArticleWhichIndustrial
  327. }
  328. // 列表
  329. func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
  330. o := orm.NewOrm()
  331. sql := `SELECT
  332. art.* ,m.industry_name,d.nick_name,
  333. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  334. ( 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
  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. sql += ` LIMIT ?,?`
  346. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  347. return
  348. }
  349. func GetWhichDepartmentCount(condition string) (count int, err error) {
  350. o := orm.NewOrm()
  351. sql := `SELECT COUNT(1) count
  352. FROM
  353. cygx_article AS art
  354. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  355. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  356. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  357. WHERE 1 = 1
  358. AND art.publish_status = 1`
  359. if condition != "" {
  360. sql += condition
  361. }
  362. err = o.Raw(sql).QueryRow(&count)
  363. return
  364. }
  365. type IsShow struct {
  366. IsShow bool `description:"绝密内参按钮是否展示"`
  367. IsShowFreeButton bool `description:"免费送月卡按钮是否展示"`
  368. IsShowResearch bool `description:"研选是否展示限免"`
  369. IsShowChart bool `description:"图表是否展示限免"`
  370. IsShowList bool `description:"榜单是否展示"`
  371. LinkWxExplain string `description:"关注微信公众号链接说明地址"`
  372. YanXuan_Explain bool `description:"研选说明"`
  373. ActivitySpecialExplain string `description:"专项调研活动"`
  374. SearchTxtList SearchTxt `description:"搜索栏回显内容说明"`
  375. IsBelongRai bool `description:"是否属于权益内部人员"`
  376. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  377. IsShowQuestionnaire bool `description:"是否展示研选问卷调查"`
  378. IsShowAboutVideo bool `description:"是否展示关于我们的视频"`
  379. IsShowMobileAndEmailButton bool `description:"是否展示手机号跟邮箱按钮"`
  380. }
  381. type SearchTxt struct {
  382. SummarySearch string `description:"素材库搜索说明"`
  383. ReportSearch string `description:"报告搜索说明"`
  384. YanXuanSearch string `description:"研选搜索说明"`
  385. ActivitySearch string `description:"活动搜索说明"`
  386. TabSearch string `description:"素材库搜索说明"`
  387. }
  388. // 获取用户是否有查看权限
  389. func GetUserIsAdminCount(mobile string) (count int, err error) {
  390. o := orm.NewOrm()
  391. sql := `SELECT COUNT(1) count FROM admin
  392. WHERE
  393. mobile = ?
  394. AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 ) AND enabled = 1`
  395. err = o.Raw(sql, mobile).QueryRow(&count)
  396. return
  397. }
  398. type ReportDetailRoadshow struct {
  399. ArticleId int `description:"报告Id"`
  400. Title string `description:"标题"`
  401. Department string `orm:"column(seller_and_mobile)"description:"作者"`
  402. PublishDate string `description:"发布时间"`
  403. VideoUrl string `description:"链接"`
  404. VideoPlaySeconds string `description:"时长"`
  405. VideoName string `description:"音频名称"`
  406. Abstract string `description:"摘要"`
  407. Body string `description:"内容"`
  408. CategoryName string `description:"行业名称"`
  409. ReportLink string `orm:"column(link_article_id)"description:"报告链接"`
  410. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  411. IsRoadShow bool `description:"是否是路演精华"`
  412. VisibleRange int `description:"设置可见范围1全部,0内部"`
  413. CategoryId int `description:"文章分类ID"`
  414. }
  415. type RoadshowDetailResp struct {
  416. Detail *ReportDetailRoadshow
  417. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  418. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  419. IsShow bool `description:"是否展示"`
  420. }
  421. func GetReportRoadshowDetailById(articleId int) (item *ReportDetailRoadshow, err error) {
  422. o := orm.NewOrm()
  423. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  424. err = o.Raw(sql, articleId).QueryRow(&item)
  425. return
  426. }
  427. type CygxIndustryAndArticleList struct {
  428. ArticleId int `orm:"column(article_id);pk"description:"报告id"`
  429. Title string `description:"标题"`
  430. PublishDate string `description:"发布时间"`
  431. IndustryName string `description:"产业名称"`
  432. SubjectName string `description:"标的名称"`
  433. }
  434. type CygxIndustrySearchList struct {
  435. ArtList []*CygxIndustryAndArticleList `description:"文章列表"`
  436. IndList []*IndustrialManagement `description:"产业列表"`
  437. }
  438. type CygxIndustrySearchListPc struct {
  439. DepartmentList []*CygxArticleDepartmentRepPc
  440. IndList []*IndustrialManagement `description:"产业列表"`
  441. }
  442. // 列表
  443. func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
  444. o := orm.NewOrm()
  445. sql := `SELECT
  446. art.title,
  447. art.article_id,
  448. art.publish_date
  449. FROM
  450. cygx_article AS art
  451. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  452. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = mg.article_id
  453. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  454. WHERE
  455. category_name LIKE '%研选%'
  456. 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 )
  457. 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 '%研选%' )
  458. GROUP BY
  459. art.article_id`
  460. _, err = o.Raw(sql).QueryRows(&items)
  461. return
  462. }
  463. func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
  464. o := orm.NewOrm()
  465. sql := `SELECT GROUP_CONCAT( DISTINCT a.article_id SEPARATOR ',' ) AS articleIds
  466. FROM cygx_article AS a
  467. WHERE subject_ids LIKE '%` + subjectId + `%'`
  468. err = o.Raw(sql).QueryRow(&articleIds)
  469. return
  470. } //end
  471. // 用户收藏榜start
  472. type ArticleCollectionResp struct {
  473. ArticleId int `description:"文章id"`
  474. Title string `description:"标题"`
  475. PublishDate string `description:"发布日期"`
  476. PublishTime time.Time `description:"发布时间"`
  477. IndustrialManagementId int `description:"产业Id"`
  478. IndustryName string `description:"产业名称"`
  479. DepartmentId int `description:"作者Id"`
  480. NickName string `description:"作者昵称"`
  481. MyCollectNum int `description:"本人是否收藏"`
  482. IsCollect bool `description:"本人是否收藏"`
  483. Pv int `description:"PV"`
  484. CollectNum int `description:"收藏人数"`
  485. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  486. ArticleTypeId int `description:"文章类型ID"`
  487. List []*IndustrialManagementResp `description:"产业列表"`
  488. IsSpecial int `description:"是否为研选专栏"`
  489. SpecialTags string `description:"研选专栏标签"`
  490. UserId int `description:"作者id"`
  491. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  492. IndustryTags string `description:"研选专栏行业标签"`
  493. CompanyTags string `description:"研选专栏公司标签"`
  494. ArticleTypeName string `description:"文章类型名称"`
  495. TopTime int `description:"置顶时间"`
  496. ReportId int `description:"FICC研报ID"`
  497. Resource int `description:"来源类型,1:文章、2:产品内测、3:FICC研报"`
  498. }
  499. type IndustrialManagementResp struct {
  500. IndustrialManagementId int `description:"产业Id"`
  501. IndustryName string `description:"产业名称"`
  502. ChartPermissionId int `description:"权限id"`
  503. }
  504. type ArticleCollectionLIstResp struct {
  505. List []*ArticleCollectionResp
  506. }
  507. // 研选报告收藏榜单列表
  508. func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition string) (items []*ArticleCollectionResp, err error) {
  509. o := orm.NewOrm()
  510. sql := `SELECT
  511. ac.id,
  512. a.category_id,
  513. a.article_id,
  514. a.title,
  515. a.body,
  516. a.annotation,
  517. a.abstract,
  518. a.publish_date,
  519. a.article_type_id,
  520. d.nick_name,
  521. d.department_id,
  522. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  523. ( 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
  524. FROM
  525. cygx_article AS a
  526. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  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
  532. AND a.publish_status = 1 `
  533. if condition != "" {
  534. sql += condition
  535. }
  536. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, a.publish_date DESC`
  537. sql += ` LIMIT ?`
  538. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  539. return
  540. }
  541. // 列表
  542. func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  543. o := orm.NewOrm()
  544. sql := `SELECT
  545. a.article_id,
  546. a.title,
  547. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  548. m.industry_name,
  549. m.industrial_management_id,
  550. d.nick_name,
  551. d.department_id,
  552. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  553. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  554. ( 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,
  555. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  556. FROM
  557. cygx_article AS a
  558. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  559. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  560. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  561. WHERE
  562. 1 = 1 AND a.publish_status = 1 `
  563. if condition != "" {
  564. sql += condition
  565. }
  566. _, err = o.Raw(sql, userId).QueryRows(&items)
  567. return
  568. } //end
  569. // 资源包研选跟研选专栏的搜索
  570. //func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int) (items []*ArticleCollectionResp, err error) {
  571. // o := orm.NewOrm()
  572. // sql := `SELECT
  573. // a.article_id,
  574. // a.title,
  575. // date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  576. // d.nick_name,
  577. // d.department_id,
  578. // a.article_type_id,
  579. // 0 AS is_special,
  580. // "" AS special_tags,
  581. // "" AS company_tags,
  582. // "" AS industry_tags,
  583. // ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  584. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  585. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
  586. // '' AS special_type,
  587. // '' AS user_id,
  588. // '' AS create_time
  589. // FROM
  590. // cygx_article AS a
  591. // INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  592. // INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  593. // INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  594. // WHERE
  595. // 1 = 1
  596. // AND a.publish_status = 1 ` + condition + ` GROUP BY article_id
  597. // UNION ALL
  598. // SELECT
  599. // a.id AS article_id,
  600. // a.title AS title,
  601. // date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
  602. // "" AS nick_name,
  603. // 0 AS department_id,
  604. // - 1 AS article_type_id,
  605. // 1 AS is_special,
  606. // a.tags AS special_tags,
  607. // a.company_tags,
  608. // a.industry_tags,
  609. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
  610. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  611. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
  612. // a.type AS special_type,
  613. // a.user_id AS user_id,
  614. // a.create_time AS create_time
  615. // FROM
  616. // cygx_yanxuan_special AS a
  617. // JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  618. // WHERE
  619. // 1 = 1
  620. // AND a.STATUS = 3 ` + conditionSpecial + ` ORDER BY publish_date DESC LIMIT 30`
  621. //
  622. // _, err = o.Raw(sql, userId, userId).QueryRows(&items)
  623. // return
  624. //} //end
  625. // 资源包研选跟研选专栏的搜索
  626. func GetArticleAndYxSpecialList(condition, conditionSpecial string, userId int) (items []*ArticleCollectionResp, err error) {
  627. o := orm.NewOrm()
  628. sql := `SELECT
  629. a.article_id,
  630. a.title,
  631. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  632. d.nick_name,
  633. d.department_id,
  634. a.article_type_id,
  635. 0 AS is_special,
  636. 0 AS pv,
  637. 0 AS collect_num,
  638. "" AS special_tags,
  639. "" AS company_tags,
  640. "" AS industry_tags,
  641. '' AS special_type,
  642. '' AS user_id,
  643. '' AS create_time
  644. FROM
  645. cygx_article AS a
  646. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  647. WHERE
  648. 1 = 1
  649. AND a.publish_status = 1 ` + condition + ` GROUP BY article_id
  650. UNION ALL
  651. SELECT
  652. a.id AS article_id,
  653. a.title AS title,
  654. date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
  655. "" AS nick_name,
  656. 0 AS department_id,
  657. - 1 AS article_type_id,
  658. 1 AS is_special,
  659. a.pv,
  660. a.article_collect_num as collect_num,
  661. a.tags AS special_tags,
  662. a.company_tags,
  663. a.industry_tags,
  664. a.type AS special_type,
  665. a.user_id AS user_id,
  666. a.create_time AS create_time
  667. FROM
  668. cygx_yanxuan_special AS a
  669. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  670. WHERE
  671. 1 = 1
  672. AND a.STATUS = 3 ` + conditionSpecial + ` ORDER BY publish_date DESC LIMIT 30`
  673. _, err = o.Raw(sql).QueryRows(&items)
  674. return
  675. } //end
  676. type ArticleResearchListResp struct {
  677. Paging *paging.PagingItem
  678. List []*ArticleResearchResp
  679. }
  680. type ArticleResearchResp struct {
  681. ArticleId int `description:"文章id"`
  682. Title string `description:"标题"`
  683. PublishDate string `description:"发布时间"`
  684. DepartmentId int `description:"作者Id"`
  685. NickName string `description:"作者昵称"`
  686. IsCollect bool `description:"本人是否收藏"`
  687. Pv int `description:"PV"`
  688. CollectNum int `description:"收藏人数"`
  689. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  690. ArticleTypeId int `description:"文章类型ID"`
  691. ArticleTypeName string `description:"类型名称"`
  692. ButtonStyle string `description:"按钮展示样式"`
  693. IsSpecial int `description:"是否为研选专栏"`
  694. SpecialTags string `description:"研选专栏标签"`
  695. UserId int `description:"作者id"`
  696. List []*IndustrialManagementResp `description:"产业列表"`
  697. TopTime int `description:"置顶时间"`
  698. }
  699. // 获取我的日程数量
  700. func GetArticleResearchCount(condition string, pars []interface{}, needYanxuanSpecial bool) (count int, err error) {
  701. o := orm.NewOrm()
  702. sqlCount := `SELECT COUNT( 1 ) AS count FROM
  703. cygx_article AS a
  704. WHERE
  705. 1 = 1 AND a.publish_status = 1` + condition
  706. if needYanxuanSpecial {
  707. sqlCount = `SELECT SUM(count) AS count FROM (` + sqlCount + `
  708. UNION ALL
  709. SELECT COUNT( 1 ) AS count FROM
  710. cygx_yanxuan_special AS a WHERE
  711. 1 = 1 AND a.status = 3) AS c`
  712. }
  713. err = o.Raw(sqlCount, pars).QueryRow(&count)
  714. return
  715. }
  716. //func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleCollectionResp, err error) {
  717. // o := orm.NewOrm()
  718. // sql := `SELECT
  719. // a.article_id,
  720. // a.title,
  721. // a.publish_date AS publish_time,
  722. // a.article_type_id,
  723. // d.nick_name,
  724. // d.department_id,
  725. // ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  726. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  727. // ( 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,
  728. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num,
  729. // 0 AS is_special,
  730. // 0 AS special_type,
  731. // 0 AS user_id,
  732. // '' AS company_tags,
  733. // '' AS industry_tags
  734. // FROM
  735. // cygx_article AS a
  736. // INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  737. // INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  738. // INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  739. // WHERE
  740. // 1 = 1 AND a.publish_status = 1
  741. // `
  742. // if condition != "" {
  743. // sql += condition
  744. // }
  745. // sql += ` GROUP BY a.article_id `
  746. // if needYanxuanSpecial {
  747. // sql += `UNION ALL
  748. // SELECT
  749. // a.id AS article_id,
  750. // a.title AS title,
  751. // a.publish_time AS publish_time,
  752. // -1 AS article_type_id,
  753. // b.nick_name AS nick_name,
  754. // a.user_id AS department_id,
  755. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
  756. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id ) AS collect_num,
  757. // 0 AS collect_num_order,
  758. // ( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id AND user_id = ? ) AS my_collect_num,
  759. // 1 AS is_special,
  760. // a.type AS special_type,
  761. // a.user_id AS user_id,
  762. // a.company_tags AS company_tags,
  763. // a.industry_tags AS industry_tags
  764. // FROM
  765. // cygx_yanxuan_special AS a
  766. // JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  767. // WHERE
  768. // 1 = 1 AND a.status = 3 `
  769. // sql += ` ORDER BY publish_time DESC LIMIT ?,? `
  770. // _, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
  771. // } else {
  772. // sql += ` ORDER BY publish_time DESC LIMIT ?,? `
  773. // _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  774. // }
  775. //
  776. // return
  777. //}
  778. func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleCollectionResp, err error) {
  779. o := orm.NewOrm()
  780. sql := `SELECT
  781. a.article_id,
  782. a.title,
  783. a.publish_date AS publish_time,
  784. a.article_type_id,
  785. d.nick_name,
  786. d.department_id,
  787. 0 AS is_special,
  788. 0 as pv,
  789. 0 as collect_num,
  790. 0 AS special_type,
  791. 0 AS user_id,
  792. '' AS company_tags,
  793. '' AS industry_tags,
  794. a.top_time
  795. FROM
  796. cygx_article AS a
  797. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  798. WHERE
  799. 1 = 1 AND a.publish_status = 1
  800. `
  801. if condition != "" {
  802. sql += condition
  803. }
  804. sql += ` GROUP BY a.article_id `
  805. if needYanxuanSpecial {
  806. sql += `UNION ALL
  807. SELECT
  808. a.id AS article_id,
  809. a.title AS title,
  810. a.publish_time AS publish_time,
  811. -1 AS article_type_id,
  812. b.nick_name AS nick_name,
  813. a.user_id AS department_id,
  814. 1 AS is_special,
  815. a.pv,
  816. a.article_collect_num as collect_num,
  817. a.type AS special_type,
  818. a.user_id AS user_id,
  819. a.company_tags AS company_tags,
  820. a.industry_tags AS industry_tags,
  821. 0 as top_time
  822. FROM
  823. cygx_yanxuan_special AS a
  824. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  825. WHERE
  826. 1 = 1 AND a.status = 3 `
  827. }
  828. sql += ` ORDER BY top_time DESC, publish_time DESC LIMIT ?,? `
  829. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  830. return
  831. }
  832. // 用户收藏榜start
  833. type IndustrialManagementHotResp struct {
  834. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  835. IndustryName string `description:"产业名称"`
  836. IsFollw bool `description:"是否关注"`
  837. FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
  838. FllowNum int `description:"关注数量"`
  839. IsNew bool `description:"是否新标签"`
  840. IsHot bool `description:"是否新标签"`
  841. IsRed bool `description:"是否标记红点"`
  842. Readnum int `description:"阅读数量"`
  843. PublishDate string `description:"发布时间"`
  844. MinReportTime string `description:"报告最早发布时间"`
  845. ArticleReadNum int `description:"文章阅读数量"`
  846. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  847. TimeLineData string `description:"时间线所关联最新三篇文章的json数据"`
  848. ListTimeLine []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
  849. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  850. IndustryVideo *MicroVideoSimpleInfo `description:"产业视频"`
  851. AuthInfo *UserPermissionAuthInfo
  852. }
  853. type IndustrialManagementHotListResp struct {
  854. Paging *paging.PagingItem `description:"分页数据"`
  855. List []*IndustrialManagementHotResp
  856. }
  857. // 产业列表
  858. func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  859. o := orm.NewOrm()
  860. sql := `SELECT
  861. m.industry_name,
  862. m.industrial_management_id,
  863. m.article_read_num,
  864. MAX( a.publish_date ) AS publish_date,
  865. MIN(a.publish_date) AS min_report_time,
  866. ( 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,
  867. m.yanxuan_article_read_num + m.activity_num AS sum_num
  868. FROM
  869. cygx_industrial_management AS m
  870. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  871. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  872. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  873. WHERE
  874. 1 = 1
  875. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  876. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  877. return
  878. }
  879. // 获取数量
  880. func GetThemeHeatListCount(condition string) (count int, err error) {
  881. o := orm.NewOrm()
  882. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  883. cygx_industrial_management AS m
  884. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  885. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  886. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  887. WHERE
  888. 1 = 1
  889. AND a.publish_status = 1 ` + condition
  890. err = o.Raw(sql).QueryRow(&count)
  891. return
  892. }
  893. // 标的列表
  894. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  895. o := orm.NewOrm()
  896. sql := `SELECT
  897. m.subject_name,
  898. m.industrial_management_id,
  899. m.industrial_subject_id
  900. FROM
  901. cygx_article AS a
  902. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  903. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  904. WHERE
  905. 1 = 1`
  906. if condition != "" {
  907. sql += condition
  908. }
  909. sql += ` AND publish_status = 1
  910. GROUP BY
  911. m.industrial_subject_id
  912. ORDER BY
  913. publish_date DESC`
  914. _, err = o.Raw(sql).QueryRows(&items)
  915. return
  916. } //end
  917. // Kol sratr
  918. type DepartmentResp struct {
  919. DepartmentId int `description:"作者Id"`
  920. NickName string `description:"作者昵称"`
  921. ImgUrl string `description:"图片链接"`
  922. IsFollw bool `description:"是否关注"`
  923. IsHot bool `description:"是否关注"`
  924. FllowNum int `description:"关注数量"`
  925. List []*IndustrialDepartmentListResp
  926. }
  927. type DepartmentListResp struct {
  928. Paging *paging.PagingItem `description:"分页数据"`
  929. List []*DepartmentResp
  930. }
  931. type IndustrialDepartmentListResp struct {
  932. IndustrialManagementId int `description:"产业Id"`
  933. IndustryName string `description:"产业名称"`
  934. DepartmentId int `description:"作者Id"`
  935. }
  936. // 作者列表
  937. func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
  938. o := orm.NewOrm()
  939. sql := `SELECT
  940. d.nick_name,
  941. d.department_id,
  942. d.img_url,
  943. MAX( a.publish_date ) AS publish_date,
  944. ( 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,
  945. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND f.type= 1 ) AS sum_num
  946. FROM
  947. cygx_article_department AS d
  948. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  949. WHERE
  950. 1 = 1
  951. AND publish_status = 1 ` + condition + `
  952. GROUP BY
  953. d.department_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  954. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  955. return
  956. }
  957. // 获取数量
  958. func GetDepartmentlistCount(condition string) (count int, err error) {
  959. o := orm.NewOrm()
  960. sql := `SELECT
  961. count(*) AS count
  962. FROM
  963. (
  964. SELECT
  965. COUNT( 1 ) AS count
  966. FROM
  967. cygx_article_department AS d
  968. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  969. WHERE
  970. 1 = 1
  971. AND a.article_type_id > 0
  972. AND publish_status = 1
  973. GROUP BY
  974. d.department_id
  975. ) c `
  976. err = o.Raw(sql).QueryRow(&count)
  977. return
  978. }
  979. // 作者文章所关联的产业列表
  980. func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
  981. o := orm.NewOrm()
  982. sql := `SELECT
  983. m.industrial_management_id,
  984. m.industry_name,
  985. d.department_id
  986. FROM
  987. cygx_article_department AS d
  988. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  989. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  990. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  991. WHERE
  992. 1 = 1
  993. AND a.article_type_id > 0
  994. AND publish_status = 1
  995. ORDER BY
  996. a.publish_date DESC`
  997. _, err = o.Raw(sql).QueryRows(&items)
  998. return
  999. }
  1000. // 主题详情start
  1001. type GetThemeDetailListResp struct {
  1002. ArticleId int `description:"文章id"`
  1003. Title string `description:"标题"`
  1004. PublishDate string `description:"发布时间"`
  1005. SubjectName string `description:"标的名称"`
  1006. IndustrialSubjectId int `description:"标的id"`
  1007. DepartmentId int `description:"作者Id"`
  1008. NickName string `description:"作者昵称"`
  1009. Pv int `description:"PV"`
  1010. CollectNum int `description:"收藏人数"`
  1011. IndustrialManagementId int `description:"产业Id"`
  1012. IndustryName string `description:"产业名称"`
  1013. FllowNum int `description:"关注数量"`
  1014. MyCollectNum int `description:"本人是否收藏"`
  1015. IsCollect bool `description:"本人是否收藏"`
  1016. }
  1017. type GetThemeAericleListResp struct {
  1018. ArticleId int `description:"文章id"`
  1019. Title string `description:"标题"`
  1020. PublishDate string `description:"发布时间"`
  1021. SubjectName string `description:"标的名称"`
  1022. IndustrialSubjectId int `description:"标的ID"`
  1023. DepartmentId int `description:"作者Id"`
  1024. NickName string `description:"作者昵称"`
  1025. Pv int `description:"PV"`
  1026. CollectNum int `description:"收藏人数"`
  1027. FllowNum int `description:"关注数量"`
  1028. MyCollectNum int `description:"本人是否收藏"`
  1029. IsCollect bool `description:"本人是否收藏"`
  1030. }
  1031. type GetThemeAericleListBuSubjectResp struct {
  1032. SubjectName string `description:"标的名称"`
  1033. List []*GetThemeAericleListResp
  1034. }
  1035. // 主题详情start
  1036. type GetThemeDetailResp struct {
  1037. IndustrialManagementId int `description:"产业Id"`
  1038. IndustryName string `description:"产业名称"`
  1039. IsFollw bool `description:"是否关注"`
  1040. FollowType int `description:"1,重点关注,3不感兴趣,0默认接受推送"`
  1041. ListSubject []*IndustrialSubject `description:"标的列表"`
  1042. List []*GetThemeAericleListResp
  1043. }
  1044. // 列表
  1045. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
  1046. o := orm.NewOrm()
  1047. sql := `SELECT
  1048. a.article_id,
  1049. a.title,
  1050. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1051. m.industry_name,
  1052. m.industrial_management_id,
  1053. d.nick_name,
  1054. d.department_id,
  1055. s.industrial_subject_id,
  1056. s.subject_name,
  1057. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1058. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1059. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
  1060. ( 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
  1061. FROM
  1062. cygx_article AS a
  1063. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1064. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1065. LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id
  1066. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
  1067. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  1068. WHERE
  1069. 1 = 1
  1070. AND m.industrial_management_id = ?
  1071. AND publish_status = 1 ` + condition + ` GROUP BY article_id
  1072. ORDER BY
  1073. publish_date DESC`
  1074. _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
  1075. return
  1076. } //end
  1077. // 用户收藏榜start
  1078. type DepartmentDetailResp struct {
  1079. DepartmentId int `description:"作者Id"`
  1080. NickName string `description:"作者昵称"`
  1081. ImgUrl string `description:"图片链接"`
  1082. FllowNum int `description:"多少人关注"`
  1083. ArticleNum int `description:"文章数量"`
  1084. CollectNum int `description:"收藏人数"`
  1085. IsFllow bool `description:"是否关注"`
  1086. List []*ArticleCollectionResp
  1087. ListIndustrial []*IndustrialManagementNewResp
  1088. }
  1089. type DepartmentDetail struct {
  1090. DepartmentId int `description:"作者Id"`
  1091. NickName string `description:"作者昵称"`
  1092. ImgUrl string `description:"图片链接"`
  1093. FllowNum int `description:"多少人关注"`
  1094. ArticleNum int `description:"文章数量"`
  1095. CollectNum int `description:"收藏人数"`
  1096. IsFllow bool `description:"是否关注"`
  1097. MyFllowNum int `description:"本人是否关注"`
  1098. }
  1099. // 列表
  1100. func GetDepartmentDetail(userId, departmentId int, condition string) (item DepartmentDetail, err error) {
  1101. o := orm.NewOrm()
  1102. sql := `SELECT
  1103. d.department_id,
  1104. d.nick_name,
  1105. d.img_url,
  1106. ( 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,
  1107. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND f.type= 1 ) AS fllow_num,
  1108. ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + ` ) AS article_num,
  1109. ( SELECT count( 1 ) FROM cygx_article_collect AS c WHERE c.article_id IN (SELECT article_id FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + ` )) AS collect_num
  1110. FROM
  1111. cygx_article_department AS d
  1112. WHERE
  1113. d.department_id = ?`
  1114. err = o.Raw(sql, userId, departmentId).QueryRow(&item)
  1115. return
  1116. } //end
  1117. // 报告搜索start
  1118. type ReoprtSearchResp struct {
  1119. ListYx []*ArticleCollectionResp `description:"研选报告"`
  1120. ListHz []*ArticleCollectionResp `description:"弘则报告"`
  1121. }
  1122. //// 列表
  1123. //func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  1124. // o := orm.NewOrm()
  1125. // sql := `SELECT
  1126. // a.article_id,
  1127. // a.title,
  1128. // date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1129. // m.industry_name,
  1130. // m.industrial_management_id,
  1131. // ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1132. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1133. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  1134. // FROM
  1135. // cygx_article AS a
  1136. // LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1137. // LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1138. // WHERE
  1139. // 1 = 1 `
  1140. // if condition != "" {
  1141. // sql += condition
  1142. // }
  1143. // _, err = o.Raw(sql, userId).QueryRows(&items)
  1144. // return
  1145. //} //end
  1146. // 列表
  1147. func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  1148. o := orm.NewOrm()
  1149. sql := `SELECT
  1150. a.article_id,
  1151. a.report_id,
  1152. a.title,
  1153. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1154. m.industry_name,
  1155. m.industrial_management_id
  1156. FROM
  1157. cygx_article AS a
  1158. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1159. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1160. WHERE
  1161. 1 = 1 `
  1162. if condition != "" {
  1163. sql += condition
  1164. }
  1165. _, err = o.Raw(sql).QueryRows(&items)
  1166. return
  1167. } //end
  1168. // 搜索资源包 start
  1169. type SearchResourceResp struct {
  1170. ListHz []*IndustrialManagementHotResp `description:"弘则"`
  1171. ListYx []*IndustrialManagementHotResp `description:"研选"`
  1172. }
  1173. // 搜索资源包 start
  1174. type SearchReportAndResourceResp struct {
  1175. ListHzResource []*IndustrialManagement `description:"弘则资源包"`
  1176. ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
  1177. ListYxReport []*ArticleCollectionResp `description:"研选报告"`
  1178. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  1179. }
  1180. // 产业列表
  1181. func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  1182. o := orm.NewOrm()
  1183. sql := `SELECT
  1184. m.time_line_data,
  1185. m.industry_name,
  1186. m.industrial_management_id,
  1187. MAX( a.publish_date ) as publish_date_order,
  1188. MIN(a.publish_date) AS min_report_time,
  1189. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  1190. (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
  1191. FROM
  1192. cygx_industrial_management AS m
  1193. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1194. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  1195. WHERE
  1196. 1 = 1
  1197. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  1198. if startSize > 0 || pageSize > 0 {
  1199. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1200. }
  1201. _, err = o.Raw(sql).QueryRows(&items)
  1202. return
  1203. }
  1204. // 列表
  1205. func GetSearchResourceListcondition(condition string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
  1206. o := orm.NewOrm()
  1207. sql := `SELECT
  1208. m.time_line_data,
  1209. m.industry_name,
  1210. m.chart_permission_id,
  1211. m.industrial_management_id,
  1212. MAX( a.publish_date ) as publish_date_order,
  1213. MIN( a.publish_date ) AS min_report_time,
  1214. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
  1215. FROM
  1216. cygx_industrial_management AS m
  1217. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1218. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  1219. WHERE
  1220. 1 = 1
  1221. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  1222. if startSize > 0 || pageSize > 0 {
  1223. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1224. }
  1225. _, err = o.Raw(sql).QueryRows(&items)
  1226. return
  1227. }
  1228. // 切换列表
  1229. type ReportBillboardTableResp struct {
  1230. Name string `description:"名称"`
  1231. Source int `description:"类型"`
  1232. List []*ChartPermission
  1233. }
  1234. // 切换列表
  1235. type ReportBillboardTableListResp struct {
  1236. List []*ReportBillboardTableResp
  1237. }
  1238. // 报告榜单start
  1239. type ArticleReportBillboardResp struct {
  1240. ArticleId int `description:"文章id"`
  1241. Title string `description:"标题"`
  1242. PublishDate string `description:"发布时间"`
  1243. PermissionName string `description:"行业名称"`
  1244. DepartmentId int `description:"作者Id"`
  1245. NickName string `description:"作者昵称"`
  1246. IsCollect bool `description:"本人是否收藏"`
  1247. Pv int `description:"PV"`
  1248. CollectNum int `description:"收藏人数"`
  1249. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  1250. IsRoadShow bool `description:"是否是路演精华"`
  1251. CategoryId int `description:"分类ID"`
  1252. IsResearch bool `description:"是否属于研选"`
  1253. ArticleTypeId int `description:"文章类型ID"`
  1254. ArticleTypeName string `description:"文章类型名称"`
  1255. IsSpecial int `description:"是否为研选专栏"`
  1256. SpecialTags string `description:"研选专栏标签"`
  1257. MyCollectNum int `description:"本人是否收藏"`
  1258. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  1259. UserId int `description:"作者id"`
  1260. List []*IndustrialManagementIdInt
  1261. }
  1262. type ArticleReportBillboardLIstResp struct {
  1263. List []*ArticleReportBillboardResp
  1264. }
  1265. type ArticleReportBillboardLIstPageResp struct {
  1266. List []*ArticleReportBillboardResp
  1267. Paging *paging.PagingItem
  1268. }
  1269. // 报告收藏榜单列表
  1270. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  1271. o := orm.NewOrm()
  1272. sql := `SELECT
  1273. ac.id,
  1274. a.article_id,
  1275. a.title,
  1276. date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
  1277. m.chart_permission_name AS permission_name,
  1278. COUNT(ac.id) AS collection_num
  1279. FROM
  1280. cygx_article AS a
  1281. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  1282. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  1283. WHERE
  1284. 1 = 1
  1285. AND a.publish_status = 1 `
  1286. if condition != "" {
  1287. sql += condition
  1288. }
  1289. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  1290. sql += ` LIMIT ?`
  1291. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  1292. return
  1293. }
  1294. // 报告阅读榜单列表
  1295. func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  1296. o := orm.NewOrm()
  1297. sql := `SELECT
  1298. a.article_id,
  1299. a.title,
  1300. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date
  1301. FROM
  1302. cygx_article AS a
  1303. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  1304. WHERE
  1305. 1 = 1
  1306. AND a.publish_status = 1 `
  1307. if condition != "" {
  1308. sql += condition
  1309. }
  1310. _, err = o.Raw(sql, pars).QueryRows(&items)
  1311. return
  1312. }
  1313. // 获取产业报告+晨会点评数量
  1314. func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
  1315. o := orm.NewOrm()
  1316. sql := `SELECT SUM(count) AS count FROM (
  1317. SELECT
  1318. COUNT( 1 ) count
  1319. FROM
  1320. cygx_article AS a
  1321. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  1322. WHERE
  1323. a.publish_status = 1
  1324. AND a.is_class = 1
  1325. AND man_g.industrial_management_id = ?
  1326. UNION ALL
  1327. SELECT
  1328. COUNT( 1 ) count
  1329. FROM
  1330. cygx_morning_meeting_review_chapter AS mmc
  1331. INNER JOIN cygx_morning_meeting_reviews AS mm
  1332. WHERE
  1333. mm.id = mmc.meeting_id
  1334. AND mm.status = 1
  1335. AND mmc.industry_id = ? UNION ALL
  1336. SELECT
  1337. COUNT( 1 ) count
  1338. FROM
  1339. cygx_product_interior AS p
  1340. INNER JOIN cygx_product_interior_industrial_group_management AS pm
  1341. WHERE
  1342. p.product_interior_id = pm.product_interior_id
  1343. AND p.visible_range = 1
  1344. AND pm.industrial_management_id = ? ) AS t `
  1345. err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&count)
  1346. return
  1347. }
  1348. type TimeLineReportItem struct {
  1349. Id int `description:"文章或晨报点评id"`
  1350. Title string `description:"标题"`
  1351. PublishTime string `description:"发布时间"`
  1352. Content string `description:"内容"`
  1353. VideoUrl string `description:"视频链接"`
  1354. VoiceUrl string `description:"音频链接"`
  1355. VoicePlaySeconds string `description:"音频时长"`
  1356. IsHaveVideo bool `description:"是否包含视频"`
  1357. ImgUrlPc string `description:"pc图片"`
  1358. SubCategoryName string `description:"二级分类"`
  1359. IsRed bool `description:"是否标红"`
  1360. Readnum int `description:"阅读数量"`
  1361. Resource int `description:"来源类型,1:文章、2:产品内测、3:晨报点评 4:活动回放视频 5:活动回放音频 "`
  1362. LinkArticleId int `description:"晨会精华报告ID链接"`
  1363. ListSubject []*CygxIndustrialSubject `description:"标的列表"`
  1364. }
  1365. // 获取产业报告+晨会点评列表
  1366. func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  1367. o := orm.NewOrm()
  1368. sql := `SELECT
  1369. *
  1370. FROM
  1371. (
  1372. SELECT
  1373. a.article_id AS id,
  1374. a.title,
  1375. a.publish_date AS publish_time,
  1376. a.video_url,
  1377. '' AS voice_url,
  1378. a.sub_category_name,
  1379. '' AS content,
  1380. 1 AS resource,
  1381. '' AS voice_play_seconds,
  1382. ( 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
  1383. FROM
  1384. cygx_article AS a
  1385. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  1386. WHERE
  1387. a.publish_status = 1
  1388. AND a.is_class = 1
  1389. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  1390. SELECT
  1391. mmc.id,
  1392. mmc.title,
  1393. mm.publish_time AS publish_time,
  1394. '' AS video_url,
  1395. '' AS voice_url,
  1396. '时间线' AS sub_category_name,
  1397. mmc.content,
  1398. 3 AS resource,
  1399. '' AS voice_play_seconds,
  1400. 0 AS readnum
  1401. FROM
  1402. cygx_morning_meeting_review_chapter AS mmc
  1403. INNER JOIN cygx_morning_meeting_reviews AS mm
  1404. WHERE
  1405. mm.id = mmc.meeting_id
  1406. AND mm.STATUS = 1
  1407. AND mmc.industry_id = ? UNION ALL
  1408. SELECT
  1409. p.product_interior_id AS id,
  1410. p.title,
  1411. p.publish_time,
  1412. '' AS video_url,
  1413. '' AS voice_url,
  1414. '' AS sub_category_name,
  1415. '' AS content,
  1416. 2 AS resource,
  1417. '' AS voice_play_seconds,
  1418. 0 AS readnum
  1419. FROM
  1420. cygx_product_interior AS p
  1421. INNER JOIN cygx_product_interior_industrial_group_management AS pm
  1422. WHERE
  1423. p.product_interior_id = pm.product_interior_id
  1424. AND p.visible_range = 1
  1425. AND pm.industrial_management_id = ? UNION ALL
  1426. SELECT
  1427. ca.activity_id AS id,
  1428. cav.video_name AS title,
  1429. ca.activity_time AS publish_time,
  1430. cav.video_url AS video_url,
  1431. '' AS voice_url,
  1432. '' AS sub_category_name,
  1433. '' AS content,
  1434. 4 AS resource,
  1435. '' AS voice_play_seconds,
  1436. ( 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
  1437. FROM
  1438. cygx_activity AS ca
  1439. INNER JOIN cygx_activity_video AS cav ON ca.activity_id = cav.activity_id
  1440. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  1441. WHERE
  1442. cam.industrial_management_id = ? AND cam.source = 1 UNION ALL
  1443. SELECT
  1444. ca.activity_id AS id,
  1445. cavo.voice_name AS title,
  1446. ca.activity_time AS publish_time,
  1447. '' AS video_url,
  1448. cavo.voice_url AS voice_url,
  1449. '' AS sub_category_name,
  1450. '' AS content,
  1451. 5 AS resource,
  1452. cavo.voice_play_seconds AS voice_play_seconds,
  1453. ( 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
  1454. FROM
  1455. cygx_activity AS ca
  1456. INNER JOIN cygx_activity_voice AS cavo ON ca.activity_id = cavo.activity_id
  1457. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  1458. WHERE
  1459. cam.industrial_management_id = ? AND cam.source = 1
  1460. ) AS t
  1461. `
  1462. sql += ` ORDER BY
  1463. t.publish_time DESC LIMIT ?,? `
  1464. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  1465. return
  1466. }
  1467. type ArticleIdReq struct {
  1468. ArticleId int `description:"文章id"`
  1469. PlaySeconds int `description:"播放时长"`
  1470. PageRouter string `description:"页面路径"`
  1471. }
  1472. type IndustrialReadNum struct {
  1473. IndustrialManagementId int `description:"产业id"`
  1474. Readnum int `description:"阅读次数"`
  1475. }
  1476. // 获取该产业下文章的用户阅读次数-小红点用
  1477. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  1478. o := orm.NewOrm()
  1479. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  1480. 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
  1481. FROM
  1482. cygx_article AS a
  1483. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  1484. WHERE
  1485. a.publish_status = 1
  1486. AND a.is_class = 1
  1487. AND man_g.industrial_management_id IN (` + industrialIds + `)
  1488. AND a.publish_date > ?
  1489. GROUP BY a.article_id ORDER BY publish_date DESC
  1490. ) AS a GROUP BY industrial_management_id`
  1491. _, err = o.Raw(sql, createtime).QueryRows(&items)
  1492. return
  1493. }
  1494. // 获取行业报告列表
  1495. func GetReportAndproductIndustrylListimgZhouqi(condition string, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
  1496. o := orm.NewOrm()
  1497. sql := `SELECT
  1498. art.article_id,
  1499. art.report_id,
  1500. art.body,
  1501. art.annotation,
  1502. art.abstract,
  1503. art.category_id,
  1504. art.title,
  1505. art.publish_date,
  1506. 1 AS resource
  1507. FROM
  1508. cygx_article AS art
  1509. WHERE
  1510. art.publish_status = 1 AND category_name = '周期' ` + condition
  1511. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1512. err = o.Raw(totalSql).QueryRow(&total)
  1513. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  1514. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  1515. return
  1516. }