package com.cf.imes.module.manage.dal.mysql.plate;

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.manage.controller.admin.plate.vo.plate.PlatePageReqVO;
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 板材信息表 plate_{N} Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface PlateMapper extends BaseMapperX<PlateDO> {

    default PlateDO selectByGoodID(String goodId) {
        return selectOne(PlateDO::getGoodsId, goodId);
    }

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

}