feat: 完善数据库信息保存以及项目、redis相关操作

This commit is contained in:
meilin.huang
2021-07-28 18:03:19 +08:00
parent 3ebc3ee14d
commit bda3920c1e
153 changed files with 5527 additions and 1017 deletions

28
base/captcha/captcha.go Normal file
View File

@@ -0,0 +1,28 @@
package captcha
import (
"mayfly-go/base/biz"
"github.com/mojocn/base64Captcha"
)
var store = base64Captcha.DefaultMemStore
var driver base64Captcha.Driver = base64Captcha.DefaultDriverDigit
// 生成验证码
func Generate() (string, string) {
c := base64Captcha.NewCaptcha(driver, store)
// 获取
id, b64s, err := c.Generate()
biz.ErrIsNilAppendErr(err, "获取验证码错误: %s")
return id, b64s
}
// 验证验证码
func Verify(id string, val string) bool {
if id == "" || val == "" {
return false
}
// 同时清理掉这个图片
return store.Verify(id, val, true)
}