This commit is contained in:
haomingming
2026-09-17 09:18:24 +08:00
parent 5d4fcf993e
commit bb3dcd4e1d
2 changed files with 18 additions and 4 deletions
+14
View File
@@ -173,6 +173,20 @@ func (r *DoctorPharmacyDao) GetPharmacyDoctorListByPharmacyId(pharmacyId int64)
return m, nil return m, nil
} }
// GetDefaultPharmacyDoctorListByPharmacyId 获取将该药房设为默认药房的医生列表
func (r *DoctorPharmacyDao) GetDefaultPharmacyDoctorListByPharmacyId(pharmacyId int64) (m []*model.DoctorPharmacy, err error) {
err = global.Db.Preload("UserDoctor").
Preload("UserDoctor.User").
Preload("UserDoctor.Hospital").
Where("pharmacy_id = ? AND status = 1 AND is_default = 1", pharmacyId).
Order("created_at desc").
Find(&m).Error
if err != nil {
return nil, err
}
return m, nil
}
// GetDoctorPharmacyCountsByPharmacyId 获取药房绑定的医生数量(有效绑定数、设为默认药房数) // GetDoctorPharmacyCountsByPharmacyId 获取药房绑定的医生数量(有效绑定数、设为默认药房数)
func (r *DoctorPharmacyDao) GetDoctorPharmacyCountsByPharmacyId(pharmacyId int64) (totalCount int64, defaultCount int64, err error) { func (r *DoctorPharmacyDao) GetDoctorPharmacyCountsByPharmacyId(pharmacyId int64) (totalCount int64, defaultCount int64, err error) {
err = global.Db.Model(&model.DoctorPharmacy{}). err = global.Db.Model(&model.DoctorPharmacy{}).
+4 -4
View File
@@ -365,10 +365,10 @@ func (r *PharmacyService) GetAffectedDoctors(pharmacyId int64) (*dto.PharmacyAff
return nil, errors.New("查询药房关联医生数量失败") return nil, errors.New("查询药房关联医生数量失败")
} }
// 获取当前药房绑定的所有医生 // 获取将当前药房设为默认药房的受影响医生列表(仅默认药房受影响的医生需要重新指定默认药房)
list, err := doctorPharmacyDao.GetPharmacyDoctorListByPharmacyId(pharmacyId) list, err := doctorPharmacyDao.GetDefaultPharmacyDoctorListByPharmacyId(pharmacyId)
if err != nil { if err != nil {
return nil, errors.New("查询药房关联医生列表失败") return nil, errors.New("查询受影响医生列表失败")
} }
// 收集所有医生ID // 收集所有医生ID
@@ -383,7 +383,7 @@ func (r *PharmacyService) GetAffectedDoctors(pharmacyId int64) (*dto.PharmacyAff
otherList, err := doctorPharmacyDao.GetOtherPharmaciesByDoctorIds(doctorIds, pharmacyId) otherList, err := doctorPharmacyDao.GetOtherPharmaciesByDoctorIds(doctorIds, pharmacyId)
if err == nil { if err == nil {
for _, dp := range otherList { for _, dp := range otherList {
if dp.Pharmacy != nil { if dp.Pharmacy != nil && dp.Pharmacy.Status == 1 {
otherMap[dp.DoctorId] = append(otherMap[dp.DoctorId], dto.BoundPharmacySimpleDto{ otherMap[dp.DoctorId] = append(otherMap[dp.DoctorId], dto.BoundPharmacySimpleDto{
PharmacyId: strconv.FormatInt(dp.Pharmacy.PharmacyId, 10), PharmacyId: strconv.FormatInt(dp.Pharmacy.PharmacyId, 10),
PharmacyName: dp.Pharmacy.PharmacyName, PharmacyName: dp.Pharmacy.PharmacyName,