package logic

import (
	"app.yhyue.com/moapp/jybase/common"
	"context"
	"jyBXCore/rpc/type/bxcore"
	"net/http"

	"jyBXCore/api/internal/svc"
	"jyBXCore/api/internal/types"

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

type ParticipateListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	r      *http.Request
}

func NewParticipateListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *ParticipateListLogic {
	return &ParticipateListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
		r:      r,
	}
}

func (l *ParticipateListLogic) ParticipateList(req *types.ParticipateListReq) (resp *types.CommonResp, err error) {
	defer common.Catch()
	res, err := l.svcCtx.BxCore.ParticipateList(l.ctx, &bxcore.ParticipateListReq{
		Identity:      req.Identity,
		EntId:         req.EntId,
		EntUserId:     req.EntUserId,
		PositionId:    req.PositionId,
		PositionType:  req.PositionType,
		AppId:         req.AppId,
		MgoUserId:     req.MgoUserId,
		AccountId:     req.AccountId,
		UserId:        req.UserId,
		NewUserId:     req.NewUserId,
		Area:          req.Area,
		City:          req.City,
		BidTime:       req.BidTime,
		BidEndTime:    req.BidEndTime,
		BidOpenTime:   req.BidOpenTime,
		BidEndStatus:  req.BidEndStatus,
		BidOpenStatus: req.BidOpenStatus,
		Keywords:      req.Keywords,
		EntUserIds:    req.EntUserIds,
		PageSize:      req.PageSize,
		PageNum:       req.PageNum,
		OrderNum:      req.OrderNum,
		EntAccountId:  req.EntAccountId,
		Phone:         req.Phone,
	})
	if res != nil && (*res).Data != nil {
		return &types.CommonResp{
			Err_code: res.ErrCode,
			Err_msg:  res.ErrMsg,
			Data:     res.Data,
		}, err
	}
	return &types.CommonResp{
		Err_code: 0,
		Err_msg:  "",
		Data:     nil,
	}, nil
}
