处理 GORM 0 的bug
This commit is contained in:
@@ -3,6 +3,7 @@ package dto
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/global"
|
||||
)
|
||||
|
||||
type DoctorPharmacyDto struct {
|
||||
@@ -39,6 +40,12 @@ func GetDoctorPharmacyDto(m *model.DoctorPharmacy) *DoctorPharmacyDto {
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
if m.Pharmacy == nil {
|
||||
var ph model.Pharmacy
|
||||
if err := global.Db.Where("pharmacy_id = ?", m.PharmacyId).First(&ph).Error; err == nil {
|
||||
m.Pharmacy = &ph
|
||||
}
|
||||
}
|
||||
if m.Pharmacy != nil {
|
||||
dto.PharmacyName = m.Pharmacy.PharmacyName
|
||||
dto.PharmacyCode = m.Pharmacy.PharmacyCode
|
||||
|
||||
Reference in New Issue
Block a user