<?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=".dao.SysMuenRoleDao">

    <resultMap type=".entity.SysMuenRole" id="SysMuenRoleMap">
        <result property="roleId" column="role_id" jdbcType="INTEGER"/>
        <result property="powerId" column="power_id" jdbcType="INTEGER"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="SysMuenRoleMap">
        select
          role_id, power_id
        from sys_muen_role
        where role_id = #{roleId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="SysMuenRoleMap">
        select
          role_id, power_id
        from sys_muen_role
        <where>
            <if test="roleId != null">
                and role_id = #{roleId}
            </if>
            <if test="powerId != null">
                and power_id = #{powerId}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from sys_muen_role
        <where>
            <if test="roleId != null">
                and role_id = #{roleId}
            </if>
            <if test="powerId != null">
                and power_id = #{powerId}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="roleId" useGeneratedKeys="true">
        insert into sys_muen_role()
        values ()
    </insert>

    <insert id="insertBatch" keyProperty="roleId" useGeneratedKeys="true">
        insert into sys_muen_role()
        values
        <foreach collection="entities" item="entity" separator=",">
        ()
        </foreach>
    </insert>

    <insert id="insertOrUpdateBatch" keyProperty="roleId" useGeneratedKeys="true">
        insert into sys_muen_role()
        values
        <foreach collection="entities" item="entity" separator=",">
            ()
        </foreach>
        on duplicate key update
        
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update sys_muen_role
        <set>
        </set>
        where role_id = #{roleId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from sys_muen_role where role_id = #{roleId}
    </delete>

</mapper>

