package cn.iocoder.yudao.module.identity.dal.mysql.generatebatch;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.identity.dal.dataobject.generatebatch.GenerateBatchDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.identity.controller.admin.generatebatch.vo.*;

/**
 * 码生成记录与批次关联记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface GenerateBatchMapper extends BaseMapperX<GenerateBatchDO> {

    default PageResult<GenerateBatchDO> selectPage(GenerateBatchPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GenerateBatchDO>()
                .eqIfPresent(GenerateBatchDO::getGenerateRecordId, reqVO.getGenerateRecordId())
                .eqIfPresent(GenerateBatchDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(GenerateBatchDO::getNum, reqVO.getNum())
                .eqIfPresent(GenerateBatchDO::getBatchType, reqVO.getBatchType())
                .eqIfPresent(GenerateBatchDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(GenerateBatchDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(GenerateBatchDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GenerateBatchDO::getId));
    }

    default List<GenerateBatchDO> selectList(GenerateBatchExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GenerateBatchDO>()
                .eqIfPresent(GenerateBatchDO::getGenerateRecordId, reqVO.getGenerateRecordId())
                .eqIfPresent(GenerateBatchDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(GenerateBatchDO::getNum, reqVO.getNum())
                .eqIfPresent(GenerateBatchDO::getBatchType, reqVO.getBatchType())
                .eqIfPresent(GenerateBatchDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(GenerateBatchDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(GenerateBatchDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GenerateBatchDO::getId));
    }

}
