package dto import ( "fmt" "hospital-admin-api/api/model" ) type DoctorPharmacyDto struct { DoctorPharmacyId string `json:"doctor_pharmacy_id"` // 绑定关系id DoctorId string `json:"doctor_id"` // 医生id PharmacyId string `json:"pharmacy_id"` // 药房id PharmacyName string `json:"pharmacy_name"` // 药房名称 PharmacyCode string `json:"pharmacy_code"` // 药房代码 Postage float64 `json:"postage"` // 基础邮费 FreeShippingThreshold float64 `json:"free_shipping_threshold"` // 满XX包邮门槛金额 IsPickup int `json:"is_pickup"` // 是否支持自提(0:否 1:是) Telephone string `json:"telephone"` // 电话 Province string `json:"province"` // 省份 City string `json:"city"` // 城市 County string `json:"county"` // 区县 Address string `json:"address"` // 详细地址 FullAddress string `json:"full_address"` // 完整地址 IsDefault int `json:"is_default"` // 是否默认药房(0:否 1:是) Status int `json:"status"` // 状态(0:禁用 1:正常) CreatedAt model.LocalTime `json:"created_at"` // 绑定时间 UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间 } func GetDoctorPharmacyDto(m *model.DoctorPharmacy) *DoctorPharmacyDto { if m == nil { return nil } dto := &DoctorPharmacyDto{ DoctorPharmacyId: fmt.Sprintf("%d", m.DoctorPharmacyId), DoctorId: fmt.Sprintf("%d", m.DoctorId), PharmacyId: fmt.Sprintf("%d", m.PharmacyId), IsDefault: m.IsDefault, Status: m.Status, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt, } if m.Pharmacy != nil { dto.PharmacyName = m.Pharmacy.PharmacyName dto.PharmacyCode = m.Pharmacy.PharmacyCode dto.Postage = m.Pharmacy.Postage dto.FreeShippingThreshold = m.Pharmacy.FreeShippingThreshold dto.IsPickup = m.Pharmacy.IsPickup dto.Telephone = m.Pharmacy.Telephone dto.Province = m.Pharmacy.Province dto.City = m.Pharmacy.City dto.County = m.Pharmacy.County dto.Address = m.Pharmacy.Address dto.FullAddress = fmt.Sprintf("%s%s%s%s", m.Pharmacy.Province, m.Pharmacy.City, m.Pharmacy.County, m.Pharmacy.Address) } return dto } func GetDoctorPharmacyListDto(list []*model.DoctorPharmacy) []*DoctorPharmacyDto { res := make([]*DoctorPharmacyDto, len(list)) for i, v := range list { res[i] = GetDoctorPharmacyDto(v) } return res }