report.go 150 KB

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