package cn.iocoder.yudao.module.product.dal.mysql.inspection;

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

/**
 * 检验检疫 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface InspectionMapper extends BaseMapperX<InspectionDO> {

    default PageResult<InspectionDO> selectPage(InspectionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectionDO>()
                .eqIfPresent(InspectionDO::getInspectionId, reqVO.getInspectionId())
                .eqIfPresent(InspectionDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(InspectionDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(InspectionDO::getHarvestBatchId, reqVO.getHarvestBatchId())
                .betweenIfPresent(InspectionDO::getHarvestTime, reqVO.getHarvestTime())
                .eqIfPresent(InspectionDO::getInspectionStandard, reqVO.getInspectionStandard())
                .eqIfPresent(InspectionDO::getInspectionResult, reqVO.getInspectionResult())
                .eqIfPresent(InspectionDO::getInspectionOwnItem, reqVO.getInspectionOwnItem())
                .eqIfPresent(InspectionDO::getInspectionUser, reqVO.getInspectionUser())
                .eqIfPresent(InspectionDO::getInspectionEntrustItem, reqVO.getInspectionEntrustItem())
                .eqIfPresent(InspectionDO::getInspectionOrganization, reqVO.getInspectionOrganization())
                .betweenIfPresent(InspectionDO::getInspectionDate, reqVO.getInspectionDate())
                .eqIfPresent(InspectionDO::getInspectionLevel, reqVO.getInspectionLevel())
                .betweenIfPresent(InspectionDO::getIssuanceDate, reqVO.getIssuanceDate())
                .eqIfPresent(InspectionDO::getBlockState, reqVO.getBlockState())
                .eqIfPresent(InspectionDO::getBlockChainId, reqVO.getBlockChainId())
                .eqIfPresent(InspectionDO::getBlockChainBlockIdentity, reqVO.getBlockChainBlockIdentity())
                .eqIfPresent(InspectionDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(InspectionDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(InspectionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionDO::getId));
    }

    default List<InspectionDO> selectList(InspectionExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectionDO>()
                .eqIfPresent(InspectionDO::getInspectionId, reqVO.getInspectionId())
                .eqIfPresent(InspectionDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(InspectionDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(InspectionDO::getHarvestBatchId, reqVO.getHarvestBatchId())
                .betweenIfPresent(InspectionDO::getHarvestTime, reqVO.getHarvestTime())
                .eqIfPresent(InspectionDO::getInspectionStandard, reqVO.getInspectionStandard())
                .eqIfPresent(InspectionDO::getInspectionResult, reqVO.getInspectionResult())
                .eqIfPresent(InspectionDO::getInspectionOwnItem, reqVO.getInspectionOwnItem())
                .eqIfPresent(InspectionDO::getInspectionUser, reqVO.getInspectionUser())
                .eqIfPresent(InspectionDO::getInspectionEntrustItem, reqVO.getInspectionEntrustItem())
                .eqIfPresent(InspectionDO::getInspectionOrganization, reqVO.getInspectionOrganization())
                .betweenIfPresent(InspectionDO::getInspectionDate, reqVO.getInspectionDate())
                .eqIfPresent(InspectionDO::getInspectionLevel, reqVO.getInspectionLevel())
                .betweenIfPresent(InspectionDO::getIssuanceDate, reqVO.getIssuanceDate())
                .eqIfPresent(InspectionDO::getBlockState, reqVO.getBlockState())
                .eqIfPresent(InspectionDO::getBlockChainId, reqVO.getBlockChainId())
                .eqIfPresent(InspectionDO::getBlockChainBlockIdentity, reqVO.getBlockChainBlockIdentity())
                .eqIfPresent(InspectionDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(InspectionDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(InspectionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InspectionDO::getId));
    }

    List<InspectionRespVO> getInspectionList(Map<String, Object> params);

}
