report.go 76 KB

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