report.go 55 KB

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