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

8 months ago
package model
import (
"encoding/json"
"time"
)
7 months ago
const UserStatusActive = 1
const UserStatusDisable = 2
8 months ago
type User struct {
ID int
Mobile string
Nickname string
UserType int `json:"-"`
MasterUserId int `json:"-"`
PasswordHash string `json:"-"`
PaymentPasswordHash string `json:"-"`
7 months ago
AlipayAccount string
8 months ago
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),
})
}
7 months ago
func (u User) GetStatusText() string {
statusText := ""
switch u.Status {
case UserStatusActive:
statusText = "正常"
case UserStatusDisable:
statusText = "禁用"
}
return statusText
}