report.go 61 KB

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