根据药房查询医生列表

This commit is contained in:
haomingming
2026-09-07 15:21:06 +08:00
parent 0cff5b3f8d
commit 338d56beda
7 changed files with 260 additions and 6 deletions
+54
View File
@@ -9,6 +9,7 @@ import (
"hospital-admin-api/api/model"
"hospital-admin-api/api/requests"
"hospital-admin-api/global"
"strconv"
)
type PharmacyService struct{}
@@ -259,3 +260,56 @@ func (r *PharmacyService) GetPharmacy(pharmacyId int64) (*dto.PharmacyDto, error
return dto.GetPharmacyDto(pharmacy), nil
}
// GetPharmacyDoctorPage 获取药房绑定的医生列表-分页
func (r *PharmacyService) GetPharmacyDoctorPage(req requests.GetPharmacyDoctorPage) (map[string]interface{}, error) {
pharmacyId, err := strconv.ParseInt(req.PharmacyId, 10, 64)
if err != nil || pharmacyId == 0 {
return nil, errors.New("药房id无效")
}
pharmacyDao := dao.PharmacyDao{}
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
if err != nil || pharmacy == nil {
return nil, errors.New("药房不存在或已被删除")
}
if req.Page <= 0 {
req.Page = 1
}
if req.PageSize <= 0 {
req.PageSize = 20
}
doctorPharmacyDao := dao.DoctorPharmacyDao{}
list, total, err := doctorPharmacyDao.GetPharmacyDoctorPageSearch(pharmacyId, req, req.Page, req.PageSize)
if err != nil {
return nil, err
}
resList := dto.GetPharmacyDoctorListDto(list)
result := make(map[string]interface{})
result["page"] = req.Page
result["page_size"] = req.PageSize
result["total"] = total
result["data"] = resList
return result, nil
}
// GetPharmacyDoctorList 获取药房绑定的全部医生列表
func (r *PharmacyService) GetPharmacyDoctorList(pharmacyId int64) ([]dto.PharmacyDoctorDto, error) {
pharmacyDao := dao.PharmacyDao{}
pharmacy, err := pharmacyDao.GetPharmacyById(pharmacyId)
if err != nil || pharmacy == nil {
return nil, errors.New("药房不存在或已被删除")
}
doctorPharmacyDao := dao.DoctorPharmacyDao{}
list, err := doctorPharmacyDao.GetPharmacyDoctorListByPharmacyId(pharmacyId)
if err != nil {
return nil, err
}
return dto.GetPharmacyDoctorListDto(list), nil
}