config.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_cygx/models"
  5. "time"
  6. )
  7. type ConfigController struct {
  8. BaseAuthController
  9. }
  10. // @Title 获取搜索推荐词
  11. // @Description 获取搜索推荐词
  12. // @Success 200 {object} models.ConfigResp
  13. // @router /detail [get]
  14. func (this *ConfigController) BrowseHistoryList() {
  15. br := new(models.BaseResponse).Init()
  16. defer func() {
  17. this.Data["json"] = br
  18. this.ServeJSON()
  19. }()
  20. configCode := "hot_search"
  21. detail, err := models.GetConfigByCode(configCode)
  22. if err != nil {
  23. br.Msg = "获取数据失败"
  24. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  25. return
  26. }
  27. resp := new(models.ConfigResp)
  28. resp.Item = detail
  29. br.Msg = "获取成功!"
  30. br.Ret = 200
  31. br.Success = true
  32. br.Data = resp
  33. }
  34. // @Title 页面访问统计
  35. // @Description 上传页面访问统计
  36. // @Param request body models.CygxPageHistoryRecordRep true "type json string"
  37. // @Success Ret=200 新增成功
  38. // @router /pageHistory [post]
  39. func (this *ConfigController) PageHistory() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. this.Data["json"] = br
  43. this.ServeJSON()
  44. }()
  45. user := this.User
  46. if user == nil {
  47. br.Msg = "请登录"
  48. br.ErrMsg = "请登录,SysUser Is Empty"
  49. br.Ret = 408
  50. return
  51. }
  52. var req models.CygxPageHistoryRecordRep
  53. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  54. if err != nil {
  55. br.Msg = "参数解析异常!"
  56. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  57. return
  58. }
  59. pageType := req.PageType
  60. var havePageType bool
  61. PageType := []string{"Summary", "SummarySearch", "Report", "ReportSearch", "IndustryList", "Activit", "ActivitSearch", "ActivitParticulars", "ReportParticulars", "MySchedule", "LabelMore", "ArticleCopy"}
  62. for _, v := range PageType {
  63. if pageType == v {
  64. havePageType = true
  65. }
  66. }
  67. if !havePageType {
  68. br.Msg = "新增失败"
  69. br.ErrMsg = "PageType参数类型错误:" + pageType
  70. return
  71. }
  72. item := new(models.CygxPageHistoryRecord)
  73. item.UserId = user.UserId
  74. item.CreateTime = time.Now()
  75. item.Mobile = user.Mobile
  76. item.Email = user.Email
  77. item.CompanyId = user.CompanyId
  78. item.CompanyName = user.CompanyName
  79. item.DetailId = req.DetailId
  80. item.ChartPermissionId = req.ChartPermissionId
  81. item.IndustrialManagementId = req.IndustrialManagementId
  82. item.PageType = req.PageType
  83. _, err = models.AddCygxPageHistoryRecord(item)
  84. if err != nil {
  85. br.Msg = "新增访问记录失败"
  86. br.ErrMsg = "新增访问记录失败,Err:" + err.Error()
  87. return
  88. }
  89. br.Ret = 200
  90. br.Success = true
  91. br.Msg = "新增成功"
  92. }
  93. // @Title 获取研选说明
  94. // @Description 获取研选说明接口
  95. // @Success 200 {object} models.ConfigResp
  96. // @router /descriptionOfResearch [get]
  97. func (this *ConfigController) DescriptionOfResearch() {
  98. br := new(models.BaseResponse).Init()
  99. defer func() {
  100. this.Data["json"] = br
  101. this.ServeJSON()
  102. }()
  103. configCode := "description_of_research"
  104. detail, err := models.GetConfigByCode(configCode)
  105. if err != nil {
  106. br.Msg = "获取数据失败"
  107. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  108. return
  109. }
  110. resp := new(models.ConfigResp)
  111. resp.Item = detail
  112. br.Msg = "获取成功!"
  113. br.Ret = 200
  114. br.Success = true
  115. br.Data = resp
  116. }