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

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.asset.controller.admin.supplier.vo.SupplierPageReqVO;
import cn.iocoder.yudao.module.asset.dal.dataobject.supplier.SupplierDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 供应商信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface SupplierMapper extends BaseMapperX<SupplierDO> {

    default PageResult<SupplierDO> selectPage(SupplierPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierDO>()
                .eqIfPresent(SupplierDO::getSupplierCode, reqVO.getSupplierCode())
                .inIfPresent(SupplierDO::getCoopStatus, reqVO.getCoopStatus())
                .likeIfPresent(SupplierDO::getSupplierName, reqVO.getSupplierName())
                .inIfPresent(SupplierDO::getType, reqVO.getType())
                .inIfPresent(SupplierDO::getRegion, reqVO.getRegion())
                .eqIfPresent(SupplierDO::getCity, reqVO.getCity())
                .eqIfPresent(SupplierDO::getCreator, reqVO.getCreator())
                .orderByDesc(SupplierDO::getId));
    }

}
