package dto import ( "fmt" "hospital-admin-api/api/model" ) type PharmacyDoctorDto struct { DoctorPharmacyId string `json:"doctor_pharmacy_id"` // 绑定关系id DoctorId string `json:"doctor_id"` // 医生id UserId string `json:"user_id"` // 用户id UserName string `json:"user_name"` // 医生姓名 Avatar string `json:"avatar"` // 头像 DoctorTitle int `json:"doctor_title"` // 职称代码 DoctorTitleName string `json:"doctor_title_name"` // 职称名称 DepartmentCustomId string `json:"department_custom_id"` // 科室id DepartmentCustomName string `json:"department_custom_name"` // 科室名称 DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话 HospitalId string `json:"hospital_id"` // 医院id HospitalName string `json:"hospital_name"` // 医院名称 Mobile string `json:"mobile"` // 手机号 IsDefault int `json:"is_default"` // 是否为默认药房(0:否 1:是) Status int `json:"status"` // 状态(1:正常) BindTime model.LocalTime `json:"bind_time"` // 绑定时间 } var doctorTitleMap = map[int]string{ 1: "主任医师", 2: "主任中医师", 3: "副主任医师", 4: "副主任中医师", 5: "主治医师", 6: "住院医师", } func GetPharmacyDoctorDto(m *model.DoctorPharmacy) *PharmacyDoctorDto { if m == nil { return nil } dto := &PharmacyDoctorDto{ DoctorPharmacyId: fmt.Sprintf("%d", m.DoctorPharmacyId), DoctorId: fmt.Sprintf("%d", m.DoctorId), IsDefault: m.IsDefault, Status: m.Status, BindTime: m.CreatedAt, } if m.UserDoctor != nil { dto.UserId = fmt.Sprintf("%d", m.UserDoctor.UserId) dto.UserName = m.UserDoctor.UserName dto.Avatar = m.UserDoctor.Avatar dto.DoctorTitle = m.UserDoctor.DoctorTitle dto.DoctorTitleName = doctorTitleMap[m.UserDoctor.DoctorTitle] dto.DepartmentCustomId = fmt.Sprintf("%d", m.UserDoctor.DepartmentCustomId) dto.DepartmentCustomName = m.UserDoctor.DepartmentCustomName dto.DepartmentCustomMobile = m.UserDoctor.DepartmentCustomMobile dto.HospitalId = fmt.Sprintf("%d", m.UserDoctor.HospitalID) if m.UserDoctor.Hospital != nil { dto.HospitalName = m.UserDoctor.Hospital.HospitalName } if m.UserDoctor.User != nil { dto.Mobile = m.UserDoctor.User.Mobile } } return dto } func GetPharmacyDoctorListDto(list []*model.DoctorPharmacy) []PharmacyDoctorDto { res := make([]PharmacyDoctorDto, len(list)) for i, v := range list { res[i] = *GetPharmacyDoctorDto(v) } return res }