<?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.srs.dormitory.mapper.DmsApprovalProcessMapper">

    <resultMap type="DmsApprovalProcess" id="DmsApprovalProcessResult">
        <result property="id"    column="id"    />
        <result property="applyId"    column="apply_id"    />
        <result property="applyType"    column="apply_type"    />
        <result property="fdyNo"    column="fdy_no"    />
        <result property="fdyStatus"    column="fdy_status"    />
        <result property="fdyComment"    column="fdy_comment"    />
        <result property="fdyTime"    column="fdy_time"    />
        <result property="workNo"    column="work_no"    />
        <result property="wordkStatus"    column="wordk_status"    />
        <result property="workComment"    column="work_comment"    />
        <result property="workTime"    column="work_time"    />
        <result property="finalNo"    column="final_no"    />
        <result property="finalStatus"    column="final_status"    />
        <result property="finalComment"    column="final_comment"    />
        <result property="finalTime"    column="final_time"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDmsApprovalProcessVo">
        select id, apply_id, apply_type, fdy_no, fdy_status, fdy_comment, fdy_time, work_no, wordk_status, work_comment, work_time, final_no, final_status, final_comment, final_time, status, del_flag, create_by, create_time, update_by, update_time from dms_approval_process
    </sql>

    <select id="selectDmsApprovalProcessList" parameterType="DmsApprovalProcess" resultMap="DmsApprovalProcessResult">
        <include refid="selectDmsApprovalProcessVo"/>
        <where>
            <if test="applyId != null "> and apply_id = #{applyId}</if>
            <if test="applyType != null  and applyType != ''"> and apply_type = #{applyType}</if>
            <if test="fdyNo != null  and fdyNo != ''"> and fdy_no = #{fdyNo}</if>
            <if test="fdyStatus != null  and fdyStatus != ''"> and fdy_status = #{fdyStatus}</if>
            <if test="fdyComment != null  and fdyComment != ''"> and fdy_comment = #{fdyComment}</if>
            <if test="fdyTime != null "> and fdy_time = #{fdyTime}</if>
            <if test="workNo != null  and workNo != ''"> and work_no = #{workNo}</if>
            <if test="wordkStatus != null  and wordkStatus != ''"> and wordk_status = #{wordkStatus}</if>
            <if test="workComment != null  and workComment != ''"> and work_comment = #{workComment}</if>
            <if test="workTime != null "> and work_time = #{workTime}</if>
            <if test="finalNo != null  and finalNo != ''"> and final_no = #{finalNo}</if>
            <if test="finalStatus != null  and finalStatus != ''"> and final_status = #{finalStatus}</if>
            <if test="finalComment != null  and finalComment != ''"> and final_comment = #{finalComment}</if>
            <if test="finalTime != null "> and final_time = #{finalTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectDmsApprovalProcessById" parameterType="Long" resultMap="DmsApprovalProcessResult">
        <include refid="selectDmsApprovalProcessVo"/>
        where id = #{id}
    </select>

    <insert id="insertDmsApprovalProcess" parameterType="DmsApprovalProcess" useGeneratedKeys="true" keyProperty="id">
        insert into dms_approval_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applyId != null">apply_id,</if>
            <if test="applyType != null and applyType != ''">apply_type,</if>
            <if test="fdyNo != null">fdy_no,</if>
            <if test="fdyStatus != null">fdy_status,</if>
            <if test="fdyComment != null">fdy_comment,</if>
            <if test="fdyTime != null">fdy_time,</if>
            <if test="workNo != null">work_no,</if>
            <if test="wordkStatus != null">wordk_status,</if>
            <if test="workComment != null">work_comment,</if>
            <if test="workTime != null">work_time,</if>
            <if test="finalNo != null">final_no,</if>
            <if test="finalStatus != null">final_status,</if>
            <if test="finalComment != null">final_comment,</if>
            <if test="finalTime != null">final_time,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="applyId != null">#{applyId},</if>
            <if test="applyType != null and applyType != ''">#{applyType},</if>
            <if test="fdyNo != null">#{fdyNo},</if>
            <if test="fdyStatus != null">#{fdyStatus},</if>
            <if test="fdyComment != null">#{fdyComment},</if>
            <if test="fdyTime != null">#{fdyTime},</if>
            <if test="workNo != null">#{workNo},</if>
            <if test="wordkStatus != null">#{wordkStatus},</if>
            <if test="workComment != null">#{workComment},</if>
            <if test="workTime != null">#{workTime},</if>
            <if test="finalNo != null">#{finalNo},</if>
            <if test="finalStatus != null">#{finalStatus},</if>
            <if test="finalComment != null">#{finalComment},</if>
            <if test="finalTime != null">#{finalTime},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateDmsApprovalProcess" parameterType="DmsApprovalProcess">
        update dms_approval_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="applyId != null">apply_id = #{applyId},</if>
            <if test="applyType != null and applyType != ''">apply_type = #{applyType},</if>
            <if test="fdyNo != null">fdy_no = #{fdyNo},</if>
            <if test="fdyStatus != null">fdy_status = #{fdyStatus},</if>
            <if test="fdyComment != null">fdy_comment = #{fdyComment},</if>
            <if test="fdyTime != null">fdy_time = #{fdyTime},</if>
            <if test="workNo != null">work_no = #{workNo},</if>
            <if test="wordkStatus != null">wordk_status = #{wordkStatus},</if>
            <if test="workComment != null">work_comment = #{workComment},</if>
            <if test="workTime != null">work_time = #{workTime},</if>
            <if test="finalNo != null">final_no = #{finalNo},</if>
            <if test="finalStatus != null">final_status = #{finalStatus},</if>
            <if test="finalComment != null">final_comment = #{finalComment},</if>
            <if test="finalTime != null">final_time = #{finalTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDmsApprovalProcessById" parameterType="Long">
        delete from dms_approval_process where id = #{id}
    </delete>

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