report.go 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/services"
  8. "hongze/hongze_cygx/utils"
  9. "html"
  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. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  267. if err != nil {
  268. br.Msg = "获取信息失败"
  269. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  270. return
  271. }
  272. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  273. if err != nil {
  274. br.Msg = "获取信息失败"
  275. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  276. return
  277. }
  278. for k, v := range list {
  279. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  280. if err != nil && err.Error() != utils.ErrNoRow() {
  281. br.Msg = "获取信息失败"
  282. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  283. return
  284. }
  285. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  286. if err != nil {
  287. br.Msg = "获取信息失败"
  288. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  289. return
  290. }
  291. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  292. list[k].IsRed = true
  293. }
  294. }
  295. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  296. //if err != nil {
  297. // br.Msg = "获取信息失败"
  298. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  299. // return
  300. //}
  301. resp := new(models.IndustrialToArticleCategoryListRep)
  302. resp.List = list
  303. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  304. resp.IndustryName = detail.IndustryName
  305. resp.IndustrialManagementId = industrialManagementId
  306. br.Ret = 200
  307. br.Success = true
  308. br.Msg = "获取成功"
  309. br.Data = resp
  310. }
  311. // @Title 产业文章列表接口
  312. // @Description 获取产业文章列表接口
  313. // @Param PageSize query int true "每页数据条数"
  314. // @Param CurrentIndex query int true "当前页页码,从1开始"
  315. // @Param CategoryId query int true "分类ID"
  316. // @Param IndustrialManagementId query int true "产业ID"
  317. // @Success 200 {object} models.TacticsListResp
  318. // @router /industry/ArticleList [get]
  319. func (this *ReportController) List() {
  320. br := new(models.BaseResponse).Init()
  321. defer func() {
  322. this.Data["json"] = br
  323. this.ServeJSON()
  324. }()
  325. user := this.User
  326. if user == nil {
  327. br.Msg = "请重新登录"
  328. br.Ret = 408
  329. return
  330. }
  331. uid := user.UserId
  332. pageSize, _ := this.GetInt("PageSize")
  333. currentIndex, _ := this.GetInt("CurrentIndex")
  334. categoryId, _ := this.GetInt("CategoryId")
  335. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  336. var startSize int
  337. if pageSize <= 0 {
  338. pageSize = utils.PageSize20
  339. }
  340. if currentIndex <= 0 {
  341. currentIndex = 1
  342. }
  343. startSize = paging.StartIndex(currentIndex, pageSize)
  344. var pars []interface{}
  345. var total int
  346. resp := new(models.TacticsListResp)
  347. page := paging.GetPaging(currentIndex, pageSize, total)
  348. if categoryId < 1 {
  349. br.Msg = "请输入分类ID"
  350. return
  351. }
  352. if industrialManagementId < 1 {
  353. br.Msg = "请输入产业ID"
  354. return
  355. }
  356. //获取该产业下所对应的行业图片
  357. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  358. if errCategory != nil {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  361. return
  362. }
  363. //对应行业的图片
  364. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  365. if err != nil {
  366. br.Msg = "获取数据失败"
  367. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  368. return
  369. }
  370. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  371. mapChartPermission := make(map[string]string)
  372. var permissionName string
  373. var imgUrlChartPermission string
  374. for _, v := range chartPermissionUrlList {
  375. vslice := strings.Split(v, "_")
  376. permissionName = vslice[0]
  377. imgUrlChartPermission = vslice[len(vslice)-1]
  378. mapChartPermission[permissionName] = imgUrlChartPermission
  379. }
  380. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  381. if err != nil {
  382. br.Msg = "获取信息失败"
  383. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  384. return
  385. }
  386. page = paging.GetPaging(currentIndex, pageSize, total)
  387. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  388. if err != nil {
  389. br.Msg = "获取信息失败"
  390. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  391. return
  392. }
  393. //对应分类的所图片
  394. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  395. if err != nil {
  396. br.Msg = "获取数据失败"
  397. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  398. return
  399. }
  400. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  401. mapCategoryUrl := make(map[string]string)
  402. var categoryIdStr string
  403. var imgUrlChart string
  404. for _, v := range categoryUrlList {
  405. vslice := strings.Split(v, "_")
  406. categoryIdStr = vslice[0]
  407. imgUrlChart = vslice[len(vslice)-1]
  408. mapCategoryUrl[categoryIdStr] = imgUrlChart
  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. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  425. }
  426. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  427. resp.List = list
  428. resp.Paging = page
  429. br.Ret = 200
  430. br.Success = true
  431. br.Msg = "获取成功"
  432. br.Data = resp
  433. }
  434. // @Title 置顶/取消置顶
  435. // @Description 置顶
  436. // @Param request body models.CygxIndustryTopRep true "type json string"
  437. // @Success 200
  438. // @router /top [post]
  439. func (this *ReportController) ArticleCollect() {
  440. br := new(models.BaseResponse).Init()
  441. defer func() {
  442. this.Data["json"] = br
  443. this.ServeJSON()
  444. }()
  445. user := this.User
  446. if user == nil {
  447. br.Msg = "请重新登录"
  448. br.Ret = 408
  449. return
  450. }
  451. uid := user.UserId
  452. var req models.CygxIndustryTopRep
  453. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  454. if err != nil {
  455. br.Msg = "参数解析异常!"
  456. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  457. return
  458. }
  459. industrialManagementId := req.IndustrialManagementId
  460. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  461. if err != nil {
  462. br.Msg = "获取数据失败!"
  463. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  464. return
  465. }
  466. if countIndustrial == 0 {
  467. br.Msg = "产业不存在!"
  468. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  469. return
  470. }
  471. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  472. if err != nil {
  473. br.Msg = "获取数据失败!"
  474. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  475. return
  476. }
  477. resp := new(models.ArticleCollectResp)
  478. if count <= 0 {
  479. item := new(models.CygxIndustryTop)
  480. item.IndustrialManagementId = req.IndustrialManagementId
  481. item.UserId = uid
  482. item.CreateTime = time.Now()
  483. _, err = models.AddCygxIndustryTop(item)
  484. if err != nil {
  485. br.Msg = "置顶失败"
  486. br.ErrMsg = "置顶失败,Err:" + err.Error()
  487. return
  488. }
  489. br.Msg = "置顶成功"
  490. resp.Status = 1
  491. } else {
  492. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  493. if err != nil {
  494. br.Msg = "取消置顶失败"
  495. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  496. return
  497. }
  498. br.Msg = "已取消置顶"
  499. resp.Status = 2
  500. }
  501. br.Ret = 200
  502. br.Success = true
  503. br.Data = resp
  504. }
  505. // @Title 关注/取消关注产业
  506. // @Description 关注/取消关注 接口
  507. // @Param request body models.CygxIndustryFllowRep true "type json string"
  508. // @Success 200
  509. // @router /fllow [post]
  510. func (this *ReportController) Fllow() {
  511. br := new(models.BaseResponse).Init()
  512. defer func() {
  513. this.Data["json"] = br
  514. this.ServeJSON()
  515. }()
  516. user := this.User
  517. if user == nil {
  518. br.Msg = "请重新登录"
  519. br.Ret = 408
  520. return
  521. }
  522. uid := user.UserId
  523. var req models.CygxIndustryFllowRep
  524. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  525. if err != nil {
  526. br.Msg = "参数解析异常!"
  527. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  528. return
  529. }
  530. industrialManagementId := req.IndustrialManagementId
  531. var condition string
  532. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  533. if err != nil {
  534. br.Msg = "获取数据失败!"
  535. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  536. return
  537. }
  538. if countIndustrial == 0 {
  539. br.Msg = "产业不存在!"
  540. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  541. return
  542. }
  543. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  544. if err != nil {
  545. br.Msg = "获取数据失败!"
  546. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  547. return
  548. }
  549. resp := new(models.CygxIndustryFllowResp)
  550. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  551. if countUser == 0 {
  552. resp.GoFollow = true
  553. }
  554. if count == 0 {
  555. item := new(models.CygxIndustryFllow)
  556. item.IndustrialManagementId = industrialManagementId
  557. item.UserId = uid
  558. item.Email = user.Email
  559. item.Mobile = user.Mobile
  560. item.CompanyId = user.CompanyId
  561. item.CompanyName = user.CompanyName
  562. item.Type = 1
  563. item.CreateTime = time.Now()
  564. item.ModifyTime = time.Now()
  565. _, err = models.AddCygxIndustryFllow(item)
  566. if err != nil {
  567. br.Msg = "操作失败"
  568. br.ErrMsg = "操作失败,Err:" + err.Error()
  569. return
  570. }
  571. resp.Status = 1
  572. } else {
  573. var doType int
  574. condition = ` AND type = 1`
  575. count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  576. if err != nil {
  577. br.Msg = "操作失败!"
  578. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  579. return
  580. }
  581. if count == 1 {
  582. resp.Status = 2
  583. doType = 2
  584. } else {
  585. resp.Status = 1
  586. doType = 1
  587. }
  588. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
  589. if err != nil {
  590. br.Msg = "操作失败"
  591. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  592. return
  593. }
  594. }
  595. br.Msg = "操作成功"
  596. br.Ret = 200
  597. br.Success = true
  598. br.Data = resp
  599. }
  600. // @Title 产业报告分类关联作者列表接口
  601. // @Description 获取产业报告分类关联作者列表接口
  602. // @Param ChartPermissionId query int true "分类ID"
  603. // @Param PageSize query int true "每页数据条数"
  604. // @Param CurrentIndex query int true "当前页页码,从1开始"
  605. // @Success 200 {object} models.CygxArticleDepartmentList
  606. // @router /industryListByDepartment [get]
  607. func (this *ReportController) IndustryListByDepartment() {
  608. br := new(models.BaseResponse).Init()
  609. defer func() {
  610. this.Data["json"] = br
  611. this.ServeJSON()
  612. }()
  613. user := this.User
  614. if user == nil {
  615. br.Msg = "请重新登录"
  616. br.Ret = 408
  617. return
  618. }
  619. uid := user.UserId
  620. pageSize, _ := this.GetInt("PageSize")
  621. currentIndex, _ := this.GetInt("CurrentIndex")
  622. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  623. var startSize int
  624. var condition string
  625. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  626. condition = ` AND a.publish_status=1 `
  627. if pageSize <= 0 {
  628. pageSize = utils.PageSize20
  629. }
  630. if currentIndex <= 0 {
  631. currentIndex = 1
  632. }
  633. startSize = paging.StartIndex(currentIndex, pageSize)
  634. total, err := models.GetArticleDepartmentCount(condition)
  635. page := paging.GetPaging(currentIndex, pageSize, total)
  636. resp := new(models.CygxArticleDepartmentList)
  637. userType, _, err := services.GetUserType(user.CompanyId)
  638. if err != nil {
  639. br.Msg = "获取信息失败"
  640. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  641. return
  642. }
  643. if userType == 1 {
  644. resp.Paging = page
  645. br.Ret = 200
  646. br.Success = true
  647. br.Msg = "获取成功"
  648. br.Data = resp
  649. return
  650. }
  651. resp.HaveResearch = true
  652. //获取作者信息,并排序
  653. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  654. if err != nil {
  655. br.Msg = "获取信息失败"
  656. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  657. return
  658. }
  659. for k, v := range list {
  660. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  661. if err != nil {
  662. br.Msg = "获取信息失败"
  663. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  664. return
  665. }
  666. for k2, v2 := range artList {
  667. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  668. if err != nil {
  669. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  670. br.ErrMsg = "获取失败,Err:" + err.Error()
  671. return
  672. }
  673. var subjectNamesNew string
  674. if len(subjectNames) > 0 {
  675. slice := strings.Split(subjectNames, "/")
  676. for k3, v3 := range slice {
  677. if k3 < 4 {
  678. subjectNamesNew += v3 + "/"
  679. }
  680. }
  681. }
  682. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  683. if err != nil && err.Error() != utils.ErrNoRow() {
  684. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  685. br.ErrMsg = "获取失败,Err:" + err.Error()
  686. return
  687. }
  688. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  689. artList[k2].SubjectName = subjectNamesNew
  690. artList[k2].DepartmentId = v.DepartmentId
  691. if subjectNamesNew == "" {
  692. artList[k2].IndustryName = industryName
  693. } else {
  694. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  695. }
  696. if artList[k2].IsReport == "1" {
  697. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  698. } else {
  699. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  700. }
  701. }
  702. list[k].List = artList
  703. if v.FollowNum > 0 {
  704. list[k].IsMyFollow = true
  705. }
  706. }
  707. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  708. if err != nil {
  709. br.Msg = "获取信息失败"
  710. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  711. return
  712. }
  713. if len(listnNew) > 0 {
  714. for _, v := range listnNew {
  715. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  716. Management := new(models.IndustrialManagementIdInt)
  717. if firstStr == 0 {
  718. Management.IndustryName = v.IndustryName
  719. } else {
  720. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  721. if err != nil {
  722. br.Msg = "获取信息失败"
  723. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  724. return
  725. }
  726. var subjectNamesNew string
  727. for _, v1 := range listSub {
  728. subjectNamesNew += v1.SubjectName + "/"
  729. }
  730. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  731. Management.IndustryName = subjectNamesNew
  732. }
  733. Management.IndustrialManagementId = v.IndustrialManagementId
  734. Management.ArticleId = v.ArticleId
  735. resp.ListnNew = append(resp.ListnNew, Management)
  736. }
  737. }
  738. resp.List = list
  739. resp.Paging = page
  740. br.Ret = 200
  741. br.Success = true
  742. br.Msg = "获取成功"
  743. br.Data = resp
  744. }
  745. // @Title 关注作者/取消关注作者
  746. // @Description 关注作者/取消关注作者 接口
  747. // @Param request body models.CygxArticleDepartmentId true "type json string"
  748. // @Success 200
  749. // @router /fllowDepartment [post]
  750. func (this *ReportController) FllowDepartment() {
  751. br := new(models.BaseResponse).Init()
  752. defer func() {
  753. this.Data["json"] = br
  754. this.ServeJSON()
  755. }()
  756. user := this.User
  757. if user == nil {
  758. br.Msg = "请重新登录"
  759. br.Ret = 408
  760. return
  761. }
  762. uid := user.UserId
  763. var req models.CygxArticleDepartmentId
  764. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  765. if err != nil {
  766. br.Msg = "参数解析异常!"
  767. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  768. return
  769. }
  770. departmentId := req.DepartmentId
  771. var condition string
  772. countDepartment, err := models.GetDepartmentCount(departmentId)
  773. if err != nil {
  774. br.Msg = "获取数据失败!"
  775. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  776. return
  777. }
  778. if countDepartment == 0 {
  779. br.Msg = "作者不存在!"
  780. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  781. return
  782. }
  783. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  784. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  785. if err != nil {
  786. br.Msg = "获取数据失败!"
  787. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  788. return
  789. }
  790. resp := new(models.CygxArticleDepartmentFollowResp)
  791. if countUser == 0 {
  792. resp.GoFollow = true
  793. }
  794. if count == 0 {
  795. item := new(models.CygxArticleDepartmentFollow)
  796. item.DepartmentId = departmentId
  797. item.UserId = uid
  798. item.Email = user.Email
  799. item.Mobile = user.Mobile
  800. item.CompanyId = user.CompanyId
  801. item.CompanyName = user.CompanyName
  802. item.Type = 1
  803. item.CreateTime = time.Now()
  804. item.ModifyTime = time.Now()
  805. _, err = models.AddArticleDepartmentFollow(item)
  806. if err != nil {
  807. br.Msg = "操作失败"
  808. br.ErrMsg = "操作失败,Err:" + err.Error()
  809. return
  810. }
  811. resp.Status = 1
  812. } else {
  813. var doType int
  814. condition = ` AND type = 1`
  815. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  816. if err != nil {
  817. br.Msg = "操作失败!"
  818. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  819. return
  820. }
  821. if count == 1 {
  822. resp.Status = 2
  823. doType = 2
  824. } else {
  825. resp.Status = 1
  826. doType = 1
  827. }
  828. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  829. if err != nil {
  830. br.Msg = "操作失败"
  831. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  832. return
  833. }
  834. }
  835. br.Msg = "操作成功"
  836. br.Ret = 200
  837. br.Success = true
  838. br.Data = resp
  839. }
  840. // @Title 研选文章列表接口
  841. // @Description 获取研选文章列表接口
  842. // @Param PageSize query int true "每页数据条数"
  843. // @Param CurrentIndex query int true "当前页页码,从1开始"
  844. // @Param ArticleId query int true "文章id"
  845. // @Param DepartmentId query int true "作者ID"
  846. // @Param IndustrialManagementId query int true "产业ID"
  847. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  848. // @router /industry/reportList [get]
  849. func (this *ReportController) ReportList() {
  850. br := new(models.BaseResponse).Init()
  851. defer func() {
  852. this.Data["json"] = br
  853. this.ServeJSON()
  854. }()
  855. user := this.User
  856. if user == nil {
  857. br.Msg = "请重新登录"
  858. br.Ret = 408
  859. return
  860. }
  861. uid := user.UserId
  862. pageSize, _ := this.GetInt("PageSize")
  863. currentIndex, _ := this.GetInt("CurrentIndex")
  864. departmentId, _ := this.GetInt("DepartmentId")
  865. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  866. articleId, _ := this.GetInt("ArticleId")
  867. var condition string
  868. var startSize int
  869. if pageSize <= 0 {
  870. pageSize = utils.PageSize20
  871. }
  872. if currentIndex <= 0 {
  873. currentIndex = 1
  874. }
  875. startSize = paging.StartIndex(currentIndex, pageSize)
  876. var pars []interface{}
  877. var total int
  878. resp := new(models.ReportArticleWhichIndustrialRepList)
  879. page := paging.GetPaging(currentIndex, pageSize, total)
  880. userType, _, err := services.GetUserType(user.CompanyId)
  881. if err != nil {
  882. br.Msg = "获取信息失败"
  883. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  884. return
  885. }
  886. if userType == 1 {
  887. resp.Paging = page
  888. br.Ret = 200
  889. br.Success = true
  890. br.Msg = "获取成功"
  891. br.Data = resp
  892. return
  893. }
  894. resp.HaveResearch = true
  895. if departmentId > 0 {
  896. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  897. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  898. if err != nil {
  899. br.Msg = "获取信息失败"
  900. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  901. return
  902. }
  903. resp.NickName = detail.NickName
  904. }
  905. if industrialManagementId > 0 {
  906. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  907. }
  908. if articleId > 0 {
  909. detail, err := models.GetArticleDetailById(articleId)
  910. if err != nil {
  911. br.Msg = "获取信息失败"
  912. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  913. return
  914. }
  915. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  916. }
  917. total, err = models.GetWhichDepartmentCount(condition)
  918. if err != nil {
  919. br.Msg = "获取信息失败"
  920. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  921. return
  922. }
  923. page = paging.GetPaging(currentIndex, pageSize, total)
  924. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  925. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  926. if err != nil {
  927. br.Msg = "获取失败"
  928. br.ErrMsg = "获取失败,Err:" + err.Error()
  929. return
  930. }
  931. for k, v := range list {
  932. if v.Readnum == 0 {
  933. list[k].IsRed = true
  934. }
  935. list[k].IsResearch = true
  936. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  937. if err != nil {
  938. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  939. br.ErrMsg = "获取失败,Err:" + err.Error()
  940. return
  941. }
  942. var subjectNamesNew string
  943. if len(subjectNames) > 0 {
  944. slice := strings.Split(subjectNames, "/")
  945. for k3, v3 := range slice {
  946. if k3 < 4 {
  947. subjectNamesNew += v3 + "/"
  948. }
  949. }
  950. }
  951. industryName, err := models.GetIndustrialNames(v.ArticleId)
  952. if err != nil && err.Error() != utils.ErrNoRow() {
  953. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  954. br.ErrMsg = "获取失败,Err:" + err.Error()
  955. return
  956. }
  957. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  958. list[k].SubjectName = subjectNamesNew
  959. if subjectNamesNew != "" {
  960. list[k].IndustryName = industryName + "-" + subjectNamesNew
  961. } else {
  962. list[k].IndustryName = industryName
  963. }
  964. resp.IndustryName = industryName
  965. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  966. }
  967. resp.List = list
  968. resp.Paging = page
  969. br.Ret = 200
  970. br.Success = true
  971. br.Msg = "获取成功"
  972. br.Data = resp
  973. }
  974. // @Title 研选最新主题关键词文章列表接口
  975. // @Description 获取研选最新主题关键词文章列表接口
  976. // @Param PageSize query int true "每页数据条数"
  977. // @Param CurrentIndex query int true "当前页页码,从1开始"
  978. // @Param ArticleId query int true "文章id"
  979. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  980. // @router /industry/reportListNew [get]
  981. func (this *ReportController) ReportListNew() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. user := this.User
  988. if user == nil {
  989. br.Msg = "请重新登录"
  990. br.Ret = 408
  991. return
  992. }
  993. uid := user.UserId
  994. pageSize, _ := this.GetInt("PageSize")
  995. currentIndex, _ := this.GetInt("CurrentIndex")
  996. articleId, _ := this.GetInt("ArticleId")
  997. var condition string
  998. var startSize int
  999. if pageSize <= 0 {
  1000. pageSize = utils.PageSize20
  1001. }
  1002. if currentIndex <= 0 {
  1003. currentIndex = 1
  1004. }
  1005. startSize = paging.StartIndex(currentIndex, pageSize)
  1006. var pars []interface{}
  1007. var total int
  1008. resp := new(models.ReportArticleWhichIndustrialRepList)
  1009. page := paging.GetPaging(currentIndex, pageSize, total)
  1010. userType, _, err := services.GetUserType(user.CompanyId)
  1011. if err != nil {
  1012. br.Msg = "获取信息失败"
  1013. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. if userType == 1 {
  1017. resp.Paging = page
  1018. br.Ret = 200
  1019. br.Success = true
  1020. br.Msg = "获取成功"
  1021. br.Data = resp
  1022. return
  1023. }
  1024. resp.HaveResearch = true
  1025. if articleId > 0 {
  1026. detail, err := models.GetArticleDetailById(articleId)
  1027. if err != nil {
  1028. br.Msg = "获取信息失败"
  1029. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1030. return
  1031. }
  1032. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1033. if firstStr == 0 {
  1034. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1035. } else {
  1036. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1037. }
  1038. }
  1039. total, err = models.GetWhichDepartmentCount(condition)
  1040. if err != nil {
  1041. br.Msg = "获取信息失败"
  1042. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1043. return
  1044. }
  1045. page = paging.GetPaging(currentIndex, pageSize, total)
  1046. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1047. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1048. if err != nil {
  1049. br.Msg = "获取失败"
  1050. br.ErrMsg = "获取失败,Err:" + err.Error()
  1051. return
  1052. }
  1053. for k, v := range list {
  1054. if v.Readnum == 0 {
  1055. list[k].IsRed = true
  1056. }
  1057. list[k].IsResearch = true
  1058. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1059. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1060. if err != nil {
  1061. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1062. br.ErrMsg = "获取失败,Err:" + err.Error()
  1063. return
  1064. }
  1065. var subjectNamesNew string
  1066. if len(subjectNames) > 0 {
  1067. slice := strings.Split(subjectNames, "/")
  1068. for k3, v3 := range slice {
  1069. if k3 < 4 {
  1070. subjectNamesNew += v3 + "/"
  1071. }
  1072. }
  1073. }
  1074. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1075. if err != nil && err.Error() != utils.ErrNoRow() {
  1076. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1077. br.ErrMsg = "获取失败,Err:" + err.Error()
  1078. return
  1079. }
  1080. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1081. list[k].SubjectName = subjectNamesNew
  1082. if subjectNamesNew != "" {
  1083. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1084. } else {
  1085. list[k].IndustryName = industryName
  1086. }
  1087. resp.IndustryName = industryName
  1088. }
  1089. resp.List = list
  1090. resp.Paging = page
  1091. br.Ret = 200
  1092. br.Success = true
  1093. br.Msg = "获取成功"
  1094. br.Data = resp
  1095. }
  1096. // @Title 是否展示绝密内参
  1097. // @Description 获取是否展示绝密内参接口
  1098. // @Param request body models.IsShow true "type json string"
  1099. // @Success 200
  1100. // @router /isShow [get]
  1101. func (this *ReportController) IsShow() {
  1102. br := new(models.BaseResponse).Init()
  1103. defer func() {
  1104. this.Data["json"] = br
  1105. this.ServeJSON()
  1106. }()
  1107. user := this.User
  1108. if user == nil {
  1109. br.Msg = "请重新登录"
  1110. br.Ret = 408
  1111. return
  1112. }
  1113. var resp models.IsShow
  1114. mobile := user.Mobile
  1115. if mobile == "" {
  1116. br.Ret = 200
  1117. br.Success = true
  1118. br.Data = resp
  1119. return
  1120. }
  1121. total, _ := models.GetUserIsAdminCount(mobile)
  1122. if total > 0 {
  1123. resp.IsShow = true
  1124. }
  1125. br.Ret = 200
  1126. br.Success = true
  1127. br.Data = resp
  1128. }
  1129. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1130. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1131. // @Param PageSize query int true "每页数据条数"
  1132. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1133. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1134. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1135. // @router /reportList/byType [get]
  1136. func (this *ReportController) ReportListByType() {
  1137. br := new(models.BaseResponse).Init()
  1138. defer func() {
  1139. this.Data["json"] = br
  1140. this.ServeJSON()
  1141. }()
  1142. user := this.User
  1143. if user == nil {
  1144. br.Msg = "请重新登录"
  1145. br.Ret = 408
  1146. return
  1147. }
  1148. uid := user.UserId
  1149. pageSize, _ := this.GetInt("PageSize")
  1150. currentIndex, _ := this.GetInt("CurrentIndex")
  1151. reportType := this.GetString("ReportType")
  1152. var condition string
  1153. var startSize int
  1154. if pageSize <= 0 {
  1155. pageSize = utils.PageSize20
  1156. }
  1157. if currentIndex <= 0 {
  1158. currentIndex = 1
  1159. }
  1160. startSize = paging.StartIndex(currentIndex, pageSize)
  1161. var pars []interface{}
  1162. var total int
  1163. resp := new(models.CygxReportSelectionListPublicRep)
  1164. page := paging.GetPaging(currentIndex, pageSize, total)
  1165. var tbdb string
  1166. var readSql string
  1167. var reportTypeStr string
  1168. if reportType == "1" {
  1169. tbdb = "cygx_report_selection"
  1170. reportTypeStr = "bgjx"
  1171. } else if reportType == "2" {
  1172. tbdb = "cygx_research_summary"
  1173. reportTypeStr = "bzyjhz"
  1174. } else if reportType == "3" {
  1175. tbdb = "cygx_minutes_summary"
  1176. reportTypeStr = "szjyhz"
  1177. } else {
  1178. br.Msg = "请选择报告类型"
  1179. return
  1180. }
  1181. fmt.Println(tbdb)
  1182. condition = ` AND publish_status = 1`
  1183. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1184. if err != nil {
  1185. br.Msg = "获取信息失败"
  1186. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1187. return
  1188. }
  1189. 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`
  1190. page = paging.GetPaging(currentIndex, pageSize, total)
  1191. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1192. if err != nil {
  1193. br.Msg = "获取失败"
  1194. br.ErrMsg = "获取失败,Err:" + err.Error()
  1195. return
  1196. }
  1197. for k, v := range list {
  1198. if reportType == "1" {
  1199. list[k].Abstract = v.UpdateDescription
  1200. }
  1201. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1202. if v.ReadNum == 0 {
  1203. list[k].IsRed = true
  1204. }
  1205. }
  1206. resp.List = list
  1207. resp.Paging = page
  1208. br.Ret = 200
  1209. br.Success = true
  1210. br.Msg = "获取成功"
  1211. br.Data = resp
  1212. }
  1213. // @Title 获取报告精选详情
  1214. // @Description 获取报告精选详情接口
  1215. // @Param ArticleId query int true "报告ID"
  1216. // @Success 200 {object} models.ReportSelectionLetailResp
  1217. // @router /reportSelection/detail [get]
  1218. func (this *ReportController) Detail() {
  1219. br := new(models.BaseResponse).Init()
  1220. defer func() {
  1221. this.Data["json"] = br
  1222. this.ServeJSON()
  1223. }()
  1224. user := this.User
  1225. if user == nil {
  1226. br.Msg = "请重新登录"
  1227. br.Ret = 408
  1228. return
  1229. }
  1230. uid := user.UserId
  1231. articleId, _ := this.GetInt("ArticleId")
  1232. if articleId < 0 {
  1233. br.Msg = "参数错误"
  1234. br.ErrMsg = "参数错误"
  1235. return
  1236. }
  1237. resp := new(models.ReportSelectionLetailResp)
  1238. //判断用户权限
  1239. hasPermission, err := services.GetUserhasPermission(user)
  1240. if err != nil {
  1241. br.Msg = "获取信息失败"
  1242. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1243. }
  1244. resp.HasPermission = hasPermission
  1245. if hasPermission != 1 {
  1246. br.Ret = 200
  1247. br.Success = true
  1248. br.Msg = "获取成功"
  1249. br.Data = resp
  1250. return
  1251. }
  1252. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1253. if err != nil {
  1254. br.Msg = "获取信息失败"
  1255. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1256. return
  1257. }
  1258. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1259. existMap := make(map[int]int)
  1260. var items []*models.ReportSelectionChartPermission
  1261. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1262. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1263. if err != nil {
  1264. br.Msg = "获取失败"
  1265. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1266. return
  1267. }
  1268. //var itemLogs []*models.CygxReportSelectionLogDetail
  1269. for _, v := range listLog {
  1270. item := new(models.ReportSelectionChartPermission)
  1271. if existMap[v.ChartPermissionId] == 0 {
  1272. item.PermissionName = v.PermissionName + "领域深度调研和报告"
  1273. item.IcoLink = v.IcoLink
  1274. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1275. if err != nil && err.Error() != utils.ErrNoRow() {
  1276. br.Msg = "获取信息失败"
  1277. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1278. return
  1279. }
  1280. for k2, v2 := range listSonLog {
  1281. if v2.IndustrialManagementId != "" {
  1282. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1283. if err != nil && err.Error() != utils.ErrNoRow() {
  1284. br.Msg = "获取信息失败"
  1285. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1286. return
  1287. }
  1288. listSonLog[k2].List = listIndustrial
  1289. }
  1290. }
  1291. item.List = listSonLog
  1292. items = append(items, item)
  1293. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1294. }
  1295. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1296. }
  1297. historyRecord := new(models.CygxReportHistoryRecord)
  1298. historyRecord.UserId = uid
  1299. historyRecord.ArticleId = articleId
  1300. historyRecord.CreateTime = time.Now()
  1301. historyRecord.Mobile = user.Mobile
  1302. historyRecord.Email = user.Email
  1303. historyRecord.CompanyId = user.CompanyId
  1304. historyRecord.CompanyName = user.CompanyName
  1305. historyRecord.ReportType = "bgjx"
  1306. go models.AddCygxReportHistoryRecord(historyRecord)
  1307. resp.List = items
  1308. resp.Detail = detail
  1309. br.Ret = 200
  1310. br.Success = true
  1311. br.Msg = "获取成功"
  1312. br.Data = resp
  1313. }
  1314. // @Title 获取本周研究汇总详情
  1315. // @Description 获取本周研究汇总详情接口
  1316. // @Param ArticleId query int true "报告ID"
  1317. // @Success 200 {object} models.ResearchSummaryLetailResp
  1318. // @router /researchSummary/detail [get]
  1319. func (this *ReportController) ResearchDetail() {
  1320. br := new(models.BaseResponse).Init()
  1321. defer func() {
  1322. this.Data["json"] = br
  1323. this.ServeJSON()
  1324. }()
  1325. user := this.User
  1326. if user == nil {
  1327. br.Msg = "请重新登录"
  1328. br.Ret = 408
  1329. return
  1330. }
  1331. uid := user.UserId
  1332. articleId, _ := this.GetInt("ArticleId")
  1333. if articleId < 0 {
  1334. br.Msg = "参数错误"
  1335. br.ErrMsg = "参数错误"
  1336. return
  1337. }
  1338. resp := new(models.ResearchSummaryLetailResp)
  1339. //判断用户权限
  1340. hasPermission, err := services.GetUserhasPermission(user)
  1341. if err != nil {
  1342. br.Msg = "获取信息失败"
  1343. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1344. }
  1345. resp.HasPermission = hasPermission
  1346. if hasPermission != 1 {
  1347. br.Ret = 200
  1348. br.Success = true
  1349. br.Msg = "获取成功"
  1350. br.Data = resp
  1351. return
  1352. }
  1353. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1354. if err != nil {
  1355. br.Msg = "获取信息失败"
  1356. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1357. return
  1358. }
  1359. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1360. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1361. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1362. if err != nil {
  1363. br.Msg = "获取失败"
  1364. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1365. return
  1366. }
  1367. for k, v := range listFirst {
  1368. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1369. if err != nil && err.Error() != utils.ErrNoRow() {
  1370. br.Msg = "获取信息失败"
  1371. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1372. return
  1373. }
  1374. for k2, v2 := range listSecond {
  1375. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1376. if err != nil && err.Error() != utils.ErrNoRow() {
  1377. br.Msg = "获取信息失败"
  1378. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1379. return
  1380. }
  1381. if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1382. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1383. listSecond[k2].PermissionName = "研选纪要"
  1384. } else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1385. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1386. listSecond[k2].PermissionName = "研选观点"
  1387. }
  1388. if len(listThird) > 0 {
  1389. for k3, v3 := range listThird {
  1390. if v3.VideoUrl != "" {
  1391. listThird[k3].IsHaveVideo = true
  1392. }
  1393. if v3.ReportLink == "0" {
  1394. listThird[k3].ReportLink = ""
  1395. }
  1396. }
  1397. listSecond[k2].List = listThird
  1398. }
  1399. }
  1400. if len(listSecond) > 0 {
  1401. listFirst[k].List = listSecond
  1402. }
  1403. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1404. if v.Type == "SDBG" {
  1405. listFirst[k].ListName = "深度报告"
  1406. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1407. } else if v.Type == "BZCHJH" {
  1408. listFirst[k].ListName = "本周晨会精华"
  1409. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1410. } else if v.Type == "CYDYJY" {
  1411. listFirst[k].ListName = "产业调研纪要"
  1412. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1413. } else if v.Type == "SSGS" {
  1414. listFirst[k].ListName = "上市公司调研纪要篇"
  1415. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1416. } else if v.Type == "SJDP" {
  1417. listFirst[k].ListName = "事件点评"
  1418. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1419. } else if v.Type == "YANX" {
  1420. listFirst[k].ListName = "研选"
  1421. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1422. }
  1423. }
  1424. historyRecord := new(models.CygxReportHistoryRecord)
  1425. historyRecord.UserId = uid
  1426. historyRecord.ArticleId = articleId
  1427. historyRecord.CreateTime = time.Now()
  1428. historyRecord.Mobile = user.Mobile
  1429. historyRecord.Email = user.Email
  1430. historyRecord.CompanyId = user.CompanyId
  1431. historyRecord.CompanyName = user.CompanyName
  1432. historyRecord.ReportType = "bzyjhz"
  1433. go models.AddCygxReportHistoryRecord(historyRecord)
  1434. resp.List = listFirst
  1435. resp.Detail = detail
  1436. br.Ret = 200
  1437. br.Success = true
  1438. br.Msg = "获取成功"
  1439. br.Data = resp
  1440. }
  1441. // @Title 上周纪要汇总内容详情
  1442. // @Description 获取上周纪要汇总内容详情接口
  1443. // @Param ArticleId query int true "报告ID"
  1444. // @Success 200 {object} models.MinutesSummaryLetailResp
  1445. // @router /minutesSummary/detailv4 [get]
  1446. func (this *ReportController) MinutesDetailV4() {
  1447. br := new(models.BaseResponse).Init()
  1448. defer func() {
  1449. this.Data["json"] = br
  1450. this.ServeJSON()
  1451. }()
  1452. user := this.User
  1453. if user == nil {
  1454. br.Msg = "请重新登录"
  1455. br.Ret = 408
  1456. return
  1457. }
  1458. uid := user.UserId
  1459. articleId, _ := this.GetInt("ArticleId")
  1460. if articleId < 0 {
  1461. br.Msg = "参数错误"
  1462. br.ErrMsg = "参数错误"
  1463. return
  1464. }
  1465. resp := new(models.MinutesSummaryLetailRespV4)
  1466. //判断用户权限
  1467. hasPermission, err := services.GetUserhasPermission(user)
  1468. if err != nil {
  1469. br.Msg = "获取信息失败"
  1470. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1471. }
  1472. resp.HasPermission = hasPermission
  1473. if hasPermission != 1 {
  1474. br.Ret = 200
  1475. br.Success = true
  1476. br.Msg = "获取成功"
  1477. br.Data = resp
  1478. return
  1479. }
  1480. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1481. if err != nil {
  1482. br.Msg = "获取信息失败"
  1483. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1484. return
  1485. }
  1486. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1487. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1488. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1489. if err != nil {
  1490. br.Msg = "获取失败"
  1491. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1492. return
  1493. }
  1494. for k, v := range listFirst {
  1495. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1496. if err != nil && err.Error() != utils.ErrNoRow() {
  1497. br.Msg = "获取信息失败"
  1498. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1499. return
  1500. }
  1501. for k2, v2 := range listSecond {
  1502. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1503. if err != nil && err.Error() != utils.ErrNoRow() {
  1504. br.Msg = "获取信息失败"
  1505. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1506. return
  1507. }
  1508. if len(listThird) > 0 {
  1509. for k3, v3 := range listThird {
  1510. if v3.VideoUrl != "" {
  1511. listThird[k3].IsHaveVideo = true
  1512. }
  1513. if v3.ReportLink == "0" {
  1514. listThird[k3].ReportLink = ""
  1515. }
  1516. }
  1517. listSecond[k2].List = listThird
  1518. }
  1519. }
  1520. if len(listSecond) > 0 {
  1521. listFirst[k].List = listSecond
  1522. }
  1523. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1524. if v.Type == "CYDYJY" {
  1525. listFirst[k].ListName = "产业调研纪要"
  1526. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1527. } else if v.Type == "SSGS" {
  1528. listFirst[k].ListName = "上市公司调研纪要篇"
  1529. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1530. } else if v.Type == "YANX" {
  1531. listFirst[k].ListName = "研选纪要"
  1532. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1533. }
  1534. }
  1535. historyRecord := new(models.CygxReportHistoryRecord)
  1536. historyRecord.UserId = uid
  1537. historyRecord.ArticleId = articleId
  1538. historyRecord.CreateTime = time.Now()
  1539. historyRecord.Mobile = user.Mobile
  1540. historyRecord.Email = user.Email
  1541. historyRecord.CompanyId = user.CompanyId
  1542. historyRecord.CompanyName = user.CompanyName
  1543. historyRecord.ReportType = "szjyhz"
  1544. go models.AddCygxReportHistoryRecord(historyRecord)
  1545. resp.List = listFirst
  1546. resp.Detail = detail
  1547. br.Ret = 200
  1548. br.Success = true
  1549. br.Msg = "获取成功"
  1550. br.Data = resp
  1551. }
  1552. // @Title 上周纪要汇总内容详情
  1553. // @Description 获取上周纪要汇总内容详情接口
  1554. // @Param ArticleId query int true "报告ID"
  1555. // @Success 200 {object} models.MinutesSummaryLetailResp
  1556. // @router /minutesSummary/detail [get]
  1557. func (this *ReportController) MinutesDetail() {
  1558. br := new(models.BaseResponse).Init()
  1559. defer func() {
  1560. this.Data["json"] = br
  1561. this.ServeJSON()
  1562. }()
  1563. user := this.User
  1564. if user == nil {
  1565. br.Msg = "请重新登录"
  1566. br.Ret = 408
  1567. return
  1568. }
  1569. uid := user.UserId
  1570. articleId, _ := this.GetInt("ArticleId")
  1571. if articleId < 0 {
  1572. br.Msg = "参数错误"
  1573. br.ErrMsg = "参数错误"
  1574. return
  1575. }
  1576. resp := new(models.MinutesSummaryLetailResp)
  1577. //判断用户权限
  1578. hasPermission, err := services.GetUserhasPermission(user)
  1579. if err != nil {
  1580. br.Msg = "获取信息失败"
  1581. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1582. }
  1583. resp.HasPermission = hasPermission
  1584. if hasPermission != 1 {
  1585. br.Ret = 200
  1586. br.Success = true
  1587. br.Msg = "获取成功"
  1588. br.Data = resp
  1589. return
  1590. }
  1591. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1592. if err != nil {
  1593. br.Msg = "获取信息失败"
  1594. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1595. return
  1596. }
  1597. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1598. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1599. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1600. if err != nil {
  1601. br.Msg = "获取失败"
  1602. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1603. return
  1604. }
  1605. for k, v := range listLog {
  1606. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1607. if err != nil && err.Error() != utils.ErrNoRow() {
  1608. br.Msg = "获取信息失败"
  1609. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1610. return
  1611. }
  1612. if len(listSonLog) > 0 {
  1613. listLog[k].List = listSonLog
  1614. for k2, v2 := range listSonLog {
  1615. if v2.ReportLink == "0" {
  1616. listSonLog[k2].ReportLink = ""
  1617. }
  1618. }
  1619. }
  1620. }
  1621. historyRecord := new(models.CygxReportHistoryRecord)
  1622. historyRecord.UserId = uid
  1623. historyRecord.ArticleId = articleId
  1624. historyRecord.CreateTime = time.Now()
  1625. historyRecord.Mobile = user.Mobile
  1626. historyRecord.Email = user.Email
  1627. historyRecord.CompanyId = user.CompanyId
  1628. historyRecord.CompanyName = user.CompanyName
  1629. historyRecord.ReportType = "szjyhz"
  1630. go models.AddCygxReportHistoryRecord(historyRecord)
  1631. resp.List = listLog
  1632. resp.Detail = detail
  1633. br.Ret = 200
  1634. br.Success = true
  1635. br.Msg = "获取成功"
  1636. br.Data = resp
  1637. }
  1638. // @Title 获取路演精华详情
  1639. // @Description 获取路演精华详情接口
  1640. // @Param ArticleId query int true "报告ID"
  1641. // @Success 200 {object} models.RoadshowDetailResp
  1642. // @router /roadshowEssence/detail [get]
  1643. func (this *ReportController) RoadshowDetail() {
  1644. br := new(models.BaseResponse).Init()
  1645. defer func() {
  1646. this.Data["json"] = br
  1647. this.ServeJSON()
  1648. }()
  1649. user := this.User
  1650. if user == nil {
  1651. br.Msg = "请登录"
  1652. br.ErrMsg = "请登录,用户信息为空"
  1653. br.Ret = 408
  1654. return
  1655. }
  1656. uid := user.UserId
  1657. articleId, err := this.GetInt("ArticleId")
  1658. if articleId <= 0 {
  1659. br.Msg = "文章不存在"
  1660. br.ErrMsg = "文章不存在,文章ID错误"
  1661. return
  1662. }
  1663. detail := new(models.ReportDetailRoadshow)
  1664. hasPermission := 0
  1665. hasFree := 0
  1666. //判断是否已经申请过
  1667. applyCount, err := models.GetApplyRecordCount(uid)
  1668. if err != nil && err.Error() != utils.ErrNoRow() {
  1669. br.Msg = "获取信息失败"
  1670. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1671. return
  1672. }
  1673. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1674. if user.CompanyId > 1 {
  1675. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1676. if err != nil {
  1677. br.Msg = "获取信息失败"
  1678. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1679. return
  1680. }
  1681. detail, err = models.GetReportRoadshowDetailById(articleId)
  1682. if err != nil {
  1683. br.Msg = "获取信息失败"
  1684. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1685. return
  1686. }
  1687. detail.Body = html.UnescapeString(detail.Body)
  1688. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1689. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1690. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1691. if detail.ReportLink == "0" {
  1692. detail.ReportLink = ""
  1693. }
  1694. if companyPermission == "" {
  1695. if applyCount > 0 {
  1696. hasPermission = 5
  1697. } else {
  1698. hasPermission = 2
  1699. }
  1700. hasFree = 2
  1701. goto Loop
  1702. } else {
  1703. hasFree = 1
  1704. var articlePermissionPermissionName string
  1705. articlePermissionPermissionName = detail.CategoryName
  1706. var hasPersion bool
  1707. slice := strings.Split(articlePermissionPermissionName, ",")
  1708. for _, v := range slice {
  1709. if strings.Contains(companyPermission, v) {
  1710. hasPersion = true
  1711. }
  1712. }
  1713. if hasPersion {
  1714. hasPermission = 1
  1715. historyRecord := new(models.CygxArticleHistoryRecord)
  1716. historyRecord.UserId = uid
  1717. historyRecord.ArticleId = articleId
  1718. historyRecord.CreateTime = time.Now()
  1719. historyRecord.Mobile = user.Mobile
  1720. historyRecord.Email = user.Email
  1721. historyRecord.CompanyId = user.CompanyId
  1722. historyRecord.CompanyName = user.CompanyName
  1723. go models.AddCygxArticleHistoryRecord(historyRecord)
  1724. } else { //无该行业权限
  1725. hasPermission = 3
  1726. }
  1727. if hasPermission == 1 {
  1728. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1729. if !utils.Rc.IsExist(key) {
  1730. //新增浏览记录
  1731. record := new(models.CygxArticleViewRecord)
  1732. record.UserId = uid
  1733. record.ArticleId = articleId
  1734. record.CreateTime = time.Now()
  1735. record.Mobile = user.Mobile
  1736. record.Email = user.Email
  1737. record.CompanyId = user.CompanyId
  1738. record.CompanyName = user.CompanyName
  1739. go models.AddCygxArticleViewRecord(record)
  1740. utils.Rc.Put(key, 1, 5*time.Second)
  1741. models.ModifyReportLastViewTime(uid)
  1742. }
  1743. }
  1744. }
  1745. } else { //潜在客户
  1746. if applyCount > 0 {
  1747. hasPermission = 5
  1748. } else {
  1749. hasPermission = 4
  1750. }
  1751. }
  1752. Loop:
  1753. if hasPermission != 1 {
  1754. detail.Body = ""
  1755. detail.Abstract = ""
  1756. }
  1757. resp := new(models.RoadshowDetailResp)
  1758. resp.HasPermission = hasPermission
  1759. resp.HasFree = hasFree
  1760. resp.Detail = detail
  1761. br.Ret = 200
  1762. br.Success = true
  1763. br.Msg = "获取成功"
  1764. br.Data = resp
  1765. }
  1766. // @Title 产业文章列表接口
  1767. // @Description 获取产业文章列表接口
  1768. // @Param KeyWord query string true "搜索关键词"
  1769. // @Success 200 {object} models.CygxIndustrySearchList
  1770. // @router /industryAndArticle/list [get]
  1771. func (this *ReportController) IndustryAndArticleList() {
  1772. br := new(models.BaseResponse).Init()
  1773. defer func() {
  1774. this.Data["json"] = br
  1775. this.ServeJSON()
  1776. }()
  1777. user := this.User
  1778. if user == nil {
  1779. br.Msg = "请重新登录"
  1780. br.Ret = 408
  1781. return
  1782. }
  1783. uid := user.UserId
  1784. keyWord := this.GetString("KeyWord")
  1785. orderSrt := "update_time DESC"
  1786. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1787. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1788. if err != nil {
  1789. br.Msg = "获取信息失败"
  1790. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1791. return
  1792. }
  1793. for k, v := range list {
  1794. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1795. if err != nil {
  1796. br.Msg = "获取信息失败"
  1797. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1798. return
  1799. }
  1800. list[k].IndustrialSubjectList = industrialSubjectList
  1801. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1802. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1803. if err != nil {
  1804. br.Msg = "获取信息失败"
  1805. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1806. return
  1807. }
  1808. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1809. }
  1810. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1811. if err != nil {
  1812. br.Msg = "获取失败"
  1813. br.ErrMsg = "获取失败,Err:" + err.Error()
  1814. return
  1815. }
  1816. for k2, v2 := range artList {
  1817. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1818. if err != nil {
  1819. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1820. br.ErrMsg = "获取失败,Err:" + err.Error()
  1821. return
  1822. }
  1823. var subjectNamesNew string
  1824. if len(subjectNames) > 0 {
  1825. slice := strings.Split(subjectNames, "/")
  1826. for k3, v3 := range slice {
  1827. if k3 < 4 {
  1828. subjectNamesNew += v3 + "/"
  1829. }
  1830. }
  1831. }
  1832. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1833. if err != nil && err.Error() != utils.ErrNoRow() {
  1834. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1835. br.ErrMsg = "获取失败,Err:" + err.Error()
  1836. return
  1837. }
  1838. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1839. artList[k2].SubjectName = subjectNamesNew
  1840. if subjectNamesNew == "" {
  1841. artList[k2].IndustryName = industryName
  1842. } else {
  1843. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1844. }
  1845. }
  1846. if keyWord != "" {
  1847. keyWordItem := new(models.CygxUserSearchKeyWord)
  1848. keyWordItem.UserId = user.UserId
  1849. keyWordItem.KeyWord = keyWord
  1850. keyWordItem.PageType = "ReortSearch"
  1851. keyWordItem.CreateTime = time.Now()
  1852. go models.AddUserSearchKeyWord(keyWordItem)
  1853. }
  1854. resp := new(models.CygxIndustrySearchList)
  1855. resp.ArtList = artList
  1856. resp.IndList = list
  1857. br.Ret = 200
  1858. br.Success = true
  1859. br.Msg = "获取成功"
  1860. br.Data = resp
  1861. }
  1862. // @Title 产业报告分类关联作者列表接口Pc端
  1863. // @Description 获取产业报告分类关联作者列表接口Pc端
  1864. // @Param ChartPermissionId query int true "分类ID"
  1865. // @Param KeyWord query string true "搜索关键词"
  1866. // @Param PageSize query int true "每页数据条数"
  1867. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1868. // @Success 200 {object} models.CygxArticleDepartmentListPc
  1869. // @router /industryListByDepartmentPc [get]
  1870. func (this *ReportController) IndustryListByDepartmentPc() {
  1871. br := new(models.BaseResponse).Init()
  1872. defer func() {
  1873. this.Data["json"] = br
  1874. this.ServeJSON()
  1875. }()
  1876. user := this.User
  1877. if user == nil {
  1878. br.Msg = "请重新登录"
  1879. br.Ret = 408
  1880. return
  1881. }
  1882. uid := user.UserId
  1883. pageSize, _ := this.GetInt("PageSize")
  1884. currentIndex, _ := this.GetInt("CurrentIndex")
  1885. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1886. keyWord := this.GetString("KeyWord")
  1887. var startSize int
  1888. var condition string
  1889. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  1890. if pageSize <= 0 {
  1891. pageSize = utils.PageSize20
  1892. }
  1893. if currentIndex <= 0 {
  1894. currentIndex = 1
  1895. }
  1896. var articleIdGroup string
  1897. if keyWord != "" {
  1898. //获取标的关联的文章ID
  1899. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  1900. if err != nil {
  1901. br.Msg = "获取信息失败"
  1902. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  1903. return
  1904. }
  1905. //获取产业关联的标的
  1906. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  1907. if err != nil {
  1908. br.Msg = "获取信息失败"
  1909. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  1910. return
  1911. }
  1912. if articleIdSub != "" && articleIdInd != "" {
  1913. articleIdGroup = articleIdSub + "," + articleIdInd
  1914. } else if articleIdSub != "" && articleIdInd == "" {
  1915. articleIdGroup = articleIdSub
  1916. } else if articleIdSub == "" && articleIdInd != "" {
  1917. articleIdGroup = articleIdInd
  1918. }
  1919. slice := strings.Split(keyWord, "/")
  1920. if len(slice) > 1 {
  1921. var subjectIds string
  1922. for _, v := range slice {
  1923. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  1924. if err != nil && err.Error() != utils.ErrNoRow() {
  1925. br.Msg = "获取信息失败"
  1926. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1927. return
  1928. }
  1929. if subjectId != "" {
  1930. subjectIds += subjectId + ","
  1931. }
  1932. }
  1933. subjectIds = strings.TrimRight(subjectIds, ",")
  1934. if len(subjectIds) > 0 {
  1935. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  1936. if err != nil {
  1937. br.Msg = "获取信息失败"
  1938. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  1939. return
  1940. }
  1941. if articleIdGroup != "" {
  1942. if articleBySub != "" {
  1943. articleIdGroup += "," + articleBySub
  1944. }
  1945. } else {
  1946. articleIdGroup = articleBySub
  1947. }
  1948. }
  1949. }
  1950. }
  1951. if articleIdGroup != "" {
  1952. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  1953. }
  1954. startSize = paging.StartIndex(currentIndex, pageSize)
  1955. total, err := models.GetArticleDepartmentCount(condition)
  1956. page := paging.GetPaging(currentIndex, pageSize, total)
  1957. resp := new(models.CygxArticleDepartmentListPc)
  1958. userType, _, err := services.GetUserType(user.CompanyId)
  1959. if err != nil {
  1960. br.Msg = "获取信息失败"
  1961. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1962. return
  1963. }
  1964. if userType == 1 {
  1965. resp.Paging = page
  1966. br.Ret = 200
  1967. br.Success = true
  1968. br.Msg = "获取成功"
  1969. br.Data = resp
  1970. return
  1971. }
  1972. resp.HaveResearch = true
  1973. //获取作者信息,并排序
  1974. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  1975. if err != nil {
  1976. br.Msg = "获取信息失败"
  1977. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1978. return
  1979. }
  1980. for k, v := range list {
  1981. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  1982. if err != nil {
  1983. br.Msg = "获取信息失败"
  1984. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  1985. return
  1986. }
  1987. for k2, v2 := range artList {
  1988. if artList[k2].IsReport == "1" {
  1989. artList[k2].Title = v2.Title
  1990. } else {
  1991. artList[k2].Title = v2.Title
  1992. }
  1993. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  1994. }
  1995. list[k].List = artList
  1996. if v.FollowNum > 0 {
  1997. list[k].IsMyFollow = true
  1998. }
  1999. }
  2000. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2001. if err != nil {
  2002. br.Msg = "获取信息失败"
  2003. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2004. return
  2005. }
  2006. if len(listnNew) > 0 {
  2007. for _, v := range listnNew {
  2008. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2009. Management := new(models.IndustrialManagementIdInt)
  2010. if firstStr == 0 {
  2011. Management.IndustryName = v.IndustryName
  2012. } else {
  2013. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2014. if err != nil {
  2015. br.Msg = "获取信息失败"
  2016. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2017. return
  2018. }
  2019. var subjectNamesNew string
  2020. for _, v1 := range listSub {
  2021. subjectNamesNew += v1.SubjectName + "/"
  2022. }
  2023. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2024. Management.IndustryName = subjectNamesNew
  2025. }
  2026. Management.IndustrialManagementId = v.IndustrialManagementId
  2027. Management.ArticleId = v.ArticleId
  2028. resp.ListnNew = append(resp.ListnNew, Management)
  2029. }
  2030. }
  2031. resp.List = list
  2032. resp.Paging = page
  2033. br.Ret = 200
  2034. br.Success = true
  2035. br.Msg = "获取成功"
  2036. br.Data = resp
  2037. }
  2038. // @Title 产业文章列表接口Pc端
  2039. // @Description 获取产业文章列表接口Pc端
  2040. // @Param KeyWord query string true "搜索关键词"
  2041. // @Success 200 {object} models.CygxIndustrySearchListPc
  2042. // @router /industryAndArticle/listPc [get]
  2043. func (this *ReportController) IndustryAndArticleListPc() {
  2044. br := new(models.BaseResponse).Init()
  2045. defer func() {
  2046. this.Data["json"] = br
  2047. this.ServeJSON()
  2048. }()
  2049. user := this.User
  2050. if user == nil {
  2051. br.Msg = "请重新登录"
  2052. br.Ret = 408
  2053. return
  2054. }
  2055. uid := user.UserId
  2056. keyWord := this.GetString("KeyWord")
  2057. resp := new(models.CygxIndustrySearchListPc)
  2058. orderSrt := "update_time DESC"
  2059. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2060. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2061. if err != nil {
  2062. br.Msg = "获取信息失败"
  2063. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2064. return
  2065. }
  2066. for k, v := range list {
  2067. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2068. if err != nil {
  2069. br.Msg = "获取信息失败"
  2070. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2071. return
  2072. }
  2073. list[k].IndustrialSubjectList = industrialSubjectList
  2074. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2075. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2076. if err != nil {
  2077. br.Msg = "获取信息失败"
  2078. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2079. return
  2080. }
  2081. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2082. }
  2083. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2084. if err != nil {
  2085. br.Msg = "获取失败"
  2086. br.ErrMsg = "获取失败,Err:" + err.Error()
  2087. return
  2088. }
  2089. if len(artList) > 0 {
  2090. var articleIds string
  2091. for _, v := range artList {
  2092. articleIds += strconv.Itoa(v.ArticleId) + ","
  2093. }
  2094. articleIds = strings.TrimRight(articleIds, ",")
  2095. if articleIds != "" {
  2096. condition = ` AND a.article_id IN (` + articleIds + `)`
  2097. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2098. if err != nil {
  2099. br.Msg = "获取信息失败"
  2100. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2101. return
  2102. }
  2103. for k, v := range DepartmentList {
  2104. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2105. if err != nil {
  2106. br.Msg = "获取信息失败"
  2107. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2108. return
  2109. }
  2110. for k2, v2 := range artList {
  2111. if artList[k2].IsReport == "1" {
  2112. artList[k2].Title = v2.Title
  2113. } else {
  2114. artList[k2].Title = v2.Title
  2115. }
  2116. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2117. }
  2118. DepartmentList[k].List = artList
  2119. if v.FollowNum > 0 {
  2120. DepartmentList[k].IsMyFollow = true
  2121. }
  2122. }
  2123. resp.DepartmentList = DepartmentList
  2124. }
  2125. }
  2126. if keyWord != "" {
  2127. keyWordItem := new(models.CygxUserSearchKeyWord)
  2128. keyWordItem.UserId = user.UserId
  2129. keyWordItem.KeyWord = keyWord
  2130. keyWordItem.PageType = "ReortSearch"
  2131. keyWordItem.CreateTime = time.Now()
  2132. go models.AddUserSearchKeyWord(keyWordItem)
  2133. }
  2134. resp.IndList = list
  2135. br.Ret = 200
  2136. br.Success = true
  2137. br.Msg = "获取成功"
  2138. br.Data = resp
  2139. }