mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
1. 修复日志创建时间筛选报错的bug.
2. 修复日志里操作人,修改人,userAgent为空的bug. 3. 迁移表时,日志表添加字段注释. 4. sys_opera_log表oper_param字段类型改为text,解决字段长度报错的问题
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common"
|
||||
gaConfig "go-admin/config"
|
||||
"io"
|
||||
@@ -102,6 +103,7 @@ func LoggerToFile() gin.HandlerFunc {
|
||||
|
||||
// SetDBOperLog 写入操作日志表 fixme 该方法后续即将弃用
|
||||
func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string, reqMethod string, latencyTime time.Duration, body string, result string, status int) {
|
||||
|
||||
log := api.GetRequestLogger(c)
|
||||
l := make(map[string]interface{})
|
||||
l["_fullPath"] = c.FullPath()
|
||||
@@ -110,16 +112,19 @@ func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string
|
||||
fmt.Println("gaConfig.ExtConfig.AMap.Key", gaConfig.ExtConfig.AMap.Key)
|
||||
l["operLocation"] = pkg.GetLocation(clientIP, gaConfig.ExtConfig.AMap.Key)
|
||||
l["operName"] = user.GetUserName(c)
|
||||
l["requestMethod"] = c.Request.Method
|
||||
l["requestMethod"] = reqMethod
|
||||
l["operParam"] = body
|
||||
l["operTime"] = time.Now()
|
||||
l["jsonResult"] = result
|
||||
l["latencyTime"] = latencyTime.String()
|
||||
l["statusCode"] = statusCode
|
||||
l["userAgent"] = c.Request.UserAgent()
|
||||
l["createBy"] = user.GetUserId(c)
|
||||
l["updateBy"] = user.GetUserId(c)
|
||||
if status == http.StatusOK {
|
||||
l["status"] = "2"
|
||||
l["status"] = dto.OperaStatusEnabel
|
||||
} else {
|
||||
l["status"] = "1"
|
||||
l["status"] = dto.OperaStatusDisable
|
||||
}
|
||||
q := sdk.Runtime.GetMemoryQueue(c.Request.Host)
|
||||
message, err := sdk.Runtime.GetStreamMessage("", global.OperateLog, l)
|
||||
@@ -132,4 +137,4 @@ func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string
|
||||
log.Errorf("Append message error, %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user