report.go 64 KB

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