package dto import ( "fmt" "hospital-admin-api/api/model" ) type OrderPrescriptionIcdDto struct { PrescriptionIcdId string `json:"prescription_icd_id"` // 主键id OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id IcdId string `json:"icd_id"` // 疾病id(icd) IcdName string `json:"icd_name"` // 疾病名称(icd) IcdCode string `json:"icd_code"` // icd编码 CreatedAt model.LocalTime `json:"created_at"` // 创建时间 UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 } func GetOrderPrescriptionIcdDto(m *model.OrderPrescriptionIcd) *OrderPrescriptionIcdDto { return &OrderPrescriptionIcdDto{ PrescriptionIcdId: fmt.Sprintf("%d", m.PrescriptionIcdId), OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId), IcdId: fmt.Sprintf("%d", m.IcdId), IcdName: m.IcdName, IcdCode: m.IcdCode, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } } func GetOrderPrescriptionIcdListDto(m []*model.OrderPrescriptionIcd) []OrderPrescriptionIcdDto { // 处理返回值 responses := make([]OrderPrescriptionIcdDto, len(m)) if len(m) > 0 { for i, v := range m { response := OrderPrescriptionIcdDto{ PrescriptionIcdId: fmt.Sprintf("%d", v.PrescriptionIcdId), OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId), IcdId: fmt.Sprintf("%d", v.IcdId), IcdName: v.IcdName, IcdCode: v.IcdCode, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, } // 将转换后的结构体添加到新切片中 responses[i] = response } } return responses }