package dto import ( "fmt" "hospital-admin-api/api/model" ) type DoctorExpertiseDto struct { DoctorId string `json:"doctor_id"` // 医生id ExpertiseId string `json:"expertise_id"` // 专长id ExpertiseName string `json:"expertise_name"` // 专长名称 } func GetDoctorExpertiseDto(m *model.DoctorExpertise) *DoctorExpertiseDto { return &DoctorExpertiseDto{ DoctorId: fmt.Sprintf("%d", m.DoctorId), ExpertiseId: fmt.Sprintf("%d", m.ExpertiseId), } } func GetDoctorExpertiseListDto(m []*model.DoctorExpertise) []DoctorExpertiseDto { // 处理返回值 responses := make([]DoctorExpertiseDto, len(m)) if len(m) > 0 { for i, v := range m { response := DoctorExpertiseDto{ DoctorId: fmt.Sprintf("%d", v.DoctorId), ExpertiseId: fmt.Sprintf("%d", v.ExpertiseId), } // 将转换后的结构体添加到新切片中 responses[i] = response } } return responses } // LoadExpertiseName 加载专长名称 func (r *DoctorExpertiseDto) LoadExpertiseName(m *model.DiseaseClassExpertise) *DoctorExpertiseDto { if m != nil { r.ExpertiseName = m.ExpertiseName } return r }