<?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.supervision.thought.mapper.ThoughtTalkMapper">

    <resultMap type="ThoughtTalk" id="ThoughtTalkResult">
        <result property="id"    column="id"    />
        <result property="talkPeople"    column="talk_people"    />
        <result property="unitName"    column="unit_name"    />
        <result property="unitId"    column="unit_id"    />
        <result property="talkObject"    column="talk_object"    />
        <result property="talkObjectId"    column="talk_object_id"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createName"    column="create_name"    />
        <result property="createId"    column="create_id"    />
        <result property="filePath"    column="file_path"    />
        <result property="fileName"    column="file_name"    />
        <result property="talkContent"    column="talk_content"    />
        <result property="talkTime"    column="talk_time"    />
        <result property="talkAddress"    column="talk_address"    />
        <result property="recorder"    column="recorder"    />
        <result property="recorderId"    column="recorder_id"    />
        <result property="talktype"    column="talktype"    />

    </resultMap>

    <sql id="selectThoughtTalkVo">
        select id, talk_people, unit_name, unit_id, talk_object, talk_object_id, start_time, end_time, create_time, update_time, create_name, create_id, file_path, file_name, talk_content, talk_time, talk_address, recorder, recorder_id,talktype from thought_talk
    </sql>

    <select id="selectThoughtTalkList" parameterType="ThoughtTalk" resultMap="ThoughtTalkResult">
        <include refid="selectThoughtTalkVo"/>
        <where>
            <if test="talkPeople != null  and talkPeople != ''"> and talk_people = #{talkPeople}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="unitId != null "> and unit_id = #{unitId}</if>
            <if test="talkObject != null  and talkObject != ''"> and talk_object = #{talkObject}</if>
            <if test="talkObjectId != null "> and talk_object_id = #{talkObjectId}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="createName != null  and createName != ''"> and create_name like concat('%', #{createName}, '%')</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="talkContent != null  and talkContent != ''"> and talk_content = #{talkContent}</if>
            <if test="talkTime != null "> and talk_time = #{talkTime}</if>
            <if test="talkAddress != null  and talkAddress != ''"> and talk_address = #{talkAddress}</if>
            <if test="recorder != null  and recorder != ''"> and recorder = #{recorder}</if>
            <if test="recorderId != null  and recorderId != ''"> and recorder_id = #{recorderId}</if>
            <if test="talktype != null  and talktype != ''"> and talktype = #{talktype}</if>

        </where>
        order by id desc
    </select>

    <select id="selectThoughtTalkById" parameterType="Long" resultMap="ThoughtTalkResult">
        <include refid="selectThoughtTalkVo"/>
        where id = #{id}
    </select>

    <insert id="insertThoughtTalk" parameterType="ThoughtTalk" useGeneratedKeys="true" keyProperty="id">
        insert into thought_talk
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="talkPeople != null">talk_people,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="unitId != null">unit_id,</if>
            <if test="talkObject != null">talk_object,</if>
            <if test="talkObjectId != null">talk_object_id,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createName != null">create_name,</if>
            <if test="createId != null">create_id,</if>
            <if test="filePath != null">file_path,</if>
            <if test="fileName != null">file_name,</if>
            <if test="talkContent != null">talk_content,</if>
            <if test="talkTime != null">talk_time,</if>
            <if test="talkAddress != null">talk_address,</if>
            <if test="recorder != null">recorder,</if>
            <if test="recorderId != null">recorder_id,</if>
            <if test="talktype != null">talktype,</if>

         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="talkPeople != null">#{talkPeople},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="unitId != null">#{unitId},</if>
            <if test="talkObject != null">#{talkObject},</if>
            <if test="talkObjectId != null">#{talkObjectId},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createName != null">#{createName},</if>
            <if test="createId != null">#{createId},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="talkContent != null">#{talkContent},</if>
            <if test="talkTime != null">#{talkTime},</if>
            <if test="talkAddress != null">#{talkAddress},</if>
            <if test="recorder != null">#{recorder},</if>
            <if test="recorderId != null">#{recorderId},</if>
            <if test="talktype != null">#{talktype},</if>

         </trim>
    </insert>

    <update id="updateThoughtTalk" parameterType="ThoughtTalk">
        update thought_talk
        <trim prefix="SET" suffixOverrides=",">
            <if test="talkPeople != null">talk_people = #{talkPeople},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="talkObject != null">talk_object = #{talkObject},</if>
            <if test="talkObjectId != null">talk_object_id = #{talkObjectId},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createName != null">create_name = #{createName},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="talkContent != null">talk_content = #{talkContent},</if>
            <if test="talkTime != null">talk_time = #{talkTime},</if>
            <if test="talkAddress != null">talk_address = #{talkAddress},</if>
            <if test="recorder != null">recorder = #{recorder},</if>
            <if test="recorderId != null">recorder_id = #{recorderId},</if>
            <if test="talktype != null">talktype = #{talktype},</if>

        </trim>
        where id = #{id}
    </update>

    <delete id="deleteThoughtTalkById" parameterType="Long">
        delete from thought_talk where id = #{id}
    </delete>

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