|
@ -8,11 +8,11 @@ import ( |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
"io/ioutil" |
|
|
"io/ioutil" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
"strconv" |
|
|
"strings" |
|
|
"strings" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var body []byte |
|
|
var body []byte |
|
|
var userId uint |
|
|
|
|
|
|
|
|
|
|
|
func RecordRequestBody() gin.HandlerFunc { |
|
|
func RecordRequestBody() gin.HandlerFunc { |
|
|
return func(c *gin.Context) { |
|
|
return func(c *gin.Context) { |
|
@ -26,8 +26,6 @@ func RecordRequestBody() gin.HandlerFunc { |
|
|
} else { |
|
|
} else { |
|
|
body = nil |
|
|
body = nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//TODO parse token , userId <-
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -40,7 +38,11 @@ func OperationRecord() gin.HandlerFunc { |
|
|
return "" |
|
|
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, |
|
|
Ip: param.ClientIP, |
|
|
Method: param.Method, |
|
|
Method: param.Method, |
|
|
Path: param.Path, |
|
|
Path: param.Path, |
|
@ -49,7 +51,7 @@ func OperationRecord() gin.HandlerFunc { |
|
|
Agent: param.Request.UserAgent(), |
|
|
Agent: param.Request.UserAgent(), |
|
|
ErrorMessage: param.ErrorMessage, |
|
|
ErrorMessage: param.ErrorMessage, |
|
|
Body: string(body), |
|
|
Body: string(body), |
|
|
UserId: int(userId), |
|
|
|
|
|
|
|
|
UserId: userId, |
|
|
}) |
|
|
}) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
global.GVA_LOG.Error(err) |
|
|
global.GVA_LOG.Error(err) |
|
|