package dto import ( "fmt" "hospital-admin-api/api/model" ) type DiseaseClassExpertiseDto struct { ExpertiseId string `json:"expertise_id"` // 主键 ExpertiseName string `json:"expertise_name"` // 专长名称 ExpertiseSort int `json:"expertise_sort"` // 排序(越大排序越靠前) CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } func GetDiseaseClassExpertiseDto(m *model.DiseaseClassExpertise) *DiseaseClassExpertiseDto { return &DiseaseClassExpertiseDto{ ExpertiseId: fmt.Sprintf("%d", m.ExpertiseId), ExpertiseName: m.ExpertiseName, ExpertiseSort: m.ExpertiseSort, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } } func GetDiseaseClassExpertiseListDto(m []*model.DiseaseClassExpertise) []DiseaseClassExpertiseDto { // 处理返回值 responses := make([]DiseaseClassExpertiseDto, len(m)) if len(m) > 0 { for i, v := range m { response := DiseaseClassExpertiseDto{ ExpertiseId: fmt.Sprintf("%d", v.ExpertiseId), ExpertiseName: v.ExpertiseName, ExpertiseSort: v.ExpertiseSort, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, } // 将转换后的结构体添加到新切片中 responses[i] = response } } return responses }