mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-21 12:32:25 +00:00
增加多角色功能和角色切换功能
调整前端获取用户信息方式
This commit is contained in:
@@ -13,5 +13,14 @@ type CasbinInReceive struct {
|
||||
}
|
||||
|
||||
func DefaultCasbin() []CasbinInfo {
|
||||
return []CasbinInfo{{Path: "/menu/getMenu", Method: "POST"}, {Path: "/jwt/jsonInBlacklist", Method: "POST"}}
|
||||
return []CasbinInfo{
|
||||
{Path: "/menu/getMenu", Method: "POST"},
|
||||
{Path: "/jwt/jsonInBlacklist", Method: "POST"},
|
||||
{Path: "/base/login", Method: "POST"},
|
||||
{Path: "/user/register", Method: "POST"},
|
||||
{Path: "/user/changePassword", Method: "POST"},
|
||||
{Path: "/user/setUserAuthority", Method: "POST"},
|
||||
{Path: "/user/setUserInfo", Method: "PUT"},
|
||||
{Path: "/user/getUserInfo", Method: "GET"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package request
|
||||
|
||||
import uuid "github.com/satori/go.uuid"
|
||||
|
||||
// User register structure
|
||||
type Register struct {
|
||||
Username string `json:"userName"`
|
||||
Password string `json:"passWord"`
|
||||
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
|
||||
HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888"`
|
||||
Username string `json:"userName"`
|
||||
Password string `json:"passWord"`
|
||||
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
|
||||
HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888"`
|
||||
AuthorityIds []string `json:"authorityIds"`
|
||||
}
|
||||
|
||||
// User login structure
|
||||
@@ -28,6 +27,11 @@ type ChangePasswordStruct struct {
|
||||
|
||||
// Modify user's auth structure
|
||||
type SetUserAuth struct {
|
||||
UUID uuid.UUID `json:"uuid"` // 用户UUID
|
||||
AuthorityId string `json:"authorityId"` // 角色ID
|
||||
AuthorityId string `json:"authorityId"` // 角色ID
|
||||
}
|
||||
|
||||
// Modify user's auth structure
|
||||
type SetUserAuthorities struct {
|
||||
ID uint
|
||||
AuthorityIds []string `json:"authorityIds"` // 角色ID
|
||||
}
|
||||
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
|
||||
type SysUser struct {
|
||||
global.GVA_MODEL
|
||||
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID
|
||||
Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名
|
||||
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
|
||||
SideMode string `json:"sideMode" gorm:"default:dark;comment:用户角色ID"` // 用户侧边主题
|
||||
ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:用户角色ID"` // 活跃颜色
|
||||
BaseColor string `json:"baseColor" gorm:"default:#fff;comment:用户角色ID"` // 基础颜色
|
||||
UUID uuid.UUID `json:"uuid" gorm:"comment:用户UUID"` // 用户UUID
|
||||
Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名
|
||||
Password string `json:"-" gorm:"comment:用户登录密码"` // 用户登录密码
|
||||
NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称
|
||||
HeaderImg string `json:"headerImg" gorm:"default:http://qmplusimg.henrongyi.top/head.png;comment:用户头像"` // 用户头像
|
||||
Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
|
||||
AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID
|
||||
SideMode string `json:"sideMode" gorm:"default:dark;comment:用户角色ID"` // 用户侧边主题
|
||||
ActiveColor string `json:"activeColor" gorm:"default:#1890ff;comment:用户角色ID"` // 活跃颜色
|
||||
BaseColor string `json:"baseColor" gorm:"default:#fff;comment:用户角色ID"` // 基础颜色
|
||||
Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package system
|
||||
|
||||
type SysUseAuthority struct {
|
||||
SysUserId uint `gorm:"column:sys_user_id"`
|
||||
SysAuthorityAuthorityId string `gorm:"column:sys_authority_authority_id"`
|
||||
}
|
||||
|
||||
func (s *SysUseAuthority) TableName() string {
|
||||
return "sys_user_authority"
|
||||
}
|
||||
Reference in New Issue
Block a user