package com.base.plan.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.plan.model.dto.StepWindowDTO;
import com.base.plan.model.entity.StepWindowRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface StepWindowRelationMapper extends BaseMapper<StepWindowRelation> {

    List<StepWindowDTO> selectIsUsedStepWindowDTOList(@Param("list") List<String> list, Integer isConfirm);

    default void deleteByStepIds(List<String> list){
        this.delete(new QueryWrapper<StepWindowRelation>().in("step_id",list));
    }

    default List<StepWindowRelation> selectByStepId(String stepId,Integer isConfirm){
        return this.selectList(new QueryWrapper<StepWindowRelation>().eq("step_id",stepId).eq("is_confirm",isConfirm));
    }

    void batchInsert(@Param("list") List<StepWindowRelation> list);

    default void confirmWindow(List<String> list){
        this.update(null, new UpdateWrapper<StepWindowRelation>().set("is_confirm",1).in("step_id",list));
    }
}
