// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package exchange

import (
	"context"

	"sundynix-micro-go/app/plant/api/internal/svc"
	"sundynix-micro-go/app/plant/api/internal/types"
	"sundynix-micro-go/app/plant/rpc/plant"

	"github.com/zeromicro/go-zero/core/logx"
)

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

// 兑换商品列表
func NewGetExchangeItemListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetExchangeItemListLogic {
	return &GetExchangeItemListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetExchangeItemListLogic) GetExchangeItemList(req *types.ExchangeItemListReq) (interface{}, error) {
	result, err := l.svcCtx.PlantRpc.GetExchangeItemList(l.ctx, &plant.ExchangeItemListReq{
		Current:  int32(req.Current),
		PageSize: int32(req.PageSize),
	})
	if err != nil {
		return nil, err
	}
	return map[string]interface{}{
		"list":  result.List,
		"total": result.Total,
	}, nil
}
