98 lines
3.3 KiB
Go
98 lines
3.3 KiB
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/model"
|
|
)
|
|
|
|
// DoctorConfigHealthPackageDto 医生配置-健康包
|
|
type DoctorConfigHealthPackageDto struct {
|
|
HealthPackageId string `json:"health_package_id"` // 主键id
|
|
DoctorId string `json:"doctor_id"` // 医生id
|
|
PackageId string `json:"package_id"` // 健康包配置id
|
|
ServicePrice float64 `json:"service_price"` // 服务价格(根据图文问诊价格计算)
|
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
|
HealthPackage *HealthPackageDto `json:"health_package"` // 健康包
|
|
UserDoctor *UserDoctorDto `json:"user_doctor"` // 医生数据
|
|
DoctorInquiryConfig *DoctorInquiryConfigDto `json:"doctor_inquiry_config"` // 医生问诊配置数据
|
|
}
|
|
|
|
func GetDoctorConfigHealthPackageDto(m *model.DoctorConfigHealthPackage) *DoctorConfigHealthPackageDto {
|
|
return &DoctorConfigHealthPackageDto{
|
|
HealthPackageId: fmt.Sprintf("%d", m.HealthPackageId),
|
|
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
|
PackageId: fmt.Sprintf("%d", m.PackageId),
|
|
ServicePrice: m.ServicePrice,
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func GetDoctorConfigHealthPackageListDto(m []*model.DoctorConfigHealthPackage) []*DoctorConfigHealthPackageDto {
|
|
// 处理返回值
|
|
responses := make([]*DoctorConfigHealthPackageDto, len(m))
|
|
|
|
if len(m) > 0 {
|
|
for i, v := range m {
|
|
response := &DoctorConfigHealthPackageDto{
|
|
HealthPackageId: fmt.Sprintf("%d", v.HealthPackageId),
|
|
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
|
PackageId: fmt.Sprintf("%d", v.PackageId),
|
|
ServicePrice: v.ServicePrice,
|
|
CreatedAt: v.CreatedAt,
|
|
UpdatedAt: v.UpdatedAt,
|
|
}
|
|
|
|
if v.HealthPackage != nil {
|
|
response.LoadHealthPackage(v.HealthPackage)
|
|
}
|
|
|
|
if v.UserDoctor != nil {
|
|
response.LoadUserDoctor(v.UserDoctor)
|
|
}
|
|
|
|
if v.UserDoctor.Hospital != nil {
|
|
response.LoadUserDoctorHospital(v.UserDoctor.Hospital)
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
responses[i] = response
|
|
}
|
|
}
|
|
|
|
return responses
|
|
}
|
|
|
|
// LoadHealthPackage 加载健康包
|
|
func (r *DoctorConfigHealthPackageDto) LoadHealthPackage(m *model.HealthPackage) *DoctorConfigHealthPackageDto {
|
|
if m != nil {
|
|
r.HealthPackage = GetHealthPackageDto(m)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// LoadUserDoctor 加载医生数据
|
|
func (r *DoctorConfigHealthPackageDto) LoadUserDoctor(m *model.UserDoctor) *DoctorConfigHealthPackageDto {
|
|
if m != nil {
|
|
r.UserDoctor = GetUserDoctorDto(m)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// LoadUserDoctorHospital 加载医生医院数据
|
|
func (r *DoctorConfigHealthPackageDto) LoadUserDoctorHospital(m *model.Hospital) *DoctorConfigHealthPackageDto {
|
|
if m != nil && r.UserDoctor != nil {
|
|
r.UserDoctor.Hospital = GetHospitalDto(m)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// LoadDoctorInquiryConfig 加载医生问诊配置
|
|
func (r *DoctorConfigHealthPackageDto) LoadDoctorInquiryConfig(m *model.DoctorInquiryConfig) *DoctorConfigHealthPackageDto {
|
|
if m != nil {
|
|
r.DoctorInquiryConfig = GetDoctorInquiryConfigDto(m)
|
|
}
|
|
return r
|
|
}
|