report.go 62 KB

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