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;
import org.apache.ibatis.annotations.Param;

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

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

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

    PlateDO selectOneById(@Param("id") Long id, @Param("organId") Long organId);
}
