<?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.bonus.material.scrap.mapper.ScrapAuditorSetMapper">
    <resultMap type="com.bonus.material.scrap.domain.ScrapAuditorSet" id="ScrapAuditorSetResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="status"    column="status"    />
        <result property="companyId"    column="company_id"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="reasonRejection"    column="reason_rejection"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectScrapAuditorSetVo">
        select id, task_id, dept_id, user_id, status, company_id, audit_time, reason_rejection, create_time, update_time from scrap_auditor_set
    </sql>

    <select id="selectScrapAuditorSetList" parameterType="com.bonus.material.scrap.domain.ScrapAuditorSet" resultMap="ScrapAuditorSetResult">
        <include refid="selectScrapAuditorSetVo"/>
        <where>  
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="reasonRejection != null  and reasonRejection != ''"> and reason_rejection = #{reasonRejection}</if>
        </where>
    </select>
    
    <select id="selectScrapAuditorSetById" parameterType="Long" resultMap="ScrapAuditorSetResult">
        <include refid="selectScrapAuditorSetVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertScrapAuditorSet" parameterType="com.bonus.material.scrap.domain.ScrapAuditorSet" useGeneratedKeys="true" keyProperty="id">
        insert into scrap_auditor_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="status != null">status,</if>
            <if test="companyId != null">company_id,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="reasonRejection != null">reason_rejection,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="status != null">#{status},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="reasonRejection != null">#{reasonRejection},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateScrapAuditorSet" parameterType="com.bonus.material.scrap.domain.ScrapAuditorSet">
        update scrap_auditor_set
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="reasonRejection != null">reason_rejection = #{reasonRejection},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteScrapAuditorSetById" parameterType="Long">
        delete from scrap_auditor_set where id = #{id}
    </delete>

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