<?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.TSuperviseMapper">
    
    <resultMap type="TSupervise" id="TSuperviseResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="resultContent"    column="result_content"    />
        <result property="person"    column="person"    />
        <result property="address"    column="address"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="pictrueUrl"    column="pictrue_url"    />
        <result property="vedioUrl"    column="vedio_url"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTSuperviseVo">
        select id, title, content, result_content, person, address, longitude, latitude, enterprise_id, pictrue_url, vedio_url, create_time from t_supervise
    </sql>

    <select id="selectTSuperviseList" parameterType="TSupervise" resultMap="TSuperviseResult">
        <include refid="selectTSuperviseVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="person != null  and person != ''"> and person like concat('%', #{person}, '%') </if>
            <if test="enterpriseId != null "> and enterprise_id = #{enterpriseId}</if>
        </where>
    </select>
    
    <select id="selectTSuperviseById" parameterType="Long" resultMap="TSuperviseResult">
        <include refid="selectTSuperviseVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSupervise" parameterType="TSupervise" useGeneratedKeys="true" keyProperty="id">
        insert into t_supervise
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="resultContent != null">result_content,</if>
            <if test="person != null">person,</if>
            <if test="address != null">address,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="pictrueUrl != null">pictrue_url,</if>
            <if test="vedioUrl != null">vedio_url,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="resultContent != null">#{resultContent},</if>
            <if test="person != null">#{person},</if>
            <if test="address != null">#{address},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="enterpriseId != null">#{enterpriseId},</if>
            <if test="pictrueUrl != null">#{pictrueUrl},</if>
            <if test="vedioUrl != null">#{vedioUrl},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTSupervise" parameterType="TSupervise">
        update t_supervise
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="resultContent != null">result_content = #{resultContent},</if>
            <if test="person != null">person = #{person},</if>
            <if test="address != null">address = #{address},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="pictrueUrl != null">pictrue_url = #{pictrueUrl},</if>
            <if test="vedioUrl != null">vedio_url = #{vedioUrl},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTSuperviseById" parameterType="Long">
        delete from t_supervise where id = #{id}
    </delete>

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