feat: RBAC 基本完成
This commit is contained in:
@@ -13,6 +13,6 @@ type CustomClaims struct {
|
||||
|
||||
type BaseClaims struct {
|
||||
UUID uuid.UUID
|
||||
ID uint
|
||||
ID string
|
||||
Account string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package request
|
||||
|
||||
type GetMenuTree struct {
|
||||
Category int `json:"category" form:"category"`
|
||||
ParentId string `json:"parentId" form:"parentId"`
|
||||
}
|
||||
@@ -7,3 +7,8 @@ type GetRoleList struct {
|
||||
Code string `json:"code" form:"code"`
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
type GrantMenu struct {
|
||||
RoleId string `json:"roleId"`
|
||||
MenuIds []string `json:"menuIds"`
|
||||
}
|
||||
|
||||
@@ -14,3 +14,13 @@ type GetUserList struct {
|
||||
Account string `json:"account" form:"account"`
|
||||
Phone string `json:"phone" form:"phone"`
|
||||
}
|
||||
|
||||
type ChangePwd struct {
|
||||
Id string `json:"id"`
|
||||
NewPwd string `json:"newPwd"`
|
||||
}
|
||||
|
||||
type GrantRole struct {
|
||||
UserId string `json:"userId"`
|
||||
RoleIds []string `json:"roleIds"`
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@ package response
|
||||
|
||||
import "sundynix-go/model/system"
|
||||
|
||||
type SysUserResponse struct {
|
||||
User system.User `json:"user"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
User system.User `json:"user"`
|
||||
Token string `json:"token"`
|
||||
|
||||
@@ -8,5 +8,5 @@ type Client struct {
|
||||
Name string `gorm:"size:50;" json:"name"`
|
||||
GrantType string `gorm:"size:50;" json:"grantType"`
|
||||
AdditionalInfo string `gorm:"type:text" json:"additionalInfo"`
|
||||
ActiveTimeout uint `json:"activeTimeout"`
|
||||
ActiveTimeout int64 `json:"activeTimeout"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package system
|
||||
|
||||
import "sundynix-go/global"
|
||||
|
||||
type Menu struct {
|
||||
global.BaseModel
|
||||
ParentId string `gorm:"size:100;default:'0'" json:"parentId" form:"parentId"`
|
||||
Category int `json:"category" form:"category"`
|
||||
Name string `gorm:"size:20" json:"name" form:"name"`
|
||||
Title string `gorm:"size:20" json:"title" form:"title"`
|
||||
Code string `gorm:"size:20" json:"code" form:"code"`
|
||||
Permission string `gorm:"size:20" json:"permission" form:"permission"`
|
||||
Locale string `gorm:"size:50" json:"locale" form:"locale"`
|
||||
Icon string `gorm:"size:20" json:"icon" form:"icon"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Children []*Menu `json:"children" gorm:"-"`
|
||||
}
|
||||
@@ -4,7 +4,8 @@ import "sundynix-go/global"
|
||||
|
||||
type Role struct {
|
||||
global.BaseModel
|
||||
Name string `json:"name" form:"name"`
|
||||
Code string `json:"code" form:"code"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Name string `gorm:"size:20" json:"name" form:"name"`
|
||||
Code string `gorm:"size:20" json:"code" form:"code"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
Menus []Menu `gorm:"many2many:role_menu;"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package system
|
||||
|
||||
type RoleMenu struct {
|
||||
RoleId string `json:"roleId" gorm:"size:100;column:role_id;comment:角色id"`
|
||||
MenuId string `json:"menuId" gorm:"size:100;column:menu_id;comment:菜单id"`
|
||||
}
|
||||
@@ -6,21 +6,23 @@ import (
|
||||
|
||||
type Login interface {
|
||||
GetAccount() string
|
||||
GetUserId() uint
|
||||
GetUserId() string
|
||||
GetUserInfo() any
|
||||
}
|
||||
type User struct {
|
||||
global.BaseModel
|
||||
TenantId string `gorm:"size:20;" json:"tenantId" form:"tenantId"`
|
||||
ClientId string `gorm:"size:20;" json:"clientId"`
|
||||
Account string `gorm:"size:11;unique;" json:"account" form:"account"`
|
||||
Password string `gorm:"size:100;" json:"-" form:"password"`
|
||||
Phone string `gorm:"size:11;" json:"phone" form:"phone"`
|
||||
Roles []Role `gorm:"many2many:user_role;" json:"roles"`
|
||||
}
|
||||
|
||||
func (u *User) GetAccount() string {
|
||||
return u.Account
|
||||
}
|
||||
func (u *User) GetUserId() uint {
|
||||
func (u *User) GetUserId() string {
|
||||
return u.Id
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package system
|
||||
|
||||
type UserRole struct {
|
||||
UserId string `json:"userId" gorm:"size:100;column:user_id;comment:用户id"`
|
||||
RoleId string `json:"roleId" gorm:"size:100;column:role_id;comment:角色id"`
|
||||
}
|
||||
Reference in New Issue
Block a user