50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package session
|
|
|
|
import (
|
|
"SciencesServer/utils"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type Admin struct {
|
|
UID uint64 `json:"uid"` // 唯一标识ID
|
|
TenantID uint64 `json:"tenant_id"` // 租户ID
|
|
Token string `json:"token"` // token
|
|
Name string `json:"name"` // 名称
|
|
Mobile string `json:"mobile"` // 手机号码
|
|
IsAdmin bool `json:"is_admin"` // 是否超管
|
|
IsSystemAdmin bool `json:"is_system_admin"` // 是否系统管理员
|
|
}
|
|
|
|
func (this *Admin) SetToken(token string) {
|
|
this.Token = token
|
|
}
|
|
|
|
func (this *Admin) GetToken() string {
|
|
return this.GetToken()
|
|
}
|
|
|
|
func (this *Admin) TenantIDFormat() string {
|
|
return fmt.Sprintf("%d", this.TenantID)
|
|
}
|
|
|
|
func (this *Admin) GetUID() uint64 {
|
|
return this.UID
|
|
}
|
|
|
|
func (this *Admin) GetStringUID() string {
|
|
return fmt.Sprintf("%d", this.UID)
|
|
}
|
|
|
|
func (this *Admin) MarshalBinary() ([]byte, error) {
|
|
return json.Marshal(this)
|
|
}
|
|
|
|
func (this *Admin) UnmarshalBinary(data []byte) error {
|
|
return utils.FromJSONBytes(data, this)
|
|
}
|
|
|
|
func NewAdmin() *Admin {
|
|
return &Admin{}
|
|
}
|