<?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.zehong.system.mapper.TComplainDealOverSuperMapper">
    
    <resultMap type="TComplainDealOverSuper" id="TComplainDealOverSuperResult">
        <result property="complainDealOverSuperId"    column="complain_deal_over_super_id"    />
        <result property="complainDealId"    column="complain_deal_id"    />
        <result property="supervisionReasons"    column="supervision_reasons"    />
        <result property="concent"    column="concent"    />
        <result property="overtimeSupervision"    column="overtime_supervision"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTComplainDealOverSuperVo">
        select complain_deal_over_super_id, complain_deal_id, supervision_reasons, concent, overtime_supervision, create_by, create_time from t_complain_deal_over_super
    </sql>

    <select id="selectTComplainDealOverSuperList" parameterType="TComplainDealOverSuper" resultMap="TComplainDealOverSuperResult">
        <include refid="selectTComplainDealOverSuperVo"/>
        <where>  
            <if test="complainDealId != null "> and complain_deal_id = #{complainDealId}</if>
            <if test="supervisionReasons != null  and supervisionReasons != ''"> and supervision_reasons = #{supervisionReasons}</if>
            <if test="concent != null  and concent != ''"> and concent = #{concent}</if>
            <if test="overtimeSupervision != null  and overtimeSupervision != ''"> and overtime_supervision = #{overtimeSupervision}</if>
        </where>
    </select>
    
    <select id="selectTComplainDealOverSuperById" parameterType="Long" resultMap="TComplainDealOverSuperResult">
        <include refid="selectTComplainDealOverSuperVo"/>
        where complain_deal_over_super_id = #{complainDealOverSuperId}
    </select>
    <select id="getOverSuperByComplainDealIdAndStatus" resultMap="TComplainDealOverSuperResult">
        <include refid="selectTComplainDealOverSuperVo"/>
        where complain_deal_id= #{complainDealId} and overtime_supervision = #{overtimeSupervision}
    </select>
        
    <insert id="insertTComplainDealOverSuper" parameterType="TComplainDealOverSuper" useGeneratedKeys="true" keyProperty="complainDealOverSuperId">
        insert into t_complain_deal_over_super
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="complainDealId != null">complain_deal_id,</if>
            <if test="supervisionReasons != null">supervision_reasons,</if>
            <if test="concent != null">concent,</if>
            <if test="overtimeSupervision != null">overtime_supervision,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="complainDealId != null">#{complainDealId},</if>
            <if test="supervisionReasons != null">#{supervisionReasons},</if>
            <if test="concent != null">#{concent},</if>
            <if test="overtimeSupervision != null">#{overtimeSupervision},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTComplainDealOverSuper" parameterType="TComplainDealOverSuper">
        update t_complain_deal_over_super
        <trim prefix="SET" suffixOverrides=",">
            <if test="complainDealId != null">complain_deal_id = #{complainDealId},</if>
            <if test="supervisionReasons != null">supervision_reasons = #{supervisionReasons},</if>
            <if test="concent != null">concent = #{concent},</if>
            <if test="overtimeSupervision != null">overtime_supervision = #{overtimeSupervision},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where complain_deal_over_super_id = #{complainDealOverSuperId}
    </update>

    <delete id="deleteTComplainDealOverSuperById" parameterType="Long">
        delete from t_complain_deal_over_super where complain_deal_over_super_id = #{complainDealOverSuperId}
    </delete>

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