医院废弃物信息化管理平台
“mitao”
2026-04-21 2f18b3a28054c3917010f95ba84f7425280a2622
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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="cn.besteam.modules.system.mapper.SysPermissionMapper">
 
    <resultMap id="TreeModel" type="cn.besteam.modules.system.vo.TreeModel" >
        <result column="id" property="key" jdbcType="INTEGER"/>
        <result column="name" property="title" jdbcType="VARCHAR"/>
        <result column="icon" property="icon" jdbcType="VARCHAR"/>
        <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
        <result column="leaf_flag" property="isLeaf" jdbcType="INTEGER"/>
    </resultMap>
 
    <!-- 通过<resultMap>映射实体类属性名和表的字段名对应关系 -->
    <resultMap id="SysPermission" type="cn.besteam.modules.system.entity.SysPermission">
        <!-- result属性映射非匹配字段 -->
        <result column="is_route" property="isRoute"/>
        <result column="keep_alive" property="keepAlive"/>
        <result column="is_leaf" property="isLeaf"/>
    </resultMap>
 
 
    <select id="queryListByParentId" parameterType="Object"  resultMap="TreeModel">
        SELECT
        id
        ,parent_id
        ,name
        ,icon
        ,leaf_flag
        FROM   sys_permission
        WHERE 1=1
        <choose>
            <when test="parentId != null and parentId != ''">
                AND parent_id =  #{parentId,jdbcType=VARCHAR}
            </when>
            <otherwise>
                AND parent_id is null
            </otherwise>
        </choose>
    </select>
 
    <!-- 获取登录用户拥有的权限 -->
    <select id="queryByUser" parameterType="Object"  resultMap="SysPermission">
           SELECT p.*
           FROM  sys_permission p
           WHERE exists(
                   select a.id from sys_role_permission a
                   join sys_role b on a.role_id = b.id
                   join sys_user_role c on c.role_id = b.id
                   join sys_user d on d.id = c.user_id
                   where p.id = a.permission_id AND d.account = #{username,jdbcType=VARCHAR}
           )
           and p.del_flag = 0
           order by p.sort_no ASC
    </select>
 
</mapper>