<?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.CmcProjectContractMapper">
    
    <resultMap type="CmcProjectContract" id="CmcProjectContractResult">
        <result property="projectId"    column="project_id"    />
        <result property="contractId"    column="contract_id"    />
    </resultMap>

    <sql id="selectCmcProjectContractVo">
        select project_id, contract_id from cmc_project_contract
    </sql>

    <select id="selectCmcProjectContractList" parameterType="CmcProjectContract" resultMap="CmcProjectContractResult">
        <include refid="selectCmcProjectContractVo"/>
        <where>
            <if test="projectId != null  and projectId != ''"> and project_id = #{projectId}</if>
            <if test="contractId != null  and contractId != ''"> and contract_id = #{contractId}</if>
        </where>
    </select>
    
    <select id="selectCmcProjectContractByProjectId" parameterType="String" resultMap="CmcProjectContractResult">
        <include refid="selectCmcProjectContractVo"/>
        where project_id = #{projectId}
    </select>
        
    <insert id="insertCmcProjectContract" parameterType="CmcProjectContract">
        insert into cmc_project_contract
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="contractId != null">contract_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="contractId != null">#{contractId},</if>
         </trim>
    </insert>

    <update id="updateCmcProjectContract" parameterType="CmcProjectContract">
        update cmc_project_contract
        <trim prefix="SET" suffixOverrides=",">
            <if test="contractId != null">contract_id = #{contractId},</if>
        </trim>
        where project_id = #{projectId}
    </update>

    <delete id="deleteCmcProjectContractByProjectId" parameterType="String">
        delete from cmc_project_contract where project_id = #{projectId}
    </delete>

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