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

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


/**
 * 贴皮 Mapper
 *
 * @author Gqr
 * @since 2026/1/4 14:14
 */
@Mapper
public interface VeneerMapper extends BaseMapperX<VeneerDO> {
    /**
     * 分页查询
     * @param reqVO
     * @return
     */
    default PageResult<VeneerDO> selectPage(VeneerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VeneerDO>()
                .eqIfPresent(VeneerDO::getVeneerNo, reqVO.getVeneerNo())
                .eqIfPresent(VeneerDO::getBatchNo, reqVO.getBatchNo())
                .eqIfPresent(VeneerDO::getClassificationName, reqVO.getClassificationName())
                .eqIfPresent(VeneerDO::getVeneerName, reqVO.getVeneerName())
                .eqIfPresent(VeneerDO::getProductLevel, reqVO.getProductLevel())
                .eqIfPresent(VeneerDO::getColor, reqVO.getColor())
                .eqIfPresent(VeneerDO::getMaterial, reqVO.getMaterial())
                .betweenIfPresent(VeneerDO::getLength, reqVO.getLength())
                .betweenIfPresent(VeneerDO::getWidth, reqVO.getWidth())
                .betweenIfPresent(VeneerDO::getThickness, reqVO.getThickness())
                .eqIfPresent(VeneerDO::getSpec, reqVO.getSpec())
                .eqIfPresent(VeneerDO::getFactory, reqVO.getFactory())
                .betweenIfPresent(VeneerDO::getNum, reqVO.getNum())
                .eqIfPresent(VeneerDO::getDefect, reqVO.getDefect())
                .likeIfPresent(VeneerDO::getRemark, reqVO.getRemark())
                .eqIfPresent(VeneerDO::getRemain, reqVO.getRemain())
                .eqIfPresent(VeneerDO::getSourcePlanNo, reqVO.getSourcePlanNo())
                .eqIfPresent(VeneerDO::getPlanNo, reqVO.getPlanNo())
                .eqIfPresent(VeneerDO::getStatus, reqVO.getStatus())
                // 查询字段
                .select(VeneerDO::getId, VeneerDO::getVeneerNo, VeneerDO::getBatchNo, VeneerDO::getClassificationName, VeneerDO::getVeneerName,
                        VeneerDO::getProductLevel, VeneerDO::getColor, VeneerDO::getMaterial, VeneerDO::getLength, VeneerDO::getWidth, VeneerDO::getThickness,
                        VeneerDO::getBrand, VeneerDO::getSpec, VeneerDO::getFactory, VeneerDO::getNum, VeneerDO::getDefect, VeneerDO::getRemark, VeneerDO::getRemain,
                        VeneerDO::getSourcePlanNo, VeneerDO::getPlanNo, VeneerDO::getStatus, VeneerDO::getSourceVeneerNo)
                .orderByDesc(VeneerDO::getId));
    }
}
