package cn.iocoder.yudao.module.erp.dal.mysql.autocode;

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.erp.dal.dataobject.autocode.AutocodeRuleDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.vo.*;

/**
 * 编码规则 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface AutocodeRuleMapper extends BaseMapperX<AutocodeRuleDO> {

    default PageResult<AutocodeRuleDO> selectPage(AutocodeRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AutocodeRuleDO>()
                .likeIfPresent(AutocodeRuleDO::getRuleCode, reqVO.getRuleCode())
                .likeIfPresent(AutocodeRuleDO::getRuleName, reqVO.getRuleName())
                .eqIfPresent(AutocodeRuleDO::getRuleDesc, reqVO.getRuleDesc())
                .eqIfPresent(AutocodeRuleDO::getMaxLength, reqVO.getMaxLength())
                .eqIfPresent(AutocodeRuleDO::getIsPadded, reqVO.getIsPadded())
                .eqIfPresent(AutocodeRuleDO::getPaddedChar, reqVO.getPaddedChar())
                .eqIfPresent(AutocodeRuleDO::getPaddedMethod, reqVO.getPaddedMethod())
                .eqIfPresent(AutocodeRuleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(AutocodeRuleDO::getIsEnable, reqVO.getIsEnable())
                .betweenIfPresent(AutocodeRuleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AutocodeRuleDO::getId));
    }

}