廖井涛
2024-05-09 ad03e69a942f88e8c7d0c4002532a6ec18360f4e
north-glass-erp/src/main/resources/mapper/userInfo/PermissionBasicMapper.xml
@@ -4,28 +4,46 @@
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.erp.mapper.userInfo.PermissionBasicMapper">
    <select id="getPermission">
        select a.*,
               CASE
                   WHEN b.id IS NULL THEN 0
                   ELSE 1
                END
        select a.id,
        <if test="lang=='en'">
               a.menu,
        </if>
        <if test="lang=='zh'">
               c.itemName as menu,
        </if>
               a.page,
               a.permission,
               a.state,
        IF(b.id IS NULL, 0, 1) as 'checked'
        from permission_basic as a
        left join permission_role as b
        on a.id = b.permission_id
        left join user_role as c
        on b.role_id = c.role_id
        left join user as d
        on c.user_id = d.id
        and d.id = #{userId}
        on b.permission_id = a.id
        and b.role_id = #{roleId}
        <if test="lang=='zh'">
            left join sys_menu_item as c
            on c.menu = a.menu
        </if>
        where a.id!=1 and a.state=1
        <if test="id != null and id != ''">
            and a.page = (select page from permission_basic where id = #{id})
        </if>
        group by a.id
    </select>
    
    <select id="selectOneLevel">
        select *
        from permission_basic
        where id!=1 and state=1
        group by  menu
        select a.id,
               <if test="lang=='zh'">
                   b.itemName as menu
               </if>
                <if test="lang=='en'">
                    a.menu
                </if>
        from permission_basic as a
        left join sys_menu_item as b
        on a.menu = b.menu
        where a.id!=1 and a.state=1
        group by  a.menu
    </select>
@@ -34,8 +52,10 @@
            id as value,
            page as label
        from permission_basic
        where id!=1 and state=1
        group by  menu
        where
          state=1
          and menu = (select menu from permission_basic where id = #{id})
        group by page
    </select>