新增身份证解密

This commit is contained in:
2023-07-11 15:19:38 +08:00
parent cdbaed5755
commit 4465131099
7 changed files with 221 additions and 2 deletions
+42
View File
@@ -394,3 +394,45 @@ func (r *UserService) PutUserPassword(requestUserId int64, putUserPasswordReques
return true, nil
}
// GetUserCardNum 获取用户身份证号
func (r *UserService) GetUserCardNum(userId, familyId int64) (string, error) {
var cardNum string
// 获取用户数据
userDao := dao.UserDao{}
user, err := userDao.GetUserById(userId)
if err != nil || user == nil {
return "", errors.New("用户错误")
}
// 判断用户类型
if user.UserType == 1 {
// 患者
if familyId == 0 {
return "", errors.New("获取失败")
}
patientFamilyDao := dao.PatientFamilyDao{}
patientFamily, err := patientFamilyDao.GetPatientFamilyById(familyId)
if err != nil || patientFamily == nil {
return "", errors.New("获取失败")
}
cardNum = patientFamily.IdNumber
} else if user.UserType == 2 {
// 医生
userDoctorInfoDao := dao.UserDoctorInfoDao{}
userDoctorInfo, err := userDoctorInfoDao.GetUserDoctorInfoByUserId(userId)
if err != nil || userDoctorInfo == nil {
return "", errors.New("获取失败")
}
cardNum = userDoctorInfo.CardNum
} else if user.UserType == 3 {
// 药师
cardNum = "暂时未做"
}
return cardNum, nil
}