report.go 107 KB

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