蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

171 lines
6.0 KiB

  1. package web
  2. import (
  3. "applet/app/e"
  4. "applet/app/md/setCenter"
  5. "applet/app/svc"
  6. "applet/app/utils"
  7. "encoding/json"
  8. "github.com/gin-gonic/gin"
  9. "strings"
  10. )
  11. // GetBasic
  12. // @Summary 基础设置-网站信息-基本设置(获取)
  13. // @Tags 基础设置
  14. // @Description 网站信息-基本设置(获取)
  15. // @Accept json
  16. // @Produce json
  17. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  18. // @Success 200 {object} setCenter.WebBasicResp "设置列表"
  19. // @Failure 400 {object} md.Response "具体错误"
  20. // @Router /api/settCenter/web/getBasic [get]
  21. func GetBasic(c *gin.Context) {
  22. resp := setCenter.WebBasicResp{
  23. SeoTitle: svc.GetSysCfgStr("seo_title"),
  24. SeoLogo: svc.GetSysCfgStr("seo_logo"),
  25. SeoLogoUrl: svc.GetOssUrl(svc.GetSysCfgStr("seo_logo")),
  26. WebLogo: svc.GetSysCfgStr("web_logo"),
  27. WebLogoUrl: svc.GetOssUrl(svc.GetSysCfgStr("web_logo")),
  28. WapHost: svc.GetOssUrl(svc.GetSysCfgStr("wap_host")),
  29. AndroidDownUrl: svc.GetSysCfgStr("android_down_url"),
  30. IosDownUrl: svc.GetSysCfgStr("ios_down_url"),
  31. }
  32. e.OutSuc(c, resp, nil)
  33. }
  34. // SetBasic
  35. // @Summary 基础设置-网站信息-基本设置(更新)
  36. // @Tags 基础设置
  37. // @Description 基本设置(更新)
  38. // @Accept json
  39. // @Produce json
  40. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  41. // @param req body setCenter.WebBasicReq true "上传需要修改的信息"
  42. // @Success 200 {string} "success"
  43. // @Failure 400 {object} md.Response "具体错误"
  44. // @Router /api/settCenter/web/setBasic [post]
  45. func SetBasic(c *gin.Context) {
  46. var req *setCenter.WebBasicReq
  47. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  48. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  49. return
  50. }
  51. if req.WebLogo != "" {
  52. svc.SetSysCfgStr("web_logo", req.WebLogo)
  53. }
  54. if req.WapHost != "" {
  55. svc.SetSysCfgStr("wap_host", req.WapHost)
  56. }
  57. if req.SeoLogo != "" {
  58. svc.SetSysCfgStr("seo_logo", req.SeoLogo)
  59. }
  60. if req.SeoTitle != "" {
  61. svc.SetSysCfgStr("seo_title", req.SeoTitle)
  62. }
  63. if req.AndroidDownUrl != "" {
  64. svc.SetSysCfgStr("android_down_url", req.AndroidDownUrl)
  65. }
  66. if req.IosDownUrl != "" {
  67. svc.SetSysCfgStr("ios_down_url", req.IosDownUrl)
  68. }
  69. e.OutSuc(c, "success", nil)
  70. return
  71. }
  72. // GetDownDomainBasic
  73. // @Summary 基础设置-网站信息-下载页多域名设置(获取)
  74. // @Tags 基础设置
  75. // @Description 网站信息-下载页多域名设置(获取)
  76. // @Accept json
  77. // @Produce json
  78. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  79. // @Success 200 {object} setCenter.WebDomainBasicReq "设置列表"
  80. // @Failure 400 {object} md.Response "具体错误"
  81. // @Router /api/settCenter/web/getDownDomainBasic [get]
  82. func GetDownDomainBasic(c *gin.Context) {
  83. domain := svc.GetSysCfgStr("down_web_domain")
  84. var tmp = make([]string, 0)
  85. json.Unmarshal([]byte(domain), &tmp)
  86. resp := setCenter.WebDomainBasicReq{
  87. WebDomain: tmp,
  88. }
  89. e.OutSuc(c, resp, nil)
  90. }
  91. // SetDownDomainBasic
  92. // @Summary 基础设置-网站信息-下载页多域名设置(更新)
  93. // @Tags 基础设置
  94. // @Description 下载页多域名设置(更新)
  95. // @Accept json
  96. // @Produce json
  97. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  98. // @param req body setCenter.WebDomainBasicReq true "上传需要修改的信息"
  99. // @Success 200 {string} "success"
  100. // @Failure 400 {object} md.Response "具体错误"
  101. // @Router /api/settCenter/web/setDownDomainBasic [post]
  102. func SetDownDomainBasic(c *gin.Context) {
  103. var req *setCenter.WebDomainBasicReq
  104. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  105. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  106. return
  107. }
  108. domain := utils.SerializeStr(req.WebDomain)
  109. domain = strings.ReplaceAll(domain, "http://", "")
  110. domain = strings.ReplaceAll(domain, "https://", "")
  111. domain = strings.ReplaceAll(domain, "/", "")
  112. svc.SetSysCfgStr("down_web_domain", domain)
  113. e.OutSuc(c, "success", nil)
  114. return
  115. }
  116. // GetRegisterDomainBasic
  117. // @Summary 基础设置-网站信息-下载页多域名设置(获取)
  118. // @Tags 基础设置
  119. // @Description 网站信息-下载页多域名设置(获取)
  120. // @Accept json
  121. // @Produce json
  122. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  123. // @Success 200 {object} setCenter.WebDomainBasicReq "设置列表"
  124. // @Failure 400 {object} md.Response "具体错误"
  125. // @Router /api/settCenter/web/getRegisterDomainBasic [get]
  126. func GetRegisterDomainBasic(c *gin.Context) {
  127. domain := svc.GetSysCfgStr("down_register_domain")
  128. var tmp = make([]string, 0)
  129. json.Unmarshal([]byte(domain), &tmp)
  130. downWebOpen := svc.GetSysCfgStr("down_web_open")
  131. resp := setCenter.WebDomainBasicReq{
  132. WebDomain: tmp,
  133. DownWebOpen: downWebOpen,
  134. }
  135. e.OutSuc(c, resp, nil)
  136. }
  137. // SetRegisterDomainBasic
  138. // @Summary 基础设置-网站信息-下载页多域名设置(更新)
  139. // @Tags 基础设置
  140. // @Description 下载页多域名设置(更新)
  141. // @Accept json
  142. // @Produce json
  143. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  144. // @param req body setCenter.WebDomainBasicReq true "上传需要修改的信息"
  145. // @Success 200 {string} "success"
  146. // @Failure 400 {object} md.Response "具体错误"
  147. // @Router /api/settCenter/web/setRegisterDomainBasic [post]
  148. func SetRegisterDomainBasic(c *gin.Context) {
  149. var req *setCenter.WebDomainBasicReq
  150. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  151. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  152. return
  153. }
  154. domain := utils.SerializeStr(req.WebDomain)
  155. domain = strings.ReplaceAll(domain, "http://", "")
  156. domain = strings.ReplaceAll(domain, "https://", "")
  157. domain = strings.ReplaceAll(domain, "/", "")
  158. svc.SetSysCfgStr("down_web_open", req.DownWebOpen)
  159. svc.SetSysCfgStr("down_register_domain", domain)
  160. e.OutSuc(c, "success", nil)
  161. return
  162. }