refactor(system): 重构系统模块中的菜单和角色关联关系
This commit is contained in:
+25
-25
@@ -1,29 +1,29 @@
|
||||
<?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.odboy.system.dal.mysql.SystemDictDetailMapper">
|
||||
<select id="selectPageByArgs" resultType="cn.odboy.system.dal.model.response.SystemDictDetailVo">
|
||||
SELECT
|
||||
t1.*
|
||||
FROM system_dict_detail t1 LEFT JOIN system_dict t2 ON t1.dict_id = t2.id
|
||||
<where>
|
||||
<if test="args.dictName != null and args.dictName != ''">
|
||||
AND t2.name = #{args.dictName}
|
||||
</if>
|
||||
<if test="args.label != null and args.label != ''">
|
||||
AND t1.label = #{args.label}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.dict_sort
|
||||
</select>
|
||||
<select id="listDictDetailByName" resultType="cn.odboy.system.dal.model.response.SystemDictDetailVo">
|
||||
SELECT t1.*
|
||||
FROM system_dict_detail t1
|
||||
LEFT JOIN system_dict t2 ON t1.dict_id = t2.id
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND t2.name = #{name}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.dict_sort
|
||||
</select>
|
||||
<select id="selectPageByArgs" resultType="cn.odboy.system.dal.model.response.SystemDictDetailVo">
|
||||
SELECT
|
||||
t1.*
|
||||
FROM system_dict_detail t1 LEFT JOIN system_dict t2 ON t1.dict_id = t2.id
|
||||
<where>
|
||||
<if test="args.dictName != null and args.dictName != ''">
|
||||
AND t2.name = #{args.dictName}
|
||||
</if>
|
||||
<if test="args.label != null and args.label != ''">
|
||||
AND t1.label = #{args.label}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.dict_sort
|
||||
</select>
|
||||
<select id="listDictDetailByName" resultType="cn.odboy.system.dal.model.response.SystemDictDetailVo">
|
||||
SELECT t1.*
|
||||
FROM system_dict_detail t1
|
||||
LEFT JOIN system_dict t2 ON t1.dict_id = t2.id
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND t2.name = #{name}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.dict_sort
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?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.odboy.system.dal.mysql.SystemRoleMapper">
|
||||
<select id="listRoleLevelByRoleIds" resultType="java.lang.Integer">
|
||||
SELECT DISTINCT t1.`level`
|
||||
FROM system_role t1
|
||||
WHERE t1.`level` IS NOT NULL
|
||||
AND t1.role_id IN
|
||||
<foreach collection="roleIds" separator="," open="(" close=")" item="roleId">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?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.odboy.system.dal.mysql.SystemRoleMenuMapper">
|
||||
<select id="listMenuPermissionByRoleIds" resultType="java.lang.String">
|
||||
SELECT DISTINCT
|
||||
t2.permission
|
||||
FROM
|
||||
system_roles_menus t1
|
||||
LEFT JOIN system_menu t2 ON t1.menu_id = t2.menu_id
|
||||
WHERE
|
||||
t1.role_id IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="listMenuWithRoleIdsNeButton" resultType="cn.odboy.system.dal.dataobject.SystemMenuTb">
|
||||
SELECT t2.*,
|
||||
t2.menu_id AS id
|
||||
FROM system_roles_menus t1
|
||||
LEFT JOIN system_menu t2 ON t1.menu_id = t2.menu_id
|
||||
WHERE t2.`type` != 2 AND t1.role_id IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
ORDER BY
|
||||
menu_sort ASC
|
||||
</select>
|
||||
<select id="listMenuWithRoleIds" resultType="cn.odboy.system.dal.dataobject.SystemMenuTb">
|
||||
SELECT t2.*,
|
||||
t2.menu_id AS id
|
||||
FROM system_roles_menus t1
|
||||
LEFT JOIN system_menu t2 ON t1.menu_id = t2.menu_id
|
||||
WHERE t1.role_id IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
ORDER BY
|
||||
menu_sort ASC
|
||||
</select>
|
||||
</mapper>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?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.odboy.system.dal.mysql.SystemUserMapper">
|
||||
<select id="listUsernameByIds" resultType="java.lang.String">
|
||||
SELECT DISTINCT
|
||||
t1.username
|
||||
FROM
|
||||
system_user t1
|
||||
WHERE
|
||||
t1.user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
+12
@@ -7,4 +7,16 @@
|
||||
LEFT JOIN system_users_roles t2 ON t1.role_id = t2.role_id
|
||||
WHERE t2.user_id = #{userId}
|
||||
</select>
|
||||
<select id="listUserRoleLevelByUserId" resultType="java.lang.Integer">
|
||||
SELECT DISTINCT t1.`level`
|
||||
FROM system_role t1
|
||||
LEFT JOIN system_users_roles t2 ON t1.role_id = t2.role_id
|
||||
WHERE t2.user_id = #{userId}
|
||||
</select>
|
||||
<select id="listUserRoleIdByUserId" resultType="java.lang.Long">
|
||||
SELECT DISTINCT t1.`role_id`
|
||||
FROM system_role t1
|
||||
LEFT JOIN system_users_roles t2 ON t1.role_id = t2.role_id
|
||||
WHERE t2.user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user