package cn.iocoder.yudao.module.bpm.dal.mysql.oa;

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.bpm.controller.admin.oa.vo.supplier.BpmOASupplierProductPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASupplierProductDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * OA供应商商品 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface BpmOASupplierProductMapper extends BaseMapperX<BpmOASupplierProductDO> {

    default PageResult<BpmOASupplierProductDO> selectPage(BpmOASupplierProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOASupplierProductDO>()
                .eqIfPresent(BpmOASupplierProductDO::getOaSupplierId, reqVO.getOaSupplierId())
                .eqIfPresent(BpmOASupplierProductDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(BpmOASupplierProductDO::getSupplierProductId, reqVO.getSupplierProductId())
                .eqIfPresent(BpmOASupplierProductDO::getAssetsTypeId, reqVO.getAssetsTypeId())
                .likeIfPresent(BpmOASupplierProductDO::getAssetsName, reqVO.getAssetsName())
                .eqIfPresent(BpmOASupplierProductDO::getUtil, reqVO.getUtil())
                .eqIfPresent(BpmOASupplierProductDO::getModel, reqVO.getModel())
                .eqIfPresent(BpmOASupplierProductDO::getPrice, reqVO.getPrice())
                .eqIfPresent(BpmOASupplierProductDO::getRemarks, reqVO.getRemarks())
                .betweenIfPresent(BpmOASupplierProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOASupplierProductDO::getId));
    }

    /**
     * 通过供应商id获取商品列表
     *
     * @param oaSupplierId
     * @return
     */
    List<BpmOASupplierProductDO> getByOaSupplierId(@Param("oaSupplierId") Long oaSupplierId);
}
