<?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.ruoyi.project.process.mapper.TMocMapper">
    
    <resultMap type="TMoc" id="TMocResult">
        <result property="id"    column="id"    />
        <result property="mocNo"    column="moc_no"    />
        <result property="mocOwner"    column="moc_owner"    />
        <result property="changeName"    column="change_name"    />
        <result property="tOrP"    column="t_or_p"    />
        <result property="issueDate"    column="issue_date"    />
        <result property="emocStatus"    column="emoc_status"    />
        <result property="priority"    column="priority"    />
        <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="selectTMocVo">
        select id, moc_no, moc_owner, change_name, t_or_p, issue_date, emoc_status, priority, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id from t_moc
    </sql>

    <select id="selectTMocList" parameterType="TMoc" resultMap="TMocResult">
        <include refid="selectTMocVo"/>
        <where>  
            <if test="mocNo != null  and mocNo != ''"> and moc_no = #{mocNo}</if>
            <if test="mocOwner != null  and mocOwner != ''"> and moc_owner = #{mocOwner}</if>
            <if test="changeName != null  and changeName != ''"> and change_name like concat('%', #{changeName}, '%')</if>
            <if test="tOrP != null  and tOrP != ''"> and t_or_p = #{tOrP}</if>
            <if test="issueDate != null "> and issue_date = #{issueDate}</if>
            <if test="emocStatus != null  and emocStatus != ''"> and emoc_status = #{emocStatus}</if>
            <if test="priority != null  and priority != ''"> and priority = #{priority}</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>
        </where>
    </select>
    
    <select id="selectTMocById" parameterType="Long" resultMap="TMocResult">
        <include refid="selectTMocVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTMoc" parameterType="TMoc">
        insert into t_moc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="mocNo != null and mocNo != ''">moc_no,</if>
            <if test="mocOwner != null">moc_owner,</if>
            <if test="changeName != null">change_name,</if>
            <if test="tOrP != null">t_or_p,</if>
            <if test="issueDate != null">issue_date,</if>
            <if test="emocStatus != null">emoc_status,</if>
            <if test="priority != null">priority,</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="id != null">#{id},</if>
            <if test="mocNo != null and mocNo != ''">#{mocNo},</if>
            <if test="mocOwner != null">#{mocOwner},</if>
            <if test="changeName != null">#{changeName},</if>
            <if test="tOrP != null">#{tOrP},</if>
            <if test="issueDate != null">#{issueDate},</if>
            <if test="emocStatus != null">#{emocStatus},</if>
            <if test="priority != null">#{priority},</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="updateTMoc" parameterType="TMoc">
        update t_moc
        <trim prefix="SET" suffixOverrides=",">
            <if test="mocNo != null and mocNo != ''">moc_no = #{mocNo},</if>
            <if test="mocOwner != null">moc_owner = #{mocOwner},</if>
            <if test="changeName != null">change_name = #{changeName},</if>
            <if test="tOrP != null">t_or_p = #{tOrP},</if>
            <if test="issueDate != null">issue_date = #{issueDate},</if>
            <if test="emocStatus != null">emoc_status = #{emocStatus},</if>
            <if test="priority != null">priority = #{priority},</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="deleteTMocById" parameterType="Long">
        delete from t_moc where id = #{id}
    </delete>

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