package com.ruoyi.oa.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.oa.domain.OaProjectScheduleStep;
import com.ruoyi.oa.domain.vo.OaProjectScheduleStepVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.toolkit.Constants;

import java.util.Collection;
import java.util.List;

/**
 * 项目进度步骤跟踪Mapper接口
 *
 * @author hdka
 * @date 2025-05-08
 */
public interface OaProjectScheduleStepMapper extends BaseMapperPlus<OaProjectScheduleStepMapper, OaProjectScheduleStep, OaProjectScheduleStepVo> {

    Page<OaProjectScheduleStepVo> selectVoPagePlus(@Param("page")Page<Object> build, @Param(Constants.WRAPPER) QueryWrapper<OaProjectScheduleStep> lqw, @Param("userId") Long userId);

    OaProjectScheduleStepVo selectVoPlusById(@Param("trackId") Long trackId, @Param("userId") Long userId);

    OaProjectScheduleStepVo maxStepByScheduleId(Long scheduleId);

    void updateByStepAndScheduleId(@Param("currentStep") Long currentStep, @Param("scheduleId") Long scheduleId);

    OaProjectScheduleStepVo selectByCurrentStepAndScheduleId(@Param("currentStep") Long currentStep, @Param("scheduleId") Long scheduleId);

    void saveBatch(List<OaProjectScheduleStep> entities);

    /**
     * 根据 schedule_id 批量删除步骤记录
     * @param scheduleIds 主表的 schedule_id 集合
     * @return 删除的记录数
     */
    int deleteByScheduleIds(@Param("scheduleIds") Collection<Long> scheduleIds);

    Page<OaProjectScheduleStepVo> selectVoPageNew(Page<Object> build,@Param(Constants.WRAPPER) QueryWrapper<OaProjectScheduleStep> lqw);
}
