report.go 133 KB

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