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 ParticipateRecordsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
	r      *http.Request
}

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

func (l *ParticipateRecordsLogic) ParticipateRecords(req *types.ParticipateRecordsReq) (resp *types.CommonResp, err error) {
	defer common.Catch()
	res, err := l.svcCtx.BxCore.ParticipateRecords(l.ctx, &bxcore.ParticipateRecordsReq{
		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,
		Sid:          req.Sid,
		PageSize:     req.PageSize,
		Page:         req.PageNum,
		EntAccountId: req.EntAccountId,
		Phone:        req.Phone,
	})
	if err != nil {
		return &types.CommonResp{
			Err_code: -1,
			Err_msg:  "查询失败",
			Data: map[string]interface{}{
				"list":  []map[string]interface{}{},
				"total": 0,
			},
		}, nil
	}
	return &types.CommonResp{
		Err_code: res.ErrCode,
		Err_msg:  res.ErrMsg,
		Data:     res.Data,
	}, nil
}
