report.go 61 KB

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