report.go 61 KB

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