兼容casbin2.24.0版本log
迁移脚本编译时不打包
This commit is contained in:
1 parent
48f0cb46ec
commit
39dd1ee6f8
56 files changed
+320
-454
No files matched your search
+2
-4
@@ -2,7 +2,6 @@ package tools
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -70,16 +69,15 @@ func GenerateMsgIDFromContext(c *gin.Context) string {
|
||||
|
||||
// GetOrm 获取orm连接
|
||||
func GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
msgID := GenerateMsgIDFromContext(c)
|
||||
idb, exist := c.Get("db")
|
||||
if !exist {
|
||||
return nil, errors.New(fmt.Sprintf("msgID[%s], db connect not exist", msgID))
|
||||
return nil, errors.New("db connect not exist")
|
||||
}
|
||||
switch idb.(type) {
|
||||
case *gorm.DB:
|
||||
//新增操作
|
||||
return idb.(*gorm.DB), nil
|
||||
default:
|
||||
return nil, errors.New(fmt.Sprintf("msgID[%s], db connect not exist", msgID))
|
||||
return nil, errors.New("db connect not exist")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user