[style] 格式优化
This commit is contained in:
parent
e095ca8bc0
commit
074894e7f8
24
base/user.go
24
base/user.go
@ -8,7 +8,7 @@ import (
|
||||
"git.fsdpf.net/go/contracts"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
type user struct {
|
||||
id int
|
||||
uuid string
|
||||
username string
|
||||
@ -17,39 +17,39 @@ type User struct {
|
||||
roles []string
|
||||
}
|
||||
|
||||
func (this User) ID() int {
|
||||
func (this user) ID() int {
|
||||
return this.id
|
||||
}
|
||||
|
||||
func (this User) Uuid() string {
|
||||
func (this user) Uuid() string {
|
||||
return this.uuid
|
||||
}
|
||||
|
||||
func (this User) Username() string {
|
||||
func (this user) Username() string {
|
||||
return this.username
|
||||
}
|
||||
|
||||
func (this User) Nickname() string {
|
||||
func (this user) Nickname() string {
|
||||
return this.nickname
|
||||
}
|
||||
|
||||
func (this User) GetUserInfo() any {
|
||||
func (this user) GetUserInfo() any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this User) Roles() (roles []string) {
|
||||
func (this user) Roles() (roles []string) {
|
||||
return this.roles
|
||||
}
|
||||
|
||||
func (this User) HasUserRoles(roles ...string) bool {
|
||||
func (this user) HasUserRoles(roles ...string) bool {
|
||||
return lo.Contains(this.Roles(), "ffffffff-ffff-ffff-ffff-ffffffffffff") || len(lo.Intersect(this.Roles(), roles)) > 0
|
||||
}
|
||||
|
||||
func (this User) IsAnonymous() bool {
|
||||
func (this user) IsAnonymous() bool {
|
||||
return reflect.DeepEqual(this.Roles(), []string{"00000000-0000-0000-0000-000000000000"})
|
||||
}
|
||||
|
||||
func (this User) Platform() string {
|
||||
func (this user) Platform() string {
|
||||
if this.platform == "" {
|
||||
return "unknown"
|
||||
}
|
||||
@ -58,7 +58,7 @@ func (this User) Platform() string {
|
||||
|
||||
// 获取匿名用户
|
||||
func GetAnonymous() contracts.User {
|
||||
return User{
|
||||
return user{
|
||||
id: 0,
|
||||
uuid: "00000000-0000-0000-0000-000000000000",
|
||||
username: "anonymous",
|
||||
@ -70,7 +70,7 @@ func GetAnonymous() contracts.User {
|
||||
|
||||
// 系统用户
|
||||
func GetSystemUser() contracts.User {
|
||||
return User{
|
||||
return user{
|
||||
id: -1,
|
||||
uuid: "ffffffff-ffff-ffff-ffff-ffffffffffff",
|
||||
username: "system",
|
||||
|
Loading…
Reference in New Issue
Block a user