You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1016 B
Go
52 lines
1016 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
const UserStatusActive = 1
|
|
const UserStatusDisable = 2
|
|
|
|
type User struct {
|
|
ID int
|
|
Mobile string
|
|
Nickname string
|
|
UserType int `json:"-"`
|
|
MasterUserId int `json:"-"`
|
|
PasswordHash string `json:"-"`
|
|
PaymentPasswordHash string `json:"-"`
|
|
AlipayAccount string
|
|
Profit float64
|
|
Balance float64
|
|
Status int
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time `json:"-"`
|
|
}
|
|
|
|
func (User) TableName() string {
|
|
return "users"
|
|
}
|
|
|
|
func (u User) MarshalJSON() ([]byte, error) {
|
|
type Alias User
|
|
return json.Marshal(&struct {
|
|
CreatedAt string
|
|
*Alias
|
|
}{
|
|
CreatedAt: u.CreatedAt.Format("2006-01-02 15:04:05"),
|
|
Alias: (*Alias)(&u),
|
|
})
|
|
}
|
|
|
|
func (u User) GetStatusText() string {
|
|
statusText := ""
|
|
switch u.Status {
|
|
case UserStatusActive:
|
|
statusText = "正常"
|
|
case UserStatusDisable:
|
|
statusText = "禁用"
|
|
}
|
|
return statusText
|
|
}
|