提交 2da6e092 编写于 作者: G granty1

Add user id support for operation record.

上级 95444a6e
......@@ -8,11 +8,11 @@ import (
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
"strconv"
"strings"
)
var body []byte
var userId uint
func RecordRequestBody() gin.HandlerFunc {
return func(c *gin.Context) {
......@@ -26,8 +26,6 @@ func RecordRequestBody() gin.HandlerFunc {
} else {
body = nil
}
//TODO parse token , userId <-
}
}
......@@ -40,7 +38,11 @@ func OperationRecord() gin.HandlerFunc {
return ""
}
}
err := service.CreateSysOperationRecord(model.SysOperationRecord{
userId, err := strconv.Atoi(param.Request.Header.Get("x-user-id"))
if err != nil {
userId = 0
}
err = service.CreateSysOperationRecord(model.SysOperationRecord{
Ip: param.ClientIP,
Method: param.Method,
Path: param.Path,
......@@ -49,7 +51,7 @@ func OperationRecord() gin.HandlerFunc {
Agent: param.Request.UserAgent(),
ErrorMessage: param.ErrorMessage,
Body: string(body),
UserId: int(userId),
UserId: userId,
})
if err != nil {
global.GVA_LOG.Error(err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册