report.go 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155
  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.body_text 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. listHzResource, err := models.GetSearchResourceListcondition(condition, 0, pageSize)
  3087. if err != nil {
  3088. br.Msg = "获取信息失败"
  3089. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3090. return
  3091. }
  3092. if len(listHzResource) > 0 {
  3093. listHzResource, err = services.HandleIndustryListHzAndYx(listHzResource, user, "Hz")
  3094. if err != nil {
  3095. br.Msg = "获取信息失败"
  3096. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3097. return
  3098. }
  3099. } else {
  3100. listHzResource = make([]*models.IndustrialManagement, 0)
  3101. }
  3102. //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 + `%' ) `
  3103. //
  3104. //hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  3105. //if e != nil {
  3106. // br.Msg = "获取信息失败"
  3107. // br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  3108. // return
  3109. //}
  3110. //listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3111. //if err != nil {
  3112. // br.Msg = "获取信息失败"
  3113. // br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  3114. // return
  3115. //}
  3116. ////合并产业关联的标的
  3117. //listSubjcet, err := models.GetThemeHeatSubjectList("")
  3118. //if err != nil {
  3119. // br.Msg = "获取信息失败"
  3120. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3121. // return
  3122. //}
  3123. //industrialIdArr := make([]int, 0)
  3124. //nowTime := time.Now().Local()
  3125. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3126. //mapHot := make(map[int]bool)
  3127. //
  3128. ////if themeType == 2 {
  3129. //mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  3130. //if err != nil {
  3131. // br.Msg = "获取信息失败"
  3132. // br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  3133. // return
  3134. //}
  3135. //
  3136. ////conditionOrder := ` ORDER BY sum_num DESC `
  3137. ////listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  3138. ////if err != nil {
  3139. //// br.Msg = "获取信息失败"
  3140. //// br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3141. //// return
  3142. ////}
  3143. //for k, _ := range mapHot {
  3144. // industrialIdArr = append(industrialIdArr, k)
  3145. //}
  3146. //orderSrt := "man.recommended_index DESC,update_time DESC"
  3147. //for k, v := range listHzResource {
  3148. // // 关联报告发布时间均在3个月内则标记New
  3149. // if v.MinReportTime != "" {
  3150. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3151. // if e != nil {
  3152. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3153. // return
  3154. // }
  3155. // if t.After(threeMonBefore) {
  3156. // listHzResource[k].IsNew = true
  3157. // }
  3158. // }
  3159. // //弘则资源包不展示hot标签
  3160. // //if mapHot[v.IndustryName] > 0 {
  3161. // // listHzResource[k].IsHot = true
  3162. // //}
  3163. // listHzResource[k].Source = 1
  3164. // if fllowMap[v.IndustrialManagementId] > 0 {
  3165. // listHzResource[k].IsFollw = true
  3166. // }
  3167. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3168. // industrialIdSlice := make([]int, 0)
  3169. // articleIdArr := make([]int, 0)
  3170. // industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  3171. // listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  3172. // if err != nil && err.Error() != utils.ErrNoRow() {
  3173. // return
  3174. // }
  3175. // for _, v := range listUpdateTime {
  3176. // articleIdArr = append(articleIdArr, v.ArticleId)
  3177. // }
  3178. //
  3179. // if err != nil {
  3180. // return
  3181. // }
  3182. // mapHistroyArticleId := make(map[int]int)
  3183. //
  3184. // if user.UserId > 0 {
  3185. // listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3186. // if e != nil && e.Error() != utils.ErrNoRow() {
  3187. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3188. // return
  3189. // }
  3190. // for _, v := range listArticleHistory {
  3191. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3192. // }
  3193. // }
  3194. // condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3195. // list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3196. // if err != nil {
  3197. // br.Msg = "获取信息失败"
  3198. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3199. // return
  3200. // }
  3201. //
  3202. // mapUPdateTime := make(map[int]string)
  3203. // //获取这些产业下最新更新的文章
  3204. //
  3205. // //时间线的更新时间
  3206. // // maptimelineUPdateTime := make(map[int]string)
  3207. // listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3208. // if err != nil && err.Error() != utils.ErrNoRow() {
  3209. // br.Msg = "获取信息失败"
  3210. // br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3211. // return
  3212. // }
  3213. // for _, v := range listtimelinePublishdate {
  3214. // if mapUPdateTime[v.IndustrialManagementId] != "" {
  3215. // if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3216. // mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3217. // }
  3218. // }
  3219. // }
  3220. //
  3221. // //mapHistroyArticleId := make(map[int]int)
  3222. //
  3223. // //if userId > 0 {
  3224. // // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3225. // // if e != nil && e.Error() != utils.ErrNoRow() {
  3226. // // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3227. // // return
  3228. // // }
  3229. // // for _, v := range listArticleHistory {
  3230. // // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3231. // // }
  3232. // //}
  3233. // var industrialIds string
  3234. // for _, id := range industrialIdArr {
  3235. // industrialIds += strconv.Itoa(id) + ","
  3236. // }
  3237. // industrialIds = strings.TrimRight(industrialIds, ",")
  3238. // articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3239. // if err != nil && err.Error() != utils.ErrNoRow() {
  3240. // br.Msg = "获取信息失败"
  3241. // br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3242. // return
  3243. // }
  3244. // mapHistroyindustrialId := make(map[int]int)
  3245. // for _, v := range articleList {
  3246. // mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3247. // }
  3248. // //nowTime := time.Now().Local()
  3249. // //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3250. //
  3251. // //查询用户今天是否看过时间线
  3252. // //haveMorningMeeting := false
  3253. // //var morningMeetingTime string
  3254. // recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3255. // if err != nil {
  3256. // br.Msg = "获取信息失败"
  3257. // br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3258. // return
  3259. // }
  3260. // var industrialManagementIdstr string
  3261. // industrialIdMap := make(map[string]time.Time)
  3262. // for _, v := range recrodList {
  3263. // industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3264. // if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3265. // if createTime.Before(v.CreateTime) {
  3266. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3267. // }
  3268. // } else {
  3269. // industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3270. // }
  3271. // }
  3272. //
  3273. // mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3274. // if err != nil {
  3275. // return
  3276. // }
  3277. // morningMeetingTimeMap := make(map[int]time.Time)
  3278. // for _, v := range mmList {
  3279. // morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3280. // }
  3281. // timeLineRedMap := make(map[int]bool, 0)
  3282. //
  3283. // for _, industrialId := range industrialIdArr {
  3284. // if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3285. // if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3286. // timeLineRedMap[industrialId] = true
  3287. // }
  3288. // }
  3289. // }
  3290. //
  3291. // for k, v := range list {
  3292. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3293. // if user.UserId > 0 {
  3294. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3295. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3296. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3297. // list[k].IsRed = true
  3298. // }
  3299. // }
  3300. // } else {
  3301. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3302. // list[k].IsRed = true
  3303. // }
  3304. // list[k].IsFollow = 0
  3305. // }
  3306. //
  3307. // list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3308. // if user.UserId > 0 {
  3309. // //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3310. // if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3311. // if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3312. // list[k].IsRed = true
  3313. // }
  3314. // }
  3315. // } else {
  3316. // if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3317. // list[k].IsRed = true
  3318. // }
  3319. // list[k].IsFollow = 0
  3320. // }
  3321. // }
  3322. //
  3323. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3324. //}
  3325. //
  3326. //for k, v := range listYxResource {
  3327. // // 关联报告发布时间均在3个月内则标记New
  3328. // if v.MinReportTime != "" {
  3329. // t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3330. // if e != nil {
  3331. // err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3332. // return
  3333. // }
  3334. // if t.After(threeMonBefore) {
  3335. // listYxResource[k].IsNew = true
  3336. // }
  3337. // }
  3338. // listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3339. // listYxResource[k].Source = 2
  3340. // if fllowMap[v.IndustrialManagementId] > 0 {
  3341. // listYxResource[k].IsFollw = true
  3342. // }
  3343. // v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3344. // industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3345. //}
  3346. //
  3347. //if len(industrialIdArr) > 0 {
  3348. // //查询产业视频
  3349. // industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3350. // // 获取默认图配置
  3351. // _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3352. // if e != nil {
  3353. // br.Msg = "获取视频默认配置图失败"
  3354. // br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3355. // return
  3356. // }
  3357. // videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3358. // if err != nil {
  3359. // br.Msg = "产业视频列表失败"
  3360. // br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3361. // return
  3362. // }
  3363. // for _, v := range videoList {
  3364. // tmp := &models.MicroVideoSimpleInfo{
  3365. // Id: v.VideoId,
  3366. // Title: "5min逻辑【" + v.IndustryName + "】解析",
  3367. // ResourceUrl: v.VideoUrl,
  3368. // BackgroundImg: v.ImgUrl,
  3369. // PlaySeconds: v.VideoDuration,
  3370. // DetailImgUrl: v.DetailImgUrl,
  3371. // ChartPermissionName: v.ChartPermissionName,
  3372. // ChartPermissionId: v.ChartPermissionId,
  3373. // }
  3374. // if tmp.BackgroundImg == "" {
  3375. // tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3376. // }
  3377. // industrialVideoMap[v.IndustryId] = tmp
  3378. // }
  3379. //
  3380. // //查询权限
  3381. // // 用户权限
  3382. // authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3383. // if e != nil {
  3384. // br.Msg = "获取失败"
  3385. // br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3386. // return
  3387. // }
  3388. //
  3389. // for k, v := range listHzResource {
  3390. // //展示产业视频
  3391. // if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3392. // au := new(models.UserPermissionAuthInfo)
  3393. // au.SellerName = authInfo.SellerName
  3394. // au.SellerMobile = authInfo.SellerMobile
  3395. // au.HasPermission = authInfo.HasPermission
  3396. // au.OperationMode = authInfo.OperationMode
  3397. // if au.HasPermission == 1 {
  3398. // // 非宏观权限进一步判断是否有权限
  3399. // if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3400. // au.HasPermission = 2
  3401. // }
  3402. // }
  3403. // // 无权限的弹框提示
  3404. // if au.HasPermission != 1 {
  3405. // if au.OperationMode == services.UserPermissionOperationModeCall {
  3406. // au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3407. // } else {
  3408. // au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3409. // }
  3410. // video.ResourceUrl = ""
  3411. // }
  3412. // listHzResource[k].AuthInfo = au
  3413. // listHzResource[k].IndustryVideo = video
  3414. // }
  3415. // }
  3416. //
  3417. // //合并产业关联的标的
  3418. // listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3419. // if err != nil {
  3420. // br.Msg = "获取信息失败"
  3421. // br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3422. // return
  3423. // }
  3424. // //严选的产业只关联研选下面的标的
  3425. // var yxcondition string
  3426. // var yxPer []interface{}
  3427. // yxcondition = ` AND ag.article_id >= ?`
  3428. // yxPer = append(yxPer, utils.SummaryArticleId)
  3429. // listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3430. // if err != nil && err.Error() != utils.ErrNoRow() {
  3431. // br.Msg = "获取信息失败"
  3432. // br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3433. // return
  3434. // }
  3435. // mapYxSubject := make(map[int]int)
  3436. // for _, v := range listYxAticleSubject {
  3437. // mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3438. // }
  3439. //
  3440. // mapIndustrial := make(map[string]int)
  3441. // for _, v := range listSubjcet {
  3442. // for k2, v2 := range listYxResource {
  3443. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3444. // listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3445. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3446. // }
  3447. // }
  3448. // for k2, v2 := range listHzResource {
  3449. // if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3450. // listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3451. // mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3452. // }
  3453. // }
  3454. // }
  3455. //}
  3456. resp := new(models.SearchReportAndResourceResp)
  3457. //if len(listYxResource) == 0 {
  3458. // listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3459. //}
  3460. //if len(listHzResource) == 0 {
  3461. // listHzResource =
  3462. // listHzResource = make([]*models.IndustrialManagement,0)
  3463. //}
  3464. if keyWord != "" {
  3465. keyWordItem := new(models.CygxUserSearchKeyWord)
  3466. keyWordItem.UserId = user.UserId
  3467. keyWordItem.KeyWord = keyWord
  3468. keyWordItem.PageType = "ReortSearch"
  3469. keyWordItem.CreateTime = time.Now()
  3470. go models.AddUserSearchKeyWord(keyWordItem)
  3471. //go services.AddUserSearchLog(user, keyWord, 5)
  3472. }
  3473. resp.ListHzResource = listHzResource
  3474. resp.ListYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3475. resp.ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3476. resp.ListHzReport = ListYxReport
  3477. br.Ret = 200
  3478. br.Success = true
  3479. br.Msg = "获取成功"
  3480. br.Data = resp
  3481. }
  3482. // @Title 产业报告公司列表
  3483. // @Description 获取产业报告公司列表接口
  3484. // @Param ChartPermissionId query int true "行业id"
  3485. // @Success 200 {object} models.IndustrialManagementList
  3486. // @router /home/stockName [get]
  3487. func (this *ReportController) StockNameList() {
  3488. br := new(models.BaseResponse).Init()
  3489. defer func() {
  3490. this.Data["json"] = br
  3491. this.ServeJSON()
  3492. }()
  3493. user := this.User
  3494. if user == nil {
  3495. br.Msg = "请重新登录"
  3496. br.Ret = 408
  3497. return
  3498. }
  3499. //uid := user.UserId
  3500. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3501. list, err := models.GetSummaryArticle(chartPermissionId)
  3502. if err != nil {
  3503. br.Msg = "获取综述报告公司名称失败"
  3504. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3505. return
  3506. }
  3507. var respList []*models.SummaryArticleStock
  3508. for _, item := range list {
  3509. sliceSubjects := strings.Split(item.Stock, "/")
  3510. if len(sliceSubjects) > 0 {
  3511. for i, vSubject := range sliceSubjects {
  3512. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3513. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3514. subject := sliceXiahuaxian[0]
  3515. if i > 0 {
  3516. newItem := models.SummaryArticleStock{
  3517. Id: item.Id,
  3518. ArticleId: item.ArticleId,
  3519. Stock: subject,
  3520. }
  3521. respList = append(respList, &newItem)
  3522. } else {
  3523. item.Stock = subject
  3524. respList = append(respList, item)
  3525. }
  3526. }
  3527. }
  3528. //index := strings.Index(item.Stock, "(")
  3529. //item.Stock = item.Stock[:index]
  3530. //if strings.Contains(item.Stock, "-B"){
  3531. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3532. //}
  3533. //if strings.Contains(item.Stock, "-W"){
  3534. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3535. //}
  3536. }
  3537. resp := new(models.SummaryArticleStockResp)
  3538. resp.List = respList
  3539. br.Ret = 200
  3540. br.Success = true
  3541. br.Msg = "获取成功"
  3542. br.Data = resp
  3543. }
  3544. // @Title 文章留言接口
  3545. // @Description 文章留言接口
  3546. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3547. // @Success 200 {object} models.TacticsListResp
  3548. // @router /commentAdd [post]
  3549. func (this *ReportController) CommentAdd() {
  3550. br := new(models.BaseResponse).Init()
  3551. defer func() {
  3552. this.Data["json"] = br
  3553. this.ServeJSON()
  3554. }()
  3555. user := this.User
  3556. if user == nil {
  3557. br.Msg = "请重新登录"
  3558. br.Ret = 408
  3559. return
  3560. }
  3561. var req models.AddCygxArticleCommentReq
  3562. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3563. if err != nil {
  3564. br.Msg = "参数解析异常!"
  3565. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3566. return
  3567. }
  3568. if req.ArticleId <= 0 {
  3569. br.Msg = "文章不存在"
  3570. br.ErrMsg = "文章不存在,文章ID错误"
  3571. return
  3572. }
  3573. if req.Content == "" {
  3574. br.Msg = "建议内容不可为空"
  3575. return
  3576. }
  3577. content := req.Content
  3578. itemToken, err := services.WxGetToken()
  3579. if err != nil {
  3580. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3581. return
  3582. }
  3583. if itemToken.AccessToken == "" {
  3584. br.Msg = "accessToken is empty"
  3585. return
  3586. }
  3587. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3588. if err != nil {
  3589. br.Msg = "内容校验失败!"
  3590. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3591. return
  3592. }
  3593. if commerr.ErrCode != 0 {
  3594. br.Msg = "内容违规,请重新提交!"
  3595. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3596. return
  3597. }
  3598. articleId := req.ArticleId
  3599. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3600. if articleInfo == nil {
  3601. br.Msg = "操作失败"
  3602. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3603. return
  3604. }
  3605. if errInfo != nil {
  3606. br.Msg = "操作失败"
  3607. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3608. return
  3609. }
  3610. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3611. if err != nil {
  3612. br.Msg = "提交失败!"
  3613. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3614. return
  3615. }
  3616. if companyDetail == nil {
  3617. br.Msg = "提交失败!"
  3618. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3619. return
  3620. }
  3621. item := models.CygxArticleComment{
  3622. UserId: user.UserId,
  3623. ArticleId: req.ArticleId,
  3624. CreateTime: time.Now(),
  3625. Mobile: user.Mobile,
  3626. Email: user.Email,
  3627. CompanyId: user.CompanyId,
  3628. CompanyName: companyDetail.CompanyName,
  3629. Content: content,
  3630. Title: articleInfo.Title,
  3631. }
  3632. msgId, err := models.AddArticleComment(&item)
  3633. if err != nil {
  3634. br.Msg = "提交失败"
  3635. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3636. return
  3637. }
  3638. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  3639. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  3640. br.Ret = 200
  3641. br.Success = true
  3642. br.Msg = "提交成功"
  3643. }
  3644. // @Title 记录用户浏览音频回放接口
  3645. // @Description 记录用户浏览音频回放接口
  3646. // @Param request body models.ArticleIdReq true "type json string"
  3647. // @Success Ret=200 操作成功
  3648. // @router /voiceHistory/add [post]
  3649. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3650. br := new(models.BaseResponse).Init()
  3651. defer func() {
  3652. this.Data["json"] = br
  3653. this.ServeJSON()
  3654. }()
  3655. user := this.User
  3656. if user == nil {
  3657. br.Msg = "请登录"
  3658. br.ErrMsg = "请登录,用户信息为空"
  3659. br.Ret = 408
  3660. return
  3661. }
  3662. uid := user.UserId
  3663. var req models.ArticleIdReq
  3664. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3665. if err != nil {
  3666. br.Msg = "参数解析异常!"
  3667. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3668. return
  3669. }
  3670. articleId := req.ArticleId
  3671. playSeconds := req.PlaySeconds
  3672. pageRouter := req.PageRouter
  3673. if pageRouter == "本周研究汇总" {
  3674. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3675. if articleInfo == nil {
  3676. br.Msg = "操作失败"
  3677. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3678. return
  3679. }
  3680. if errInfo != nil {
  3681. br.Msg = "操作失败"
  3682. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3683. return
  3684. }
  3685. var sellerName string
  3686. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3687. if err != nil {
  3688. br.Msg = "报名失败!"
  3689. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3690. return
  3691. }
  3692. item := models.CygxResearchSummaryVoiceHistory{
  3693. ArticleId: articleId,
  3694. UserId: uid,
  3695. CreateTime: time.Now(),
  3696. Mobile: user.Mobile,
  3697. Email: user.Email,
  3698. CompanyId: user.CompanyId,
  3699. CompanyName: user.CompanyName,
  3700. RealName: user.RealName,
  3701. SellerName: sellerName,
  3702. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3703. ModifyTime: time.Now(),
  3704. }
  3705. if playSeconds != 0 {
  3706. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3707. if err != nil {
  3708. br.Msg = "操作失败"
  3709. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3710. return
  3711. }
  3712. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3713. if err != nil {
  3714. br.Msg = "更新失败"
  3715. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3716. return
  3717. }
  3718. } else {
  3719. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3720. if err != nil {
  3721. br.Msg = "操作失败"
  3722. br.ErrMsg = "操作失败,Err:" + err.Error()
  3723. return
  3724. }
  3725. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3726. if err != nil {
  3727. br.Msg = "更新失败"
  3728. br.ErrMsg = "更新失败,Err:" + err.Error()
  3729. return
  3730. }
  3731. }
  3732. } else if pageRouter == "上周纪要汇总" {
  3733. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3734. if articleInfo == nil {
  3735. br.Msg = "操作失败"
  3736. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3737. return
  3738. }
  3739. if errInfo != nil {
  3740. br.Msg = "操作失败"
  3741. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3742. return
  3743. }
  3744. var sellerName string
  3745. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3746. if err != nil {
  3747. br.Msg = "报名失败!"
  3748. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3749. return
  3750. }
  3751. item := models.CygxMinutesSummaryVoiceHistory{
  3752. ArticleId: articleId,
  3753. UserId: uid,
  3754. CreateTime: time.Now(),
  3755. Mobile: user.Mobile,
  3756. Email: user.Email,
  3757. CompanyId: user.CompanyId,
  3758. CompanyName: user.CompanyName,
  3759. RealName: user.RealName,
  3760. SellerName: sellerName,
  3761. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3762. ModifyTime: time.Now(),
  3763. }
  3764. if playSeconds != 0 {
  3765. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3766. if err != nil {
  3767. br.Msg = "操作失败"
  3768. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3769. return
  3770. }
  3771. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3772. if err != nil {
  3773. br.Msg = "更新失败"
  3774. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3775. return
  3776. }
  3777. } else {
  3778. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3779. if err != nil {
  3780. br.Msg = "操作失败"
  3781. br.ErrMsg = "操作失败,Err:" + err.Error()
  3782. return
  3783. }
  3784. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3785. if err != nil {
  3786. br.Msg = "更新失败"
  3787. br.ErrMsg = "更新失败,Err:" + err.Error()
  3788. return
  3789. }
  3790. }
  3791. } else if pageRouter == "报告精选" {
  3792. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3793. if articleInfo == nil {
  3794. br.Msg = "操作失败"
  3795. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3796. return
  3797. }
  3798. if errInfo != nil {
  3799. br.Msg = "操作失败"
  3800. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3801. return
  3802. }
  3803. var sellerName string
  3804. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3805. if err != nil {
  3806. br.Msg = "报名失败!"
  3807. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3808. return
  3809. }
  3810. item := models.CygxReportSelectionVoiceHistory{
  3811. ArticleId: articleId,
  3812. UserId: uid,
  3813. CreateTime: time.Now(),
  3814. Mobile: user.Mobile,
  3815. Email: user.Email,
  3816. CompanyId: user.CompanyId,
  3817. CompanyName: user.CompanyName,
  3818. RealName: user.RealName,
  3819. SellerName: sellerName,
  3820. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3821. ModifyTime: time.Now(),
  3822. }
  3823. if playSeconds != 0 {
  3824. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3825. if err != nil {
  3826. br.Msg = "操作失败"
  3827. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3828. return
  3829. }
  3830. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3831. if err != nil {
  3832. br.Msg = "更新失败"
  3833. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3834. return
  3835. }
  3836. } else {
  3837. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3838. if err != nil {
  3839. br.Msg = "操作失败"
  3840. br.ErrMsg = "操作失败,Err:" + err.Error()
  3841. return
  3842. }
  3843. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3844. if err != nil {
  3845. br.Msg = "更新失败"
  3846. br.ErrMsg = "更新失败,Err:" + err.Error()
  3847. return
  3848. }
  3849. }
  3850. }
  3851. br.Ret = 200
  3852. br.Success = true
  3853. br.Msg = "操作成功"
  3854. return
  3855. }
  3856. // @Title 周期行业报告分类列表接口
  3857. // @Description 周期获取行业报告分类列表接口
  3858. // @Success 200 {object} models.TradeReportMappingResp
  3859. // @router /zhouqi_tradeList [get]
  3860. func (this *ReportController) ZouqiTradeList() {
  3861. br := new(models.BaseResponse).Init()
  3862. defer func() {
  3863. this.Data["json"] = br
  3864. this.ServeJSON()
  3865. }()
  3866. user := this.User
  3867. if user == nil {
  3868. br.Msg = "请重新登录"
  3869. br.Ret = 408
  3870. return
  3871. }
  3872. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  3873. if err != nil {
  3874. br.Msg = "获取信息失败"
  3875. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3876. return
  3877. }
  3878. resp := new(models.TradeReportMappingResp)
  3879. var list []*models.TradeReportMapping
  3880. if len(listCategory) == 0 {
  3881. list = make([]*models.TradeReportMapping, 0)
  3882. } else {
  3883. for _, v := range listCategory {
  3884. item := new(models.TradeReportMapping)
  3885. item.CategoryId = v.CategoryId
  3886. item.MatchTypeName = v.MatchTypeName
  3887. item.UpdateTime = v.ArticleUpdateTime
  3888. //item.ListArticle = make([]*models.HomeArticle, 0)
  3889. list = append(list, item)
  3890. }
  3891. }
  3892. resp.List = list
  3893. br.Ret = 200
  3894. br.Success = true
  3895. br.Msg = "获取成功"
  3896. br.Data = resp
  3897. }
  3898. // @Title 周期根据行业分类获取行业文章列表
  3899. // @Description 周期根据行业分类获取行业文章列表接口
  3900. // @Param PageSize query int true "每页数据条数"
  3901. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3902. // @Param CategoryId query int true "分类ID"
  3903. // @Success 200 {object} models.TacticsListResp
  3904. // @router /tactics/zhouqi_list [get]
  3905. func (this *ReportController) ZhouqiTacticsList() {
  3906. br := new(models.BaseResponse).Init()
  3907. defer func() {
  3908. this.Data["json"] = br
  3909. this.ServeJSON()
  3910. }()
  3911. user := this.User
  3912. if user == nil {
  3913. br.Msg = "请重新登录"
  3914. br.Ret = 408
  3915. return
  3916. }
  3917. //uid := user.UserId
  3918. pageSize, _ := this.GetInt("PageSize")
  3919. currentIndex, _ := this.GetInt("CurrentIndex")
  3920. categoryId, _ := this.GetInt("CategoryId")
  3921. var startSize int
  3922. if pageSize <= 0 {
  3923. pageSize = utils.PageSize20
  3924. }
  3925. if currentIndex <= 0 {
  3926. currentIndex = 1
  3927. }
  3928. startSize = paging.StartIndex(currentIndex, pageSize)
  3929. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  3930. if err != nil {
  3931. br.Msg = "获取信息失败"
  3932. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  3933. return
  3934. }
  3935. var total int
  3936. //var err error
  3937. resp := new(models.TacticsListZhouqiResp)
  3938. page := paging.GetPaging(currentIndex, pageSize, total)
  3939. list := make([]*models.HomeArticle, 0)
  3940. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  3941. if err != nil {
  3942. br.Msg = "获取信息失败"
  3943. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  3944. return
  3945. }
  3946. var matchTypeName = []string{}
  3947. var seriesName = []string{}
  3948. for _, v := range listCategory {
  3949. if v.MatchTypeName != "" {
  3950. matchTypeName = append(matchTypeName, v.MatchTypeName)
  3951. }
  3952. if v.SeriesName != "" {
  3953. seriesName = append(seriesName, v.SeriesName)
  3954. }
  3955. }
  3956. var conditionOr string
  3957. if detail.FiccReportId != "" {
  3958. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  3959. }
  3960. if len(seriesName) > 0 {
  3961. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  3962. }
  3963. var condition string
  3964. //var pars []interface{}
  3965. //if len(seriesName) == 0 {
  3966. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  3967. //} else {
  3968. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  3969. //}
  3970. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  3971. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  3972. if err != nil {
  3973. br.Msg = "获取信息失败"
  3974. br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
  3975. return
  3976. }
  3977. listPublic, err := services.HandleArticleCategoryImg(list)
  3978. if err != nil {
  3979. br.Msg = "获取失败"
  3980. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  3981. return
  3982. }
  3983. var articleIds []int
  3984. for _, v := range listPublic {
  3985. if v.Resource == 1 {
  3986. articleIds = append(articleIds, v.ArticleId)
  3987. }
  3988. }
  3989. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  3990. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  3991. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  3992. resp.IsShowAbstract = true
  3993. listResp := make([]*models.HomeArticle, 0)
  3994. for _, v := range listPublic {
  3995. item := new(models.HomeArticle)
  3996. item.ArticleId = v.ArticleId
  3997. item.ReportId = v.ReportId
  3998. item.Title = v.Title
  3999. item.Annotation = v.Annotation
  4000. item.Abstract = v.Abstract
  4001. item.ImgUrlPc = v.ImgUrlPc
  4002. item.PublishDate = v.PublishDate
  4003. item.Resource = v.Resource
  4004. if v.Resource == 1 {
  4005. item.Pv = articleMapPv[v.ArticleId]
  4006. item.IsCollect = articleCollectMap[v.ArticleId]
  4007. item.CollectNum = articleCollectNumMap[v.ArticleId]
  4008. }
  4009. if v.ReportId > 0 {
  4010. item.Resource = 3
  4011. }
  4012. if v.Abstract != "" {
  4013. item.IsShowAbstract = resp.IsShowAbstract
  4014. }
  4015. listResp = append(listResp, item)
  4016. }
  4017. if len(listResp) == 0 {
  4018. listResp = make([]*models.HomeArticle, 0)
  4019. }
  4020. page = paging.GetPaging(currentIndex, pageSize, total)
  4021. resp.List = listResp
  4022. resp.Paging = page
  4023. br.Ret = 200
  4024. br.Success = true
  4025. br.Msg = "获取成功"
  4026. br.Data = resp
  4027. }