日志生效,
调整路由注册方式
This commit is contained in:
1 parent
2fe2c96e82
commit
7d8a267da7
8 files changed
+148
-33
No files matched your search
+7
-3
@@ -12,9 +12,13 @@ import (
|
||||
type Api struct {
|
||||
}
|
||||
|
||||
// GetOrm 获取orm连接
|
||||
func (e *Api) GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
msgID := e.GenerateMsgIDFromContext(c)
|
||||
return GetOrm(c)
|
||||
}
|
||||
|
||||
// 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))
|
||||
@@ -29,7 +33,7 @@ func (e *Api) GetOrm(c *gin.Context) (*gorm.DB, error) {
|
||||
}
|
||||
|
||||
// GenerateMsgIDFromContext 生成msgID
|
||||
func (e *Api) GenerateMsgIDFromContext(c *gin.Context) string {
|
||||
func GenerateMsgIDFromContext(c *gin.Context) string {
|
||||
var msgID string
|
||||
data, ok := c.Get("msgID")
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user