package cn.iocoder.yudao.module.basic.dal.mysql.dealergoods;

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.basic.controller.admin.dealergoods.vo.DealerGoodsListReqVO;
import cn.iocoder.yudao.module.basic.controller.admin.dealergoods.vo.DealerGoodsPageReqVO;
import cn.iocoder.yudao.module.basic.dal.dataobject.dealergoods.DealerGoodsDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 经销商经销产品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DealerGoodsMapper extends BaseMapperX<DealerGoodsDO> {

    default PageResult<DealerGoodsDO> selectPage(DealerGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DealerGoodsDO>()
                .eqIfPresent(DealerGoodsDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(DealerGoodsDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(DealerGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(DealerGoodsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(DealerGoodsDO::getSaleArea, reqVO.getSaleArea())
                .eqIfPresent(DealerGoodsDO::getSaleAreaId, reqVO.getSaleAreaId())
                .eqIfPresent(DealerGoodsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .eqIfPresent(DealerGoodsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(DealerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DealerGoodsDO::getId));
    }

    default List<DealerGoodsDO> selectListQuery(DealerGoodsListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DealerGoodsDO>()
                .eqIfPresent(DealerGoodsDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(DealerGoodsDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(DealerGoodsDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(DealerGoodsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(DealerGoodsDO::getSaleArea, reqVO.getSaleArea())
                .eqIfPresent(DealerGoodsDO::getSaleAreaId, reqVO.getSaleAreaId())
                .eqIfPresent(DealerGoodsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .eqIfPresent(DealerGoodsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(DealerGoodsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DealerGoodsDO::getId));
    }

}
