report.go 62 KB

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