<?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.generator.mapper.GenProjectMapper">
    
    <resultMap type="GenProject" id="GenProjectResult">
        <result property="projectId"    column="project_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectFileName"    column="project_file_name"    />
        <result property="packageName"    column="package_name"    />
        <result property="version"    column="version"    />
        <result property="projectDesc"    column="project_desc"    />
        <result property="author"    column="author"    />
        <result property="frontFramework"    column="front_framework"    />
        <result property="backFramework"    column="back_framework"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectGenProjectVo">
        select project_id, project_name, project_file_name, package_name, version, project_desc, author, front_framework, back_framework, status, create_by, create_time, update_by, update_time, remark from gen_project
    </sql>

    <select id="selectGenProjectList" parameterType="GenProject" resultMap="GenProjectResult">
        <include refid="selectGenProjectVo"/>
        <where>  
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="projectFileName != null  and projectFileName != ''"> and project_file_name like concat('%', #{projectFileName}, '%')</if>
            <if test="packageName != null  and packageName != ''"> and package_name like concat('%', #{packageName}, '%')</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="projectDesc != null  and projectDesc != ''"> and project_desc like concat('%', #{projectDesc}, '%')</if>
            <if test="author != null  and author != ''"> and author like concat('%', #{author}, '%')</if>
            <if test="frontFramework != null  and frontFramework != ''"> and front_framework = #{frontFramework}</if>
            <if test="backFramework != null  and backFramework != ''"> and back_framework = #{backFramework}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectGenProjectById" parameterType="Long" resultMap="GenProjectResult">
        <include refid="selectGenProjectVo"/>
        where project_id = #{projectId}
    </select>
        
    <insert id="insertGenProject" parameterType="GenProject" useGeneratedKeys="true" keyProperty="projectId">
        insert into gen_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null">project_name,</if>
            <if test="projectFileName != null">project_file_name,</if>
            <if test="packageName != null">package_name,</if>
            <if test="version != null">version,</if>
            <if test="projectDesc != null">project_desc,</if>
            <if test="author != null">author,</if>
            <if test="frontFramework != null">front_framework,</if>
            <if test="backFramework != null">back_framework,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectName != null">#{projectName},</if>
            <if test="projectFileName != null">#{projectFileName},</if>
            <if test="packageName != null">#{packageName},</if>
            <if test="version != null">#{version},</if>
            <if test="projectDesc != null">#{projectDesc},</if>
            <if test="author != null">#{author},</if>
            <if test="frontFramework != null">#{frontFramework},</if>
            <if test="backFramework != null">#{backFramework},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateGenProject" parameterType="GenProject">
        update gen_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="projectFileName != null">project_file_name = #{projectFileName},</if>
            <if test="packageName != null">package_name = #{packageName},</if>
            <if test="version != null">version = #{version},</if>
            <if test="projectDesc != null">project_desc = #{projectDesc},</if>
            <if test="author != null">author = #{author},</if>
            <if test="frontFramework != null">front_framework = #{frontFramework},</if>
            <if test="backFramework != null">back_framework = #{backFramework},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where project_id = #{projectId}
    </update>

    <delete id="deleteGenProjectById" parameterType="Long">
        delete from gen_project where project_id = #{projectId}
    </delete>

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