refactor🎨: 添加日志排序

This commit is contained in:
zhangwenjian committed 2021-06-14 20:07:48 +08:00
1 parent 67d393a222
commit 880a3700d1
3 files changed
+9 -3

No files matched your search

+2 -1
View File
@@ -16,10 +16,11 @@ type SysLoginLogSearch struct {
LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_login_log" comment:"归属地"`
BeginTime string `form:"beginTime" search:"type:gte;column:ctime;table:sys_login_log" comment:"创建时间"`
EndTime string `form:"endTime" search:"type:lte;column:ctime;table:sys_login_log" comment:"创建时间"`
SysLoginLogOrder
}
type SysLoginLogOrder struct {
HandleOrder string `search:"type:order;column:created_at;table:sys_login_log" form:"createdAtOrder"`
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_login_log" form:"createdAtOrder"`
}
func (m *SysLoginLogSearch) GetNeedSearch() interface{} {
+5
View File
@@ -18,6 +18,11 @@ type SysOperaLogSearch struct {
Status int `form:"status" search:"type:exact;column:status;table:sys_opera_log" comment:"状态"`
BeginTime string `form:"beginTime" search:"type:gte;column:ctime;table:sys_opera_log" comment:"创建时间"`
EndTime string `form:"endTime" search:"type:lte;column:ctime;table:sys_opera_log" comment:"创建时间"`
SysOperaLogOrder
}
type SysOperaLogOrder struct {
CreatedAtOrder string `search:"type:order;column:created_at;table:sys_opera_log" form:"createdAtOrder"`
}
func (m *SysOperaLogSearch) GetNeedSearch() interface{} {
+2 -2
View File
@@ -32,7 +32,7 @@ func LoggerToFile() gin.HandlerFunc {
// 处理请求
var body string
switch c.Request.Method {
case http.MethodPost, http.MethodPut, http.MethodDelete:
case http.MethodPost, http.MethodPut, http.MethodGet, http.MethodDelete:
bf := bytes.NewBuffer(nil)
wt := bufio.NewWriter(bf)
_, err := io.Copy(wt, c.Request.Body)
@@ -94,7 +94,7 @@ func LoggerToFile() gin.HandlerFunc {
}
log.WithFields(logData).Info()
if c.Request.Method != "OPTIONS" && c.Request.Method != "GET" && config.LoggerConfig.EnabledDB {
if c.Request.Method != "OPTIONS" && config.LoggerConfig.EnabledDB && statusCode != 404 {
SetDBOperLog(c, clientIP, statusCode, reqUri, reqMethod, latencyTime, body, result, statusBus)
}
}