report.go 102 KB

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