<?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.bonus.system.mapper.SysTemplateMenuMapper">

    <resultMap type="com.bonus.system.api.domain.SysTemplateMenu" id="SysTemplateMenuMap">
        <result property="tempId" column="temp_id" />
        <result property="menuId" column="menu_id" />
    </resultMap>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="SysTemplateMenuMap">
        select
          temp_id, menu_id
        from sys_template_menu
        limit #{offset}, #{limit}
    </select>

    <!--通过实体作为筛选条件查询-->
    <select id="queryMenuIdByTemplateId" resultType="Long">
        select
            menu_id
        from
            sys_template_menu
        where
            temp_id = #{tempId}
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="" useGeneratedKeys="true">
        insert into sys_template_menu(temp_id, menu_id)
        values (#{tempId}, #{menuId})
    </insert>

    <insert id="batchInsert">
        insert into sys_template_menu(temp_id, menu_id) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.tempId},#{item.menuId})
        </foreach>
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update sys_template_menu
        <set>
            <if test="tempId != null">
                temp_id = #{tempId},
            </if>
            <if test="menuId != null">
                menu_id = #{menuId},
            </if>
        </set>
        where  = #{}
    </update>

    <delete id="deleteByTempId" parameterType="Long">
        delete from sys_template_menu where temp_id = #{tempId}
    </delete>
</mapper>