From ed2b936bf2757fc259cf29a8d7349b983b6796b3 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sat, 18 Oct 2025 22:35:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/user.go | 34 +++++++++++++++++++--------------- handler/cid.go | 4 ++-- handler/file.go | 2 +- handler/tool.go | 6 +++--- main.go | 6 +++--- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/dao/user.go b/dao/user.go index 87f64ea..dff01f7 100644 --- a/dao/user.go +++ b/dao/user.go @@ -8,21 +8,25 @@ import ( type User struct { gorm.Model - Name string `gorm:"column:name"` - Age int `gorm:"column:age"` - Email string `gorm:"column:email"` - Password string `gorm:"column:password"` - Gender string `gorm:"column:gender"` - Role string `gorm:"column:role"` - Redis bool `gorm:"column:redis"` - Run bool `gorm:"column:run"` - Upload bool `gorm:"column:upload"` - VideoFunc bool `gorm:"column:video_func"` //视频功能 - DeviceFunc bool `gorm:"column:device_func"` //设备功能 - CIDFunc bool `gorm:"column:cid_func"` //持续集成功能 - Avatar string `gorm:"column:avatar"` - CreateTime string `gorm:"column:create_time"` - UpdateTime string `gorm:"column:update_time"` + Name string `gorm:"column:name"` + Age int `gorm:"column:age"` + Email string `gorm:"column:email"` + Password string `gorm:"column:password"` + Gender string `gorm:"column:gender"` + Role string `gorm:"column:role"` + Redis int `gorm:"column:redis"` + Run int `gorm:"column:run"` + Upload int `gorm:"column:upload"` + VideoFunc int `gorm:"column:video_func"` //视频功能 + DeviceFunc int `gorm:"column:device_func"` //设备功能 + CIDFunc int `gorm:"column:cid_func"` //持续集成功能, 0为无效, -1为false, 1为true + Avatar string `gorm:"column:avatar"` + PasswordNeedSecondAuth int `gorm:"column:password_need_second_auth" json:"password_need_second_auth"` + ThirdPartyNeedSecondAuth int `gorm:"column:third_party_need_second_auth" json:"third_party_need_second_auth"` + CodeNeedSecondAuth int `gorm:"column:code_need_second_auth" json:"code_need_second_auth"` + AISecondAuth int `json:"ai_second_auth" column:"ai_second_auth"` + LoginAddressInfo string `gorm:"column:login_address_info" json:"login_address_info,omitempty"` + LoginDeviceInfo string `gorm:"column:login_device_info" json:"login_device_info,omitempty"` } func CreateUser(name, password, email, gender string, age int) uint { diff --git a/handler/cid.go b/handler/cid.go index 4ea985a..9babe17 100644 --- a/handler/cid.go +++ b/handler/cid.go @@ -87,7 +87,7 @@ func RunCID(c *gin.Context) { //获取权限 //user := dao.FindUserByUserID(authID) user := service.GetUserByIDFromUserCenter(authID) - if user.Run == false { + if user.Run > 0 { c.JSON(200, gin.H{"error": "no run Permissions", "code": proto.NoRunPermissions, "message": "no run Permissions"}) return } @@ -230,7 +230,7 @@ func CIDCallback(c *gin.Context) { //user := dao.FindUserByUserID(res.Auth_id) user := service.GetUserByIDFromUserCenter(res.Auth_id) - if user.Run == false { + if user.Run > 0 { resp.Code, resp.Message = proto.NoRunPermissions, "the user has no run Permissions" c.JSON(http.StatusOK, resp) return diff --git a/handler/file.go b/handler/file.go index 2c43032..253b6a1 100644 --- a/handler/file.go +++ b/handler/file.go @@ -141,7 +141,7 @@ func UploadFileV2(c *gin.Context) { } user := dao.FindUserByUserID(id1) - if user.Upload == false { + if user.Upload > 0 { c.JSON(http.StatusOK, gin.H{"error": "no upload Permissions", "code": proto.NoUploadPermissions, "message": "failed"}) return } diff --git a/handler/tool.go b/handler/tool.go index f4bdc98..a752db3 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -258,7 +258,7 @@ func UploadFile(c *gin.Context) { } user := dao.FindUserByUserID(id1) - if user.Upload == false { + if user.Upload > 0 { c.JSON(http.StatusOK, gin.H{"error": "no upload Permissions", "code": proto.NoUploadPermissions, "message": "failed"}) return } @@ -351,7 +351,7 @@ func SetRedis(c *gin.Context) { id, _ := c.Get("id") id1 := int(id.(float64)) user := dao.FindUserByUserID(id1) - if user.Redis == false { + if user.Redis > 0 { c.JSON(http.StatusOK, gin.H{"error": "no redis Permissions", "code": proto.NoRedisPermissions, "message": "failed"}) return } @@ -379,7 +379,7 @@ func GetRedis(c *gin.Context) { id, _ := c.Get("id") id1 := int(id.(float64)) user := dao.FindUserByUserID(id1) - if user.Redis == false { + if user.Redis > 0 { c.JSON(http.StatusOK, gin.H{"error": "no redis Permissions", "code": proto.NoRedisPermissions, "message": "failed"}) return } diff --git a/main.go b/main.go index 992bf9d..c079816 100644 --- a/main.go +++ b/main.go @@ -392,13 +392,13 @@ func UserFuncIntercept(id int, url string) bool { //如果用户有权限,则不拦截 for k, v := range proto.Per_menu_map { if strings.Contains(url, k) { - if v == 1 && user.VideoFunc == false { + if v == 1 && user.VideoFunc > 0 { return true } - if v == 2 && user.DeviceFunc == false { + if v == 2 && user.DeviceFunc > 0 { return true } - if v == 3 && user.CIDFunc == false { + if v == 3 && user.CIDFunc > 0 { return true } }