<?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.CmcProjectMapper">
    
    <resultMap type="CmcProject" id="CmcProjectResult">
        <result property="projectId"    column="project_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectNumber"    column="project_number"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectCmcProjectVo">
        select project_id, project_name, project_number, status from cmc_project
    </sql>

    <select id="selectCmcProjectList" parameterType="CmcProject" resultMap="CmcProjectResult">
        <include refid="selectCmcProjectVo"/>
        <where>  
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="projectNumber != null  and projectNumber != ''"> and project_number like concat('%', #{projectNumber}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectCmcProjectByProjectId" parameterType="String" resultMap="CmcProjectResult">
        <include refid="selectCmcProjectVo"/>
        where project_id = #{projectId}
    </select>
        
    <insert id="insertCmcProject" parameterType="CmcProject">
        insert into cmc_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="projectName != null">project_name,</if>
            <if test="projectNumber != null">project_number,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="projectNumber != null">#{projectNumber},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateCmcProject" parameterType="CmcProject">
        update cmc_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="projectNumber != null">project_number = #{projectNumber},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where project_id = #{projectId}
    </update>

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

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