55 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package userPatientResponse
import (
"fmt"
"hospital-admin-api/api/model"
"hospital-admin-api/utils"
)
// getUserPatientPage 获取医生列表-分页
type getUserPatientPage struct {
PatientId string `json:"patient_id"` // 主键id
UserId string `json:"user_id"` // 用户id;NOT NULL
UserName string `json:"user_name"` // 用户名称
Status int `json:"status"` // 状态0:禁用 1:正常 2:删除)
Avatar string `json:"avatar"` // 头像
Mobile string `json:"mobile"` // 手机号
PatientFamilyCount int `json:"patient_family_count"` // 家庭成员数量
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
}
// GetUserPatientPageResponse 获取用户列表-分页
func GetUserPatientPageResponse(userPatient []*model.UserPatient) []getUserPatientPage {
// 处理返回值
responses := make([]getUserPatientPage, len(userPatient))
if len(userPatient) > 0 {
for i, v := range userPatient {
// 将原始结构体转换为新结构体
response := getUserPatientPage{
PatientId: fmt.Sprintf("%d", v.PatientId),
UserId: fmt.Sprintf("%d", v.UserId),
UserName: v.UserName,
Status: v.Status,
Avatar: utils.AddOssDomain(v.Avatar),
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
if v.PatientFamily != nil {
response.PatientFamilyCount = len(v.PatientFamily)
}
if v.User != nil {
response.Mobile = utils.MaskPhoneStr(v.User.Mobile)
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}