1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package system
- import (
- "github.com/flipped-aurora/gin-vue-admin/global"
- "github.com/flipped-aurora/gin-vue-admin/model/common/response"
- systemRes "github.com/flipped-aurora/gin-vue-admin/model/system/response"
- "github.com/gin-gonic/gin"
- "github.com/mojocn/base64Captcha"
- "go.uber.org/zap"
- )
- var store = base64Captcha.DefaultMemStore
- type BaseApi struct {
- }
- func (b *BaseApi) Captcha(c *gin.Context) {
-
-
- driver := base64Captcha.NewDriverDigit(global.GVA_CONFIG.Captcha.ImgHeight, global.GVA_CONFIG.Captcha.ImgWidth, global.GVA_CONFIG.Captcha.KeyLong, 0.7, 80)
-
- cp := base64Captcha.NewCaptcha(driver, store)
- if id, b64s, err := cp.Generate(); err != nil {
- global.GVA_LOG.Error("验证码获取失败!", zap.Any("err", err))
- response.FailWithMessage("验证码获取失败", c)
- } else {
- response.OkWithDetailed(systemRes.SysCaptchaResponse{
- CaptchaId: id,
- PicPath: b64s,
- }, "验证码获取成功", c)
- }
- }
|