<?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="shop.alien.mapper.LifeSysMenuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="shop.alien.entity.store.LifeSysMenu">
        <id column="menu_id" property="menuId" />
        <result column="menu_name" property="menuName" />
        <result column="parent_id" property="parentId" />
        <result column="menu_type" property="menuType" />
        <result column="menu_sort" property="menuSort" />
        <result column="path" property="path" />
        <result column="component" property="component" />
        <result column="perms" property="perms" />
        <result column="icon" property="icon" />
        <result column="status" property="status" />
        <result column="visible" property="visible" />
        <result column="is_frame" property="isFrame" />
        <result column="is_cache" property="isCache" />
        <result column="del_flag" property="delFlag" />
        <result column="create_by" property="createBy" />
        <result column="created_time" property="createdTime" />
        <result column="update_by" property="updateBy" />
        <result column="updated_time" property="updatedTime" />
        <result column="remark" property="remark" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        menu_id, menu_name, parent_id, menu_type, menu_sort, path, component, perms, icon,
        status, visible, is_frame, is_cache, del_flag, create_by, created_time, update_by,
        updated_time, remark
    </sql>


    <select id="getMenuByUserId" resultType="shop.alien.entity.store.LifeSysMenu">
        select lsm.*
        from life_sys_menu lsm
                 left join life_sys_role_menu lsrm on lsrm.menu_id = lsm.menu_id
        where lsm.del_flag = 0
          and lsrm.role_id in (
            select lsur.role_id
            from life_sys_user_role lsur
            where lsur.user_id = #{userId}
        )
    </select>

</mapper>

