增加操作日志查看界面

This commit is contained in:
GoEdgeLab
2020-11-10 20:30:47 +08:00
parent 32f8ba02b6
commit d088e88e58
13 changed files with 101 additions and 47 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/types"
@@ -93,12 +94,7 @@ func (this *IndexAction) RunPost(params struct {
})
if err != nil {
_, err = rpcClient.AdminRPC().CreateAdminLog(rpcClient.Context(0), &pb.CreateAdminLogRequest{
Level: oplogs.LevelError,
Description: "登录时发生系统错误:" + err.Error(),
Action: this.Request.URL.Path,
Ip: this.RequestRemoteIP(),
})
err = models.SharedLogDAO.CreateAdminLog(rpcClient.Context(0), oplogs.LevelError, this.Request.URL.Path, "登录时发生系统错误:"+err.Error(), this.RequestRemoteIP())
if err != nil {
utils.PrintError(err)
}
@@ -107,12 +103,7 @@ func (this *IndexAction) RunPost(params struct {
}
if !resp.IsOk {
_, err = rpcClient.AdminRPC().CreateAdminLog(rpcClient.Context(0), &pb.CreateAdminLogRequest{
Level: oplogs.LevelWarn,
Description: "登录失败,用户名:" + params.Username,
Action: this.Request.URL.Path,
Ip: this.RequestRemoteIP(),
})
err = models.SharedLogDAO.CreateAdminLog(rpcClient.Context(0), oplogs.LevelWarn, this.Request.URL.Path, "登录失败,用户名:"+params.Username, this.RequestRemoteIP())
if err != nil {
utils.PrintError(err)
}
@@ -120,16 +111,11 @@ func (this *IndexAction) RunPost(params struct {
this.Fail("请输入正确的用户名密码")
}
adminId := int(resp.AdminId)
adminId := resp.AdminId
params.Auth.StoreAdmin(adminId, params.Remember)
// 记录日志
_, err = rpcClient.AdminRPC().CreateAdminLog(rpcClient.Context(0), &pb.CreateAdminLogRequest{
Level: oplogs.LevelInfo,
Description: "成功登录系统,用户名:" + params.Username,
Action: this.Request.URL.Path,
Ip: this.RequestRemoteIP(),
})
err = models.SharedLogDAO.CreateAdminLog(rpcClient.Context(adminId), oplogs.LevelInfo, this.Request.URL.Path, "成功登录系统,用户名:"+params.Username, this.RequestRemoteIP())
if err != nil {
utils.PrintError(err)
}