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

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.CertificatePageReqVO;
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.CertificateDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 供应商证件资质 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CertificateMapper extends BaseMapperX<CertificateDO> {

    default PageResult<CertificateDO> selectPage(CertificatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CertificateDO>()
                .eqIfPresent(CertificateDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(CertificateDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(CertificateDO::getType, reqVO.getType())
                .likeIfPresent(CertificateDO::getName, reqVO.getName())
                .eqIfPresent(CertificateDO::getUrls, reqVO.getUrls())
                .betweenIfPresent(CertificateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CertificateDO::getId));
    }

    default List<CertificateDO> selectListBySupplierId(Long supplierId) {
        return selectList(new LambdaQueryWrapperX<CertificateDO>()
                .eq(CertificateDO::getSupplierId, supplierId)
                .orderByDesc(CertificateDO::getId));

    }

}
