审计日志列表增加级别筛选

This commit is contained in:
刘祥超
2023-04-06 10:06:22 +08:00
parent 431054a1be
commit 9d178b238d
5 changed files with 46 additions and 5 deletions
@@ -23,6 +23,7 @@ func (this *ExportExcelAction) RunGet(params struct {
DayTo string
Keyword string
UserType string
Level string
}) {
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
Offset: 0,
@@ -31,6 +32,7 @@ func (this *ExportExcelAction) RunGet(params struct {
DayTo: params.DayTo,
Keyword: params.Keyword,
UserType: params.UserType,
Level: params.Level,
})
if err != nil {
this.ErrorPage(err)
@@ -56,6 +58,7 @@ func (this *ExportExcelAction) RunGet(params struct {
row.AddCell().SetString("区域")
row.AddCell().SetString("运营商")
row.AddCell().SetString("页面地址")
row.AddCell().SetString("级别")
}
// 数据
@@ -95,6 +98,17 @@ func (this *ExportExcelAction) RunGet(params struct {
row.AddCell().SetString(regionName)
row.AddCell().SetString(ispName)
row.AddCell().SetString(log.Action)
var levelName = ""
switch log.Level {
case "info":
levelName = "信息"
case "warn", "warning":
levelName = "警告"
case "error":
levelName = "错误"
}
row.AddCell().SetString(levelName)
}
this.AddHeader("Content-Type", "application/vnd.ms-excel")
+23 -3
View File
@@ -21,6 +21,7 @@ func (this *IndexAction) RunGet(params struct {
DayTo string
Keyword string
UserType string
Level string
}) {
// 读取配置
config, err := configloaders.LoadLogConfig()
@@ -35,18 +36,36 @@ func (this *IndexAction) RunGet(params struct {
this.Data["keyword"] = params.Keyword
this.Data["userType"] = params.UserType
// 级别
this.Data["level"] = params.Level
this.Data["levelOptions"] = []maps.Map{
{
"code": "info",
"name": "信息",
},
{
"code": "warn",
"name": "警告",
},
{
"code": "error",
"name": "错误",
},
}
countResp, err := this.RPC().LogRPC().CountLogs(this.AdminContext(), &pb.CountLogRequest{
DayFrom: params.DayFrom,
DayTo: params.DayTo,
Keyword: params.Keyword,
UserType: params.UserType,
Level: params.Level,
})
if err != nil {
this.ErrorPage(err)
return
}
count := countResp.Count
page := this.NewPage(count)
var count = countResp.Count
var page = this.NewPage(count)
this.Data["page"] = page.AsHTML()
logsResp, err := this.RPC().LogRPC().ListLogs(this.AdminContext(), &pb.ListLogsRequest{
@@ -56,12 +75,13 @@ func (this *IndexAction) RunGet(params struct {
DayTo: params.DayTo,
Keyword: params.Keyword,
UserType: params.UserType,
Level: params.Level,
})
if err != nil {
this.ErrorPage(err)
return
}
logMaps := []maps.Map{}
var logMaps = []maps.Map{}
for _, log := range logsResp.Logs {
regionName := ""
regionResp, err := this.RPC().IPLibraryRPC().LookupIPRegion(this.AdminContext(), &pb.LookupIPRegionRequest{Ip: log.Ip})