package sys import ( "encoding/base64" "eta/eta_mini_ht_api/common/contants" "eta/eta_mini_ht_api/common/exception" "eta/eta_mini_ht_api/controllers" configService "eta/eta_mini_ht_api/service/sys" ) type SysController struct { controllers.BaseController } type SysconfigResp struct { Value interface{} } // GetRiskInfoToken 获取风险测评问卷请求Token // @Summary 获取风险测评问卷请求Token // @Description 获取风险测评问卷请求Token // @Success 200 {object} controllers.BaseResponse // @router /config [get] func (s *SysController) GetConfig(config string) { controllers.Wrap(&s.BaseController, func() (result *controllers.WrapData, err error) { result = s.InitWrapData("获取配置项失败") sysConfig := contants.GetConfig(config) if sysConfig == nil { s.FailedResult("配置项不存在", result) return } var value interface{} switch sysConfig.ConfigType { case "string": value, err = configService.GetStrConfig(sysConfig.ConfigId) case "int": value, err = configService.GetIntConfig(sysConfig.ConfigId) case "byte": value, err = configService.GetByteConfig(sysConfig.ConfigId) default: s.FailedResult("配置项类型错误", result) return } if err != nil { s.FailedResult("配置项获取失败", result) return } result = s.InitWrapData("风险测评问卷请求token生成成功") s.SuccessResult("success", SysconfigResp{ Value: value, }, result) return }) } // GetQRCode 获取微信二维码 // @Summary 获取微信二维码 // @Description 获取微信二维码 // @Success 200 {object} controllers.BaseResponse // @router /getQRCode [get] func (s *SysController) GetQRCode(code string) { controllers.Wrap(&s.BaseController, func() (result *controllers.WrapData, err error) { result = s.InitWrapData("获取二维码失败") //path := "https://appchannel.htfutures.com:18086/channelqrcode/main/index.html#/regisApp?channelId=[4]10091" path := "pages/htfutures/account" qrCode, err := configService.GetQRCode(code, path) if err != nil { err = exception.NewWithException(exception.WeChatQRCodeFailed, err.Error()) s.FailedResult("获取二维码失败", result) return } s.SuccessResult("获取二维码成功", base64.StdEncoding.EncodeToString(qrCode), result) return }) }