report.go 107 KB

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