<?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.oa.mapper.CmcOutsourceWorkMapper">
    
    <resultMap type="CmcOutsourceWork" id="CmcOutsourceWorkResult">
        <result property="workId"    column="work_id"    />
        <result property="outsourceId"    column="outsource_id"    />
        <result property="content"    column="content"    />
        <result property="scale"    column="scale"    />
        <result property="unit"    column="unit"    />
        <result property="workload"    column="workload"    />
        <result property="deadline"    column="deadline"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCmcOutsourceWorkVo">
        select work_id, outsource_id, content, scale, unit, workload, deadline, remark from cmc_outsource_work
    </sql>

    <select id="selectCmcOutsourceWorkList" parameterType="CmcOutsourceWork" resultMap="CmcOutsourceWorkResult">
        <include refid="selectCmcOutsourceWorkVo"/>
        <where>  
            <if test="outsourceId != null  and outsourceId != ''"> and outsource_id = #{outsourceId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="scale != null  and scale != ''"> and scale = #{scale}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="workload != null  and workload != ''"> and workload = #{workload}</if>
            <if test="deadline != null "> and deadline = #{deadline}</if>
        </where>
    </select>
    
    <select id="selectCmcOutsourceWorkByWorkId" parameterType="Integer" resultMap="CmcOutsourceWorkResult">
        <include refid="selectCmcOutsourceWorkVo"/>
        where work_id = #{workId}
    </select>
        
    <insert id="insertCmcOutsourceWork" parameterType="CmcOutsourceWork">
        insert into cmc_outsource_work
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workId != null">work_id,</if>
            <if test="outsourceId != null">outsource_id,</if>
            <if test="content != null">content,</if>
            <if test="scale != null">scale,</if>
            <if test="unit != null">unit,</if>
            <if test="workload != null">workload,</if>
            <if test="deadline != null">deadline,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workId != null">#{workId},</if>
            <if test="outsourceId != null">#{outsourceId},</if>
            <if test="content != null">#{content},</if>
            <if test="scale != null">#{scale},</if>
            <if test="unit != null">#{unit},</if>
            <if test="workload != null">#{workload},</if>
            <if test="deadline != null">#{deadline},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCmcOutsourceWork" parameterType="CmcOutsourceWork">
        update cmc_outsource_work
        <trim prefix="SET" suffixOverrides=",">
            <if test="outsourceId != null">outsource_id = #{outsourceId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="scale != null">scale = #{scale},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="workload != null">workload = #{workload},</if>
            <if test="deadline != null">deadline = #{deadline},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where work_id = #{workId}
    </update>

    <delete id="deleteCmcOutsourceWorkByWorkId" parameterType="Integer">
        delete from cmc_outsource_work where work_id = #{workId}
    </delete>

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