<?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.cpms.project.plant.mapper.TMtContentMapper">

    <resultMap type="TMtContent" id="TMtContentResult">
        <result property="id"    column="id"    />
        <result property="meetingId"    column="meeting_id"    />
        <result property="agendaContent"    column="agenda_content"    />
        <result property="workType"    column="work_type"    />
        <result property="responsible"    column="responsible"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
        <result property="presided"    column="presided"    />
        <result property="isHis"    column="is_his"    />
        <result property="deadlineTime"    column="deadline_time"    />
        <result property="meetingTitle"    column="meeting_title"    />
        <result property="subject"    column="subject"    />
        <result property="meetingNo"    column="meeting_no"    />
        <result property="meetingDate"    column="meeting_date"    />
    </resultMap>

    <sql id="selectTMtContentVo">
        select id, meeting_id, agenda_content, work_type, responsible, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks, presided, is_his, deadline_time, meeting_title from t_mt_content
    </sql>

    <select id="selectTMtContentList" parameterType="TMtContent" resultMap="TMtContentResult">
        <include refid="selectTMtContentVo"/>
        <where>
            <if test="meetingId != null  and meetingId != ''"> and meeting_id = #{meetingId}</if>
            <if test="agendaContent != null  and agendaContent != ''"> and agenda_content = #{agendaContent}</if>
            <if test="workType != null  and workType != ''"> and work_type = #{workType}</if>
            <if test="responsible != null  and responsible != ''"> and responsible = #{responsible}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="presided != null  and presided != ''"> and presided = #{presided}</if>
            <if test="isHis != null "> and is_his = #{isHis}</if>
            <if test="deadlineTime != null "> and deadline_time <![CDATA[ < ]]> #{deadlineTime}</if>
            <if test="meetingTitle != null  and meetingTitle != ''"> and meeting_title = #{meetingTitle}</if>
        and del_flag = 0
        </where>
    </select>

    <select id="selectContentList" parameterType="TMtContent" resultMap="TMtContentResult">
        select a.id, a.meeting_id, a.agenda_content, a.work_type, a.responsible, a.status, a.remarks, a.presided,
        a.is_his, a.deadline_time, a.meeting_title,b.subject,b.meeting_no,b.meeting_date from t_mt_content a
        left join t_mt_meeting b on a.meeting_id=b.id
        <where>
            <if test="isHis != null ">and a.is_his = #{isHis}</if>
            <if test="deadlineTime != null ">and a.deadline_time <![CDATA[ < ]]> #{deadlineTime}</if>
            <if test="workType != null  and workType != ''">and a.work_type = #{workType}</if>
            <if test="status != null  and status != ''">and a.status = #{status}</if>
            <if test="responsible != null">and a.responsible like concat('%',#{responsible},'%')</if>
            and a.del_flag = 0
            and b.del_flag = 0
        </where>
    </select>

    <select id="selectTMtContentById" parameterType="Long" resultMap="TMtContentResult">
        <include refid="selectTMtContentVo"/>
        where id = #{id}
    </select>

    <insert id="insertTMtContent" parameterType="TMtContent" useGeneratedKeys="true" keyProperty="id">
        insert into t_mt_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="meetingId != null">meeting_id,</if>
            <if test="agendaContent != null">agenda_content,</if>
            <if test="workType != null">work_type,</if>
            <if test="responsible != null">responsible,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="presided != null">presided,</if>
            <if test="isHis != null">is_his,</if>
            <if test="deadlineTime != null">deadline_time,</if>
            <if test="meetingTitle != null">meeting_title,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="meetingId != null">#{meetingId},</if>
            <if test="agendaContent != null">#{agendaContent},</if>
            <if test="workType != null">#{workType},</if>
            <if test="responsible != null">#{responsible},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="presided != null">#{presided},</if>
            <if test="isHis != null">#{isHis},</if>
            <if test="deadlineTime != null">#{deadlineTime},</if>
            <if test="meetingTitle != null">#{meetingTitle},</if>
         </trim>
    </insert>

    <update id="updateTMtContent" parameterType="TMtContent">
        update t_mt_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="meetingId != null">meeting_id = #{meetingId},</if>
            <if test="agendaContent != null">agenda_content = #{agendaContent},</if>
            <if test="workType != null">work_type = #{workType},</if>
            <if test="responsible != null">responsible = #{responsible},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="presided != null">presided = #{presided},</if>
            <if test="isHis != null">is_his = #{isHis},</if>
            <if test="deadlineTime != null">deadline_time = #{deadlineTime},</if>
            <if test="meetingTitle != null">meeting_title = #{meetingTitle},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTMtContentById" parameterType="Long">
        update t_mt_content set del_flag=1 where id = #{id}
    </delete>

    <delete id="deleteTMtContentByIds" parameterType="String">
        update t_mt_content set del_flag=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
