config.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_clpt/models"
  5. "hongze/hongze_clpt/services"
  6. "hongze/hongze_clpt/utils"
  7. "strings"
  8. )
  9. type ConfigController struct {
  10. BaseAuthController
  11. }
  12. type BaseConfigController struct {
  13. BaseCommonController
  14. }
  15. // @Title 相关内容是否展示
  16. // @Description 相关内容是否展示接口
  17. // @Param request body models.IsShow true "type json string"
  18. // @Success 200
  19. // @router /isShow [get]
  20. func (this *ConfigController) IsShow() {
  21. br := new(models.BaseResponse).Init()
  22. defer func() {
  23. this.Data["json"] = br
  24. this.ServeJSON()
  25. }()
  26. user := this.User
  27. if user == nil {
  28. br.Msg = "请重新登录"
  29. br.Ret = 408
  30. return
  31. }
  32. var resp models.IsShow
  33. resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
  34. resp.IsShowResearchPoints = true
  35. br.Ret = 200
  36. br.Success = true
  37. br.Data = resp
  38. }
  39. // @Title 关于我们
  40. // @Description 关于我们接口
  41. // @Param request body models.IsShow true "type json string"
  42. // @Success 200
  43. // @router /aboutUs [get]
  44. func (this *ConfigController) AboutUs() {
  45. br := new(models.BaseResponse).Init()
  46. defer func() {
  47. this.Data["json"] = br
  48. this.ServeJSON()
  49. }()
  50. user := this.User
  51. if user == nil {
  52. br.Msg = "请重新登录"
  53. br.Ret = 408
  54. return
  55. }
  56. var aboutUs = new(models.AboutUs)
  57. aboutUs.Title = utils.ABOUT_US_TITLE
  58. aboutUs.Url = utils.ABOUT_US_URL
  59. br.Ret = 200
  60. br.Success = true
  61. br.Data = aboutUs
  62. }
  63. // @Title 关于我们浏览记录
  64. // @Description 关于我们浏览记录接口
  65. // @Success 200
  66. // @router /aboutUs/addHistory [post]
  67. func (this *ConfigController) AboutUsAdd() {
  68. br := new(models.BaseResponse).Init()
  69. defer func() {
  70. this.Data["json"] = br
  71. this.ServeJSON()
  72. }()
  73. user := this.User
  74. if user == nil {
  75. br.Msg = "请重新登录"
  76. br.Ret = 408
  77. return
  78. }
  79. go services.AddCygxAboutUsVideoHistory(user)
  80. br.Ret = 200
  81. br.Success = true
  82. br.Msg = "操作成功!"
  83. }
  84. // @Title 买方研选产品介绍(无需token)
  85. // @Description 买方研选产品介绍接口(无需token)
  86. // @Success 200 {object} models.ConfigImgListResp
  87. // @router /research/introduce [get]
  88. func (this *BaseConfigController) ResearchIntroduce() {
  89. br := new(models.BaseResponse).Init()
  90. defer func() {
  91. this.Data["json"] = br
  92. this.ServeJSON()
  93. }()
  94. conf, err := models.GetConfigByCode("research_introduce_img_url_pc")
  95. if err != nil {
  96. br.Msg = "获取数据失败"
  97. br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
  98. return
  99. }
  100. if conf.ConfigValue == "" {
  101. br.Msg = "获取失败"
  102. br.ErrMsg = "买方研选产品介绍信息失败"
  103. return
  104. }
  105. list := new(*models.ConfigImgListResp)
  106. if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
  107. br.Msg = "获取失败"
  108. br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
  109. return
  110. }
  111. br.Msg = "获取成功!"
  112. br.Ret = 200
  113. br.Success = true
  114. br.Data = list
  115. }
  116. // @Title 买方研选报价单(无需token)
  117. // @Description 买方研选报价单(无需token)
  118. // @Success 200 {object} models.ConfigImgListResp
  119. // @router /research/quotation [get]
  120. func (this *BaseConfigController) ResearchQuotation() {
  121. br := new(models.BaseResponse).Init()
  122. defer func() {
  123. this.Data["json"] = br
  124. this.ServeJSON()
  125. }()
  126. conf, err := models.GetConfigByCode("research_quotation_img_url_pc")
  127. if err != nil {
  128. br.Msg = "获取数据失败"
  129. br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
  130. return
  131. }
  132. if conf.ConfigValue == "" {
  133. br.Msg = "获取失败"
  134. br.ErrMsg = "买方研选产品介绍信息失败"
  135. return
  136. }
  137. list := new(*models.ConfigImgListResp)
  138. if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
  139. br.Msg = "获取失败"
  140. br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
  141. return
  142. }
  143. br.Msg = "获取成功!"
  144. br.Ret = 200
  145. br.Success = true
  146. br.Data = list
  147. }
  148. // @Title 买方研选升级新资源海报(无需token)
  149. // @Description 买方研选升级新资源海报(无需token)
  150. // @Success 200 {object} models.ConfigImgListResp
  151. // @router /research/hb [get]
  152. func (this *BaseConfigController) ResearchHb() {
  153. br := new(models.BaseResponse).Init()
  154. defer func() {
  155. this.Data["json"] = br
  156. this.ServeJSON()
  157. }()
  158. detail, err := models.GetConfigByCode("research_hb_img_url")
  159. if err != nil {
  160. br.Msg = "获取数据失败"
  161. br.ErrMsg = "买方研选升级新资源海报信息失败,Err:" + err.Error()
  162. return
  163. }
  164. resp := new(models.ConfigImgHbResp)
  165. list := strings.Split(detail.ConfigValue, "{|}")
  166. if len(list) == 0 {
  167. list = make([]string, 0)
  168. }
  169. resp.HbImg = list[0]
  170. resp.ButtonImg = list[len(list)-1]
  171. br.Msg = "获取成功!"
  172. br.Ret = 200
  173. br.Success = true
  174. br.Data = resp
  175. }