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,25 +139,39 @@ func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
CertExpireTime = model.LocalTime(time.Now().AddDate(0, 0, 365))
|
||||
}
|
||||
|
||||
// 新增ca监管证书表
|
||||
userCaCert = &model.UserCaCert{
|
||||
UserId: &userId,
|
||||
IsSystem: 0,
|
||||
IsLatest: 1,
|
||||
Type: 2,
|
||||
CertBase64: cloudCertResponse.CertBase64,
|
||||
CertChainP7: cloudCertResponse.CertP7,
|
||||
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
||||
CaPin: fmt.Sprintf("%d", userId),
|
||||
IsSignConfig: 0,
|
||||
SignConfig: "",
|
||||
CertApplicationTime: model.LocalTime(time.Now()),
|
||||
CertExpireTime: CertExpireTime, // 180天以后的时间
|
||||
}
|
||||
if userCaCert == nil {
|
||||
// 新增ca监管证书表
|
||||
userCaCert = &model.UserCaCert{
|
||||
UserId: &userId,
|
||||
IsSystem: 0,
|
||||
IsLatest: 1,
|
||||
Type: 2,
|
||||
CertBase64: cloudCertResponse.CertBase64,
|
||||
CertChainP7: cloudCertResponse.CertP7,
|
||||
CertSerialNumber: cloudCertResponse.CertSerialnumber,
|
||||
CaPin: fmt.Sprintf("%d", userId),
|
||||
IsSignConfig: 0,
|
||||
SignConfig: "",
|
||||
CertApplicationTime: model.LocalTime(time.Now()),
|
||||
CertExpireTime: CertExpireTime, // 180天以后的时间
|
||||
}
|
||||
|
||||
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
||||
if err != nil || userCaCert == nil {
|
||||
return false, errors.New(err.Error())
|
||||
userCaCert, err = userCaCertDao.AddUserCaCert(tx, userCaCert)
|
||||
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
|
||||
@ -153,18 +193,20 @@ func (r *UserCaCertService) AddHospitalCloudCert(tx *gorm.DB) (bool, error) {
|
||||
|
||||
// 申请云证书
|
||||
cloudCertRequestData := &ca.AddCloudCertRequest{
|
||||
EntityId: fmt.Sprintf("%d", userId),
|
||||
EntityType: "Organizational",
|
||||
PersonalPhone: "18221234167",
|
||||
OrgName: "成都金牛欣欣相照互联网医院有限公司",
|
||||
OrgNumber: "91510106MABTJY4K9R",
|
||||
Pin: fmt.Sprintf("%d", userId),
|
||||
Province: "四川省",
|
||||
Locality: "成都市",
|
||||
AuthType: "实人认证",
|
||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
AuthResult: "认证通过",
|
||||
AuthNoticeType: "数字证书申请告知",
|
||||
EntityId: fmt.Sprintf("%d", userId),
|
||||
EntityType: "Organizational",
|
||||
PersonalPhone: "18601047315",
|
||||
PersonalName: "张晓彦",
|
||||
PersonalIdNumber: "132527197709270017",
|
||||
OrgName: "成都金牛欣欣相照互联网医院有限公司",
|
||||
OrgNumber: "91510106MABTJY4K9R",
|
||||
Pin: fmt.Sprintf("%d", userId),
|
||||
Province: "四川省",
|
||||
Locality: "成都市",
|
||||
AuthType: "实人认证",
|
||||
AuthTime: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
AuthResult: "认证通过",
|
||||
AuthNoticeType: "数字证书申请告知",
|
||||
}
|
||||
|
||||
cloudCertResponse, err := ca.AddCloudCert(cloudCertRequestData)
|
||||
@ -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