package cn.iocoder.yudao.module.system.dal.mysql.authentication;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.authentication.vo.AuthenticationPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.authentication.AuthenticationDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 认证 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface AuthenticationMapper extends BaseMapperX<AuthenticationDO> {

    default PageResult<AuthenticationDO> selectPage(AuthenticationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AuthenticationDO>()
                .eqIfPresent(AuthenticationDO::getUserid, reqVO.getUserid())
                .eqIfPresent(AuthenticationDO::getJobNumber, reqVO.getJobNumber())
                .eqIfPresent(AuthenticationDO::getRandomCode, reqVO.getRandomCode())
                .eqIfPresent(AuthenticationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(AuthenticationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AuthenticationDO::getId));
    }

    default List<AuthenticationDO> selectList(AuthenticationPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AuthenticationDO>()
                .eqIfPresent(AuthenticationDO::getUserid, reqVO.getUserid())
                .eqIfPresent(AuthenticationDO::getJobNumber, reqVO.getJobNumber())
                .eqIfPresent(AuthenticationDO::getRandomCode, reqVO.getRandomCode())
                .eqIfPresent(AuthenticationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(AuthenticationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AuthenticationDO::getId));
    }

}