report.go 97 KB

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