<?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.ProposalUnitReplyMapper">
    
    <resultMap type="ProposalUnitReply" id="ProposalUnitReplyResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="proposalId"    column="proposal_id"    />
        <result property="isReply"    column="is_reply"    />
        <result property="content"    column="content"    />
        <result property="type"    column="type"    />

        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="handling"    column="handling"    />
        <result property="degree"    column="degree"    />

        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProposalUnitReplyVo">
        select id, dept_id,dept_name, proposal_id,is_reply, content, type,start_time,end_time,handling,degree, remark from proposal_unit_reply
    </sql>

    <select id="selectProposalUnitReplyList" parameterType="ProposalUnitReply" resultMap="ProposalUnitReplyResult">
        <include refid="selectProposalUnitReplyVo"/>
        <where>  
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="proposalId != null "> and proposal_id = #{proposalId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="isReply != null  and isReply != ''"> and is_reply = #{isReply}</if>
        </where>
    </select>
    
    <select id="selectProposalUnitReplyById" parameterType="Long" resultMap="ProposalUnitReplyResult">
        <include refid="selectProposalUnitReplyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProposalUnitReply" parameterType="ProposalUnitReply" useGeneratedKeys="true" keyProperty="id">
        insert into proposal_unit_reply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null and deptName != ''">dept_name,</if>
            <if test="proposalId != null">proposal_id,</if>
            <if test="isReply != null  ">is_reply ,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="type != null">type,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="handling != null">handling,</if>
            <if test="degree != null">degree,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null and deptName != ''">#{deptName},</if>
            <if test="proposalId != null">#{proposalId},</if>
            <if test="isReply != null  ">#{isReply},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="type != null">#{type},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="handling != null">#{handling},</if>
            <if test="degree != null">#{degree},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProposalUnitReply" parameterType="ProposalUnitReply">
        update proposal_unit_reply
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null and deptName != ''">dept_name= #{deptName},</if>
            <if test="proposalId != null">proposal_id = #{proposalId},</if>
            <if test="isReply != null  "> is_reply = #{isReply},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="type != null">type = #{type},</if>
            <if test="startTime != null">start_time= #{startTime},</if>
            <if test="endTime != null">end_time= #{endTime},</if>
            <if test="handling != null">handling= #{handling},</if>
            <if test="degree != null">degree= #{degree},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>
    <update id="updateContent" parameterType="ProposalUnitReply">
        update proposal_unit_reply
        <trim prefix="SET" suffixOverrides=",">
            <if test="content != null and content != ''">content = #{content},</if>
        </trim>
        where dept_id = #{deptId} and >proposal_id = #{proposalId}
    </update>

    <delete id="deleteProposalUnitReplyById" parameterType="Long">
        delete from proposal_unit_reply where id = #{id}
    </delete>

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