数据结构优化
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/niangaodev/art-code/models"
|
||||
"github.com/niangaodev/art-code/repositories"
|
||||
"github.com/niangaodev/art-code/utils"
|
||||
)
|
||||
|
||||
// OperationLogMiddleware 操作日志中间件
|
||||
@@ -46,11 +47,16 @@ func OperationLogMiddleware() gin.HandlerFunc {
|
||||
|
||||
username, _ := c.Get("username")
|
||||
|
||||
// 获取IP归属地
|
||||
ip := c.ClientIP()
|
||||
region := utils.GetRegion(ip)
|
||||
|
||||
// 构建操作日志
|
||||
operationLog := &models.OperationLog{
|
||||
UserID: userID.(uint),
|
||||
Username: username.(string),
|
||||
IP: c.ClientIP(),
|
||||
IP: ip,
|
||||
Region: region,
|
||||
Path: c.Request.URL.Path,
|
||||
Method: c.Request.Method,
|
||||
Params: string(requestBody),
|
||||
|
||||
Reference in New Issue
Block a user