report.go 53 KB

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