新增申请云证书接口

This commit is contained in:
2023-10-25 17:36:31 +08:00
parent 70f9c47e0c
commit d0d86826bc
8 changed files with 472 additions and 130 deletions
+6
View File
@@ -12,6 +12,7 @@ type Api struct {
caseManage // 病例管理
orderPrescriptionManage // 处方管理
inquiryManage // 问诊管理
caManage // ca管理
}
// SysSetting 系统设置
@@ -65,3 +66,8 @@ type orderPrescriptionManage struct {
type inquiryManage struct {
InquiryConfig // 问诊配置
}
// ca管理
type caManage struct {
UserCaCert // 证书
}
+49
View File
@@ -0,0 +1,49 @@
package controller
import (
"github.com/gin-gonic/gin"
"hospital-admin-api/api/responses"
"hospital-admin-api/api/service"
"hospital-admin-api/config"
"hospital-admin-api/global"
"strconv"
)
type UserCaCert struct{}
// GetUserCloudCert 申请云证书-个人
func (r *UserCaCert) GetUserCloudCert(c *gin.Context) {
id := c.Param("user_id")
if id == "" {
responses.FailWithMessage("缺少参数", c)
return
}
// 将 id 转换为 int64 类型
userId, err := strconv.ParseInt(id, 10, 64)
if err != nil {
responses.Fail(c)
return
}
// 业务处理
tx := global.Db.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
if config.C.Env == "prod" {
userCaCertService := service.UserCaCertService{}
_, err = userCaCertService.GetUserCloudCert(tx, userId)
if err != nil {
tx.Rollback()
responses.FailWithMessage(err.Error(), c)
return
}
}
tx.Commit()
responses.Ok(c)
}