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