<?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.system.mapper.SysProjectMapper">
    
    <resultMap type="SysProject" id="SysProjectResult">
        <result property="id"    column="id"    />
        <result property="projectCode"    column="project_code"    />
        <result property="projectName"    column="project_name"    />
        <result property="overdueDate"    column="overdue_date"    />
    </resultMap>

    <sql id="selectSysProjectVo">
        select id, project_code, project_name, overdue_date from sys_project
    </sql>

    <select id="selectSysProjectList" parameterType="SysProject" resultMap="SysProjectResult">
        <include refid="selectSysProjectVo"/>
        <where>  
            <if test="projectCode != null  and projectCode != ''"> and project_code = #{projectCode}</if>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
        </where>
    </select>
    
    <select id="selectSysProjectById" parameterType="Long" resultMap="SysProjectResult">
        <include refid="selectSysProjectVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysProject" parameterType="SysProject" useGeneratedKeys="true" keyProperty="id">
        insert into sys_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectCode != null">project_code,</if>
            <if test="projectName != null">project_name,</if>
            <if test="overdueDate != null">overdue_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectCode != null">#{projectCode},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="overdueDate != null">#{overdueDate},</if>
         </trim>
    </insert>

    <update id="updateSysProject" parameterType="SysProject">
        update sys_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectCode != null">project_code = #{projectCode},</if>
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="overdueDate != null">overdue_date = #{overdueDate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysProjectById" parameterType="Long">
        delete from sys_project where id = #{id}
    </delete>

    <delete id="deleteSysProjectByIds" parameterType="String">
        delete from sys_project where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectSysProjectAllList" resultMap="SysProjectResult">
        select id, project_name from sys_project where id not in(select project_id from sys_secret_project)
    </select>
</mapper>