report.go 76 KB

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