report.go 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  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 IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  104. o := orm.NewOrm()
  105. sql := `SELECT map.match_type_name,map.category_id
  106. FROM cygx_report_mapping AS map
  107. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  108. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  109. WHERE map.report_type = 2
  110. AND map.is_report = 1
  111. AND art.is_report = 1
  112. AND art.publish_status = 1
  113. AND man_g.industrial_management_id =?
  114. AND map.chart_permission_id = ?
  115. GROUP BY map.match_type_name`
  116. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  117. return
  118. }
  119. //产业下所关联的文章分类列表 2022-10-13
  120. func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  121. o := orm.NewOrm()
  122. sql := `SELECT map.match_type_name,map.category_id
  123. FROM cygx_report_mapping AS map
  124. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  125. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  126. WHERE map.report_type = 2
  127. AND map.is_report = 1
  128. AND art.is_report = 1
  129. AND art.publish_status = 1
  130. AND man_g.industrial_management_id =?
  131. GROUP BY map.match_type_name`
  132. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  133. return
  134. }
  135. //判断用户是否阅读该产业下,某一分类的文章
  136. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  137. o := orm.NewOrm()
  138. sql := `SELECT
  139. COUNT(1) count
  140. FROM
  141. cygx_article_history_record
  142. WHERE
  143. 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
  144. category_id
  145. FROM
  146. cygx_report_mapping
  147. WHERE
  148. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  149. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  150. AND user_id = ? `
  151. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  152. return
  153. }
  154. //获取最新文章
  155. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  156. o := orm.NewOrm()
  157. //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`
  158. 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
  159. category_id
  160. FROM
  161. cygx_report_mapping
  162. WHERE
  163. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  164. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  165. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  166. return
  167. }
  168. //获取最新文章
  169. func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
  170. o := orm.NewOrm()
  171. sql := ` SELECT * FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
  172. err = o.Raw(sql, categoryId).QueryRow(&item)
  173. return
  174. }
  175. func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagementIds string, err error) {
  176. sql := `SELECT GROUP_CONCAT(DISTINCT industrial_management_id SEPARATOR ',') AS industrial_management_ids FROM cygx_industrial_management WHERE` + condition
  177. o := orm.NewOrm()
  178. err = o.Raw(sql).QueryRow(&industrialManagementIds)
  179. return
  180. }
  181. type ReportArticleWhichIndustrial struct {
  182. ArticleId int `description:"文章id"`
  183. Title string `description:"标题"`
  184. PublishDate string `description:"发布时间"`
  185. IndustryName string `description:"产业名称"`
  186. SubjectName string `description:"标的名称"`
  187. NickName string `description:"作者昵称"`
  188. IsRed bool `description:"是否标记红点"`
  189. Readnum int `description:"阅读数量"`
  190. IsResearch bool `description:"是否属于研选"`
  191. Pv int `description:"PV"`
  192. ImgUrlPc string `description:"图片链接"`
  193. }
  194. type ReportArticleWhichIndustrialRepList struct {
  195. HaveResearch bool `description:"是否有研选权限"`
  196. Paging *paging.PagingItem `description:"分页数据"`
  197. NickName string `description:"作者昵称"`
  198. IndustryName string `description:"产业名称"`
  199. List []*ReportArticleWhichIndustrial
  200. }
  201. //列表
  202. func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
  203. o := orm.NewOrm()
  204. sql := `SELECT
  205. art.* ,m.industry_name,d.nick_name,
  206. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  207. ( 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
  208. FROM
  209. cygx_article AS art
  210. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  211. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  212. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  213. WHERE 1 = 1
  214. AND art.publish_status = 1`
  215. if condition != "" {
  216. sql += condition
  217. }
  218. sql += ` LIMIT ?,?`
  219. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  220. return
  221. }
  222. func GetWhichDepartmentCount(condition string) (count int, err error) {
  223. o := orm.NewOrm()
  224. sql := `SELECT COUNT(1) count
  225. FROM
  226. cygx_article AS art
  227. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  228. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  229. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  230. WHERE 1 = 1
  231. AND art.publish_status = 1`
  232. if condition != "" {
  233. sql += condition
  234. }
  235. err = o.Raw(sql).QueryRow(&count)
  236. return
  237. }
  238. type IsShow struct {
  239. IsShow bool `description:"绝密内参按钮是否展示"`
  240. IsShowFreeButton bool `description:"免费送月卡按钮是否展示"`
  241. IsShowResearch bool `description:"研选是否展示限免"`
  242. IsShowChart bool `description:"图表是否展示限免"`
  243. IsShowList bool `description:"榜单是否展示"`
  244. LinkWxExplain string `description:"关注微信公众号链接说明地址"`
  245. YanXuan_Explain bool `description:"研选说明"`
  246. ActivitySpecialExplain string `description:"专项调研活动"`
  247. SearchTxtList SearchTxt `description:"搜索栏回显内容说明"`
  248. }
  249. type SearchTxt struct {
  250. SummarySearch string `description:"素材库搜索说明"`
  251. ReportSearch string `description:"报告搜索说明"`
  252. YanXuanSearch string `description:"研选搜索说明"`
  253. ActivitySearch string `description:"活动搜索说明"`
  254. TabSearch string `description:"素材库搜索说明"`
  255. }
  256. //获取用户是否有查看权限
  257. func GetUserIsAdminCount(mobile string) (count int, err error) {
  258. o := orm.NewOrm()
  259. sql := `SELECT COUNT(1) count FROM admin
  260. WHERE
  261. mobile = ?
  262. AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 ) AND enabled = 1`
  263. err = o.Raw(sql, mobile).QueryRow(&count)
  264. return
  265. }
  266. type ReportDetailRoadshow struct {
  267. ArticleId int `description:"报告Id"`
  268. Title string `description:"标题"`
  269. Department string `orm:"column(seller_and_mobile)"description:"作者"`
  270. PublishDate string `description:"发布时间"`
  271. VideoUrl string `description:"链接"`
  272. VideoPlaySeconds string `description:"时长"`
  273. VideoName string `description:"音频名称"`
  274. Abstract string `description:"摘要"`
  275. Body string `description:"内容"`
  276. CategoryName string `description:"行业名称"`
  277. ReportLink string `orm:"column(link_article_id)"description:"报告链接"`
  278. }
  279. type RoadshowDetailResp struct {
  280. Detail *ReportDetailRoadshow
  281. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  282. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  283. }
  284. func GetReportRoadshowDetailById(articleId int) (item *ReportDetailRoadshow, err error) {
  285. o := orm.NewOrm()
  286. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  287. err = o.Raw(sql, articleId).QueryRow(&item)
  288. return
  289. }
  290. type CygxIndustryAndArticleList struct {
  291. ArticleId int `orm:"column(article_id);pk"description:"报告id"`
  292. Title string `description:"标题"`
  293. PublishDate string `description:"发布时间"`
  294. IndustryName string `description:"产业名称"`
  295. SubjectName string `description:"标的名称"`
  296. }
  297. type CygxIndustrySearchList struct {
  298. ArtList []*CygxIndustryAndArticleList `description:"文章列表"`
  299. IndList []*IndustrialManagement `description:"产业列表"`
  300. }
  301. type CygxIndustrySearchListPc struct {
  302. DepartmentList []*CygxArticleDepartmentRepPc
  303. IndList []*IndustrialManagement `description:"产业列表"`
  304. }
  305. //列表
  306. func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
  307. o := orm.NewOrm()
  308. sql := `SELECT
  309. art.title,
  310. art.article_id,
  311. art.publish_date
  312. FROM
  313. cygx_article AS art
  314. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  315. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = mg.article_id
  316. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  317. WHERE
  318. category_name LIKE '%研选%'
  319. 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 )
  320. 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 '%研选%' )
  321. GROUP BY
  322. art.article_id`
  323. _, err = o.Raw(sql).QueryRows(&items)
  324. return
  325. }
  326. func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
  327. o := orm.NewOrm()
  328. sql := `SELECT GROUP_CONCAT( DISTINCT a.article_id SEPARATOR ',' ) AS articleIds
  329. FROM cygx_article AS a
  330. WHERE subject_ids LIKE '%` + subjectId + `%'`
  331. err = o.Raw(sql).QueryRow(&articleIds)
  332. return
  333. } //end
  334. //用户收藏榜start
  335. type ArticleCollectionResp struct {
  336. ArticleId int `description:"文章id"`
  337. Title string `description:"标题"`
  338. PublishDate string `description:"发布时间"`
  339. IndustrialManagementId int `description:"产业Id"`
  340. IndustryName string `description:"产业名称"`
  341. DepartmentId int `description:"作者Id"`
  342. NickName string `description:"作者昵称"`
  343. MyCollectNum int `description:"本人是否收藏"`
  344. IsCollect bool `description:"本人是否收藏"`
  345. Pv int `description:"PV"`
  346. CollectNum int `description:"收藏人数"`
  347. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  348. List []*IndustrialManagementResp `description:"产业列表"`
  349. }
  350. type IndustrialManagementResp struct {
  351. IndustrialManagementId int `description:"产业Id"`
  352. IndustryName string `description:"产业名称"`
  353. ChartPermissionId int `description:"权限id"`
  354. }
  355. type ArticleCollectionLIstResp struct {
  356. List []*ArticleCollectionResp
  357. }
  358. //列表
  359. func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  360. o := orm.NewOrm()
  361. sql := `SELECT
  362. a.article_id,
  363. a.title,
  364. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  365. m.industry_name,
  366. m.industrial_management_id,
  367. d.nick_name,
  368. d.department_id,
  369. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  370. ( 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,
  371. ( 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,
  372. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  373. FROM
  374. cygx_article AS a
  375. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  376. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  377. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  378. WHERE
  379. 1 = 1 AND a.publish_status = 1 `
  380. if condition != "" {
  381. sql += condition
  382. }
  383. _, err = o.Raw(sql, userId).QueryRows(&items)
  384. return
  385. } //end
  386. //用户收藏榜start
  387. type IndustrialManagementHotResp struct {
  388. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  389. IndustryName string `description:"产业名称"`
  390. IsFollw bool `description:"是否关注"`
  391. FllowNum int `description:"关注数量"`
  392. IsNew bool `description:"是否新标签"`
  393. IsHot bool `description:"是否新标签"`
  394. IsRed bool `description:"是否标记红点"`
  395. Readnum int `description:"阅读数量"`
  396. PublishDate string `description:"发布时间"`
  397. MinReportTime string `description:"报告最早发布时间"`
  398. ArticleReadNum int `description:"文章阅读数量"`
  399. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  400. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  401. IndustryVideo *MicroVideoSimpleInfo `description:"产业视频"`
  402. AuthInfo *UserPermissionAuthInfo
  403. }
  404. type IndustrialManagementHotListResp struct {
  405. Paging *paging.PagingItem `description:"分页数据"`
  406. List []*IndustrialManagementHotResp
  407. }
  408. //产业列表
  409. func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  410. o := orm.NewOrm()
  411. sql := `SELECT
  412. m.industry_name,
  413. m.industrial_management_id,
  414. m.article_read_num,
  415. MAX( a.publish_date ) AS publish_date,
  416. MIN(a.publish_date) AS min_report_time,
  417. ( 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,
  418. m.article_read_num + ( SELECT count( 1 ) FROM cygx_activity_meet_detail_log AS la WHERE la.activity_id IN (SELECT activity_id FROM cygx_industrial_activity_group_management WHERE industrial_management_id = m.industrial_management_id ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( la.activity_time ) ) AS sum_num
  419. FROM
  420. cygx_industrial_management AS m
  421. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  422. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  423. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  424. WHERE
  425. 1 = 1
  426. AND a.article_type_id > 0
  427. AND publish_status = 1
  428. GROUP BY m.industrial_management_id ` + condition + ` LIMIT ?,?`
  429. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  430. return
  431. }
  432. //获取数量
  433. func GetThemeHeatListCount(condition string) (count int, err error) {
  434. o := orm.NewOrm()
  435. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  436. cygx_industrial_management AS m
  437. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  438. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  439. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  440. WHERE
  441. 1 = 1
  442. AND a.article_type_id > 0 AND a.publish_status = 1 ` + condition
  443. err = o.Raw(sql).QueryRow(&count)
  444. return
  445. }
  446. //标的列表
  447. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  448. o := orm.NewOrm()
  449. sql := `SELECT
  450. m.subject_name,
  451. m.industrial_management_id,
  452. m.industrial_subject_id
  453. FROM
  454. cygx_article AS a
  455. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  456. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  457. WHERE
  458. 1 = 1`
  459. if condition != "" {
  460. sql += condition
  461. }
  462. sql += ` AND publish_status = 1
  463. GROUP BY
  464. m.industrial_subject_id
  465. ORDER BY
  466. publish_date DESC`
  467. _, err = o.Raw(sql).QueryRows(&items)
  468. return
  469. } //end
  470. //Kol sratr
  471. type DepartmentResp struct {
  472. DepartmentId int `description:"作者Id"`
  473. NickName string `description:"作者昵称"`
  474. ImgUrl string `description:"图片链接"`
  475. IsFollw bool `description:"是否关注"`
  476. FllowNum int `description:"关注数量"`
  477. List []*IndustrialDepartmentListResp
  478. }
  479. type DepartmentListResp struct {
  480. List []*DepartmentResp
  481. }
  482. type IndustrialDepartmentListResp struct {
  483. IndustrialManagementId int `description:"产业Id"`
  484. IndustryName string `description:"产业名称"`
  485. DepartmentId int `description:"作者Id"`
  486. }
  487. //作者列表
  488. func GetDepartmentList(userId int) (items []*DepartmentResp, err error) {
  489. o := orm.NewOrm()
  490. sql := `SELECT
  491. d.nick_name,
  492. d.department_id,
  493. d.img_url,
  494. ( 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,
  495. ( 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 ) +( 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 IN (SELECT article_id FROM cygx_article WHERE department_id = d.department_id ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS sum_num
  496. FROM
  497. cygx_article_department AS d
  498. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  499. WHERE
  500. 1 = 1
  501. AND a.article_type_id > 0
  502. AND publish_status = 1
  503. GROUP BY
  504. d.department_id
  505. ORDER BY
  506. sum_num DESC
  507. LIMIT 15`
  508. _, err = o.Raw(sql, userId).QueryRows(&items)
  509. return
  510. }
  511. //作者文章所关联的产业列表
  512. func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
  513. o := orm.NewOrm()
  514. sql := `SELECT
  515. m.industrial_management_id,
  516. m.industry_name,
  517. d.department_id
  518. FROM
  519. cygx_article_department AS d
  520. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  521. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  522. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  523. WHERE
  524. 1 = 1
  525. AND a.article_type_id > 0
  526. AND publish_status = 1
  527. GROUP BY
  528. a.article_id
  529. ORDER BY
  530. a.publish_date DESC`
  531. _, err = o.Raw(sql).QueryRows(&items)
  532. return
  533. }
  534. //主题详情start
  535. type GetThemeDetailListResp struct {
  536. ArticleId int `description:"文章id"`
  537. Title string `description:"标题"`
  538. PublishDate string `description:"发布时间"`
  539. SubjectName string `description:"标的名称"`
  540. IndustrialSubjectId int `description:"标的id"`
  541. DepartmentId int `description:"作者Id"`
  542. NickName string `description:"作者昵称"`
  543. Pv int `description:"PV"`
  544. CollectNum int `description:"收藏人数"`
  545. IndustrialManagementId int `description:"产业Id"`
  546. IndustryName string `description:"产业名称"`
  547. FllowNum int `description:"关注数量"`
  548. MyCollectNum int `description:"本人是否收藏"`
  549. IsCollect bool `description:"本人是否收藏"`
  550. }
  551. type GetThemeAericleListResp struct {
  552. ArticleId int `description:"文章id"`
  553. Title string `description:"标题"`
  554. PublishDate string `description:"发布时间"`
  555. SubjectName string `description:"标的名称"`
  556. IndustrialSubjectId int `description:"标的ID"`
  557. DepartmentId int `description:"作者Id"`
  558. NickName string `description:"作者昵称"`
  559. Pv int `description:"PV"`
  560. CollectNum int `description:"收藏人数"`
  561. FllowNum int `description:"关注数量"`
  562. MyCollectNum int `description:"本人是否收藏"`
  563. IsCollect bool `description:"本人是否收藏"`
  564. }
  565. type GetThemeAericleListBuSubjectResp struct {
  566. SubjectName string `description:"标的名称"`
  567. List []*GetThemeAericleListResp
  568. }
  569. //主题详情start
  570. type GetThemeDetailResp struct {
  571. IndustrialManagementId int `description:"产业Id"`
  572. IndustryName string `description:"产业名称"`
  573. IsFollw bool `description:"是否关注"`
  574. ListSubject []*IndustrialSubject `description:"标的列表"`
  575. List []*GetThemeAericleListResp
  576. }
  577. //列表
  578. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
  579. o := orm.NewOrm()
  580. sql := `SELECT
  581. a.article_id,
  582. a.title,
  583. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  584. m.industry_name,
  585. m.industrial_management_id,
  586. d.nick_name,
  587. d.department_id,
  588. s.industrial_subject_id,
  589. s.subject_name,
  590. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  591. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  592. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
  593. ( 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
  594. FROM
  595. cygx_article AS a
  596. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  597. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  598. LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id
  599. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
  600. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  601. WHERE
  602. 1 = 1
  603. AND m.industrial_management_id = ?
  604. AND publish_status = 1 ` + condition + `
  605. ORDER BY
  606. publish_date DESC`
  607. _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
  608. return
  609. } //end
  610. //用户收藏榜start
  611. type DepartmentDetailResp struct {
  612. DepartmentId int `description:"作者Id"`
  613. NickName string `description:"作者昵称"`
  614. ImgUrl string `description:"图片链接"`
  615. FllowNum int `description:"多少人关注"`
  616. ArticleNum int `description:"文章数量"`
  617. CollectNum int `description:"收藏人数"`
  618. IsFllow bool `description:"是否关注"`
  619. List []*ArticleCollectionResp
  620. ListIndustrial []*IndustrialManagementNewResp
  621. }
  622. type DepartmentDetail struct {
  623. DepartmentId int `description:"作者Id"`
  624. NickName string `description:"作者昵称"`
  625. ImgUrl string `description:"图片链接"`
  626. FllowNum int `description:"多少人关注"`
  627. ArticleNum int `description:"文章数量"`
  628. CollectNum int `description:"收藏人数"`
  629. IsFllow bool `description:"是否关注"`
  630. MyFllowNum int `description:"本人是否关注"`
  631. }
  632. //列表
  633. func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err error) {
  634. o := orm.NewOrm()
  635. sql := `SELECT
  636. d.department_id,
  637. d.nick_name,
  638. d.img_url,
  639. ( 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,
  640. ( 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,
  641. ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ) AS article_num,
  642. ( 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 )) AS collect_num
  643. FROM
  644. cygx_article_department AS d
  645. WHERE
  646. d.department_id = ?`
  647. err = o.Raw(sql, userId, departmentId).QueryRow(&item)
  648. return
  649. } //end
  650. //报告搜索start
  651. type ReoprtSearchResp struct {
  652. ListYx []*ArticleCollectionResp `description:"研选报告"`
  653. ListHz []*ArticleCollectionResp `description:"弘则报告"`
  654. }
  655. //列表
  656. func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  657. o := orm.NewOrm()
  658. sql := `SELECT
  659. a.article_id,
  660. a.title,
  661. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  662. m.industry_name,
  663. m.industrial_management_id,
  664. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  665. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  666. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  667. FROM
  668. cygx_article AS a
  669. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  670. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  671. WHERE
  672. 1 = 1 `
  673. if condition != "" {
  674. sql += condition
  675. }
  676. _, err = o.Raw(sql, userId).QueryRows(&items)
  677. return
  678. } //end
  679. //搜索资源包 start
  680. type SearchResourceResp struct {
  681. ListHz []*IndustrialManagementHotResp `description:"弘则"`
  682. ListYx []*IndustrialManagementHotResp `description:"研选"`
  683. }
  684. //搜索资源包 start
  685. type SearchReportAndResourceResp struct {
  686. ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
  687. ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
  688. ListYxReport []*ArticleCollectionResp `description:"研选报告"`
  689. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  690. }
  691. //产业列表
  692. func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  693. o := orm.NewOrm()
  694. sql := `SELECT
  695. m.industry_name,
  696. m.industrial_management_id,
  697. MAX( a.publish_date ) as publish_date_order,
  698. MIN(a.publish_date) AS min_report_time,
  699. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  700. (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
  701. FROM
  702. cygx_industrial_management AS m
  703. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  704. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  705. WHERE
  706. 1 = 1
  707. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  708. if startSize > 0 || pageSize > 0 {
  709. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  710. }
  711. _, err = o.Raw(sql).QueryRows(&items)
  712. return
  713. }
  714. //切换列表
  715. type ReportBillboardTableResp struct {
  716. Name string `description:"名称"`
  717. Source int `description:"类型"`
  718. List []*ChartPermission
  719. }
  720. //切换列表
  721. type ReportBillboardTableListResp struct {
  722. List []*ReportBillboardTableResp
  723. }
  724. //报告榜单start
  725. type ArticleReportBillboardResp struct {
  726. ArticleId int `description:"文章id"`
  727. Title string `description:"标题"`
  728. PublishDate string `description:"发布时间"`
  729. PermissionName string `description:"行业名称"`
  730. DepartmentId int `description:"作者Id"`
  731. NickName string `description:"作者昵称"`
  732. IsCollect bool `description:"本人是否收藏"`
  733. Pv int `description:"PV"`
  734. CollectNum int `description:"收藏人数"`
  735. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  736. List []*IndustrialManagementIdInt
  737. }
  738. type ArticleReportBillboardLIstResp struct {
  739. List []*ArticleReportBillboardResp
  740. }
  741. type ArticleReportBillboardLIstPageResp struct {
  742. List []*ArticleReportBillboardResp
  743. Paging *paging.PagingItem
  744. }
  745. //报告收藏榜单列表
  746. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  747. o := orm.NewOrm()
  748. sql := `SELECT
  749. ac.id,
  750. a.article_id,
  751. a.title,
  752. date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
  753. m.chart_permission_name AS permission_name,
  754. COUNT(ac.id) AS collection_num
  755. FROM
  756. cygx_article AS a
  757. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  758. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  759. WHERE
  760. 1 = 1
  761. AND a.publish_status = 1 `
  762. if condition != "" {
  763. sql += condition
  764. }
  765. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  766. sql += ` LIMIT ?`
  767. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  768. return
  769. }
  770. //报告阅读榜单列表
  771. func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  772. o := orm.NewOrm()
  773. sql := `SELECT
  774. a.article_id,
  775. a.title,
  776. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date
  777. FROM
  778. cygx_article AS a
  779. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  780. WHERE
  781. 1 = 1
  782. AND a.publish_status = 1 `
  783. if condition != "" {
  784. sql += condition
  785. }
  786. _, err = o.Raw(sql, pars).QueryRows(&items)
  787. return
  788. }
  789. //获取产业报告+晨会点评数量
  790. func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
  791. o := orm.NewOrm()
  792. sql := `SELECT SUM(count) AS count FROM (
  793. SELECT
  794. COUNT( 1 ) count
  795. FROM
  796. cygx_article AS a
  797. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  798. WHERE
  799. a.publish_status = 1
  800. AND a.is_class = 1
  801. AND man_g.industrial_management_id = ?
  802. UNION ALL
  803. SELECT
  804. COUNT( 1 ) count
  805. FROM
  806. cygx_morning_meeting_review_chapter AS mmc
  807. INNER JOIN cygx_morning_meeting_reviews AS mm
  808. WHERE
  809. mm.id = mmc.meeting_id
  810. AND mm.status = 1
  811. AND mmc.industry_id = ? ) AS t `
  812. err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRow(&count)
  813. return
  814. }
  815. type TimeLineReportItem struct {
  816. Id int `description:"文章或晨报点评id"`
  817. Title string `description:"标题"`
  818. PublishTime string `description:"发布时间"`
  819. Content string `description:"内容"`
  820. VideoUrl string `description:"视频链接"`
  821. IsHaveVideo bool `description:"是否包含视频"`
  822. ImgUrlPc string `description:"pc图片"`
  823. SubCategoryName string `description:"二级分类"`
  824. IsRed bool `description:"是否标红"`
  825. Readnum int `description:"阅读数量"`
  826. }
  827. //获取产业报告+晨会点评列表
  828. func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  829. o := orm.NewOrm()
  830. sql := `SELECT
  831. *
  832. FROM
  833. (
  834. SELECT
  835. a.article_id AS id,
  836. a.title,
  837. a.publish_date AS publish_time,
  838. a.video_url,
  839. a.sub_category_name,
  840. '' AS content,
  841. ( 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
  842. FROM
  843. cygx_article AS a
  844. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  845. WHERE
  846. a.publish_status = 1
  847. AND a.is_class = 1
  848. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  849. SELECT
  850. mmc.id,
  851. '' AS title,
  852. mm.publish_time AS publish_time,
  853. '' AS video_url,
  854. '时间线' AS sub_category_name,
  855. mmc.content,
  856. 0 AS readnum
  857. FROM
  858. cygx_morning_meeting_review_chapter AS mmc
  859. INNER JOIN cygx_morning_meeting_reviews AS mm
  860. WHERE
  861. mm.id = mmc.meeting_id
  862. AND mm.STATUS = 1
  863. AND mmc.industry_id = ?
  864. ) AS t
  865. `
  866. sql += ` ORDER BY
  867. t.publish_time DESC LIMIT ?,? `
  868. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  869. return
  870. }
  871. type ArticleIdReq struct {
  872. ArticleId int `description:"文章id"`
  873. PlaySeconds int `description:"播放时长"`
  874. PageRouter string `description:"页面路径"`
  875. }
  876. type IndustrialReadNum struct {
  877. IndustrialManagementId int `description:"产业id"`
  878. Readnum int `description:"阅读次数"`
  879. }
  880. //获取该产业下文章的用户阅读次数-小红点用
  881. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  882. o := orm.NewOrm()
  883. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  884. 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
  885. FROM
  886. cygx_article AS a
  887. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  888. WHERE
  889. a.publish_status = 1
  890. AND a.is_class = 1
  891. AND man_g.industrial_management_id IN (` + industrialIds + `)
  892. AND a.publish_date > ?
  893. GROUP BY a.article_id ORDER BY publish_date DESC
  894. ) AS a GROUP BY industrial_management_id`
  895. _, err = o.Raw(sql, createtime).QueryRows(&items)
  896. return
  897. }