report.go 111 KB

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