修改action和模版,使用log打印日志,修复job删除问题,已经所有删除问题
This commit is contained in:
1 parent
f3e0e4dbc6
commit
8460b3f385
17 files changed
+319
-314
No files matched your search
+4
-16
@@ -3,10 +3,11 @@ package apis
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/tools"
|
||||
)
|
||||
|
||||
type Api struct {
|
||||
@@ -18,7 +19,7 @@ func (e *Api) GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
|
||||
// GetOrm 获取orm连接
|
||||
func GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
msgID := GenerateMsgIDFromContext(c)
|
||||
msgID := tools.GenerateMsgIDFromContext(c)
|
||||
idb, exist := c.Get("db")
|
||||
if !exist {
|
||||
return nil, errors.New(fmt.Sprintf("msgID[%s], db connect not exist", msgID))
|
||||
@@ -31,16 +32,3 @@ func GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
return nil, errors.New(fmt.Sprintf("msgID[%s], db connect not exist", msgID))
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateMsgIDFromContext 生成msgID
|
||||
func GenerateMsgIDFromContext(c *gin.Context) string {
|
||||
var msgID string
|
||||
data, ok := c.Get("msgID")
|
||||
if !ok {
|
||||
msgID = uuid.New().String()
|
||||
c.Set("msgID", msgID)
|
||||
return msgID
|
||||
}
|
||||
msgID = cast.ToString(data)
|
||||
return msgID
|
||||
}
|
||||
Reference in new issue
Block a user