package com.yhy.module.core.dal.mysql.workbench;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yhy.module.core.dal.dataobject.workbench.ProgressDivisionDO;
import java.util.Collection;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;

/**
 * 进度款-清单关联 Mapper
 *
 * @author yhy
 */
@Mapper
public interface ProgressDivisionMapper extends BaseMapperX<ProgressDivisionDO> {

    /**
     * 根据进度款模式ID查询关联列表
     */
    default List<ProgressDivisionDO> selectListByProgressPaymentModeId(Long progressPaymentModeId) {
        return selectList(new LambdaQueryWrapperX<ProgressDivisionDO>()
                .eq(ProgressDivisionDO::getProgressPaymentModeId, progressPaymentModeId));
    }

    /**
     * 根据清单节点ID查询关联列表
     */
    default List<ProgressDivisionDO> selectListByBoqDivisionId(Long boqDivisionId) {
        return selectList(new LambdaQueryWrapperX<ProgressDivisionDO>()
                .eq(ProgressDivisionDO::getBoqDivisionId, boqDivisionId));
    }

    /**
     * 根据进度款模式ID和清单节点ID查询
     */
    default ProgressDivisionDO selectByPaymentModeIdAndBoqDivisionId(Long progressPaymentModeId, Long boqDivisionId) {
        return selectOne(new LambdaQueryWrapperX<ProgressDivisionDO>()
                .eq(ProgressDivisionDO::getProgressPaymentModeId, progressPaymentModeId)
                .eq(ProgressDivisionDO::getBoqDivisionId, boqDivisionId));
    }

    /**
     * 根据进度款模式ID删除所有关联
     */
    default int deleteByProgressPaymentModeId(Long progressPaymentModeId) {
        return delete(new LambdaQueryWrapperX<ProgressDivisionDO>()
                .eq(ProgressDivisionDO::getProgressPaymentModeId, progressPaymentModeId));
    }

    /**
     * 根据进度款模式ID列表批量查询关联列表
     */
    default List<ProgressDivisionDO> selectListByProgressPaymentModeIds(Collection<Long> progressPaymentModeIds) {
        return selectList(new LambdaQueryWrapperX<ProgressDivisionDO>()
                .in(ProgressDivisionDO::getProgressPaymentModeId, progressPaymentModeIds));
    }
}
