report.go 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "strconv"
  6. "time"
  7. //"github.com/rdlucklib/rdluck_tools/paging"
  8. )
  9. type IndustrialManagementList struct {
  10. Paging *paging.PagingItem
  11. List []*IndustrialManagement
  12. }
  13. type IndustrialManagement struct {
  14. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  15. IndustryName string `description:"产业名称"`
  16. RecommendedIndex int `description:"推荐指数"`
  17. CategoryId int `description:"文章分类ID"`
  18. LayoutTime string `description:"布局时间"`
  19. UpdateTime string `description:"更新时间"`
  20. MinReportTime string `description:"报告最早发布时间"`
  21. IsRed bool `description:"是否标记红点"`
  22. IsTop bool `description:"是否置顶"`
  23. IsHot bool `description:"是否是热门-近一个月内,产业下关联的报告阅读次数最多的"`
  24. IsFollow int `description:"是否关注"`
  25. IsNew bool `description:"是否为新-关联报告的发布时间,均在3个月以内的"`
  26. Analyst string `description:"分析师"`
  27. ArticleReadNum int `description:"文章阅读数量"`
  28. OneMonFollowNum int `description:"近一个月关注增量"`
  29. AnalystList []*IndustrialAnalyst `description:"分析师列表"`
  30. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  31. ChartPermissionId int `description:"行业ID"`
  32. PermissionName string `description:"行业名称"`
  33. IndustryVideo *MicroVideoSimpleInfo
  34. AuthInfo *UserPermissionAuthInfo
  35. ArticleId int `description:"文章id"`
  36. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  37. }
  38. type MicroVideoSimpleInfo struct {
  39. Id int `description:"视频ID"`
  40. Title string `description:"标题"`
  41. ResourceUrl string `description:"链接"`
  42. BackgroundImg string `description:"背景图"`
  43. PlaySeconds int `description:"音视频时长"`
  44. DetailImgUrl string `description:"产业详情页背景图"`
  45. ChartPermissionId int `description:"行业ID"`
  46. ChartPermissionName string `description:"行业名称"`
  47. }
  48. type IndustrialAnalyst struct {
  49. AnalystName string `description:"分析师名称"`
  50. IndustrialManagementId int `description:"产业id"`
  51. }
  52. type IndustrialSubject struct {
  53. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  54. IndustrialManagementId int `description:"产业id"`
  55. SubjectName string `description:"标的名称"`
  56. IndustryName string `description:"产业名称"`
  57. LayoutTime string `description:"产业布局时间"`
  58. }
  59. // 获取产业报告数量
  60. func GetReportIndustrialCount(categoryId, industrialManagementId int) (count int, err error) {
  61. o := orm.NewOrm()
  62. sql := `SELECT COUNT(1) count
  63. FROM
  64. cygx_article AS a
  65. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  66. WHERE
  67. a.publish_status = 1
  68. AND category_id IN (SELECT
  69. category_id
  70. FROM
  71. cygx_report_mapping
  72. WHERE
  73. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  74. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  75. AND a.is_class = 1
  76. AND man_g.industrial_management_id = ? `
  77. err = o.Raw(sql, industrialManagementId).QueryRow(&count)
  78. return
  79. }
  80. // 获取产业报告列表
  81. func GetReportIndustrialList(pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
  82. o := orm.NewOrm()
  83. sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum
  84. FROM
  85. cygx_article AS a
  86. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  87. WHERE
  88. a.publish_status = 1
  89. AND category_id IN (SELECT
  90. category_id
  91. FROM
  92. cygx_report_mapping
  93. WHERE
  94. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  95. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  96. AND a.is_class = 1
  97. AND man_g.industrial_management_id = ?`
  98. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  99. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  100. return
  101. }
  102. // 产业下所关联的文章分类列表
  103. func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int) (items []*IndustrialToArticleCategoryRep, err error) {
  104. o := orm.NewOrm()
  105. sql := `SELECT map.match_type_name,map.category_id
  106. FROM cygx_report_mapping AS map
  107. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  108. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  109. WHERE map.report_type = 2
  110. AND map.is_report = 1
  111. AND art.is_report = 1
  112. AND art.publish_status = 1
  113. AND man_g.industrial_management_id =?
  114. AND map.chart_permission_id = ?
  115. GROUP BY map.match_type_name`
  116. _, err = o.Raw(sql, industrialManagementId, chartPermissionId).QueryRows(&items)
  117. return
  118. }
  119. // 产业下所关联的文章分类列表 2022-10-13
  120. func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
  121. o := orm.NewOrm()
  122. sql := `SELECT map.match_type_name,map.category_id
  123. FROM cygx_report_mapping AS map
  124. INNER JOIN cygx_article AS art ON art.category_id = map.category_id
  125. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
  126. WHERE map.report_type = 2
  127. AND map.is_report = 1
  128. AND art.is_report = 1
  129. AND art.publish_status = 1
  130. AND man_g.industrial_management_id =?
  131. GROUP BY map.match_type_name`
  132. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  133. return
  134. }
  135. // 判断用户是否阅读该产业下,某一分类的文章
  136. func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
  137. o := orm.NewOrm()
  138. sql := `SELECT
  139. COUNT(1) count
  140. FROM
  141. cygx_article_history_record
  142. WHERE
  143. 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
  144. category_id
  145. FROM
  146. cygx_report_mapping
  147. WHERE
  148. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  149. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1 )
  150. AND user_id = ? `
  151. err = o.Raw(sql, industrialManagementId, categoryId, categoryId, userId).QueryRow(&count)
  152. return
  153. }
  154. // 获取最新文章
  155. func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
  156. o := orm.NewOrm()
  157. //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`
  158. 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
  159. category_id
  160. FROM
  161. cygx_report_mapping
  162. WHERE
  163. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ? )
  164. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ) ORDER BY publish_date DESC LIMIT 0, 1`
  165. err = o.Raw(sql, industrialManagementId, categoryId, categoryId).QueryRow(&item)
  166. return
  167. }
  168. // 获取最新文章
  169. func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
  170. o := orm.NewOrm()
  171. sql := ` SELECT * FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
  172. err = o.Raw(sql, categoryId).QueryRow(&item)
  173. return
  174. }
  175. func GetIndustrialManagementIdsBykeyWord(condition string) (industrialManagementIds string, err error) {
  176. sql := `SELECT GROUP_CONCAT(DISTINCT industrial_management_id SEPARATOR ',') AS industrial_management_ids FROM cygx_industrial_management WHERE` + condition
  177. o := orm.NewOrm()
  178. err = o.Raw(sql).QueryRow(&industrialManagementIds)
  179. return
  180. }
  181. type ReportArticleWhichIndustrial struct {
  182. ArticleId int `description:"文章id"`
  183. Title string `description:"标题"`
  184. PublishDate string `description:"发布时间"`
  185. IndustryName string `description:"产业名称"`
  186. SubjectName string `description:"标的名称"`
  187. NickName string `description:"作者昵称"`
  188. IsRed bool `description:"是否标记红点"`
  189. Readnum int `description:"阅读数量"`
  190. IsResearch bool `description:"是否属于研选"`
  191. Pv int `description:"PV"`
  192. ImgUrlPc string `description:"图片链接"`
  193. }
  194. type ReportArticleWhichIndustrialRepList struct {
  195. HaveResearch bool `description:"是否有研选权限"`
  196. Paging *paging.PagingItem `description:"分页数据"`
  197. NickName string `description:"作者昵称"`
  198. IndustryName string `description:"产业名称"`
  199. List []*ReportArticleWhichIndustrial
  200. }
  201. // 列表
  202. func IndustrialToArticleWhichDepartment(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ReportArticleWhichIndustrial, err error) {
  203. o := orm.NewOrm()
  204. sql := `SELECT
  205. art.* ,m.industry_name,d.nick_name,
  206. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  207. ( 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
  208. FROM
  209. cygx_article AS art
  210. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  211. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  212. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  213. WHERE 1 = 1
  214. AND art.publish_status = 1`
  215. if condition != "" {
  216. sql += condition
  217. }
  218. sql += ` LIMIT ?,?`
  219. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  220. return
  221. }
  222. func GetWhichDepartmentCount(condition string) (count int, err error) {
  223. o := orm.NewOrm()
  224. sql := `SELECT COUNT(1) count
  225. FROM
  226. cygx_article AS art
  227. INNER JOIN cygx_industrial_article_group_management as mg ON mg.article_id = art.article_id
  228. INNER JOIN cygx_industrial_management as m ON m.industrial_management_id = mg.industrial_management_id
  229. INNER JOIN cygx_article_department as d ON d.department_id = art.department_id
  230. WHERE 1 = 1
  231. AND art.publish_status = 1`
  232. if condition != "" {
  233. sql += condition
  234. }
  235. err = o.Raw(sql).QueryRow(&count)
  236. return
  237. }
  238. type IsShow struct {
  239. IsShow bool `description:"绝密内参按钮是否展示"`
  240. IsShowFreeButton bool `description:"免费送月卡按钮是否展示"`
  241. IsShowResearch bool `description:"研选是否展示限免"`
  242. IsShowChart bool `description:"图表是否展示限免"`
  243. IsShowList bool `description:"榜单是否展示"`
  244. LinkWxExplain string `description:"关注微信公众号链接说明地址"`
  245. YanXuan_Explain bool `description:"研选说明"`
  246. ActivitySpecialExplain string `description:"专项调研活动"`
  247. SearchTxtList SearchTxt `description:"搜索栏回显内容说明"`
  248. }
  249. type SearchTxt struct {
  250. SummarySearch string `description:"素材库搜索说明"`
  251. ReportSearch string `description:"报告搜索说明"`
  252. YanXuanSearch string `description:"研选搜索说明"`
  253. ActivitySearch string `description:"活动搜索说明"`
  254. TabSearch string `description:"素材库搜索说明"`
  255. }
  256. // 获取用户是否有查看权限
  257. func GetUserIsAdminCount(mobile string) (count int, err error) {
  258. o := orm.NewOrm()
  259. sql := `SELECT COUNT(1) count FROM admin
  260. WHERE
  261. mobile = ?
  262. AND (group_id IN (11, 13, 14, 15, 16, 17) OR department_id = 3 ) AND enabled = 1`
  263. err = o.Raw(sql, mobile).QueryRow(&count)
  264. return
  265. }
  266. type ReportDetailRoadshow struct {
  267. ArticleId int `description:"报告Id"`
  268. Title string `description:"标题"`
  269. Department string `orm:"column(seller_and_mobile)"description:"作者"`
  270. PublishDate string `description:"发布时间"`
  271. VideoUrl string `description:"链接"`
  272. VideoPlaySeconds string `description:"时长"`
  273. VideoName string `description:"音频名称"`
  274. Abstract string `description:"摘要"`
  275. Body string `description:"内容"`
  276. CategoryName string `description:"行业名称"`
  277. ReportLink string `orm:"column(link_article_id)"description:"报告链接"`
  278. }
  279. type RoadshowDetailResp struct {
  280. Detail *ReportDetailRoadshow
  281. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  282. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  283. }
  284. func GetReportRoadshowDetailById(articleId int) (item *ReportDetailRoadshow, err error) {
  285. o := orm.NewOrm()
  286. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  287. err = o.Raw(sql, articleId).QueryRow(&item)
  288. return
  289. }
  290. type CygxIndustryAndArticleList struct {
  291. ArticleId int `orm:"column(article_id);pk"description:"报告id"`
  292. Title string `description:"标题"`
  293. PublishDate string `description:"发布时间"`
  294. IndustryName string `description:"产业名称"`
  295. SubjectName string `description:"标的名称"`
  296. }
  297. type CygxIndustrySearchList struct {
  298. ArtList []*CygxIndustryAndArticleList `description:"文章列表"`
  299. IndList []*IndustrialManagement `description:"产业列表"`
  300. }
  301. type CygxIndustrySearchListPc struct {
  302. DepartmentList []*CygxArticleDepartmentRepPc
  303. IndList []*IndustrialManagement `description:"产业列表"`
  304. }
  305. // 列表
  306. func GetCygxIndustryAndArticleList(keyWord string) (items []*CygxIndustryAndArticleList, err error) {
  307. o := orm.NewOrm()
  308. sql := `SELECT
  309. art.title,
  310. art.article_id,
  311. art.publish_date
  312. FROM
  313. cygx_article AS art
  314. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  315. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = mg.article_id
  316. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  317. WHERE
  318. category_name LIKE '%研选%'
  319. 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 )
  320. 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 '%研选%' )
  321. GROUP BY
  322. art.article_id`
  323. _, err = o.Raw(sql).QueryRows(&items)
  324. return
  325. }
  326. func GetArticleIdsBySubId(subjectId string) (articleIds string, err error) {
  327. o := orm.NewOrm()
  328. sql := `SELECT GROUP_CONCAT( DISTINCT a.article_id SEPARATOR ',' ) AS articleIds
  329. FROM cygx_article AS a
  330. WHERE subject_ids LIKE '%` + subjectId + `%'`
  331. err = o.Raw(sql).QueryRow(&articleIds)
  332. return
  333. } //end
  334. // 用户收藏榜start
  335. type ArticleCollectionResp struct {
  336. ArticleId int `description:"文章id"`
  337. Title string `description:"标题"`
  338. PublishDate string `description:"发布时间"`
  339. IndustrialManagementId int `description:"产业Id"`
  340. IndustryName string `description:"产业名称"`
  341. DepartmentId int `description:"作者Id"`
  342. NickName string `description:"作者昵称"`
  343. MyCollectNum int `description:"本人是否收藏"`
  344. IsCollect bool `description:"本人是否收藏"`
  345. Pv int `description:"PV"`
  346. CollectNum int `description:"收藏人数"`
  347. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  348. ArticleTypeId int `description:"文章类型ID"`
  349. List []*IndustrialManagementResp `description:"产业列表"`
  350. }
  351. type IndustrialManagementResp struct {
  352. IndustrialManagementId int `description:"产业Id"`
  353. IndustryName string `description:"产业名称"`
  354. ChartPermissionId int `description:"权限id"`
  355. }
  356. type ArticleCollectionLIstResp struct {
  357. List []*ArticleCollectionResp
  358. }
  359. // 列表
  360. func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  361. o := orm.NewOrm()
  362. sql := `SELECT
  363. a.article_id,
  364. a.title,
  365. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  366. m.industry_name,
  367. m.industrial_management_id,
  368. d.nick_name,
  369. d.department_id,
  370. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  371. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id ) AS collect_num,
  372. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
  373. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  374. FROM
  375. cygx_article AS a
  376. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  377. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  378. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  379. WHERE
  380. 1 = 1 AND a.publish_status = 1 `
  381. if condition != "" {
  382. sql += condition
  383. }
  384. _, err = o.Raw(sql, userId).QueryRows(&items)
  385. return
  386. } //end
  387. type ArticleResearchListResp struct {
  388. Paging *paging.PagingItem
  389. List []*ArticleResearchResp
  390. }
  391. type ArticleResearchResp struct {
  392. ArticleId int `description:"文章id"`
  393. Title string `description:"标题"`
  394. PublishDate string `description:"发布时间"`
  395. DepartmentId int `description:"作者Id"`
  396. NickName string `description:"作者昵称"`
  397. IsCollect bool `description:"本人是否收藏"`
  398. Pv int `description:"PV"`
  399. CollectNum int `description:"收藏人数"`
  400. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  401. ArticleTypeId int `description:"文章类型ID"`
  402. ArticleTypeName string `description:"类型名称"`
  403. ButtonStyle string `description:"按钮展示样式"`
  404. List []*IndustrialManagementResp `description:"产业列表"`
  405. }
  406. // 获取我的日程数量
  407. func GetArticleResearchCount(condition string, pars []interface{}) (count int, err error) {
  408. o := orm.NewOrm()
  409. sqlCount := `SELECT COUNT( 1 ) AS count FROM
  410. cygx_article AS a
  411. WHERE
  412. 1 = 1 AND a.publish_status = 1` + condition
  413. err = o.Raw(sqlCount, pars).QueryRow(&count)
  414. return
  415. }
  416. func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleCollectionResp, err error) {
  417. o := orm.NewOrm()
  418. sql := `SELECT
  419. a.article_id,
  420. a.title,
  421. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  422. a.article_type_id,
  423. d.nick_name,
  424. d.department_id,
  425. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  426. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id ) AS collect_num,
  427. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
  428. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
  429. FROM
  430. cygx_article AS a
  431. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  432. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  433. INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
  434. WHERE
  435. 1 = 1 AND a.publish_status = 1 `
  436. if condition != "" {
  437. sql += condition
  438. }
  439. sql += ` GROUP BY a.article_id ORDER BY a.publish_date DESC LIMIT ?,? `
  440. _, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
  441. return
  442. }
  443. // 用户收藏榜start
  444. type IndustrialManagementHotResp struct {
  445. IndustrialManagementId int `orm:"column(industrial_management_id);pk" description:"产业id"`
  446. IndustryName string `description:"产业名称"`
  447. IsFollw bool `description:"是否关注"`
  448. FllowNum int `description:"关注数量"`
  449. IsNew bool `description:"是否新标签"`
  450. IsHot bool `description:"是否新标签"`
  451. IsRed bool `description:"是否标记红点"`
  452. Readnum int `description:"阅读数量"`
  453. PublishDate string `description:"发布时间"`
  454. MinReportTime string `description:"报告最早发布时间"`
  455. ArticleReadNum int `description:"文章阅读数量"`
  456. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  457. IndustrialSubjectList []*IndustrialSubject `description:"标的列表"`
  458. IndustryVideo *MicroVideoSimpleInfo `description:"产业视频"`
  459. AuthInfo *UserPermissionAuthInfo
  460. }
  461. type IndustrialManagementHotListResp struct {
  462. Paging *paging.PagingItem `description:"分页数据"`
  463. List []*IndustrialManagementHotResp
  464. }
  465. // 产业列表
  466. func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  467. o := orm.NewOrm()
  468. sql := `SELECT
  469. m.industry_name,
  470. m.industrial_management_id,
  471. m.article_read_num,
  472. MAX( a.publish_date ) AS publish_date,
  473. MIN(a.publish_date) AS min_report_time,
  474. ( 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,
  475. m.article_read_num + ( SELECT count( 1 ) FROM cygx_activity_meet_detail_log AS la WHERE la.activity_id IN (SELECT activity_id FROM cygx_industrial_activity_group_management WHERE industrial_management_id = m.industrial_management_id ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( la.activity_time ) ) AS sum_num
  476. FROM
  477. cygx_industrial_management AS m
  478. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  479. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  480. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  481. WHERE
  482. 1 = 1
  483. AND a.article_type_id > 0
  484. AND publish_status = 1
  485. GROUP BY m.industrial_management_id ` + condition + ` LIMIT ?,?`
  486. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  487. return
  488. }
  489. // 获取数量
  490. func GetThemeHeatListCount(condition string) (count int, err error) {
  491. o := orm.NewOrm()
  492. sql := `SELECT COUNT( DISTINCT m.industrial_management_id ) FROM
  493. cygx_industrial_management AS m
  494. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  495. LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id
  496. LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
  497. WHERE
  498. 1 = 1
  499. AND a.article_type_id > 0 AND a.publish_status = 1 ` + condition
  500. err = o.Raw(sql).QueryRow(&count)
  501. return
  502. }
  503. // 标的列表
  504. func GetThemeHeatSubjectList(condition string) (items []*IndustrialSubject, err error) {
  505. o := orm.NewOrm()
  506. sql := `SELECT
  507. m.subject_name,
  508. m.industrial_management_id,
  509. m.industrial_subject_id
  510. FROM
  511. cygx_article AS a
  512. INNER JOIN cygx_industrial_article_group_subject AS mg ON mg.article_id = a.article_id
  513. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  514. WHERE
  515. 1 = 1`
  516. if condition != "" {
  517. sql += condition
  518. }
  519. sql += ` AND publish_status = 1
  520. GROUP BY
  521. m.industrial_subject_id
  522. ORDER BY
  523. publish_date DESC`
  524. _, err = o.Raw(sql).QueryRows(&items)
  525. return
  526. } //end
  527. // Kol sratr
  528. type DepartmentResp struct {
  529. DepartmentId int `description:"作者Id"`
  530. NickName string `description:"作者昵称"`
  531. ImgUrl string `description:"图片链接"`
  532. IsFollw bool `description:"是否关注"`
  533. FllowNum int `description:"关注数量"`
  534. List []*IndustrialDepartmentListResp
  535. }
  536. type DepartmentListResp struct {
  537. Paging *paging.PagingItem `description:"分页数据"`
  538. List []*DepartmentResp
  539. }
  540. type IndustrialDepartmentListResp struct {
  541. IndustrialManagementId int `description:"产业Id"`
  542. IndustryName string `description:"产业名称"`
  543. DepartmentId int `description:"作者Id"`
  544. }
  545. // 作者列表
  546. func GetDepartmentList(condition string, userId, startSize, pageSize int) (items []*DepartmentResp, err error) {
  547. o := orm.NewOrm()
  548. sql := `SELECT
  549. d.nick_name,
  550. d.department_id,
  551. d.img_url,
  552. MAX( a.publish_date ) AS publish_date,
  553. ( 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,
  554. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user AS u ON u.user_id = f.user_id WHERE f.department_id = d.department_id AND f.type= 1 ) +( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user AS u ON u.user_id = ac.user_id WHERE ac.article_id IN (SELECT article_id FROM cygx_article WHERE department_id = d.department_id ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS sum_num
  555. FROM
  556. cygx_article_department AS d
  557. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  558. WHERE
  559. 1 = 1
  560. AND a.article_type_id > 0
  561. AND publish_status = 1
  562. GROUP BY
  563. d.department_id ` + condition + ` LIMIT ?,?`
  564. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  565. return
  566. }
  567. // 获取数量
  568. func GetDepartmentlistCount(condition string) (count int, err error) {
  569. o := orm.NewOrm()
  570. sql := `SELECT
  571. count(*) AS count
  572. FROM
  573. (
  574. SELECT
  575. COUNT( 1 ) AS count
  576. FROM
  577. cygx_article_department AS d
  578. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  579. WHERE
  580. 1 = 1
  581. AND a.article_type_id > 0
  582. AND publish_status = 1
  583. GROUP BY
  584. d.department_id
  585. ) c `
  586. err = o.Raw(sql).QueryRow(&count)
  587. return
  588. }
  589. // 作者文章所关联的产业列表
  590. func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
  591. o := orm.NewOrm()
  592. sql := `SELECT
  593. m.industrial_management_id,
  594. m.industry_name,
  595. d.department_id
  596. FROM
  597. cygx_article_department AS d
  598. INNER JOIN cygx_article AS a ON d.department_id = a.department_id
  599. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  600. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  601. WHERE
  602. 1 = 1
  603. AND a.article_type_id > 0
  604. AND publish_status = 1
  605. GROUP BY
  606. a.article_id
  607. ORDER BY
  608. a.publish_date DESC`
  609. _, err = o.Raw(sql).QueryRows(&items)
  610. return
  611. }
  612. // 主题详情start
  613. type GetThemeDetailListResp struct {
  614. ArticleId int `description:"文章id"`
  615. Title string `description:"标题"`
  616. PublishDate string `description:"发布时间"`
  617. SubjectName string `description:"标的名称"`
  618. IndustrialSubjectId int `description:"标的id"`
  619. DepartmentId int `description:"作者Id"`
  620. NickName string `description:"作者昵称"`
  621. Pv int `description:"PV"`
  622. CollectNum int `description:"收藏人数"`
  623. IndustrialManagementId int `description:"产业Id"`
  624. IndustryName string `description:"产业名称"`
  625. FllowNum int `description:"关注数量"`
  626. MyCollectNum int `description:"本人是否收藏"`
  627. IsCollect bool `description:"本人是否收藏"`
  628. }
  629. type GetThemeAericleListResp struct {
  630. ArticleId int `description:"文章id"`
  631. Title string `description:"标题"`
  632. PublishDate string `description:"发布时间"`
  633. SubjectName string `description:"标的名称"`
  634. IndustrialSubjectId int `description:"标的ID"`
  635. DepartmentId int `description:"作者Id"`
  636. NickName string `description:"作者昵称"`
  637. Pv int `description:"PV"`
  638. CollectNum int `description:"收藏人数"`
  639. FllowNum int `description:"关注数量"`
  640. MyCollectNum int `description:"本人是否收藏"`
  641. IsCollect bool `description:"本人是否收藏"`
  642. }
  643. type GetThemeAericleListBuSubjectResp struct {
  644. SubjectName string `description:"标的名称"`
  645. List []*GetThemeAericleListResp
  646. }
  647. // 主题详情start
  648. type GetThemeDetailResp struct {
  649. IndustrialManagementId int `description:"产业Id"`
  650. IndustryName string `description:"产业名称"`
  651. IsFollw bool `description:"是否关注"`
  652. ListSubject []*IndustrialSubject `description:"标的列表"`
  653. List []*GetThemeAericleListResp
  654. }
  655. // 列表
  656. func GetThemeDetail(userId, industrialManagementId int, condition string) (items []*GetThemeDetailListResp, err error) {
  657. o := orm.NewOrm()
  658. sql := `SELECT
  659. a.article_id,
  660. a.title,
  661. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  662. m.industry_name,
  663. m.industrial_management_id,
  664. d.nick_name,
  665. d.department_id,
  666. s.industrial_subject_id,
  667. s.subject_name,
  668. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  669. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  670. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id and user_id = ? ) AS my_collect_num,
  671. ( 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
  672. FROM
  673. cygx_article AS a
  674. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  675. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  676. LEFT JOIN cygx_article_department AS d ON d.department_id = a.department_id
  677. LEFT JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = a.article_id
  678. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  679. WHERE
  680. 1 = 1
  681. AND m.industrial_management_id = ?
  682. AND publish_status = 1 ` + condition + `
  683. ORDER BY
  684. publish_date DESC`
  685. _, err = o.Raw(sql, userId, userId, industrialManagementId).QueryRows(&items)
  686. return
  687. } //end
  688. // 用户收藏榜start
  689. type DepartmentDetailResp struct {
  690. DepartmentId int `description:"作者Id"`
  691. NickName string `description:"作者昵称"`
  692. ImgUrl string `description:"图片链接"`
  693. FllowNum int `description:"多少人关注"`
  694. ArticleNum int `description:"文章数量"`
  695. CollectNum int `description:"收藏人数"`
  696. IsFllow bool `description:"是否关注"`
  697. List []*ArticleCollectionResp
  698. ListIndustrial []*IndustrialManagementNewResp
  699. }
  700. type DepartmentDetail struct {
  701. DepartmentId int `description:"作者Id"`
  702. NickName string `description:"作者昵称"`
  703. ImgUrl string `description:"图片链接"`
  704. FllowNum int `description:"多少人关注"`
  705. ArticleNum int `description:"文章数量"`
  706. CollectNum int `description:"收藏人数"`
  707. IsFllow bool `description:"是否关注"`
  708. MyFllowNum int `description:"本人是否关注"`
  709. }
  710. // 列表
  711. func GetDepartmentDetail(userId, departmentId int) (item DepartmentDetail, err error) {
  712. o := orm.NewOrm()
  713. sql := `SELECT
  714. d.department_id,
  715. d.nick_name,
  716. d.img_url,
  717. ( 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,
  718. ( SELECT count( 1 ) FROM cygx_article_department_follow AS f INNER JOIN wx_user as u ON u.user_id = f.user_id WHERE f.department_id = d.department_id AND f.type= 1 ) AS fllow_num,
  719. ( SELECT count( 1 ) FROM cygx_article AS a WHERE a.department_id = d.department_id ) AS article_num,
  720. ( SELECT count( 1 ) FROM cygx_article_collect AS c INNER JOIN wx_user as u ON u.user_id = c.user_id WHERE c.article_id IN (SELECT article_id FROM cygx_article AS a WHERE a.department_id = d.department_id )) AS collect_num
  721. FROM
  722. cygx_article_department AS d
  723. WHERE
  724. d.department_id = ?`
  725. err = o.Raw(sql, userId, departmentId).QueryRow(&item)
  726. return
  727. } //end
  728. // 报告搜索start
  729. type ReoprtSearchResp struct {
  730. ListYx []*ArticleCollectionResp `description:"研选报告"`
  731. ListHz []*ArticleCollectionResp `description:"弘则报告"`
  732. }
  733. // 列表
  734. func GetReoprtSearchList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
  735. o := orm.NewOrm()
  736. sql := `SELECT
  737. a.article_id,
  738. a.title,
  739. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
  740. m.industry_name,
  741. m.industrial_management_id,
  742. ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
  743. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
  744. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ?) AS my_collect_num
  745. FROM
  746. cygx_article AS a
  747. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  748. LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  749. WHERE
  750. 1 = 1 `
  751. if condition != "" {
  752. sql += condition
  753. }
  754. _, err = o.Raw(sql, userId).QueryRows(&items)
  755. return
  756. } //end
  757. // 搜索资源包 start
  758. type SearchResourceResp struct {
  759. ListHz []*IndustrialManagementHotResp `description:"弘则"`
  760. ListYx []*IndustrialManagementHotResp `description:"研选"`
  761. }
  762. // 搜索资源包 start
  763. type SearchReportAndResourceResp struct {
  764. ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
  765. ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
  766. ListYxReport []*ArticleCollectionResp `description:"研选报告"`
  767. ListHzReport []*ArticleCollectionResp `description:"弘则报告"`
  768. }
  769. // 产业列表
  770. func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
  771. o := orm.NewOrm()
  772. sql := `SELECT
  773. m.industry_name,
  774. m.industrial_management_id,
  775. MAX( a.publish_date ) as publish_date_order,
  776. MIN(a.publish_date) AS min_report_time,
  777. date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
  778. (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
  779. FROM
  780. cygx_industrial_management AS m
  781. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
  782. INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
  783. WHERE
  784. 1 = 1
  785. AND publish_status = 1 ` + condition + ` GROUP BY m.industrial_management_id ORDER BY publish_date_order DESC `
  786. if startSize > 0 || pageSize > 0 {
  787. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  788. }
  789. _, err = o.Raw(sql).QueryRows(&items)
  790. return
  791. }
  792. // 切换列表
  793. type ReportBillboardTableResp struct {
  794. Name string `description:"名称"`
  795. Source int `description:"类型"`
  796. List []*ChartPermission
  797. }
  798. // 切换列表
  799. type ReportBillboardTableListResp struct {
  800. List []*ReportBillboardTableResp
  801. }
  802. // 报告榜单start
  803. type ArticleReportBillboardResp struct {
  804. ArticleId int `description:"文章id"`
  805. Title string `description:"标题"`
  806. PublishDate string `description:"发布时间"`
  807. PermissionName string `description:"行业名称"`
  808. DepartmentId int `description:"作者Id"`
  809. NickName string `description:"作者昵称"`
  810. IsCollect bool `description:"本人是否收藏"`
  811. Pv int `description:"PV"`
  812. CollectNum int `description:"收藏人数"`
  813. Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
  814. List []*IndustrialManagementIdInt
  815. }
  816. type ArticleReportBillboardLIstResp struct {
  817. List []*ArticleReportBillboardResp
  818. }
  819. type ArticleReportBillboardLIstPageResp struct {
  820. List []*ArticleReportBillboardResp
  821. Paging *paging.PagingItem
  822. }
  823. // 报告收藏榜单列表
  824. func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  825. o := orm.NewOrm()
  826. sql := `SELECT
  827. ac.id,
  828. a.article_id,
  829. a.title,
  830. date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
  831. m.chart_permission_name AS permission_name,
  832. COUNT(ac.id) AS collection_num
  833. FROM
  834. cygx_article AS a
  835. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  836. INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id
  837. WHERE
  838. 1 = 1
  839. AND a.publish_status = 1 `
  840. if condition != "" {
  841. sql += condition
  842. }
  843. sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
  844. sql += ` LIMIT ?`
  845. _, err = o.Raw(sql, pars, limit).QueryRows(&items)
  846. return
  847. }
  848. // 报告阅读榜单列表
  849. func GetReportPvBillboardList(pars []interface{}, condition string) (items []*ArticleReportBillboardResp, err error) {
  850. o := orm.NewOrm()
  851. sql := `SELECT
  852. a.article_id,
  853. a.title,
  854. date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date
  855. FROM
  856. cygx_article AS a
  857. INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
  858. WHERE
  859. 1 = 1
  860. AND a.publish_status = 1 `
  861. if condition != "" {
  862. sql += condition
  863. }
  864. _, err = o.Raw(sql, pars).QueryRows(&items)
  865. return
  866. }
  867. // 获取产业报告+晨会点评数量
  868. func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
  869. o := orm.NewOrm()
  870. sql := `SELECT SUM(count) AS count FROM (
  871. SELECT
  872. COUNT( 1 ) count
  873. FROM
  874. cygx_article AS a
  875. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  876. WHERE
  877. a.publish_status = 1
  878. AND a.is_class = 1
  879. AND man_g.industrial_management_id = ?
  880. UNION ALL
  881. SELECT
  882. COUNT( 1 ) count
  883. FROM
  884. cygx_morning_meeting_review_chapter AS mmc
  885. INNER JOIN cygx_morning_meeting_reviews AS mm
  886. WHERE
  887. mm.id = mmc.meeting_id
  888. AND mm.status = 1
  889. AND mmc.industry_id = ? ) AS t `
  890. err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRow(&count)
  891. return
  892. }
  893. type TimeLineReportItem struct {
  894. Id int `description:"文章或晨报点评id"`
  895. Title string `description:"标题"`
  896. PublishTime string `description:"发布时间"`
  897. Content string `description:"内容"`
  898. VideoUrl string `description:"视频链接"`
  899. IsHaveVideo bool `description:"是否包含视频"`
  900. ImgUrlPc string `description:"pc图片"`
  901. SubCategoryName string `description:"二级分类"`
  902. IsRed bool `description:"是否标红"`
  903. Readnum int `description:"阅读数量"`
  904. }
  905. // 获取产业报告+晨会点评列表
  906. func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
  907. o := orm.NewOrm()
  908. sql := `SELECT
  909. *
  910. FROM
  911. (
  912. SELECT
  913. a.article_id AS id,
  914. a.title,
  915. a.publish_date AS publish_time,
  916. a.video_url,
  917. a.sub_category_name,
  918. '' AS content,
  919. ( 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
  920. FROM
  921. cygx_article AS a
  922. INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id
  923. WHERE
  924. a.publish_status = 1
  925. AND a.is_class = 1
  926. AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
  927. SELECT
  928. mmc.id,
  929. '' AS title,
  930. mm.publish_time AS publish_time,
  931. '' AS video_url,
  932. '时间线' AS sub_category_name,
  933. mmc.content,
  934. 0 AS readnum
  935. FROM
  936. cygx_morning_meeting_review_chapter AS mmc
  937. INNER JOIN cygx_morning_meeting_reviews AS mm
  938. WHERE
  939. mm.id = mmc.meeting_id
  940. AND mm.STATUS = 1
  941. AND mmc.industry_id = ?
  942. ) AS t
  943. `
  944. sql += ` ORDER BY
  945. t.publish_time DESC LIMIT ?,? `
  946. _, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
  947. return
  948. }
  949. type ArticleIdReq struct {
  950. ArticleId int `description:"文章id"`
  951. PlaySeconds int `description:"播放时长"`
  952. PageRouter string `description:"页面路径"`
  953. }
  954. type IndustrialReadNum struct {
  955. IndustrialManagementId int `description:"产业id"`
  956. Readnum int `description:"阅读次数"`
  957. }
  958. // 获取该产业下文章的用户阅读次数-小红点用
  959. func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
  960. o := orm.NewOrm()
  961. sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
  962. 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
  963. FROM
  964. cygx_article AS a
  965. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  966. WHERE
  967. a.publish_status = 1
  968. AND a.is_class = 1
  969. AND man_g.industrial_management_id IN (` + industrialIds + `)
  970. AND a.publish_date > ?
  971. GROUP BY a.article_id ORDER BY publish_date DESC
  972. ) AS a GROUP BY industrial_management_id`
  973. _, err = o.Raw(sql, createtime).QueryRows(&items)
  974. return
  975. }