package logic

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

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

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

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

func (l *NewestBiddingLogic) NewestBidding(req *types.NewestReq) (resp *types.CommonRes, err error) {
	res, err0 := l.svcCtx.Bxbase.NewestBidding(l.ctx, &bxbase.NewestBiddingReq{
		City:         req.City,
		IsSearch:     req.IsSearch,
		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,
		EntAccountId: req.EntAccountId,
		Phone:        req.Phone,
	})
	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.Data,
	}, nil
}
