report.go 55 KB

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