sys_controller.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package sys
  2. import (
  3. "eta/eta_mini_ht_api/common/contants"
  4. "eta/eta_mini_ht_api/controllers"
  5. configService "eta/eta_mini_ht_api/service/sys"
  6. )
  7. type SysController struct {
  8. controllers.BaseController
  9. }
  10. type SysconfigResp struct {
  11. Value interface{}
  12. }
  13. // GetRiskInfoToken 获取风险测评问卷请求Token
  14. // @Summary 获取风险测评问卷请求Token
  15. // @Description 获取风险测评问卷请求Token
  16. // @Success 200 {object} controllers.BaseResponse
  17. // @router /config [get]
  18. func (s *SysController) GetConfig(config string) {
  19. controllers.Wrap(&s.BaseController, func() (result *controllers.WrapData, err error) {
  20. result = s.InitWrapData("获取配置项失败")
  21. sysConfig := contants.GetConfig(config)
  22. if sysConfig == nil {
  23. s.FailedResult("配置项不存在", result)
  24. return
  25. }
  26. var value interface{}
  27. switch sysConfig.ConfigType {
  28. case "string":
  29. value, err = configService.GetStrConfig(sysConfig.ConfigId)
  30. case "int":
  31. value, err = configService.GetIntConfig(sysConfig.ConfigId)
  32. case "byte":
  33. value, err = configService.GetByteConfig(sysConfig.ConfigId)
  34. default:
  35. s.FailedResult("配置项类型错误", result)
  36. return
  37. }
  38. if err != nil {
  39. s.FailedResult("配置项获取失败", result)
  40. return
  41. }
  42. result = s.InitWrapData("风险测评问卷请求token生成成功")
  43. s.SuccessResult("success", SysconfigResp{
  44. Value: value,
  45. }, result)
  46. return
  47. })
  48. }