package operationRecord

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"sundynix-micro-go/app/system/api/internal/svc"
	"sundynix-micro-go/app/system/api/internal/types"
	"sundynix-micro-go/app/system/rpc/system"
)

type GetOperationRecordListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetOperationRecordListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOperationRecordListLogic {
	return &GetOperationRecordListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *GetOperationRecordListLogic) GetOperationRecordList(req *types.OperationRecordListReq) (interface{}, error) {
	resp, err := l.svcCtx.SystemRpc.GetOperationRecordList(l.ctx, &system.OperationRecordListReq{
		Current: int32(req.Current), PageSize: int32(req.PageSize),
		Method: req.Method, Path: req.Path, Status: int32(req.Status),
	})
	if err != nil {
		return nil, err
	}
	return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
}
