<?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.kcim.dao.mapper.MenuMapper">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.kcim.dao.model.Menu" id="menuMap">
        <result property="menuId" column="menu_id"/>
        <result property="parentId" column="parent_id"/>
        <result property="name" column="name"/>
        <result property="path" column="path"/>
        <result property="url" column="url"/>
        <result property="perms" column="perms"/>
        <result property="hospId" column="hosp_id"/>
        <result property="type" column="type"/>
        <result property="icon" column="icon"/>
        <result property="orderNum" column="order_num"/>
        <result property="modifyUserId" column="modify_user_id"/>
        <result property="modifyTime" column="modify_time"/>
    </resultMap>
    <select id="getNav" resultType="com.kcim.dao.model.Menu">
        select *
        from sys_menu sm
        where sm.menu_id in (select distinct rm.menu_id
                             from sys_user_role ur
                                      LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
                                      LEFT JOIN sys_user su on ur.user_id = su.id
                             where su.id = #{id}
                               and su.hosp_id = #{hospId}
                               and ur.hosp_id = #{hospId}
                               and rm.hosp_id = #{hospId})
          and sm.type = 1
    </select>
    <select id="getAllParentNav" resultType="com.kcim.vo.NavVO">
        select *
        from sys_menu sm
        where sm.menu_id in (select distinct rm.menu_id
                             from sys_user_role ur
                                      LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
                                      LEFT JOIN sys_user su on ur.user_id = su.id
                             where su.id = #{id}
                               and su.hosp_id = #{hospId}
                               and ur.hosp_id = #{hospId}
                               and rm.hosp_id = #{hospId})
          and sm.type = 0
    </select>


</mapper>