report.go 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "html"
  9. "rdluck_tools/paging"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. //报告
  15. type ReportController struct {
  16. BaseAuthController
  17. }
  18. type ReportCommonController struct {
  19. BaseCommonController
  20. }
  21. // @Title 行业报告分类列表接口
  22. // @Description 获取行业报告分类列表接口
  23. // @Param ChartPermissionId query int true "分类ID"
  24. // @Success 200 {object} models.IndustrialManagementList
  25. // @router /home/tradeList [get]
  26. func (this *ReportController) TradeList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请重新登录"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  40. if ChartPermissionId < 1 {
  41. br.Msg = "请输入分类ID"
  42. return
  43. }
  44. list, err := models.GetTradeAll(ChartPermissionId)
  45. if err != nil {
  46. br.Msg = "获取信息失败"
  47. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  48. return
  49. }
  50. for k, v := range list {
  51. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  52. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  53. if err != nil {
  54. br.Msg = "获取信息失败"
  55. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  56. return
  57. }
  58. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  59. list[k].IsRed = true
  60. }
  61. }
  62. resp := new(models.TradeReportMappingResp)
  63. resp.List = list
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 产业报告分类列表接口
  70. // @Description 获取产业报告分类列表接口
  71. // @Param ChartPermissionId query int true "分类ID"
  72. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  73. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  74. // @Param KeyWord query string true "搜索关键词"
  75. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  76. // @Param PageSize query int true "每页数据条数"
  77. // @Param CurrentIndex query int true "当前页页码,从1开始"
  78. // @Success 200 {object} models.IndustrialManagementList
  79. // @router /home/industryList [get]
  80. func (this *ReportController) IndustryList() {
  81. br := new(models.BaseResponse).Init()
  82. defer func() {
  83. this.Data["json"] = br
  84. this.ServeJSON()
  85. }()
  86. user := this.User
  87. if user == nil {
  88. br.Msg = "请重新登录"
  89. br.Ret = 408
  90. return
  91. }
  92. uid := user.UserId
  93. fmt.Println(uid)
  94. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  95. orderColumn := this.GetString("OrderColumn")
  96. isNewLabel := this.GetString("IsNewLabel")
  97. isDeepLabel := this.GetString("IsDeepLabel")
  98. keyWord := this.GetString("KeyWord")
  99. pageSize, _ := this.GetInt("PageSize")
  100. currentIndex, _ := this.GetInt("CurrentIndex")
  101. var orderSrt string
  102. var condition string
  103. var startSize int
  104. resp := new(models.IndustrialManagementList)
  105. if pageSize <= 0 {
  106. pageSize = utils.PageSize20
  107. }
  108. if currentIndex <= 0 {
  109. currentIndex = 1
  110. }
  111. startSize = paging.StartIndex(currentIndex, pageSize)
  112. if isNewLabel == "1" {
  113. condition += ` AND is_new_label = ` + isNewLabel
  114. }
  115. if isDeepLabel == "1" {
  116. condition += ` AND is_deep_label = ` + isDeepLabel
  117. }
  118. if keyWord != "" {
  119. keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  120. if err != nil {
  121. br.Msg = "获取信息失败"
  122. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  123. return
  124. }
  125. var conditionkeyWord string
  126. conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  127. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  128. keyWordLen := len(keyWordArr)
  129. if keyWordLen <= 0 {
  130. keyWordArr = append(keyWordArr, keyWord)
  131. keyWordLen = len(keyWordArr)
  132. }
  133. for _, v := range keyWordArr {
  134. conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  135. }
  136. industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  137. if err != nil {
  138. br.Msg = "获取信息失败"
  139. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  140. return
  141. }
  142. if industrialManagementIds == "" {
  143. br.Ret = 200
  144. br.Success = true
  145. br.Msg = "获取成功"
  146. br.Data = resp
  147. return
  148. }
  149. condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  150. }
  151. var sqlChartPermissionId string
  152. if ChartPermissionId > 0 {
  153. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  154. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  155. }
  156. //var total int
  157. var list []*models.IndustrialManagement
  158. //totalTopList, errTop := models.GetIndustrialManagemenCountTop(sqlChartPermissionId, uid, condition)
  159. //totalTop := len(totalTopList)
  160. //if errTop != nil {
  161. // br.Msg = "获取信息失败"
  162. // br.ErrMsg = "获取品种信息失败,Err:" + errTop.Error()
  163. // return
  164. //}
  165. //totalNoTopList, errNoTop := models.GetIndustrialManagemenCountNoTop(sqlChartPermissionId, uid, condition)
  166. //totalNoTop := len(totalNoTopList)
  167. //if errNoTop != nil {
  168. // br.Msg = "获取信息失败"
  169. // br.ErrMsg = "获取品种信息失败,Err:" + errNoTop.Error()
  170. // return
  171. //}
  172. total, err := models.GetIndustrialManagementAllCount(condition)
  173. if err != nil {
  174. br.Msg = "获取信息失败"
  175. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  176. return
  177. }
  178. page := paging.GetPaging(currentIndex, pageSize, total)
  179. if orderColumn == "" {
  180. orderColumn = "NewTime"
  181. }
  182. if orderColumn == "NewTime" {
  183. orderSrt = "update_time DESC"
  184. } else {
  185. orderSrt = "man.recommended_index DESC,update_time DESC"
  186. }
  187. //全部都是置顶
  188. //if totalTop >= currentIndex*pageSize {
  189. // listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
  190. // for k, _ := range listTop {
  191. // listTop[k].IsTop = true
  192. // }
  193. // if err != nil {
  194. // br.Msg = "获取信息失败"
  195. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  196. // return
  197. // }
  198. // list = listTop
  199. //} else if totalTop < (currentIndex-1)*pageSize { //全部都是不置顶
  200. // listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize-totalTop, pageSize)
  201. // if err != nil {
  202. // br.Msg = "获取信息失败"
  203. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  204. // return
  205. // }
  206. // list = listNoTop
  207. //} else { //部分置顶,部分不置顶
  208. // listTop, err := models.GetIndustrialManagementTopAll(uid, condition, startSize, pageSize)
  209. // if err != nil {
  210. // br.Msg = "获取信息失败"
  211. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  212. // return
  213. // }
  214. // for k, _ := range listTop {
  215. // listTop[k].IsTop = true
  216. // }
  217. // listNoTop, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, pageSize-len(listTop))
  218. // if err != nil {
  219. // br.Msg = "获取信息失败"
  220. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  221. // return
  222. // }
  223. // list = append(listTop, listNoTop...)
  224. //}
  225. if ChartPermissionId == 0 {
  226. ChartPermissionId = 20
  227. }
  228. detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  229. if err != nil {
  230. br.Msg = "获取信息失败"
  231. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  232. return
  233. }
  234. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  235. if err != nil {
  236. br.Msg = "获取信息失败"
  237. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  238. return
  239. }
  240. for k, v := range list {
  241. //var analystStr string
  242. //analystList, err := models.GetIndustrialAnalystAll(v.IndustrialManagementId)
  243. //if err != nil {
  244. // br.Msg = "获取信息失败"
  245. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  246. // return
  247. //}
  248. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  249. if err != nil {
  250. br.Msg = "获取信息失败"
  251. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  252. return
  253. }
  254. list[k].IndustrialSubjectList = industrialSubjectList
  255. //if len(analystList) > 0 {
  256. // for _, v2 := range analystList {
  257. // analystStr += v2.AnalystName + "/"
  258. // }
  259. // analystStr = strings.TrimRight(analystStr, "/")
  260. //}
  261. //list[k].Analyst = analystStr
  262. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  263. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  264. if err != nil {
  265. br.Msg = "获取信息失败"
  266. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  267. return
  268. }
  269. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  270. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  271. if err != nil && err.Error() != utils.ErrNoRow() {
  272. br.Msg = "获取信息失败"
  273. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  274. return
  275. }
  276. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  277. list[k].IsRed = true
  278. }
  279. if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  280. list[k].IsHot = true
  281. }
  282. }
  283. resp.List = list
  284. resp.Paging = page
  285. br.Ret = 200
  286. br.Success = true
  287. br.Msg = "获取成功"
  288. br.Data = resp
  289. }
  290. // @Title 产业下所关联的文章分类列表
  291. // @Description 产业下所关联的文章分类列表接口
  292. // @Param IndustrialManagementId query int true "产业ID"
  293. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  294. // @router /toArticleCategoryList [get]
  295. func (this *ReportController) ArticleCategoryList() {
  296. br := new(models.BaseResponse).Init()
  297. defer func() {
  298. this.Data["json"] = br
  299. this.ServeJSON()
  300. }()
  301. user := this.User
  302. if user == nil {
  303. br.Msg = "请重新登录"
  304. br.Ret = 408
  305. return
  306. }
  307. uid := user.UserId
  308. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  309. if industrialManagementId < 1 {
  310. br.Msg = "请输入分类ID"
  311. return
  312. }
  313. list, err := models.IndustrialToArticleCategory(industrialManagementId)
  314. if err != nil {
  315. br.Msg = "获取信息失败"
  316. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  317. return
  318. }
  319. for k, v := range list {
  320. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  321. if err != nil && err.Error() != utils.ErrNoRow() {
  322. br.Msg = "获取信息失败"
  323. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  324. return
  325. }
  326. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  327. if err != nil {
  328. br.Msg = "获取信息失败"
  329. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  330. return
  331. }
  332. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  333. list[k].IsRed = true
  334. }
  335. }
  336. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  337. if err != nil {
  338. br.Msg = "获取信息失败"
  339. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  340. return
  341. }
  342. resp := new(models.IndustrialToArticleCategoryListRep)
  343. resp.List = list
  344. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  345. resp.IndustryName = detail.IndustryName
  346. resp.IndustrialManagementId = industrialManagementId
  347. br.Ret = 200
  348. br.Success = true
  349. br.Msg = "获取成功"
  350. br.Data = resp
  351. }
  352. // @Title 产业文章列表接口
  353. // @Description 获取产业文章列表接口
  354. // @Param PageSize query int true "每页数据条数"
  355. // @Param CurrentIndex query int true "当前页页码,从1开始"
  356. // @Param CategoryId query int true "分类ID"
  357. // @Param IndustrialManagementId query int true "产业ID"
  358. // @Success 200 {object} models.TacticsListResp
  359. // @router /industry/ArticleList [get]
  360. func (this *ReportController) List() {
  361. br := new(models.BaseResponse).Init()
  362. defer func() {
  363. this.Data["json"] = br
  364. this.ServeJSON()
  365. }()
  366. user := this.User
  367. if user == nil {
  368. br.Msg = "请重新登录"
  369. br.Ret = 408
  370. return
  371. }
  372. uid := user.UserId
  373. pageSize, _ := this.GetInt("PageSize")
  374. currentIndex, _ := this.GetInt("CurrentIndex")
  375. categoryId, _ := this.GetInt("CategoryId")
  376. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  377. var startSize int
  378. if pageSize <= 0 {
  379. pageSize = utils.PageSize20
  380. }
  381. if currentIndex <= 0 {
  382. currentIndex = 1
  383. }
  384. startSize = paging.StartIndex(currentIndex, pageSize)
  385. var pars []interface{}
  386. var total int
  387. resp := new(models.TacticsListResp)
  388. page := paging.GetPaging(currentIndex, pageSize, total)
  389. if categoryId < 1 {
  390. br.Msg = "请输入分类ID"
  391. return
  392. }
  393. if industrialManagementId < 1 {
  394. br.Msg = "请输入产业ID"
  395. return
  396. }
  397. total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
  398. if err != nil {
  399. br.Msg = "获取信息失败"
  400. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  401. return
  402. }
  403. page = paging.GetPaging(currentIndex, pageSize, total)
  404. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  405. if err != nil {
  406. br.Msg = "获取信息失败"
  407. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  408. return
  409. }
  410. lenList := len(list)
  411. for i := 0; i < lenList; i++ {
  412. item := list[i]
  413. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  414. //list[i].Abstract = html.UnescapeString(item.Abstract)
  415. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  416. }
  417. for k, v := range list {
  418. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  419. list[k].IsRed = true
  420. }
  421. if v.VideoUrl != "" {
  422. list[k].IsHaveVideo = true
  423. }
  424. }
  425. resp.List = list
  426. resp.Paging = page
  427. br.Ret = 200
  428. br.Success = true
  429. br.Msg = "获取成功"
  430. br.Data = resp
  431. }
  432. // @Title 置顶/取消置顶
  433. // @Description 置顶
  434. // @Param request body models.CygxIndustryTopRep true "type json string"
  435. // @Success 200
  436. // @router /top [post]
  437. func (this *ReportController) ArticleCollect() {
  438. br := new(models.BaseResponse).Init()
  439. defer func() {
  440. this.Data["json"] = br
  441. this.ServeJSON()
  442. }()
  443. user := this.User
  444. if user == nil {
  445. br.Msg = "请重新登录"
  446. br.Ret = 408
  447. return
  448. }
  449. uid := user.UserId
  450. var req models.CygxIndustryTopRep
  451. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  452. if err != nil {
  453. br.Msg = "参数解析异常!"
  454. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  455. return
  456. }
  457. industrialManagementId := req.IndustrialManagementId
  458. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  459. if err != nil {
  460. br.Msg = "获取数据失败!"
  461. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  462. return
  463. }
  464. if countIndustrial == 0 {
  465. br.Msg = "产业不存在!"
  466. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  467. return
  468. }
  469. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  470. if err != nil {
  471. br.Msg = "获取数据失败!"
  472. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  473. return
  474. }
  475. resp := new(models.ArticleCollectResp)
  476. if count <= 0 {
  477. item := new(models.CygxIndustryTop)
  478. item.IndustrialManagementId = req.IndustrialManagementId
  479. item.UserId = uid
  480. item.CreateTime = time.Now()
  481. _, err = models.AddCygxIndustryTop(item)
  482. if err != nil {
  483. br.Msg = "置顶失败"
  484. br.ErrMsg = "置顶失败,Err:" + err.Error()
  485. return
  486. }
  487. br.Msg = "置顶成功"
  488. resp.Status = 1
  489. } else {
  490. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  491. if err != nil {
  492. br.Msg = "取消置顶失败"
  493. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  494. return
  495. }
  496. br.Msg = "已取消置顶"
  497. resp.Status = 2
  498. }
  499. br.Ret = 200
  500. br.Success = true
  501. br.Data = resp
  502. }
  503. // @Title 关注/取消关注产业
  504. // @Description 关注/取消关注 接口
  505. // @Param request body models.CygxIndustryFllowRep true "type json string"
  506. // @Success 200
  507. // @router /fllow [post]
  508. func (this *ReportController) Fllow() {
  509. br := new(models.BaseResponse).Init()
  510. defer func() {
  511. this.Data["json"] = br
  512. this.ServeJSON()
  513. }()
  514. user := this.User
  515. if user == nil {
  516. br.Msg = "请重新登录"
  517. br.Ret = 408
  518. return
  519. }
  520. uid := user.UserId
  521. var req models.CygxIndustryFllowRep
  522. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  523. if err != nil {
  524. br.Msg = "参数解析异常!"
  525. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  526. return
  527. }
  528. industrialManagementId := req.IndustrialManagementId
  529. var condition string
  530. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  531. if err != nil {
  532. br.Msg = "获取数据失败!"
  533. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  534. return
  535. }
  536. if countIndustrial == 0 {
  537. br.Msg = "产业不存在!"
  538. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  539. return
  540. }
  541. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  542. if err != nil {
  543. br.Msg = "获取数据失败!"
  544. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  545. return
  546. }
  547. resp := new(models.CygxIndustryFllowResp)
  548. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  549. if countUser == 0 {
  550. resp.GoFollow = true
  551. }
  552. if count == 0 {
  553. item := new(models.CygxIndustryFllow)
  554. item.IndustrialManagementId = industrialManagementId
  555. item.UserId = uid
  556. item.Email = user.Email
  557. item.Mobile = user.Mobile
  558. item.CompanyId = user.CompanyId
  559. item.CompanyName = user.CompanyName
  560. item.Type = 1
  561. item.CreateTime = time.Now()
  562. item.ModifyTime = time.Now()
  563. _, err = models.AddCygxIndustryFllow(item)
  564. if err != nil {
  565. br.Msg = "操作失败"
  566. br.ErrMsg = "操作失败,Err:" + err.Error()
  567. return
  568. }
  569. resp.Status = 1
  570. } else {
  571. var doType int
  572. condition = ` AND type = 1`
  573. count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  574. if err != nil {
  575. br.Msg = "操作失败!"
  576. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  577. return
  578. }
  579. if count == 1 {
  580. resp.Status = 2
  581. doType = 2
  582. } else {
  583. resp.Status = 1
  584. doType = 1
  585. }
  586. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
  587. if err != nil {
  588. br.Msg = "操作失败"
  589. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  590. return
  591. }
  592. }
  593. br.Msg = "操作成功"
  594. br.Ret = 200
  595. br.Success = true
  596. br.Data = resp
  597. }
  598. // @Title 产业报告分类关联作者列表接口
  599. // @Description 获取产业报告分类关联作者列表接口
  600. // @Param ChartPermissionId query int true "分类ID"
  601. // @Param PageSize query int true "每页数据条数"
  602. // @Param CurrentIndex query int true "当前页页码,从1开始"
  603. // @Success 200 {object} models.CygxArticleDepartmentList
  604. // @router /industryListByDepartment [get]
  605. func (this *ReportController) IndustryListByDepartment() {
  606. br := new(models.BaseResponse).Init()
  607. defer func() {
  608. this.Data["json"] = br
  609. this.ServeJSON()
  610. }()
  611. user := this.User
  612. if user == nil {
  613. br.Msg = "请重新登录"
  614. br.Ret = 408
  615. return
  616. }
  617. uid := user.UserId
  618. pageSize, _ := this.GetInt("PageSize")
  619. currentIndex, _ := this.GetInt("CurrentIndex")
  620. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  621. var startSize int
  622. var condition string
  623. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  624. condition = ` AND a.publish_status=1 `
  625. if pageSize <= 0 {
  626. pageSize = utils.PageSize20
  627. }
  628. if currentIndex <= 0 {
  629. currentIndex = 1
  630. }
  631. startSize = paging.StartIndex(currentIndex, pageSize)
  632. total, err := models.GetArticleDepartmentCount(condition)
  633. page := paging.GetPaging(currentIndex, pageSize, total)
  634. resp := new(models.CygxArticleDepartmentList)
  635. userType, _, err := services.GetUserType(user.CompanyId)
  636. if err != nil {
  637. br.Msg = "获取信息失败"
  638. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  639. return
  640. }
  641. if userType == 1 {
  642. resp.Paging = page
  643. br.Ret = 200
  644. br.Success = true
  645. br.Msg = "获取成功"
  646. br.Data = resp
  647. return
  648. }
  649. resp.HaveResearch = true
  650. //获取作者信息,并排序
  651. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  652. if err != nil {
  653. br.Msg = "获取信息失败"
  654. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  655. return
  656. }
  657. for k, v := range list {
  658. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  659. if err != nil {
  660. br.Msg = "获取信息失败"
  661. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  662. return
  663. }
  664. for k2, v2 := range artList {
  665. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  666. if err != nil {
  667. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  668. br.ErrMsg = "获取失败,Err:" + err.Error()
  669. return
  670. }
  671. var subjectNamesNew string
  672. if len(subjectNames) > 0 {
  673. slice := strings.Split(subjectNames, "/")
  674. for k3, v3 := range slice {
  675. if k3 < 4 {
  676. subjectNamesNew += v3 + "/"
  677. }
  678. }
  679. }
  680. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  681. if err != nil && err.Error() != utils.ErrNoRow() {
  682. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  683. br.ErrMsg = "获取失败,Err:" + err.Error()
  684. return
  685. }
  686. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  687. artList[k2].SubjectName = subjectNamesNew
  688. artList[k2].DepartmentId = v.DepartmentId
  689. if subjectNamesNew == "" {
  690. artList[k2].IndustryName = industryName
  691. } else {
  692. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  693. }
  694. if artList[k2].IsReport == "1" {
  695. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  696. } else {
  697. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  698. }
  699. }
  700. list[k].List = artList
  701. if v.FollowNum > 0 {
  702. list[k].IsMyFollow = true
  703. }
  704. }
  705. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  706. if err != nil {
  707. br.Msg = "获取信息失败"
  708. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  709. return
  710. }
  711. if len(listnNew) > 0 {
  712. for _, v := range listnNew {
  713. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  714. Management := new(models.IndustrialManagementIdInt)
  715. if firstStr == 0 {
  716. Management.IndustryName = v.IndustryName
  717. } else {
  718. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  719. if err != nil {
  720. br.Msg = "获取信息失败"
  721. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  722. return
  723. }
  724. var subjectNamesNew string
  725. for _, v1 := range listSub {
  726. subjectNamesNew += v1.SubjectName + "/"
  727. }
  728. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  729. Management.IndustryName = subjectNamesNew
  730. }
  731. Management.IndustrialManagementId = v.IndustrialManagementId
  732. Management.ArticleId = v.ArticleId
  733. resp.ListnNew = append(resp.ListnNew, Management)
  734. }
  735. }
  736. resp.List = list
  737. resp.Paging = page
  738. br.Ret = 200
  739. br.Success = true
  740. br.Msg = "获取成功"
  741. br.Data = resp
  742. }
  743. // @Title 关注作者/取消关注作者
  744. // @Description 关注作者/取消关注作者 接口
  745. // @Param request body models.CygxArticleDepartmentId true "type json string"
  746. // @Success 200
  747. // @router /fllowDepartment [post]
  748. func (this *ReportController) FllowDepartment() {
  749. br := new(models.BaseResponse).Init()
  750. defer func() {
  751. this.Data["json"] = br
  752. this.ServeJSON()
  753. }()
  754. user := this.User
  755. if user == nil {
  756. br.Msg = "请重新登录"
  757. br.Ret = 408
  758. return
  759. }
  760. uid := user.UserId
  761. var req models.CygxArticleDepartmentId
  762. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  763. if err != nil {
  764. br.Msg = "参数解析异常!"
  765. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  766. return
  767. }
  768. departmentId := req.DepartmentId
  769. var condition string
  770. countDepartment, err := models.GetDepartmentCount(departmentId)
  771. if err != nil {
  772. br.Msg = "获取数据失败!"
  773. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  774. return
  775. }
  776. if countDepartment == 0 {
  777. br.Msg = "作者不存在!"
  778. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  779. return
  780. }
  781. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  782. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  783. if err != nil {
  784. br.Msg = "获取数据失败!"
  785. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  786. return
  787. }
  788. resp := new(models.CygxArticleDepartmentFollowResp)
  789. if countUser == 0 {
  790. resp.GoFollow = true
  791. }
  792. if count == 0 {
  793. item := new(models.CygxArticleDepartmentFollow)
  794. item.DepartmentId = departmentId
  795. item.UserId = uid
  796. item.Email = user.Email
  797. item.Mobile = user.Mobile
  798. item.CompanyId = user.CompanyId
  799. item.CompanyName = user.CompanyName
  800. item.Type = 1
  801. item.CreateTime = time.Now()
  802. item.ModifyTime = time.Now()
  803. _, err = models.AddArticleDepartmentFollow(item)
  804. if err != nil {
  805. br.Msg = "操作失败"
  806. br.ErrMsg = "操作失败,Err:" + err.Error()
  807. return
  808. }
  809. resp.Status = 1
  810. } else {
  811. var doType int
  812. condition = ` AND type = 1`
  813. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  814. if err != nil {
  815. br.Msg = "操作失败!"
  816. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  817. return
  818. }
  819. if count == 1 {
  820. resp.Status = 2
  821. doType = 2
  822. } else {
  823. resp.Status = 1
  824. doType = 1
  825. }
  826. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  827. if err != nil {
  828. br.Msg = "操作失败"
  829. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  830. return
  831. }
  832. }
  833. br.Msg = "操作成功"
  834. br.Ret = 200
  835. br.Success = true
  836. br.Data = resp
  837. }
  838. // @Title 研选文章列表接口
  839. // @Description 获取研选文章列表接口
  840. // @Param PageSize query int true "每页数据条数"
  841. // @Param CurrentIndex query int true "当前页页码,从1开始"
  842. // @Param ArticleId query int true "文章id"
  843. // @Param DepartmentId query int true "作者ID"
  844. // @Param IndustrialManagementId query int true "产业ID"
  845. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  846. // @router /industry/reportList [get]
  847. func (this *ReportController) ReportList() {
  848. br := new(models.BaseResponse).Init()
  849. defer func() {
  850. this.Data["json"] = br
  851. this.ServeJSON()
  852. }()
  853. user := this.User
  854. if user == nil {
  855. br.Msg = "请重新登录"
  856. br.Ret = 408
  857. return
  858. }
  859. uid := user.UserId
  860. pageSize, _ := this.GetInt("PageSize")
  861. currentIndex, _ := this.GetInt("CurrentIndex")
  862. departmentId, _ := this.GetInt("DepartmentId")
  863. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  864. articleId, _ := this.GetInt("ArticleId")
  865. var condition string
  866. var startSize int
  867. if pageSize <= 0 {
  868. pageSize = utils.PageSize20
  869. }
  870. if currentIndex <= 0 {
  871. currentIndex = 1
  872. }
  873. startSize = paging.StartIndex(currentIndex, pageSize)
  874. var pars []interface{}
  875. var total int
  876. resp := new(models.ReportArticleWhichIndustrialRepList)
  877. page := paging.GetPaging(currentIndex, pageSize, total)
  878. userType, _, err := services.GetUserType(user.CompanyId)
  879. if err != nil {
  880. br.Msg = "获取信息失败"
  881. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  882. return
  883. }
  884. if userType == 1 {
  885. resp.Paging = page
  886. br.Ret = 200
  887. br.Success = true
  888. br.Msg = "获取成功"
  889. br.Data = resp
  890. return
  891. }
  892. resp.HaveResearch = true
  893. if departmentId > 0 {
  894. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  895. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  896. if err != nil {
  897. br.Msg = "获取信息失败"
  898. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  899. return
  900. }
  901. resp.NickName = detail.NickName
  902. }
  903. if industrialManagementId > 0 {
  904. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  905. }
  906. if articleId > 0 {
  907. detail, err := models.GetArticleDetailById(articleId)
  908. if err != nil {
  909. br.Msg = "获取信息失败"
  910. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  911. return
  912. }
  913. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  914. }
  915. total, err = models.GetWhichDepartmentCount(condition)
  916. if err != nil {
  917. br.Msg = "获取信息失败"
  918. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  919. return
  920. }
  921. page = paging.GetPaging(currentIndex, pageSize, total)
  922. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  923. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  924. if err != nil {
  925. br.Msg = "获取失败"
  926. br.ErrMsg = "获取失败,Err:" + err.Error()
  927. return
  928. }
  929. for k, v := range list {
  930. if v.Readnum == 0 {
  931. list[k].IsRed = true
  932. }
  933. list[k].IsResearch = true
  934. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  935. if err != nil {
  936. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  937. br.ErrMsg = "获取失败,Err:" + err.Error()
  938. return
  939. }
  940. var subjectNamesNew string
  941. if len(subjectNames) > 0 {
  942. slice := strings.Split(subjectNames, "/")
  943. for k3, v3 := range slice {
  944. if k3 < 4 {
  945. subjectNamesNew += v3 + "/"
  946. }
  947. }
  948. }
  949. industryName, err := models.GetIndustrialNames(v.ArticleId)
  950. if err != nil && err.Error() != utils.ErrNoRow() {
  951. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  952. br.ErrMsg = "获取失败,Err:" + err.Error()
  953. return
  954. }
  955. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  956. list[k].SubjectName = subjectNamesNew
  957. if subjectNamesNew != "" {
  958. list[k].IndustryName = industryName + "-" + subjectNamesNew
  959. } else {
  960. list[k].IndustryName = industryName
  961. }
  962. resp.IndustryName = industryName
  963. }
  964. resp.List = list
  965. resp.Paging = page
  966. br.Ret = 200
  967. br.Success = true
  968. br.Msg = "获取成功"
  969. br.Data = resp
  970. }
  971. // @Title 研选最新主题关键词文章列表接口
  972. // @Description 获取研选最新主题关键词文章列表接口
  973. // @Param PageSize query int true "每页数据条数"
  974. // @Param CurrentIndex query int true "当前页页码,从1开始"
  975. // @Param ArticleId query int true "文章id"
  976. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  977. // @router /industry/reportListNew [get]
  978. func (this *ReportController) ReportListNew() {
  979. br := new(models.BaseResponse).Init()
  980. defer func() {
  981. this.Data["json"] = br
  982. this.ServeJSON()
  983. }()
  984. user := this.User
  985. if user == nil {
  986. br.Msg = "请重新登录"
  987. br.Ret = 408
  988. return
  989. }
  990. uid := user.UserId
  991. pageSize, _ := this.GetInt("PageSize")
  992. currentIndex, _ := this.GetInt("CurrentIndex")
  993. articleId, _ := this.GetInt("ArticleId")
  994. var condition string
  995. var startSize int
  996. if pageSize <= 0 {
  997. pageSize = utils.PageSize20
  998. }
  999. if currentIndex <= 0 {
  1000. currentIndex = 1
  1001. }
  1002. startSize = paging.StartIndex(currentIndex, pageSize)
  1003. var pars []interface{}
  1004. var total int
  1005. resp := new(models.ReportArticleWhichIndustrialRepList)
  1006. page := paging.GetPaging(currentIndex, pageSize, total)
  1007. userType, _, err := services.GetUserType(user.CompanyId)
  1008. if err != nil {
  1009. br.Msg = "获取信息失败"
  1010. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1011. return
  1012. }
  1013. if userType == 1 {
  1014. resp.Paging = page
  1015. br.Ret = 200
  1016. br.Success = true
  1017. br.Msg = "获取成功"
  1018. br.Data = resp
  1019. return
  1020. }
  1021. resp.HaveResearch = true
  1022. if articleId > 0 {
  1023. detail, err := models.GetArticleDetailById(articleId)
  1024. if err != nil {
  1025. br.Msg = "获取信息失败"
  1026. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1027. return
  1028. }
  1029. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1030. if firstStr == 0 {
  1031. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1032. } else {
  1033. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1034. }
  1035. }
  1036. total, err = models.GetWhichDepartmentCount(condition)
  1037. if err != nil {
  1038. br.Msg = "获取信息失败"
  1039. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1040. return
  1041. }
  1042. page = paging.GetPaging(currentIndex, pageSize, total)
  1043. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1044. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1045. if err != nil {
  1046. br.Msg = "获取失败"
  1047. br.ErrMsg = "获取失败,Err:" + err.Error()
  1048. return
  1049. }
  1050. for k, v := range list {
  1051. if v.Readnum == 0 {
  1052. list[k].IsRed = true
  1053. }
  1054. list[k].IsResearch = true
  1055. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1056. if err != nil {
  1057. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1058. br.ErrMsg = "获取失败,Err:" + err.Error()
  1059. return
  1060. }
  1061. var subjectNamesNew string
  1062. if len(subjectNames) > 0 {
  1063. slice := strings.Split(subjectNames, "/")
  1064. for k3, v3 := range slice {
  1065. if k3 < 4 {
  1066. subjectNamesNew += v3 + "/"
  1067. }
  1068. }
  1069. }
  1070. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1071. if err != nil && err.Error() != utils.ErrNoRow() {
  1072. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1073. br.ErrMsg = "获取失败,Err:" + err.Error()
  1074. return
  1075. }
  1076. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1077. list[k].SubjectName = subjectNamesNew
  1078. if subjectNamesNew != "" {
  1079. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1080. } else {
  1081. list[k].IndustryName = industryName
  1082. }
  1083. resp.IndustryName = industryName
  1084. }
  1085. resp.List = list
  1086. resp.Paging = page
  1087. br.Ret = 200
  1088. br.Success = true
  1089. br.Msg = "获取成功"
  1090. br.Data = resp
  1091. }
  1092. // @Title 是否展示绝密内参
  1093. // @Description 获取是否展示绝密内参接口
  1094. // @Param request body models.IsShow true "type json string"
  1095. // @Success 200
  1096. // @router /isShow [get]
  1097. func (this *ReportController) IsShow() {
  1098. br := new(models.BaseResponse).Init()
  1099. defer func() {
  1100. this.Data["json"] = br
  1101. this.ServeJSON()
  1102. }()
  1103. user := this.User
  1104. if user == nil {
  1105. br.Msg = "请重新登录"
  1106. br.Ret = 408
  1107. return
  1108. }
  1109. var resp models.IsShow
  1110. mobile := user.Mobile
  1111. if mobile == "" {
  1112. br.Ret = 200
  1113. br.Success = true
  1114. br.Data = resp
  1115. return
  1116. }
  1117. total, _ := models.GetUserIsAdminCount(mobile)
  1118. if total > 0 {
  1119. resp.IsShow = true
  1120. }
  1121. br.Ret = 200
  1122. br.Success = true
  1123. br.Data = resp
  1124. }
  1125. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1126. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1127. // @Param PageSize query int true "每页数据条数"
  1128. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1129. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1130. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1131. // @router /reportList/byType [get]
  1132. func (this *ReportController) ReportListByType() {
  1133. br := new(models.BaseResponse).Init()
  1134. defer func() {
  1135. this.Data["json"] = br
  1136. this.ServeJSON()
  1137. }()
  1138. user := this.User
  1139. if user == nil {
  1140. br.Msg = "请重新登录"
  1141. br.Ret = 408
  1142. return
  1143. }
  1144. uid := user.UserId
  1145. pageSize, _ := this.GetInt("PageSize")
  1146. currentIndex, _ := this.GetInt("CurrentIndex")
  1147. reportType := this.GetString("ReportType")
  1148. var condition string
  1149. var startSize int
  1150. if pageSize <= 0 {
  1151. pageSize = utils.PageSize20
  1152. }
  1153. if currentIndex <= 0 {
  1154. currentIndex = 1
  1155. }
  1156. startSize = paging.StartIndex(currentIndex, pageSize)
  1157. var pars []interface{}
  1158. var total int
  1159. resp := new(models.CygxReportSelectionListPublicRep)
  1160. page := paging.GetPaging(currentIndex, pageSize, total)
  1161. var tbdb string
  1162. var readSql string
  1163. var reportTypeStr string
  1164. if reportType == "1" {
  1165. tbdb = "cygx_report_selection"
  1166. reportTypeStr = "bgjx"
  1167. } else if reportType == "2" {
  1168. tbdb = "cygx_research_summary"
  1169. reportTypeStr = "bzyjhz"
  1170. } else if reportType == "3" {
  1171. tbdb = "cygx_minutes_summary"
  1172. reportTypeStr = "szjyhz"
  1173. } else {
  1174. br.Msg = "请选择报告类型"
  1175. return
  1176. }
  1177. fmt.Println(tbdb)
  1178. condition = ` AND publish_status = 1`
  1179. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1180. if err != nil {
  1181. br.Msg = "获取信息失败"
  1182. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1183. return
  1184. }
  1185. readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
  1186. page = paging.GetPaging(currentIndex, pageSize, total)
  1187. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1188. if err != nil {
  1189. br.Msg = "获取失败"
  1190. br.ErrMsg = "获取失败,Err:" + err.Error()
  1191. return
  1192. }
  1193. for k, v := range list {
  1194. if reportType == "1" {
  1195. list[k].Abstract = v.UpdateDescription
  1196. }
  1197. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1198. if v.ReadNum == 0 {
  1199. list[k].IsRed = true
  1200. }
  1201. }
  1202. resp.List = list
  1203. resp.Paging = page
  1204. br.Ret = 200
  1205. br.Success = true
  1206. br.Msg = "获取成功"
  1207. br.Data = resp
  1208. }
  1209. // @Title 获取报告精选详情
  1210. // @Description 获取报告精选详情接口
  1211. // @Param ArticleId query int true "报告ID"
  1212. // @Success 200 {object} models.ReportSelectionLetailResp
  1213. // @router /reportSelection/detail [get]
  1214. func (this *ReportController) Detail() {
  1215. br := new(models.BaseResponse).Init()
  1216. defer func() {
  1217. this.Data["json"] = br
  1218. this.ServeJSON()
  1219. }()
  1220. user := this.User
  1221. if user == nil {
  1222. br.Msg = "请重新登录"
  1223. br.Ret = 408
  1224. return
  1225. }
  1226. uid := user.UserId
  1227. articleId, _ := this.GetInt("ArticleId")
  1228. if articleId < 0 {
  1229. br.Msg = "参数错误"
  1230. br.ErrMsg = "参数错误"
  1231. return
  1232. }
  1233. resp := new(models.ReportSelectionLetailResp)
  1234. //判断用户权限
  1235. hasPermission, err := services.GetUserhasPermission(user)
  1236. if err != nil {
  1237. br.Msg = "获取信息失败"
  1238. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1239. }
  1240. resp.HasPermission = hasPermission
  1241. if hasPermission != 1 {
  1242. br.Ret = 200
  1243. br.Success = true
  1244. br.Msg = "获取成功"
  1245. br.Data = resp
  1246. return
  1247. }
  1248. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1249. if err != nil {
  1250. br.Msg = "获取信息失败"
  1251. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1252. return
  1253. }
  1254. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1255. existMap := make(map[int]int)
  1256. var items []*models.ReportSelectionChartPermission
  1257. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1258. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1259. if err != nil {
  1260. br.Msg = "获取失败"
  1261. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1262. return
  1263. }
  1264. //var itemLogs []*models.CygxReportSelectionLogDetail
  1265. for _, v := range listLog {
  1266. item := new(models.ReportSelectionChartPermission)
  1267. if existMap[v.ChartPermissionId] == 0 {
  1268. item.PermissionName = v.PermissionName + "领域深度调研和报告"
  1269. item.IcoLink = v.IcoLink
  1270. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1271. if err != nil && err.Error() != utils.ErrNoRow() {
  1272. br.Msg = "获取信息失败"
  1273. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1274. return
  1275. }
  1276. for k2, v2 := range listSonLog {
  1277. if v2.IndustrialManagementId != "" {
  1278. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1279. if err != nil && err.Error() != utils.ErrNoRow() {
  1280. br.Msg = "获取信息失败"
  1281. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1282. return
  1283. }
  1284. listSonLog[k2].List = listIndustrial
  1285. }
  1286. }
  1287. item.List = listSonLog
  1288. items = append(items, item)
  1289. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1290. }
  1291. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1292. }
  1293. historyRecord := new(models.CygxReportHistoryRecord)
  1294. historyRecord.UserId = uid
  1295. historyRecord.ArticleId = articleId
  1296. historyRecord.CreateTime = time.Now()
  1297. historyRecord.Mobile = user.Mobile
  1298. historyRecord.Email = user.Email
  1299. historyRecord.CompanyId = user.CompanyId
  1300. historyRecord.CompanyName = user.CompanyName
  1301. historyRecord.ReportType = "bgjx"
  1302. go models.AddCygxReportHistoryRecord(historyRecord)
  1303. resp.List = items
  1304. resp.Detail = detail
  1305. br.Ret = 200
  1306. br.Success = true
  1307. br.Msg = "获取成功"
  1308. br.Data = resp
  1309. }
  1310. // @Title 获取本周研究汇总详情
  1311. // @Description 获取本周研究汇总详情接口
  1312. // @Param ArticleId query int true "报告ID"
  1313. // @Success 200 {object} models.ResearchSummaryLetailResp
  1314. // @router /researchSummary/detail [get]
  1315. func (this *ReportController) ResearchDetail() {
  1316. br := new(models.BaseResponse).Init()
  1317. defer func() {
  1318. this.Data["json"] = br
  1319. this.ServeJSON()
  1320. }()
  1321. user := this.User
  1322. if user == nil {
  1323. br.Msg = "请重新登录"
  1324. br.Ret = 408
  1325. return
  1326. }
  1327. uid := user.UserId
  1328. articleId, _ := this.GetInt("ArticleId")
  1329. if articleId < 0 {
  1330. br.Msg = "参数错误"
  1331. br.ErrMsg = "参数错误"
  1332. return
  1333. }
  1334. resp := new(models.ResearchSummaryLetailResp)
  1335. //判断用户权限
  1336. hasPermission, err := services.GetUserhasPermission(user)
  1337. if err != nil {
  1338. br.Msg = "获取信息失败"
  1339. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1340. }
  1341. resp.HasPermission = hasPermission
  1342. if hasPermission != 1 {
  1343. br.Ret = 200
  1344. br.Success = true
  1345. br.Msg = "获取成功"
  1346. br.Data = resp
  1347. return
  1348. }
  1349. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1350. if err != nil {
  1351. br.Msg = "获取信息失败"
  1352. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1353. return
  1354. }
  1355. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1356. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1357. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1358. if err != nil {
  1359. br.Msg = "获取失败"
  1360. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1361. return
  1362. }
  1363. for k, v := range listFirst {
  1364. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1365. if err != nil && err.Error() != utils.ErrNoRow() {
  1366. br.Msg = "获取信息失败"
  1367. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1368. return
  1369. }
  1370. for k2, v2 := range listSecond {
  1371. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1372. if err != nil && err.Error() != utils.ErrNoRow() {
  1373. br.Msg = "获取信息失败"
  1374. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1375. return
  1376. }
  1377. if len(listThird) > 0 {
  1378. listSecond[k2].List = listThird
  1379. for k3, v3 := range listThird {
  1380. if v3.VideoUrl != "" {
  1381. listThird[k3].IsHaveVideo = true
  1382. }
  1383. if v3.ReportLink == "0" {
  1384. listThird[k3].ReportLink = ""
  1385. }
  1386. }
  1387. }
  1388. }
  1389. if len(listSecond) > 0 {
  1390. listFirst[k].List = listSecond
  1391. }
  1392. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1393. if v.Type == "SDBG" {
  1394. listFirst[k].ListName = "深度报告"
  1395. listFirst[k].IcoLink = ""
  1396. } else if v.Type == "BZCHJH" {
  1397. listFirst[k].ListName = "本周晨会精华"
  1398. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1399. } else if v.Type == "CYDYJY" {
  1400. listFirst[k].ListName = "产业调研纪要"
  1401. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1402. } else {
  1403. listFirst[k].ListName = "事件点评"
  1404. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1405. }
  1406. }
  1407. historyRecord := new(models.CygxReportHistoryRecord)
  1408. historyRecord.UserId = uid
  1409. historyRecord.ArticleId = articleId
  1410. historyRecord.CreateTime = time.Now()
  1411. historyRecord.Mobile = user.Mobile
  1412. historyRecord.Email = user.Email
  1413. historyRecord.CompanyId = user.CompanyId
  1414. historyRecord.CompanyName = user.CompanyName
  1415. historyRecord.ReportType = "bzyjhz"
  1416. go models.AddCygxReportHistoryRecord(historyRecord)
  1417. resp.List = listFirst
  1418. resp.Detail = detail
  1419. br.Ret = 200
  1420. br.Success = true
  1421. br.Msg = "获取成功"
  1422. br.Data = resp
  1423. }
  1424. // @Title 上周纪要汇总内容详情
  1425. // @Description 获取上周纪要汇总内容详情接口
  1426. // @Param ArticleId query int true "报告ID"
  1427. // @Success 200 {object} models.MinutesSummaryLetailResp
  1428. // @router /minutesSummary/detail [get]
  1429. func (this *ReportController) MinutesDetail() {
  1430. br := new(models.BaseResponse).Init()
  1431. defer func() {
  1432. this.Data["json"] = br
  1433. this.ServeJSON()
  1434. }()
  1435. user := this.User
  1436. if user == nil {
  1437. br.Msg = "请重新登录"
  1438. br.Ret = 408
  1439. return
  1440. }
  1441. uid := user.UserId
  1442. articleId, _ := this.GetInt("ArticleId")
  1443. if articleId < 0 {
  1444. br.Msg = "参数错误"
  1445. br.ErrMsg = "参数错误"
  1446. return
  1447. }
  1448. resp := new(models.MinutesSummaryLetailResp)
  1449. //判断用户权限
  1450. hasPermission, err := services.GetUserhasPermission(user)
  1451. if err != nil {
  1452. br.Msg = "获取信息失败"
  1453. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1454. }
  1455. resp.HasPermission = hasPermission
  1456. if hasPermission != 1 {
  1457. br.Ret = 200
  1458. br.Success = true
  1459. br.Msg = "获取成功"
  1460. br.Data = resp
  1461. return
  1462. }
  1463. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1464. if err != nil {
  1465. br.Msg = "获取信息失败"
  1466. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1467. return
  1468. }
  1469. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1470. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1471. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1472. if err != nil {
  1473. br.Msg = "获取失败"
  1474. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1475. return
  1476. }
  1477. for k, v := range listLog {
  1478. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1479. if err != nil && err.Error() != utils.ErrNoRow() {
  1480. br.Msg = "获取信息失败"
  1481. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. if len(listSonLog) > 0 {
  1485. listLog[k].List = listSonLog
  1486. for k2, v2 := range listSonLog {
  1487. if v2.ReportLink == "0" {
  1488. listSonLog[k2].ReportLink = ""
  1489. }
  1490. }
  1491. }
  1492. }
  1493. historyRecord := new(models.CygxReportHistoryRecord)
  1494. historyRecord.UserId = uid
  1495. historyRecord.ArticleId = articleId
  1496. historyRecord.CreateTime = time.Now()
  1497. historyRecord.Mobile = user.Mobile
  1498. historyRecord.Email = user.Email
  1499. historyRecord.CompanyId = user.CompanyId
  1500. historyRecord.CompanyName = user.CompanyName
  1501. historyRecord.ReportType = "szjyhz"
  1502. go models.AddCygxReportHistoryRecord(historyRecord)
  1503. resp.List = listLog
  1504. resp.Detail = detail
  1505. br.Ret = 200
  1506. br.Success = true
  1507. br.Msg = "获取成功"
  1508. br.Data = resp
  1509. }
  1510. // @Title 获取路演精华详情
  1511. // @Description 获取路演精华详情接口
  1512. // @Param ArticleId query int true "报告ID"
  1513. // @Success 200 {object} models.RoadshowDetailResp
  1514. // @router /roadshowEssence/detail [get]
  1515. func (this *ReportController) RoadshowDetail() {
  1516. br := new(models.BaseResponse).Init()
  1517. defer func() {
  1518. this.Data["json"] = br
  1519. this.ServeJSON()
  1520. }()
  1521. user := this.User
  1522. if user == nil {
  1523. br.Msg = "请登录"
  1524. br.ErrMsg = "请登录,用户信息为空"
  1525. br.Ret = 408
  1526. return
  1527. }
  1528. uid := user.UserId
  1529. articleId, err := this.GetInt("ArticleId")
  1530. if articleId <= 0 {
  1531. br.Msg = "文章不存在"
  1532. br.ErrMsg = "文章不存在,文章ID错误"
  1533. return
  1534. }
  1535. detail := new(models.ReportDetailRoadshow)
  1536. hasPermission := 0
  1537. hasFree := 0
  1538. //判断是否已经申请过
  1539. applyCount, err := models.GetApplyRecordCount(uid)
  1540. if err != nil && err.Error() != utils.ErrNoRow() {
  1541. br.Msg = "获取信息失败"
  1542. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1543. return
  1544. }
  1545. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1546. if user.CompanyId > 1 {
  1547. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1548. if err != nil {
  1549. br.Msg = "获取信息失败"
  1550. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1551. return
  1552. }
  1553. detail, err = models.GetReportRoadshowDetailById(articleId)
  1554. if err != nil {
  1555. br.Msg = "获取信息失败"
  1556. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1557. return
  1558. }
  1559. detail.Body = html.UnescapeString(detail.Body)
  1560. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1561. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1562. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1563. if detail.ReportLink == "0" {
  1564. detail.ReportLink = ""
  1565. }
  1566. if companyPermission == "" {
  1567. if applyCount > 0 {
  1568. hasPermission = 5
  1569. } else {
  1570. hasPermission = 2
  1571. }
  1572. hasFree = 2
  1573. goto Loop
  1574. } else {
  1575. hasFree = 1
  1576. var articlePermissionPermissionName string
  1577. articlePermissionPermissionName = detail.CategoryName
  1578. var hasPersion bool
  1579. slice := strings.Split(articlePermissionPermissionName, ",")
  1580. for _, v := range slice {
  1581. if strings.Contains(companyPermission, v) {
  1582. hasPersion = true
  1583. }
  1584. }
  1585. if hasPersion {
  1586. hasPermission = 1
  1587. historyRecord := new(models.CygxArticleHistoryRecord)
  1588. historyRecord.UserId = uid
  1589. historyRecord.ArticleId = articleId
  1590. historyRecord.CreateTime = time.Now()
  1591. historyRecord.Mobile = user.Mobile
  1592. historyRecord.Email = user.Email
  1593. historyRecord.CompanyId = user.CompanyId
  1594. historyRecord.CompanyName = user.CompanyName
  1595. go models.AddCygxArticleHistoryRecord(historyRecord)
  1596. } else { //无该行业权限
  1597. hasPermission = 3
  1598. }
  1599. if hasPermission == 1 {
  1600. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1601. if !utils.Rc.IsExist(key) {
  1602. //新增浏览记录
  1603. record := new(models.CygxArticleViewRecord)
  1604. record.UserId = uid
  1605. record.ArticleId = articleId
  1606. record.CreateTime = time.Now()
  1607. record.Mobile = user.Mobile
  1608. record.Email = user.Email
  1609. record.CompanyId = user.CompanyId
  1610. record.CompanyName = user.CompanyName
  1611. go models.AddCygxArticleViewRecord(record)
  1612. utils.Rc.Put(key, 1, 5*time.Second)
  1613. models.ModifyReportLastViewTime(uid)
  1614. }
  1615. }
  1616. }
  1617. } else { //潜在客户
  1618. if applyCount > 0 {
  1619. hasPermission = 5
  1620. } else {
  1621. hasPermission = 4
  1622. }
  1623. }
  1624. Loop:
  1625. if hasPermission != 1 {
  1626. detail.Body = ""
  1627. detail.Abstract = ""
  1628. }
  1629. resp := new(models.RoadshowDetailResp)
  1630. resp.HasPermission = hasPermission
  1631. resp.HasFree = hasFree
  1632. resp.Detail = detail
  1633. br.Ret = 200
  1634. br.Success = true
  1635. br.Msg = "获取成功"
  1636. br.Data = resp
  1637. }