Chever John 71a2d912e2 feat: initial commit for muyu-apiserver
Go service with gateway, RPC, model layers and k8s deploy configs.

Made-with: Cursor
2026-02-28 15:29:16 +08:00

63 lines
1.4 KiB
Go

package log
import (
"context"
"muyu-apiserver/gateway/internal/svc"
"muyu-apiserver/gateway/internal/types"
"muyu-apiserver/rpc/system/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type ListLogLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogLogic {
return &ListLogLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ListLogLogic) ListLog(req *types.ListLogReq) (resp *types.ListLogResp, err error) {
rpcResp, err := l.svcCtx.SystemRpc.ListOperationLog(l.ctx, &pb.ListLogReq{
Page: req.Page,
PageSize: req.PageSize,
Username: req.Username,
Module: req.Module,
Operation: req.Operation,
StartTime: req.StartTime,
EndTime: req.EndTime,
})
if err != nil {
return nil, err
}
list := make([]types.OperationLogInfo, 0, len(rpcResp.List))
for _, item := range rpcResp.List {
list = append(list, types.OperationLogInfo{
LogId: item.LogId,
UserId: item.UserId,
Username: item.Username,
Module: item.Module,
Operation: item.Operation,
Method: item.Method,
Path: item.Path,
Ip: item.Ip,
Duration: item.Duration,
Status: item.Status,
CreatedAt: item.CreatedAt,
})
}
return &types.ListLogResp{
Total: rpcResp.Total,
List: list,
}, nil
}