report.go 64 KB

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