新增申请云证书接口
This commit is contained in:
@@ -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