package com.zt.plat.module.base.dal.dao.processingoperationmaterial;

import java.util.*;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.controller.admin.processinginfomationoperation.vo.ProcessingInfomationOperationOrganizationPageReqVO;
import com.zt.plat.module.base.dal.dataobject.processingoperationmaterial.ProcessingOperationMaterialDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.processingoperationmaterial.vo.*;

/**
 * 工艺工序物料 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface ProcessingOperationMaterialMapper extends BaseMapperX<ProcessingOperationMaterialDO> {

    default PageResult<ProcessingOperationMaterialDO> selectPage(ProcessingOperationMaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProcessingOperationMaterialDO>()
                .eqIfPresent(ProcessingOperationMaterialDO::getTypeValue, reqVO.getTypeValue())
                .eqIfPresent(ProcessingOperationMaterialDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ProcessingOperationMaterialDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProcessingOperationMaterialDO::getDepartmentIds, reqVO.getDepartmentIds())
                .orderByDesc(ProcessingOperationMaterialDO::getId));
    }

    default void deleteByProcessingOperationId(Long processingOperationId) {
        if (processingOperationId == null) {
            return;
        }
        delete(new LambdaQueryWrapperX<ProcessingOperationMaterialDO>()
                .eq(ProcessingOperationMaterialDO::getProcessingOperationId, processingOperationId));
    }

    default void deleteByProcessingOperationIds(Collection<Long> processingOperationIds) {
        if (processingOperationIds == null || processingOperationIds.isEmpty()) {
            return;
        }
        delete(new LambdaQueryWrapperX<ProcessingOperationMaterialDO>()
                .in(ProcessingOperationMaterialDO::getProcessingOperationId, processingOperationIds));
    }

    default List<ProcessingOperationMaterialDO> selectListByProcessingOperationIds(Collection<Long> processingOperationIds) {
        if (processingOperationIds == null || processingOperationIds.isEmpty()) {
            return Collections.emptyList();
        }
        return selectList(new LambdaQueryWrapperX<ProcessingOperationMaterialDO>()
                .in(ProcessingOperationMaterialDO::getProcessingOperationId, processingOperationIds));
    }

    default List<ProcessingOperationMaterialDO> selectOrganizationList(ProcessingInfomationOperationOrganizationPageReqVO reqVO) {
        return selectList();
    }

}