This commit is contained in:
haomingming
2026-09-07 16:44:34 +08:00
parent 3205005b9a
commit b74a8aa898
3 changed files with 8 additions and 8 deletions
+5 -5
View File
@@ -32,7 +32,7 @@ func (r *DoctorPharmacyService) BindDoctorPharmacies(doctorId int64, req request
}
pharmacyDao := dao.PharmacyDao{}
var defaultPharmacyId int64
var defaultPharmacyId int64 = -1
if req.DefaultPharmacyId != "" {
defaultPharmacyId, _ = strconv.ParseInt(req.DefaultPharmacyId, 10, 64)
}
@@ -56,7 +56,7 @@ func (r *DoctorPharmacyService) BindDoctorPharmacies(doctorId int64, req request
// 遍历新增绑定
for i, v := range req.PharmacyIds {
pharmacyId, err := strconv.ParseInt(v, 10, 64)
if err != nil || pharmacyId == 0 {
if err != nil || pharmacyId < 0 {
continue
}
@@ -68,9 +68,9 @@ func (r *DoctorPharmacyService) BindDoctorPharmacies(doctorId int64, req request
}
isDefault := 0
if defaultPharmacyId != 0 && pharmacyId == defaultPharmacyId {
if defaultPharmacyId >= 0 && pharmacyId == defaultPharmacyId {
isDefault = 1
} else if defaultPharmacyId == 0 && i == 0 {
} else if defaultPharmacyId < 0 && i == 0 {
// 未指定默认药房时,默认第1个为默认药房
isDefault = 1
}
@@ -103,7 +103,7 @@ func (r *DoctorPharmacyService) AddDoctorPharmacy(doctorId int64, req requests.A
}
pharmacyId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
if err != nil || pharmacyId == 0 {
if err != nil || pharmacyId < 0 {
return false, errors.New("药房id无效")
}