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

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.code.CodeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.identity.controller.admin.code.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 标识码 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CodeMapper extends BaseMapperX<CodeDO> {

    default PageResult<CodeDO> selectPage(CodePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CodeDO>()
                .eqIfPresent(CodeDO::getGenerateRecordId, reqVO.getGenerateRecordId())
                .eqIfPresent(CodeDO::getIdentityCode, reqVO.getIdentityCode())
                .eqIfPresent(CodeDO::getVerfiyCode, reqVO.getVerfiyCode())
                .eqIfPresent(CodeDO::getRuleId, reqVO.getRuleId())
                .eqIfPresent(CodeDO::getCodeRuleFormat, reqVO.getCodeRuleFormat())
                .eqIfPresent(CodeDO::getCodeType, reqVO.getCodeType())
                .eqIfPresent(CodeDO::getCharLength, reqVO.getCharLength())
                .eqIfPresent(CodeDO::getCharType, reqVO.getCharType())
                .eqIfPresent(CodeDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(CodeDO::getBatchType, reqVO.getBatchType())
                .eqIfPresent(CodeDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(CodeDO::getGoodsName, reqVO.getGoodsName())
                .likeIfPresent(CodeDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(CodeDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(CodeDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(CodeDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(CodeDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CodeDO::getScanCount, reqVO.getScanCount())
                .eqIfPresent(CodeDO::getLimitCount, reqVO.getLimitCount())
                .orderByDesc(CodeDO::getId));
    }

    default List<CodeDO> selectList(CodeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CodeDO>()
                .eqIfPresent(CodeDO::getGenerateRecordId, reqVO.getGenerateRecordId())
                .eqIfPresent(CodeDO::getIdentityCode, reqVO.getIdentityCode())
                .eqIfPresent(CodeDO::getVerfiyCode, reqVO.getVerfiyCode())
                .eqIfPresent(CodeDO::getRuleId, reqVO.getRuleId())
                .eqIfPresent(CodeDO::getCodeRuleFormat, reqVO.getCodeRuleFormat())
                .eqIfPresent(CodeDO::getCodeType, reqVO.getCodeType())
                .eqIfPresent(CodeDO::getCharLength, reqVO.getCharLength())
                .eqIfPresent(CodeDO::getCharType, reqVO.getCharType())
                .eqIfPresent(CodeDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(CodeDO::getBatchType, reqVO.getBatchType())
                .eqIfPresent(CodeDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(CodeDO::getGoodsName, reqVO.getGoodsName())
                .likeIfPresent(CodeDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(CodeDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(CodeDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(CodeDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(CodeDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CodeDO::getScanCount, reqVO.getScanCount())
                .eqIfPresent(CodeDO::getLimitCount, reqVO.getLimitCount())
                .orderByDesc(CodeDO::getId));
    }

    List<CodeDO> getListByBatchIds(@Param("batchIdList") List<String> batchIdList);

}
