package com.cf.imes.module.executor.dal.mysql.goods;

import java.util.*;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
import org.apache.ibatis.annotations.Mapper;
import com.cf.imes.module.executor.controller.admin.goods.vo.*;

/**
 * 生产单商品 Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface GoodsMapper extends BaseMapperX<GoodsDO> {

    default PageResult<GoodsDO> selectPage(GoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GoodsDO>()
                .eqIfPresent(GoodsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(GoodsDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(GoodsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(GoodsDO::getMaterial, reqVO.getMaterial())
                .eqIfPresent(GoodsDO::getColor, reqVO.getColor())
                .eqIfPresent(GoodsDO::getWidth, reqVO.getWidth())
                .eqIfPresent(GoodsDO::getHeight, reqVO.getHeight())
                .eqIfPresent(GoodsDO::getThickness, reqVO.getThickness())
                .eqIfPresent(GoodsDO::getPrice, reqVO.getPrice())
                .eqIfPresent(GoodsDO::getBrand, reqVO.getBrand())
                .eqIfPresent(GoodsDO::getSpec, reqVO.getSpec())
                .eqIfPresent(GoodsDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(GoodsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GoodsDO::getId));
    }

}