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. }
  13. type IndustrialManagement struct {
  14. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  15. IndustryName string `description:"产业名称"`
  16. RecommendedIndex int `description:"推荐指数"`
  17. CategoryId int `description:"文章分类ID"`
  18. LayoutTime string `description:"布局时间"`
  19. UpdateTime string `description:"更新时间"`
  20. PublishDate string `description:"更新时间"`
  21. MinReportTime string `description:"报告最早发布时间"`
  22. IsRed bool `description:"是否标记红点"`
  23. IsTop bool `description:"是否置顶"`
  24. IsHot bool `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
  25. IsFollow int `description:"是否关注"`
  26. IsNew bool `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
  27. Analyst string `description:"分析师"`
  28. ArticleReadNum int `description:"文章阅读数量"`
  29. OneMonFollowNum int `description:"近一个月关注增量"`
  30. AnalystList []*IndustrialAnalyst `description:"分析师列表"`
  31. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  32. ChartPermissionId int `description:"行业ID"`
  33. PermissionName string `description:"行业名称"`
  34. TimeLineData string `description:"时间线所关联最新三篇文章的json数据"`
  35. ListTimeLine []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
  36. IndustryVideo *MicroVideoSimpleInfo
  37. AuthInfo *UserPermissionAuthInfo
  38. ArticleId int `description:"文章id"`
  39. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  40. }
  41. type TimeLineReportResp struct {
  42. Title string `description:"标题"`
  43. PublishDate string `description:"发布时间"`
  44. }
  45. type MicroVideoSimpleInfo struct {
  46. Id int `description:"视频ID"`
  47. Title string `description:"标题"`
  48. ResourceUrl string `description:"链接"`
  49. BackgroundImg string `description:"背景图"`
  50. PlaySeconds int `description:"音视频时长"`
  51. DetailImgUrl string `description:"产业详情页背景图"`
  52. ChartPermissionId int `description:"行业ID"`
  53. ChartPermissionName string `description:"行业名称"`
  54. }
  55. type IndustrialAnalyst struct {
  56. AnalystName string `description:"分析师名称"`
  57. IndustrialManagementId int `description:"产业id"`
  58. }
  59. type IndustrialSubject struct {
  60. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  61. IndustrialManagementId int `description:"产业id"`
  62. SubjectName string `description:"标的名称"`
  63. IndustryName string `description:"产业名称"`
  64. LayoutTime string `description:"产业布局时间"`
  65. }
  66. // 获取产业报告数量
  67. func GetReportIndustrialCount(categoryId, industrialManagementId int) (count int, err error) {
  68. o := orm.NewOrm()
  69. sql := `SELECT COUNT(1) count
  70. FROM
  71. cygx_article AS a
  72. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  73. WHERE
  74. a.publish_status = 1
  75. AND category_id IN (SELECT
  76. category_id
  77. FROM
  78. cygx_report_mapping
  79. WHERE
  80. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  81. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  82. AND a.is_class = 1
  83. AND man_g.industrial_management_id = ? `
  84. err = o.Raw(sql, industrialManagementId).QueryRow(&count)
  85. return
  86. }
  87. // 获取产业报告列表
  88. func GetReportIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
  89. o := orm.NewOrm()
  90. 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
  91. FROM
  92. cygx_article AS a
  93. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  94. WHERE
  95. a.publish_status = 1
  96. AND category_id IN (SELECT
  97. category_id
  98. FROM
  99. cygx_report_mapping
  100. WHERE
  101. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  102. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  103. AND a.is_class = 1
  104. AND man_g.industrial_management_id = ?`
  105. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  106. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  107. return
  108. }
  109. // 获取产业报告列表
  110. func GetReportAndproductInteriorIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
  111. o := orm.NewOrm()
  112. sql := `SELECT
  113. art.article_id,
  114. art.title,
  115. art.publish_date,
  116. ( 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 ,
  117. 1 AS resource
  118. FROM
  119. cygx_article AS art
  120. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  121. WHERE
  122. art.publish_status = 1
  123. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` )
  124. AND art.is_class = 1
  125. AND man_g.industrial_management_id =` + strconv.Itoa(industrialManagementId) + `
  126. GROUP BY
  127. art.article_id UNION ALL
  128. SELECT
  129. art.product_interior_id AS article_id,
  130. art.title,
  131. art.publish_time AS publish_date,
  132. ( 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 ,
  133. 2 AS resource
  134. FROM
  135. cygx_product_interior AS art
  136. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  137. WHERE
  138. art.STATUS = 1
  139. AND art.visible_range = 1
  140. AND art.match_type_id = ` + strconv.Itoa(categoryId) + `
  141. AND man_g.industrial_management_id = ` + strconv.Itoa(industrialManagementId) + `
  142. GROUP BY
  143. art.product_interior_id `
  144. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  145. err = o.Raw(totalSql, pars).QueryRow(&total)
  146. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  147. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  148. return
  149. }
  150. // 获取行业报告列表
  151. func GetReportAndproductIndustrylList(categoryId, startSize, pageSize int) (items []*ReportArticle, total int, err error) {
  152. o := orm.NewOrm()
  153. sql := `SELECT
  154. art.article_id,
  155. art.report_id,
  156. art.title,
  157. art.abstract,
  158. art.publish_date,
  159. 1 AS resource
  160. FROM
  161. cygx_article AS art
  162. WHERE
  163. art.publish_status = 1
  164. AND art.article_id IN ( SELECT article_id FROM cygx_report_mapping_category_group WHERE id_cygx = ` + strconv.Itoa(categoryId) + ` ) UNION ALL
  165. SELECT
  166. art.product_interior_id AS article_id,
  167. 0 AS report_id,
  168. art.title,
  169. "" as abstract,
  170. art.publish_time AS publish_date,
  171. 2 AS resource
  172. FROM
  173. cygx_product_interior AS art
  174. WHERE
  175. art.STATUS = 1
  176. AND art.visible_range = 1
  177. AND art.match_type_id = ` + strconv.Itoa(categoryId)
  178. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  179. err = o.Raw(totalSql).QueryRow(&total)
  180. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  181. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  182. return
  183. }
  184. // 产业下所关联的文章分类列表
  185. func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  186. o := orm.NewOrm()
  187. sql := `SELECT map.match_type_name,map.category_id
  188. FROM cygx_report_mapping AS map
  189. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  190. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  191. WHERE map.report_type = 2
  192. AND map.is_report = 1
  193. AND art.is_report = 1
  194. AND art.publish_status = 1
  195. AND man_g.industrial_management_id =?
  196. AND map.chart_permission_id = ?
  197. GROUP BY map.match_type_name`
  198. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  199. return
  200. }
  201. // 产业下所关联的文章分类列表 2022-10-13
  202. func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  203. o := orm.NewOrm()
  204. sql := `SELECT map.match_type_name,map.category_id
  205. FROM cygx_report_mapping AS map
  206. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  207. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  208. WHERE map.report_type = 2
  209. AND map.is_report = 1
  210. AND art.is_report = 1
  211. AND art.publish_status = 1
  212. AND man_g.industrial_management_id =?
  213. GROUP BY map.match_type_name`
  214. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  215. return
  216. }
  217. // 产业下所关联的文章、产品内测分类列表 2023-04-14
  218. func IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  219. o := orm.NewOrm()
  220. sql := `SELECT
  221. map.match_type_name,
  222. map.sort,
  223. map.id,
  224. map.id AS category_id
  225. FROM
  226. cygx_report_mapping_cygx AS map
  227. INNER JOIN cygx_report_mapping_group AS g ON g.id_cygx = map.id
  228. INNER JOIN cygx_report_mapping_celue AS cl ON cl.category_id = g.category_id_celue
  229. INNER JOIN cygx_article AS art ON art.category_id = cl.category_id
  230. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  231. WHERE
  232. 1 = 1
  233. AND map.report_type = 2
  234. AND map.is_report = 1
  235. AND art.is_report = 1
  236. AND art.publish_status = 1
  237. AND man_g.industrial_management_id = ?
  238. GROUP BY
  239. map.match_type_name UNION ALL
  240. SELECT
  241. map.match_type_name,
  242. map.sort,
  243. map.id,
  244. map.id AS category_id
  245. FROM
  246. cygx_report_mapping_cygx AS map
  247. INNER JOIN cygx_industrial_management AS im ON im.chart_permission_id = map.chart_permission_id
  248. INNER JOIN cygx_product_interior AS art ON art.match_type_id = map.id
  249. INNER JOIN cygx_product_interior_industrial_group_management AS man_g ON man_g.product_interior_id = art.product_interior_id
  250. WHERE
  251. 1 = 1
  252. AND art.STATUS = 1
  253. AND art.visible_range = 1
  254. AND man_g.industrial_management_id = ?
  255. GROUP BY
  256. map.match_type_name ORDER BY id ASC , sort DESC `
  257. _, err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRows(&items)
  258. return
  259. }
  260. // 判断用户是否阅读该产业下,某一分类的文章
  261. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  262. o := orm.NewOrm()
  263. sql := `SELECT
  264. COUNT(1) count
  265. FROM
  266. cygx_article_history_record
  267. WHERE
  268. 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
  269. category_id
  270. FROM
  271. cygx_report_mapping
  272. WHERE
  273. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  274. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  275. AND user_id = ? `
  276. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  277. return
  278. }
  279. // 获取最新文章
  280. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  281. o := orm.NewOrm()
  282. //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`
  283. 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
  284. category_id
  285. FROM
  286. cygx_report_mapping
  287. WHERE
  288. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  289. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  290. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  291. return
  292. }
  293. // 获取最新文章
  294. func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
  295. o := orm.NewOrm()
  296. 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 `
  297. err = o.Raw(sql, categoryId).QueryRow(&item)
  298. return
  299. }
  300. func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagementIds string, err error) {
  301. sql := `SELECT GROUP_CONCAT(DISTINCT industrial_management_id SEPARATOR ',') AS industrial_management_ids FROM cygx_industrial_management WHERE` + condition
  302. o := orm.NewOrm()
  303. err = o.Raw(sql).QueryRow(&industrialManagementIds)
  304. return
  305. }
  306. type ReportArticleWhichIndustrial struct {
  307. ArticleId int `description:"文章id"`
  308. Title string `description:"标题"`
  309. PublishDate string `description:"发布时间"`
  310. IndustryName string `description:"产业名称"`
  311. SubjectName string `description:"标的名称"`
  312. NickName string `description:"作者昵称"`
  313. IsRed bool `description:"是否标记红点"`
  314. Readnum int `description:"阅读数量"`
  315. IsResearch bool `description:"是否属于研选"`
  316. Pv int `description:"PV"`
  317. ImgUrlPc string `description:"图片链接"`
  318. }
  319. type ReportArticleWhichIndustrialRepList struct {
  320. HaveResearch bool `description:"是否有研选权限"`
  321. Paging *paging.PagingItem `description:"分页数据"`
  322. NickName string `description:"作者昵称"`
  323. IndustryName string `description:"产业名称"`
  324. List []*ReportArticleWhichIndustrial
  325. }
  326. // 列表
  327. func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
  328. o := orm.NewOrm()
  329. sql := `SELECT
  330. art.* ,m.industry_name,d.nick_name,
  331. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  332. ( 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
  333. FROM
  334. cygx_article AS art
  335. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  336. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  337. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  338. WHERE 1 = 1
  339. AND art.publish_status = 1`
  340. if condition != "" {
  341. sql += condition
  342. }
  343. sql += ` LIMIT ?,?`
  344. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  345. return
  346. }
  347. func GetWhichDepartmentCount(condition string) (count int, err error) {
  348. o := orm.NewOrm()
  349. sql := `SELECT COUNT(1) count
  350. FROM
  351. cygx_article AS art
  352. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  353. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  354. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  355. WHERE 1 = 1
  356. AND art.publish_status = 1`
  357. if condition != "" {
  358. sql += condition
  359. }
  360. err = o.Raw(sql).QueryRow(&count)
  361. return
  362. }
  363. type IsShow struct {
  364. IsShow bool `description:"绝密内参按钮是否展示"`
  365. IsShowFreeButton bool `description:"免费送月卡按钮是否展示"`
  366. IsShowResearch bool `description:"研选是否展示限免"`
  367. IsShowChart bool `description:"图表是否展示限免"`
  368. IsShowList bool `description:"榜单是否展示"`
  369. LinkWxExplain string `description:"关注微信公众号链接说明地址"`
  370. YanXuan_Explain bool `description:"研选说明"`
  371. ActivitySpecialExplain string `description:"专项调研活动"`
  372. SearchTxtList SearchTxt `description:"搜索栏回显内容说明"`
  373. IsBelongRai bool `description:"是否属于权益内部人员"`
  374. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  375. IsShowQuestionnaire bool `description:"是否展示研选问卷调查"`
  376. IsShowAboutVideo bool `description:"是否展示关于我们的视频"`
  377. IsShowMobileAndEmailButton bool `description:"是否展示手机号跟邮箱按钮"`
  378. IsShowTerminateButton bool `description:"是否弹到期提醒的弹窗"`
  379. EndData string `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. CategoryId int `description:"文章分类ID"`
  413. VisibleRange int `description:"设置可见范围1全部,0内部"`
  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. FllowNum int `description:"关注数量"`
  839. IsNew bool `description:"是否新标签"`
  840. IsHot bool `description:"是否新标签"`
  841. IsRed bool `description:"是否标记红点"`
  842. Readnum int `description:"阅读数量"`
  843. PublishDate string `description:"发布时间"`
  844. MinReportTime string `description:"报告最早发布时间"`
  845. ArticleReadNum int `description:"文章阅读数量"`
  846. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  847. TimeLineData string `description:"时间线所关联最新三篇文章的json数据"`
  848. ListTimeLine []TimeLineReportResp `description:"时间线所关联最新三篇文章列表"`
  849. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  850. IndustryVideo *MicroVideoSimpleInfo `description:"产业视频"`
  851. AuthInfo *UserPermissionAuthInfo
  852. }
  853. type IndustrialManagementHotListResp struct {
  854. Paging *paging.PagingItem `description:"分页数据"`
  855. List []*IndustrialManagementHotResp
  856. }
  857. // 产业列表
  858. func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  859. o := orm.NewOrm()
  860. sql := `SELECT
  861. m.industry_name,
  862. m.industrial_management_id,
  863. m.article_read_num,
  864. MAX( a.publish_date ) AS publish_date,
  865. MIN(a.publish_date) AS min_report_time,
  866. ( 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,
  867. m.yanxuan_article_read_num + m.activity_num AS sum_num
  868. FROM
  869. cygx_industrial_management AS m
  870. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  871. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  872. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  873. WHERE
  874. 1 = 1
  875. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  876. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  877. return
  878. }
  879. // 获取数量
  880. func GetThemeHeatListCount(condition string) (count int, err error) {
  881. o := orm.NewOrm()
  882. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  883. cygx_industrial_management AS m
  884. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  885. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  886. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  887. WHERE
  888. 1 = 1
  889. AND a.publish_status = 1 ` + condition
  890. err = o.Raw(sql).QueryRow(&count)
  891. return
  892. }
  893. // 标的列表
  894. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  895. o := orm.NewOrm()
  896. sql := `SELECT
  897. m.subject_name,
  898. m.industrial_management_id,
  899. m.industrial_subject_id
  900. FROM
  901. cygx_article AS a
  902. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  903. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  904. WHERE
  905. 1 = 1`
  906. if condition != "" {
  907. sql += condition
  908. }
  909. sql += ` AND publish_status = 1
  910. GROUP BY
  911. m.industrial_subject_id
  912. ORDER BY
  913. publish_date DESC`
  914. _, err = o.Raw(sql).QueryRows(&items)
  915. return
  916. } //end
  917. // Kol sratr
  918. type DepartmentResp struct {
  919. DepartmentId int `description:"作者Id"`
  920. NickName string `description:"作者昵称"`
  921. ImgUrl string `description:"图片链接"`
  922. IsFollw bool `description:"是否关注"`
  923. IsHot bool `description:"是否关注"`
  924. FllowNum int `description:"关注数量"`
  925. List []*IndustrialDepartmentListResp
  926. }
  927. type DepartmentListResp struct {
  928. Paging *paging.PagingItem `description:"分页数据"`
  929. List []*DepartmentResp
  930. }
  931. type IndustrialDepartmentListResp struct {
  932. IndustrialManagementId int `description:"产业Id"`
  933. IndustryName string `description:"产业名称"`
  934. DepartmentId int `description:"作者Id"`
  935. }
  936. // 作者列表
  937. func GetDepartmentList(condition, conditionOrder string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
  938. o := orm.NewOrm()
  939. sql := `SELECT
  940. d.nick_name,
  941. d.department_id,
  942. d.img_url,
  943. MAX( a.publish_date ) AS publish_date,
  944. ( 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,
  945. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND f.type= 1 ) AS sum_num
  946. FROM
  947. cygx_article_department AS d
  948. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  949. WHERE
  950. 1 = 1
  951. AND publish_status = 1 ` + condition + `
  952. GROUP BY
  953. d.department_id ` + conditionOrder + ` , last_updated_time DESC LIMIT ?,?`
  954. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  955. return
  956. }
  957. // 获取数量
  958. func GetDepartmentlistCount(condition string) (count int, err error) {
  959. o := orm.NewOrm()
  960. sql := `SELECT
  961. count(*) AS count
  962. FROM
  963. (
  964. SELECT
  965. COUNT( 1 ) AS count
  966. FROM
  967. cygx_article_department AS d
  968. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  969. WHERE
  970. 1 = 1
  971. AND a.article_type_id > 0
  972. AND publish_status = 1
  973. GROUP BY
  974. d.department_id
  975. ) c `
  976. err = o.Raw(sql).QueryRow(&count)
  977. return
  978. }
  979. // 作者文章所关联的产业列表
  980. func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
  981. o := orm.NewOrm()
  982. sql := `SELECT
  983. m.industrial_management_id,
  984. m.industry_name,
  985. d.department_id
  986. FROM
  987. cygx_article_department AS d
  988. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  989. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  990. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  991. WHERE
  992. 1 = 1
  993. AND a.article_type_id > 0
  994. AND publish_status = 1
  995. ORDER BY
  996. a.publish_date DESC`
  997. _, err = o.Raw(sql).QueryRows(&items)
  998. return
  999. }
  1000. // 主题详情start
  1001. type GetThemeDetailListResp struct {
  1002. ArticleId int `description:"文章id"`
  1003. Title string `description:"标题"`
  1004. PublishDate string `description:"发布时间"`
  1005. SubjectName string `description:"标的名称"`
  1006. IndustrialSubjectId int `description:"标的id"`
  1007. DepartmentId int `description:"作者Id"`
  1008. NickName string `description:"作者昵称"`
  1009. Pv int `description:"PV"`
  1010. CollectNum int `description:"收藏人数"`
  1011. IndustrialManagementId int `description:"产业Id"`
  1012. IndustryName string `description:"产业名称"`
  1013. FllowNum int `description:"关注数量"`
  1014. MyCollectNum int `description:"本人是否收藏"`
  1015. IsCollect bool `description:"本人是否收藏"`
  1016. }
  1017. type GetThemeAericleListResp struct {
  1018. ArticleId int `description:"文章id"`
  1019. Title string `description:"标题"`
  1020. PublishDate string `description:"发布时间"`
  1021. SubjectName string `description:"标的名称"`
  1022. IndustrialSubjectId int `description:"标的ID"`
  1023. DepartmentId int `description:"作者Id"`
  1024. NickName string `description:"作者昵称"`
  1025. Pv int `description:"PV"`
  1026. CollectNum int `description:"收藏人数"`
  1027. FllowNum int `description:"关注数量"`
  1028. MyCollectNum int `description:"本人是否收藏"`
  1029. IsCollect bool `description:"本人是否收藏"`
  1030. }
  1031. type GetThemeAericleListBuSubjectResp struct {
  1032. SubjectName string `description:"标的名称"`
  1033. List []*GetThemeAericleListResp
  1034. }
  1035. // 主题详情start
  1036. type GetThemeDetailResp struct {
  1037. IndustrialManagementId int `description:"产业Id"`
  1038. IndustryName string `description:"产业名称"`
  1039. IsFollw bool `description:"是否关注"`
  1040. ListSubject []*IndustrialSubject `description:"标的列表"`
  1041. List []*GetThemeAericleListResp
  1042. }
  1043. // 列表
  1044. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
  1045. o := orm.NewOrm()
  1046. sql := `SELECT
  1047. a.article_id,
  1048. a.title,
  1049. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1050. m.industry_name,
  1051. m.industrial_management_id,
  1052. d.nick_name,
  1053. d.department_id,
  1054. s.industrial_subject_id,
  1055. s.subject_name,
  1056. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1057. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1058. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
  1059. ( 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
  1060. FROM
  1061. cygx_article AS a
  1062. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1063. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1064. LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id
  1065. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
  1066. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  1067. WHERE
  1068. 1 = 1
  1069. AND m.industrial_management_id = ?
  1070. AND publish_status = 1 ` + condition + ` GROUP BY article_id
  1071. ORDER BY
  1072. publish_date DESC`
  1073. _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
  1074. return
  1075. } //end
  1076. // 用户收藏榜start
  1077. type DepartmentDetailResp struct {
  1078. DepartmentId int `description:"作者Id"`
  1079. NickName string `description:"作者昵称"`
  1080. ImgUrl string `description:"图片链接"`
  1081. FllowNum int `description:"多少人关注"`
  1082. ArticleNum int `description:"文章数量"`
  1083. CollectNum int `description:"收藏人数"`
  1084. IsFllow bool `description:"是否关注"`
  1085. List []*ArticleCollectionResp
  1086. ListIndustrial []*IndustrialManagementNewResp
  1087. }
  1088. type DepartmentDetail struct {
  1089. DepartmentId int `description:"作者Id"`
  1090. NickName string `description:"作者昵称"`
  1091. ImgUrl string `description:"图片链接"`
  1092. FllowNum int `description:"多少人关注"`
  1093. ArticleNum int `description:"文章数量"`
  1094. CollectNum int `description:"收藏人数"`
  1095. IsFllow bool `description:"是否关注"`
  1096. MyFllowNum int `description:"本人是否关注"`
  1097. }
  1098. // 列表
  1099. func GetDepartmentDetail(userId, departmentId int, condition string) (item DepartmentDetail, err error) {
  1100. o := orm.NewOrm()
  1101. sql := `SELECT
  1102. d.department_id,
  1103. d.nick_name,
  1104. d.img_url,
  1105. ( 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,
  1106. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f WHERE f.department_id = d.department_id AND f.type= 1 ) AS fllow_num,
  1107. ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ` + condition + ` ) AS article_num,
  1108. ( 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
  1109. FROM
  1110. cygx_article_department AS d
  1111. WHERE
  1112. d.department_id = ?`
  1113. err = o.Raw(sql, userId, departmentId).QueryRow(&item)
  1114. return
  1115. } //end
  1116. // 报告搜索start
  1117. type ReoprtSearchResp struct {
  1118. ListYx []*ArticleCollectionResp `description:"研选报告"`
  1119. ListHz []*ArticleCollectionResp `description:"弘则报告"`
  1120. }
  1121. //// 列表
  1122. //func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  1123. // o := orm.NewOrm()
  1124. // sql := `SELECT
  1125. // a.article_id,
  1126. // a.title,
  1127. // date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1128. // m.industry_name,
  1129. // m.industrial_management_id,
  1130. // ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  1131. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  1132. // ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  1133. // FROM
  1134. // cygx_article AS a
  1135. // LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1136. // LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1137. // WHERE
  1138. // 1 = 1 `
  1139. // if condition != "" {
  1140. // sql += condition
  1141. // }
  1142. // _, err = o.Raw(sql, userId).QueryRows(&items)
  1143. // return
  1144. //} //end
  1145. // 列表
  1146. func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  1147. o := orm.NewOrm()
  1148. sql := `SELECT
  1149. a.article_id,
  1150. a.report_id,
  1151. a.title,
  1152. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  1153. m.industry_name,
  1154. m.industrial_management_id
  1155. FROM
  1156. cygx_article AS a
  1157. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  1158. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  1159. WHERE
  1160. 1 = 1 `
  1161. if condition != "" {
  1162. sql += condition
  1163. }
  1164. _, err = o.Raw(sql).QueryRows(&items)
  1165. return
  1166. } //end
  1167. // 搜索资源包 start
  1168. type SearchResourceResp struct {
  1169. ListHz []*IndustrialManagementHotResp `description:"弘则"`
  1170. ListYx []*IndustrialManagementHotResp `description:"研选"`
  1171. }
  1172. // 搜索资源包 start
  1173. type SearchReportAndResourceResp struct {
  1174. ListHzResource []*IndustrialManagement `description:"弘则资源包"`
  1175. ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
  1176. ListYxReport []*ArticleCollectionResp `description:"研选报告"`
  1177. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  1178. }
  1179. // 产业列表
  1180. func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  1181. o := orm.NewOrm()
  1182. sql := `SELECT
  1183. m.time_line_data,
  1184. m.industry_name,
  1185. m.industrial_management_id,
  1186. MAX( a.publish_date ) as publish_date_order,
  1187. MIN(a.publish_date) AS min_report_time,
  1188. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  1189. (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
  1190. FROM
  1191. cygx_industrial_management AS m
  1192. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1193. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  1194. WHERE
  1195. 1 = 1
  1196. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  1197. if startSize > 0 || pageSize > 0 {
  1198. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1199. }
  1200. _, err = o.Raw(sql).QueryRows(&items)
  1201. return
  1202. }
  1203. // 列表
  1204. func GetSearchResourceListcondition(condition string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
  1205. o := orm.NewOrm()
  1206. sql := `SELECT
  1207. m.time_line_data,
  1208. m.industry_name,
  1209. m.chart_permission_id,
  1210. m.industrial_management_id,
  1211. MAX( a.publish_date ) as publish_date_order,
  1212. MIN( a.publish_date ) AS min_report_time,
  1213. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date
  1214. FROM
  1215. cygx_industrial_management AS m
  1216. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  1217. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  1218. WHERE
  1219. 1 = 1
  1220. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  1221. if startSize > 0 || pageSize > 0 {
  1222. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1223. }
  1224. _, err = o.Raw(sql).QueryRows(&items)
  1225. return
  1226. }
  1227. // 切换列表
  1228. type ReportBillboardTableResp struct {
  1229. Name string `description:"名称"`
  1230. Source int `description:"类型"`
  1231. List []*ChartPermission
  1232. }
  1233. // 切换列表
  1234. type ReportBillboardTableListResp struct {
  1235. List []*ReportBillboardTableResp
  1236. }
  1237. // 报告榜单start
  1238. type ArticleReportBillboardResp struct {
  1239. ArticleId int `description:"文章id"`
  1240. Title string `description:"标题"`
  1241. PublishDate string `description:"发布时间"`
  1242. PermissionName string `description:"行业名称"`
  1243. DepartmentId int `description:"作者Id"`
  1244. NickName string `description:"作者昵称"`
  1245. IsCollect bool `description:"本人是否收藏"`
  1246. Pv int `description:"PV"`
  1247. CollectNum int `description:"收藏人数"`
  1248. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  1249. IsRoadShow bool `description:"是否是路演精华"`
  1250. CategoryId int `description:"分类ID"`
  1251. IsResearch bool `description:"是否属于研选"`
  1252. ArticleTypeId int `description:"文章类型ID"`
  1253. ArticleTypeName string `description:"文章类型名称"`
  1254. IsSpecial int `description:"是否为研选专栏"`
  1255. SpecialTags string `description:"研选专栏标签"`
  1256. MyCollectNum int `description:"本人是否收藏"`
  1257. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  1258. UserId int `description:"作者id"`
  1259. List []*IndustrialManagementIdInt
  1260. }
  1261. type ArticleReportBillboardLIstResp struct {
  1262. List []*ArticleReportBillboardResp
  1263. }
  1264. type ArticleReportBillboardLIstPageResp struct {
  1265. List []*ArticleReportBillboardResp
  1266. Paging *paging.PagingItem
  1267. }
  1268. // 报告收藏榜单列表
  1269. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  1270. o := orm.NewOrm()
  1271. sql := `SELECT
  1272. ac.id,
  1273. a.article_id,
  1274. a.title,
  1275. date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
  1276. m.chart_permission_name AS permission_name,
  1277. COUNT(ac.id) AS collection_num
  1278. FROM
  1279. cygx_article AS a
  1280. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  1281. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  1282. WHERE
  1283. 1 = 1
  1284. AND a.publish_status = 1 `
  1285. if condition != "" {
  1286. sql += condition
  1287. }
  1288. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  1289. sql += ` LIMIT ?`
  1290. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  1291. return
  1292. }
  1293. // 报告阅读榜单列表
  1294. func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  1295. o := orm.NewOrm()
  1296. sql := `SELECT
  1297. a.article_id,
  1298. a.title,
  1299. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date
  1300. FROM
  1301. cygx_article AS a
  1302. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  1303. WHERE
  1304. 1 = 1
  1305. AND a.publish_status = 1 `
  1306. if condition != "" {
  1307. sql += condition
  1308. }
  1309. _, err = o.Raw(sql, pars).QueryRows(&items)
  1310. return
  1311. }
  1312. // 获取产业报告+晨会点评数量
  1313. func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
  1314. o := orm.NewOrm()
  1315. sql := `SELECT SUM(count) AS count FROM (
  1316. SELECT
  1317. COUNT( 1 ) count
  1318. FROM
  1319. cygx_article AS a
  1320. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  1321. WHERE
  1322. a.publish_status = 1
  1323. AND a.is_class = 1
  1324. AND man_g.industrial_management_id = ?
  1325. UNION ALL
  1326. SELECT
  1327. COUNT( 1 ) count
  1328. FROM
  1329. cygx_morning_meeting_review_chapter AS mmc
  1330. INNER JOIN cygx_morning_meeting_reviews AS mm
  1331. WHERE
  1332. mm.id = mmc.meeting_id
  1333. AND mm.status = 1
  1334. AND mmc.industry_id = ? UNION ALL
  1335. SELECT
  1336. COUNT( 1 ) count
  1337. FROM
  1338. cygx_product_interior AS p
  1339. INNER JOIN cygx_product_interior_industrial_group_management AS pm
  1340. WHERE
  1341. p.product_interior_id = pm.product_interior_id
  1342. AND p.visible_range = 1
  1343. AND pm.industrial_management_id = ? ) AS t `
  1344. err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&count)
  1345. return
  1346. }
  1347. type TimeLineReportItem struct {
  1348. Id int `description:"文章或晨报点评id"`
  1349. Title string `description:"标题"`
  1350. PublishTime string `description:"发布时间"`
  1351. Content string `description:"内容"`
  1352. VideoUrl string `description:"视频链接"`
  1353. VoiceUrl string `description:"音频链接"`
  1354. VoicePlaySeconds string `description:"音频时长"`
  1355. IsHaveVideo bool `description:"是否包含视频"`
  1356. ImgUrlPc string `description:"pc图片"`
  1357. SubCategoryName string `description:"二级分类"`
  1358. IsRed bool `description:"是否标红"`
  1359. Readnum int `description:"阅读数量"`
  1360. Resource int `description:"来源类型,1:文章、2:产品内测、3:晨报点评 4:活动回放视频 5:活动回放音频 "`
  1361. LinkArticleId int `description:"晨会精华报告ID链接"`
  1362. ListSubject []*CygxIndustrialSubject `description:"标的列表"`
  1363. }
  1364. // 获取产业报告+晨会点评列表
  1365. func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  1366. o := orm.NewOrm()
  1367. sql := `SELECT
  1368. *
  1369. FROM
  1370. (
  1371. SELECT
  1372. a.article_id AS id,
  1373. a.title,
  1374. a.publish_date AS publish_time,
  1375. a.video_url,
  1376. '' AS voice_url,
  1377. a.sub_category_name,
  1378. '' AS content,
  1379. 1 AS resource,
  1380. '' AS voice_play_seconds,
  1381. ( 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
  1382. FROM
  1383. cygx_article AS a
  1384. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  1385. WHERE
  1386. a.publish_status = 1
  1387. AND a.is_class = 1
  1388. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  1389. SELECT
  1390. mmc.id,
  1391. mmc.title,
  1392. mm.publish_time AS publish_time,
  1393. '' AS video_url,
  1394. '' AS voice_url,
  1395. '时间线' AS sub_category_name,
  1396. mmc.content,
  1397. 3 AS resource,
  1398. '' AS voice_play_seconds,
  1399. 0 AS readnum
  1400. FROM
  1401. cygx_morning_meeting_review_chapter AS mmc
  1402. INNER JOIN cygx_morning_meeting_reviews AS mm
  1403. WHERE
  1404. mm.id = mmc.meeting_id
  1405. AND mm.STATUS = 1
  1406. AND mmc.industry_id = ? UNION ALL
  1407. SELECT
  1408. p.product_interior_id AS id,
  1409. p.title,
  1410. p.publish_time,
  1411. '' AS video_url,
  1412. '' AS voice_url,
  1413. '' AS sub_category_name,
  1414. '' AS content,
  1415. 2 AS resource,
  1416. '' AS voice_play_seconds,
  1417. 0 AS readnum
  1418. FROM
  1419. cygx_product_interior AS p
  1420. INNER JOIN cygx_product_interior_industrial_group_management AS pm
  1421. WHERE
  1422. p.product_interior_id = pm.product_interior_id
  1423. AND p.visible_range = 1
  1424. AND pm.industrial_management_id = ? UNION ALL
  1425. SELECT
  1426. ca.activity_id AS id,
  1427. cav.video_name AS title,
  1428. ca.activity_time AS publish_time,
  1429. cav.video_url AS video_url,
  1430. '' AS voice_url,
  1431. '' AS sub_category_name,
  1432. '' AS content,
  1433. 4 AS resource,
  1434. '' AS voice_play_seconds,
  1435. ( 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
  1436. FROM
  1437. cygx_activity AS ca
  1438. INNER JOIN cygx_activity_video AS cav ON ca.activity_id = cav.activity_id
  1439. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  1440. WHERE
  1441. cam.industrial_management_id = ? AND cam.source = 1 UNION ALL
  1442. SELECT
  1443. ca.activity_id AS id,
  1444. cavo.voice_name AS title,
  1445. ca.activity_time AS publish_time,
  1446. '' AS video_url,
  1447. cavo.voice_url AS voice_url,
  1448. '' AS sub_category_name,
  1449. '' AS content,
  1450. 5 AS resource,
  1451. cavo.voice_play_seconds AS voice_play_seconds,
  1452. ( 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
  1453. FROM
  1454. cygx_activity AS ca
  1455. INNER JOIN cygx_activity_voice AS cavo ON ca.activity_id = cavo.activity_id
  1456. INNER JOIN cygx_industrial_activity_group_management AS cam ON ca.activity_id=cam.activity_id
  1457. WHERE
  1458. cam.industrial_management_id = ? AND cam.source = 1
  1459. ) AS t
  1460. `
  1461. sql += ` ORDER BY
  1462. t.publish_time DESC LIMIT ?,? `
  1463. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  1464. return
  1465. }
  1466. type ArticleIdReq struct {
  1467. ArticleId int `description:"文章id"`
  1468. PlaySeconds int `description:"播放时长"`
  1469. PageRouter string `description:"页面路径"`
  1470. }
  1471. type IndustrialReadNum struct {
  1472. IndustrialManagementId int `description:"产业id"`
  1473. Readnum int `description:"阅读次数"`
  1474. }
  1475. // 获取该产业下文章的用户阅读次数-小红点用
  1476. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  1477. o := orm.NewOrm()
  1478. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  1479. 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
  1480. FROM
  1481. cygx_article AS a
  1482. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  1483. WHERE
  1484. a.publish_status = 1
  1485. AND a.is_class = 1
  1486. AND man_g.industrial_management_id IN (` + industrialIds + `)
  1487. AND a.publish_date > ?
  1488. GROUP BY a.article_id ORDER BY publish_date DESC
  1489. ) AS a GROUP BY industrial_management_id`
  1490. _, err = o.Raw(sql, createtime).QueryRows(&items)
  1491. return
  1492. }
  1493. // 获取行业报告列表
  1494. func GetReportAndproductIndustrylListimgZhouqi(condition string, startSize, pageSize int) (items []*HomeArticle, total int, err error) {
  1495. o := orm.NewOrm()
  1496. sql := `SELECT
  1497. art.article_id,
  1498. art.report_id,
  1499. art.body,
  1500. art.annotation,
  1501. art.abstract,
  1502. art.category_id,
  1503. art.title,
  1504. art.publish_date,
  1505. art.sub_category_name,
  1506. 1 AS resource
  1507. FROM
  1508. cygx_article AS art
  1509. WHERE
  1510. art.publish_status = 1 AND category_name = '周期' ` + condition
  1511. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1512. err = o.Raw(totalSql).QueryRow(&total)
  1513. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  1514. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  1515. return
  1516. }