68 lines
2.7 KiB
Go
68 lines
2.7 KiB
Go
package dto
|
||
|
||
import (
|
||
"fmt"
|
||
"hepa-calc-api/api/model"
|
||
"hepa-calc-api/utils"
|
||
"time"
|
||
)
|
||
|
||
// UserDto 用户表
|
||
type UserDto struct {
|
||
UserId string `json:"user_id"` // 用户id
|
||
UserName string `json:"user_name"` // 用户名称
|
||
Mobile string `json:"mobile"` // 手机号
|
||
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||
OpenId string `json:"open_id"` // 用户微信标识
|
||
UnionId string `json:"union_id"` // 微信开放平台标识
|
||
Birthday *string `json:"birthday"` // 出生日期
|
||
Age *uint `json:"age"` // 年龄
|
||
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
Avatar string `json:"avatar"` // 头像
|
||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||
LoginAt *model.LocalTime `json:"login_at"` // 登陆时间
|
||
LoginIp string `json:"login_ip"` // 登陆ip
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
IsCompleteInfo bool `json:"is_complete_info"` // 信息是否完整(0:否 1:是)
|
||
}
|
||
|
||
// UserCheckDto 检测用户
|
||
type UserCheckDto struct {
|
||
WxStatus int `json:"wx_status"` // 微信绑定状态(0:否 1:是)
|
||
MobileStatus int `json:"mobile_status"` // 手机号绑定状态(0:否 1:是)
|
||
Mobile string `json:"mobile"` // 手机号
|
||
}
|
||
|
||
// GetUserDto 详情
|
||
func GetUserDto(m *model.User) *UserDto {
|
||
return &UserDto{
|
||
UserId: fmt.Sprintf("%d", m.UserId),
|
||
UserName: m.UserName,
|
||
Mobile: m.Mobile,
|
||
UserStatus: m.UserStatus,
|
||
RegisterSource: m.RegisterSource,
|
||
Age: m.Age,
|
||
Sex: m.Sex,
|
||
Avatar: utils.AddOssDomain(m.Avatar),
|
||
IsMember: m.IsMember,
|
||
MemberExpireDate: m.MemberExpireDate,
|
||
LoginAt: m.LoginAt,
|
||
LoginIp: m.LoginIp,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
}
|
||
|
||
// LoadBirthday 加载数据-生日
|
||
func (r *UserDto) LoadBirthday(birthday *model.LocalTime) *UserDto {
|
||
if birthday != nil {
|
||
t := time.Time(*birthday).Format("2006-01-02")
|
||
r.Birthday = &t
|
||
}
|
||
|
||
return r
|
||
}
|