report.go 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 报告
  13. type ReportController struct {
  14. BaseAuthController
  15. }
  16. type ReportCommonController struct {
  17. BaseCommonController
  18. }
  19. type MobileReportController struct {
  20. BaseAuthMobileController
  21. }
  22. // @Title 行业报告分类列表接口
  23. // @Description 获取行业报告分类列表接口
  24. // @Param ChartPermissionId query int true "分类ID"
  25. // @Success 200 {object} models.TradeReportMappingResp
  26. // @router /tradeList [get]
  27. func (this *MobileReportController) TradeList() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. user := this.User
  34. if user == nil {
  35. br.Msg = "请重新登录"
  36. br.Ret = 408
  37. return
  38. }
  39. //uid := user.UserId
  40. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  41. if ChartPermissionId < 1 {
  42. br.Msg = "请输入分类ID"
  43. return
  44. }
  45. //var result []*models.SearchItem
  46. var list []*models.TradeReportMapping
  47. var err error
  48. mapCategory := make(map[int]int)
  49. if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
  50. listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
  51. err = errTrade
  52. if ChartPermissionId == utils.CE_LUE_ID {
  53. cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
  54. if err != nil {
  55. br.Msg = "获取失败"
  56. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  57. return
  58. }
  59. if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  60. item := new(models.TradeReportMapping)
  61. item.CategoryId = utils.TIME_LINE_ID
  62. item.MatchTypeName = utils.TIME_LINE_NAME
  63. list = append(list, item)
  64. }
  65. }
  66. for _, v := range listTrade {
  67. list = append(list, v)
  68. }
  69. if user.Mobile != "" {
  70. //策略的处理
  71. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  72. if err != nil && err.Error() != utils.ErrNoRow() {
  73. br.Msg = "获取信息失败"
  74. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  75. return
  76. }
  77. for _, v := range categoryList {
  78. mapCategory[v.IdCygx] = v.IdCygx
  79. }
  80. }
  81. } else {
  82. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  83. if err != nil {
  84. br.Msg = "获取信息失败"
  85. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  86. return
  87. }
  88. categoryMap := make(map[int]int)
  89. for _, v := range listCategory {
  90. if categoryMap[v.CategoryId] > 0 {
  91. continue
  92. }
  93. categoryMap[v.CategoryId] = v.CategoryId
  94. list = append(list, v)
  95. }
  96. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  97. //if ChartPermissionId == utils.KE_JI_ID {
  98. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  99. //}
  100. }
  101. if err != nil {
  102. br.Msg = "获取信息失败"
  103. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  104. return
  105. }
  106. for k, v := range list {
  107. if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
  108. var pageSize int
  109. var listArticle []*models.HomeArticle
  110. pageSize = 3
  111. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  112. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  113. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  114. } else {
  115. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  116. }
  117. if err != nil {
  118. br.Msg = "获取信息失败"
  119. br.Msg = "GetHomeList,Err:" + err.Error()
  120. return
  121. }
  122. if len(listArticle) > 0 {
  123. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  124. }
  125. list[k].ListArticle = listArticle
  126. } else {
  127. if mapCategory[v.CategoryId] > 0 {
  128. list[k].IsFollow = true
  129. }
  130. list[k].ListArticle = make([]*models.HomeArticle, 0)
  131. }
  132. }
  133. resp := new(models.TradeReportMappingResp)
  134. if len(list) == 0 {
  135. list = make([]*models.TradeReportMapping, 0)
  136. }
  137. resp.List = list
  138. br.Ret = 200
  139. br.Success = true
  140. br.Msg = "获取成功"
  141. br.Data = resp
  142. }
  143. // @Title 产业报告分类列表接口
  144. // @Description 获取产业报告分类列表接口
  145. // @Param ChartPermissionId query int true "分类ID"
  146. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  147. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  148. // @Param PageSize query int true "每页数据条数"
  149. // @Param CurrentIndex query int true "当前页页码,从1开始"
  150. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  151. // @Success 200 {object} models.IndustrialManagementList
  152. // @router /industryList [get]
  153. func (this *MobileReportController) IndustryList() {
  154. br := new(models.BaseResponse).Init()
  155. defer func() {
  156. this.Data["json"] = br
  157. this.ServeJSON()
  158. }()
  159. user := this.User
  160. if user == nil {
  161. br.Msg = "请重新登录"
  162. br.Ret = 408
  163. return
  164. }
  165. uid := user.UserId
  166. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  167. orderColumn := this.GetString("OrderColumn")
  168. orderColumnNew := this.GetString("OrderColumn")
  169. isNewLabel := this.GetString("IsNewLabel")
  170. isDeepLabel := this.GetString("IsDeepLabel")
  171. pageSize, _ := this.GetInt("PageSize")
  172. currentIndex, _ := this.GetInt("CurrentIndex")
  173. deepCover, _ := this.GetInt("DeepCover")
  174. recommendFocus, _ := this.GetInt("RecommendFocus")
  175. isBillboard, _ := this.GetBool("IsBillboard", false)
  176. var orderSrt string
  177. var condition string
  178. var startSize int
  179. resp := new(models.IndustrialManagementList)
  180. if pageSize <= 0 {
  181. pageSize = utils.PageSize20
  182. }
  183. if currentIndex <= 0 {
  184. currentIndex = 1
  185. }
  186. startSize = paging.StartIndex(currentIndex, pageSize)
  187. if ChartPermissionId > 0 {
  188. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  189. }
  190. // 获取近一个月产业报告阅读次数最多的产业
  191. var topCond string
  192. var topPars []interface{}
  193. topReadIndustryId := 0
  194. if ChartPermissionId > 0 {
  195. topCond += ` AND chart_permission_id = ?`
  196. topPars = append(topPars, ChartPermissionId)
  197. }
  198. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  199. if e != nil && e.Error() != utils.ErrNoRow() {
  200. br.Msg = "获取信息失败"
  201. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  202. return
  203. }
  204. if topReadIndustry != nil {
  205. topReadIndustryId = topReadIndustry.IndustrialManagementId
  206. }
  207. // 深度覆盖
  208. if deepCover == 1 {
  209. // 查询深标签产业报告数
  210. var deepCondition string
  211. var deepPars []interface{}
  212. deepCondition += ` AND man.is_deep_label = 1`
  213. if ChartPermissionId > 0 {
  214. deepCondition += ` AND man.chart_permission_id = ?`
  215. deepPars = append(deepPars, ChartPermissionId)
  216. }
  217. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  218. if e != nil {
  219. br.Msg = "获取信息失败"
  220. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  221. return
  222. }
  223. deepIdArr := make([]string, 0)
  224. for i := range industryCountList {
  225. if industryCountList[i].ArtNum > 10 {
  226. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  227. }
  228. }
  229. deepIds := strings.Join(deepIdArr, ",")
  230. if deepIds != "" {
  231. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  232. }
  233. }
  234. // 推荐关注
  235. if recommendFocus == 1 {
  236. condition += ` AND man.recommended_index >= 80`
  237. }
  238. var list []*models.IndustrialManagement
  239. total, err := models.GetIndustrialManagementAllCount(condition)
  240. if err != nil {
  241. br.Msg = "获取信息失败"
  242. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  243. return
  244. }
  245. if orderColumn == "" {
  246. orderColumn = "NewTime"
  247. }
  248. if orderColumn == "NewTime" {
  249. orderSrt = "update_time DESC"
  250. } else {
  251. orderSrt = "man.recommended_index DESC,update_time DESC"
  252. }
  253. if isBillboard {
  254. // 查询有已归类行业报告的行业IDs
  255. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  256. if e != nil {
  257. br.Msg = "获取失败"
  258. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  259. return
  260. }
  261. activeIndustryLen := len(activeIndustryIds)
  262. //topNum := pageSize
  263. condition = ""
  264. var parsBd []interface{}
  265. if ChartPermissionId > 0 {
  266. condition += ` AND man.chart_permission_id = ? `
  267. parsBd = append(parsBd, ChartPermissionId)
  268. }
  269. if activeIndustryLen > 0 {
  270. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  271. parsBd = append(parsBd, activeIndustryIds)
  272. }
  273. //nowTime := time.Now().Local()
  274. //startTime := nowTime.AddDate(0, -1, 0)
  275. //endTime := nowTime.AddDate(0, 0, -1)
  276. //condition += ` AND idf.create_time BETWEEN ? AND ?`
  277. //parsBd = append(parsBd, startTime, endTime)
  278. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  279. if e != nil {
  280. br.Msg = "获取失败"
  281. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  282. return
  283. }
  284. } else {
  285. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  286. if err != nil {
  287. br.Msg = "获取信息失败"
  288. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  289. return
  290. }
  291. }
  292. var resource string
  293. if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  294. resource = utils.REOURCE_YX
  295. } else {
  296. resource = utils.REOURCE_HZ
  297. }
  298. list, err = services.HandleIndustryList(list, user, resource)
  299. if err != nil {
  300. br.Msg = "获取信息失败"
  301. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  302. return
  303. }
  304. industrialIdArr := make([]int, 0)
  305. for k, v := range list {
  306. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  307. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  308. list[k].IsHot = true
  309. }
  310. }
  311. if orderColumnNew != "" {
  312. item := new(models.CygxReportIndustrialSeaarchHistory)
  313. item.UserId = user.UserId
  314. item.Mobile = user.Mobile
  315. item.CompanyId = user.CompanyId
  316. item.CompanyName = user.CompanyName
  317. item.CreateTime = time.Now()
  318. item.IsDeepLabel = isDeepLabel
  319. item.IsNewLabel = isNewLabel
  320. item.ChartPermissionId = ChartPermissionId
  321. if orderColumnNew == "NewTime" {
  322. item.OrderColumn = "0"
  323. } else {
  324. item.OrderColumn = "1"
  325. }
  326. go models.AddCygxReportIndustrialSeaarchHistory(item)
  327. }
  328. if len(list) == 0 {
  329. list = make([]*models.IndustrialManagement, 0)
  330. }
  331. page := paging.GetPaging(currentIndex, pageSize, total)
  332. if isBillboard {
  333. total = len(list)
  334. }
  335. resp.List = list
  336. resp.Paging = page
  337. br.Ret = 200
  338. br.Success = true
  339. br.Msg = "获取成功"
  340. br.Data = resp
  341. }
  342. // @Title 产业下所关联的文章分类列表
  343. // @Description 产业下所关联的文章分类列表接口
  344. // @Param IndustrialManagementId query int true "产业ID"
  345. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  346. // @router /toArticleCategoryList [get]
  347. func (this *MobileReportController) ArticleCategoryList() {
  348. br := new(models.BaseResponse).Init()
  349. defer func() {
  350. this.Data["json"] = br
  351. this.ServeJSON()
  352. }()
  353. user := this.User
  354. if user == nil {
  355. br.Msg = "请重新登录"
  356. br.Ret = 408
  357. return
  358. }
  359. //uid := user.UserId
  360. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  361. if industrialManagementId < 1 {
  362. br.Msg = "请输入分类ID"
  363. return
  364. }
  365. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  366. if err != nil {
  367. br.Msg = "获取信息失败"
  368. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  369. return
  370. }
  371. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  372. if err != nil {
  373. br.Msg = "获取信息失败"
  374. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  375. return
  376. }
  377. var list []*models.IndustrialToArticleCategoryRep
  378. categoryMap := make(map[int]int)
  379. for _, v := range listCategory {
  380. if categoryMap[v.CategoryId] > 0 {
  381. continue
  382. }
  383. categoryMap[v.CategoryId] = v.CategoryId
  384. list = append(list, v)
  385. }
  386. //标的列表
  387. industrialSubjectList, err := models.GetIndustrialArticleGroupSubjectListByHz(industrialManagementId)
  388. if err != nil {
  389. br.Msg = "获取信息失败"
  390. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  391. return
  392. }
  393. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  394. if err != nil {
  395. br.Msg = "获取失败"
  396. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  397. return
  398. }
  399. timeLineItem := models.IndustrialToArticleCategoryRep{
  400. CategoryId: utils.TIME_CATEGORYID,
  401. MatchTypeName: "时间线",
  402. }
  403. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  404. if err != nil {
  405. br.Msg = "获取失败"
  406. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  407. return
  408. }
  409. timeLineItem.IsRed = timeLineIsRed
  410. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  411. resp := new(models.IndustrialToArticleCategoryListRep)
  412. resp.List = list
  413. resp.ListSubject = industrialSubjectList
  414. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  415. resp.IndustryName = detail.IndustryName
  416. resp.IndustrialManagementId = industrialManagementId
  417. if videoSimple != nil && videoSimple.Id > 0 {
  418. resp.IndustryVideo = videoSimple
  419. }
  420. resp.AuthInfo = au
  421. br.Ret = 200
  422. br.Success = true
  423. br.Msg = "获取成功"
  424. br.Data = resp
  425. }
  426. // @Title 根据行业分类获取文章列表
  427. // @Description根据行业分类获取文章列表接口
  428. // @Param PageSize query int true "每页数据条数"
  429. // @Param CurrentIndex query int true "当前页页码,从1开始"
  430. // @Param CategoryId query int true "分类ID"
  431. // @Param IndustrialManagementId query int false "产业ID"
  432. // @Success 200 {object} models.TacticsListResp
  433. // @router /articleList/byCategoryId [get]
  434. func (this *MobileReportController) List() {
  435. br := new(models.BaseResponse).Init()
  436. defer func() {
  437. this.Data["json"] = br
  438. this.ServeJSON()
  439. }()
  440. user := this.User
  441. if user == nil {
  442. br.Msg = "请重新登录"
  443. br.Ret = 408
  444. return
  445. }
  446. //uid := user.UserId
  447. pageSize, _ := this.GetInt("PageSize")
  448. currentIndex, _ := this.GetInt("CurrentIndex")
  449. categoryId, _ := this.GetInt("CategoryId")
  450. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  451. uid := user.UserId
  452. var startSize int
  453. if pageSize <= 0 {
  454. pageSize = utils.PageSize20
  455. }
  456. if currentIndex <= 0 {
  457. currentIndex = 1
  458. }
  459. startSize = paging.StartIndex(currentIndex, pageSize)
  460. //var condition string
  461. var pars []interface{}
  462. var total int
  463. resp := new(models.TacticsListResp)
  464. page := paging.GetPaging(currentIndex, pageSize, total)
  465. list := make([]*models.ArticleListResp, 0)
  466. if categoryId == utils.TIME_CATEGORYID {
  467. var err error
  468. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  469. if err != nil {
  470. br.Msg = "获取信息失败"
  471. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  472. return
  473. }
  474. } else {
  475. //获取该产业下所对应的行业图片
  476. //var reportType int
  477. //if industrialManagementId > 0 {
  478. // reportType = 2
  479. //} else {
  480. // reportType = 1
  481. //}
  482. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  483. //if errCategory != nil {
  484. // br.Msg = "获取信息失败"
  485. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  486. // return
  487. //}
  488. //对应行业的图片
  489. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  490. if err != nil {
  491. br.Msg = "获取数据失败"
  492. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  493. return
  494. }
  495. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  496. mapChartPermission := make(map[string]string)
  497. var permissionName string
  498. var imgUrlChartPermission string
  499. for _, v := range chartPermissionUrlList {
  500. vslice := strings.Split(v, "_")
  501. permissionName = vslice[0]
  502. imgUrlChartPermission = vslice[len(vslice)-1]
  503. mapChartPermission[permissionName] = imgUrlChartPermission
  504. }
  505. //对应分类的所图片
  506. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  513. mapCategoryUrl := make(map[string]string)
  514. var categoryIdStr string
  515. var imgUrlChart string
  516. for _, v := range categoryUrlList {
  517. vslice := strings.Split(v, "_")
  518. categoryIdStr = vslice[0]
  519. imgUrlChart = vslice[len(vslice)-1]
  520. mapCategoryUrl[categoryIdStr] = imgUrlChart
  521. }
  522. list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  523. if err != nil {
  524. br.Msg = "获取信息失败"
  525. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  526. return
  527. }
  528. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  529. if err != nil {
  530. br.Msg = "获取信息失败"
  531. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  532. return
  533. }
  534. for k, v := range list {
  535. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  536. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  537. list[k].IsRed = true
  538. }
  539. }
  540. }
  541. listPublic, err := services.HandleArticleCategoryImg(list, user)
  542. if err != nil {
  543. br.Msg = "获取失败"
  544. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  545. return
  546. }
  547. var articleIds []int
  548. for _, v := range listPublic {
  549. if v.Resource == 1 {
  550. articleIds = append(articleIds, v.ArticleId)
  551. }
  552. }
  553. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  554. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  555. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  556. listResp := make([]*models.HomeArticle, 0)
  557. //listResp :=
  558. for _, v := range listPublic {
  559. listResp = append(listResp, &models.HomeArticle{
  560. ArticleId: v.ArticleId,
  561. Title: v.Title,
  562. Annotation: "核心观点:" + v.Annotation,
  563. Abstract: v.Abstract,
  564. ImgUrlPc: v.ImgUrlPc,
  565. PublishDate: v.PublishDate,
  566. Resource: v.Resource,
  567. Pv: articleMapPv[v.ArticleId],
  568. IsCollect: articleCollectMap[v.ArticleId],
  569. CollectNum: articleCollectNumMap[v.ArticleId],
  570. })
  571. }
  572. //lenList := len(list)
  573. //for i := 0; i < lenList; i++ {
  574. // item := list[i]
  575. // list[i].Body = ""
  576. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  577. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  578. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  579. // //行业比较研究、资金流向,显示报告的摘要
  580. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  581. // list[i].Annotation = list[i].Abstract
  582. // }
  583. //}
  584. if len(listResp) == 0 {
  585. listResp = make([]*models.HomeArticle, 0)
  586. }
  587. page = paging.GetPaging(currentIndex, pageSize, total)
  588. resp.List = listResp
  589. resp.Paging = page
  590. br.Ret = 200
  591. br.Success = true
  592. br.Msg = "获取成功"
  593. br.Data = resp
  594. }
  595. // @Title 产业关注/取消关注
  596. // @Description 产业关注/取消关注 接口
  597. // @Param request body models.CygxIndustryFllowRep true "type json string"
  598. // @Success 200
  599. // @router /industrial/fllow [post]
  600. func (this *ReportController) IndustrialFllow() {
  601. br := new(models.BaseResponse).Init()
  602. defer func() {
  603. this.Data["json"] = br
  604. this.ServeJSON()
  605. }()
  606. user := this.User
  607. if user == nil {
  608. br.Msg = "请重新登录"
  609. br.Ret = 408
  610. return
  611. }
  612. uid := user.UserId
  613. var req models.CygxIndustryFllowRep
  614. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  615. if err != nil {
  616. br.Msg = "参数解析异常!"
  617. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  618. return
  619. }
  620. industrialManagementId := req.IndustrialManagementId
  621. var condition string
  622. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  623. if err != nil {
  624. br.Msg = "获取数据失败!"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. if countIndustrial == 0 {
  629. br.Msg = "产业不存在!"
  630. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  631. return
  632. }
  633. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  634. if err != nil {
  635. br.Msg = "获取数据失败!"
  636. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  637. return
  638. }
  639. resp := new(models.CygxIndustryFllowResp)
  640. item := new(models.CygxIndustryFllow)
  641. item.IndustrialManagementId = industrialManagementId
  642. item.UserId = uid
  643. item.Email = user.Email
  644. item.Mobile = user.Mobile
  645. item.RealName = user.RealName
  646. item.Source = utils.REGISTER_PLATFORM
  647. item.CompanyId = user.CompanyId
  648. item.CompanyName = user.CompanyName
  649. if count == 0 {
  650. item.Type = 1
  651. item.CreateTime = time.Now()
  652. item.ModifyTime = time.Now()
  653. _, err = models.AddCygxIndustryFllow(item)
  654. if err != nil {
  655. br.Msg = "操作失败"
  656. br.ErrMsg = "操作失败,Err:" + err.Error()
  657. return
  658. }
  659. resp.Status = 1
  660. br.Msg = "关注成功"
  661. } else {
  662. item.Type = 2
  663. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  664. if err != nil {
  665. br.Msg = "操作失败"
  666. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  667. return
  668. }
  669. resp.Status = 2
  670. br.Msg = "已取消关注"
  671. }
  672. //处理是否关注全部赛道字段
  673. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  674. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  675. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  676. br.Ret = 200
  677. br.Success = true
  678. br.Data = resp
  679. }
  680. // @Title 行业关注/取消关注
  681. // @Description 行业关注/取消关注 接口
  682. // @Param request body models.CygxCategoryFllowRep true "type json string"
  683. // @Success 200
  684. // @router /category/fllow [post]
  685. func (this *ReportController) CategoryFllow() {
  686. br := new(models.BaseResponse).Init()
  687. defer func() {
  688. this.Data["json"] = br
  689. this.ServeJSON()
  690. }()
  691. user := this.User
  692. if user == nil {
  693. br.Msg = "请重新登录"
  694. br.Ret = 408
  695. return
  696. }
  697. uid := user.UserId
  698. var req models.CygxCategoryFllowRep
  699. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  700. if err != nil {
  701. br.Msg = "参数解析异常!"
  702. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  703. return
  704. }
  705. categoryId := req.CategoryId
  706. var condition string
  707. //countCategory, err := models.GetCategoryCount(categoryId)
  708. //if err != nil {
  709. // br.Msg = "获取数据失败!"
  710. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  711. // return
  712. //}
  713. //if countCategory == 0 {
  714. // br.Msg = "产业不存在!"
  715. // br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  716. // return
  717. //}
  718. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  719. if err != nil {
  720. br.Msg = "操作失败!"
  721. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  722. return
  723. }
  724. mapReport := make(map[int]int)
  725. for _, v := range listMap {
  726. mapReport[v.Id] = v.CategoryId
  727. }
  728. if mapReport[categoryId] == 0 {
  729. br.Msg = "操作失败!"
  730. br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
  731. return
  732. }
  733. count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
  734. if err != nil {
  735. br.Msg = "获取数据失败!"
  736. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. return
  738. }
  739. resp := new(models.CygxIndustryFllowResp)
  740. if count == 0 {
  741. item := new(models.CygxXzsChooseCategory)
  742. item.CategoryId = mapReport[categoryId]
  743. item.IdCygx = categoryId
  744. item.UserId = uid
  745. item.Email = user.Email
  746. item.Mobile = user.Mobile
  747. item.RealName = user.RealName
  748. item.CompanyId = user.CompanyId
  749. item.CompanyName = user.CompanyName
  750. item.CreateTime = time.Now()
  751. item.ModifyTime = time.Now()
  752. _, err = models.AddCygxCategoryFllow(item)
  753. if err != nil {
  754. br.Msg = "操作失败"
  755. br.ErrMsg = "操作失败,Err:" + err.Error()
  756. return
  757. }
  758. resp.Status = 1
  759. br.Msg = "关注成功"
  760. } else {
  761. err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
  762. if err != nil {
  763. br.Msg = "操作失败"
  764. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  765. return
  766. }
  767. resp.Status = 2
  768. br.Msg = "已取消关注"
  769. }
  770. go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
  771. br.Ret = 200
  772. br.Success = true
  773. br.Data = resp
  774. }
  775. // @Title 报告搜索
  776. // @Description 报告搜索接口
  777. // @Param PageSize query int true "每页数据条数"
  778. // @Param CurrentIndex query int true "当前页页码,从1开始"
  779. // @Param KeyWord query string true "搜索关键词"
  780. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  781. // @Param IsAll query bool true "是否为综合 "
  782. // @Success 200 {object} models.ReoprtSearchResp
  783. // @router /searchReport [get]
  784. func (this *MobileReportController) SearchReport() {
  785. br := new(models.BaseResponse).Init()
  786. defer func() {
  787. this.Data["json"] = br
  788. this.ServeJSON()
  789. }()
  790. user := this.User
  791. if user == nil {
  792. br.Msg = "请重新登录"
  793. br.Ret = 408
  794. return
  795. }
  796. pageSize, _ := this.GetInt("PageSize")
  797. currentIndex, _ := this.GetInt("CurrentIndex")
  798. //articleType, _ := this.GetInt("ArticleType", 1)
  799. keyWord := this.GetString("KeyWord")
  800. //isAll, _ := this.GetBool("IsAll")
  801. var condition string
  802. var conditionYxSpecial string
  803. var pars []interface{}
  804. //var conditionSql string
  805. var total int
  806. var startSize int
  807. if pageSize <= 0 {
  808. pageSize = utils.PageSize20
  809. }
  810. //if isAll {
  811. // pageSize = utils.PageSize5
  812. //}
  813. if currentIndex <= 0 {
  814. currentIndex = 1
  815. }
  816. startSize = paging.StartIndex(currentIndex, pageSize)
  817. resp := new(models.ReoprtSearchResp)
  818. //匹配报告标题、
  819. //articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  820. //if err != nil {
  821. // br.Msg = "获取信息失败"
  822. // br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  823. // return
  824. //}
  825. //if articleTypeIds == "" {
  826. // br.Msg = "获取信息失败"
  827. // br.ErrMsg = "研选分类ID不能为空"
  828. // return
  829. //}
  830. //处理对应的文章类型标签按钮
  831. nameMap, styleMap, err := services.GetArticleTypeMap()
  832. if err != nil {
  833. br.Msg = "获取信息失败"
  834. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  835. return
  836. }
  837. if keyWord != "" {
  838. //if articleType == 1 {
  839. // 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 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  840. // total, err = models.GetReoprtSearchCountHz(condition)
  841. //} else {
  842. // 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 AND a.article_type_id IN (` + articleTypeIds + `) `
  843. // total, err = models.GetReoprtSearchCountYx(condition)
  844. //}
  845. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body_text LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  846. conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
  847. }
  848. if err != nil {
  849. br.Msg = "获取信息失败"
  850. br.Msg = "获取总数失败,Err:" + err.Error()
  851. return
  852. }
  853. var list []*models.ArticleListResp
  854. //list := new([]models.ArticleResearchResp)
  855. //if articleType == 1 {
  856. // list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  857. //} else {
  858. // total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  859. //}
  860. total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  861. if err != nil {
  862. br.Msg = "获取信息失败"
  863. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  864. return
  865. }
  866. //return
  867. list, err = services.HandleArticleCategoryImg(list, user)
  868. if err != nil {
  869. br.Msg = "获取信息失败"
  870. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  871. return
  872. }
  873. for _, v := range list {
  874. item := models.ArticleResearchResp{
  875. ArticleId: v.ArticleId,
  876. ArticleTypeId: v.ArticleTypeId,
  877. Title: v.Title,
  878. PublishDate: v.PublishDate,
  879. DepartmentId: v.DepartmentId,
  880. NickName: v.NickName,
  881. IsCollect: v.IsCollect,
  882. Pv: v.Pv,
  883. CollectNum: v.CollectNum,
  884. Abstract: v.Abstract,
  885. Annotation: v.Annotation,
  886. ImgUrlPc: v.ImgUrlPc,
  887. ArticleTypeName: nameMap[v.ArticleTypeId],
  888. ButtonStyle: styleMap[v.ArticleTypeId],
  889. List: v.List,
  890. }
  891. if v.IsSpecial == 1 {
  892. //去除图片标签
  893. item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
  894. item.IsSpecial = true
  895. item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
  896. if v.CompanyTags != "" {
  897. item.CompanyTags = strings.Split(v.CompanyTags, ",")
  898. } else {
  899. item.CompanyTags = []string{}
  900. }
  901. if v.IndustryTags != "" {
  902. item.IndustryTags = strings.Split(v.IndustryTags, ",")
  903. } else {
  904. item.IndustryTags = []string{}
  905. }
  906. item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  907. if v.SpecialType == 1 {
  908. item.Title = "【笔记】" + item.Title
  909. } else if v.SpecialType == 2 {
  910. item.Title = "【观点】" + item.Title
  911. }
  912. if v.MyCollectNum > 0 {
  913. item.IsCollect = true
  914. }
  915. item.Resource = 2
  916. item.ResourceObj = "articlespecial"
  917. } else {
  918. if v.ReportId > 0 {
  919. item.Resource = 3
  920. item.ReportId = v.ReportId
  921. item.ResourceObj = "articleficc"
  922. } else {
  923. item.Resource = 1
  924. if v.ArticleTypeId > 0 {
  925. item.ResourceObj = "articleyx"
  926. } else {
  927. item.ResourceObj = "articlevmp"
  928. }
  929. }
  930. }
  931. resp.ListHz = append(resp.ListHz, &item)
  932. //if articleType == 1 {
  933. // resp.ListHz = append(resp.ListHz, &item)
  934. //} else {
  935. // resp.ListYx = append(resp.ListYx, &item)
  936. //}
  937. }
  938. //if keyWord != "" {
  939. //go services.AddUserSearchLog(user, keyWord, 5)
  940. //}
  941. if len(resp.ListHz) == 0 {
  942. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  943. }
  944. if len(resp.ListYx) == 0 {
  945. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  946. }
  947. page := paging.GetPaging(currentIndex, pageSize, total)
  948. resp.Paging = page
  949. br.Ret = 200
  950. br.Success = true
  951. br.Msg = "获取成功"
  952. br.Data = resp
  953. }
  954. // @Title 资源包搜索
  955. // @Description 资源包搜索接口
  956. // @Param KeyWord query string true "搜索关键词"
  957. // @Success 200 {object} models.SearchResourceResp
  958. // @router /searchResource [get]
  959. func (this *MobileReportController) SearchResource() {
  960. br := new(models.BaseResponse).Init()
  961. defer func() {
  962. this.Data["json"] = br
  963. this.ServeJSON()
  964. }()
  965. user := this.User
  966. if user == nil {
  967. br.Msg = "请重新登录"
  968. br.Ret = 408
  969. return
  970. }
  971. uid := user.UserId
  972. fllowList, err := models.GetUserFllowIndustrialList(uid)
  973. if err != nil {
  974. br.Msg = "获取失败"
  975. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  976. return
  977. }
  978. fllowMap := make(map[int]int)
  979. if len(fllowList) > 0 {
  980. for _, v := range fllowList {
  981. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  982. }
  983. }
  984. keyWord := this.GetString("KeyWord")
  985. var condition string
  986. //articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  987. //if err != nil {
  988. // br.Msg = "获取信息失败"
  989. // br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  990. // return
  991. //}
  992. //if articleTypeIds == "" {
  993. // br.Msg = "获取信息失败"
  994. // br.ErrMsg = "研选分类ID不能为空"
  995. // return
  996. //}
  997. condition = ` AND a.publish_status = 1 AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  998. listHz, err := models.GetSearchResourceList(condition)
  999. if err != nil {
  1000. br.Msg = "获取信息失败"
  1001. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1002. return
  1003. }
  1004. //condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1005. //listYx, err := models.GetSearchResourceList(condition)
  1006. //if err != nil {
  1007. // br.Msg = "获取信息失败"
  1008. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1009. // return
  1010. //}
  1011. //if len(listYx) > 0 {
  1012. // listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1013. // if err != nil {
  1014. // br.Msg = "获取信息失败"
  1015. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1016. // return
  1017. // }
  1018. //}
  1019. if len(listHz) > 0 {
  1020. listHz, err = services.HandleIndustryListHzAndYx(listHz, user, "Hz")
  1021. if err != nil {
  1022. br.Msg = "获取信息失败"
  1023. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1024. return
  1025. }
  1026. }
  1027. //if keyWord != "" {
  1028. //go services.AddUserSearchLog(user, keyWord, 4)
  1029. //}
  1030. resp := new(models.SearchResourceResp)
  1031. if len(listHz) == 0 {
  1032. listHz = make([]*models.IndustrialManagement, 0)
  1033. }
  1034. //if len(listYx) == 0 {
  1035. // listYx = make([]*models.IndustrialManagement, 0)
  1036. //}
  1037. resp.ListHz = listHz
  1038. resp.ListYx = make([]*models.IndustrialManagement, 0)
  1039. br.Ret = 200
  1040. br.Success = true
  1041. br.Msg = "获取成功"
  1042. br.Data = resp
  1043. }
  1044. // @Title 报告搜索、资源包搜索接口
  1045. // @Description 报告搜索、资源包搜索接口接口
  1046. // @Param KeyWord query string true "搜索关键词"
  1047. // @Param PageSize query int true "每页数据条数"
  1048. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1049. // @Param SearchType query int true "1:综合,2:全部"
  1050. // @Success 200 {object} models.SearchReportAndResourceResp
  1051. // @router /searchReportAndResource [get]
  1052. func (this *MobileReportController) SearchReportAndResource() {
  1053. br := new(models.BaseResponse).Init()
  1054. defer func() {
  1055. this.Data["json"] = br
  1056. this.ServeJSON()
  1057. }()
  1058. user := this.User
  1059. if user == nil {
  1060. br.Msg = "请重新登录"
  1061. br.Ret = 408
  1062. return
  1063. }
  1064. //uid := user.UserId
  1065. keyWord := this.GetString("KeyWord")
  1066. pageSize, _ := this.GetInt("PageSize")
  1067. currentIndex, _ := this.GetInt("CurrentIndex")
  1068. searchType, _ := this.GetInt("SearchType")
  1069. var total int
  1070. var startSize int
  1071. if pageSize <= 0 {
  1072. pageSize = utils.PageSize20
  1073. }
  1074. if currentIndex <= 0 {
  1075. currentIndex = 1
  1076. }
  1077. startSize = paging.StartIndex(currentIndex, pageSize)
  1078. page := paging.GetPaging(currentIndex, pageSize, total)
  1079. var condition string
  1080. var conditionSql string
  1081. //匹配报告标题、
  1082. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1083. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1084. total, err := models.GetReoprtSearchCount(conditionSql)
  1085. if err != nil {
  1086. br.Msg = "获取信息失败"
  1087. br.Msg = "获取总数失败,Err:" + err.Error()
  1088. return
  1089. }
  1090. if searchType == 1 {
  1091. pageSize = utils.PageSize5
  1092. }
  1093. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1094. if err != nil {
  1095. br.Msg = "获取失败"
  1096. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1097. return
  1098. }
  1099. if len(ListHzReport) == 0 {
  1100. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1101. }
  1102. var conditionOr string
  1103. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1104. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1105. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1106. if err != nil {
  1107. br.Msg = "获取信息失败"
  1108. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1109. return
  1110. }
  1111. resp := new(models.SearchReportAndResourceResp)
  1112. if len(listHzResource) == 0 {
  1113. listHzResource = make([]*models.IndustrialManagement, 0)
  1114. }
  1115. if keyWord != "" {
  1116. //go services.AddUserSearchLog(user, keyWord, 5)
  1117. }
  1118. page = paging.GetPaging(currentIndex, pageSize, total)
  1119. resp.Paging = page
  1120. resp.ListHzResource = listHzResource
  1121. resp.ListHzReport = ListHzReport
  1122. br.Ret = 200
  1123. br.Success = true
  1124. br.Msg = "获取成功"
  1125. br.Data = resp
  1126. }
  1127. // @Title 公司速览
  1128. // @Description 公司速览接口
  1129. // @Param ChartPermissionId query int false "分类ID"
  1130. // @Success 200 {object} models.ArticleDataLogoListResp
  1131. // @router /companyList [get]
  1132. func (this *ReportCommonController) CompanyList() {
  1133. br := new(models.BaseResponse).Init()
  1134. defer func() {
  1135. this.Data["json"] = br
  1136. this.ServeJSON()
  1137. }()
  1138. var condition string
  1139. var pars []interface{}
  1140. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1141. if chartPermissionId > 1 {
  1142. categoryId, err := models.GetCategoryId(chartPermissionId)
  1143. if err != nil && err.Error() != utils.ErrNoRow() {
  1144. br.Msg = "获取信息失败"
  1145. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. if categoryId != "" {
  1149. condition += ` AND a.category_id IN (` + categoryId + `)`
  1150. }
  1151. }
  1152. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1153. list, err := models.CygxArticleDataList(condition, pars)
  1154. if err != nil {
  1155. br.Msg = "获取失败"
  1156. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1157. return
  1158. }
  1159. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1160. for i := range list {
  1161. v := list[i]
  1162. comapnyList := services.HandleArticleStock(v.Stock)
  1163. if len(comapnyList) > 1 {
  1164. for kC, vC := range comapnyList {
  1165. sliceCovers := strings.Split(v.Cover, "{|}")
  1166. cover := v.Cover
  1167. if len(sliceCovers) == len(comapnyList) {
  1168. cover = sliceCovers[kC]
  1169. }
  1170. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1171. ArticleId: v.ArticleId,
  1172. Cover: cover,
  1173. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1174. })
  1175. }
  1176. } else {
  1177. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1178. ArticleId: v.ArticleId,
  1179. Cover: v.Cover,
  1180. ComapnyList: services.HandleArticleStock(v.Stock),
  1181. })
  1182. }
  1183. }
  1184. resp := new(models.ArticleDataLogoListResp)
  1185. resp.List = listLogo
  1186. br.Ret = 200
  1187. br.Success = true
  1188. br.Msg = "获取成功"
  1189. br.Data = resp
  1190. }
  1191. // @Title 时间线
  1192. // @Description 时间线接口
  1193. // @Param PageSize query int true "每页数据条数"
  1194. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1195. // @Param IndustrialManagementId query int false "产业ID"
  1196. // @Success 200 {object} models.TacticsListResp
  1197. // @router /timeline [get]
  1198. func (this *MobileReportController) Timeline() {
  1199. br := new(models.BaseResponse).Init()
  1200. defer func() {
  1201. this.Data["json"] = br
  1202. this.ServeJSON()
  1203. }()
  1204. user := this.User
  1205. if user == nil {
  1206. br.Msg = "请重新登录"
  1207. br.Ret = 408
  1208. return
  1209. }
  1210. pageSize, _ := this.GetInt("PageSize")
  1211. currentIndex, _ := this.GetInt("CurrentIndex")
  1212. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1213. var startSize int
  1214. if pageSize <= 0 {
  1215. pageSize = utils.PageSize20
  1216. }
  1217. if currentIndex <= 0 {
  1218. currentIndex = 1
  1219. }
  1220. startSize = paging.StartIndex(currentIndex, pageSize)
  1221. var total int
  1222. resp := new(models.TacticsListTimeResp)
  1223. page := paging.GetPaging(currentIndex, pageSize, total)
  1224. list := make([]*models.TimeLineReportItem, 0)
  1225. var err error
  1226. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1227. if err != nil {
  1228. br.Msg = "获取信息失败"
  1229. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1230. return
  1231. }
  1232. //处理晨会精华关联的标的,以及要跳转的文章ID
  1233. var meetingreviewchaptIds []int
  1234. var articleIds []int
  1235. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1236. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1237. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  1238. for _, v := range list {
  1239. if v.Resource == 3 {
  1240. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1241. }
  1242. if v.Resource == 1 {
  1243. articleIds = append(articleIds, v.ArticleId)
  1244. }
  1245. }
  1246. if len(meetingreviewchaptIds) > 0 {
  1247. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1248. if err != nil {
  1249. br.Msg = "获取失败"
  1250. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1251. }
  1252. for _, v := range listMeet {
  1253. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1254. mapchaptIdListSubject[v.Id] = v.ListSubject
  1255. }
  1256. }
  1257. if len(articleIds) > 0 {
  1258. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  1259. }
  1260. //查询用户今天是否看过时间线
  1261. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1262. //if err != nil {
  1263. // br.Msg = "查询浏览记录数量失败"
  1264. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1265. // return
  1266. //}
  1267. //var recordItem *models.CygxPageHistoryRecord
  1268. //if count > 1 {
  1269. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1270. // if err != nil {
  1271. // br.Msg = "查询浏览记录失败"
  1272. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1273. // return
  1274. // }
  1275. //}
  1276. for k, v := range list {
  1277. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1278. list[k].IsRed = true
  1279. }
  1280. //timeLineRed := false
  1281. //if count < 2 && v.SubCategoryName == "时间线" {
  1282. // timeLineRed = true
  1283. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1284. // timeLineRed = true
  1285. //}
  1286. //if v.SubCategoryName == "时间线" && timeLineRed {
  1287. list[k].IsRed = true
  1288. //}
  1289. if v.VideoUrl != "" {
  1290. list[k].IsHaveVideo = true
  1291. }
  1292. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1293. if v.Resource == 3 {
  1294. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1295. v.ListSubject = mapchaptIdListSubject[v.Id]
  1296. }
  1297. if v.Resource == 1 {
  1298. v.ListSubject = mapArticleIdListSubject[v.Id]
  1299. }
  1300. }
  1301. //添加我的日程访问记录
  1302. item := new(models.CygxPageHistoryRecord)
  1303. item.UserId = user.UserId
  1304. item.CreateTime = time.Now()
  1305. item.CompanyId = user.CompanyId
  1306. item.CompanyName = user.CompanyName
  1307. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1308. go models.AddCygxPageHistoryRecord(item)
  1309. if len(list) == 0 {
  1310. list = make([]*models.TimeLineReportItem, 0)
  1311. }
  1312. go services.AddCygxTimelineLog(user, industrialManagementId)
  1313. page = paging.GetPaging(currentIndex, pageSize, total)
  1314. resp.List = list
  1315. resp.Paging = page
  1316. br.Ret = 200
  1317. br.Success = true
  1318. br.Msg = "获取成功"
  1319. br.Data = resp
  1320. }
  1321. // @Title 文章留言接口
  1322. // @Description 文章留言接口
  1323. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1324. // @Success 200 {object} models.TacticsListResp
  1325. // @router /commentAdd [post]
  1326. func (this *ReportController) CommentAdd() {
  1327. br := new(models.BaseResponse).Init()
  1328. defer func() {
  1329. this.Data["json"] = br
  1330. this.ServeJSON()
  1331. }()
  1332. user := this.User
  1333. if user == nil {
  1334. br.Msg = "请重新登录"
  1335. br.Ret = 408
  1336. return
  1337. }
  1338. var req models.AddCygxArticleCommentReq
  1339. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1340. if err != nil {
  1341. br.Msg = "参数解析异常!"
  1342. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1343. return
  1344. }
  1345. if req.ArticleId <= 0 {
  1346. br.Msg = "文章不存在"
  1347. br.ErrMsg = "文章不存在,文章ID错误"
  1348. return
  1349. }
  1350. if req.Content == "" {
  1351. br.Msg = "建议内容不可为空"
  1352. return
  1353. }
  1354. content := req.Content
  1355. if content == "" {
  1356. br.Msg = "留言内容不能为空!"
  1357. return
  1358. }
  1359. //itemToken, err := services.WxGetToken()
  1360. //if err != nil {
  1361. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1362. // return
  1363. //}
  1364. //if itemToken.AccessToken == "" {
  1365. // br.Msg = "accessToken is empty"
  1366. // return
  1367. //}
  1368. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1369. //if err != nil {
  1370. // br.Msg = "内容校验失败!"
  1371. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1372. // return
  1373. //}
  1374. //if commerr.ErrCode != 0 {
  1375. // br.Msg = "内容违规,请重新提交!"
  1376. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1377. // return
  1378. //}
  1379. articleId := req.ArticleId
  1380. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1381. if articleInfo == nil {
  1382. br.Msg = "操作失败"
  1383. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1384. return
  1385. }
  1386. if errInfo != nil {
  1387. br.Msg = "操作失败"
  1388. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1389. return
  1390. }
  1391. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1392. if err != nil {
  1393. br.Msg = "提交失败!"
  1394. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1395. return
  1396. }
  1397. if companyDetail == nil {
  1398. br.Msg = "提交失败!"
  1399. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1400. return
  1401. }
  1402. item := models.CygxArticleComment{
  1403. UserId: user.UserId,
  1404. ArticleId: req.ArticleId,
  1405. CreateTime: time.Now(),
  1406. Mobile: user.Mobile,
  1407. Email: user.Email,
  1408. CompanyId: user.CompanyId,
  1409. CompanyName: companyDetail.CompanyName,
  1410. Content: content,
  1411. Title: articleInfo.Title,
  1412. }
  1413. msgId, err := models.AddArticleComment(&item)
  1414. if err != nil {
  1415. br.Msg = "提交失败"
  1416. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1417. return
  1418. }
  1419. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1420. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  1421. br.Ret = 200
  1422. br.Success = true
  1423. br.Msg = "提交成功"
  1424. }
  1425. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1426. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1427. // @Param PageSize query int true "每页数据条数"
  1428. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1429. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1430. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1431. // @router /reportList/byType [get]
  1432. func (this *ReportController) ReportListByType() {
  1433. br := new(models.BaseResponse).Init()
  1434. defer func() {
  1435. this.Data["json"] = br
  1436. this.ServeJSON()
  1437. }()
  1438. user := this.User
  1439. if user == nil {
  1440. br.Msg = "请重新登录"
  1441. br.Ret = 408
  1442. return
  1443. }
  1444. uid := user.UserId
  1445. pageSize, _ := this.GetInt("PageSize")
  1446. currentIndex, _ := this.GetInt("CurrentIndex")
  1447. reportType := this.GetString("ReportType")
  1448. var condition string
  1449. var startSize int
  1450. if pageSize <= 0 {
  1451. pageSize = utils.PageSize20
  1452. }
  1453. if currentIndex <= 0 {
  1454. currentIndex = 1
  1455. }
  1456. startSize = paging.StartIndex(currentIndex, pageSize)
  1457. var pars []interface{}
  1458. var total int
  1459. resp := new(models.CygxReportSelectionListPublicRep)
  1460. page := paging.GetPaging(currentIndex, pageSize, total)
  1461. var tbdb string
  1462. var readSql string
  1463. var reportTypeStr string
  1464. if reportType == "1" {
  1465. tbdb = "cygx_report_selection"
  1466. reportTypeStr = "bgjx"
  1467. } else if reportType == "2" {
  1468. tbdb = "cygx_research_summary"
  1469. reportTypeStr = "bzyjhz"
  1470. } else if reportType == "3" {
  1471. tbdb = "cygx_minutes_summary"
  1472. reportTypeStr = "szjyhz"
  1473. } else {
  1474. br.Msg = "请选择报告类型"
  1475. return
  1476. }
  1477. condition = ` AND publish_status = 1 `
  1478. if user.CompanyId != utils.HZ_COMPANY_ID {
  1479. condition += ` AND visible_range = 1 `
  1480. }
  1481. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1482. if err != nil {
  1483. br.Msg = "获取信息失败"
  1484. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1485. return
  1486. }
  1487. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1488. if reportType == "1" {
  1489. startSize = 0
  1490. pageSize = 1
  1491. total = 1
  1492. }
  1493. 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`
  1494. page = paging.GetPaging(currentIndex, pageSize, total)
  1495. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1496. if err != nil {
  1497. br.Msg = "获取失败"
  1498. br.ErrMsg = "获取失败,Err:" + err.Error()
  1499. return
  1500. }
  1501. for k, v := range list {
  1502. if reportType == "1" {
  1503. list[k].Abstract = v.UpdateDescription
  1504. }
  1505. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1506. if v.ReadNum == 0 {
  1507. list[k].IsRed = true
  1508. }
  1509. }
  1510. resp.List = list
  1511. resp.Paging = page
  1512. br.Ret = 200
  1513. br.Success = true
  1514. br.Msg = "获取成功"
  1515. br.Data = resp
  1516. }
  1517. // @Title 获取本周研究汇总详情
  1518. // @Description 获取本周研究汇总详情接口
  1519. // @Param ArticleId query int true "报告ID"
  1520. // @Success 200 {object} models.ResearchSummaryLetailResp
  1521. // @router /researchSummary/detail [get]
  1522. func (this *ReportController) ResearchDetail() {
  1523. br := new(models.BaseResponse).Init()
  1524. defer func() {
  1525. this.Data["json"] = br
  1526. this.ServeJSON()
  1527. }()
  1528. user := this.User
  1529. if user == nil {
  1530. br.Msg = "请重新登录"
  1531. br.Ret = 408
  1532. return
  1533. }
  1534. //uid := user.UserId
  1535. articleId, _ := this.GetInt("ArticleId")
  1536. if articleId < 0 {
  1537. br.Msg = "参数错误"
  1538. br.ErrMsg = "参数错误"
  1539. return
  1540. }
  1541. resp := new(models.ResearchSummaryLetailResp)
  1542. //判断用户权限
  1543. hasPermission, err := services.GetUserhasPermission(user)
  1544. if err != nil {
  1545. br.Msg = "获取信息失败"
  1546. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1547. }
  1548. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1549. if err != nil {
  1550. br.Msg = "获取信息失败"
  1551. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1552. return
  1553. }
  1554. PermissionNameMap, err := services.GetPermissionNameMap()
  1555. if err != nil {
  1556. br.Msg = "获取失败"
  1557. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1558. return
  1559. }
  1560. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1561. if err != nil {
  1562. br.Msg = "获取失败"
  1563. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1564. return
  1565. }
  1566. //未设置全部可见的只能给弘则内部查看
  1567. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1568. resp.IsShow = true
  1569. }
  1570. resp.HasPermission = hasPermission
  1571. if hasPermission != 1 || !resp.IsShow {
  1572. br.Ret = 200
  1573. br.Success = true
  1574. br.Msg = "获取成功"
  1575. br.Data = resp
  1576. return
  1577. }
  1578. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1579. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1580. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1581. if err != nil {
  1582. br.Msg = "获取失败"
  1583. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1584. return
  1585. }
  1586. listArticleType, err := models.GetCygxArticleTypeList()
  1587. if err != nil {
  1588. br.Msg = "获取失败"
  1589. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1590. return
  1591. }
  1592. for k, v := range listFirst {
  1593. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1594. if err != nil && err.Error() != utils.ErrNoRow() {
  1595. br.Msg = "获取信息失败"
  1596. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1597. return
  1598. }
  1599. for k2, v2 := range listSecond {
  1600. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1601. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1602. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1603. if err != nil && err.Error() != utils.ErrNoRow() {
  1604. br.Msg = "获取信息失败"
  1605. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1606. return
  1607. }
  1608. for _, vType := range listArticleType {
  1609. if v2.ChartPermissionId == vType.YanxPermissionId {
  1610. listSecond[k2].IcoLink = vType.IcoLinkM
  1611. listSecond[k2].PermissionName = vType.YanxPermissionName
  1612. }
  1613. }
  1614. if len(listThird) > 0 {
  1615. for k3, v3 := range listThird {
  1616. if v3.VideoUrl != "" {
  1617. listThird[k3].IsHaveVideo = true
  1618. }
  1619. if v3.ReportLink == "0" {
  1620. listThird[k3].ReportLink = ""
  1621. }
  1622. }
  1623. listSecond[k2].List = listThird
  1624. }
  1625. }
  1626. if len(listSecond) > 0 {
  1627. listFirst[k].List = listSecond
  1628. }
  1629. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1630. if v.Type == "SDBG" {
  1631. listFirst[k].ListName = "深度报告"
  1632. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1633. } else if v.Type == "BZCHJH" {
  1634. listFirst[k].ListName = "本周晨会精华"
  1635. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1636. } else if v.Type == "CYDYJY" {
  1637. listFirst[k].ListName = "产业调研纪要"
  1638. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1639. } else if v.Type == "SSGS" {
  1640. listFirst[k].ListName = "上市公司调研纪要篇"
  1641. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1642. } else if v.Type == "SJDP" {
  1643. listFirst[k].ListName = "市场QA汇总"
  1644. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1645. } else if v.Type == "YANX" {
  1646. listFirst[k].ListName = "买方研选"
  1647. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1648. }
  1649. }
  1650. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1651. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1652. resp.List = listFirst
  1653. resp.Detail = detail
  1654. br.Ret = 200
  1655. br.Success = true
  1656. br.Msg = "获取成功"
  1657. br.Data = resp
  1658. }
  1659. // @Title 上周纪要汇总内容详情
  1660. // @Description 获取上周纪要汇总内容详情接口
  1661. // @Param ArticleId query int true "报告ID"
  1662. // @Success 200 {object} models.MinutesSummaryLetailResp
  1663. // @router /minutesSummary/detail [get]
  1664. func (this *ReportController) MinutesDetail() {
  1665. br := new(models.BaseResponse).Init()
  1666. defer func() {
  1667. this.Data["json"] = br
  1668. this.ServeJSON()
  1669. }()
  1670. user := this.User
  1671. if user == nil {
  1672. br.Msg = "请重新登录"
  1673. br.Ret = 408
  1674. return
  1675. }
  1676. articleId, _ := this.GetInt("ArticleId")
  1677. if articleId < 0 {
  1678. br.Msg = "参数错误"
  1679. br.ErrMsg = "参数错误"
  1680. return
  1681. }
  1682. resp := new(models.MinutesSummaryLetailRespV4)
  1683. //判断用户权限
  1684. hasPermission, err := services.GetUserhasPermission(user)
  1685. if err != nil {
  1686. br.Msg = "获取信息失败"
  1687. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1688. }
  1689. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1690. if err != nil {
  1691. br.Msg = "获取信息失败"
  1692. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1693. return
  1694. }
  1695. PermissionNameMap, err := services.GetPermissionNameMap()
  1696. if err != nil {
  1697. br.Msg = "获取失败"
  1698. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1699. return
  1700. }
  1701. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1702. if err != nil {
  1703. br.Msg = "获取失败"
  1704. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1705. return
  1706. }
  1707. //未设置全部可见的只能给弘则内部查看
  1708. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1709. resp.IsShow = true
  1710. }
  1711. resp.HasPermission = hasPermission
  1712. if hasPermission != 1 || !resp.IsShow {
  1713. br.Ret = 200
  1714. br.Success = true
  1715. br.Msg = "获取成功"
  1716. br.Data = resp
  1717. return
  1718. }
  1719. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1720. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1721. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1722. if err != nil {
  1723. br.Msg = "获取失败"
  1724. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1725. return
  1726. }
  1727. for k, v := range listFirst {
  1728. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1729. if err != nil && err.Error() != utils.ErrNoRow() {
  1730. br.Msg = "获取信息失败"
  1731. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1732. return
  1733. }
  1734. for k2, v2 := range listSecond {
  1735. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1736. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1737. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1738. if err != nil && err.Error() != utils.ErrNoRow() {
  1739. br.Msg = "获取信息失败"
  1740. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1741. return
  1742. }
  1743. if len(listThird) > 0 {
  1744. for k3, v3 := range listThird {
  1745. if v3.VideoUrl != "" {
  1746. listThird[k3].IsHaveVideo = true
  1747. }
  1748. if v3.ReportLink == "0" {
  1749. listThird[k3].ReportLink = ""
  1750. }
  1751. }
  1752. listSecond[k2].List = listThird
  1753. }
  1754. }
  1755. if len(listSecond) > 0 {
  1756. listFirst[k].List = listSecond
  1757. }
  1758. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1759. if v.Type == "CYDYJY" {
  1760. listFirst[k].ListName = "产业调研纪要"
  1761. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1762. } else if v.Type == "SSGS" {
  1763. listFirst[k].ListName = "上市公司调研纪要篇"
  1764. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1765. } else if v.Type == "YANX" {
  1766. listFirst[k].ListName = "买方研选纪要"
  1767. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1768. }
  1769. }
  1770. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1771. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1772. resp.List = listFirst
  1773. resp.Detail = detail
  1774. br.Ret = 200
  1775. br.Success = true
  1776. br.Msg = "获取成功"
  1777. br.Data = resp
  1778. }
  1779. // @Title 记录用户浏览音频回放接口
  1780. // @Description 记录用户浏览音频回放接口
  1781. // @Param request body models.ArticleIdReq true "type json string"
  1782. // @Success Ret=200 操作成功
  1783. // @router /voiceHistory/add [post]
  1784. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1785. br := new(models.BaseResponse).Init()
  1786. defer func() {
  1787. this.Data["json"] = br
  1788. this.ServeJSON()
  1789. }()
  1790. user := this.User
  1791. if user == nil {
  1792. br.Msg = "请登录"
  1793. br.ErrMsg = "请登录,用户信息为空"
  1794. br.Ret = 408
  1795. return
  1796. }
  1797. uid := user.UserId
  1798. var req models.ArticleIdReq
  1799. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1800. if err != nil {
  1801. br.Msg = "参数解析异常!"
  1802. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1803. return
  1804. }
  1805. articleId := req.ArticleId
  1806. playSeconds := req.PlaySeconds
  1807. reportType := req.ReportType
  1808. //本周研究汇总
  1809. if reportType == 2 {
  1810. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1811. if articleInfo == nil {
  1812. br.Msg = "操作失败"
  1813. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1814. return
  1815. }
  1816. if errInfo != nil {
  1817. br.Msg = "操作失败"
  1818. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1819. return
  1820. }
  1821. var sellerName string
  1822. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1823. if err != nil {
  1824. br.Msg = "报名失败!"
  1825. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1826. return
  1827. }
  1828. item := models.CygxResearchSummaryVoiceHistory{
  1829. ArticleId: articleId,
  1830. UserId: uid,
  1831. CreateTime: time.Now(),
  1832. Mobile: user.Mobile,
  1833. Email: user.Email,
  1834. CompanyId: user.CompanyId,
  1835. CompanyName: user.CompanyName,
  1836. RealName: user.RealName,
  1837. SellerName: sellerName,
  1838. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1839. ModifyTime: time.Now(),
  1840. RegisterPlatform: utils.REGISTER_PLATFORM,
  1841. }
  1842. if playSeconds != 0 {
  1843. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1844. if err != nil {
  1845. br.Msg = "操作失败"
  1846. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1847. return
  1848. }
  1849. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1850. if err != nil {
  1851. br.Msg = "更新失败"
  1852. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1853. return
  1854. }
  1855. } else {
  1856. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1857. if err != nil {
  1858. br.Msg = "操作失败"
  1859. br.ErrMsg = "操作失败,Err:" + err.Error()
  1860. return
  1861. }
  1862. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1863. if err != nil {
  1864. br.Msg = "更新失败"
  1865. br.ErrMsg = "更新失败,Err:" + err.Error()
  1866. return
  1867. }
  1868. }
  1869. } else if reportType == 3 {
  1870. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1871. if articleInfo == nil {
  1872. br.Msg = "操作失败"
  1873. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1874. return
  1875. }
  1876. if errInfo != nil {
  1877. br.Msg = "操作失败"
  1878. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1879. return
  1880. }
  1881. var sellerName string
  1882. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1883. if err != nil {
  1884. br.Msg = "报名失败!"
  1885. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1886. return
  1887. }
  1888. item := models.CygxMinutesSummaryVoiceHistory{
  1889. ArticleId: articleId,
  1890. UserId: uid,
  1891. CreateTime: time.Now(),
  1892. Mobile: user.Mobile,
  1893. Email: user.Email,
  1894. CompanyId: user.CompanyId,
  1895. CompanyName: user.CompanyName,
  1896. RealName: user.RealName,
  1897. SellerName: sellerName,
  1898. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1899. ModifyTime: time.Now(),
  1900. RegisterPlatform: utils.REGISTER_PLATFORM,
  1901. }
  1902. if playSeconds != 0 {
  1903. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1904. if err != nil {
  1905. br.Msg = "操作失败"
  1906. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1907. return
  1908. }
  1909. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1910. if err != nil {
  1911. br.Msg = "更新失败"
  1912. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1913. return
  1914. }
  1915. } else {
  1916. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1917. if err != nil {
  1918. br.Msg = "操作失败"
  1919. br.ErrMsg = "操作失败,Err:" + err.Error()
  1920. return
  1921. }
  1922. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1923. if err != nil {
  1924. br.Msg = "更新失败"
  1925. br.ErrMsg = "更新失败,Err:" + err.Error()
  1926. return
  1927. }
  1928. }
  1929. }
  1930. br.Ret = 200
  1931. br.Success = true
  1932. br.Msg = "操作成功"
  1933. return
  1934. }
  1935. // @Title 根据行业分类获取行业文章列表
  1936. // @Description 根据行业分类获取行业文章列表接口
  1937. // @Param PageSize query int true "每页数据条数"
  1938. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1939. // @Param CategoryId query int true "分类ID"
  1940. // @Param IndustrialManagementId query int false "产业ID"
  1941. // @Success 200 {object} models.TacticsListResp
  1942. // @router /tactics/list [get]
  1943. func (this *MobileReportController) TacticsList() {
  1944. br := new(models.BaseResponse).Init()
  1945. defer func() {
  1946. this.Data["json"] = br
  1947. this.ServeJSON()
  1948. }()
  1949. user := this.User
  1950. if user == nil {
  1951. br.Msg = "请重新登录"
  1952. br.Ret = 408
  1953. return
  1954. }
  1955. //uid := user.UserId
  1956. pageSize, _ := this.GetInt("PageSize")
  1957. currentIndex, _ := this.GetInt("CurrentIndex")
  1958. categoryId, _ := this.GetInt("CategoryId")
  1959. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1960. var startSize int
  1961. if pageSize <= 0 {
  1962. pageSize = utils.PageSize20
  1963. }
  1964. if currentIndex <= 0 {
  1965. currentIndex = 1
  1966. }
  1967. startSize = paging.StartIndex(currentIndex, pageSize)
  1968. //var condition string
  1969. //var pars []interface{}
  1970. var total int
  1971. var err error
  1972. resp := new(models.TacticsListResp)
  1973. page := paging.GetPaging(currentIndex, pageSize, total)
  1974. list := make([]*models.ArticleListResp, 0)
  1975. if categoryId == utils.TIME_CATEGORYID {
  1976. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  1977. if err != nil {
  1978. br.Msg = "获取信息失败"
  1979. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1980. return
  1981. }
  1982. } else {
  1983. if categoryId == utils.ACTEGORY_ID_AI_QY {
  1984. listArticle := make([]*models.HomeArticle, 0)
  1985. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  1986. if err != nil {
  1987. br.Msg = "获取信息失败"
  1988. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  1989. return
  1990. }
  1991. for _, v := range listArticle {
  1992. list = append(list, &models.ArticleListResp{
  1993. ArticleId: v.ArticleId,
  1994. Title: v.Title,
  1995. CategoryId: v.CategoryId,
  1996. Annotation: v.Annotation,
  1997. Abstract: v.Abstract,
  1998. Body: v.Body,
  1999. PublishDate: v.PublishDate,
  2000. Resource: 1,
  2001. })
  2002. }
  2003. } else {
  2004. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2005. if err != nil {
  2006. br.Msg = "获取信息失败"
  2007. br.Msg = "GetHomeList,Err:" + err.Error()
  2008. return
  2009. }
  2010. }
  2011. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2012. if err != nil {
  2013. br.Msg = "获取信息失败"
  2014. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2015. return
  2016. }
  2017. for k, v := range list {
  2018. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2019. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2020. list[k].IsRed = true
  2021. }
  2022. }
  2023. if categoryId > 0 {
  2024. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2025. if errCategory != nil {
  2026. br.Msg = "获取信息失败"
  2027. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2028. return
  2029. }
  2030. resp.MatchTypeName = detail.MatchTypeName
  2031. }
  2032. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2033. }
  2034. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2035. if err != nil {
  2036. br.Msg = "获取失败"
  2037. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2038. return
  2039. }
  2040. var articleIds []int
  2041. var productInteriorIs []int
  2042. for _, v := range listPublic {
  2043. if v.Resource == 1 {
  2044. articleIds = append(articleIds, v.ArticleId)
  2045. }
  2046. if v.Resource == 2 {
  2047. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2048. }
  2049. }
  2050. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2051. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2052. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2053. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2054. listResp := make([]*models.HomeArticle, 0)
  2055. for _, v := range listPublic {
  2056. item := new(models.HomeArticle)
  2057. item.ArticleId = v.ArticleId
  2058. item.ReportId = v.ReportId
  2059. item.Title = v.Title
  2060. item.Annotation = v.Annotation
  2061. item.Abstract = v.Abstract
  2062. item.ImgUrlPc = v.ImgUrlPc
  2063. item.PublishDate = v.PublishDate
  2064. item.Resource = v.Resource
  2065. if v.Resource == 1 {
  2066. item.Pv = articleMapPv[v.ArticleId]
  2067. item.IsCollect = articleCollectMap[v.ArticleId]
  2068. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2069. }
  2070. if v.Resource == 2 {
  2071. item.Pv = productInteriorMapPv[v.ArticleId]
  2072. }
  2073. if v.ReportId > 0 {
  2074. item.Resource = 3
  2075. }
  2076. listResp = append(listResp, item)
  2077. }
  2078. if len(listResp) == 0 {
  2079. listResp = make([]*models.HomeArticle, 0)
  2080. }
  2081. page = paging.GetPaging(currentIndex, pageSize, total)
  2082. resp.List = listResp
  2083. resp.Paging = page
  2084. br.Ret = 200
  2085. br.Success = true
  2086. br.Msg = "获取成功"
  2087. br.Data = resp
  2088. }
  2089. // @Title 周期行业报告分类列表接口
  2090. // @Description 周期获取行业报告分类列表接口
  2091. // @Success 200 {object} models.TradeReportMappingResp
  2092. // @router /zhouqi_tradeList [get]
  2093. func (this *MobileReportController) ZouqiTradeList() {
  2094. br := new(models.BaseResponse).Init()
  2095. defer func() {
  2096. this.Data["json"] = br
  2097. this.ServeJSON()
  2098. }()
  2099. user := this.User
  2100. if user == nil {
  2101. br.Msg = "请重新登录"
  2102. br.Ret = 408
  2103. return
  2104. }
  2105. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  2106. if err != nil {
  2107. br.Msg = "获取信息失败"
  2108. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2109. return
  2110. }
  2111. fllowMap := services.GetXzsChooseCategoryZhouqiMapByMobile(user.Mobile)
  2112. resp := new(models.TradeReportMappingResp)
  2113. var list []*models.TradeReportMapping
  2114. if len(listCategory) == 0 {
  2115. list = make([]*models.TradeReportMapping, 0)
  2116. } else {
  2117. for _, v := range listCategory {
  2118. item := new(models.TradeReportMapping)
  2119. item.CategoryId = v.CategoryId
  2120. item.MatchTypeName = v.MatchTypeName
  2121. item.UpdateTime = utils.TimeRemoveHms(v.ArticleUpdateTime)
  2122. item.IsFollow = fllowMap[item.CategoryId]
  2123. item.ListArticle = make([]*models.HomeArticle, 0)
  2124. list = append(list, item)
  2125. }
  2126. }
  2127. resp.List = list
  2128. br.Ret = 200
  2129. br.Success = true
  2130. br.Msg = "获取成功"
  2131. br.Data = resp
  2132. }
  2133. // @Title 周期根据行业分类获取行业文章列表
  2134. // @Description 周期根据行业分类获取行业文章列表接口
  2135. // @Param PageSize query int true "每页数据条数"
  2136. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2137. // @Param CategoryId query int true "分类ID"
  2138. // @Success 200 {object} models.TacticsListResp
  2139. // @router /tactics/zhouqi_list [get]
  2140. func (this *MobileReportController) ZhouqiTacticsList() {
  2141. br := new(models.BaseResponse).Init()
  2142. defer func() {
  2143. this.Data["json"] = br
  2144. this.ServeJSON()
  2145. }()
  2146. user := this.User
  2147. if user == nil {
  2148. br.Msg = "请重新登录"
  2149. br.Ret = 408
  2150. return
  2151. }
  2152. //uid := user.UserId
  2153. pageSize, _ := this.GetInt("PageSize")
  2154. currentIndex, _ := this.GetInt("CurrentIndex")
  2155. categoryId, _ := this.GetInt("CategoryId")
  2156. var startSize int
  2157. if pageSize <= 0 {
  2158. pageSize = utils.PageSize20
  2159. }
  2160. if currentIndex <= 0 {
  2161. currentIndex = 1
  2162. }
  2163. startSize = paging.StartIndex(currentIndex, pageSize)
  2164. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  2165. if err != nil {
  2166. br.Msg = "获取信息失败"
  2167. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2168. return
  2169. }
  2170. var total int
  2171. //var err error
  2172. resp := new(models.TacticsListResp)
  2173. page := paging.GetPaging(currentIndex, pageSize, total)
  2174. list := make([]*models.ArticleListResp, 0)
  2175. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  2176. if err != nil {
  2177. br.Msg = "获取信息失败"
  2178. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2179. return
  2180. }
  2181. var matchTypeName = []string{}
  2182. var seriesName = []string{}
  2183. for _, v := range listCategory {
  2184. if v.MatchTypeName != "" {
  2185. matchTypeName = append(matchTypeName, v.MatchTypeName)
  2186. }
  2187. if v.SeriesName != "" {
  2188. seriesName = append(seriesName, v.SeriesName)
  2189. }
  2190. }
  2191. var conditionOr string
  2192. if detail.FiccReportId != "" {
  2193. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  2194. }
  2195. if len(seriesName) > 0 {
  2196. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  2197. }
  2198. var condition string
  2199. //var pars []interface{}
  2200. //if len(seriesName) == 0 {
  2201. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  2202. //} else {
  2203. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  2204. //}
  2205. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  2206. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  2207. if err != nil {
  2208. br.Msg = "获取信息失败"
  2209. br.Msg = "GetHomeList,Err:" + err.Error()
  2210. return
  2211. }
  2212. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2213. if err != nil {
  2214. br.Msg = "获取失败"
  2215. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2216. return
  2217. }
  2218. var articleIds []int
  2219. var productInteriorIs []int
  2220. for _, v := range listPublic {
  2221. if v.Resource == 1 {
  2222. articleIds = append(articleIds, v.ArticleId)
  2223. }
  2224. if v.Resource == 2 {
  2225. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2226. }
  2227. }
  2228. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2229. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2230. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2231. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2232. listResp := make([]*models.HomeArticle, 0)
  2233. for _, v := range listPublic {
  2234. item := new(models.HomeArticle)
  2235. item.ArticleId = v.ArticleId
  2236. item.ReportId = v.ReportId
  2237. item.Title = v.Title
  2238. item.Annotation = v.Annotation
  2239. item.Abstract = v.Abstract
  2240. item.ImgUrlPc = v.ImgUrlPc
  2241. item.PublishDate = v.PublishDate
  2242. item.Resource = v.Resource
  2243. if v.Resource == 1 {
  2244. item.Pv = articleMapPv[v.ArticleId]
  2245. item.IsCollect = articleCollectMap[v.ArticleId]
  2246. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2247. }
  2248. if v.Resource == 2 {
  2249. item.Pv = productInteriorMapPv[v.ArticleId]
  2250. }
  2251. if v.ReportId > 0 {
  2252. item.Resource = 3
  2253. }
  2254. listResp = append(listResp, item)
  2255. }
  2256. if len(listResp) == 0 {
  2257. listResp = make([]*models.HomeArticle, 0)
  2258. }
  2259. page = paging.GetPaging(currentIndex, pageSize, total)
  2260. resp.List = listResp
  2261. resp.Paging = page
  2262. br.Ret = 200
  2263. br.Success = true
  2264. br.Msg = "获取成功"
  2265. br.Data = resp
  2266. }
  2267. // @Title 周期行业关注/取消关注
  2268. // @Description 周期行业关注/取消关注 接口
  2269. // @Param request body models.CygxCategoryFllowRep true "type json string"
  2270. // @Success 200
  2271. // @router /category/zhouqi_fllow [post]
  2272. func (this *ReportController) CategoryZhouqiFllow() {
  2273. br := new(models.BaseResponse).Init()
  2274. defer func() {
  2275. this.Data["json"] = br
  2276. this.ServeJSON()
  2277. }()
  2278. user := this.User
  2279. if user == nil {
  2280. br.Msg = "请重新登录"
  2281. br.Ret = 408
  2282. return
  2283. }
  2284. uid := user.UserId
  2285. var req models.CygxCategoryFllowRep
  2286. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2287. if err != nil {
  2288. br.Msg = "参数解析异常!"
  2289. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2290. return
  2291. }
  2292. categoryId := req.CategoryId
  2293. count, err := models.GetCountCategoryFllowZhouqi(categoryId, user.Mobile)
  2294. if err != nil {
  2295. br.Msg = "获取数据失败!"
  2296. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2297. return
  2298. }
  2299. resp := new(models.CygxIndustryFllowResp)
  2300. if count == 0 {
  2301. item := new(models.CygxXzsChooseCategoryZhouqi)
  2302. item.CategoryId = categoryId
  2303. item.UserId = uid
  2304. item.Email = user.Email
  2305. item.Mobile = user.Mobile
  2306. item.RealName = user.RealName
  2307. item.CompanyId = user.CompanyId
  2308. item.CompanyName = user.CompanyName
  2309. item.CreateTime = time.Now()
  2310. item.ModifyTime = time.Now()
  2311. _, err = models.AddCygxCategoryFllowZhouqi(item)
  2312. if err != nil {
  2313. br.Msg = "操作失败"
  2314. br.ErrMsg = "操作失败,Err:" + err.Error()
  2315. return
  2316. }
  2317. resp.Status = 1
  2318. br.Msg = "关注成功"
  2319. } else {
  2320. err = models.RemoveCygxCategoryFllowZhouqi(user.Mobile, categoryId)
  2321. if err != nil {
  2322. br.Msg = "操作失败"
  2323. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  2324. return
  2325. }
  2326. resp.Status = 2
  2327. br.Msg = "已取消关注"
  2328. }
  2329. br.Ret = 200
  2330. br.Success = true
  2331. br.Data = resp
  2332. }