package logic

import (
	"app.yhyue.com/moapp/jybase/common"
	"context"
	"jyBXBase/api/internal/types"
	"jyBXBase/rpc/type/bxbase"

	"github.com/zeromicro/go-zero/core/logx"
	"jyBXBase/api/internal/svc"
)

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

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

func (l *ListLogic) List(req *types.List) (resp *types.CommonRes, err error) {
	res, err0 := l.svcCtx.Bxbase.List(l.ctx, &bxbase.ListReq{
		UserId:      req.UserId,
		SelectTime:  req.SelectTime,
		Buyerclass:  req.Buyerclass,
		BuyerPhone:  req.BuyerPhone,
		Pagenum:     req.Pagenum,
		Pagesize:    req.Pagesize,
		WinnerPhone: req.WinnerPhone,
		AppId:       req.AppId,
	})
	if err0 != nil {
		return &types.CommonRes{
			Err_code: -1,
			Err_msg:  "错误",
			Data:     nil,
		}, nil
	}
	return &types.CommonRes{
		Err_code: common.IntAll(res.ErrCode),
		Err_msg:  res.ErrMsg,
		Data:     res.Ldata,
	}, nil
}
