<?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.dd.admin.system.roleMenu.mapper.RoleMenuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dd.admin.system.roleMenu.entity.RoleMenu">
        <id column="ID" property="id" />
        <result column="ROLE_ID" property="roleId" />
        <result column="MENU_ID" property="menuId" />
        <result column="CREATE_TIME" property="createTime" />
        <result column="CREATE_NAME" property="createName" />
        <result column="CREATE_ID" property="createId" />
        <result column="UPDATE_TIME" property="updateTime" />
        <result column="UPDATE_NAME" property="updateName" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID, ROLE_ID, MENU_ID, CREATE_TIME, CREATE_NAME, CREATE_ID, UPDATE_TIME, UPDATE_NAME
    </sql>

    <select id="selectRoleMenuPage" resultType="com.dd.admin.system.roleMenu.domain.RoleMenuVo">
        select
        *
        from sys_role_menu where 1 = 1
    </select>

    <select id="selectRoleMenuList" resultType="com.dd.admin.system.roleMenu.domain.RoleMenuVo">
        select
        *
        from sys_role_menu where 1 = 1
    </select>

    <select id="selectAllByRoleId" resultType="java.lang.String">
        SELECT
            a.menu_id
        FROM
            sys_role_menu a LEFT JOIN sys_menu b on a.menu_id = b.menu_id
        where a.role_id = #{roleId}
    </select>

    <delete id="deleteRoleMenuByRoleId">
        delete from sys_role_menu where role_id = #{roleId}
    </delete>
</mapper>
