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

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

/**
 * 码规则 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BusinessRuleMapper extends BaseMapperX<BusinessRuleDO> {

    default PageResult<BusinessRuleDO> selectPage(BusinessRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessRuleDO>()
                .eqIfPresent(BusinessRuleDO::getBusinessId, reqVO.getBusinessId())
                .likeIfPresent(BusinessRuleDO::getBusinessName, reqVO.getBusinessName())
                .eqIfPresent(BusinessRuleDO::getCodeRuleId, reqVO.getCodeRuleId())
                .likeIfPresent(BusinessRuleDO::getCodeRuleName, reqVO.getCodeRuleName())
                .eqIfPresent(BusinessRuleDO::getCodeType, reqVO.getCodeType())
                .eqIfPresent(BusinessRuleDO::getCodeRuleFormat, reqVO.getCodeRuleFormat())
                .betweenIfPresent(BusinessRuleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BusinessRuleDO::getId));
    }

    default List<BusinessRuleDO> selectList(BusinessRuleExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BusinessRuleDO>()
                .eqIfPresent(BusinessRuleDO::getBusinessId, reqVO.getBusinessId())
                .likeIfPresent(BusinessRuleDO::getBusinessName, reqVO.getBusinessName())
                .eqIfPresent(BusinessRuleDO::getCodeRuleId, reqVO.getCodeRuleId())
                .likeIfPresent(BusinessRuleDO::getCodeRuleName, reqVO.getCodeRuleName())
                .eqIfPresent(BusinessRuleDO::getCodeType, reqVO.getCodeType())
                .eqIfPresent(BusinessRuleDO::getCodeRuleFormat, reqVO.getCodeRuleFormat())
                .betweenIfPresent(BusinessRuleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BusinessRuleDO::getId));
    }

}
