package com.yolo.keyboard.dal.mysql.userinvites;

import java.util.*;

import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
import com.yolo.keyboard.dal.dataobject.userinvites.KeyboardUserInvitesDO;
import org.apache.ibatis.annotations.Mapper;
import com.yolo.keyboard.controller.admin.userinvites.vo.*;

/**
 * 用户邀请关系绑定台账表，记录新用户最终归属的邀请人 Mapper
 *
 * @author ziin
 */
@Mapper
public interface KeyboardUserInvitesMapper extends BaseMapperX<KeyboardUserInvitesDO> {

    default PageResult<KeyboardUserInvitesDO> selectPage(KeyboardUserInvitesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserInvitesDO>()
                .eqIfPresent(KeyboardUserInvitesDO::getInviterUserId, reqVO.getInviterUserId())
                .eqIfPresent(KeyboardUserInvitesDO::getInviteeUserId, reqVO.getInviteeUserId())
                .eqIfPresent(KeyboardUserInvitesDO::getInviteCodeId, reqVO.getInviteCodeId())
                .eqIfPresent(KeyboardUserInvitesDO::getClickToken, reqVO.getClickToken())
                .eqIfPresent(KeyboardUserInvitesDO::getBindType, reqVO.getBindType())
                .eqIfPresent(KeyboardUserInvitesDO::getBoundAt, reqVO.getBoundAt())
                .eqIfPresent(KeyboardUserInvitesDO::getBindIp, reqVO.getBindIp())
                .eqIfPresent(KeyboardUserInvitesDO::getBindUserAgent, reqVO.getBindUserAgent())
                .eqIfPresent(KeyboardUserInvitesDO::getInviteType, reqVO.getInviteType())
                .eqIfPresent(KeyboardUserInvitesDO::getProfitTenantId, reqVO.getProfitTenantId())
                .eqIfPresent(KeyboardUserInvitesDO::getProfitEmployeeId, reqVO.getProfitEmployeeId())
                .eqIfPresent(KeyboardUserInvitesDO::getInviterTenantId, reqVO.getInviterTenantId())
                .eqIfPresent(KeyboardUserInvitesDO::getInviteCode, reqVO.getInviteCode())
                .orderByDesc(KeyboardUserInvitesDO::getId));
    }

}