package com.sky.ioc.mapper.scene;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.ioc.entity.domain.scene.Strategy;
import com.sky.ioc.entity.params.IocParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StrategyMapper extends BaseMapper<Strategy> {

    @Select("<script>" +
            "select * from strategy where is_del = 0 " +
            "<if test='type!=null '> " +
            " and type = #{type} " +
            "</if>" +
            "<if test ='status!=null '>" +
            " and status = #{status}" +
            "</if>" +
            "<if test ='name!=null and name!=\"\" '>" +
            " and name like  #{name}" +
            "</if>" +
            "</script>")
    List<Strategy> getListByNameAndTypeAndStatus(@Param("type") Integer type, @Param("status") Integer status,
                                                 @Param("name")String name);

   @Update("update strategy set is_del = 1 where id=#{id}")
    Integer delById(@Param("id") Integer id);

    @Update("<script>" +
            " update strategy set is_del= 1  " +
            " where id in (<foreach collection='ids' item='id' index='no' separator=','>#{id}</foreach>) "

            + "</script>")
    Integer batchDelByIds(@Param("ids") List<Integer> ids);
}
