51 lines
904 B
Go
51 lines
904 B
Go
|
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
|
||
|
}
|
||
|
}
|