report.go 108 KB

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