49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/dao"
|
|
"hospital-admin-api/api/responses/patientFamilyResponse"
|
|
)
|
|
|
|
type PatientFamilyService struct {
|
|
}
|
|
|
|
// GetPatientFamilyListByPatientId 获取患者家庭成员-患者id
|
|
func (r *PatientFamilyService) GetPatientFamilyListByPatientId(patientId int64) (u []*patientFamilyResponse.GetUserPatient, err error) {
|
|
patientFamilyDao := dao.PatientFamilyDao{}
|
|
patientFamilys, err := patientFamilyDao.GetPatientFamilyListByPatientId(patientId)
|
|
|
|
if len(patientFamilys) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
// 处理返回值
|
|
items := make([]*patientFamilyResponse.GetUserPatient, len(patientFamilys))
|
|
|
|
if len(patientFamilys) > 0 {
|
|
for i, v := range patientFamilys {
|
|
// 将原始结构体转换为新结构体
|
|
item := &patientFamilyResponse.GetUserPatient{
|
|
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
|
PatientId: fmt.Sprintf("%d", v.PatientId),
|
|
Relation: &v.Relation,
|
|
Status: &v.Status,
|
|
IsDefault: &v.IsDefault,
|
|
CardNameMask: v.CardNameMask,
|
|
MobileMask: v.MobileMask,
|
|
IdNumberMask: v.IdNumberMask,
|
|
Sex: &v.Sex,
|
|
Age: v.Age,
|
|
CreatedAt: v.CreatedAt,
|
|
UpdatedAt: v.UpdatedAt,
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
items[i] = item
|
|
}
|
|
}
|
|
|
|
return items, nil
|
|
}
|