<?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.SqmyUnitReplyMapper">
    
    <resultMap type="SqmyUnitReply" id="SqmyUnitReplyResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="sqmyId"    column="sqmy_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="selectSqmyUnitReplyVo">
        select id, dept_id, dept_name, sqmy_id, is_reply, content, type, start_time, end_time, handling, degree, remark from sqmy_unit_reply
    </sql>

    <select id="selectSqmyUnitReplyList" parameterType="SqmyUnitReply" resultMap="SqmyUnitReplyResult">
        <include refid="selectSqmyUnitReplyVo"/>
        <where>  
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="sqmyId != null "> and sqmy_id = #{sqmyId}</if>
            <if test="isReply != null  and isReply != ''"> and is_reply = #{isReply}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="handling != null  and handling != ''"> and handling = #{handling}</if>
            <if test="degree != null  and degree != ''"> and degree = #{degree}</if>
        </where>
    </select>
    
    <select id="selectSqmyUnitReplyById" parameterType="Long" resultMap="SqmyUnitReplyResult">
        <include refid="selectSqmyUnitReplyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSqmyUnitReply" parameterType="SqmyUnitReply" useGeneratedKeys="true" keyProperty="id">
        insert into sqmy_unit_reply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="sqmyId != null">sqmy_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">#{deptName},</if>
            <if test="sqmyId != null">#{sqmyId},</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="updateSqmyUnitReply" parameterType="SqmyUnitReply">
        update sqmy_unit_reply
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="sqmyId != null">sqmy_id = #{sqmyId},</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>

    <delete id="deleteSqmyUnitReplyById" parameterType="Long">
        delete from sqmy_unit_reply where id = #{id}
    </delete>

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