<?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.ruoyi.system.mapper.InvestigateDispositionTableMapper">
    
    <resultMap type="InvestigateDispositionTable" id="InvestigateDispositionTableResult">
        <result property="investigateTableId"    column="investigate_table_id"    />
        <result property="investigateDispositionId"    column="investigate_disposition_id"    />
        <result property="url"    column="url"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="investigateName"    column="investigate_name"    />
        <result property="endTime"    column="end_time"    />
        <result property="cipher"    column="cipher"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />

    </resultMap>

    <sql id="selectInvestigateDispositionTableVo">
        select investigate_table_id, investigate_disposition_id,url,content from investigate_disposition_table
    </sql>

    <select id="selectInvestigateDispositionTableList" parameterType="InvestigateDispositionTable" resultMap="InvestigateDispositionTableResult">
        SELECT
        t.investigate_table_id,
        t.investigate_disposition_id,
        t.url,
        t.title,
        t.content,
        it.investigate_name,
        it.end_time,
        it.create_time,
        it.create_by,
        it.cipher
        FROM
        investigate_disposition_table t
        left join investigate_table it on it.investigate_table_id = t.investigate_table_id
        <where>
            <if test="investigateTableId != null  "> and t.investigate_table_id = #{investigateTableId}</if>
            <if test="investigateDispositionId != null  "> and t.investigate_disposition_id = #{investigateDispositionId}</if>
        </where>

        order  by it.create_time DESC

    </select>
    
    <select id="selectInvestigateDispositionTableByInvestigateTableId" parameterType="Long" resultMap="InvestigateDispositionTableResult">
        <include refid="selectInvestigateDispositionTableVo"/>
        where investigate_table_id = #{investigateTableId}
    </select>
        
    <insert id="insertInvestigateDispositionTable" parameterType="InvestigateDispositionTable">
        insert into investigate_disposition_table
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="investigateTableId != null">investigate_table_id,</if>
            <if test="investigateDispositionId != null">investigate_disposition_id,</if>
            <if test="url != null">url,</if>
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="investigateTableId != null">#{investigateTableId},</if>
            <if test="investigateDispositionId != null">#{investigateDispositionId},</if>
            <if test="url != null">#{url},</if>
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
         </trim>
    </insert>

    <update id="updateInvestigateDispositionTable" parameterType="InvestigateDispositionTable">
        update investigate_disposition_table
        <trim prefix="SET" suffixOverrides=",">
            <if test="investigateDispositionId != null">investigate_disposition_id = #{investigateDispositionId},</if>
            <if test="investigateTableId != null">investigate_table_id = #{investigateTableId},</if>
            <if test="url != null">url = #{url},</if>
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
        </trim>
        where investigate_table_id = #{investigateTableId} and investigate_disposition_id = #{investigateDispositionId}
    </update>

    <delete id="deleteInvestigateDispositionTableByInvestigateTableId" parameterType="Long">
        delete from investigate_disposition_table where investigate_table_id = #{investigateTableId}
    </delete>

    <delete id="deleteInvestigateDispositionTableByInvestigateTableIds" parameterType="InvestigateDispositionTable">
        delete from investigate_disposition_table where investigate_table_id =

            #{investigateTableId} and investigate_disposition_id = #{investigateDispositionId}

    </delete>

    <insert id="batchDispositionTable">
        insert into investigate_disposition_table(investigate_table_id, investigate_disposition_id,url,content,title) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.investigateTableId},#{item.investigateDispositionId},#{item.url},#{item.content},#{item.title})
        </foreach>
    </insert>
</mapper>