feat: RBAC 基本完成

This commit is contained in:
Blizzard
2025-09-14 21:58:44 +08:00
parent 2ec091bf59
commit 9be75d53fe
35 changed files with 615 additions and 87 deletions
+11 -5
View File
@@ -1,15 +1,16 @@
package system
import (
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"go.uber.org/zap"
"sundynix-go/global"
"sundynix-go/model/commom/response"
"sundynix-go/model/system"
systemReq "sundynix-go/model/system/request"
systemRes "sundynix-go/model/system/response"
"sundynix-go/utils"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"go.uber.org/zap"
)
var store = base64Captcha.DefaultMemStore
@@ -26,7 +27,7 @@ func (a *AuthApi) Login(c *gin.Context) {
}
if l.CaptchaId != "" && l.Captcha != "" && store.Verify(l.CaptchaId, l.Captcha, true) {
u := &system.User{Account: l.Account, Password: l.Password}
user, err := UserService.Login(u)
user, err := userService.Login(u)
if err != nil {
global.Logger.Error("登录失败! 用户名不存在或者密码错误!", zap.Error(err))
response.FailWithMsg("用户名不存在或者密码错误", c)
@@ -38,6 +39,11 @@ func (a *AuthApi) Login(c *gin.Context) {
response.FailWithMsg("验证码错误", c)
}
// 登出
func (a *AuthApi) Logout(c *gin.Context) {
utils.ClearToken(c)
}
// Captcha api 生成验证码
func (u *AuthApi) Captcha(c *gin.Context) {
var driver = base64Captcha.DriverString{
@@ -45,7 +51,7 @@ func (u *AuthApi) Captcha(c *gin.Context) {
Width: 240,
NoiseCount: 2,
ShowLineOptions: 4,
Length: 6,
Length: 4,
Source: "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM",
}