report.go 133 KB

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