<?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.process.mapper.TClassdOverviewMapper">
    
    <resultMap type="TClassdOverview" id="TClassdOverviewResult">
        <result property="id"    column="id"    />
        <result property="discussionItem"    column="discussion_item"    />
        <result property="hazard"    column="hazard"    />
        <result property="cause"    column="cause"    />
        <result property="consequence"    column="consequence"    />
        <result property="p"    column="p"    />
        <result property="justificationP"    column="justification_p"    />
        <result property="s"    column="s"    />
        <result property="justificationS"    column="justification_s"    />
        <result property="rc"    column="rc"    />
        <result property="countermeasure"    column="countermeasure"    />
        <result property="remarks"    column="remarks"    />
        <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"    />
    </resultMap>

    <sql id="selectTClassdOverviewVo">
        select id, discussion_item, hazard, cause, consequence, p, justification_p, s, justification_s, rc, countermeasure, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_classd_overview
    </sql>

    <select id="selectTClassdOverviewList" parameterType="TClassdOverview" resultMap="TClassdOverviewResult">
        <include refid="selectTClassdOverviewVo"/>
        <where>  
            <if test="discussionItem != null  and discussionItem != ''"> and discussion_item = #{discussionItem}</if>
            <if test="hazard != null  and hazard != ''"> and hazard = #{hazard}</if>
            <if test="cause != null  and cause != ''"> and cause = #{cause}</if>
            <if test="consequence != null  and consequence != ''"> and consequence = #{consequence}</if>
            <if test="p != null  and p != ''"> and p = #{p}</if>
            <if test="justificationP != null  and justificationP != ''"> and justification_p = #{justificationP}</if>
            <if test="s != null  and s != ''"> and s = #{s}</if>
            <if test="justificationS != null  and justificationS != ''"> and justification_s = #{justificationS}</if>
            <if test="rc != null  and rc != ''"> and rc = #{rc}</if>
            <if test="countermeasure != null  and countermeasure != ''"> and countermeasure = #{countermeasure}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</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>
        and del_flag=0
        </where>
        order by createdate desc
    </select>
    
    <select id="selectTClassdOverviewById" parameterType="Long" resultMap="TClassdOverviewResult">
        <include refid="selectTClassdOverviewVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTClassdOverview" parameterType="TClassdOverview"  useGeneratedKeys="true" keyProperty="id">
        insert into t_classd_overview
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="discussionItem != null">discussion_item,</if>
            <if test="hazard != null">hazard,</if>
            <if test="cause != null">cause,</if>
            <if test="consequence != null">consequence,</if>
            <if test="p != null">p,</if>
            <if test="justificationP != null">justification_p,</if>
            <if test="s != null">s,</if>
            <if test="justificationS != null">justification_s,</if>
            <if test="rc != null">rc,</if>
            <if test="countermeasure != null">countermeasure,</if>
            <if test="remarks != null">remarks,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="discussionItem != null">#{discussionItem},</if>
            <if test="hazard != null">#{hazard},</if>
            <if test="cause != null">#{cause},</if>
            <if test="consequence != null">#{consequence},</if>
            <if test="p != null">#{p},</if>
            <if test="justificationP != null">#{justificationP},</if>
            <if test="s != null">#{s},</if>
            <if test="justificationS != null">#{justificationS},</if>
            <if test="rc != null">#{rc},</if>
            <if test="countermeasure != null">#{countermeasure},</if>
            <if test="remarks != null">#{remarks},</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>
         </trim>
    </insert>

    <update id="updateTClassdOverview" parameterType="TClassdOverview">
        update t_classd_overview
        <trim prefix="SET" suffixOverrides=",">
            <if test="discussionItem != null">discussion_item = #{discussionItem},</if>
            <if test="hazard != null">hazard = #{hazard},</if>
            <if test="cause != null">cause = #{cause},</if>
            <if test="consequence != null">consequence = #{consequence},</if>
            <if test="p != null">p = #{p},</if>
            <if test="justificationP != null">justification_p = #{justificationP},</if>
            <if test="s != null">s = #{s},</if>
            <if test="justificationS != null">justification_s = #{justificationS},</if>
            <if test="rc != null">rc = #{rc},</if>
            <if test="countermeasure != null">countermeasure = #{countermeasure},</if>
            <if test="remarks != null">remarks = #{remarks},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTClassdOverviewById" parameterType="Long">
        delete from t_classd_overview where id = #{id}
    </delete>

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