<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.base.plan.mapper.StripMapper">

    <select id="getStripInfoList" parameterType="com.base.plan.model.dto.request.StripDTOListReqDTO"
            resultType="com.base.plan.model.entity.StripInfo">
        select * from strip_info
        <where>
            <if test="req.reqIds !=null and req.reqIds.size()>0">
                and req_id in
                <foreach collection="req.reqIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.parentIds !=null and req.parentIds.size()>0">
                and parent_id in
                <foreach collection="req.parentIds" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="req.ids != null and req.ids.size()>0">
                and id in
                <foreach collection="req.ids" index="index" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            and is_delete=1
        </where>
    </select>

    <update id="delStripByReqId" parameterType="java.util.List">
        update strip_info
        <set>
            is_delete=0
        </set>
        <where>
            <if test="req!=null and req.size()>0">
                and req_id in
                <foreach collection="req" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </update>


    <update id="updateSelectedStatus" parameterType="com.base.plan.model.dto.QuerySelectedStripUpdateDTO">
        <foreach collection="list" item="item" index="index" separator=";">
            update strip_info
            <set>
                is_selected = #{item.isSelected}
            </set>
            where id = #{item.stripId}
        </foreach>
    </update>
    <update id="initSelected" parameterType="string">
        <bind name="parentId" value="parentId + '%'" />
        update
            strip_info si
        set
            si.is_selected = 1
        <where>
            si.parent_id like #{parentId}
            and si.is_selected = 2
        </where>
    </update>
    <update id="initSelectedByList" parameterType="arraylist">
        update
            strip_info si
        set
            si.is_selected = 1
        <where>
            si.parent_id in
            <foreach collection="parentIds" item="parentId" open="(" separator="," close=")">
                #{parentId}
            </foreach>
            and
            si.is_selected = 2
        </where>

    </update>
    <update id="batchUpdateSelectedStatus">
        update
            strip_info si
        set
            si.is_selected = 2
        <where>
            si.window_id in
            <foreach collection="windowIds" item="windowId" open="(" separator="," close=")">
                #{windowId}
            </foreach>
        </where>

    </update>
</mapper>