diff --git a/base/user.go b/base/user.go index dfb7f1a..c85ff51 100644 --- a/base/user.go +++ b/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",