ferry/apis/system/captcha.go

28 lines
426 B
Go
Raw Permalink Normal View History

2020-07-13 20:33:20 +08:00
package system
import (
"ferry/tools/app"
"ferry/tools/captcha"
2020-07-16 01:22:01 +08:00
"fmt"
2020-07-13 20:33:20 +08:00
"github.com/gin-gonic/gin"
)
2020-07-17 15:51:05 +08:00
/*
@Author : lanyulei
*/
2020-07-13 20:33:20 +08:00
func GenerateCaptchaHandler(c *gin.Context) {
id, b64s, err := captcha.DriverDigitFunc()
2020-07-16 01:22:01 +08:00
if err != nil {
app.Error(c, -1, err, fmt.Sprintf("验证码获取失败, %v", err.Error()))
return
}
2020-07-13 20:33:20 +08:00
app.Custum(c, gin.H{
"code": 200,
"data": b64s,
"id": id,
"msg": "success",
})
}