Documentation
¶
Index ¶
- Variables
- func AddPermForRole(uuid string, perms [][]string) error
- func AuthorityNameScope(authorityName string) func(db *gorm.DB) *gorm.DB
- func AuthorityTypeScope(authorityType int) func(db *gorm.DB) *gorm.DB
- func AuthorityUuidScope(uuid string) func(db *gorm.DB) *gorm.DB
- func Copy(id uint, req *CreateAuthorityRequest) (uint, error)
- func CopyAuthority(ctx *gin.Context)
- func Create(req *CreateAuthorityRequest) (uint, error)
- func CreateAuthority(ctx *gin.Context)
- func DeleteAuthority(ctx *gin.Context)
- func GetAdminAuthorityList(ctx *gin.Context)
- func GetAdminRoleName() string
- func GetAuthorityList(ctx *gin.Context)
- func GetGeneralAuthorityList(ctx *gin.Context)
- func GetMigration() *gormigrate.Migration
- func GetRoleIds() ([]uint, error)
- func GetTenancyAuthorityList(ctx *gin.Context)
- func Group(group *gin.RouterGroup)
- func IsAdminRole(id uint) error
- func ParentIdScope(id uint) func(db *gorm.DB) *gorm.DB
- func Update(id uint, req *UpdateAuthorityRequest) error
- func UpdateAuthority(ctx *gin.Context)
- type Authority
- type AuthorityCollection
- type BaseAuthority
- type BaseMenu
- type CreateAuthorityRequest
- type PageResponse
- type ReqPaginate
- type Response
- type UpdateAuthorityRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRoleNameInvalide = errors.New("角色标识已经被使用")
View Source
var Source = new(source)
Functions ¶
func AuthorityNameScope ¶
AuthorityNameScope
func AuthorityTypeScope ¶
AuthorityTypeScope
func AuthorityUuidScope ¶ added in v0.0.7
AuthorityUuidScope
func GetAdminAuthorityList ¶
GetAdminAuthorityList 分页获取管理角色列表
func GetGeneralAuthorityList ¶
GetGeneralAuthorityList 分页获取用户角色列表
func GetMigration ¶
func GetMigration() *gormigrate.Migration
func GetRoleIds ¶
func GetTenancyAuthorityList ¶
GetTenancyAuthorityList 分页获取商户角色列表
func Group ¶
func Group(group *gin.RouterGroup)
func IsAdminRole ¶
func ParentIdScope ¶ added in v0.1.17
ParentIdScope
func Update ¶
func Update(id uint, req *UpdateAuthorityRequest) error
Types ¶
type Authority ¶
type Authority struct { gorm.Model BaseAuthority Uuid string `json:"uuid" gorm:"uniqueIndex;not null;type:varchar(64);comment:角色标识" binding:"required"` Menus []BaseMenu `json:"menus" gorm:"many2many:authority_menus;"` Children []Authority `json:"children" gorm:"-"` Perms [][]string `json:"perms" gorm:"-"` }
func GetSources ¶
type AuthorityCollection ¶
type AuthorityCollection []Authority
type BaseAuthority ¶
type BaseMenu ¶
type BaseMenu struct { gorm.Model Pid uint `gorm:"index:pid;column:pid;type:int unsigned;not null;default:0" json:"pid"` // 父级id Path string `gorm:"column:path;type:varchar(512);not null" json:"path"` // 路径 Icon string `gorm:"column:icon;type:varchar(32);default:''" json:"icon"` // 图标 MenuName string `gorm:"column:menu_name;type:varchar(128);not null;default:''" json:"menu_name"` // 按钮名 Route string `gorm:"column:route;type:varchar(64);not null" json:"route"` // 路由名称 Params string `gorm:"column:params;type:varchar(128);not null;default:''" json:"params"` // 参数 Sort int8 `gorm:"column:sort;type:tinyint;not null;default:0" json:"sort"` // 排序 Hidden int `gorm:"column:hidden;type:tinyint unsigned;not null;default:1" json:"hidden"` // 是否显示 IsTenancy int `gorm:"column:is_tenancy;type:tinyint unsigned;not null;default:1" json:"is_tenancy"` // 模块,1 平台, 2商户 IsMenu int `gorm:"column:is_menu;type:tinyint unsigned;not null;default:1" json:"is_menu"` // 类型,1菜单 2 权限 Authoritys []Authority `json:"authoritys" gorm:"many2many:authority_menus;"` Children []BaseMenu `json:"children" gorm:"-"` }
type CreateAuthorityRequest ¶ added in v0.0.7
type CreateAuthorityRequest struct { Uuid string `json:"uuid"` Perms [][]string `json:"perms" gorm:"-"` BaseAuthority }
type PageResponse ¶
type PageResponse struct {
Item []*Response
}
Paginate 分页
type ReqPaginate ¶
type Response ¶
type Response struct { orm.Model BaseAuthority Uuid string `json:"uuid"` Menus []BaseMenu `json:"menus" gorm:"many2many:authority_menus;"` Children []Response `json:"children" gorm:"-"` Perms []map[string]string `json:"perms" gorm:"-"` }
type UpdateAuthorityRequest ¶ added in v0.0.7
type UpdateAuthorityRequest struct { Perms [][]string `json:"perms" gorm:"-"` BaseAuthority }
Click to show internal directories.
Click to hide internal directories.