61 lines
2.3 KiB
Go
61 lines
2.3 KiB
Go
package response
|
||
|
||
import (
|
||
"miniapp/model/app"
|
||
"miniapp/model/common"
|
||
"miniapp/model/common/constant"
|
||
"miniapp/utils"
|
||
"strconv"
|
||
"time"
|
||
)
|
||
|
||
type UserItem struct {
|
||
Id string `json:"id"`
|
||
Phone string `json:"phone"` // 手机号
|
||
Nickname string `json:"nickname"` // 用户名
|
||
CreateAt string `json:"createAt"` // 创建时间
|
||
Avatar string `json:"avatar"` // 头像
|
||
LastLoginAt string `json:"lastLoginAt"` // 最后登录时间
|
||
Status constant.UserStatus `json:"status"` // 状态:1-正常,2-禁用
|
||
}
|
||
|
||
type UserVO struct {
|
||
Id string `json:"id"`
|
||
Nickname string `json:"nickname"`
|
||
Email string `json:"email"`
|
||
Username string `json:"username"`
|
||
Phone string `json:"phone"`
|
||
Status constant.UserStatus `json:"status"`
|
||
Avatar string `json:"avatar"`
|
||
LastLoginAt *time.Time `json:"lastLoginAt"`
|
||
LastLoginIp *string `json:"lastLoginIp"`
|
||
CreatedAt time.Time `json:"createdAt"`
|
||
TimeNote string `json:"timeNote"`
|
||
IsSurgery int `json:"isSurgery" gorm:"default:0;comment:是否已经手术 0未手术 1已手术"`
|
||
IsInfo int `json:"isInfo" gorm:"default:0;comment:是否已经填写信息 0未填写 1已填写"`
|
||
HospitalId int `json:"hospital_id" gorm:"comment:手术医院"`
|
||
SurgeryTime time.Time `json:"surgery_time" gorm:"comment:手术时间"`
|
||
Todos []common.UserTodo `json:"todos" gorm:"comment:用户待办事项"`
|
||
Notes []common.Notes `json:"notes" gorm:"comment:用户须知"`
|
||
}
|
||
|
||
func (auv *UserVO) ParseOrdinary(u app.User) {
|
||
auv.Id = strconv.Itoa(int(u.ID))
|
||
auv.Phone = utils.Desensitization().Phone(u.Phone)
|
||
auv.Nickname = u.Nickname
|
||
auv.Status = u.Status
|
||
auv.LastLoginAt = u.LastLoginAt
|
||
auv.Avatar = u.Avatar
|
||
auv.CreatedAt = u.CreatedAt
|
||
auv.IsSurgery = u.IsSurgery
|
||
auv.IsInfo = u.IsInfo
|
||
auv.HospitalId = u.HospitalId
|
||
auv.SurgeryTime = u.SurgeryTime
|
||
|
||
if u.IsSurgery == 1 {
|
||
auv.TimeNote = "距离下次复查时间还剩:"
|
||
} else {
|
||
auv.TimeNote = "距离手术时间还剩:"
|
||
}
|
||
}
|