report.go 57 KB

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