<?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.inspect.patrol.mapper.PatrolLinkageStrategyReverseMapper">
    
    <resultMap type="PatrolLinkageStrategyReverse" id="PatrolLinkageStrategyReverseResult">
        <result property="linkageStrategyReverseId"    column="linkage_strategy_reverse_id"    />
        <result property="linkageStrategyId"    column="linkage_strategy_id"    />
        <result property="linkagePosId"    column="linkage_pos_id"    />
        <result property="command"    column="command"    />
        <result property="isEnable"    column="is_enable"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPatrolLinkageStrategyReverseVo">
        select linkage_strategy_reverse_id, linkage_strategy_id, linkage_pos_id, command, is_enable, create_time from patrol_linkage_strategy_reverse
    </sql>

    <select id="selectPatrolLinkageStrategyReverseList" parameterType="PatrolLinkageStrategyReverse" resultMap="PatrolLinkageStrategyReverseResult">
        <include refid="selectPatrolLinkageStrategyReverseVo"/>
        <where>  
            <if test="linkageStrategyId != null "> and linkage_strategy_id = #{linkageStrategyId}</if>
            <if test="linkagePosId != null "> and linkage_pos_id = #{linkagePosId}</if>
            <if test="command != null  and command != ''"> and command = #{command}</if>
            <if test="isEnable != null  and isEnable != ''"> and is_enable = #{isEnable}</if>
        </where>
    </select>
    
    <select id="selectPatrolLinkageStrategyReverseByLinkageStrategyReverseId" parameterType="Long" resultMap="PatrolLinkageStrategyReverseResult">
        <include refid="selectPatrolLinkageStrategyReverseVo"/>
        where linkage_strategy_reverse_id = #{linkageStrategyReverseId}
    </select>
        
    <insert id="insertPatrolLinkageStrategyReverse" parameterType="PatrolLinkageStrategyReverse" useGeneratedKeys="true" keyProperty="linkageStrategyReverseId">
        insert into patrol_linkage_strategy_reverse
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="linkageStrategyId != null">linkage_strategy_id,</if>
            <if test="linkagePosId != null">linkage_pos_id,</if>
            <if test="command != null">command,</if>
            <if test="isEnable != null">is_enable,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="linkageStrategyId != null">#{linkageStrategyId},</if>
            <if test="linkagePosId != null">#{linkagePosId},</if>
            <if test="command != null">#{command},</if>
            <if test="isEnable != null">#{isEnable},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <insert id="insertPatrolLinkageStrategyReverses" parameterType="List">
        insert into patrol_linkage_strategy_reverse (linkage_strategy_id,linkage_pos_id,command,create_time) values
        <foreach item="item" collection="list" separator="," >
            (#{item.linkageStrategyId},#{item.linkagePosId},#{item.command},#{item.createTime})
        </foreach>
    </insert>
    <update id="updatePatrolLinkageStrategyReverse" parameterType="PatrolLinkageStrategyReverse">
        update patrol_linkage_strategy_reverse
        <trim prefix="SET" suffixOverrides=",">
            <if test="linkageStrategyId != null">linkage_strategy_id = #{linkageStrategyId},</if>
            <if test="linkagePosId != null">linkage_pos_id = #{linkagePosId},</if>
            <if test="command != null">command = #{command},</if>
            <if test="isEnable != null">is_enable = #{isEnable},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where linkage_strategy_reverse_id = #{linkageStrategyReverseId}
    </update>

    <delete id="deletePatrolLinkageStrategyReverseByLinkageStrategyReverseId" parameterType="Long">
        delete from patrol_linkage_strategy_reverse where linkage_strategy_id = #{linkageStrategyId}
    </delete>

    <delete id="deletePatrolLinkageStrategyReverseByLinkageStrategyReverseIds" parameterType="String">
        delete from patrol_linkage_strategy_reverse where linkage_strategy_reverse_id in
        <foreach item="linkageStrategyReverseId" collection="array" open="(" separator="," close=")">
            #{linkageStrategyReverseId}
        </foreach>
    </delete>
</mapper>