first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package req
|
||||
|
||||
type User interface {
|
||||
Runtime() UserRuntime
|
||||
// 用户ID
|
||||
ID() int64
|
||||
// 用户UUID
|
||||
Uuid() string
|
||||
// 用户名称
|
||||
Username() string
|
||||
// 用户昵称
|
||||
Nickname() string
|
||||
// 用户明细
|
||||
GetUserInfo() map[string]any
|
||||
// 用户权限
|
||||
Roles() []string
|
||||
// 用户权限检查
|
||||
HasUserRoles(roles ...string) bool
|
||||
// 是否匿名用户
|
||||
IsAnonymous() bool
|
||||
}
|
||||
|
||||
type UserRuntime struct {
|
||||
platform string
|
||||
saas string
|
||||
}
|
||||
|
||||
// 账号运行平台
|
||||
func (this UserRuntime) Platform() string {
|
||||
return this.platform
|
||||
}
|
||||
|
||||
// 账号运行租户
|
||||
func (this UserRuntime) SaaS() string {
|
||||
return this.saas
|
||||
}
|
||||
|
||||
type UserRuntimeOption func(option *UserRuntime)
|
||||
|
||||
func UserRuntimePlatform(value string) UserRuntimeOption {
|
||||
return func(option *UserRuntime) {
|
||||
option.platform = value
|
||||
}
|
||||
}
|
||||
|
||||
func UserRuntimeSaaS(value string) UserRuntimeOption {
|
||||
return func(option *UserRuntime) {
|
||||
option.saas = value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user