1
This commit is contained in:
parent
5e70c638c6
commit
38f0ed6bc7
@ -12,8 +12,8 @@ import (
|
||||
|
||||
type UserCaCert struct{}
|
||||
|
||||
// GetUserCloudCert 申请云证书-个人
|
||||
func (r *UserCaCert) GetUserCloudCert(c *gin.Context) {
|
||||
// AddUserCloudCert 申请云证书-个人
|
||||
func (r *UserCaCert) AddUserCloudCert(c *gin.Context) {
|
||||
id := c.Param("user_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
@ -36,7 +36,7 @@ func (r *UserCaCert) GetUserCloudCert(c *gin.Context) {
|
||||
}()
|
||||
|
||||
userCaCertService := service.UserCaCertService{}
|
||||
_, err = userCaCertService.GetUserCloudCert(tx, userId)
|
||||
_, err = userCaCertService.AddUserCloudCert(tx, userId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -47,8 +47,8 @@ func (r *UserCaCert) GetUserCloudCert(c *gin.Context) {
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetHospitalCloudCert 申请云证书-医院
|
||||
func (r *UserCaCert) GetHospitalCloudCert(c *gin.Context) {
|
||||
// AddHospitalCloudCert 申请云证书-医院
|
||||
func (r *UserCaCert) AddHospitalCloudCert(c *gin.Context) {
|
||||
// 业务处理
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@ -58,7 +58,7 @@ func (r *UserCaCert) GetHospitalCloudCert(c *gin.Context) {
|
||||
}()
|
||||
|
||||
userCaCertService := service.UserCaCertService{}
|
||||
_, err := userCaCertService.GetHospitalCloudCert(tx)
|
||||
_, err := userCaCertService.AddHospitalCloudCert(tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -195,3 +195,15 @@ func (r *UserCaCert) AddUserSignConfig(c *gin.Context) {
|
||||
tx.Commit()
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetHospitalCloudCert 获取医院云证书数据
|
||||
func (r *UserCaCert) GetHospitalCloudCert(c *gin.Context) {
|
||||
userCaCertService := service.UserCaCertService{}
|
||||
userCaCert, err := userCaCertService.GetHospitalCloudCert()
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(userCaCert, c)
|
||||
}
|
||||
|
||||
@ -554,17 +554,20 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
userGroup.PUT("/remove/:user_id", api.UserCaCert.RemoveUserCloudCert)
|
||||
|
||||
// 申请云证书-个人
|
||||
userGroup.POST("/:user_id", api.UserCaCert.GetUserCloudCert)
|
||||
userGroup.POST("/:user_id", api.UserCaCert.AddUserCloudCert)
|
||||
}
|
||||
|
||||
// 医院
|
||||
hospitalGroup := certGroup.Group("/hospital")
|
||||
{
|
||||
// 获取医院云证书数据
|
||||
hospitalGroup.GET("", api.UserCaCert.GetHospitalCloudCert)
|
||||
|
||||
// 更新云证书-医院-续约
|
||||
hospitalGroup.GET("/renew", api.UserCaCert.RenewHospitalCloudCert)
|
||||
hospitalGroup.PUT("/renew", api.UserCaCert.RenewHospitalCloudCert)
|
||||
|
||||
// 申请云证书-医院
|
||||
hospitalGroup.POST("", api.UserCaCert.GetHospitalCloudCert)
|
||||
hospitalGroup.POST("", api.UserCaCert.AddHospitalCloudCert)
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,6 +577,5 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 添加签章配置
|
||||
signGroup.POST("", api.UserCaCert.AddUserSignConfig)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/dto"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/extend/aliyun"
|
||||
@ -19,8 +20,8 @@ import (
|
||||
type UserCaCertService struct {
|
||||
}
|
||||
|
||||
// GetUserCloudCert 申请云证书-个人
|
||||
func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
|
||||
// AddUserCloudCert 申请云证书-个人
|
||||
func (r *UserCaCertService) AddUserCloudCert(tx *gorm.DB, userId int64) (bool, error) {
|
||||
userCaCertDao := dao.UserCaCertDao{}
|
||||
|
||||
// 检测是否存在云证书
|
||||
@ -64,10 +65,6 @@ func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
return false, errors.New("请先通过身份认证")
|
||||
}
|
||||
|
||||
if userDoctor.MultiPointStatus != 1 {
|
||||
return false, errors.New("请先完成多点执业认证")
|
||||
}
|
||||
|
||||
departmentCustomId = userDoctor.DepartmentCustomId // 自定义科室id
|
||||
cardName = userDoctorInfo.CardName // 身份证名称
|
||||
cardNum = userDoctorInfo.CardNum // 身份证号码
|
||||
@ -135,8 +132,8 @@ func (r *UserCaCertService) GetUserCloudCert(tx *gorm.DB, userId int64) (bool, e
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetHospitalCloudCert 申请云证书-医院
|
||||
func (r *UserCaCertService) GetHospitalCloudCert(tx *gorm.DB) (bool, error) {
|
||||
// AddHospitalCloudCert 申请云证书-医院
|
||||
func (r *UserCaCertService) AddHospitalCloudCert(tx *gorm.DB) (bool, error) {
|
||||
var userId int64 = 5345345461
|
||||
userCaCertDao := dao.UserCaCertDao{}
|
||||
|
||||
@ -704,3 +701,19 @@ func (r *UserCaCertService) AddUserSignConfig(tx *gorm.DB, req requests.AddUserS
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetHospitalCloudCert 获取医院云证书数据
|
||||
func (r *UserCaCertService) GetHospitalCloudCert() (g *dto.UserCaCertDto, err error) {
|
||||
var userId int64 = 5345345461
|
||||
userCaCertDao := dao.UserCaCertDao{}
|
||||
|
||||
// 检测是否存在云证书
|
||||
maps := make(map[string]interface{})
|
||||
maps["is_system"] = 1
|
||||
maps["ca_pin"] = userId
|
||||
maps["type"] = 2
|
||||
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||
g = dto.GetUserCaCertDto(userCaCert)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
@ -1457,7 +1457,7 @@ func (r *UserDoctorService) PutMulti(doctorId int64, req requests.PutMulti) (boo
|
||||
userCaCert, _ := userCaCertDao.GetUserCaCert(maps)
|
||||
if userCaCert == nil {
|
||||
// 申请云证书
|
||||
_, err = userCaCertService.GetUserCloudCert(tx, userDoctor.UserId)
|
||||
_, err = userCaCertService.AddUserCloudCert(tx, userDoctor.UserId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New(err.Error())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user