report.go 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/medivhzhan/weapp/v2"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "hongze/hongze_cygx/models"
  9. "hongze/hongze_cygx/services"
  10. "hongze/hongze_cygx/utils"
  11. "html"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 报告
  17. type ReportController struct {
  18. BaseAuthController
  19. }
  20. type ReportCommonController struct {
  21. BaseCommonController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.IndustrialManagementList
  27. // @router /home/tradeList [get]
  28. func (this *ReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. uid := user.UserId
  41. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  42. if ChartPermissionId < 1 {
  43. br.Msg = "请输入分类ID"
  44. return
  45. }
  46. list, err := models.GetTradeAll(ChartPermissionId)
  47. if err != nil {
  48. br.Msg = "获取信息失败"
  49. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  50. return
  51. }
  52. var condition string
  53. var pars []interface{}
  54. for k, v := range list {
  55. if v.PolymerizationId != "" {
  56. condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  57. } else {
  58. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  59. }
  60. listArticle, err := models.GetHomeList(condition, pars, 0, 1)
  61. if err != nil && err.Error() != utils.ErrNoRow() {
  62. br.Msg = "获取信息失败"
  63. br.Msg = "GetHomeList,Err:" + err.Error()
  64. return
  65. }
  66. if len(listArticle) > 0 {
  67. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  68. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  69. if err != nil {
  70. br.Msg = "获取信息失败"
  71. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  72. return
  73. }
  74. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  75. list[k].IsRed = true
  76. }
  77. }
  78. }
  79. resp := new(models.TradeReportMappingResp)
  80. resp.List = list
  81. br.Ret = 200
  82. br.Success = true
  83. br.Msg = "获取成功"
  84. br.Data = resp
  85. }
  86. // @Title 产业报告分类列表接口
  87. // @Description 获取产业报告分类列表接口
  88. // @Param ChartPermissionId query int true "分类ID"
  89. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  90. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  91. // @Param KeyWord query string true "搜索关键词"
  92. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  93. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  94. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  95. // @Param PageSize query int true "每页数据条数"
  96. // @Param CurrentIndex query int true "当前页页码,从1开始"
  97. // @Success 200 {object} models.IndustrialManagementList
  98. // @router /home/industryList [get]
  99. func (this *ReportController) IndustryList() {
  100. br := new(models.BaseResponse).Init()
  101. defer func() {
  102. this.Data["json"] = br
  103. this.ServeJSON()
  104. }()
  105. user := this.User
  106. if user == nil {
  107. br.Msg = "请重新登录"
  108. br.Ret = 408
  109. return
  110. }
  111. uid := user.UserId
  112. fmt.Println(uid)
  113. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  114. orderColumn := this.GetString("OrderColumn")
  115. orderColumnNew := this.GetString("OrderColumn")
  116. isNewLabel := this.GetString("IsNewLabel")
  117. isDeepLabel := this.GetString("IsDeepLabel")
  118. keyWord := this.GetString("KeyWord")
  119. pageSize, _ := this.GetInt("PageSize")
  120. currentIndex, _ := this.GetInt("CurrentIndex")
  121. deepCover, _ := this.GetInt("DeepCover")
  122. recommendFocus, _ := this.GetInt("RecommendFocus")
  123. var orderSrt string
  124. var condition string
  125. var startSize int
  126. resp := new(models.IndustrialManagementList)
  127. if pageSize <= 0 {
  128. pageSize = utils.PageSize20
  129. }
  130. if currentIndex <= 0 {
  131. currentIndex = 1
  132. }
  133. startSize = paging.StartIndex(currentIndex, pageSize)
  134. if isNewLabel == "1" {
  135. condition += ` AND is_new_label = ` + isNewLabel
  136. }
  137. if isDeepLabel == "1" {
  138. condition += ` AND is_deep_label = ` + isDeepLabel
  139. }
  140. if keyWord != "" {
  141. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  142. }
  143. var sqlChartPermissionId string
  144. if ChartPermissionId > 0 {
  145. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  146. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  147. }
  148. // 深度覆盖
  149. if deepCover == 1 {
  150. // 查询深标签产业报告数
  151. var deepCondition string
  152. var deepPars []interface{}
  153. deepCondition += ` AND man.is_deep_label = 1`
  154. if ChartPermissionId > 0 {
  155. deepCondition += ` AND man.chart_permission_id = ?`
  156. deepPars = append(deepPars, ChartPermissionId)
  157. }
  158. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  159. if e != nil {
  160. br.Msg = "获取信息失败"
  161. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  162. return
  163. }
  164. deepIdArr := make([]string, 0)
  165. for i := range industryCountList {
  166. if industryCountList[i].ArtNum > 10 {
  167. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  168. }
  169. }
  170. deepIds := strings.Join(deepIdArr, ",")
  171. if deepIds != "" {
  172. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  173. }
  174. }
  175. // 推荐关注
  176. if recommendFocus == 1 {
  177. condition += ` AND man.recommended_index >= 80`
  178. }
  179. // 列表总数据量
  180. var list []*models.IndustrialManagement
  181. total, err := models.GetIndustrialManagementAllCount(condition)
  182. if err != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  185. return
  186. }
  187. page := paging.GetPaging(currentIndex, pageSize, total)
  188. if orderColumn == "" {
  189. orderColumn = "NewTime"
  190. }
  191. if orderColumn == "NewTime" {
  192. orderSrt = "update_time DESC"
  193. } else {
  194. orderSrt = "man.recommended_index DESC,update_time DESC"
  195. }
  196. if ChartPermissionId == 0 {
  197. ChartPermissionId = 20
  198. }
  199. // 阅读第三的产业详情
  200. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  201. //if err != nil {
  202. // br.Msg = "获取信息失败"
  203. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  204. // return
  205. //}
  206. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  207. if err != nil {
  208. br.Msg = "获取信息失败"
  209. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  210. return
  211. }
  212. // 获取近一个月产业报告阅读次数最多的产业
  213. var topCond string
  214. var topPars []interface{}
  215. //topReadIndustryId := 0
  216. if ChartPermissionId > 0 {
  217. topCond += ` AND chart_permission_id = ?`
  218. topPars = append(topPars, ChartPermissionId)
  219. }
  220. list, err = services.HandleIndustryList(list, user)
  221. if orderColumnNew != "" {
  222. item := new(models.CygxReportIndustrialSeaarchHistory)
  223. item.UserId = user.UserId
  224. item.Mobile = user.Mobile
  225. item.CompanyId = user.CompanyId
  226. item.CompanyName = user.CompanyName
  227. item.CreateTime = time.Now()
  228. item.IsDeepLabel = isDeepLabel
  229. item.IsNewLabel = isNewLabel
  230. item.ChartPermissionId = ChartPermissionId
  231. if orderColumnNew == "NewTime" {
  232. item.OrderColumn = "0"
  233. } else {
  234. item.OrderColumn = "1"
  235. }
  236. go models.AddCygxReportIndustrialSeaarchHistory(item)
  237. }
  238. resp.List = list
  239. resp.Paging = page
  240. br.Ret = 200
  241. br.Success = true
  242. br.Msg = "获取成功"
  243. br.Data = resp
  244. }
  245. // @Title 产业下所关联的文章分类列表
  246. // @Description 产业下所关联的文章分类列表接口
  247. // @Param IndustrialManagementId query int true "产业ID"
  248. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  249. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  250. // @router /toArticleCategoryList [get]
  251. func (this *ReportController) ArticleCategoryList() {
  252. br := new(models.BaseResponse).Init()
  253. defer func() {
  254. this.Data["json"] = br
  255. this.ServeJSON()
  256. }()
  257. user := this.User
  258. if user == nil {
  259. br.Msg = "请重新登录"
  260. br.Ret = 408
  261. return
  262. }
  263. uid := user.UserId
  264. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  265. if industrialManagementId < 1 {
  266. br.Msg = "请输入分类ID"
  267. return
  268. }
  269. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  270. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  271. if err != nil {
  272. br.Msg = "获取信息失败"
  273. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  274. return
  275. }
  276. list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  277. if err != nil {
  278. br.Msg = "获取信息失败"
  279. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  280. return
  281. }
  282. for k, v := range list {
  283. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  284. if err != nil && err.Error() != utils.ErrNoRow() {
  285. br.Msg = "获取信息失败"
  286. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  287. return
  288. }
  289. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  290. if err != nil && err.Error() != utils.ErrNoRow() {
  291. br.Msg = "获取信息失败"
  292. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  293. return
  294. }
  295. if Newdetail != nil {
  296. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  297. list[k].IsRed = true
  298. }
  299. }
  300. }
  301. // 用户权限
  302. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  303. if e != nil {
  304. br.Msg = "获取失败"
  305. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  306. return
  307. }
  308. videoSimple := new(models.MicroVideoSimpleInfo)
  309. // 权限
  310. var au *models.UserPermissionAuthInfo
  311. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  312. if err != nil {
  313. if err.Error() != utils.ErrNoRow() {
  314. br.Msg = "获取产业视频失败"
  315. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  316. return
  317. }
  318. } else {
  319. videoSimple.Id = video.VideoId
  320. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  321. videoSimple.BackgroundImg = video.ImgUrl
  322. videoSimple.DetailImgUrl = video.DetailImgUrl
  323. if videoSimple.BackgroundImg == "" {
  324. // 获取默认图配置
  325. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  326. if e != nil {
  327. br.Msg = "获取视频默认配置图失败"
  328. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  329. return
  330. }
  331. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  332. }
  333. videoSimple.PlaySeconds = video.VideoDuration
  334. videoSimple.ResourceUrl = video.VideoUrl
  335. au = new(models.UserPermissionAuthInfo)
  336. au.SellerName = authInfo.SellerName
  337. au.SellerMobile = authInfo.SellerMobile
  338. au.HasPermission = authInfo.HasPermission
  339. au.OperationMode = authInfo.OperationMode
  340. if au.HasPermission == 1 {
  341. // 非宏观权限进一步判断是否有权限
  342. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  343. au.HasPermission = 2
  344. }
  345. }
  346. // 无权限的弹框提示
  347. if au.HasPermission != 1 {
  348. if au.OperationMode == services.UserPermissionOperationModeCall {
  349. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  350. } else {
  351. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  352. }
  353. videoSimple.ResourceUrl = ""
  354. }
  355. }
  356. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  357. //if err != nil {
  358. // br.Msg = "获取信息失败"
  359. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  360. // return
  361. //}
  362. //时间线
  363. if showTimeLine == 1 {
  364. timeLineItem := models.IndustrialToArticleCategoryRep{
  365. CategoryId: 99999,
  366. MatchTypeName: "时间线",
  367. }
  368. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  369. if err != nil {
  370. br.Msg = "获取信息失败"
  371. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  372. return
  373. }
  374. //查询用户今天是否看过时间线
  375. haveMorningMeeting := false
  376. var morningMeetingTime string
  377. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  378. if err != nil {
  379. br.Msg = "查询浏览记录数量失败"
  380. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  381. return
  382. }
  383. var recordItem *models.CygxPageHistoryRecord
  384. if count > 1 {
  385. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  386. if err != nil {
  387. br.Msg = "查询浏览记录失败"
  388. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  389. return
  390. }
  391. }
  392. for _, v := range timeLineList {
  393. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  394. if v.SubCategoryName == "时间线" {
  395. haveMorningMeeting = true
  396. morningMeetingTime = v.PublishTime
  397. continue
  398. }
  399. timeLineItem.IsRed = true
  400. }
  401. }
  402. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  403. timeLineRed := false
  404. if count < 2 {
  405. timeLineRed = true
  406. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  407. timeLineRed = true
  408. }
  409. if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  410. timeLineItem.IsRed = true
  411. }
  412. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  413. }
  414. resp := new(models.IndustrialToArticleCategoryListRep)
  415. resp.List = list
  416. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  417. resp.IndustryName = detail.IndustryName
  418. resp.IndustrialManagementId = industrialManagementId
  419. resp.AuthInfo = au
  420. if videoSimple.Id > 0 {
  421. resp.IndustryVideo = videoSimple
  422. }
  423. br.Ret = 200
  424. br.Success = true
  425. br.Msg = "获取成功"
  426. br.Data = resp
  427. }
  428. // @Title 产业文章列表接口
  429. // @Description 获取产业文章列表接口
  430. // @Param PageSize query int true "每页数据条数"
  431. // @Param CurrentIndex query int true "当前页页码,从1开始"
  432. // @Param CategoryId query int true "分类ID"
  433. // @Param IndustrialManagementId query int true "产业ID"
  434. // @Success 200 {object} models.TacticsListResp
  435. // @router /industry/ArticleList [get]
  436. func (this *ReportController) List() {
  437. br := new(models.BaseResponse).Init()
  438. defer func() {
  439. this.Data["json"] = br
  440. this.ServeJSON()
  441. }()
  442. user := this.User
  443. if user == nil {
  444. br.Msg = "请重新登录"
  445. br.Ret = 408
  446. return
  447. }
  448. uid := user.UserId
  449. pageSize, _ := this.GetInt("PageSize")
  450. currentIndex, _ := this.GetInt("CurrentIndex")
  451. categoryId, _ := this.GetInt("CategoryId")
  452. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  453. var startSize int
  454. if pageSize <= 0 {
  455. pageSize = utils.PageSize20
  456. }
  457. if currentIndex <= 0 {
  458. currentIndex = 1
  459. }
  460. startSize = paging.StartIndex(currentIndex, pageSize)
  461. var pars []interface{}
  462. var total int
  463. page := paging.GetPaging(currentIndex, pageSize, total)
  464. if categoryId < 1 {
  465. br.Msg = "请输入分类ID"
  466. return
  467. }
  468. if industrialManagementId < 1 {
  469. br.Msg = "请输入产业ID"
  470. return
  471. }
  472. if categoryId != 99999 {
  473. resp := new(models.TacticsListResp)
  474. //获取该产业下所对应的行业图片
  475. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  476. if errCategory != nil {
  477. br.Msg = "获取信息失败"
  478. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  479. return
  480. }
  481. //对应行业的图片
  482. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  483. if err != nil {
  484. br.Msg = "获取数据失败"
  485. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  486. return
  487. }
  488. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  489. mapChartPermission := make(map[string]string)
  490. var permissionName string
  491. var imgUrlChartPermission string
  492. for _, v := range chartPermissionUrlList {
  493. vslice := strings.Split(v, "_")
  494. permissionName = vslice[0]
  495. imgUrlChartPermission = vslice[len(vslice)-1]
  496. mapChartPermission[permissionName] = imgUrlChartPermission
  497. }
  498. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  499. if err != nil {
  500. br.Msg = "获取信息失败"
  501. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  502. return
  503. }
  504. page = paging.GetPaging(currentIndex, pageSize, total)
  505. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  506. if err != nil {
  507. br.Msg = "获取信息失败"
  508. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  509. return
  510. }
  511. //对应分类的所图片
  512. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  513. if err != nil {
  514. br.Msg = "获取数据失败"
  515. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  516. return
  517. }
  518. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  519. mapCategoryUrl := make(map[string]string)
  520. var categoryIdStr string
  521. var imgUrlChart string
  522. for _, v := range categoryUrlList {
  523. vslice := strings.Split(v, "_")
  524. categoryIdStr = vslice[0]
  525. imgUrlChart = vslice[len(vslice)-1]
  526. mapCategoryUrl[categoryIdStr] = imgUrlChart
  527. }
  528. lenList := len(list)
  529. for i := 0; i < lenList; i++ {
  530. item := list[i]
  531. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  532. //list[i].Abstract = html.UnescapeString(item.Abstract)
  533. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  534. }
  535. for k, v := range list {
  536. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  537. list[k].IsRed = true
  538. }
  539. if v.VideoUrl != "" {
  540. list[k].IsHaveVideo = true
  541. }
  542. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  543. if mapCategoryUrl[v.CategoryId] == "" {
  544. if detail.ChartPermissionId == utils.YI_YAO_ID {
  545. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  546. }
  547. }
  548. }
  549. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  550. resp.ChartPermissionId = detail.ChartPermissionId
  551. resp.List = list
  552. resp.Paging = page
  553. br.Ret = 200
  554. br.Success = true
  555. br.Msg = "获取成功"
  556. br.Data = resp
  557. } else {
  558. //获取该产业下所对应的行业图片
  559. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  560. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  561. if err != nil {
  562. br.Msg = "获取信息失败"
  563. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  564. return
  565. }
  566. var timeLineCategoryId int
  567. if len(categoryList) > 0 {
  568. timeLineCategoryId = categoryList[0].CategoryId
  569. }
  570. var detail *models.ReportMapping
  571. var errCategory error
  572. if timeLineCategoryId > 0 {
  573. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  574. if errCategory != nil {
  575. br.Msg = "获取信息失败"
  576. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  577. return
  578. }
  579. }
  580. //对应行业的图片
  581. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  582. if err != nil {
  583. br.Msg = "获取数据失败"
  584. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  585. return
  586. }
  587. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  588. mapChartPermission := make(map[string]string)
  589. var permissionName string
  590. var imgUrlChartPermission string
  591. for _, v := range chartPermissionUrlList {
  592. vslice := strings.Split(v, "_")
  593. permissionName = vslice[0]
  594. imgUrlChartPermission = vslice[len(vslice)-1]
  595. mapChartPermission[permissionName] = imgUrlChartPermission
  596. }
  597. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  598. if err != nil {
  599. br.Msg = "获取信息失败"
  600. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  601. return
  602. }
  603. page = paging.GetPaging(currentIndex, pageSize, total)
  604. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  605. if err != nil {
  606. br.Msg = "获取信息失败"
  607. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  608. return
  609. }
  610. //对应分类的所图片
  611. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  612. if err != nil {
  613. br.Msg = "获取数据失败"
  614. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  615. return
  616. }
  617. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  618. mapCategoryUrl := make(map[string]string)
  619. var categoryIdStr string
  620. var imgUrlChart string
  621. for _, v := range categoryUrlList {
  622. vslice := strings.Split(v, "_")
  623. categoryIdStr = vslice[0]
  624. imgUrlChart = vslice[len(vslice)-1]
  625. mapCategoryUrl[categoryIdStr] = imgUrlChart
  626. }
  627. //lenList := len(list)
  628. //for i := 0; i < lenList; i++ {
  629. // item := list[i]
  630. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  631. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  632. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  633. //}
  634. //查询用户今天是否看过时间线
  635. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  636. if err != nil {
  637. br.Msg = "查询浏览记录数量失败"
  638. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  639. return
  640. }
  641. var recordItem *models.CygxPageHistoryRecord
  642. if count > 1 {
  643. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  644. if err != nil {
  645. br.Msg = "查询浏览记录失败"
  646. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  647. return
  648. }
  649. }
  650. for k, v := range list {
  651. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  652. list[k].IsRed = true
  653. }
  654. timeLineRed := false
  655. if count < 2 && v.SubCategoryName == "时间线" {
  656. timeLineRed = true
  657. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  658. timeLineRed = true
  659. }
  660. if v.SubCategoryName == "时间线" && timeLineRed {
  661. list[k].IsRed = true
  662. }
  663. if v.VideoUrl != "" {
  664. list[k].IsHaveVideo = true
  665. }
  666. id := strconv.Itoa(timeLineCategoryId)
  667. list[k].ImgUrlPc = mapCategoryUrl[id]
  668. if mapCategoryUrl[id] == "" {
  669. if detail.ChartPermissionId == utils.YI_YAO_ID {
  670. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  671. }
  672. }
  673. }
  674. resp := new(models.TimeLineReportListResp)
  675. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  676. resp.List = list
  677. resp.Paging = page
  678. br.Ret = 200
  679. br.Success = true
  680. br.Msg = "获取成功"
  681. br.Data = resp
  682. }
  683. }
  684. // @Title 置顶/取消置顶
  685. // @Description 置顶
  686. // @Param request body models.CygxIndustryTopRep true "type json string"
  687. // @Success 200
  688. // @router /top [post]
  689. func (this *ReportController) ArticleCollect() {
  690. br := new(models.BaseResponse).Init()
  691. defer func() {
  692. this.Data["json"] = br
  693. this.ServeJSON()
  694. }()
  695. user := this.User
  696. if user == nil {
  697. br.Msg = "请重新登录"
  698. br.Ret = 408
  699. return
  700. }
  701. uid := user.UserId
  702. var req models.CygxIndustryTopRep
  703. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  704. if err != nil {
  705. br.Msg = "参数解析异常!"
  706. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  707. return
  708. }
  709. industrialManagementId := req.IndustrialManagementId
  710. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  711. if err != nil {
  712. br.Msg = "获取数据失败!"
  713. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  714. return
  715. }
  716. if countIndustrial == 0 {
  717. br.Msg = "产业不存在!"
  718. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  719. return
  720. }
  721. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  722. if err != nil {
  723. br.Msg = "获取数据失败!"
  724. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  725. return
  726. }
  727. resp := new(models.ArticleCollectResp)
  728. if count <= 0 {
  729. item := new(models.CygxIndustryTop)
  730. item.IndustrialManagementId = req.IndustrialManagementId
  731. item.UserId = uid
  732. item.CreateTime = time.Now()
  733. _, err = models.AddCygxIndustryTop(item)
  734. if err != nil {
  735. br.Msg = "置顶失败"
  736. br.ErrMsg = "置顶失败,Err:" + err.Error()
  737. return
  738. }
  739. br.Msg = "置顶成功"
  740. resp.Status = 1
  741. } else {
  742. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  743. if err != nil {
  744. br.Msg = "取消置顶失败"
  745. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  746. return
  747. }
  748. br.Msg = "已取消置顶"
  749. resp.Status = 2
  750. }
  751. br.Ret = 200
  752. br.Success = true
  753. br.Data = resp
  754. }
  755. // @Title 关注/取消关注产业
  756. // @Description 关注/取消关注 接口
  757. // @Param request body models.CygxIndustryFllowRep true "type json string"
  758. // @Success 200
  759. // @router /fllow [post]
  760. func (this *ReportController) Fllow() {
  761. br := new(models.BaseResponse).Init()
  762. defer func() {
  763. this.Data["json"] = br
  764. this.ServeJSON()
  765. }()
  766. user := this.User
  767. if user == nil {
  768. br.Msg = "请重新登录"
  769. br.Ret = 408
  770. return
  771. }
  772. uid := user.UserId
  773. var req models.CygxIndustryFllowRep
  774. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  775. if err != nil {
  776. br.Msg = "参数解析异常!"
  777. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  778. return
  779. }
  780. industrialManagementId := req.IndustrialManagementId
  781. var condition string
  782. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  783. if err != nil {
  784. br.Msg = "获取数据失败!"
  785. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  786. return
  787. }
  788. if countIndustrial == 0 {
  789. br.Msg = "产业不存在!"
  790. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  791. return
  792. }
  793. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  794. if err != nil {
  795. br.Msg = "获取数据失败!"
  796. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  797. return
  798. }
  799. resp := new(models.CygxIndustryFllowResp)
  800. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  801. if countUser == 0 {
  802. resp.GoFollow = true
  803. }
  804. if count == 0 {
  805. item := new(models.CygxIndustryFllow)
  806. item.IndustrialManagementId = industrialManagementId
  807. item.UserId = uid
  808. item.Email = user.Email
  809. item.Mobile = user.Mobile
  810. item.RealName = user.RealName
  811. item.CompanyId = user.CompanyId
  812. item.CompanyName = user.CompanyName
  813. item.Type = 1
  814. item.CreateTime = time.Now()
  815. item.ModifyTime = time.Now()
  816. _, err = models.AddCygxIndustryFllow(item)
  817. if err != nil {
  818. br.Msg = "操作失败"
  819. br.ErrMsg = "操作失败,Err:" + err.Error()
  820. return
  821. }
  822. resp.Status = 1
  823. } else {
  824. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  825. if err != nil {
  826. br.Msg = "操作失败"
  827. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  828. return
  829. }
  830. }
  831. //处理是否关注全部赛道字段
  832. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  833. br.Msg = "操作成功"
  834. br.Ret = 200
  835. br.Success = true
  836. br.Data = resp
  837. }
  838. // @Title 产业报告分类关联作者列表接口
  839. // @Description 获取产业报告分类关联作者列表接口
  840. // @Param ChartPermissionId query int true "分类ID"
  841. // @Param PageSize query int true "每页数据条数"
  842. // @Param CurrentIndex query int true "当前页页码,从1开始"
  843. // @Success 200 {object} models.CygxArticleDepartmentList
  844. // @router /industryListByDepartment [get]
  845. func (this *ReportController) IndustryListByDepartment() {
  846. br := new(models.BaseResponse).Init()
  847. defer func() {
  848. this.Data["json"] = br
  849. this.ServeJSON()
  850. }()
  851. user := this.User
  852. if user == nil {
  853. br.Msg = "请重新登录"
  854. br.Ret = 408
  855. return
  856. }
  857. uid := user.UserId
  858. pageSize, _ := this.GetInt("PageSize")
  859. currentIndex, _ := this.GetInt("CurrentIndex")
  860. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  861. var startSize int
  862. var condition string
  863. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  864. condition = ` AND a.publish_status=1 `
  865. if pageSize <= 0 {
  866. pageSize = utils.PageSize20
  867. }
  868. if currentIndex <= 0 {
  869. currentIndex = 1
  870. }
  871. startSize = paging.StartIndex(currentIndex, pageSize)
  872. total, err := models.GetArticleDepartmentCount(condition)
  873. page := paging.GetPaging(currentIndex, pageSize, total)
  874. resp := new(models.CygxArticleDepartmentList)
  875. userType, _, err := services.GetUserType(user.CompanyId)
  876. if err != nil {
  877. br.Msg = "获取信息失败"
  878. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  879. return
  880. }
  881. if userType == 1 {
  882. resp.Paging = page
  883. br.Ret = 200
  884. br.Success = true
  885. br.Msg = "获取成功"
  886. br.Data = resp
  887. return
  888. }
  889. resp.HaveResearch = true
  890. //获取作者信息,并排序
  891. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  892. if err != nil {
  893. br.Msg = "获取信息失败"
  894. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  895. return
  896. }
  897. for k, v := range list {
  898. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  899. if err != nil {
  900. br.Msg = "获取信息失败"
  901. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  902. return
  903. }
  904. for k2, v2 := range artList {
  905. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  906. if err != nil {
  907. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  908. br.ErrMsg = "获取失败,Err:" + err.Error()
  909. return
  910. }
  911. var subjectNamesNew string
  912. if len(subjectNames) > 0 {
  913. slice := strings.Split(subjectNames, "/")
  914. for k3, v3 := range slice {
  915. if k3 < 4 {
  916. subjectNamesNew += v3 + "/"
  917. }
  918. }
  919. }
  920. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  921. if err != nil && err.Error() != utils.ErrNoRow() {
  922. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  923. br.ErrMsg = "获取失败,Err:" + err.Error()
  924. return
  925. }
  926. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  927. artList[k2].SubjectName = subjectNamesNew
  928. artList[k2].DepartmentId = v.DepartmentId
  929. if subjectNamesNew == "" {
  930. artList[k2].IndustryName = industryName
  931. } else {
  932. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  933. }
  934. if artList[k2].IsReport == "1" {
  935. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  936. } else {
  937. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  938. }
  939. }
  940. list[k].List = artList
  941. if v.FollowNum > 0 {
  942. list[k].IsMyFollow = true
  943. }
  944. }
  945. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  946. if err != nil {
  947. br.Msg = "获取信息失败"
  948. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  949. return
  950. }
  951. if len(listnNew) > 0 {
  952. for _, v := range listnNew {
  953. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  954. Management := new(models.IndustrialManagementIdInt)
  955. if firstStr == 0 {
  956. Management.IndustryName = v.IndustryName
  957. } else {
  958. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  959. if err != nil {
  960. br.Msg = "获取信息失败"
  961. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  962. return
  963. }
  964. var subjectNamesNew string
  965. for _, v1 := range listSub {
  966. subjectNamesNew += v1.SubjectName + "/"
  967. }
  968. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  969. Management.IndustryName = subjectNamesNew
  970. }
  971. Management.IndustrialManagementId = v.IndustrialManagementId
  972. Management.ArticleId = v.ArticleId
  973. resp.ListnNew = append(resp.ListnNew, Management)
  974. }
  975. }
  976. resp.List = list
  977. resp.Paging = page
  978. br.Ret = 200
  979. br.Success = true
  980. br.Msg = "获取成功"
  981. br.Data = resp
  982. }
  983. // @Title 关注作者/取消关注作者
  984. // @Description 关注作者/取消关注作者 接口
  985. // @Param request body models.CygxArticleDepartmentId true "type json string"
  986. // @Success 200
  987. // @router /fllowDepartment [post]
  988. func (this *ReportController) FllowDepartment() {
  989. br := new(models.BaseResponse).Init()
  990. defer func() {
  991. this.Data["json"] = br
  992. this.ServeJSON()
  993. }()
  994. user := this.User
  995. if user == nil {
  996. br.Msg = "请重新登录"
  997. br.Ret = 408
  998. return
  999. }
  1000. uid := user.UserId
  1001. var req models.CygxArticleDepartmentId
  1002. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1003. if err != nil {
  1004. br.Msg = "参数解析异常!"
  1005. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1006. return
  1007. }
  1008. departmentId := req.DepartmentId
  1009. var condition string
  1010. countDepartment, err := models.GetDepartmentCount(departmentId)
  1011. if err != nil {
  1012. br.Msg = "获取数据失败!"
  1013. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. if countDepartment == 0 {
  1017. br.Msg = "作者不存在!"
  1018. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1019. return
  1020. }
  1021. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1022. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1023. if err != nil {
  1024. br.Msg = "获取数据失败!"
  1025. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1026. return
  1027. }
  1028. resp := new(models.CygxArticleDepartmentFollowResp)
  1029. if countUser == 0 {
  1030. resp.GoFollow = true
  1031. }
  1032. if count == 0 {
  1033. item := new(models.CygxArticleDepartmentFollow)
  1034. item.DepartmentId = departmentId
  1035. item.UserId = uid
  1036. item.Email = user.Email
  1037. item.Mobile = user.Mobile
  1038. item.RealName = user.RealName
  1039. item.CompanyId = user.CompanyId
  1040. item.CompanyName = user.CompanyName
  1041. item.Type = 1
  1042. item.CreateTime = time.Now()
  1043. item.ModifyTime = time.Now()
  1044. _, err = models.AddArticleDepartmentFollow(item)
  1045. if err != nil {
  1046. br.Msg = "操作失败"
  1047. br.ErrMsg = "操作失败,Err:" + err.Error()
  1048. return
  1049. }
  1050. resp.Status = 1
  1051. } else {
  1052. var doType int
  1053. condition = ` AND type = 1`
  1054. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1055. if err != nil {
  1056. br.Msg = "操作失败!"
  1057. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1058. return
  1059. }
  1060. if count == 1 {
  1061. resp.Status = 2
  1062. doType = 2
  1063. } else {
  1064. resp.Status = 1
  1065. doType = 1
  1066. }
  1067. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1068. if err != nil {
  1069. br.Msg = "操作失败"
  1070. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1071. return
  1072. }
  1073. }
  1074. br.Msg = "操作成功"
  1075. br.Ret = 200
  1076. br.Success = true
  1077. br.Data = resp
  1078. }
  1079. // @Title 研选文章列表接口
  1080. // @Description 获取研选文章列表接口
  1081. // @Param PageSize query int true "每页数据条数"
  1082. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1083. // @Param ArticleId query int true "文章id"
  1084. // @Param DepartmentId query int true "作者ID"
  1085. // @Param IndustrialManagementId query int true "产业ID"
  1086. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1087. // @router /industry/reportList [get]
  1088. func (this *ReportController) ReportList() {
  1089. br := new(models.BaseResponse).Init()
  1090. defer func() {
  1091. this.Data["json"] = br
  1092. this.ServeJSON()
  1093. }()
  1094. user := this.User
  1095. if user == nil {
  1096. br.Msg = "请重新登录"
  1097. br.Ret = 408
  1098. return
  1099. }
  1100. uid := user.UserId
  1101. pageSize, _ := this.GetInt("PageSize")
  1102. currentIndex, _ := this.GetInt("CurrentIndex")
  1103. departmentId, _ := this.GetInt("DepartmentId")
  1104. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1105. articleId, _ := this.GetInt("ArticleId")
  1106. var condition string
  1107. var startSize int
  1108. if pageSize <= 0 {
  1109. pageSize = utils.PageSize20
  1110. }
  1111. if currentIndex <= 0 {
  1112. currentIndex = 1
  1113. }
  1114. startSize = paging.StartIndex(currentIndex, pageSize)
  1115. var pars []interface{}
  1116. var total int
  1117. resp := new(models.ReportArticleWhichIndustrialRepList)
  1118. page := paging.GetPaging(currentIndex, pageSize, total)
  1119. userType, _, err := services.GetUserType(user.CompanyId)
  1120. if err != nil {
  1121. br.Msg = "获取信息失败"
  1122. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1123. return
  1124. }
  1125. if userType == 1 {
  1126. resp.Paging = page
  1127. br.Ret = 200
  1128. br.Success = true
  1129. br.Msg = "获取成功"
  1130. br.Data = resp
  1131. return
  1132. }
  1133. resp.HaveResearch = true
  1134. if departmentId > 0 {
  1135. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1136. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1137. if err != nil {
  1138. br.Msg = "获取信息失败"
  1139. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1140. return
  1141. }
  1142. resp.NickName = detail.NickName
  1143. }
  1144. if industrialManagementId > 0 {
  1145. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1146. }
  1147. if articleId > 0 {
  1148. detail, err := models.GetArticleDetailById(articleId)
  1149. if err != nil {
  1150. br.Msg = "获取信息失败"
  1151. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1152. return
  1153. }
  1154. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1155. }
  1156. total, err = models.GetWhichDepartmentCount(condition)
  1157. if err != nil {
  1158. br.Msg = "获取信息失败"
  1159. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1160. return
  1161. }
  1162. page = paging.GetPaging(currentIndex, pageSize, total)
  1163. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1164. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1165. if err != nil {
  1166. br.Msg = "获取失败"
  1167. br.ErrMsg = "获取失败,Err:" + err.Error()
  1168. return
  1169. }
  1170. for k, v := range list {
  1171. if v.Readnum == 0 {
  1172. list[k].IsRed = true
  1173. }
  1174. list[k].IsResearch = true
  1175. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1176. if err != nil {
  1177. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1178. br.ErrMsg = "获取失败,Err:" + err.Error()
  1179. return
  1180. }
  1181. var subjectNamesNew string
  1182. if len(subjectNames) > 0 {
  1183. slice := strings.Split(subjectNames, "/")
  1184. for k3, v3 := range slice {
  1185. if k3 < 4 {
  1186. subjectNamesNew += v3 + "/"
  1187. }
  1188. }
  1189. }
  1190. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1191. if err != nil && err.Error() != utils.ErrNoRow() {
  1192. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1193. br.ErrMsg = "获取失败,Err:" + err.Error()
  1194. return
  1195. }
  1196. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1197. list[k].SubjectName = subjectNamesNew
  1198. if subjectNamesNew != "" {
  1199. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1200. } else {
  1201. list[k].IndustryName = industryName
  1202. }
  1203. resp.IndustryName = industryName
  1204. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1205. }
  1206. resp.List = list
  1207. resp.Paging = page
  1208. br.Ret = 200
  1209. br.Success = true
  1210. br.Msg = "获取成功"
  1211. br.Data = resp
  1212. }
  1213. // @Title 研选最新主题关键词文章列表接口
  1214. // @Description 获取研选最新主题关键词文章列表接口
  1215. // @Param PageSize query int true "每页数据条数"
  1216. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1217. // @Param ArticleId query int true "文章id"
  1218. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1219. // @router /industry/reportListNew [get]
  1220. func (this *ReportController) ReportListNew() {
  1221. br := new(models.BaseResponse).Init()
  1222. defer func() {
  1223. this.Data["json"] = br
  1224. this.ServeJSON()
  1225. }()
  1226. user := this.User
  1227. if user == nil {
  1228. br.Msg = "请重新登录"
  1229. br.Ret = 408
  1230. return
  1231. }
  1232. uid := user.UserId
  1233. pageSize, _ := this.GetInt("PageSize")
  1234. currentIndex, _ := this.GetInt("CurrentIndex")
  1235. articleId, _ := this.GetInt("ArticleId")
  1236. var condition string
  1237. var startSize int
  1238. if pageSize <= 0 {
  1239. pageSize = utils.PageSize20
  1240. }
  1241. if currentIndex <= 0 {
  1242. currentIndex = 1
  1243. }
  1244. startSize = paging.StartIndex(currentIndex, pageSize)
  1245. var pars []interface{}
  1246. var total int
  1247. resp := new(models.ReportArticleWhichIndustrialRepList)
  1248. page := paging.GetPaging(currentIndex, pageSize, total)
  1249. userType, _, err := services.GetUserType(user.CompanyId)
  1250. if err != nil {
  1251. br.Msg = "获取信息失败"
  1252. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1253. return
  1254. }
  1255. if userType == 1 {
  1256. resp.Paging = page
  1257. br.Ret = 200
  1258. br.Success = true
  1259. br.Msg = "获取成功"
  1260. br.Data = resp
  1261. return
  1262. }
  1263. resp.HaveResearch = true
  1264. if articleId > 0 {
  1265. detail, err := models.GetArticleDetailById(articleId)
  1266. if err != nil {
  1267. br.Msg = "获取信息失败"
  1268. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1269. return
  1270. }
  1271. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1272. if firstStr == 0 {
  1273. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1274. } else {
  1275. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1276. }
  1277. }
  1278. total, err = models.GetWhichDepartmentCount(condition)
  1279. if err != nil {
  1280. br.Msg = "获取信息失败"
  1281. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1282. return
  1283. }
  1284. page = paging.GetPaging(currentIndex, pageSize, total)
  1285. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1286. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1287. if err != nil {
  1288. br.Msg = "获取失败"
  1289. br.ErrMsg = "获取失败,Err:" + err.Error()
  1290. return
  1291. }
  1292. for k, v := range list {
  1293. if v.Readnum == 0 {
  1294. list[k].IsRed = true
  1295. }
  1296. list[k].IsResearch = true
  1297. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1298. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1299. if err != nil {
  1300. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1301. br.ErrMsg = "获取失败,Err:" + err.Error()
  1302. return
  1303. }
  1304. var subjectNamesNew string
  1305. if len(subjectNames) > 0 {
  1306. slice := strings.Split(subjectNames, "/")
  1307. for k3, v3 := range slice {
  1308. if k3 < 4 {
  1309. subjectNamesNew += v3 + "/"
  1310. }
  1311. }
  1312. }
  1313. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1314. if err != nil && err.Error() != utils.ErrNoRow() {
  1315. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1316. br.ErrMsg = "获取失败,Err:" + err.Error()
  1317. return
  1318. }
  1319. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1320. list[k].SubjectName = subjectNamesNew
  1321. if subjectNamesNew != "" {
  1322. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1323. } else {
  1324. list[k].IndustryName = industryName
  1325. }
  1326. resp.IndustryName = industryName
  1327. }
  1328. resp.List = list
  1329. resp.Paging = page
  1330. br.Ret = 200
  1331. br.Success = true
  1332. br.Msg = "获取成功"
  1333. br.Data = resp
  1334. }
  1335. // @Title 是否展示绝密内参
  1336. // @Description 获取是否展示绝密内参接口
  1337. // @Param request body models.IsShow true "type json string"
  1338. // @Success 200
  1339. // @router /isShow [get]
  1340. func (this *ReportController) IsShow() {
  1341. br := new(models.BaseResponse).Init()
  1342. defer func() {
  1343. this.Data["json"] = br
  1344. this.ServeJSON()
  1345. }()
  1346. user := this.User
  1347. if user == nil {
  1348. br.Msg = "请重新登录"
  1349. br.Ret = 408
  1350. return
  1351. }
  1352. var resp models.IsShow
  1353. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1354. if err != nil {
  1355. br.Msg = "获取失败"
  1356. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1357. return
  1358. }
  1359. resp.IsShowChart = true
  1360. //resp.IsShowResearch = true
  1361. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1362. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1363. //resp.YanXuan_Explain = true
  1364. resp.IsShowFreeButton = IsShowFreeButton
  1365. //mobile := user.Mobile
  1366. //if mobile == "" {
  1367. // br.Ret = 200
  1368. // br.Success = true
  1369. // br.Data = resp
  1370. // return
  1371. //}
  1372. //total, _ := models.GetUserIsAdminCount(mobile)
  1373. //if total > 0 {
  1374. // resp.IsShowList = true
  1375. //}
  1376. resp.IsShowList = true
  1377. resp.SearchTxtList.SummarySearch = "全局搜索"
  1378. resp.SearchTxtList.ReportSearch = "全局搜索"
  1379. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1380. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1381. resp.SearchTxtList.TabSearch = "请输入关键词"
  1382. resp.IsShow = true
  1383. br.Ret = 200
  1384. br.Success = true
  1385. br.Data = resp
  1386. }
  1387. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1388. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1389. // @Param PageSize query int true "每页数据条数"
  1390. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1391. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1392. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1393. // @router /reportList/byType [get]
  1394. func (this *ReportController) ReportListByType() {
  1395. br := new(models.BaseResponse).Init()
  1396. defer func() {
  1397. this.Data["json"] = br
  1398. this.ServeJSON()
  1399. }()
  1400. user := this.User
  1401. if user == nil {
  1402. br.Msg = "请重新登录"
  1403. br.Ret = 408
  1404. return
  1405. }
  1406. uid := user.UserId
  1407. pageSize, _ := this.GetInt("PageSize")
  1408. currentIndex, _ := this.GetInt("CurrentIndex")
  1409. reportType := this.GetString("ReportType")
  1410. var condition string
  1411. var startSize int
  1412. if pageSize <= 0 {
  1413. pageSize = utils.PageSize20
  1414. }
  1415. if currentIndex <= 0 {
  1416. currentIndex = 1
  1417. }
  1418. startSize = paging.StartIndex(currentIndex, pageSize)
  1419. var pars []interface{}
  1420. var total int
  1421. resp := new(models.CygxReportSelectionListPublicRep)
  1422. page := paging.GetPaging(currentIndex, pageSize, total)
  1423. var tbdb string
  1424. var readSql string
  1425. var reportTypeStr string
  1426. if reportType == "1" {
  1427. tbdb = "cygx_report_selection"
  1428. reportTypeStr = "bgjx"
  1429. } else if reportType == "2" {
  1430. tbdb = "cygx_research_summary"
  1431. reportTypeStr = "bzyjhz"
  1432. } else if reportType == "3" {
  1433. tbdb = "cygx_minutes_summary"
  1434. reportTypeStr = "szjyhz"
  1435. } else {
  1436. br.Msg = "请选择报告类型"
  1437. return
  1438. }
  1439. fmt.Println(tbdb)
  1440. condition = ` AND publish_status = 1 `
  1441. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1442. if err != nil {
  1443. br.Msg = "获取信息失败"
  1444. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1445. return
  1446. }
  1447. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1448. if reportType == "1" {
  1449. startSize = 0
  1450. pageSize = 1
  1451. total = 1
  1452. }
  1453. 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`
  1454. page = paging.GetPaging(currentIndex, pageSize, total)
  1455. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1456. if err != nil {
  1457. br.Msg = "获取失败"
  1458. br.ErrMsg = "获取失败,Err:" + err.Error()
  1459. return
  1460. }
  1461. for k, v := range list {
  1462. if reportType == "1" {
  1463. list[k].Abstract = v.UpdateDescription
  1464. }
  1465. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1466. if v.ReadNum == 0 {
  1467. list[k].IsRed = true
  1468. }
  1469. }
  1470. resp.List = list
  1471. resp.Paging = page
  1472. br.Ret = 200
  1473. br.Success = true
  1474. br.Msg = "获取成功"
  1475. br.Data = resp
  1476. }
  1477. // @Title 获取报告精选详情
  1478. // @Description 获取报告精选详情接口
  1479. // @Param ArticleId query int true "报告ID"
  1480. // @Success 200 {object} models.ReportSelectionLetailResp
  1481. // @router /reportSelection/detail [get]
  1482. func (this *ReportController) Detail() {
  1483. br := new(models.BaseResponse).Init()
  1484. defer func() {
  1485. this.Data["json"] = br
  1486. this.ServeJSON()
  1487. }()
  1488. user := this.User
  1489. if user == nil {
  1490. br.Msg = "请重新登录"
  1491. br.Ret = 408
  1492. return
  1493. }
  1494. uid := user.UserId
  1495. articleId, _ := this.GetInt("ArticleId")
  1496. if articleId < 0 {
  1497. br.Msg = "参数错误"
  1498. br.ErrMsg = "参数错误"
  1499. return
  1500. }
  1501. resp := new(models.ReportSelectionLetailResp)
  1502. //判断用户权限
  1503. hasPermission, err := services.GetUserhasPermission(user)
  1504. if err != nil {
  1505. br.Msg = "获取信息失败"
  1506. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1507. }
  1508. resp.HasPermission = hasPermission
  1509. if hasPermission != 1 {
  1510. br.Ret = 200
  1511. br.Success = true
  1512. br.Msg = "获取成功"
  1513. br.Data = resp
  1514. return
  1515. }
  1516. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1517. if err != nil {
  1518. br.Msg = "获取信息失败"
  1519. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1520. return
  1521. }
  1522. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1523. existMap := make(map[int]int)
  1524. var items []*models.ReportSelectionChartPermission
  1525. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1526. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1527. if err != nil {
  1528. br.Msg = "获取失败"
  1529. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1530. return
  1531. }
  1532. //var itemLogs []*models.CygxReportSelectionLogDetail
  1533. for _, v := range listLog {
  1534. item := new(models.ReportSelectionChartPermission)
  1535. if existMap[v.ChartPermissionId] == 0 {
  1536. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1537. item.IcoLink = v.IcoLink
  1538. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1539. if err != nil && err.Error() != utils.ErrNoRow() {
  1540. br.Msg = "获取信息失败"
  1541. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1542. return
  1543. }
  1544. for k2, v2 := range listSonLog {
  1545. if v2.IndustrialManagementId != "" {
  1546. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1547. if err != nil && err.Error() != utils.ErrNoRow() {
  1548. br.Msg = "获取信息失败"
  1549. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1550. return
  1551. }
  1552. listSonLog[k2].List = listIndustrial
  1553. }
  1554. }
  1555. item.List = listSonLog
  1556. items = append(items, item)
  1557. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1558. }
  1559. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1560. }
  1561. historyRecord := new(models.CygxReportHistoryRecord)
  1562. historyRecord.UserId = uid
  1563. historyRecord.ArticleId = articleId
  1564. historyRecord.CreateTime = time.Now()
  1565. historyRecord.Mobile = user.Mobile
  1566. historyRecord.Email = user.Email
  1567. historyRecord.CompanyId = user.CompanyId
  1568. historyRecord.CompanyName = user.CompanyName
  1569. historyRecord.ReportType = "bgjx"
  1570. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1571. if err != nil && err.Error() != utils.ErrNoRow() {
  1572. br.Msg = "获取信息失败"
  1573. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1574. return
  1575. }
  1576. historyRecord.RealName = user.RealName
  1577. if sellerItem != nil {
  1578. historyRecord.SellerName = sellerItem.RealName
  1579. }
  1580. go models.AddCygxReportHistoryRecord(historyRecord)
  1581. resp.List = items
  1582. resp.Detail = detail
  1583. br.Ret = 200
  1584. br.Success = true
  1585. br.Msg = "获取成功"
  1586. br.Data = resp
  1587. }
  1588. // @Title 获取本周研究汇总详情
  1589. // @Description 获取本周研究汇总详情接口
  1590. // @Param ArticleId query int true "报告ID"
  1591. // @Success 200 {object} models.ResearchSummaryLetailResp
  1592. // @router /researchSummary/detail [get]
  1593. func (this *ReportController) ResearchDetail() {
  1594. br := new(models.BaseResponse).Init()
  1595. defer func() {
  1596. this.Data["json"] = br
  1597. this.ServeJSON()
  1598. }()
  1599. user := this.User
  1600. if user == nil {
  1601. br.Msg = "请重新登录"
  1602. br.Ret = 408
  1603. return
  1604. }
  1605. uid := user.UserId
  1606. articleId, _ := this.GetInt("ArticleId")
  1607. if articleId < 0 {
  1608. br.Msg = "参数错误"
  1609. br.ErrMsg = "参数错误"
  1610. return
  1611. }
  1612. resp := new(models.ResearchSummaryLetailResp)
  1613. //判断用户权限
  1614. hasPermission, err := services.GetUserhasPermission(user)
  1615. if err != nil {
  1616. br.Msg = "获取信息失败"
  1617. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1618. }
  1619. resp.HasPermission = hasPermission
  1620. if hasPermission != 1 {
  1621. br.Ret = 200
  1622. br.Success = true
  1623. br.Msg = "获取成功"
  1624. br.Data = resp
  1625. return
  1626. }
  1627. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1628. if err != nil {
  1629. br.Msg = "获取信息失败"
  1630. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1631. return
  1632. }
  1633. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1634. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1635. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1636. if err != nil {
  1637. br.Msg = "获取失败"
  1638. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1639. return
  1640. }
  1641. listArticleType, err := models.GetCygxArticleTypeList()
  1642. if err != nil {
  1643. br.Msg = "获取失败"
  1644. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1645. return
  1646. }
  1647. for k, v := range listFirst {
  1648. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1649. if err != nil && err.Error() != utils.ErrNoRow() {
  1650. br.Msg = "获取信息失败"
  1651. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1652. return
  1653. }
  1654. for k2, v2 := range listSecond {
  1655. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1656. if err != nil && err.Error() != utils.ErrNoRow() {
  1657. br.Msg = "获取信息失败"
  1658. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1659. return
  1660. }
  1661. for _, vType := range listArticleType {
  1662. if v2.ChartPermissionId == vType.YanxPermissionId {
  1663. listSecond[k2].IcoLink = vType.IcoLinkM
  1664. listSecond[k2].PermissionName = vType.YanxPermissionName
  1665. }
  1666. }
  1667. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1668. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1669. // listSecond[k2].PermissionName = "买方研选纪要"
  1670. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1671. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1672. // listSecond[k2].PermissionName = "买方研选观点"
  1673. //}
  1674. if len(listThird) > 0 {
  1675. for k3, v3 := range listThird {
  1676. if v3.VideoUrl != "" {
  1677. listThird[k3].IsHaveVideo = true
  1678. }
  1679. if v3.ReportLink == "0" {
  1680. listThird[k3].ReportLink = ""
  1681. }
  1682. }
  1683. listSecond[k2].List = listThird
  1684. }
  1685. }
  1686. if len(listSecond) > 0 {
  1687. listFirst[k].List = listSecond
  1688. }
  1689. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1690. if v.Type == "SDBG" {
  1691. listFirst[k].ListName = "深度报告"
  1692. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1693. } else if v.Type == "BZCHJH" {
  1694. listFirst[k].ListName = "本周晨会精华"
  1695. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1696. } else if v.Type == "CYDYJY" {
  1697. listFirst[k].ListName = "产业调研纪要"
  1698. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1699. } else if v.Type == "SSGS" {
  1700. listFirst[k].ListName = "上市公司调研纪要篇"
  1701. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1702. } else if v.Type == "SJDP" {
  1703. listFirst[k].ListName = "事件点评"
  1704. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1705. } else if v.Type == "YANX" {
  1706. listFirst[k].ListName = "买方研选"
  1707. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1708. }
  1709. }
  1710. historyRecord := new(models.CygxReportHistoryRecord)
  1711. historyRecord.UserId = uid
  1712. historyRecord.ArticleId = articleId
  1713. historyRecord.CreateTime = time.Now()
  1714. historyRecord.Mobile = user.Mobile
  1715. historyRecord.Email = user.Email
  1716. historyRecord.CompanyId = user.CompanyId
  1717. historyRecord.CompanyName = user.CompanyName
  1718. historyRecord.ReportType = "bzyjhz"
  1719. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1720. if err != nil && err.Error() != utils.ErrNoRow() {
  1721. br.Msg = "获取信息失败"
  1722. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1723. return
  1724. }
  1725. historyRecord.RealName = user.RealName
  1726. if sellerItem != nil {
  1727. historyRecord.SellerName = sellerItem.RealName
  1728. }
  1729. go models.AddCygxReportHistoryRecord(historyRecord)
  1730. resp.List = listFirst
  1731. resp.Detail = detail
  1732. br.Ret = 200
  1733. br.Success = true
  1734. br.Msg = "获取成功"
  1735. br.Data = resp
  1736. }
  1737. // @Title 上周纪要汇总内容详情
  1738. // @Description 获取上周纪要汇总内容详情接口
  1739. // @Param ArticleId query int true "报告ID"
  1740. // @Success 200 {object} models.MinutesSummaryLetailResp
  1741. // @router /minutesSummary/detailv4 [get]
  1742. func (this *ReportController) MinutesDetailV4() {
  1743. br := new(models.BaseResponse).Init()
  1744. defer func() {
  1745. this.Data["json"] = br
  1746. this.ServeJSON()
  1747. }()
  1748. user := this.User
  1749. if user == nil {
  1750. br.Msg = "请重新登录"
  1751. br.Ret = 408
  1752. return
  1753. }
  1754. uid := user.UserId
  1755. articleId, _ := this.GetInt("ArticleId")
  1756. if articleId < 0 {
  1757. br.Msg = "参数错误"
  1758. br.ErrMsg = "参数错误"
  1759. return
  1760. }
  1761. resp := new(models.MinutesSummaryLetailRespV4)
  1762. //判断用户权限
  1763. hasPermission, err := services.GetUserhasPermission(user)
  1764. if err != nil {
  1765. br.Msg = "获取信息失败"
  1766. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1767. }
  1768. resp.HasPermission = hasPermission
  1769. if hasPermission != 1 {
  1770. br.Ret = 200
  1771. br.Success = true
  1772. br.Msg = "获取成功"
  1773. br.Data = resp
  1774. return
  1775. }
  1776. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1777. if err != nil {
  1778. br.Msg = "获取信息失败"
  1779. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1780. return
  1781. }
  1782. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1783. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1784. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1785. if err != nil {
  1786. br.Msg = "获取失败"
  1787. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1788. return
  1789. }
  1790. for k, v := range listFirst {
  1791. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1792. if err != nil && err.Error() != utils.ErrNoRow() {
  1793. br.Msg = "获取信息失败"
  1794. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1795. return
  1796. }
  1797. for k2, v2 := range listSecond {
  1798. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1799. if err != nil && err.Error() != utils.ErrNoRow() {
  1800. br.Msg = "获取信息失败"
  1801. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1802. return
  1803. }
  1804. if len(listThird) > 0 {
  1805. for k3, v3 := range listThird {
  1806. if v3.VideoUrl != "" {
  1807. listThird[k3].IsHaveVideo = true
  1808. }
  1809. if v3.ReportLink == "0" {
  1810. listThird[k3].ReportLink = ""
  1811. }
  1812. }
  1813. listSecond[k2].List = listThird
  1814. }
  1815. }
  1816. if len(listSecond) > 0 {
  1817. listFirst[k].List = listSecond
  1818. }
  1819. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1820. if v.Type == "CYDYJY" {
  1821. listFirst[k].ListName = "产业调研纪要"
  1822. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1823. } else if v.Type == "SSGS" {
  1824. listFirst[k].ListName = "上市公司调研纪要篇"
  1825. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1826. } else if v.Type == "YANX" {
  1827. listFirst[k].ListName = "买方研选纪要"
  1828. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1829. }
  1830. }
  1831. historyRecord := new(models.CygxReportHistoryRecord)
  1832. historyRecord.UserId = uid
  1833. historyRecord.ArticleId = articleId
  1834. historyRecord.CreateTime = time.Now()
  1835. historyRecord.Mobile = user.Mobile
  1836. historyRecord.Email = user.Email
  1837. historyRecord.CompanyId = user.CompanyId
  1838. historyRecord.CompanyName = user.CompanyName
  1839. historyRecord.ReportType = "szjyhz"
  1840. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1841. if err != nil && err.Error() != utils.ErrNoRow() {
  1842. br.Msg = "获取信息失败"
  1843. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1844. return
  1845. }
  1846. historyRecord.RealName = user.RealName
  1847. if sellerItem != nil {
  1848. historyRecord.SellerName = sellerItem.RealName
  1849. }
  1850. go models.AddCygxReportHistoryRecord(historyRecord)
  1851. resp.List = listFirst
  1852. resp.Detail = detail
  1853. br.Ret = 200
  1854. br.Success = true
  1855. br.Msg = "获取成功"
  1856. br.Data = resp
  1857. }
  1858. // @Title 上周纪要汇总内容详情
  1859. // @Description 获取上周纪要汇总内容详情接口
  1860. // @Param ArticleId query int true "报告ID"
  1861. // @Success 200 {object} models.MinutesSummaryLetailResp
  1862. // @router /minutesSummary/detail [get]
  1863. func (this *ReportController) MinutesDetail() {
  1864. br := new(models.BaseResponse).Init()
  1865. defer func() {
  1866. this.Data["json"] = br
  1867. this.ServeJSON()
  1868. }()
  1869. user := this.User
  1870. if user == nil {
  1871. br.Msg = "请重新登录"
  1872. br.Ret = 408
  1873. return
  1874. }
  1875. uid := user.UserId
  1876. articleId, _ := this.GetInt("ArticleId")
  1877. if articleId < 0 {
  1878. br.Msg = "参数错误"
  1879. br.ErrMsg = "参数错误"
  1880. return
  1881. }
  1882. resp := new(models.MinutesSummaryLetailResp)
  1883. //判断用户权限
  1884. hasPermission, err := services.GetUserhasPermission(user)
  1885. if err != nil {
  1886. br.Msg = "获取信息失败"
  1887. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1888. }
  1889. resp.HasPermission = hasPermission
  1890. if hasPermission != 1 {
  1891. br.Ret = 200
  1892. br.Success = true
  1893. br.Msg = "获取成功"
  1894. br.Data = resp
  1895. return
  1896. }
  1897. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1898. if err != nil {
  1899. br.Msg = "获取信息失败"
  1900. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1901. return
  1902. }
  1903. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1904. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1905. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1906. if err != nil {
  1907. br.Msg = "获取失败"
  1908. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1909. return
  1910. }
  1911. for k, v := range listLog {
  1912. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1913. if err != nil && err.Error() != utils.ErrNoRow() {
  1914. br.Msg = "获取信息失败"
  1915. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1916. return
  1917. }
  1918. if len(listSonLog) > 0 {
  1919. listLog[k].List = listSonLog
  1920. for k2, v2 := range listSonLog {
  1921. if v2.ReportLink == "0" {
  1922. listSonLog[k2].ReportLink = ""
  1923. }
  1924. }
  1925. }
  1926. }
  1927. historyRecord := new(models.CygxReportHistoryRecord)
  1928. historyRecord.UserId = uid
  1929. historyRecord.ArticleId = articleId
  1930. historyRecord.CreateTime = time.Now()
  1931. historyRecord.Mobile = user.Mobile
  1932. historyRecord.Email = user.Email
  1933. historyRecord.CompanyId = user.CompanyId
  1934. historyRecord.CompanyName = user.CompanyName
  1935. historyRecord.ReportType = "szjyhz"
  1936. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1937. if err != nil && err.Error() != utils.ErrNoRow() {
  1938. br.Msg = "获取信息失败"
  1939. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1940. return
  1941. }
  1942. historyRecord.RealName = user.RealName
  1943. if sellerItem != nil {
  1944. historyRecord.SellerName = sellerItem.RealName
  1945. }
  1946. go models.AddCygxReportHistoryRecord(historyRecord)
  1947. resp.List = listLog
  1948. resp.Detail = detail
  1949. br.Ret = 200
  1950. br.Success = true
  1951. br.Msg = "获取成功"
  1952. br.Data = resp
  1953. }
  1954. // @Title 获取路演精华详情
  1955. // @Description 获取路演精华详情接口
  1956. // @Param ArticleId query int true "报告ID"
  1957. // @Success 200 {object} models.RoadshowDetailResp
  1958. // @router /roadshowEssence/detail [get]
  1959. func (this *ReportController) RoadshowDetail() {
  1960. br := new(models.BaseResponse).Init()
  1961. defer func() {
  1962. this.Data["json"] = br
  1963. this.ServeJSON()
  1964. }()
  1965. user := this.User
  1966. if user == nil {
  1967. br.Msg = "请登录"
  1968. br.ErrMsg = "请登录,用户信息为空"
  1969. br.Ret = 408
  1970. return
  1971. }
  1972. uid := user.UserId
  1973. articleId, err := this.GetInt("ArticleId")
  1974. if articleId <= 0 {
  1975. br.Msg = "文章不存在"
  1976. br.ErrMsg = "文章不存在,文章ID错误"
  1977. return
  1978. }
  1979. detail := new(models.ReportDetailRoadshow)
  1980. hasPermission := 0
  1981. hasFree := 0
  1982. //判断是否已经申请过
  1983. applyCount, err := models.GetApplyRecordCount(uid)
  1984. if err != nil && err.Error() != utils.ErrNoRow() {
  1985. br.Msg = "获取信息失败"
  1986. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1987. return
  1988. }
  1989. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1990. if user.CompanyId > 1 {
  1991. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1992. if err != nil {
  1993. br.Msg = "获取信息失败"
  1994. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1995. return
  1996. }
  1997. detail, err = models.GetReportRoadshowDetailById(articleId)
  1998. if err != nil {
  1999. br.Msg = "获取信息失败"
  2000. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2001. return
  2002. }
  2003. detail.Body = html.UnescapeString(detail.Body)
  2004. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2005. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2006. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2007. if detail.ReportLink == "0" {
  2008. detail.ReportLink = ""
  2009. }
  2010. if companyPermission == "" {
  2011. if applyCount > 0 {
  2012. hasPermission = 5
  2013. } else {
  2014. hasPermission = 2
  2015. }
  2016. hasFree = 2
  2017. goto Loop
  2018. } else {
  2019. hasFree = 1
  2020. var articlePermissionPermissionName string
  2021. articlePermissionPermissionName = detail.CategoryName
  2022. var hasPersion bool
  2023. slice := strings.Split(articlePermissionPermissionName, ",")
  2024. for _, v := range slice {
  2025. if strings.Contains(companyPermission, v) {
  2026. hasPersion = true
  2027. }
  2028. }
  2029. if hasPersion {
  2030. hasPermission = 1
  2031. historyRecord := new(models.CygxArticleHistoryRecord)
  2032. historyRecord.UserId = uid
  2033. historyRecord.ArticleId = articleId
  2034. historyRecord.CreateTime = time.Now()
  2035. historyRecord.Mobile = user.Mobile
  2036. historyRecord.Email = user.Email
  2037. historyRecord.CompanyId = user.CompanyId
  2038. historyRecord.CompanyName = user.CompanyName
  2039. go models.AddCygxArticleHistoryRecord(historyRecord)
  2040. } else { //无该行业权限
  2041. hasPermission = 3
  2042. }
  2043. if hasPermission == 1 {
  2044. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2045. if !utils.Rc.IsExist(key) {
  2046. //新增浏览记录
  2047. record := new(models.CygxArticleViewRecord)
  2048. record.UserId = uid
  2049. record.ArticleId = articleId
  2050. record.CreateTime = time.Now()
  2051. record.Mobile = user.Mobile
  2052. record.Email = user.Email
  2053. record.CompanyId = user.CompanyId
  2054. record.CompanyName = user.CompanyName
  2055. go models.AddCygxArticleViewRecord(record)
  2056. utils.Rc.Put(key, 1, 5*time.Second)
  2057. models.ModifyReportLastViewTime(uid)
  2058. }
  2059. }
  2060. }
  2061. } else { //潜在客户
  2062. if applyCount > 0 {
  2063. hasPermission = 5
  2064. } else {
  2065. hasPermission = 4
  2066. }
  2067. }
  2068. Loop:
  2069. if hasPermission != 1 {
  2070. detail.Body = ""
  2071. detail.Abstract = ""
  2072. }
  2073. resp := new(models.RoadshowDetailResp)
  2074. resp.HasPermission = hasPermission
  2075. resp.HasFree = hasFree
  2076. resp.Detail = detail
  2077. br.Ret = 200
  2078. br.Success = true
  2079. br.Msg = "获取成功"
  2080. br.Data = resp
  2081. }
  2082. // @Title 产业文章列表接口
  2083. // @Description 获取产业文章列表接口
  2084. // @Param KeyWord query string true "搜索关键词"
  2085. // @Success 200 {object} models.CygxIndustrySearchList
  2086. // @router /industryAndArticle/list [get]
  2087. func (this *ReportController) IndustryAndArticleList() {
  2088. br := new(models.BaseResponse).Init()
  2089. defer func() {
  2090. this.Data["json"] = br
  2091. this.ServeJSON()
  2092. }()
  2093. user := this.User
  2094. if user == nil {
  2095. br.Msg = "请重新登录"
  2096. br.Ret = 408
  2097. return
  2098. }
  2099. uid := user.UserId
  2100. keyWord := this.GetString("KeyWord")
  2101. orderSrt := "update_time DESC"
  2102. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2103. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2104. if err != nil {
  2105. br.Msg = "获取信息失败"
  2106. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2107. return
  2108. }
  2109. for k, v := range list {
  2110. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2111. if err != nil {
  2112. br.Msg = "获取信息失败"
  2113. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2114. return
  2115. }
  2116. list[k].IndustrialSubjectList = industrialSubjectList
  2117. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2118. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2119. if err != nil {
  2120. br.Msg = "获取信息失败"
  2121. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2122. return
  2123. }
  2124. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2125. }
  2126. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2127. if err != nil {
  2128. br.Msg = "获取失败"
  2129. br.ErrMsg = "获取失败,Err:" + err.Error()
  2130. return
  2131. }
  2132. for k2, v2 := range artList {
  2133. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2134. if err != nil {
  2135. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2136. br.ErrMsg = "获取失败,Err:" + err.Error()
  2137. return
  2138. }
  2139. var subjectNamesNew string
  2140. if len(subjectNames) > 0 {
  2141. slice := strings.Split(subjectNames, "/")
  2142. for k3, v3 := range slice {
  2143. if k3 < 4 {
  2144. subjectNamesNew += v3 + "/"
  2145. }
  2146. }
  2147. }
  2148. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2149. if err != nil && err.Error() != utils.ErrNoRow() {
  2150. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2151. br.ErrMsg = "获取失败,Err:" + err.Error()
  2152. return
  2153. }
  2154. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2155. artList[k2].SubjectName = subjectNamesNew
  2156. if subjectNamesNew == "" {
  2157. artList[k2].IndustryName = industryName
  2158. } else {
  2159. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2160. }
  2161. }
  2162. if keyWord != "" {
  2163. keyWordItem := new(models.CygxUserSearchKeyWord)
  2164. keyWordItem.UserId = user.UserId
  2165. keyWordItem.KeyWord = keyWord
  2166. keyWordItem.PageType = "ReortSearch"
  2167. keyWordItem.CreateTime = time.Now()
  2168. go models.AddUserSearchKeyWord(keyWordItem)
  2169. }
  2170. resp := new(models.CygxIndustrySearchList)
  2171. resp.ArtList = artList
  2172. resp.IndList = list
  2173. br.Ret = 200
  2174. br.Success = true
  2175. br.Msg = "获取成功"
  2176. br.Data = resp
  2177. }
  2178. // @Title 产业报告分类关联作者列表接口Pc端
  2179. // @Description 获取产业报告分类关联作者列表接口Pc端
  2180. // @Param ChartPermissionId query int true "分类ID"
  2181. // @Param KeyWord query string true "搜索关键词"
  2182. // @Param PageSize query int true "每页数据条数"
  2183. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2184. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2185. // @router /industryListByDepartmentPc [get]
  2186. func (this *ReportController) IndustryListByDepartmentPc() {
  2187. br := new(models.BaseResponse).Init()
  2188. defer func() {
  2189. this.Data["json"] = br
  2190. this.ServeJSON()
  2191. }()
  2192. user := this.User
  2193. if user == nil {
  2194. br.Msg = "请重新登录"
  2195. br.Ret = 408
  2196. return
  2197. }
  2198. uid := user.UserId
  2199. pageSize, _ := this.GetInt("PageSize")
  2200. currentIndex, _ := this.GetInt("CurrentIndex")
  2201. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2202. keyWord := this.GetString("KeyWord")
  2203. var startSize int
  2204. var condition string
  2205. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2206. if pageSize <= 0 {
  2207. pageSize = utils.PageSize20
  2208. }
  2209. if currentIndex <= 0 {
  2210. currentIndex = 1
  2211. }
  2212. var articleIdGroup string
  2213. if keyWord != "" {
  2214. //获取标的关联的文章ID
  2215. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2216. if err != nil {
  2217. br.Msg = "获取信息失败"
  2218. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2219. return
  2220. }
  2221. //获取产业关联的标的
  2222. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2223. if err != nil {
  2224. br.Msg = "获取信息失败"
  2225. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2226. return
  2227. }
  2228. if articleIdSub != "" && articleIdInd != "" {
  2229. articleIdGroup = articleIdSub + "," + articleIdInd
  2230. } else if articleIdSub != "" && articleIdInd == "" {
  2231. articleIdGroup = articleIdSub
  2232. } else if articleIdSub == "" && articleIdInd != "" {
  2233. articleIdGroup = articleIdInd
  2234. }
  2235. slice := strings.Split(keyWord, "/")
  2236. if len(slice) > 1 {
  2237. var subjectIds string
  2238. for _, v := range slice {
  2239. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2240. if err != nil && err.Error() != utils.ErrNoRow() {
  2241. br.Msg = "获取信息失败"
  2242. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2243. return
  2244. }
  2245. if subjectId != "" {
  2246. subjectIds += subjectId + ","
  2247. }
  2248. }
  2249. subjectIds = strings.TrimRight(subjectIds, ",")
  2250. if len(subjectIds) > 0 {
  2251. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2252. if err != nil {
  2253. br.Msg = "获取信息失败"
  2254. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2255. return
  2256. }
  2257. if articleIdGroup != "" {
  2258. if articleBySub != "" {
  2259. articleIdGroup += "," + articleBySub
  2260. }
  2261. } else {
  2262. articleIdGroup = articleBySub
  2263. }
  2264. }
  2265. }
  2266. }
  2267. if articleIdGroup != "" {
  2268. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2269. }
  2270. startSize = paging.StartIndex(currentIndex, pageSize)
  2271. total, err := models.GetArticleDepartmentCount(condition)
  2272. page := paging.GetPaging(currentIndex, pageSize, total)
  2273. resp := new(models.CygxArticleDepartmentListPc)
  2274. userType, _, err := services.GetUserType(user.CompanyId)
  2275. if err != nil {
  2276. br.Msg = "获取信息失败"
  2277. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2278. return
  2279. }
  2280. if userType == 1 {
  2281. resp.Paging = page
  2282. br.Ret = 200
  2283. br.Success = true
  2284. br.Msg = "获取成功"
  2285. br.Data = resp
  2286. return
  2287. }
  2288. resp.HaveResearch = true
  2289. //获取作者信息,并排序
  2290. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2291. if err != nil {
  2292. br.Msg = "获取信息失败"
  2293. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2294. return
  2295. }
  2296. for k, v := range list {
  2297. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2298. if err != nil {
  2299. br.Msg = "获取信息失败"
  2300. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2301. return
  2302. }
  2303. for k2, v2 := range artList {
  2304. if artList[k2].IsReport == "1" {
  2305. artList[k2].Title = v2.Title
  2306. } else {
  2307. artList[k2].Title = v2.Title
  2308. }
  2309. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2310. }
  2311. list[k].List = artList
  2312. if v.FollowNum > 0 {
  2313. list[k].IsMyFollow = true
  2314. }
  2315. }
  2316. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2317. if err != nil {
  2318. br.Msg = "获取信息失败"
  2319. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2320. return
  2321. }
  2322. if len(listnNew) > 0 {
  2323. for _, v := range listnNew {
  2324. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2325. Management := new(models.IndustrialManagementIdInt)
  2326. if firstStr == 0 {
  2327. Management.IndustryName = v.IndustryName
  2328. } else {
  2329. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2330. if err != nil {
  2331. br.Msg = "获取信息失败"
  2332. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2333. return
  2334. }
  2335. var subjectNamesNew string
  2336. for _, v1 := range listSub {
  2337. subjectNamesNew += v1.SubjectName + "/"
  2338. }
  2339. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2340. Management.IndustryName = subjectNamesNew
  2341. }
  2342. Management.IndustrialManagementId = v.IndustrialManagementId
  2343. Management.ArticleId = v.ArticleId
  2344. resp.ListnNew = append(resp.ListnNew, Management)
  2345. }
  2346. }
  2347. resp.List = list
  2348. resp.Paging = page
  2349. br.Ret = 200
  2350. br.Success = true
  2351. br.Msg = "获取成功"
  2352. br.Data = resp
  2353. }
  2354. // @Title 产业文章列表接口Pc端
  2355. // @Description 获取产业文章列表接口Pc端
  2356. // @Param KeyWord query string true "搜索关键词"
  2357. // @Success 200 {object} models.CygxIndustrySearchListPc
  2358. // @router /industryAndArticle/listPc [get]
  2359. func (this *ReportController) IndustryAndArticleListPc() {
  2360. br := new(models.BaseResponse).Init()
  2361. defer func() {
  2362. this.Data["json"] = br
  2363. this.ServeJSON()
  2364. }()
  2365. user := this.User
  2366. if user == nil {
  2367. br.Msg = "请重新登录"
  2368. br.Ret = 408
  2369. return
  2370. }
  2371. uid := user.UserId
  2372. keyWord := this.GetString("KeyWord")
  2373. resp := new(models.CygxIndustrySearchListPc)
  2374. orderSrt := "update_time DESC"
  2375. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2376. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2377. if err != nil {
  2378. br.Msg = "获取信息失败"
  2379. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2380. return
  2381. }
  2382. for k, v := range list {
  2383. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2384. if err != nil {
  2385. br.Msg = "获取信息失败"
  2386. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2387. return
  2388. }
  2389. list[k].IndustrialSubjectList = industrialSubjectList
  2390. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2391. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2392. if err != nil {
  2393. br.Msg = "获取信息失败"
  2394. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2395. return
  2396. }
  2397. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2398. }
  2399. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2400. if err != nil {
  2401. br.Msg = "获取失败"
  2402. br.ErrMsg = "获取失败,Err:" + err.Error()
  2403. return
  2404. }
  2405. if len(artList) > 0 {
  2406. var articleIds string
  2407. for _, v := range artList {
  2408. articleIds += strconv.Itoa(v.ArticleId) + ","
  2409. }
  2410. articleIds = strings.TrimRight(articleIds, ",")
  2411. if articleIds != "" {
  2412. condition = ` AND a.article_id IN (` + articleIds + `)`
  2413. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2414. if err != nil {
  2415. br.Msg = "获取信息失败"
  2416. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2417. return
  2418. }
  2419. for k, v := range DepartmentList {
  2420. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2421. if err != nil {
  2422. br.Msg = "获取信息失败"
  2423. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2424. return
  2425. }
  2426. for k2, v2 := range artList {
  2427. if artList[k2].IsReport == "1" {
  2428. artList[k2].Title = v2.Title
  2429. } else {
  2430. artList[k2].Title = v2.Title
  2431. }
  2432. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2433. }
  2434. DepartmentList[k].List = artList
  2435. if v.FollowNum > 0 {
  2436. DepartmentList[k].IsMyFollow = true
  2437. }
  2438. }
  2439. resp.DepartmentList = DepartmentList
  2440. }
  2441. }
  2442. if keyWord != "" {
  2443. keyWordItem := new(models.CygxUserSearchKeyWord)
  2444. keyWordItem.UserId = user.UserId
  2445. keyWordItem.KeyWord = keyWord
  2446. keyWordItem.PageType = "ReortSearch"
  2447. keyWordItem.CreateTime = time.Now()
  2448. go models.AddUserSearchKeyWord(keyWordItem)
  2449. }
  2450. resp.IndList = list
  2451. br.Ret = 200
  2452. br.Success = true
  2453. br.Msg = "获取成功"
  2454. br.Data = resp
  2455. }
  2456. // @Title 报告搜索
  2457. // @Description 报告搜索接口
  2458. // @Param KeyWord query string true "搜索关键词"
  2459. // @Success 200 {object} models.ReoprtSearchResp
  2460. // @router /searchReport [get]
  2461. func (this *ReportController) SearchReport() {
  2462. br := new(models.BaseResponse).Init()
  2463. defer func() {
  2464. this.Data["json"] = br
  2465. this.ServeJSON()
  2466. }()
  2467. user := this.User
  2468. if user == nil {
  2469. br.Msg = "请重新登录"
  2470. br.Ret = 408
  2471. return
  2472. }
  2473. keyWord := this.GetString("KeyWord")
  2474. var condition string
  2475. var sqlGroup string
  2476. //匹配报告标题、
  2477. 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 `
  2478. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2479. //对应产业名称、标的名称。
  2480. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2481. if err != nil {
  2482. br.Msg = "获取信息失败"
  2483. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2484. return
  2485. }
  2486. for k, v := range listYx {
  2487. listYx[k].Source = 2
  2488. if v.MyCollectNum > 0 {
  2489. listYx[k].IsCollect = true
  2490. }
  2491. }
  2492. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2493. if err != nil {
  2494. br.Msg = "获取信息失败"
  2495. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2496. return
  2497. }
  2498. for k, v := range listHz {
  2499. listHz[k].Source = 1
  2500. if v.MyCollectNum > 0 {
  2501. listHz[k].IsCollect = true
  2502. }
  2503. }
  2504. if keyWord != "" {
  2505. keyWordItem := new(models.CygxUserSearchKeyWord)
  2506. keyWordItem.UserId = user.UserId
  2507. keyWordItem.KeyWord = keyWord
  2508. keyWordItem.PageType = "ReortSearch"
  2509. keyWordItem.CreateTime = time.Now()
  2510. go models.AddUserSearchKeyWord(keyWordItem)
  2511. //go services.AddUserSearchLog(user, keyWord, 5)
  2512. }
  2513. if len(listYx) == 0 {
  2514. listYx = make([]*models.ArticleCollectionResp, 0)
  2515. }
  2516. if len(listHz) == 0 {
  2517. listHz = make([]*models.ArticleCollectionResp, 0)
  2518. }
  2519. resp := new(models.ReoprtSearchResp)
  2520. resp.ListYx = listYx
  2521. resp.ListHz = listHz
  2522. br.Ret = 200
  2523. br.Success = true
  2524. br.Msg = "获取成功"
  2525. br.Data = resp
  2526. }
  2527. // @Title 资源包搜索
  2528. // @Description 资源包搜索接口
  2529. // @Param KeyWord query string true "搜索关键词"
  2530. // @Success 200 {object} models.SearchResourceResp
  2531. // @router /searchResource [get]
  2532. func (this *ReportController) SearchResource() {
  2533. br := new(models.BaseResponse).Init()
  2534. defer func() {
  2535. this.Data["json"] = br
  2536. this.ServeJSON()
  2537. }()
  2538. user := this.User
  2539. if user == nil {
  2540. br.Msg = "请重新登录"
  2541. br.Ret = 408
  2542. return
  2543. }
  2544. uid := user.UserId
  2545. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2546. if err != nil {
  2547. br.Msg = "获取失败"
  2548. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2549. return
  2550. }
  2551. fllowMap := make(map[int]int)
  2552. if len(fllowList) > 0 {
  2553. for _, v := range fllowList {
  2554. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2555. }
  2556. }
  2557. keyWord := this.GetString("KeyWord")
  2558. var condition string
  2559. var conditionOr string
  2560. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2561. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2562. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2563. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2564. if err != nil {
  2565. br.Msg = "获取信息失败"
  2566. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2567. return
  2568. }
  2569. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2570. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2571. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2572. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2573. if err != nil {
  2574. br.Msg = "获取信息失败"
  2575. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2576. return
  2577. }
  2578. //合并产业关联的标的
  2579. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2580. if err != nil {
  2581. br.Msg = "获取信息失败"
  2582. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2583. return
  2584. }
  2585. industrialIdArr := make([]int, 0)
  2586. for k, v := range listHz {
  2587. listHz[k].Source = 1
  2588. if fllowMap[v.IndustrialManagementId] > 0 {
  2589. listHz[k].IsFollw = true
  2590. }
  2591. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2592. }
  2593. for k, v := range listYx {
  2594. listYx[k].Source = 2
  2595. if fllowMap[v.IndustrialManagementId] > 0 {
  2596. listYx[k].IsFollw = true
  2597. }
  2598. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2599. }
  2600. if len(industrialIdArr) > 0 {
  2601. //合并产业关联的标的
  2602. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2603. if err != nil {
  2604. br.Msg = "获取信息失败"
  2605. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2606. return
  2607. }
  2608. mapIndustrial := make(map[string]int)
  2609. for _, v := range listSubjcet {
  2610. for k2, v2 := range listYx {
  2611. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2612. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2613. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2614. }
  2615. }
  2616. for k2, v2 := range listHz {
  2617. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2618. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2619. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2620. }
  2621. }
  2622. }
  2623. }
  2624. if keyWord != "" {
  2625. keyWordItem := new(models.CygxUserSearchKeyWord)
  2626. keyWordItem.UserId = user.UserId
  2627. keyWordItem.KeyWord = keyWord
  2628. keyWordItem.PageType = "ReortSearch"
  2629. keyWordItem.CreateTime = time.Now()
  2630. go models.AddUserSearchKeyWord(keyWordItem)
  2631. }
  2632. resp := new(models.SearchResourceResp)
  2633. if len(listYx) == 0 {
  2634. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2635. }
  2636. if len(listHz) == 0 {
  2637. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2638. }
  2639. resp.ListYx = listYx
  2640. resp.ListHz = listHz
  2641. br.Ret = 200
  2642. br.Success = true
  2643. br.Msg = "获取成功"
  2644. br.Data = resp
  2645. }
  2646. // @Title 报告搜索、资源包搜索接口
  2647. // @Description 报告搜索、资源包搜索接口接口
  2648. // @Param KeyWord query string true "搜索关键词"
  2649. // @Param PageSize query int true "每页数据条数"
  2650. // @Success 200 {object} models.SearchReportAndResourceResp
  2651. // @router /searchReportAndResource [get]
  2652. func (this *ReportController) SearchReportAndResource() {
  2653. br := new(models.BaseResponse).Init()
  2654. defer func() {
  2655. this.Data["json"] = br
  2656. this.ServeJSON()
  2657. }()
  2658. user := this.User
  2659. if user == nil {
  2660. br.Msg = "请重新登录"
  2661. br.Ret = 408
  2662. return
  2663. }
  2664. uid := user.UserId
  2665. keyWord := this.GetString("KeyWord")
  2666. pageSize, _ := this.GetInt("PageSize")
  2667. var condition string
  2668. var sqlGroup string
  2669. //匹配报告标题、
  2670. 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 `
  2671. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2672. if pageSize > 0 {
  2673. sqlGroup += ` LIMIT 5 `
  2674. } else {
  2675. sqlGroup += ` LIMIT 100 `
  2676. }
  2677. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2678. if err != nil {
  2679. br.Msg = "获取信息失败"
  2680. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2681. return
  2682. }
  2683. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2684. if err != nil {
  2685. br.Msg = "获取信息失败"
  2686. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2687. return
  2688. }
  2689. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2690. if err != nil {
  2691. br.Msg = "获取失败"
  2692. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2693. return
  2694. }
  2695. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2696. var keyWordIk string
  2697. if len(keyWordArr) > 1 {
  2698. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2699. var conditionIk string
  2700. var sqlGroupIk string
  2701. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2702. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2703. if pageSize > 0 {
  2704. sqlGroupIk += ` LIMIT 5 `
  2705. } else {
  2706. sqlGroupIk += ` LIMIT 20 `
  2707. }
  2708. //研选的联想词列表
  2709. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2710. if err != nil && err.Error() != utils.ErrNoRow() {
  2711. br.Msg = "获取信息失败"
  2712. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2713. return
  2714. }
  2715. if len(ListYxReportIk) > 0 {
  2716. for _, v := range ListYxReportIk {
  2717. ListYxReport = append(ListYxReport, v)
  2718. }
  2719. }
  2720. //弘则的联想词列表
  2721. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2722. if err != nil && err.Error() != utils.ErrNoRow() {
  2723. br.Msg = "获取信息失败"
  2724. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2725. return
  2726. }
  2727. if len(ListHzReportIk) > 0 {
  2728. for _, v := range ListHzReportIk {
  2729. ListHzReport = append(ListHzReport, v)
  2730. }
  2731. }
  2732. }
  2733. for k, v := range ListHzReport {
  2734. ListHzReport[k].Source = 1
  2735. if v.MyCollectNum > 0 {
  2736. ListHzReport[k].IsCollect = true
  2737. }
  2738. }
  2739. for k, v := range ListYxReport {
  2740. ListYxReport[k].Source = 2
  2741. if v.MyCollectNum > 0 {
  2742. ListYxReport[k].IsCollect = true
  2743. }
  2744. }
  2745. var articleIds string
  2746. for _, v := range ListHzReport {
  2747. articleIds += strconv.Itoa(v.ArticleId) + ","
  2748. }
  2749. for _, v := range ListYxReport {
  2750. articleIds += strconv.Itoa(v.ArticleId) + ","
  2751. }
  2752. articleIds = strings.TrimRight(articleIds, ",")
  2753. silcearticleIds := strings.Split(articleIds, ",")
  2754. var parsindustrial []interface{}
  2755. parsindustrial = make([]interface{}, 0)
  2756. articleIdList := make([]string, 0)
  2757. for _, v := range silcearticleIds {
  2758. articleIdList = append(articleIdList, v)
  2759. }
  2760. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  2761. parsindustrial = append(parsindustrial, articleIdList)
  2762. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  2763. if err != nil {
  2764. return
  2765. }
  2766. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  2767. if len(industrialList) > 0 {
  2768. for _, v := range industrialList {
  2769. item := new(models.IndustrialManagementResp)
  2770. //item.ArticleId = v.ArticleId
  2771. item.IndustrialManagementId = v.IndustrialManagementId
  2772. item.IndustryName = v.IndustryName
  2773. item.ChartPermissionId = v.ChartPermissionId
  2774. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  2775. }
  2776. }
  2777. for k, v := range ListHzReport {
  2778. if len(industrialMap[v.ArticleId]) > 0 {
  2779. ListHzReport[k].List = industrialMap[v.ArticleId]
  2780. } else {
  2781. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2782. }
  2783. }
  2784. for k, v := range ListYxReport {
  2785. if len(industrialMap[v.ArticleId]) > 0 {
  2786. ListYxReport[k].List = industrialMap[v.ArticleId]
  2787. } else {
  2788. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2789. }
  2790. }
  2791. //获取文章关联的产业
  2792. if len(ListYxReport) == 0 {
  2793. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2794. }
  2795. if len(ListHzReport) == 0 {
  2796. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2797. }
  2798. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2799. if err != nil {
  2800. br.Msg = "获取失败"
  2801. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2802. return
  2803. }
  2804. fllowMap := make(map[int]int)
  2805. if len(fllowList) > 0 {
  2806. for _, v := range fllowList {
  2807. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2808. }
  2809. }
  2810. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2811. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2812. if err != nil {
  2813. br.Msg = "获取信息失败"
  2814. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2815. return
  2816. }
  2817. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2818. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2819. if err != nil {
  2820. br.Msg = "获取信息失败"
  2821. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2822. return
  2823. }
  2824. //合并产业关联的标的
  2825. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2826. if err != nil {
  2827. br.Msg = "获取信息失败"
  2828. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2829. return
  2830. }
  2831. industrialIdArr := make([]int, 0)
  2832. nowTime := time.Now().Local()
  2833. threeMonBefore := nowTime.AddDate(0, -3, 0)
  2834. mapHot := make(map[string]int)
  2835. conditionOrder := ` ORDER BY sum_num DESC `
  2836. listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  2837. if err != nil {
  2838. br.Msg = "获取信息失败"
  2839. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2840. return
  2841. }
  2842. for _, v := range listHot {
  2843. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2844. mapHot[v.IndustryName] = v.IndustrialManagementId
  2845. }
  2846. orderSrt := "man.recommended_index DESC,update_time DESC"
  2847. for k, v := range listHzResource {
  2848. // 关联报告发布时间均在3个月内则标记New
  2849. if v.MinReportTime != "" {
  2850. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  2851. if e != nil {
  2852. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  2853. return
  2854. }
  2855. if t.After(threeMonBefore) {
  2856. listHzResource[k].IsNew = true
  2857. }
  2858. }
  2859. //弘则资源包不展示hot标签
  2860. //if mapHot[v.IndustryName] > 0 {
  2861. // listHzResource[k].IsHot = true
  2862. //}
  2863. listHzResource[k].Source = 1
  2864. if fllowMap[v.IndustrialManagementId] > 0 {
  2865. listHzResource[k].IsFollw = true
  2866. }
  2867. industrialIdSlice := make([]int, 0)
  2868. articleIdArr := make([]int, 0)
  2869. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  2870. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  2871. if err != nil && err.Error() != utils.ErrNoRow() {
  2872. return
  2873. }
  2874. for _, v := range listUpdateTime {
  2875. articleIdArr = append(articleIdArr, v.ArticleId)
  2876. }
  2877. if err != nil {
  2878. return
  2879. }
  2880. mapHistroyArticleId := make(map[int]int)
  2881. if user.UserId > 0 {
  2882. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  2883. if e != nil && e.Error() != utils.ErrNoRow() {
  2884. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2885. return
  2886. }
  2887. for _, v := range listArticleHistory {
  2888. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2889. }
  2890. }
  2891. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  2892. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  2893. if err != nil {
  2894. br.Msg = "获取信息失败"
  2895. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2896. return
  2897. }
  2898. mapUPdateTime := make(map[int]string)
  2899. //获取这些产业下最新更新的文章
  2900. //时间线的更新时间
  2901. // maptimelineUPdateTime := make(map[int]string)
  2902. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  2903. if err != nil && err.Error() != utils.ErrNoRow() {
  2904. return
  2905. }
  2906. for _, v := range listtimelinePublishdate {
  2907. if mapUPdateTime[v.IndustrialManagementId] != "" {
  2908. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2909. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  2910. }
  2911. }
  2912. }
  2913. //mapHistroyArticleId := make(map[int]int)
  2914. //if userId > 0 {
  2915. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  2916. // if e != nil && e.Error() != utils.ErrNoRow() {
  2917. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2918. // return
  2919. // }
  2920. // for _, v := range listArticleHistory {
  2921. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2922. // }
  2923. //}
  2924. var industrialIds string
  2925. for _, id := range industrialIdArr {
  2926. industrialIds += strconv.Itoa(id) + ","
  2927. }
  2928. industrialIds = strings.TrimRight(industrialIds, ",")
  2929. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  2930. mapHistroyindustrialId := make(map[int]int)
  2931. for _, v := range articleList {
  2932. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  2933. }
  2934. //nowTime := time.Now().Local()
  2935. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  2936. //查询用户今天是否看过时间线
  2937. //haveMorningMeeting := false
  2938. //var morningMeetingTime string
  2939. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  2940. if err != nil {
  2941. return
  2942. }
  2943. var industrialManagementIdstr string
  2944. industrialIdMap := make(map[string]time.Time)
  2945. for _, v := range recrodList {
  2946. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  2947. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  2948. if createTime.Before(v.CreateTime) {
  2949. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  2950. }
  2951. } else {
  2952. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  2953. }
  2954. }
  2955. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  2956. if err != nil {
  2957. return
  2958. }
  2959. morningMeetingTimeMap := make(map[int]time.Time)
  2960. for _, v := range mmList {
  2961. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  2962. }
  2963. timeLineRedMap := make(map[int]bool, 0)
  2964. for _, industrialId := range industrialIdArr {
  2965. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  2966. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  2967. timeLineRedMap[industrialId] = true
  2968. }
  2969. }
  2970. }
  2971. for k, v := range list {
  2972. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  2973. if user.UserId > 0 {
  2974. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  2975. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  2976. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2977. list[k].IsRed = true
  2978. }
  2979. }
  2980. } else {
  2981. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2982. list[k].IsRed = true
  2983. }
  2984. list[k].IsFollow = 0
  2985. }
  2986. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  2987. if user.UserId > 0 {
  2988. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  2989. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  2990. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2991. list[k].IsRed = true
  2992. }
  2993. }
  2994. } else {
  2995. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2996. list[k].IsRed = true
  2997. }
  2998. list[k].IsFollow = 0
  2999. }
  3000. }
  3001. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3002. }
  3003. for k, v := range listYxResource {
  3004. // 关联报告发布时间均在3个月内则标记New
  3005. if v.MinReportTime != "" {
  3006. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3007. if e != nil {
  3008. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3009. return
  3010. }
  3011. if t.After(threeMonBefore) {
  3012. listYxResource[k].IsNew = true
  3013. }
  3014. }
  3015. if mapHot[v.IndustryName] > 0 {
  3016. listYxResource[k].IsHot = true
  3017. }
  3018. listYxResource[k].Source = 2
  3019. if fllowMap[v.IndustrialManagementId] > 0 {
  3020. listYxResource[k].IsFollw = true
  3021. }
  3022. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3023. }
  3024. if len(industrialIdArr) > 0 {
  3025. //查询产业视频
  3026. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3027. // 获取默认图配置
  3028. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3029. if e != nil {
  3030. br.Msg = "获取视频默认配置图失败"
  3031. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3032. return
  3033. }
  3034. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3035. if err != nil {
  3036. br.Msg = "产业视频列表失败"
  3037. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3038. return
  3039. }
  3040. for _, v := range videoList {
  3041. tmp := &models.MicroVideoSimpleInfo{
  3042. Id: v.VideoId,
  3043. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3044. ResourceUrl: v.VideoUrl,
  3045. BackgroundImg: v.ImgUrl,
  3046. PlaySeconds: v.VideoDuration,
  3047. DetailImgUrl: v.DetailImgUrl,
  3048. ChartPermissionName: v.ChartPermissionName,
  3049. ChartPermissionId: v.ChartPermissionId,
  3050. }
  3051. if tmp.BackgroundImg == "" {
  3052. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3053. }
  3054. industrialVideoMap[v.IndustryId] = tmp
  3055. }
  3056. //查询权限
  3057. // 用户权限
  3058. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3059. if e != nil {
  3060. br.Msg = "获取失败"
  3061. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3062. return
  3063. }
  3064. for k, v := range listHzResource {
  3065. //展示产业视频
  3066. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3067. au := new(models.UserPermissionAuthInfo)
  3068. au.SellerName = authInfo.SellerName
  3069. au.SellerMobile = authInfo.SellerMobile
  3070. au.HasPermission = authInfo.HasPermission
  3071. au.OperationMode = authInfo.OperationMode
  3072. if au.HasPermission == 1 {
  3073. // 非宏观权限进一步判断是否有权限
  3074. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3075. au.HasPermission = 2
  3076. }
  3077. }
  3078. // 无权限的弹框提示
  3079. if au.HasPermission != 1 {
  3080. if au.OperationMode == services.UserPermissionOperationModeCall {
  3081. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3082. } else {
  3083. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3084. }
  3085. video.ResourceUrl = ""
  3086. }
  3087. listHzResource[k].AuthInfo = au
  3088. listHzResource[k].IndustryVideo = video
  3089. }
  3090. }
  3091. //合并产业关联的标的
  3092. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3093. if err != nil {
  3094. br.Msg = "获取信息失败"
  3095. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3096. return
  3097. }
  3098. //严选的产业只关联研选下面的标的
  3099. var yxcondition string
  3100. var yxPer []interface{}
  3101. yxcondition = ` AND ag.article_id >= ?`
  3102. yxPer = append(yxPer, utils.SummaryArticleId)
  3103. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3104. if err != nil && err.Error() != utils.ErrNoRow() {
  3105. br.Msg = "获取信息失败"
  3106. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3107. return
  3108. }
  3109. mapYxSubject := make(map[int]int)
  3110. for _, v := range listYxAticleSubject {
  3111. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3112. }
  3113. mapIndustrial := make(map[string]int)
  3114. for _, v := range listSubjcet {
  3115. for k2, v2 := range listYxResource {
  3116. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3117. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3118. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3119. }
  3120. }
  3121. for k2, v2 := range listHzResource {
  3122. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3123. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3124. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3125. }
  3126. }
  3127. }
  3128. }
  3129. resp := new(models.SearchReportAndResourceResp)
  3130. if len(listYxResource) == 0 {
  3131. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3132. }
  3133. if len(listHzResource) == 0 {
  3134. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3135. }
  3136. if keyWord != "" {
  3137. keyWordItem := new(models.CygxUserSearchKeyWord)
  3138. keyWordItem.UserId = user.UserId
  3139. keyWordItem.KeyWord = keyWord
  3140. keyWordItem.PageType = "ReortSearch"
  3141. keyWordItem.CreateTime = time.Now()
  3142. go models.AddUserSearchKeyWord(keyWordItem)
  3143. //go services.AddUserSearchLog(user, keyWord, 5)
  3144. }
  3145. resp.ListHzResource = listHzResource
  3146. resp.ListYxResource = listYxResource
  3147. resp.ListYxReport = ListYxReport
  3148. resp.ListHzReport = ListHzReport
  3149. br.Ret = 200
  3150. br.Success = true
  3151. br.Msg = "获取成功"
  3152. br.Data = resp
  3153. }
  3154. // @Title 产业报告公司列表
  3155. // @Description 获取产业报告公司列表接口
  3156. // @Param ChartPermissionId query int true "行业id"
  3157. // @Success 200 {object} models.IndustrialManagementList
  3158. // @router /home/stockName [get]
  3159. func (this *ReportController) StockNameList() {
  3160. br := new(models.BaseResponse).Init()
  3161. defer func() {
  3162. this.Data["json"] = br
  3163. this.ServeJSON()
  3164. }()
  3165. user := this.User
  3166. if user == nil {
  3167. br.Msg = "请重新登录"
  3168. br.Ret = 408
  3169. return
  3170. }
  3171. //uid := user.UserId
  3172. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3173. list, err := models.GetSummaryArticle(chartPermissionId)
  3174. if err != nil {
  3175. br.Msg = "获取综述报告公司名称失败"
  3176. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3177. return
  3178. }
  3179. var respList []*models.SummaryArticleStock
  3180. for _, item := range list {
  3181. sliceSubjects := strings.Split(item.Stock, "/")
  3182. if len(sliceSubjects) > 0 {
  3183. for i, vSubject := range sliceSubjects {
  3184. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3185. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3186. subject := sliceXiahuaxian[0]
  3187. if i > 0 {
  3188. newItem := models.SummaryArticleStock{
  3189. Id: item.Id,
  3190. ArticleId: item.ArticleId,
  3191. Stock: subject,
  3192. }
  3193. respList = append(respList, &newItem)
  3194. } else {
  3195. item.Stock = subject
  3196. respList = append(respList, item)
  3197. }
  3198. }
  3199. }
  3200. //index := strings.Index(item.Stock, "(")
  3201. //item.Stock = item.Stock[:index]
  3202. //if strings.Contains(item.Stock, "-B"){
  3203. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3204. //}
  3205. //if strings.Contains(item.Stock, "-W"){
  3206. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3207. //}
  3208. }
  3209. resp := new(models.SummaryArticleStockResp)
  3210. resp.List = respList
  3211. br.Ret = 200
  3212. br.Success = true
  3213. br.Msg = "获取成功"
  3214. br.Data = resp
  3215. }
  3216. // @Title 文章留言接口
  3217. // @Description 文章留言接口
  3218. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3219. // @Success 200 {object} models.TacticsListResp
  3220. // @router /commentAdd [post]
  3221. func (this *ReportController) CommentAdd() {
  3222. br := new(models.BaseResponse).Init()
  3223. defer func() {
  3224. this.Data["json"] = br
  3225. this.ServeJSON()
  3226. }()
  3227. user := this.User
  3228. if user == nil {
  3229. br.Msg = "请重新登录"
  3230. br.Ret = 408
  3231. return
  3232. }
  3233. var req models.AddCygxArticleCommentReq
  3234. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3235. if err != nil {
  3236. br.Msg = "参数解析异常!"
  3237. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3238. return
  3239. }
  3240. if req.ArticleId <= 0 {
  3241. br.Msg = "文章不存在"
  3242. br.ErrMsg = "文章不存在,文章ID错误"
  3243. return
  3244. }
  3245. if req.Content == "" {
  3246. br.Msg = "建议内容不可为空"
  3247. return
  3248. }
  3249. content := req.Content
  3250. itemToken, err := services.WxGetToken()
  3251. if err != nil {
  3252. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3253. return
  3254. }
  3255. if itemToken.AccessToken == "" {
  3256. br.Msg = "accessToken is empty"
  3257. return
  3258. }
  3259. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3260. if err != nil {
  3261. br.Msg = "内容校验失败!"
  3262. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3263. return
  3264. }
  3265. if commerr.ErrCode != 0 {
  3266. br.Msg = "内容违规,请重新提交!"
  3267. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3268. return
  3269. }
  3270. articleId := req.ArticleId
  3271. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3272. if articleInfo == nil {
  3273. br.Msg = "操作失败"
  3274. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3275. return
  3276. }
  3277. if errInfo != nil {
  3278. br.Msg = "操作失败"
  3279. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3280. return
  3281. }
  3282. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3283. if err != nil {
  3284. br.Msg = "提交失败!"
  3285. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3286. return
  3287. }
  3288. if companyDetail == nil {
  3289. br.Msg = "提交失败!"
  3290. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3291. return
  3292. }
  3293. item := models.CygxArticleComment{
  3294. UserId: user.UserId,
  3295. ArticleId: req.ArticleId,
  3296. CreateTime: time.Now(),
  3297. Mobile: user.Mobile,
  3298. Email: user.Email,
  3299. CompanyId: user.CompanyId,
  3300. CompanyName: companyDetail.CompanyName,
  3301. Content: content,
  3302. Title: articleInfo.Title,
  3303. }
  3304. _, err = models.AddArticleComment(&item)
  3305. if err != nil {
  3306. br.Msg = "提交失败"
  3307. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3308. return
  3309. }
  3310. //获取销售信息
  3311. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3312. //if err != nil && err.Error() != utils.ErrNoRow() {
  3313. // br.Msg = "提交失败"
  3314. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3315. // return
  3316. //}
  3317. //// 给所属销售发送消息
  3318. //var openIdList []*models.OpenIdList
  3319. //if sellerItem != nil {
  3320. // list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
  3321. // for _, idList := range list {
  3322. // openIdList = append(openIdList, idList)
  3323. // }
  3324. // if openIdList != nil {
  3325. // // 给芳姐发消息
  3326. // cnf, _ := models.GetConfigByCode("tpl_msg")
  3327. // if cnf != nil {
  3328. // list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
  3329. // for _, idList := range list {
  3330. // openIdList = append(openIdList, idList)
  3331. // }
  3332. // }
  3333. // if articleId > 1000000 {
  3334. // //发给汪洋
  3335. // list, _ := models.GetWxOpenIdByMobileList(utils.ActSendMsgMobile)
  3336. // for _, idList := range list {
  3337. // openIdList = append(openIdList, idList)
  3338. // }
  3339. // }
  3340. // services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
  3341. // }
  3342. //}
  3343. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  3344. br.Ret = 200
  3345. br.Success = true
  3346. br.Msg = "提交成功"
  3347. }
  3348. // @Title 记录用户浏览音频回放接口
  3349. // @Description 记录用户浏览音频回放接口
  3350. // @Param request body models.ArticleIdReq true "type json string"
  3351. // @Success Ret=200 操作成功
  3352. // @router /voiceHistory/add [post]
  3353. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3354. br := new(models.BaseResponse).Init()
  3355. defer func() {
  3356. this.Data["json"] = br
  3357. this.ServeJSON()
  3358. }()
  3359. user := this.User
  3360. if user == nil {
  3361. br.Msg = "请登录"
  3362. br.ErrMsg = "请登录,用户信息为空"
  3363. br.Ret = 408
  3364. return
  3365. }
  3366. uid := user.UserId
  3367. var req models.ArticleIdReq
  3368. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3369. if err != nil {
  3370. br.Msg = "参数解析异常!"
  3371. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3372. return
  3373. }
  3374. articleId := req.ArticleId
  3375. playSeconds := req.PlaySeconds
  3376. pageRouter := req.PageRouter
  3377. if pageRouter == "本周研究汇总" {
  3378. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3379. if articleInfo == nil {
  3380. br.Msg = "操作失败"
  3381. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3382. return
  3383. }
  3384. if errInfo != nil {
  3385. br.Msg = "操作失败"
  3386. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3387. return
  3388. }
  3389. var sellerName string
  3390. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3391. if err != nil {
  3392. br.Msg = "报名失败!"
  3393. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3394. return
  3395. }
  3396. item := models.CygxResearchSummaryVoiceHistory{
  3397. ArticleId: articleId,
  3398. UserId: uid,
  3399. CreateTime: time.Now(),
  3400. Mobile: user.Mobile,
  3401. Email: user.Email,
  3402. CompanyId: user.CompanyId,
  3403. CompanyName: user.CompanyName,
  3404. RealName: user.RealName,
  3405. SellerName: sellerName,
  3406. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3407. ModifyTime: time.Now(),
  3408. }
  3409. if playSeconds != 0 {
  3410. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3411. if err != nil {
  3412. br.Msg = "操作失败"
  3413. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3414. return
  3415. }
  3416. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3417. if err != nil {
  3418. br.Msg = "更新失败"
  3419. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3420. return
  3421. }
  3422. } else {
  3423. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3424. if err != nil {
  3425. br.Msg = "操作失败"
  3426. br.ErrMsg = "操作失败,Err:" + err.Error()
  3427. return
  3428. }
  3429. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3430. if err != nil {
  3431. br.Msg = "更新失败"
  3432. br.ErrMsg = "更新失败,Err:" + err.Error()
  3433. return
  3434. }
  3435. }
  3436. } else if pageRouter == "上周纪要汇总" {
  3437. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3438. if articleInfo == nil {
  3439. br.Msg = "操作失败"
  3440. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3441. return
  3442. }
  3443. if errInfo != nil {
  3444. br.Msg = "操作失败"
  3445. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3446. return
  3447. }
  3448. var sellerName string
  3449. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3450. if err != nil {
  3451. br.Msg = "报名失败!"
  3452. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3453. return
  3454. }
  3455. item := models.CygxMinutesSummaryVoiceHistory{
  3456. ArticleId: articleId,
  3457. UserId: uid,
  3458. CreateTime: time.Now(),
  3459. Mobile: user.Mobile,
  3460. Email: user.Email,
  3461. CompanyId: user.CompanyId,
  3462. CompanyName: user.CompanyName,
  3463. RealName: user.RealName,
  3464. SellerName: sellerName,
  3465. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3466. ModifyTime: time.Now(),
  3467. }
  3468. if playSeconds != 0 {
  3469. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3470. if err != nil {
  3471. br.Msg = "操作失败"
  3472. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3473. return
  3474. }
  3475. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3476. if err != nil {
  3477. br.Msg = "更新失败"
  3478. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3479. return
  3480. }
  3481. } else {
  3482. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3483. if err != nil {
  3484. br.Msg = "操作失败"
  3485. br.ErrMsg = "操作失败,Err:" + err.Error()
  3486. return
  3487. }
  3488. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3489. if err != nil {
  3490. br.Msg = "更新失败"
  3491. br.ErrMsg = "更新失败,Err:" + err.Error()
  3492. return
  3493. }
  3494. }
  3495. } else if pageRouter == "报告精选" {
  3496. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3497. if articleInfo == nil {
  3498. br.Msg = "操作失败"
  3499. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3500. return
  3501. }
  3502. if errInfo != nil {
  3503. br.Msg = "操作失败"
  3504. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3505. return
  3506. }
  3507. var sellerName string
  3508. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3509. if err != nil {
  3510. br.Msg = "报名失败!"
  3511. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3512. return
  3513. }
  3514. item := models.CygxReportSelectionVoiceHistory{
  3515. ArticleId: articleId,
  3516. UserId: uid,
  3517. CreateTime: time.Now(),
  3518. Mobile: user.Mobile,
  3519. Email: user.Email,
  3520. CompanyId: user.CompanyId,
  3521. CompanyName: user.CompanyName,
  3522. RealName: user.RealName,
  3523. SellerName: sellerName,
  3524. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3525. ModifyTime: time.Now(),
  3526. }
  3527. if playSeconds != 0 {
  3528. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3529. if err != nil {
  3530. br.Msg = "操作失败"
  3531. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3532. return
  3533. }
  3534. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3535. if err != nil {
  3536. br.Msg = "更新失败"
  3537. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3538. return
  3539. }
  3540. } else {
  3541. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3542. if err != nil {
  3543. br.Msg = "操作失败"
  3544. br.ErrMsg = "操作失败,Err:" + err.Error()
  3545. return
  3546. }
  3547. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3548. if err != nil {
  3549. br.Msg = "更新失败"
  3550. br.ErrMsg = "更新失败,Err:" + err.Error()
  3551. return
  3552. }
  3553. }
  3554. }
  3555. br.Ret = 200
  3556. br.Success = true
  3557. br.Msg = "操作成功"
  3558. return
  3559. }