report.go 113 KB

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