From 5e70c638c62f0a67e824c41a105ca711ab881006 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Fri, 27 Oct 2023 14:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=BB=E7=94=9F=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/dao/userCaCert.go | 18 ++++++++-------- api/dto/UserCaCert.go | 45 +++++++++++++++++++++++++++++++++++++++ api/dto/UserDoctor.go | 9 ++++++++ api/service/UserCaCert.go | 14 ++++++------ api/service/userDoctor.go | 16 +++++++++++--- 5 files changed, 83 insertions(+), 19 deletions(-) create mode 100644 api/dto/UserCaCert.go diff --git a/api/dao/userCaCert.go b/api/dao/userCaCert.go index adb7dc8..0267c5f 100644 --- a/api/dao/userCaCert.go +++ b/api/dao/userCaCert.go @@ -6,11 +6,11 @@ import ( "hospital-admin-api/global" ) -type UserCaCert struct { +type UserCaCertDao struct { } // GetUserCaCertById 获取监管证书数据-监管证书id -func (r *UserCaCert) GetUserCaCertById(certId int64) (m *model.UserCaCert, err error) { +func (r *UserCaCertDao) GetUserCaCertById(certId int64) (m *model.UserCaCert, err error) { err = global.Db.First(&m, certId).Error if err != nil { return nil, err @@ -19,7 +19,7 @@ func (r *UserCaCert) GetUserCaCertById(certId int64) (m *model.UserCaCert, err e } // GetUserCaCertByUserId 获取监管证书数据-监管证书id -func (r *UserCaCert) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, err error) { +func (r *UserCaCertDao) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, err error) { err = global.Db.Where("user_id = ?", userId).First(&m).Error if err != nil { return nil, err @@ -28,7 +28,7 @@ func (r *UserCaCert) GetUserCaCertByUserId(userId int64) (m *model.UserCaCert, e } // GetUserCaCertListByUserId 获取监管证书数据-监管证书id -func (r *UserCaCert) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaCert, err error) { +func (r *UserCaCertDao) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaCert, err error) { err = global.Db.Where("user_id = ?", userId).Find(&m).Error if err != nil { return nil, err @@ -37,7 +37,7 @@ func (r *UserCaCert) GetUserCaCertListByUserId(userId int64) (m []*model.UserCaC } // AddUserCaCert 新增监管证书 -func (r *UserCaCert) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model.UserCaCert, error) { +func (r *UserCaCertDao) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model.UserCaCert, error) { if err := tx.Create(model).Error; err != nil { return nil, err } @@ -45,7 +45,7 @@ func (r *UserCaCert) AddUserCaCert(tx *gorm.DB, model *model.UserCaCert) (*model } // GetUserCaCertList 获取监管证书列表 -func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, err error) { +func (r *UserCaCertDao) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, err error) { err = global.Db.Where(maps).Find(&m).Error if err != nil { return nil, err @@ -54,7 +54,7 @@ func (r *UserCaCert) GetUserCaCertList(maps interface{}) (m []*model.UserCaCert, } // GetUserCaCert 获取监管证书 -func (r *UserCaCert) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err error) { +func (r *UserCaCertDao) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err error) { err = global.Db.Where(maps).First(&m).Error if err != nil { return nil, err @@ -63,7 +63,7 @@ func (r *UserCaCert) GetUserCaCert(maps interface{}) (m *model.UserCaCert, err e } // DeleteUserCaCertById 删除监管证书-监管证书id -func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error { +func (r *UserCaCertDao) DeleteUserCaCertById(tx *gorm.DB, certId int64) error { if err := tx.Delete(&model.UserCaCert{}, certId).Error; err != nil { return err } @@ -71,7 +71,7 @@ func (r *UserCaCert) DeleteUserCaCertById(tx *gorm.DB, certId int64) error { } // EditUserCaCertById 修改监管证书-监管证书id -func (r *UserCaCert) EditUserCaCertById(tx *gorm.DB, certId int64, data interface{}) error { +func (r *UserCaCertDao) EditUserCaCertById(tx *gorm.DB, certId int64, data interface{}) error { err := tx.Model(&model.UserCaCert{}).Where("cert_id = ?", certId).Updates(data).Error if err != nil { return err diff --git a/api/dto/UserCaCert.go b/api/dto/UserCaCert.go new file mode 100644 index 0000000..5ac83ed --- /dev/null +++ b/api/dto/UserCaCert.go @@ -0,0 +1,45 @@ +package dto + +import ( + "fmt" + "hospital-admin-api/api/model" +) + +type UserCaCertDto struct { + CertId string `json:"cert_id"` // 主键id + UserId *string `json:"user_id"` // 用户id(系统证书时为null) + IsSystem int `json:"is_system"` // 是否系统证书(0:否 1:是) + IsLatest int `json:"is_latest"` // 是否最新(0:否 1:是) + Type int `json:"type"` // 证书类型(1:线下 2:线上) + CertBase64 string `json:"cert_base64"` // 签名值证书 + CertChainP7 string `json:"cert_chain_p7"` // 证书链 + CertSerialNumber string `json:"cert_serial_number"` // 证书序列号 + CaPin string `json:"ca_pin"` // ca认证pin值 + IsSignConfig int `json:"is_sign_config"` // 是否已添加签章配置(第一次需申请) + SignConfig string `json:"sign_config"` // 签章坐标配置 + CertApplicationTime model.LocalTime `json:"cert_application_time"` // 证书申请时间 + CertExpireTime model.LocalTime `json:"cert_expire_time"` // 证书过期时间 + CreatedAt model.LocalTime `json:"created_at"` // 创建时间 + UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间 +} + +func GetUserCaCertDto(m *model.UserCaCert) *UserCaCertDto { + userId := fmt.Sprintf("%d", &m.UserId) + return &UserCaCertDto{ + CertId: fmt.Sprintf("%d", m.CertId), + UserId: &userId, + IsSystem: m.IsSystem, + IsLatest: m.IsSystem, + Type: m.IsSystem, + CertBase64: m.CertBase64, + CertChainP7: m.CertChainP7, + CertSerialNumber: m.CertSerialNumber, + CaPin: m.CaPin, + IsSignConfig: m.IsSignConfig, + SignConfig: m.SignConfig, + CertApplicationTime: m.CertApplicationTime, + CertExpireTime: m.CertExpireTime, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + } +} diff --git a/api/dto/UserDoctor.go b/api/dto/UserDoctor.go index 5318875..27f7b9d 100644 --- a/api/dto/UserDoctor.go +++ b/api/dto/UserDoctor.go @@ -54,6 +54,7 @@ type UserDoctorDto struct { DoctorExpertise []*DoctorExpertiseDto `json:"doctor_expertise"` // 医生专长 DoctorBankCard *DoctorBankCardDto `json:"doctor_bank_card"` // 医生银行卡 InquiryType string `json:"inquiry_type"` // 服务类型 + UserCaCert *UserCaCertDto `json:"user_ca_cert"` // ca监管证书 } type UserDoctorPendingDto struct { @@ -359,6 +360,14 @@ func (r *UserDoctorDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorD return r } +// LoadUserCaCert 加载医生云证书详情 +func (r *UserDoctorDto) LoadUserCaCert(m *model.UserCaCert) *UserDoctorDto { + if m != nil { + r.UserCaCert = GetUserCaCertDto(m) + } + return r +} + // LoadUserDoctorInfo 加载医生详情 func (r *UserDoctorPendingDto) LoadUserDoctorInfo(m *model.UserDoctorInfo) *UserDoctorPendingDto { if m != nil { diff --git a/api/service/UserCaCert.go b/api/service/UserCaCert.go index f8fb732..e9bd231 100644 --- a/api/service/UserCaCert.go +++ b/api/service/UserCaCert.go @@ -21,7 +21,7 @@ type UserCaCertService struct { // GetUserCloudCert 申请云证书-个人 func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, error) { - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -138,7 +138,7 @@ func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, e // GetHospitalCloudCert 申请云证书-医院 func (r *UserCaCertService) GetHospitalCloudCert(tx *gorm.DB) (bool, error) { var userId int64 = 5345345461 - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -196,7 +196,7 @@ func (r *UserCaCertService) GetHospitalCloudCert(tx *gorm.DB) (bool, error) { // EditUserCloudCert 修改云证书-个人 func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool, error) { - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -320,7 +320,7 @@ func (r *UserCaCertService) EditUserCloudCert(tx *gorm.DB, userId int64) (bool, // RenewUserCloudCert 更新云证书-个人-续约 func (r *UserCaCertService) RenewUserCloudCert(tx *gorm.DB, userId int64) (bool, error) { - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -407,7 +407,7 @@ func (r *UserCaCertService) RenewUserCloudCert(tx *gorm.DB, userId int64) (bool, func (r *UserCaCertService) RenewHospitalCloudCert(tx *gorm.DB) (bool, error) { var userId int64 = 5345345461 - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -460,7 +460,7 @@ func (r *UserCaCertService) RenewHospitalCloudCert(tx *gorm.DB) (bool, error) { // RemoveUserCloudCert 注销云证书-个人 func (r *UserCaCertService) RemoveUserCloudCert(tx *gorm.DB, userId int64) (bool, error) { - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} // 检测是否存在云证书 maps := make(map[string]interface{}) @@ -529,7 +529,7 @@ func (r *UserCaCertService) RemoveUserCloudCert(tx *gorm.DB, userId int64) (bool // AddUserSignConfig 添加用户签章配置 func (r *UserCaCertService) AddUserSignConfig(tx *gorm.DB, req requests.AddUserSignConfig) (bool, error) { - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} var entityId string // 唯一标识 var cardNum string // 身份证号/信用代码 diff --git a/api/service/userDoctor.go b/api/service/userDoctor.go index 311a511..53a3f64 100644 --- a/api/service/userDoctor.go +++ b/api/service/userDoctor.go @@ -38,6 +38,13 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse doctorBankCardDao := dao.DoctorBankCardDao{} doctorBankCard, err := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId) + // 获取医生云证书数据 + userCaCertDao := dao.UserCaCertDao{} + maps := make(map[string]interface{}) + maps["user_id"] = userDoctor.UserId + maps["type"] = 2 + userCaCert, _ := userCaCertDao.GetUserCaCert(maps) + // 处理返回值 getUserDoctorResponse = dto.GetUserDoctorDto(userDoctor) @@ -56,6 +63,9 @@ func (r *UserDoctorService) GetUserDoctor(doctorId int64) (getUserDoctorResponse // 加载医生详情 getUserDoctorResponse.LoadUserDoctorInfo(userDoctor.UserDoctorInfo) + // 加载医生云证书详情 + getUserDoctorResponse.LoadUserCaCert(userCaCert) + return getUserDoctorResponse, nil } @@ -91,7 +101,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo doctorBankCard, _ := doctorBankCardDao.GetDoctorBankCardByDoctorId(doctorId) // 获取医生云证书 - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} maps := make(map[string]interface{}) maps["user_id"] = userDoctor.UserId @@ -661,7 +671,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo signImage := utils.RemoveOssDomain(req.SignImage) if signImage != userDoctorInfo.SignImage { // 检测是否存在云证书 - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} userCaCerts, err := userCaCertDao.GetUserCaCertListByUserId(userDoctor.UserId) if err != nil { tx.Rollback() @@ -1439,7 +1449,7 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo userCaCertService := UserCaCertService{} // 检测是否存在云证书 - userCaCertDao := dao.UserCaCert{} + userCaCertDao := dao.UserCaCertDao{} maps := make(map[string]interface{}) maps["user_id"] = userDoctor.UserId