package exchange

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

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

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

func (l *GetMyExchangeOrdersLogic) GetMyExchangeOrders(req *types.ExchangeOrderListReq) (*plantPb.ExchangeOrderListResp, error) {
	userId := fmt.Sprintf("%v", l.ctx.Value("userId"))
	return l.svcCtx.PlantRpc.GetMyExchangeOrders(l.ctx, &plantPb.ExchangeOrderListReq{
		UserId: userId, Current: int32(req.Current), PageSize: int32(req.PageSize), Status: int32(req.Status),
	})
}
