report.go 99 KB

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