<?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.SysProjectTableMapper">

    <resultMap type="com.ruoyi.generator.domain.SysProjectTable" id="SysProjectTableResult">
        <result property="id" column="id"    />
        <result property="tableId" column="table_id"  />
        <result property="projectId" column="project_id" />
    </resultMap>

    <sql id="selectSysProjectTableVo">
        select id, table_id, project_id from sys_project_table
    </sql>

    <select id="selectSysProjectTableList" parameterType="com.ruoyi.generator.domain.SysProjectTable" resultMap="SysProjectTableResult">
        <include refid="selectSysProjectTableVo"/>
        <where>
            <if test="tableId != null ">
                AND table_id = #{tableId}
            </if>
            <if test="projectId != null ">
                AND project_id = #{projectId}
            </if>
        </where>
    </select>

    <select id="selectSysProjectTableById" parameterType="Long" resultMap="SysProjectTableResult">
        <include refid="selectSysProjectTableVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysProjectTable" parameterType="com.ruoyi.generator.domain.SysProjectTable" useGeneratedKeys="true" keyProperty="id">
        insert into sys_project_table
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tableId != null">table_id,</if>
            <if test="projectId != null">project_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tableId != null">#{tableId},</if>
            <if test="projectId != null">#{projectId},</if>
         </trim>
    </insert>

    <update id="updateSysProjectTable" parameterType="com.ruoyi.generator.domain.SysProjectTable">
        update sys_project_table
        <trim prefix="SET" suffixOverrides=",">
            <if test="tableId != null">table_id = #{tableId},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysProjectTableById" parameterType="Long">
        delete from sys_project_table where id = #{id}
    </delete>

    <delete id="deleteSysProjectTableByIds" parameterType="String">
        delete from sys_project_table where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

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

    <delete id="deleteSysProjectTableByTableId" parameterType="Long">
        delete from sys_project_table where table_id = #{tableId}
    </delete>
</mapper> 