report.go 77 KB

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