From 074894e7f8eb9d41f61a49a87a49b8bc8383ad8a Mon Sep 17 00:00:00 2001 From: what-00 Date: Thu, 13 Apr 2023 14:47:34 +0800 Subject: [PATCH] =?UTF-8?q?[style]=20=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/user.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/base/user.go b/base/user.go index c85ff51..dfb7f1a 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",