report.go 63 KB

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