修改 前端菜单 管理菜单,角色前后端分配 及通道创建失败的问题

This commit is contained in:
LEED
2025-07-07 22:26:26 +08:00
parent b2cee8aeb7
commit ac40c5e5ec
29 changed files with 899 additions and 81 deletions

View File

@@ -208,7 +208,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId}
delete from sys_dept where dept_id = #{deptId}
</delete>
<select id="selectSeniorDeptUser" resultType="java.lang.Long">

View File

@@ -31,15 +31,15 @@
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu
</sql>
<sql id="selectMenuF">
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu_f
</sql>
<select id="selectMenuList" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id,
case
when #{language} = 'zh-CN' then m.menu_name
when #{language} = 'en-US' then t.en_us
else m.menu_name
end as menu_name,
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
m. menu_name,
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
from sys_menu m
left join sys_menu_translate t on m.menu_id = t.id
<where>
@@ -55,34 +55,70 @@
</where>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListF" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id,
m.menu_name,
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
from sys_menu_f m
<where>
<if test="menuName != null and menuName != ''">
AND m.menu_name like concat('%', #{menuName}, '%')
</if>
<if test="visible != null and visible != ''">
AND m.visible = #{visible}
</if>
<if test="status != null and status != ''">
AND m.status = #{status}
</if>
</where>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
case
when #{language} = 'zh-CN' then m.menu_name
when #{language} = 'en-US' then t.en_us
else m.menu_name
end as menu_name,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_menu_translate t on m.menu_id = t.id
where m.menu_type in ('M', 'C') and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeAllF" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu_f m
where m.menu_type in ('M', 'C') and m.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserId" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
case
when #{language} = 'zh-CN' then m.menu_name
when #{language} = 'en-US' then t.en_us
else m.menu_name
end as menu_name,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_menu_translate t on m.menu_id = t.id
where ur.user_id = #{params.userId}
<if test="menuName != null and menuName != ''">
AND m.menu_name like concat('%', #{menuName}, '%')
</if>
<if test="visible != null and visible != ''">
AND m.visible = #{visible}
</if>
<if test="status != null and status != ''">
AND m.status = #{status}
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByUserIdF" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
where ur.user_id = #{params.userId}
<if test="menuName != null and menuName != ''">
AND m.menu_name like concat('%', #{menuName}, '%')
@@ -98,18 +134,26 @@
<select id="selectMenuTreeByUserId" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
case
when #{language} = 'zh-CN' then m.menu_name
when #{language} = 'en-US' then t.en_us
else m.menu_name
end as menu_name,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
left join sys_menu_translate t on m.menu_id = t.id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
order by m.parent_id, m.order_num
</select>
<select id="selectMenuTreeByUserIdF" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id,
m.menu_name,
m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role ro on ur.role_id = ro.role_id
left join sys_user u on ur.user_id = u.user_id
where u.user_id = #{userId} and m.menu_type in ('M', 'C') and m.status = 0 AND ro.status = 0
order by m.parent_id, m.order_num
</select>
@@ -125,12 +169,29 @@
order by m.parent_id, m.order_num
</select>
<select id="selectMenuListByRoleIdF" resultType="Long">
select m.menu_id
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
where rm.role_id = #{roleId}
<if test="menuCheckStrictly">
and m.menu_id not in (select m.parent_id from sys_menu_f m inner join sys_role_menu_f rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
</if>
order by m.parent_id, m.order_num
</select>
<select id="selectMenuPerms" resultType="String">
select distinct m.perms
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
</select>
<select id="selectMenuPermsF" resultType="String">
select distinct m.perms
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
</select>
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
select distinct m.perms
@@ -140,6 +201,14 @@
left join sys_role r on r.role_id = ur.role_id
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
</select>
<select id="selectMenuPermsByUserIdF" parameterType="Long" resultType="String">
select distinct m.perms
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
left join sys_role r on r.role_id = ur.role_id
where m.status = '0' and r.status = '0' and ur.user_id = #{userId}
</select>
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
select distinct m.perms
@@ -148,28 +217,46 @@
where m.status = '0' and rm.role_id = #{roleId}
</select>
<select id="selectMenuPermsByRoleIdF" parameterType="Long" resultType="String">
select distinct m.perms
from sys_menu_f m
left join sys_role_menu_f rm on m.menu_id = rm.menu_id
where m.status = '0' and rm.role_id = #{roleId}
</select>
<select id="selectMenuById" resultMap="SysMenuResult">
select distinct m.menu_id,
case
when #{language} = 'zh-CN' then m.menu_name
when #{language} = 'en-US' then t.en_us
else m.menu_name
end as menu_name,
m.menu_name,
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
from sys_menu m
left join sys_menu_translate t on m.menu_id = t.id
where m.menu_id = #{menuId}
</select>
<select id="selectMenuByIdF" resultMap="SysMenuResult">
select distinct m.menu_id,
m.menu_name,
m.parent_id, m.order_num, m.path, m.component, m.query, m.is_frame, m.is_cache, m.menu_type, m.visible, m.status, ifnull(m.perms,'') as perms, m.icon, m.create_time
from sys_menu_f m
where m.menu_id = #{menuId}
</select>
<select id="hasChildByMenuId" resultType="Integer">
select count(1) from sys_menu where parent_id = #{menuId}
</select>
<select id="hasChildByMenuIdF" resultType="Integer">
select count(1) from sys_menu_f where parent_id = #{menuId}
</select>
<select id="checkMenuNameUnique" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
</select>
<select id="checkMenuNameUniqueF" parameterType="com.xinda.common.core.domain.entity.SysMenu" resultMap="SysMenuResult">
select distinct menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
from sys_menu_f
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
</select>
<update id="updateMenu" parameterType="com.xinda.common.core.domain.entity.SysMenu">
update sys_menu
@@ -194,6 +281,29 @@
where menu_id = #{menuId}
</update>
<update id="updateMenuF" parameterType="com.xinda.common.core.domain.entity.SysMenu">
update sys_menu_f
<set>
<if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="path != null and path != ''">path = #{path},</if>
<if test="component != null">component = #{component},</if>
<if test="query != null">`query` = #{query},</if>
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
<if test="visible != null">visible = #{visible},</if>
<if test="status != null">status = #{status},</if>
<if test="perms !=null">perms = #{perms},</if>
<if test="icon !=null and icon != ''">icon = #{icon},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where menu_id = #{menuId}
</update>
<insert id="insertMenu" parameterType="com.xinda.common.core.domain.entity.SysMenu">
insert into sys_menu(
<if test="menuId != null and menuId != 0">menu_id,</if>
@@ -234,8 +344,51 @@
)
</insert>
<insert id="insertMenuF" parameterType="com.xinda.common.core.domain.entity.SysMenu">
insert into sys_menu_f(
<if test="menuId != null and menuId != 0">menu_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="menuName != null and menuName != ''">menu_name,</if>
<if test="orderNum != null">order_num,</if>
<if test="path != null and path != ''">path,</if>
<if test="component != null and component != ''">component,</if>
<if test="query != null and query != ''">`query`,</if>
<if test="isFrame != null and isFrame != ''">is_frame,</if>
<if test="isCache != null and isCache != ''">is_cache,</if>
<if test="menuType != null and menuType != ''">menu_type,</if>
<if test="visible != null">visible,</if>
<if test="status != null">status,</if>
<if test="perms !=null and perms != ''">perms,</if>
<if test="icon != null and icon != ''">icon,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="menuId != null and menuId != 0">#{menuId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="menuName != null and menuName != ''">#{menuName},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="path != null and path != ''">#{path},</if>
<if test="component != null and component != ''">#{component},</if>
<if test="query != null and query != ''">#{query},</if>
<if test="isFrame != null and isFrame != ''">#{isFrame},</if>
<if test="isCache != null and isCache != ''">#{isCache},</if>
<if test="menuType != null and menuType != ''">#{menuType},</if>
<if test="visible != null">#{visible},</if>
<if test="status != null">#{status},</if>
<if test="perms !=null and perms != ''">#{perms},</if>
<if test="icon != null and icon != ''">#{icon},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<delete id="deleteMenuById" parameterType="Long">
delete from sys_menu where menu_id = #{menuId}
</delete>
<delete id="deleteMenuByIdF" parameterType="Long">
delete from sys_menu_f where menu_id = #{menuId}
</delete>
</mapper>

View File

@@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="menuCheckStrictly" column="menu_check_strictly" />
<result property="deptCheckStrictly" column="dept_check_strictly" />
<result property="status" column="status" />
<result property="im" column="im" />
<result property="ib" column="ib" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@@ -23,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
r.status, r.del_flag, r.create_time, r.remark
r.status,r.im,r.ib, r.del_flag, r.create_time, r.remark
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
@@ -61,6 +63,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE r.del_flag = '0' and ur.user_id = #{userId}
</select>
<select id="selectRoleByUserIdAndIm" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
WHERE r.del_flag = '0'and r.im = '1' and ur.user_id = #{userId}
</select>
<select id="selectRoleByUserIdAndIb" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
WHERE r.del_flag = '0'and r.ib = '1' and ur.user_id = #{userId}
</select>
<select id="selectRoleAll" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
</select>
@@ -117,6 +129,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
<if test="status != null and status != ''">status,</if>
<if test="im != null and im != ''">im,</if>
<if test="ib != null and im != ''">ib,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
@@ -129,6 +143,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="im != null and im != ''">im,</if>
<if test="ib != null and im != ''">ib,</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
@@ -145,6 +161,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
<if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="im != null and im != ''">im = #{im},</if>
<if test="ib != null and ib != ''">ib = #{ib},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()

View File

@@ -13,15 +13,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from sys_role_menu where menu_id = #{menuId}
</select>
<select id="checkMenuExistRoleF" resultType="Integer">
select count(1) from sys_role_menu_f where menu_id = #{menuId}
</select>
<select id="selectRoleMenuList" resultType="com.xinda.system.domain.SysRoleMenu">
select *
from sys_role_menu
where role_id = #{roleId}
</select>
<select id="selectRoleMenuListF" resultType="com.xinda.system.domain.SysRoleMenu">
select *
from sys_role_menu_f
where role_id = #{roleId}
</select>
<delete id="deleteRoleMenuByRoleId" parameterType="Long">
delete from sys_role_menu where role_id=#{roleId}
</delete>
<delete id="deleteRoleMenuByRoleIdF" parameterType="Long">
delete from sys_role_menu_f where role_id=#{roleId}
</delete>
<delete id="deleteRoleMenu" parameterType="Long">
delete from sys_role_menu where role_id in
@@ -29,6 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{roleId}
</foreach>
</delete>
<delete id="deleteRoleMenuF" parameterType="Long">
delete from sys_role_menu_f where role_id in
<foreach collection="array" item="ids" index="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
</delete>
<insert id="batchRoleMenu">
insert into sys_role_menu(role_id, menu_id) values
@@ -36,5 +54,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{item.roleId},#{item.menuId})
</foreach>
</insert>
<insert id="batchRoleMenuF">
insert into sys_role_menu_f(role_id, menu_id) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.roleId},#{item.menuId})
</foreach>
</insert>
</mapper>