report.go 109 KB

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