report.go 105 KB

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