处理 GORM 0 的bug

This commit is contained in:
haomingming
2026-09-08 10:55:15 +08:00
parent b74a8aa898
commit 86f3cc2fbc
11 changed files with 192 additions and 9 deletions
+7
View File
@@ -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