bug
jiangping
2023-11-07 64b432916af9c9218ab3f3eca614e26c542142ae
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?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="doumeemes.dao.system.SystemMenuMapper">
 
  <!-- 查询菜单列表 -->
  <resultMap id="SystemMenuListVO" type="doumeemes.dao.system.vo.SystemMenuListVO" autoMapping="true">
    <id column="ID" property="id"/>
    <association property="createUserInfo" javaType="doumeemes.dao.system.model.SystemUser">
      <result column="CREATE_USER_ID" property="id"/>
      <result column="CREATE_USER_NAME" property="username"/>
    </association>
    <association property="updateUserInfo" javaType="doumeemes.dao.system.model.SystemUser">
      <result column="UPDATE_USER_ID" property="id"/>
      <result column="UPDATE_USER_NAME" property="username"/>
    </association>
  </resultMap>
  <select id="selectManageList" parameterType="doumeemes.dao.system.dto.QuerySystemMenuDTO" resultMap="SystemMenuListVO">
    SELECT
    menu.`TYPE`,menu.`MODULE_ID`,  menu.`ID`, menu.`PARENT_ID`, menu.`NAME`, menu.`PATH`, menu.`FIXED`, menu.`REMARK`, menu.`DISABLED`, menu.SORT, menu.`ICON`, menu.`CREATE_TIME`, menu.`UPDATE_TIME`, menu.`CREATE_USER`, menu.`UPDATE_USER`, menu.`DELETED`,menu.PATH_SEC,
    create_user.ID CREATE_USER_ID, create_user.`USERNAME` CREATE_USER_NAME,
    update_user.ID UPDETE_USER_ID, update_user.`USERNAME` UPDATE_USER_NAME
    FROM SYSTEM_MENU menu
    LEFT JOIN `SYSTEM_USER` create_user ON create_user.ID = menu.CREATE_USER
    LEFT JOIN `SYSTEM_USER` update_user ON update_user.ID = menu.UPDATE_USER
    <where>
      menu.DELETED = 0
      <if test="dto.type != null">
        AND menu.`TYPE` = #{dto.type}
      </if>
      <if test="dto.moduleId != null">
        AND menu.`MODULE_ID` = #{dto.moduleId}
      </if>
    </where>
    ORDER BY menu.SORT
  </select>
 
  <!-- 查询菜单树 -->
  <select id="selectByUserId"   resultType="doumeemes.dao.system.model.SystemMenu">
    SELECT
    DISTINCT menu.`ID`, menu.`TYPE`,menu.`MODULE_ID`,  menu.`PARENT_ID`, menu.`NAME`, menu.`PATH`, menu.`REMARK`, menu.`DISABLED`, menu.SORT, menu.`ICON`, menu.`CREATE_TIME`, menu.`UPDATE_TIME`, menu.`CREATE_USER`, menu.`UPDATE_USER`, menu.`DELETED`,menu.PATH_SEC
    FROM `SYSTEM_MENU` menu
    INNER JOIN SYSTEM_ROLE_MENU role_menu ON role_menu.MENU_ID = menu.ID AND role_menu.DELETED = 0
    INNER JOIN SYSTEM_USER_ROLE user_role ON user_role.ROLE_ID = role_menu.ROLE_ID AND user_role.DELETED = 0
    LEFT JOIN system_role r on user_role.ROLE_ID=r.id
    <where>
      AND menu.DELETED = 0
      AND menu.DISABLED = 0
      AND user_role.USER_ID = #{userId}
      <if test="type!= null">
        AND menu.`TYPE` = #{type}
      </if>
      <if test="companyId!= null">
        AND r.COMPANY_ID= #{companyId}
      </if>
    </where>
    ORDER BY menu.SORT
  </select>
 
  <!-- 根据角色ID查询菜单列表 -->
  <select id="selectByRoleId" parameterType="java.lang.Integer" resultType="doumeemes.dao.system.model.SystemMenu">
    SELECT
    menu.`TYPE`,menu.`MODULE_ID`,  menu.`ID`, menu.`PARENT_ID`, menu.`NAME`, menu.`PATH`, menu.`REMARK`, menu.`DISABLED`, menu.SORT, menu.`ICON`, menu.`CREATE_TIME`, menu.`UPDATE_TIME`, menu.`CREATE_USER`, menu.`UPDATE_USER`, menu.`DELETED`,menu.PATH_SEC
    FROM `SYSTEM_MENU` menu
    INNER JOIN `SYSTEM_ROLE_MENU` role_menu ON role_menu.MENU_ID = menu.ID AND role_menu.DELETED = 0
    <where>
      menu.DELETED = 0
      AND role_menu.ROLE_ID = #{roleId}
    </where>
  </select>
 
</mapper>