report.go 64 KB

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