report.go 109 KB

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