sys_controller.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package sys
  2. import (
  3. "encoding/base64"
  4. "eta/eta_mini_ht_api/common/contants"
  5. "eta/eta_mini_ht_api/common/exception"
  6. "eta/eta_mini_ht_api/controllers"
  7. configService "eta/eta_mini_ht_api/service/sys"
  8. )
  9. type SysController struct {
  10. controllers.BaseController
  11. }
  12. type SysconfigResp struct {
  13. Value interface{}
  14. }
  15. // GetRiskInfoToken 获取风险测评问卷请求Token
  16. // @Summary 获取风险测评问卷请求Token
  17. // @Description 获取风险测评问卷请求Token
  18. // @Success 200 {object} controllers.BaseResponse
  19. // @router /config [get]
  20. func (s *SysController) GetConfig(config string) {
  21. controllers.Wrap(&s.BaseController, func() (result *controllers.WrapData, err error) {
  22. result = s.InitWrapData("获取配置项失败")
  23. sysConfig := contants.GetConfig(config)
  24. if sysConfig == nil {
  25. s.FailedResult("配置项不存在", result)
  26. return
  27. }
  28. var value interface{}
  29. switch sysConfig.ConfigType {
  30. case "string":
  31. value, err = configService.GetStrConfig(sysConfig.ConfigId)
  32. case "int":
  33. value, err = configService.GetIntConfig(sysConfig.ConfigId)
  34. case "byte":
  35. value, err = configService.GetByteConfig(sysConfig.ConfigId)
  36. default:
  37. s.FailedResult("配置项类型错误", result)
  38. return
  39. }
  40. if err != nil {
  41. s.FailedResult("配置项获取失败", result)
  42. return
  43. }
  44. result = s.InitWrapData("风险测评问卷请求token生成成功")
  45. s.SuccessResult("success", SysconfigResp{
  46. Value: value,
  47. }, result)
  48. return
  49. })
  50. }
  51. // GetQRCode 获取微信二维码
  52. // @Summary 获取微信二维码
  53. // @Description 获取微信二维码
  54. // @Success 200 {object} controllers.BaseResponse
  55. // @router /getQRCode [get]
  56. func (s *SysController) GetQRCode(code string) {
  57. controllers.Wrap(&s.BaseController, func() (result *controllers.WrapData, err error) {
  58. result = s.InitWrapData("获取二维码失败")
  59. //path := "https://appchannel.htfutures.com:18086/channelqrcode/main/index.html#/regisApp?channelId=[4]10091"
  60. path := "pages/htfutures/account"
  61. qrCode, err := configService.GetQRCode(code, path)
  62. if err != nil {
  63. err = exception.NewWithException(exception.WeChatQRCodeFailed, err.Error())
  64. s.FailedResult("获取二维码失败", result)
  65. return
  66. }
  67. s.SuccessResult("获取二维码成功", base64.StdEncoding.EncodeToString(qrCode), result)
  68. return
  69. })
  70. }