调整整体架构写法

调整db用法
调整日志用法
调整模版
This commit is contained in:
linwenxiang committed 2021-03-04 23:45:16 +08:00
1 parent 734a48dbb8
commit e2952fa393
137 files changed
+3638 -3544

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
package middleware
import "github.com/gin-gonic/gin"
func SetLogger() gin.HandlerFunc {
return func(ctx *gin.Context) {
}
}
+27
View File
@@ -0,0 +1,27 @@
package middleware
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/logger"
"github.com/google/uuid"
)
// RequestIdLogger 自动增加requestId
func RequestIdLogger(trafficKey, loggerKey string) gin.HandlerFunc {
return func(c *gin.Context) {
requestId := c.GetHeader(trafficKey)
if requestId == "" {
requestId = c.GetHeader(strings.ToLower(trafficKey))
}
if requestId == "" {
requestId = uuid.New().String()
}
c.Header(trafficKey, requestId)
c.Set(loggerKey, logger.DefaultLogger.Fields(map[string]interface{}{
strings.ToLower(trafficKey): requestId,
}))
c.Next()
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"github.com/alibaba/sentinel-golang/core/system"
"github.com/gin-gonic/gin"
"go-admin/common/log"
log "github.com/go-admin-team/go-admin-core/logger"
)
// Sentinel 限流