report.go 57 KB

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