report.go 104 KB

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