Initial commit (code only without large binaries)
This commit is contained in:
84
EdgeAdmin/internal/web/actions/default/finance/logs/index.go
Normal file
84
EdgeAdmin/internal/web/actions/default/finance/logs/index.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
Keyword string
|
||||
EventType string
|
||||
}) {
|
||||
this.Data["keyword"] = params.Keyword
|
||||
this.Data["eventType"] = params.EventType
|
||||
|
||||
// 所有事件类型
|
||||
this.Data["events"] = userconfigs.FindAllAccountEventTypes()
|
||||
|
||||
// 数量
|
||||
countResp, err := this.RPC().UserAccountLogRPC().CountUserAccountLogs(this.AdminContext(), &pb.CountUserAccountLogsRequest{
|
||||
Keyword: params.Keyword,
|
||||
EventType: params.EventType,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var count = countResp.Count
|
||||
var page = this.NewPage(count)
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
logsResp, err := this.RPC().UserAccountLogRPC().ListUserAccountLogs(this.AdminContext(), &pb.ListUserAccountLogsRequest{
|
||||
Keyword: params.Keyword,
|
||||
EventType: params.EventType,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var logMaps = []maps.Map{}
|
||||
for _, log := range logsResp.UserAccountLogs {
|
||||
var userMap = maps.Map{}
|
||||
if log.User != nil {
|
||||
userMap = maps.Map{
|
||||
"id": log.User.Id,
|
||||
"username": log.User.Username,
|
||||
"fullname": log.User.Fullname,
|
||||
}
|
||||
}
|
||||
|
||||
logMaps = append(logMaps, maps.Map{
|
||||
"id": log.Id,
|
||||
"description": log.Description,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
||||
"delta": log.Delta,
|
||||
"deltaFormatted": numberutils.FormatFloat(log.Delta, 2),
|
||||
"deltaFrozen": log.DeltaFrozen,
|
||||
"total": log.Total,
|
||||
"totalFormatted": numberutils.FormatFloat(log.Total, 2),
|
||||
"totalFrozen": log.TotalFrozen,
|
||||
"event": userconfigs.FindAccountEvent(log.EventType),
|
||||
"user": userMap,
|
||||
"accountId": log.UserAccountId,
|
||||
})
|
||||
}
|
||||
this.Data["logs"] = logMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
27
EdgeAdmin/internal/web/actions/default/finance/logs/init.go
Normal file
27
EdgeAdmin/internal/web/actions/default/finance/logs/init.go
Normal file
@@ -0,0 +1,27 @@
|
||||
//go:build plus
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/plus"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(plus.NewHelper(plus.ComponentCodeFinance)).
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeFinance)).
|
||||
Data("teaMenu", "finance").
|
||||
Data("teaSubMenu", "logs").
|
||||
|
||||
// 财务管理
|
||||
Prefix("/finance/logs").
|
||||
Get("", new(IndexAction)).
|
||||
|
||||
//
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user