Compare commits
2 Commits
fce37aaa1b
...
19afa0fc7c
| Author | SHA1 | Date | |
|---|---|---|---|
| 19afa0fc7c | |||
| 16e97df4f9 |
@ -33,7 +33,15 @@ func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
maps["type"] = 2
|
||||
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||
if userCaCert != nil {
|
||||
return false, errors.New("医生存在正常使用的云证书,请注销后重新申请")
|
||||
if time.Time(userCaCert.CertExpireTime).IsZero() {
|
||||
return false, errors.New("云证书过期时间错误")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
certExpireTime := time.Time(userCaCert.CertExpireTime)
|
||||
if now.Before(certExpireTime) {
|
||||
return false, errors.New("云证书还未过期")
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
@ -67,6 +75,24 @@ func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
departmentCustomId = userDoctor.DepartmentCustomId // 自定义科室id
|
||||
cardName = userDoctorInfo.CardName // 身份证名称
|
||||
cardNum = userDoctorInfo.CardNum // 身份证号码
|
||||
} else {
|
||||
// 获取药师数据
|
||||
userPharmacistDao := dao.UserPharmacistDao{}
|
||||
userPharmacist, err := userPharmacistDao.GetUserPharmacistByUserId(userId)
|
||||
if err != nil || userPharmacist == nil {
|
||||
return false, errors.New("药师数据错误")
|
||||
}
|
||||
|
||||
// 获取药师详情数据
|
||||
userPharmacistInfoDao := dao.UserPharmacistInfoDao{}
|
||||
userPharmacistInfo, err := userPharmacistInfoDao.GetUserPharmacistInfoByUserId(userId)
|
||||
if err != nil || userPharmacistInfo == nil {
|
||||
return false, errors.New("药师详情数据错误")
|
||||
}
|
||||
|
||||
departmentCustomId = userPharmacist.DepartmentCustomId // 自定义科室id
|
||||
cardName = userPharmacistInfo.CardName // 身份证名称
|
||||
cardNum = userPharmacistInfo.CardNum // 身份证号码
|
||||
}
|
||||
|
||||
// 获取自定义科室数据
|
||||
@ -113,6 +139,7 @@ func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
CertExpireTime = model.LocalTime(time.Now().AddDate(0, 0, 365))
|
||||
}
|
||||
|
||||
if userCaCert == nil {
|
||||
// 新增ca监管证书表
|
||||
userCaCert = &model.UserCaCert{
|
||||
UserId: &userId,
|
||||
@ -133,6 +160,19 @@ func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
if err != nil || userCaCert == nil {
|
||||
return false, errors.New(err.Error())
|
||||
}
|
||||
} else {
|
||||
// 修改ca监管证书表
|
||||
data := make(map[string]interface{})
|
||||
data["cert_base64"] = cloudCertResponse.CertBase64
|
||||
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
||||
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
||||
data["cert_application_time"] = model.LocalTime(time.Now())
|
||||
data["cert_expire_time"] = CertExpireTime
|
||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||
if err != nil {
|
||||
return false, errors.New("审核失败")
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@ -155,7 +195,9 @@ func (r *UserCaCertService) AddHospitalCloudCert(tx *gorm.DB) (bool, error) {
|
||||
cloudCertRequestData := &ca.AddCloudCertRequest{
|
||||
EntityId: fmt.Sprintf("%d", userId),
|
||||
EntityType: "Organizational",
|
||||
PersonalPhone: "18221234167",
|
||||
PersonalPhone: "18601047315",
|
||||
PersonalName: "张晓彦",
|
||||
PersonalIdNumber: "132527197709270017",
|
||||
OrgName: "成都金牛欣欣相照互联网医院有限公司",
|
||||
OrgNumber: "91510106MABTJY4K9R",
|
||||
Pin: fmt.Sprintf("%d", userId),
|
||||
@ -300,6 +342,7 @@ func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool,
|
||||
data["cert_base64"] = cloudCertResponse.CertBase64
|
||||
data["cert_chain_p7"] = cloudCertResponse.CertP7
|
||||
data["cert_serial_number"] = cloudCertResponse.CertSerialnumber
|
||||
|
||||
err = userCaCertDao.EditUserCaCertById(tx, userCaCert.CertId, data)
|
||||
if err != nil {
|
||||
return false, errors.New("审核失败")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user