新增申请云证书接口
This commit is contained in:
@@ -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 // 证书
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user