report.go 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512
  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 DeepCover query int false "深度覆盖:0-否;1-是"
  77. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  78. // @Param PageSize query int true "每页数据条数"
  79. // @Param CurrentIndex query int true "当前页页码,从1开始"
  80. // @Success 200 {object} models.IndustrialManagementList
  81. // @router /home/industryList [get]
  82. func (this *ReportController) IndustryList() {
  83. br := new(models.BaseResponse).Init()
  84. defer func() {
  85. this.Data["json"] = br
  86. this.ServeJSON()
  87. }()
  88. user := this.User
  89. if user == nil {
  90. br.Msg = "请重新登录"
  91. br.Ret = 408
  92. return
  93. }
  94. uid := user.UserId
  95. fmt.Println(uid)
  96. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  97. orderColumn := this.GetString("OrderColumn")
  98. orderColumnNew := this.GetString("OrderColumn")
  99. isNewLabel := this.GetString("IsNewLabel")
  100. isDeepLabel := this.GetString("IsDeepLabel")
  101. keyWord := this.GetString("KeyWord")
  102. pageSize, _ := this.GetInt("PageSize")
  103. currentIndex, _ := this.GetInt("CurrentIndex")
  104. deepCover, _ := this.GetInt("DeepCover")
  105. recommendFocus, _ := this.GetInt("RecommendFocus")
  106. var orderSrt string
  107. var condition string
  108. var startSize int
  109. resp := new(models.IndustrialManagementList)
  110. if pageSize <= 0 {
  111. pageSize = utils.PageSize20
  112. }
  113. if currentIndex <= 0 {
  114. currentIndex = 1
  115. }
  116. startSize = paging.StartIndex(currentIndex, pageSize)
  117. if isNewLabel == "1" {
  118. condition += ` AND is_new_label = ` + isNewLabel
  119. }
  120. if isDeepLabel == "1" {
  121. condition += ` AND is_deep_label = ` + isDeepLabel
  122. }
  123. if keyWord != "" {
  124. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  125. //if err != nil {
  126. // br.Msg = "获取信息失败"
  127. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  128. // return
  129. //}
  130. //var conditionkeyWord string
  131. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  132. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  133. //keyWordLen := len(keyWordArr)
  134. //if keyWordLen <= 0 {
  135. // keyWordArr = append(keyWordArr, keyWord)
  136. // keyWordLen = len(keyWordArr)
  137. //}
  138. //for _, v := range keyWordArr {
  139. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  140. //}
  141. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  142. //if err != nil {
  143. // br.Msg = "获取信息失败"
  144. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  145. // return
  146. //}
  147. //if industrialManagementIds == "" {
  148. // br.Ret = 200
  149. // br.Success = true
  150. // br.Msg = "获取成功"
  151. // br.Data = resp
  152. // return
  153. //}
  154. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  155. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  156. }
  157. var sqlChartPermissionId string
  158. if ChartPermissionId > 0 {
  159. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  160. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  161. }
  162. // 深度覆盖
  163. if deepCover == 1 {
  164. // 查询深标签产业报告数
  165. var deepCondition string
  166. var deepPars []interface{}
  167. deepCondition += ` AND man.is_deep_label = 1`
  168. if ChartPermissionId > 0 {
  169. deepCondition += ` AND man.chart_permission_id = ?`
  170. deepPars = append(deepPars, ChartPermissionId)
  171. }
  172. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  173. if e != nil {
  174. br.Msg = "获取信息失败"
  175. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  176. return
  177. }
  178. deepIdArr := make([]string, 0)
  179. for i := range industryCountList {
  180. if industryCountList[i].ArtNum > 10 {
  181. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  182. }
  183. }
  184. deepIds := strings.Join(deepIdArr, ",")
  185. if deepIds != "" {
  186. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  187. }
  188. }
  189. // 推荐关注
  190. if recommendFocus == 1 {
  191. condition += ` AND man.recommended_index >= 50`
  192. }
  193. // 列表总数据量
  194. var list []*models.IndustrialManagement
  195. total, err := models.GetIndustrialManagementAllCount(condition)
  196. if err != nil {
  197. br.Msg = "获取信息失败"
  198. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  199. return
  200. }
  201. page := paging.GetPaging(currentIndex, pageSize, total)
  202. if orderColumn == "" {
  203. orderColumn = "NewTime"
  204. }
  205. if orderColumn == "NewTime" {
  206. orderSrt = "update_time DESC"
  207. } else {
  208. orderSrt = "man.recommended_index DESC,update_time DESC"
  209. }
  210. if ChartPermissionId == 0 {
  211. ChartPermissionId = 20
  212. }
  213. // 阅读第三的产业详情
  214. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  215. //if err != nil {
  216. // br.Msg = "获取信息失败"
  217. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  218. // return
  219. //}
  220. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  221. if err != nil {
  222. br.Msg = "获取信息失败"
  223. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  224. return
  225. }
  226. // 获取近一个月产业报告阅读次数最多的产业
  227. var topCond string
  228. var topPars []interface{}
  229. topReadIndustryId := 0
  230. if ChartPermissionId > 0 {
  231. topCond += ` AND chart_permission_id = ?`
  232. topPars = append(topPars, ChartPermissionId)
  233. }
  234. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  235. if e != nil && e.Error() != utils.ErrNoRow() {
  236. br.Msg = "获取信息失败"
  237. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  238. return
  239. }
  240. if topReadIndustry != nil {
  241. topReadIndustryId = topReadIndustry.IndustrialManagementId
  242. }
  243. nowTime := time.Now().Local()
  244. threeMonBefore := nowTime.AddDate(0, -3, 0)
  245. for k, v := range list {
  246. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  247. if err != nil {
  248. br.Msg = "获取信息失败"
  249. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  250. return
  251. }
  252. list[k].IndustrialSubjectList = industrialSubjectList
  253. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  254. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  255. if err != nil {
  256. br.Msg = "获取信息失败"
  257. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  258. return
  259. }
  260. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  261. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  262. if err != nil && err.Error() != utils.ErrNoRow() {
  263. br.Msg = "获取信息失败"
  264. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  265. return
  266. }
  267. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  268. list[k].IsRed = true
  269. }
  270. // 原:关联的报告阅读量大于等于阅读第三的产业,则标记热门
  271. //if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  272. // list[k].IsHot = true
  273. //}
  274. // 近一个月报告阅读次数最多的产业标记Hot
  275. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  276. list[k].IsHot = true
  277. }
  278. // 关联报告发布时间均在3个月内则标记New
  279. if v.MinReportTime != "" {
  280. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  281. if e != nil {
  282. br.Msg = "获取信息失败"
  283. br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
  284. return
  285. }
  286. if t.After(threeMonBefore) {
  287. list[k].IsNew = true
  288. }
  289. }
  290. }
  291. //记录用户搜索的筛选条件
  292. if orderColumnNew != "" {
  293. item := new(models.CygxReportIndustrialSeaarchHistory)
  294. item.UserId = user.UserId
  295. item.Mobile = user.Mobile
  296. item.CompanyId = user.CompanyId
  297. item.CompanyName = user.CompanyName
  298. item.CreateTime = time.Now()
  299. item.IsDeepLabel = isDeepLabel
  300. item.IsNewLabel = isNewLabel
  301. item.ChartPermissionId = ChartPermissionId
  302. if orderColumnNew == "NewTime" {
  303. item.OrderColumn = "0"
  304. } else {
  305. item.OrderColumn = "1"
  306. }
  307. go models.AddCygxReportIndustrialSeaarchHistory(item)
  308. }
  309. resp.List = list
  310. resp.Paging = page
  311. br.Ret = 200
  312. br.Success = true
  313. br.Msg = "获取成功"
  314. br.Data = resp
  315. }
  316. // @Title 产业下所关联的文章分类列表
  317. // @Description 产业下所关联的文章分类列表接口
  318. // @Param IndustrialManagementId query int true "产业ID"
  319. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  320. // @router /toArticleCategoryList [get]
  321. func (this *ReportController) ArticleCategoryList() {
  322. br := new(models.BaseResponse).Init()
  323. defer func() {
  324. this.Data["json"] = br
  325. this.ServeJSON()
  326. }()
  327. user := this.User
  328. if user == nil {
  329. br.Msg = "请重新登录"
  330. br.Ret = 408
  331. return
  332. }
  333. uid := user.UserId
  334. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  335. if industrialManagementId < 1 {
  336. br.Msg = "请输入分类ID"
  337. return
  338. }
  339. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  340. if err != nil {
  341. br.Msg = "获取信息失败"
  342. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  343. return
  344. }
  345. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  346. if err != nil {
  347. br.Msg = "获取信息失败"
  348. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  349. return
  350. }
  351. for k, v := range list {
  352. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  353. if err != nil && err.Error() != utils.ErrNoRow() {
  354. br.Msg = "获取信息失败"
  355. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  356. return
  357. }
  358. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  359. if err != nil {
  360. br.Msg = "获取信息失败"
  361. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  362. return
  363. }
  364. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  365. list[k].IsRed = true
  366. }
  367. }
  368. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  369. //if err != nil {
  370. // br.Msg = "获取信息失败"
  371. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  372. // return
  373. //}
  374. resp := new(models.IndustrialToArticleCategoryListRep)
  375. resp.List = list
  376. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  377. resp.IndustryName = detail.IndustryName
  378. resp.IndustrialManagementId = industrialManagementId
  379. br.Ret = 200
  380. br.Success = true
  381. br.Msg = "获取成功"
  382. br.Data = resp
  383. }
  384. // @Title 产业文章列表接口
  385. // @Description 获取产业文章列表接口
  386. // @Param PageSize query int true "每页数据条数"
  387. // @Param CurrentIndex query int true "当前页页码,从1开始"
  388. // @Param CategoryId query int true "分类ID"
  389. // @Param IndustrialManagementId query int true "产业ID"
  390. // @Success 200 {object} models.TacticsListResp
  391. // @router /industry/ArticleList [get]
  392. func (this *ReportController) List() {
  393. br := new(models.BaseResponse).Init()
  394. defer func() {
  395. this.Data["json"] = br
  396. this.ServeJSON()
  397. }()
  398. user := this.User
  399. if user == nil {
  400. br.Msg = "请重新登录"
  401. br.Ret = 408
  402. return
  403. }
  404. uid := user.UserId
  405. pageSize, _ := this.GetInt("PageSize")
  406. currentIndex, _ := this.GetInt("CurrentIndex")
  407. categoryId, _ := this.GetInt("CategoryId")
  408. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  409. var startSize int
  410. if pageSize <= 0 {
  411. pageSize = utils.PageSize20
  412. }
  413. if currentIndex <= 0 {
  414. currentIndex = 1
  415. }
  416. startSize = paging.StartIndex(currentIndex, pageSize)
  417. var pars []interface{}
  418. var total int
  419. resp := new(models.TacticsListResp)
  420. page := paging.GetPaging(currentIndex, pageSize, total)
  421. if categoryId < 1 {
  422. br.Msg = "请输入分类ID"
  423. return
  424. }
  425. if industrialManagementId < 1 {
  426. br.Msg = "请输入产业ID"
  427. return
  428. }
  429. //获取该产业下所对应的行业图片
  430. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  431. if errCategory != nil {
  432. br.Msg = "获取信息失败"
  433. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  434. return
  435. }
  436. //对应行业的图片
  437. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  438. if err != nil {
  439. br.Msg = "获取数据失败"
  440. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  441. return
  442. }
  443. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  444. mapChartPermission := make(map[string]string)
  445. var permissionName string
  446. var imgUrlChartPermission string
  447. for _, v := range chartPermissionUrlList {
  448. vslice := strings.Split(v, "_")
  449. permissionName = vslice[0]
  450. imgUrlChartPermission = vslice[len(vslice)-1]
  451. mapChartPermission[permissionName] = imgUrlChartPermission
  452. }
  453. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  454. if err != nil {
  455. br.Msg = "获取信息失败"
  456. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  457. return
  458. }
  459. page = paging.GetPaging(currentIndex, pageSize, total)
  460. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  461. if err != nil {
  462. br.Msg = "获取信息失败"
  463. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  464. return
  465. }
  466. //对应分类的所图片
  467. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  468. if err != nil {
  469. br.Msg = "获取数据失败"
  470. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  471. return
  472. }
  473. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  474. mapCategoryUrl := make(map[string]string)
  475. var categoryIdStr string
  476. var imgUrlChart string
  477. for _, v := range categoryUrlList {
  478. vslice := strings.Split(v, "_")
  479. categoryIdStr = vslice[0]
  480. imgUrlChart = vslice[len(vslice)-1]
  481. mapCategoryUrl[categoryIdStr] = imgUrlChart
  482. }
  483. lenList := len(list)
  484. for i := 0; i < lenList; i++ {
  485. item := list[i]
  486. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  487. //list[i].Abstract = html.UnescapeString(item.Abstract)
  488. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  489. list[i].Annotation = services.GetAnnotationTextSub(item.Annotation)
  490. }
  491. for k, v := range list {
  492. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  493. list[k].IsRed = true
  494. }
  495. if v.VideoUrl != "" {
  496. list[k].IsHaveVideo = true
  497. }
  498. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  499. if mapCategoryUrl[v.CategoryId] == "" {
  500. if detail.ChartPermissionId == utils.YI_YAO_ID {
  501. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  502. }
  503. }
  504. }
  505. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  506. resp.List = list
  507. resp.Paging = page
  508. br.Ret = 200
  509. br.Success = true
  510. br.Msg = "获取成功"
  511. br.Data = resp
  512. }
  513. // @Title 置顶/取消置顶
  514. // @Description 置顶
  515. // @Param request body models.CygxIndustryTopRep true "type json string"
  516. // @Success 200
  517. // @router /top [post]
  518. func (this *ReportController) ArticleCollect() {
  519. br := new(models.BaseResponse).Init()
  520. defer func() {
  521. this.Data["json"] = br
  522. this.ServeJSON()
  523. }()
  524. user := this.User
  525. if user == nil {
  526. br.Msg = "请重新登录"
  527. br.Ret = 408
  528. return
  529. }
  530. uid := user.UserId
  531. var req models.CygxIndustryTopRep
  532. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  533. if err != nil {
  534. br.Msg = "参数解析异常!"
  535. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  536. return
  537. }
  538. industrialManagementId := req.IndustrialManagementId
  539. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  540. if err != nil {
  541. br.Msg = "获取数据失败!"
  542. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  543. return
  544. }
  545. if countIndustrial == 0 {
  546. br.Msg = "产业不存在!"
  547. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  548. return
  549. }
  550. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  551. if err != nil {
  552. br.Msg = "获取数据失败!"
  553. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  554. return
  555. }
  556. resp := new(models.ArticleCollectResp)
  557. if count <= 0 {
  558. item := new(models.CygxIndustryTop)
  559. item.IndustrialManagementId = req.IndustrialManagementId
  560. item.UserId = uid
  561. item.CreateTime = time.Now()
  562. _, err = models.AddCygxIndustryTop(item)
  563. if err != nil {
  564. br.Msg = "置顶失败"
  565. br.ErrMsg = "置顶失败,Err:" + err.Error()
  566. return
  567. }
  568. br.Msg = "置顶成功"
  569. resp.Status = 1
  570. } else {
  571. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  572. if err != nil {
  573. br.Msg = "取消置顶失败"
  574. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  575. return
  576. }
  577. br.Msg = "已取消置顶"
  578. resp.Status = 2
  579. }
  580. br.Ret = 200
  581. br.Success = true
  582. br.Data = resp
  583. }
  584. // @Title 关注/取消关注产业
  585. // @Description 关注/取消关注 接口
  586. // @Param request body models.CygxIndustryFllowRep true "type json string"
  587. // @Success 200
  588. // @router /fllow [post]
  589. func (this *ReportController) Fllow() {
  590. br := new(models.BaseResponse).Init()
  591. defer func() {
  592. this.Data["json"] = br
  593. this.ServeJSON()
  594. }()
  595. user := this.User
  596. if user == nil {
  597. br.Msg = "请重新登录"
  598. br.Ret = 408
  599. return
  600. }
  601. uid := user.UserId
  602. var req models.CygxIndustryFllowRep
  603. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  604. if err != nil {
  605. br.Msg = "参数解析异常!"
  606. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  607. return
  608. }
  609. industrialManagementId := req.IndustrialManagementId
  610. var condition string
  611. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  612. if err != nil {
  613. br.Msg = "获取数据失败!"
  614. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  615. return
  616. }
  617. if countIndustrial == 0 {
  618. br.Msg = "产业不存在!"
  619. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  620. return
  621. }
  622. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  623. if err != nil {
  624. br.Msg = "获取数据失败!"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. resp := new(models.CygxIndustryFllowResp)
  629. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  630. if countUser == 0 {
  631. resp.GoFollow = true
  632. }
  633. if count == 0 {
  634. item := new(models.CygxIndustryFllow)
  635. item.IndustrialManagementId = industrialManagementId
  636. item.UserId = uid
  637. item.Email = user.Email
  638. item.Mobile = user.Mobile
  639. item.RealName = user.RealName
  640. item.CompanyId = user.CompanyId
  641. item.CompanyName = user.CompanyName
  642. item.Type = 1
  643. item.CreateTime = time.Now()
  644. item.ModifyTime = time.Now()
  645. _, err = models.AddCygxIndustryFllow(item)
  646. if err != nil {
  647. br.Msg = "操作失败"
  648. br.ErrMsg = "操作失败,Err:" + err.Error()
  649. return
  650. }
  651. resp.Status = 1
  652. } else {
  653. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  654. if err != nil {
  655. br.Msg = "操作失败"
  656. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  657. return
  658. }
  659. }
  660. //处理是否关注全部赛道字段
  661. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  662. br.Msg = "操作成功"
  663. br.Ret = 200
  664. br.Success = true
  665. br.Data = resp
  666. }
  667. // @Title 产业报告分类关联作者列表接口
  668. // @Description 获取产业报告分类关联作者列表接口
  669. // @Param ChartPermissionId query int true "分类ID"
  670. // @Param PageSize query int true "每页数据条数"
  671. // @Param CurrentIndex query int true "当前页页码,从1开始"
  672. // @Success 200 {object} models.CygxArticleDepartmentList
  673. // @router /industryListByDepartment [get]
  674. func (this *ReportController) IndustryListByDepartment() {
  675. br := new(models.BaseResponse).Init()
  676. defer func() {
  677. this.Data["json"] = br
  678. this.ServeJSON()
  679. }()
  680. user := this.User
  681. if user == nil {
  682. br.Msg = "请重新登录"
  683. br.Ret = 408
  684. return
  685. }
  686. uid := user.UserId
  687. pageSize, _ := this.GetInt("PageSize")
  688. currentIndex, _ := this.GetInt("CurrentIndex")
  689. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  690. var startSize int
  691. var condition string
  692. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  693. condition = ` AND a.publish_status=1 `
  694. if pageSize <= 0 {
  695. pageSize = utils.PageSize20
  696. }
  697. if currentIndex <= 0 {
  698. currentIndex = 1
  699. }
  700. startSize = paging.StartIndex(currentIndex, pageSize)
  701. total, err := models.GetArticleDepartmentCount(condition)
  702. page := paging.GetPaging(currentIndex, pageSize, total)
  703. resp := new(models.CygxArticleDepartmentList)
  704. userType, _, err := services.GetUserType(user.CompanyId)
  705. if err != nil {
  706. br.Msg = "获取信息失败"
  707. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  708. return
  709. }
  710. if userType == 1 {
  711. resp.Paging = page
  712. br.Ret = 200
  713. br.Success = true
  714. br.Msg = "获取成功"
  715. br.Data = resp
  716. return
  717. }
  718. resp.HaveResearch = true
  719. //获取作者信息,并排序
  720. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  721. if err != nil {
  722. br.Msg = "获取信息失败"
  723. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  724. return
  725. }
  726. for k, v := range list {
  727. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  728. if err != nil {
  729. br.Msg = "获取信息失败"
  730. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  731. return
  732. }
  733. for k2, v2 := range artList {
  734. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  735. if err != nil {
  736. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  737. br.ErrMsg = "获取失败,Err:" + err.Error()
  738. return
  739. }
  740. var subjectNamesNew string
  741. if len(subjectNames) > 0 {
  742. slice := strings.Split(subjectNames, "/")
  743. for k3, v3 := range slice {
  744. if k3 < 4 {
  745. subjectNamesNew += v3 + "/"
  746. }
  747. }
  748. }
  749. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  750. if err != nil && err.Error() != utils.ErrNoRow() {
  751. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  752. br.ErrMsg = "获取失败,Err:" + err.Error()
  753. return
  754. }
  755. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  756. artList[k2].SubjectName = subjectNamesNew
  757. artList[k2].DepartmentId = v.DepartmentId
  758. if subjectNamesNew == "" {
  759. artList[k2].IndustryName = industryName
  760. } else {
  761. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  762. }
  763. if artList[k2].IsReport == "1" {
  764. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  765. } else {
  766. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  767. }
  768. }
  769. list[k].List = artList
  770. if v.FollowNum > 0 {
  771. list[k].IsMyFollow = true
  772. }
  773. }
  774. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  775. if err != nil {
  776. br.Msg = "获取信息失败"
  777. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  778. return
  779. }
  780. if len(listnNew) > 0 {
  781. for _, v := range listnNew {
  782. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  783. Management := new(models.IndustrialManagementIdInt)
  784. if firstStr == 0 {
  785. Management.IndustryName = v.IndustryName
  786. } else {
  787. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  788. if err != nil {
  789. br.Msg = "获取信息失败"
  790. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  791. return
  792. }
  793. var subjectNamesNew string
  794. for _, v1 := range listSub {
  795. subjectNamesNew += v1.SubjectName + "/"
  796. }
  797. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  798. Management.IndustryName = subjectNamesNew
  799. }
  800. Management.IndustrialManagementId = v.IndustrialManagementId
  801. Management.ArticleId = v.ArticleId
  802. resp.ListnNew = append(resp.ListnNew, Management)
  803. }
  804. }
  805. resp.List = list
  806. resp.Paging = page
  807. br.Ret = 200
  808. br.Success = true
  809. br.Msg = "获取成功"
  810. br.Data = resp
  811. }
  812. // @Title 关注作者/取消关注作者
  813. // @Description 关注作者/取消关注作者 接口
  814. // @Param request body models.CygxArticleDepartmentId true "type json string"
  815. // @Success 200
  816. // @router /fllowDepartment [post]
  817. func (this *ReportController) FllowDepartment() {
  818. br := new(models.BaseResponse).Init()
  819. defer func() {
  820. this.Data["json"] = br
  821. this.ServeJSON()
  822. }()
  823. user := this.User
  824. if user == nil {
  825. br.Msg = "请重新登录"
  826. br.Ret = 408
  827. return
  828. }
  829. uid := user.UserId
  830. var req models.CygxArticleDepartmentId
  831. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  832. if err != nil {
  833. br.Msg = "参数解析异常!"
  834. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  835. return
  836. }
  837. departmentId := req.DepartmentId
  838. var condition string
  839. countDepartment, err := models.GetDepartmentCount(departmentId)
  840. if err != nil {
  841. br.Msg = "获取数据失败!"
  842. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  843. return
  844. }
  845. if countDepartment == 0 {
  846. br.Msg = "作者不存在!"
  847. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  848. return
  849. }
  850. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  851. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  852. if err != nil {
  853. br.Msg = "获取数据失败!"
  854. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  855. return
  856. }
  857. resp := new(models.CygxArticleDepartmentFollowResp)
  858. if countUser == 0 {
  859. resp.GoFollow = true
  860. }
  861. if count == 0 {
  862. item := new(models.CygxArticleDepartmentFollow)
  863. item.DepartmentId = departmentId
  864. item.UserId = uid
  865. item.Email = user.Email
  866. item.Mobile = user.Mobile
  867. item.RealName = user.RealName
  868. item.CompanyId = user.CompanyId
  869. item.CompanyName = user.CompanyName
  870. item.Type = 1
  871. item.CreateTime = time.Now()
  872. item.ModifyTime = time.Now()
  873. _, err = models.AddArticleDepartmentFollow(item)
  874. if err != nil {
  875. br.Msg = "操作失败"
  876. br.ErrMsg = "操作失败,Err:" + err.Error()
  877. return
  878. }
  879. resp.Status = 1
  880. } else {
  881. var doType int
  882. condition = ` AND type = 1`
  883. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  884. if err != nil {
  885. br.Msg = "操作失败!"
  886. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  887. return
  888. }
  889. if count == 1 {
  890. resp.Status = 2
  891. doType = 2
  892. } else {
  893. resp.Status = 1
  894. doType = 1
  895. }
  896. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  897. if err != nil {
  898. br.Msg = "操作失败"
  899. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  900. return
  901. }
  902. }
  903. br.Msg = "操作成功"
  904. br.Ret = 200
  905. br.Success = true
  906. br.Data = resp
  907. }
  908. // @Title 研选文章列表接口
  909. // @Description 获取研选文章列表接口
  910. // @Param PageSize query int true "每页数据条数"
  911. // @Param CurrentIndex query int true "当前页页码,从1开始"
  912. // @Param ArticleId query int true "文章id"
  913. // @Param DepartmentId query int true "作者ID"
  914. // @Param IndustrialManagementId query int true "产业ID"
  915. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  916. // @router /industry/reportList [get]
  917. func (this *ReportController) ReportList() {
  918. br := new(models.BaseResponse).Init()
  919. defer func() {
  920. this.Data["json"] = br
  921. this.ServeJSON()
  922. }()
  923. user := this.User
  924. if user == nil {
  925. br.Msg = "请重新登录"
  926. br.Ret = 408
  927. return
  928. }
  929. uid := user.UserId
  930. pageSize, _ := this.GetInt("PageSize")
  931. currentIndex, _ := this.GetInt("CurrentIndex")
  932. departmentId, _ := this.GetInt("DepartmentId")
  933. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  934. articleId, _ := this.GetInt("ArticleId")
  935. var condition string
  936. var startSize int
  937. if pageSize <= 0 {
  938. pageSize = utils.PageSize20
  939. }
  940. if currentIndex <= 0 {
  941. currentIndex = 1
  942. }
  943. startSize = paging.StartIndex(currentIndex, pageSize)
  944. var pars []interface{}
  945. var total int
  946. resp := new(models.ReportArticleWhichIndustrialRepList)
  947. page := paging.GetPaging(currentIndex, pageSize, total)
  948. userType, _, err := services.GetUserType(user.CompanyId)
  949. if err != nil {
  950. br.Msg = "获取信息失败"
  951. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  952. return
  953. }
  954. if userType == 1 {
  955. resp.Paging = page
  956. br.Ret = 200
  957. br.Success = true
  958. br.Msg = "获取成功"
  959. br.Data = resp
  960. return
  961. }
  962. resp.HaveResearch = true
  963. if departmentId > 0 {
  964. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  965. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  966. if err != nil {
  967. br.Msg = "获取信息失败"
  968. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  969. return
  970. }
  971. resp.NickName = detail.NickName
  972. }
  973. if industrialManagementId > 0 {
  974. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  975. }
  976. if articleId > 0 {
  977. detail, err := models.GetArticleDetailById(articleId)
  978. if err != nil {
  979. br.Msg = "获取信息失败"
  980. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  981. return
  982. }
  983. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  984. }
  985. total, err = models.GetWhichDepartmentCount(condition)
  986. if err != nil {
  987. br.Msg = "获取信息失败"
  988. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  989. return
  990. }
  991. page = paging.GetPaging(currentIndex, pageSize, total)
  992. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  993. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  994. if err != nil {
  995. br.Msg = "获取失败"
  996. br.ErrMsg = "获取失败,Err:" + err.Error()
  997. return
  998. }
  999. for k, v := range list {
  1000. if v.Readnum == 0 {
  1001. list[k].IsRed = true
  1002. }
  1003. list[k].IsResearch = true
  1004. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1005. if err != nil {
  1006. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1007. br.ErrMsg = "获取失败,Err:" + err.Error()
  1008. return
  1009. }
  1010. var subjectNamesNew string
  1011. if len(subjectNames) > 0 {
  1012. slice := strings.Split(subjectNames, "/")
  1013. for k3, v3 := range slice {
  1014. if k3 < 4 {
  1015. subjectNamesNew += v3 + "/"
  1016. }
  1017. }
  1018. }
  1019. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1020. if err != nil && err.Error() != utils.ErrNoRow() {
  1021. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1022. br.ErrMsg = "获取失败,Err:" + err.Error()
  1023. return
  1024. }
  1025. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1026. list[k].SubjectName = subjectNamesNew
  1027. if subjectNamesNew != "" {
  1028. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1029. } else {
  1030. list[k].IndustryName = industryName
  1031. }
  1032. resp.IndustryName = industryName
  1033. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1034. }
  1035. resp.List = list
  1036. resp.Paging = page
  1037. br.Ret = 200
  1038. br.Success = true
  1039. br.Msg = "获取成功"
  1040. br.Data = resp
  1041. }
  1042. // @Title 研选最新主题关键词文章列表接口
  1043. // @Description 获取研选最新主题关键词文章列表接口
  1044. // @Param PageSize query int true "每页数据条数"
  1045. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1046. // @Param ArticleId query int true "文章id"
  1047. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1048. // @router /industry/reportListNew [get]
  1049. func (this *ReportController) ReportListNew() {
  1050. br := new(models.BaseResponse).Init()
  1051. defer func() {
  1052. this.Data["json"] = br
  1053. this.ServeJSON()
  1054. }()
  1055. user := this.User
  1056. if user == nil {
  1057. br.Msg = "请重新登录"
  1058. br.Ret = 408
  1059. return
  1060. }
  1061. uid := user.UserId
  1062. pageSize, _ := this.GetInt("PageSize")
  1063. currentIndex, _ := this.GetInt("CurrentIndex")
  1064. articleId, _ := this.GetInt("ArticleId")
  1065. var condition string
  1066. var startSize int
  1067. if pageSize <= 0 {
  1068. pageSize = utils.PageSize20
  1069. }
  1070. if currentIndex <= 0 {
  1071. currentIndex = 1
  1072. }
  1073. startSize = paging.StartIndex(currentIndex, pageSize)
  1074. var pars []interface{}
  1075. var total int
  1076. resp := new(models.ReportArticleWhichIndustrialRepList)
  1077. page := paging.GetPaging(currentIndex, pageSize, total)
  1078. userType, _, err := services.GetUserType(user.CompanyId)
  1079. if err != nil {
  1080. br.Msg = "获取信息失败"
  1081. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1082. return
  1083. }
  1084. if userType == 1 {
  1085. resp.Paging = page
  1086. br.Ret = 200
  1087. br.Success = true
  1088. br.Msg = "获取成功"
  1089. br.Data = resp
  1090. return
  1091. }
  1092. resp.HaveResearch = true
  1093. if articleId > 0 {
  1094. detail, err := models.GetArticleDetailById(articleId)
  1095. if err != nil {
  1096. br.Msg = "获取信息失败"
  1097. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1098. return
  1099. }
  1100. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1101. if firstStr == 0 {
  1102. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1103. } else {
  1104. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1105. }
  1106. }
  1107. total, err = models.GetWhichDepartmentCount(condition)
  1108. if err != nil {
  1109. br.Msg = "获取信息失败"
  1110. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1111. return
  1112. }
  1113. page = paging.GetPaging(currentIndex, pageSize, total)
  1114. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1115. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1116. if err != nil {
  1117. br.Msg = "获取失败"
  1118. br.ErrMsg = "获取失败,Err:" + err.Error()
  1119. return
  1120. }
  1121. for k, v := range list {
  1122. if v.Readnum == 0 {
  1123. list[k].IsRed = true
  1124. }
  1125. list[k].IsResearch = true
  1126. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1127. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1128. if err != nil {
  1129. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1130. br.ErrMsg = "获取失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. var subjectNamesNew string
  1134. if len(subjectNames) > 0 {
  1135. slice := strings.Split(subjectNames, "/")
  1136. for k3, v3 := range slice {
  1137. if k3 < 4 {
  1138. subjectNamesNew += v3 + "/"
  1139. }
  1140. }
  1141. }
  1142. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1143. if err != nil && err.Error() != utils.ErrNoRow() {
  1144. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1145. br.ErrMsg = "获取失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1149. list[k].SubjectName = subjectNamesNew
  1150. if subjectNamesNew != "" {
  1151. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1152. } else {
  1153. list[k].IndustryName = industryName
  1154. }
  1155. resp.IndustryName = industryName
  1156. }
  1157. resp.List = list
  1158. resp.Paging = page
  1159. br.Ret = 200
  1160. br.Success = true
  1161. br.Msg = "获取成功"
  1162. br.Data = resp
  1163. }
  1164. // @Title 是否展示绝密内参
  1165. // @Description 获取是否展示绝密内参接口
  1166. // @Param request body models.IsShow true "type json string"
  1167. // @Success 200
  1168. // @router /isShow [get]
  1169. func (this *ReportController) IsShow() {
  1170. br := new(models.BaseResponse).Init()
  1171. defer func() {
  1172. this.Data["json"] = br
  1173. this.ServeJSON()
  1174. }()
  1175. user := this.User
  1176. if user == nil {
  1177. br.Msg = "请重新登录"
  1178. br.Ret = 408
  1179. return
  1180. }
  1181. var resp models.IsShow
  1182. resp.IsShowChart = true
  1183. resp.IsShowResearch = true
  1184. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1185. resp.YanXuan_Explain = true
  1186. mobile := user.Mobile
  1187. if mobile == "" {
  1188. br.Ret = 200
  1189. br.Success = true
  1190. br.Data = resp
  1191. return
  1192. }
  1193. total, _ := models.GetUserIsAdminCount(mobile)
  1194. if total > 0 {
  1195. resp.IsShowList = true
  1196. }
  1197. resp.IsShow = true
  1198. br.Ret = 200
  1199. br.Success = true
  1200. br.Data = resp
  1201. }
  1202. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1203. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1204. // @Param PageSize query int true "每页数据条数"
  1205. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1206. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1207. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1208. // @router /reportList/byType [get]
  1209. func (this *ReportController) ReportListByType() {
  1210. br := new(models.BaseResponse).Init()
  1211. defer func() {
  1212. this.Data["json"] = br
  1213. this.ServeJSON()
  1214. }()
  1215. user := this.User
  1216. if user == nil {
  1217. br.Msg = "请重新登录"
  1218. br.Ret = 408
  1219. return
  1220. }
  1221. uid := user.UserId
  1222. pageSize, _ := this.GetInt("PageSize")
  1223. currentIndex, _ := this.GetInt("CurrentIndex")
  1224. reportType := this.GetString("ReportType")
  1225. var condition string
  1226. var startSize int
  1227. if pageSize <= 0 {
  1228. pageSize = utils.PageSize20
  1229. }
  1230. if currentIndex <= 0 {
  1231. currentIndex = 1
  1232. }
  1233. startSize = paging.StartIndex(currentIndex, pageSize)
  1234. var pars []interface{}
  1235. var total int
  1236. resp := new(models.CygxReportSelectionListPublicRep)
  1237. page := paging.GetPaging(currentIndex, pageSize, total)
  1238. var tbdb string
  1239. var readSql string
  1240. var reportTypeStr string
  1241. if reportType == "1" {
  1242. tbdb = "cygx_report_selection"
  1243. reportTypeStr = "bgjx"
  1244. } else if reportType == "2" {
  1245. tbdb = "cygx_research_summary"
  1246. reportTypeStr = "bzyjhz"
  1247. } else if reportType == "3" {
  1248. tbdb = "cygx_minutes_summary"
  1249. reportTypeStr = "szjyhz"
  1250. } else {
  1251. br.Msg = "请选择报告类型"
  1252. return
  1253. }
  1254. fmt.Println(tbdb)
  1255. condition = ` AND publish_status = 1`
  1256. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1257. if err != nil {
  1258. br.Msg = "获取信息失败"
  1259. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1260. return
  1261. }
  1262. 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`
  1263. page = paging.GetPaging(currentIndex, pageSize, total)
  1264. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1265. if err != nil {
  1266. br.Msg = "获取失败"
  1267. br.ErrMsg = "获取失败,Err:" + err.Error()
  1268. return
  1269. }
  1270. for k, v := range list {
  1271. if reportType == "1" {
  1272. list[k].Abstract = v.UpdateDescription
  1273. }
  1274. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1275. if v.ReadNum == 0 {
  1276. list[k].IsRed = true
  1277. }
  1278. }
  1279. resp.List = list
  1280. resp.Paging = page
  1281. br.Ret = 200
  1282. br.Success = true
  1283. br.Msg = "获取成功"
  1284. br.Data = resp
  1285. }
  1286. // @Title 获取报告精选详情
  1287. // @Description 获取报告精选详情接口
  1288. // @Param ArticleId query int true "报告ID"
  1289. // @Success 200 {object} models.ReportSelectionLetailResp
  1290. // @router /reportSelection/detail [get]
  1291. func (this *ReportController) Detail() {
  1292. br := new(models.BaseResponse).Init()
  1293. defer func() {
  1294. this.Data["json"] = br
  1295. this.ServeJSON()
  1296. }()
  1297. user := this.User
  1298. if user == nil {
  1299. br.Msg = "请重新登录"
  1300. br.Ret = 408
  1301. return
  1302. }
  1303. uid := user.UserId
  1304. articleId, _ := this.GetInt("ArticleId")
  1305. if articleId < 0 {
  1306. br.Msg = "参数错误"
  1307. br.ErrMsg = "参数错误"
  1308. return
  1309. }
  1310. resp := new(models.ReportSelectionLetailResp)
  1311. //判断用户权限
  1312. hasPermission, err := services.GetUserhasPermission(user)
  1313. if err != nil {
  1314. br.Msg = "获取信息失败"
  1315. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1316. }
  1317. resp.HasPermission = hasPermission
  1318. if hasPermission != 1 {
  1319. br.Ret = 200
  1320. br.Success = true
  1321. br.Msg = "获取成功"
  1322. br.Data = resp
  1323. return
  1324. }
  1325. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1326. if err != nil {
  1327. br.Msg = "获取信息失败"
  1328. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1329. return
  1330. }
  1331. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1332. existMap := make(map[int]int)
  1333. var items []*models.ReportSelectionChartPermission
  1334. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1335. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1336. if err != nil {
  1337. br.Msg = "获取失败"
  1338. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1339. return
  1340. }
  1341. //var itemLogs []*models.CygxReportSelectionLogDetail
  1342. for _, v := range listLog {
  1343. item := new(models.ReportSelectionChartPermission)
  1344. if existMap[v.ChartPermissionId] == 0 {
  1345. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1346. item.IcoLink = v.IcoLink
  1347. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1348. if err != nil && err.Error() != utils.ErrNoRow() {
  1349. br.Msg = "获取信息失败"
  1350. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1351. return
  1352. }
  1353. for k2, v2 := range listSonLog {
  1354. if v2.IndustrialManagementId != "" {
  1355. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1356. if err != nil && err.Error() != utils.ErrNoRow() {
  1357. br.Msg = "获取信息失败"
  1358. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1359. return
  1360. }
  1361. listSonLog[k2].List = listIndustrial
  1362. }
  1363. }
  1364. item.List = listSonLog
  1365. items = append(items, item)
  1366. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1367. }
  1368. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1369. }
  1370. historyRecord := new(models.CygxReportHistoryRecord)
  1371. historyRecord.UserId = uid
  1372. historyRecord.ArticleId = articleId
  1373. historyRecord.CreateTime = time.Now()
  1374. historyRecord.Mobile = user.Mobile
  1375. historyRecord.Email = user.Email
  1376. historyRecord.CompanyId = user.CompanyId
  1377. historyRecord.CompanyName = user.CompanyName
  1378. historyRecord.ReportType = "bgjx"
  1379. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1380. if err != nil && err.Error() != utils.ErrNoRow() {
  1381. br.Msg = "获取信息失败"
  1382. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1383. return
  1384. }
  1385. historyRecord.RealName = user.RealName
  1386. if sellerItem != nil {
  1387. historyRecord.SellerName = sellerItem.RealName
  1388. }
  1389. go models.AddCygxReportHistoryRecord(historyRecord)
  1390. resp.List = items
  1391. resp.Detail = detail
  1392. br.Ret = 200
  1393. br.Success = true
  1394. br.Msg = "获取成功"
  1395. br.Data = resp
  1396. }
  1397. // @Title 获取本周研究汇总详情
  1398. // @Description 获取本周研究汇总详情接口
  1399. // @Param ArticleId query int true "报告ID"
  1400. // @Success 200 {object} models.ResearchSummaryLetailResp
  1401. // @router /researchSummary/detail [get]
  1402. func (this *ReportController) ResearchDetail() {
  1403. br := new(models.BaseResponse).Init()
  1404. defer func() {
  1405. this.Data["json"] = br
  1406. this.ServeJSON()
  1407. }()
  1408. user := this.User
  1409. if user == nil {
  1410. br.Msg = "请重新登录"
  1411. br.Ret = 408
  1412. return
  1413. }
  1414. uid := user.UserId
  1415. articleId, _ := this.GetInt("ArticleId")
  1416. if articleId < 0 {
  1417. br.Msg = "参数错误"
  1418. br.ErrMsg = "参数错误"
  1419. return
  1420. }
  1421. resp := new(models.ResearchSummaryLetailResp)
  1422. //判断用户权限
  1423. hasPermission, err := services.GetUserhasPermission(user)
  1424. if err != nil {
  1425. br.Msg = "获取信息失败"
  1426. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1427. }
  1428. resp.HasPermission = hasPermission
  1429. if hasPermission != 1 {
  1430. br.Ret = 200
  1431. br.Success = true
  1432. br.Msg = "获取成功"
  1433. br.Data = resp
  1434. return
  1435. }
  1436. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1437. if err != nil {
  1438. br.Msg = "获取信息失败"
  1439. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1440. return
  1441. }
  1442. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1443. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1444. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1445. if err != nil {
  1446. br.Msg = "获取失败"
  1447. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1448. return
  1449. }
  1450. listArticleType, err := models.GetCygxArticleTypeList()
  1451. if err != nil {
  1452. br.Msg = "获取失败"
  1453. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1454. return
  1455. }
  1456. for k, v := range listFirst {
  1457. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1458. if err != nil && err.Error() != utils.ErrNoRow() {
  1459. br.Msg = "获取信息失败"
  1460. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1461. return
  1462. }
  1463. for k2, v2 := range listSecond {
  1464. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1465. if err != nil && err.Error() != utils.ErrNoRow() {
  1466. br.Msg = "获取信息失败"
  1467. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1468. return
  1469. }
  1470. for _, vType := range listArticleType {
  1471. if v2.ChartPermissionId == vType.YanxPermissionId {
  1472. listSecond[k2].IcoLink = vType.IcoLinkM
  1473. listSecond[k2].PermissionName = vType.YanxPermissionName
  1474. }
  1475. }
  1476. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1477. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1478. // listSecond[k2].PermissionName = "买方研选纪要"
  1479. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1480. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1481. // listSecond[k2].PermissionName = "买方研选观点"
  1482. //}
  1483. if len(listThird) > 0 {
  1484. for k3, v3 := range listThird {
  1485. if v3.VideoUrl != "" {
  1486. listThird[k3].IsHaveVideo = true
  1487. }
  1488. if v3.ReportLink == "0" {
  1489. listThird[k3].ReportLink = ""
  1490. }
  1491. }
  1492. listSecond[k2].List = listThird
  1493. }
  1494. }
  1495. if len(listSecond) > 0 {
  1496. listFirst[k].List = listSecond
  1497. }
  1498. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1499. if v.Type == "SDBG" {
  1500. listFirst[k].ListName = "深度报告"
  1501. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1502. } else if v.Type == "BZCHJH" {
  1503. listFirst[k].ListName = "本周晨会精华"
  1504. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1505. } else if v.Type == "CYDYJY" {
  1506. listFirst[k].ListName = "产业调研纪要"
  1507. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1508. } else if v.Type == "SSGS" {
  1509. listFirst[k].ListName = "上市公司调研纪要篇"
  1510. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1511. } else if v.Type == "SJDP" {
  1512. listFirst[k].ListName = "事件点评"
  1513. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1514. } else if v.Type == "YANX" {
  1515. listFirst[k].ListName = "买方研选"
  1516. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1517. }
  1518. }
  1519. historyRecord := new(models.CygxReportHistoryRecord)
  1520. historyRecord.UserId = uid
  1521. historyRecord.ArticleId = articleId
  1522. historyRecord.CreateTime = time.Now()
  1523. historyRecord.Mobile = user.Mobile
  1524. historyRecord.Email = user.Email
  1525. historyRecord.CompanyId = user.CompanyId
  1526. historyRecord.CompanyName = user.CompanyName
  1527. historyRecord.ReportType = "bzyjhz"
  1528. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1529. if err != nil && err.Error() != utils.ErrNoRow() {
  1530. br.Msg = "获取信息失败"
  1531. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1532. return
  1533. }
  1534. historyRecord.RealName = user.RealName
  1535. if sellerItem != nil {
  1536. historyRecord.SellerName = sellerItem.RealName
  1537. }
  1538. go models.AddCygxReportHistoryRecord(historyRecord)
  1539. resp.List = listFirst
  1540. resp.Detail = detail
  1541. br.Ret = 200
  1542. br.Success = true
  1543. br.Msg = "获取成功"
  1544. br.Data = resp
  1545. }
  1546. // @Title 上周纪要汇总内容详情
  1547. // @Description 获取上周纪要汇总内容详情接口
  1548. // @Param ArticleId query int true "报告ID"
  1549. // @Success 200 {object} models.MinutesSummaryLetailResp
  1550. // @router /minutesSummary/detailv4 [get]
  1551. func (this *ReportController) MinutesDetailV4() {
  1552. br := new(models.BaseResponse).Init()
  1553. defer func() {
  1554. this.Data["json"] = br
  1555. this.ServeJSON()
  1556. }()
  1557. user := this.User
  1558. if user == nil {
  1559. br.Msg = "请重新登录"
  1560. br.Ret = 408
  1561. return
  1562. }
  1563. uid := user.UserId
  1564. articleId, _ := this.GetInt("ArticleId")
  1565. if articleId < 0 {
  1566. br.Msg = "参数错误"
  1567. br.ErrMsg = "参数错误"
  1568. return
  1569. }
  1570. resp := new(models.MinutesSummaryLetailRespV4)
  1571. //判断用户权限
  1572. hasPermission, err := services.GetUserhasPermission(user)
  1573. if err != nil {
  1574. br.Msg = "获取信息失败"
  1575. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1576. }
  1577. resp.HasPermission = hasPermission
  1578. if hasPermission != 1 {
  1579. br.Ret = 200
  1580. br.Success = true
  1581. br.Msg = "获取成功"
  1582. br.Data = resp
  1583. return
  1584. }
  1585. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1586. if err != nil {
  1587. br.Msg = "获取信息失败"
  1588. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1589. return
  1590. }
  1591. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1592. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1593. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1594. if err != nil {
  1595. br.Msg = "获取失败"
  1596. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1597. return
  1598. }
  1599. for k, v := range listFirst {
  1600. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1601. if err != nil && err.Error() != utils.ErrNoRow() {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1604. return
  1605. }
  1606. for k2, v2 := range listSecond {
  1607. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1608. if err != nil && err.Error() != utils.ErrNoRow() {
  1609. br.Msg = "获取信息失败"
  1610. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1611. return
  1612. }
  1613. if len(listThird) > 0 {
  1614. for k3, v3 := range listThird {
  1615. if v3.VideoUrl != "" {
  1616. listThird[k3].IsHaveVideo = true
  1617. }
  1618. if v3.ReportLink == "0" {
  1619. listThird[k3].ReportLink = ""
  1620. }
  1621. }
  1622. listSecond[k2].List = listThird
  1623. }
  1624. }
  1625. if len(listSecond) > 0 {
  1626. listFirst[k].List = listSecond
  1627. }
  1628. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1629. if v.Type == "CYDYJY" {
  1630. listFirst[k].ListName = "产业调研纪要"
  1631. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1632. } else if v.Type == "SSGS" {
  1633. listFirst[k].ListName = "上市公司调研纪要篇"
  1634. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1635. } else if v.Type == "YANX" {
  1636. listFirst[k].ListName = "买方研选纪要"
  1637. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1638. }
  1639. }
  1640. historyRecord := new(models.CygxReportHistoryRecord)
  1641. historyRecord.UserId = uid
  1642. historyRecord.ArticleId = articleId
  1643. historyRecord.CreateTime = time.Now()
  1644. historyRecord.Mobile = user.Mobile
  1645. historyRecord.Email = user.Email
  1646. historyRecord.CompanyId = user.CompanyId
  1647. historyRecord.CompanyName = user.CompanyName
  1648. historyRecord.ReportType = "szjyhz"
  1649. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1650. if err != nil && err.Error() != utils.ErrNoRow() {
  1651. br.Msg = "获取信息失败"
  1652. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1653. return
  1654. }
  1655. historyRecord.RealName = user.RealName
  1656. if sellerItem != nil {
  1657. historyRecord.SellerName = sellerItem.RealName
  1658. }
  1659. go models.AddCygxReportHistoryRecord(historyRecord)
  1660. resp.List = listFirst
  1661. resp.Detail = detail
  1662. br.Ret = 200
  1663. br.Success = true
  1664. br.Msg = "获取成功"
  1665. br.Data = resp
  1666. }
  1667. // @Title 上周纪要汇总内容详情
  1668. // @Description 获取上周纪要汇总内容详情接口
  1669. // @Param ArticleId query int true "报告ID"
  1670. // @Success 200 {object} models.MinutesSummaryLetailResp
  1671. // @router /minutesSummary/detail [get]
  1672. func (this *ReportController) MinutesDetail() {
  1673. br := new(models.BaseResponse).Init()
  1674. defer func() {
  1675. this.Data["json"] = br
  1676. this.ServeJSON()
  1677. }()
  1678. user := this.User
  1679. if user == nil {
  1680. br.Msg = "请重新登录"
  1681. br.Ret = 408
  1682. return
  1683. }
  1684. uid := user.UserId
  1685. articleId, _ := this.GetInt("ArticleId")
  1686. if articleId < 0 {
  1687. br.Msg = "参数错误"
  1688. br.ErrMsg = "参数错误"
  1689. return
  1690. }
  1691. resp := new(models.MinutesSummaryLetailResp)
  1692. //判断用户权限
  1693. hasPermission, err := services.GetUserhasPermission(user)
  1694. if err != nil {
  1695. br.Msg = "获取信息失败"
  1696. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1697. }
  1698. resp.HasPermission = hasPermission
  1699. if hasPermission != 1 {
  1700. br.Ret = 200
  1701. br.Success = true
  1702. br.Msg = "获取成功"
  1703. br.Data = resp
  1704. return
  1705. }
  1706. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1707. if err != nil {
  1708. br.Msg = "获取信息失败"
  1709. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1710. return
  1711. }
  1712. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1713. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1714. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1715. if err != nil {
  1716. br.Msg = "获取失败"
  1717. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1718. return
  1719. }
  1720. for k, v := range listLog {
  1721. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1722. if err != nil && err.Error() != utils.ErrNoRow() {
  1723. br.Msg = "获取信息失败"
  1724. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1725. return
  1726. }
  1727. if len(listSonLog) > 0 {
  1728. listLog[k].List = listSonLog
  1729. for k2, v2 := range listSonLog {
  1730. if v2.ReportLink == "0" {
  1731. listSonLog[k2].ReportLink = ""
  1732. }
  1733. }
  1734. }
  1735. }
  1736. historyRecord := new(models.CygxReportHistoryRecord)
  1737. historyRecord.UserId = uid
  1738. historyRecord.ArticleId = articleId
  1739. historyRecord.CreateTime = time.Now()
  1740. historyRecord.Mobile = user.Mobile
  1741. historyRecord.Email = user.Email
  1742. historyRecord.CompanyId = user.CompanyId
  1743. historyRecord.CompanyName = user.CompanyName
  1744. historyRecord.ReportType = "szjyhz"
  1745. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1746. if err != nil && err.Error() != utils.ErrNoRow() {
  1747. br.Msg = "获取信息失败"
  1748. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1749. return
  1750. }
  1751. historyRecord.RealName = user.RealName
  1752. if sellerItem != nil {
  1753. historyRecord.SellerName = sellerItem.RealName
  1754. }
  1755. go models.AddCygxReportHistoryRecord(historyRecord)
  1756. resp.List = listLog
  1757. resp.Detail = detail
  1758. br.Ret = 200
  1759. br.Success = true
  1760. br.Msg = "获取成功"
  1761. br.Data = resp
  1762. }
  1763. // @Title 获取路演精华详情
  1764. // @Description 获取路演精华详情接口
  1765. // @Param ArticleId query int true "报告ID"
  1766. // @Success 200 {object} models.RoadshowDetailResp
  1767. // @router /roadshowEssence/detail [get]
  1768. func (this *ReportController) RoadshowDetail() {
  1769. br := new(models.BaseResponse).Init()
  1770. defer func() {
  1771. this.Data["json"] = br
  1772. this.ServeJSON()
  1773. }()
  1774. user := this.User
  1775. if user == nil {
  1776. br.Msg = "请登录"
  1777. br.ErrMsg = "请登录,用户信息为空"
  1778. br.Ret = 408
  1779. return
  1780. }
  1781. uid := user.UserId
  1782. articleId, err := this.GetInt("ArticleId")
  1783. if articleId <= 0 {
  1784. br.Msg = "文章不存在"
  1785. br.ErrMsg = "文章不存在,文章ID错误"
  1786. return
  1787. }
  1788. detail := new(models.ReportDetailRoadshow)
  1789. hasPermission := 0
  1790. hasFree := 0
  1791. //判断是否已经申请过
  1792. applyCount, err := models.GetApplyRecordCount(uid)
  1793. if err != nil && err.Error() != utils.ErrNoRow() {
  1794. br.Msg = "获取信息失败"
  1795. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1796. return
  1797. }
  1798. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1799. if user.CompanyId > 1 {
  1800. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1801. if err != nil {
  1802. br.Msg = "获取信息失败"
  1803. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1804. return
  1805. }
  1806. detail, err = models.GetReportRoadshowDetailById(articleId)
  1807. if err != nil {
  1808. br.Msg = "获取信息失败"
  1809. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1810. return
  1811. }
  1812. detail.Body = html.UnescapeString(detail.Body)
  1813. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  1814. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1815. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1816. if detail.ReportLink == "0" {
  1817. detail.ReportLink = ""
  1818. }
  1819. if companyPermission == "" {
  1820. if applyCount > 0 {
  1821. hasPermission = 5
  1822. } else {
  1823. hasPermission = 2
  1824. }
  1825. hasFree = 2
  1826. goto Loop
  1827. } else {
  1828. hasFree = 1
  1829. var articlePermissionPermissionName string
  1830. articlePermissionPermissionName = detail.CategoryName
  1831. var hasPersion bool
  1832. slice := strings.Split(articlePermissionPermissionName, ",")
  1833. for _, v := range slice {
  1834. if strings.Contains(companyPermission, v) {
  1835. hasPersion = true
  1836. }
  1837. }
  1838. if hasPersion {
  1839. hasPermission = 1
  1840. historyRecord := new(models.CygxArticleHistoryRecord)
  1841. historyRecord.UserId = uid
  1842. historyRecord.ArticleId = articleId
  1843. historyRecord.CreateTime = time.Now()
  1844. historyRecord.Mobile = user.Mobile
  1845. historyRecord.Email = user.Email
  1846. historyRecord.CompanyId = user.CompanyId
  1847. historyRecord.CompanyName = user.CompanyName
  1848. go models.AddCygxArticleHistoryRecord(historyRecord)
  1849. } else { //无该行业权限
  1850. hasPermission = 3
  1851. }
  1852. if hasPermission == 1 {
  1853. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1854. if !utils.Rc.IsExist(key) {
  1855. //新增浏览记录
  1856. record := new(models.CygxArticleViewRecord)
  1857. record.UserId = uid
  1858. record.ArticleId = articleId
  1859. record.CreateTime = time.Now()
  1860. record.Mobile = user.Mobile
  1861. record.Email = user.Email
  1862. record.CompanyId = user.CompanyId
  1863. record.CompanyName = user.CompanyName
  1864. go models.AddCygxArticleViewRecord(record)
  1865. utils.Rc.Put(key, 1, 5*time.Second)
  1866. models.ModifyReportLastViewTime(uid)
  1867. }
  1868. }
  1869. }
  1870. } else { //潜在客户
  1871. if applyCount > 0 {
  1872. hasPermission = 5
  1873. } else {
  1874. hasPermission = 4
  1875. }
  1876. }
  1877. Loop:
  1878. if hasPermission != 1 {
  1879. detail.Body = ""
  1880. detail.Abstract = ""
  1881. }
  1882. resp := new(models.RoadshowDetailResp)
  1883. resp.HasPermission = hasPermission
  1884. resp.HasFree = hasFree
  1885. resp.Detail = detail
  1886. br.Ret = 200
  1887. br.Success = true
  1888. br.Msg = "获取成功"
  1889. br.Data = resp
  1890. }
  1891. // @Title 产业文章列表接口
  1892. // @Description 获取产业文章列表接口
  1893. // @Param KeyWord query string true "搜索关键词"
  1894. // @Success 200 {object} models.CygxIndustrySearchList
  1895. // @router /industryAndArticle/list [get]
  1896. func (this *ReportController) IndustryAndArticleList() {
  1897. br := new(models.BaseResponse).Init()
  1898. defer func() {
  1899. this.Data["json"] = br
  1900. this.ServeJSON()
  1901. }()
  1902. user := this.User
  1903. if user == nil {
  1904. br.Msg = "请重新登录"
  1905. br.Ret = 408
  1906. return
  1907. }
  1908. uid := user.UserId
  1909. keyWord := this.GetString("KeyWord")
  1910. orderSrt := "update_time DESC"
  1911. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1912. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1913. if err != nil {
  1914. br.Msg = "获取信息失败"
  1915. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1916. return
  1917. }
  1918. for k, v := range list {
  1919. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1920. if err != nil {
  1921. br.Msg = "获取信息失败"
  1922. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1923. return
  1924. }
  1925. list[k].IndustrialSubjectList = industrialSubjectList
  1926. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1927. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1928. if err != nil {
  1929. br.Msg = "获取信息失败"
  1930. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1931. return
  1932. }
  1933. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1934. }
  1935. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1936. if err != nil {
  1937. br.Msg = "获取失败"
  1938. br.ErrMsg = "获取失败,Err:" + err.Error()
  1939. return
  1940. }
  1941. for k2, v2 := range artList {
  1942. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1943. if err != nil {
  1944. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1945. br.ErrMsg = "获取失败,Err:" + err.Error()
  1946. return
  1947. }
  1948. var subjectNamesNew string
  1949. if len(subjectNames) > 0 {
  1950. slice := strings.Split(subjectNames, "/")
  1951. for k3, v3 := range slice {
  1952. if k3 < 4 {
  1953. subjectNamesNew += v3 + "/"
  1954. }
  1955. }
  1956. }
  1957. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1958. if err != nil && err.Error() != utils.ErrNoRow() {
  1959. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1960. br.ErrMsg = "获取失败,Err:" + err.Error()
  1961. return
  1962. }
  1963. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1964. artList[k2].SubjectName = subjectNamesNew
  1965. if subjectNamesNew == "" {
  1966. artList[k2].IndustryName = industryName
  1967. } else {
  1968. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1969. }
  1970. }
  1971. if keyWord != "" {
  1972. keyWordItem := new(models.CygxUserSearchKeyWord)
  1973. keyWordItem.UserId = user.UserId
  1974. keyWordItem.KeyWord = keyWord
  1975. keyWordItem.PageType = "ReortSearch"
  1976. keyWordItem.CreateTime = time.Now()
  1977. go models.AddUserSearchKeyWord(keyWordItem)
  1978. }
  1979. resp := new(models.CygxIndustrySearchList)
  1980. resp.ArtList = artList
  1981. resp.IndList = list
  1982. br.Ret = 200
  1983. br.Success = true
  1984. br.Msg = "获取成功"
  1985. br.Data = resp
  1986. }
  1987. // @Title 产业报告分类关联作者列表接口Pc端
  1988. // @Description 获取产业报告分类关联作者列表接口Pc端
  1989. // @Param ChartPermissionId query int true "分类ID"
  1990. // @Param KeyWord query string true "搜索关键词"
  1991. // @Param PageSize query int true "每页数据条数"
  1992. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1993. // @Success 200 {object} models.CygxArticleDepartmentListPc
  1994. // @router /industryListByDepartmentPc [get]
  1995. func (this *ReportController) IndustryListByDepartmentPc() {
  1996. br := new(models.BaseResponse).Init()
  1997. defer func() {
  1998. this.Data["json"] = br
  1999. this.ServeJSON()
  2000. }()
  2001. user := this.User
  2002. if user == nil {
  2003. br.Msg = "请重新登录"
  2004. br.Ret = 408
  2005. return
  2006. }
  2007. uid := user.UserId
  2008. pageSize, _ := this.GetInt("PageSize")
  2009. currentIndex, _ := this.GetInt("CurrentIndex")
  2010. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2011. keyWord := this.GetString("KeyWord")
  2012. var startSize int
  2013. var condition string
  2014. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2015. if pageSize <= 0 {
  2016. pageSize = utils.PageSize20
  2017. }
  2018. if currentIndex <= 0 {
  2019. currentIndex = 1
  2020. }
  2021. var articleIdGroup string
  2022. if keyWord != "" {
  2023. //获取标的关联的文章ID
  2024. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2025. if err != nil {
  2026. br.Msg = "获取信息失败"
  2027. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2028. return
  2029. }
  2030. //获取产业关联的标的
  2031. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2032. if err != nil {
  2033. br.Msg = "获取信息失败"
  2034. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2035. return
  2036. }
  2037. if articleIdSub != "" && articleIdInd != "" {
  2038. articleIdGroup = articleIdSub + "," + articleIdInd
  2039. } else if articleIdSub != "" && articleIdInd == "" {
  2040. articleIdGroup = articleIdSub
  2041. } else if articleIdSub == "" && articleIdInd != "" {
  2042. articleIdGroup = articleIdInd
  2043. }
  2044. slice := strings.Split(keyWord, "/")
  2045. if len(slice) > 1 {
  2046. var subjectIds string
  2047. for _, v := range slice {
  2048. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2049. if err != nil && err.Error() != utils.ErrNoRow() {
  2050. br.Msg = "获取信息失败"
  2051. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2052. return
  2053. }
  2054. if subjectId != "" {
  2055. subjectIds += subjectId + ","
  2056. }
  2057. }
  2058. subjectIds = strings.TrimRight(subjectIds, ",")
  2059. if len(subjectIds) > 0 {
  2060. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2061. if err != nil {
  2062. br.Msg = "获取信息失败"
  2063. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2064. return
  2065. }
  2066. if articleIdGroup != "" {
  2067. if articleBySub != "" {
  2068. articleIdGroup += "," + articleBySub
  2069. }
  2070. } else {
  2071. articleIdGroup = articleBySub
  2072. }
  2073. }
  2074. }
  2075. }
  2076. if articleIdGroup != "" {
  2077. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2078. }
  2079. startSize = paging.StartIndex(currentIndex, pageSize)
  2080. total, err := models.GetArticleDepartmentCount(condition)
  2081. page := paging.GetPaging(currentIndex, pageSize, total)
  2082. resp := new(models.CygxArticleDepartmentListPc)
  2083. userType, _, err := services.GetUserType(user.CompanyId)
  2084. if err != nil {
  2085. br.Msg = "获取信息失败"
  2086. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2087. return
  2088. }
  2089. if userType == 1 {
  2090. resp.Paging = page
  2091. br.Ret = 200
  2092. br.Success = true
  2093. br.Msg = "获取成功"
  2094. br.Data = resp
  2095. return
  2096. }
  2097. resp.HaveResearch = true
  2098. //获取作者信息,并排序
  2099. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2100. if err != nil {
  2101. br.Msg = "获取信息失败"
  2102. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2103. return
  2104. }
  2105. for k, v := range list {
  2106. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2107. if err != nil {
  2108. br.Msg = "获取信息失败"
  2109. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2110. return
  2111. }
  2112. for k2, v2 := range artList {
  2113. if artList[k2].IsReport == "1" {
  2114. artList[k2].Title = v2.Title
  2115. } else {
  2116. artList[k2].Title = v2.Title
  2117. }
  2118. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2119. }
  2120. list[k].List = artList
  2121. if v.FollowNum > 0 {
  2122. list[k].IsMyFollow = true
  2123. }
  2124. }
  2125. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2126. if err != nil {
  2127. br.Msg = "获取信息失败"
  2128. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2129. return
  2130. }
  2131. if len(listnNew) > 0 {
  2132. for _, v := range listnNew {
  2133. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2134. Management := new(models.IndustrialManagementIdInt)
  2135. if firstStr == 0 {
  2136. Management.IndustryName = v.IndustryName
  2137. } else {
  2138. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2139. if err != nil {
  2140. br.Msg = "获取信息失败"
  2141. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2142. return
  2143. }
  2144. var subjectNamesNew string
  2145. for _, v1 := range listSub {
  2146. subjectNamesNew += v1.SubjectName + "/"
  2147. }
  2148. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2149. Management.IndustryName = subjectNamesNew
  2150. }
  2151. Management.IndustrialManagementId = v.IndustrialManagementId
  2152. Management.ArticleId = v.ArticleId
  2153. resp.ListnNew = append(resp.ListnNew, Management)
  2154. }
  2155. }
  2156. resp.List = list
  2157. resp.Paging = page
  2158. br.Ret = 200
  2159. br.Success = true
  2160. br.Msg = "获取成功"
  2161. br.Data = resp
  2162. }
  2163. // @Title 产业文章列表接口Pc端
  2164. // @Description 获取产业文章列表接口Pc端
  2165. // @Param KeyWord query string true "搜索关键词"
  2166. // @Success 200 {object} models.CygxIndustrySearchListPc
  2167. // @router /industryAndArticle/listPc [get]
  2168. func (this *ReportController) IndustryAndArticleListPc() {
  2169. br := new(models.BaseResponse).Init()
  2170. defer func() {
  2171. this.Data["json"] = br
  2172. this.ServeJSON()
  2173. }()
  2174. user := this.User
  2175. if user == nil {
  2176. br.Msg = "请重新登录"
  2177. br.Ret = 408
  2178. return
  2179. }
  2180. uid := user.UserId
  2181. keyWord := this.GetString("KeyWord")
  2182. resp := new(models.CygxIndustrySearchListPc)
  2183. orderSrt := "update_time DESC"
  2184. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2185. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2186. if err != nil {
  2187. br.Msg = "获取信息失败"
  2188. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2189. return
  2190. }
  2191. for k, v := range list {
  2192. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2193. if err != nil {
  2194. br.Msg = "获取信息失败"
  2195. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2196. return
  2197. }
  2198. list[k].IndustrialSubjectList = industrialSubjectList
  2199. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2200. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2201. if err != nil {
  2202. br.Msg = "获取信息失败"
  2203. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2204. return
  2205. }
  2206. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2207. }
  2208. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2209. if err != nil {
  2210. br.Msg = "获取失败"
  2211. br.ErrMsg = "获取失败,Err:" + err.Error()
  2212. return
  2213. }
  2214. if len(artList) > 0 {
  2215. var articleIds string
  2216. for _, v := range artList {
  2217. articleIds += strconv.Itoa(v.ArticleId) + ","
  2218. }
  2219. articleIds = strings.TrimRight(articleIds, ",")
  2220. if articleIds != "" {
  2221. condition = ` AND a.article_id IN (` + articleIds + `)`
  2222. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2223. if err != nil {
  2224. br.Msg = "获取信息失败"
  2225. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2226. return
  2227. }
  2228. for k, v := range DepartmentList {
  2229. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2230. if err != nil {
  2231. br.Msg = "获取信息失败"
  2232. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2233. return
  2234. }
  2235. for k2, v2 := range artList {
  2236. if artList[k2].IsReport == "1" {
  2237. artList[k2].Title = v2.Title
  2238. } else {
  2239. artList[k2].Title = v2.Title
  2240. }
  2241. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2242. }
  2243. DepartmentList[k].List = artList
  2244. if v.FollowNum > 0 {
  2245. DepartmentList[k].IsMyFollow = true
  2246. }
  2247. }
  2248. resp.DepartmentList = DepartmentList
  2249. }
  2250. }
  2251. if keyWord != "" {
  2252. keyWordItem := new(models.CygxUserSearchKeyWord)
  2253. keyWordItem.UserId = user.UserId
  2254. keyWordItem.KeyWord = keyWord
  2255. keyWordItem.PageType = "ReortSearch"
  2256. keyWordItem.CreateTime = time.Now()
  2257. go models.AddUserSearchKeyWord(keyWordItem)
  2258. }
  2259. resp.IndList = list
  2260. br.Ret = 200
  2261. br.Success = true
  2262. br.Msg = "获取成功"
  2263. br.Data = resp
  2264. }
  2265. // @Title 报告搜索
  2266. // @Description 报告搜索接口
  2267. // @Param KeyWord query string true "搜索关键词"
  2268. // @Success 200 {object} models.ReoprtSearchResp
  2269. // @router /searchReport [get]
  2270. func (this *ReportController) SearchReport() {
  2271. br := new(models.BaseResponse).Init()
  2272. defer func() {
  2273. this.Data["json"] = br
  2274. this.ServeJSON()
  2275. }()
  2276. user := this.User
  2277. if user == nil {
  2278. br.Msg = "请重新登录"
  2279. br.Ret = 408
  2280. return
  2281. }
  2282. keyWord := this.GetString("KeyWord")
  2283. var condition string
  2284. var sqlGroup string
  2285. //匹配报告标题、
  2286. condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2287. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2288. //对应产业名称、标的名称。
  2289. //OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
  2290. //OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
  2291. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2292. if err != nil {
  2293. br.Msg = "获取信息失败"
  2294. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2295. return
  2296. }
  2297. for k, v := range listYx {
  2298. listYx[k].Source = 2
  2299. if v.MyCollectNum > 0 {
  2300. listYx[k].IsCollect = true
  2301. }
  2302. }
  2303. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2304. if err != nil {
  2305. br.Msg = "获取信息失败"
  2306. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2307. return
  2308. }
  2309. for k, v := range listHz {
  2310. listHz[k].Source = 1
  2311. if v.MyCollectNum > 0 {
  2312. listHz[k].IsCollect = true
  2313. }
  2314. }
  2315. if keyWord != "" {
  2316. keyWordItem := new(models.CygxUserSearchKeyWord)
  2317. keyWordItem.UserId = user.UserId
  2318. keyWordItem.KeyWord = keyWord
  2319. keyWordItem.PageType = "ReortSearch"
  2320. keyWordItem.CreateTime = time.Now()
  2321. go models.AddUserSearchKeyWord(keyWordItem)
  2322. go services.AddUserSearchLog(user, keyWord, 5)
  2323. }
  2324. if len(listYx) == 0 {
  2325. listYx = make([]*models.ArticleCollectionResp, 0)
  2326. }
  2327. if len(listHz) == 0 {
  2328. listHz = make([]*models.ArticleCollectionResp, 0)
  2329. }
  2330. resp := new(models.ReoprtSearchResp)
  2331. resp.ListYx = listYx
  2332. resp.ListHz = listHz
  2333. br.Ret = 200
  2334. br.Success = true
  2335. br.Msg = "获取成功"
  2336. br.Data = resp
  2337. }
  2338. // @Title 资源包搜索
  2339. // @Description 资源包搜索接口
  2340. // @Param KeyWord query string true "搜索关键词"
  2341. // @Success 200 {object} models.SearchResourceResp
  2342. // @router /searchResource [get]
  2343. func (this *ReportController) SearchResource() {
  2344. br := new(models.BaseResponse).Init()
  2345. defer func() {
  2346. this.Data["json"] = br
  2347. this.ServeJSON()
  2348. }()
  2349. user := this.User
  2350. if user == nil {
  2351. br.Msg = "请重新登录"
  2352. br.Ret = 408
  2353. return
  2354. }
  2355. uid := user.UserId
  2356. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2357. if err != nil {
  2358. br.Msg = "获取失败"
  2359. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2360. return
  2361. }
  2362. fllowMap := make(map[int]int)
  2363. if len(fllowList) > 0 {
  2364. for _, v := range fllowList {
  2365. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2366. }
  2367. }
  2368. keyWord := this.GetString("KeyWord")
  2369. var condition string
  2370. var conditionOr string
  2371. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2372. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2373. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2374. listHz, err := models.GetSearchResourceList(condition)
  2375. if err != nil {
  2376. br.Msg = "获取信息失败"
  2377. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2378. return
  2379. }
  2380. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2381. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2382. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2383. listYx, err := models.GetSearchResourceList(condition)
  2384. if err != nil {
  2385. br.Msg = "获取信息失败"
  2386. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2387. return
  2388. }
  2389. //合并产业关联的标的
  2390. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2391. if err != nil {
  2392. br.Msg = "获取信息失败"
  2393. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2394. return
  2395. }
  2396. industrialIdArr := make([]int, 0)
  2397. for k, v := range listHz {
  2398. listHz[k].Source = 1
  2399. if fllowMap[v.IndustrialManagementId] > 0 {
  2400. listHz[k].IsFollw = true
  2401. }
  2402. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2403. }
  2404. for k, v := range listYx {
  2405. listYx[k].Source = 2
  2406. if fllowMap[v.IndustrialManagementId] > 0 {
  2407. listYx[k].IsFollw = true
  2408. }
  2409. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2410. }
  2411. if len(industrialIdArr) > 0 {
  2412. //合并产业关联的标的
  2413. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2414. if err != nil {
  2415. br.Msg = "获取信息失败"
  2416. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2417. return
  2418. }
  2419. mapIndustrial := make(map[string]int)
  2420. for _, v := range listSubjcet {
  2421. for k2, v2 := range listYx {
  2422. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2423. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2424. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2425. }
  2426. }
  2427. for k2, v2 := range listHz {
  2428. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2429. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2430. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2431. }
  2432. }
  2433. }
  2434. }
  2435. if keyWord != "" {
  2436. keyWordItem := new(models.CygxUserSearchKeyWord)
  2437. keyWordItem.UserId = user.UserId
  2438. keyWordItem.KeyWord = keyWord
  2439. keyWordItem.PageType = "ReortSearch"
  2440. keyWordItem.CreateTime = time.Now()
  2441. go models.AddUserSearchKeyWord(keyWordItem)
  2442. go services.AddUserSearchLog(user, keyWord, 4)
  2443. }
  2444. resp := new(models.SearchResourceResp)
  2445. if len(listYx) == 0 {
  2446. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2447. }
  2448. if len(listHz) == 0 {
  2449. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2450. }
  2451. resp.ListYx = listYx
  2452. resp.ListHz = listHz
  2453. br.Ret = 200
  2454. br.Success = true
  2455. br.Msg = "获取成功"
  2456. br.Data = resp
  2457. }