report.go 64 KB

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