<?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="com.cloud.user.dao.SysRoleMenuDao">
|
<resultMap id="BaseResultMap" type="com.cloud.model.sys.SysRoleMenu">
|
<result column="roleId" jdbcType="INTEGER" property="roleId" />
|
<result column="menuId" jdbcType="INTEGER" property="menuId" />
|
<result column="orgId" jdbcType="INTEGER" property="orgId" />
|
</resultMap>
|
<insert id="insert" parameterType="com.cloud.model.sys.SysRoleMenu">
|
insert into sys_role_menu (roleId, menuId, orgId
|
)
|
values (#{roleId,jdbcType=INTEGER}, #{menuId,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}
|
)
|
</insert>
|
<insert id="insertSelective" parameterType="com.cloud.model.sys.SysRoleMenu">
|
insert into sys_role_menu
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="roleId != null">
|
roleId,
|
</if>
|
<if test="menuId != null">
|
menuId,
|
</if>
|
<if test="orgId != null">
|
orgId,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="roleId != null">
|
#{roleId,jdbcType=INTEGER},
|
</if>
|
<if test="menuId != null">
|
#{menuId,jdbcType=INTEGER},
|
</if>
|
<if test="orgId != null">
|
#{orgId,jdbcType=INTEGER},
|
</if>
|
</trim>
|
</insert>
|
|
<select id="findPermissionsByRoleIds" resultType="com.cloud.model.sys.SysMenu">
|
select m.* from
|
sys_menu m
|
inner join sys_role_menu rm on
|
m.id = rm.menuId
|
<where>
|
rm.roleId in
|
<foreach collection="roleIds" item="roleId" open="("
|
separator="," close=")">
|
#{roleId}
|
</foreach>
|
</where>
|
<if test="orgId != null and orgId != ''">
|
and m.orgId = #{orgId}
|
</if>
|
</select>
|
|
<select id="findMenusByRoleIds" resultType="com.cloud.model.sys.SysMenu">
|
select t.* from sys_menu t
|
inner join sys_role_menu r on r.menuId = t.id
|
where t.enabled = '0' and t.delFlag = '0' and
|
r.roleId in
|
<foreach collection="roleIds" index="index" item="roleId"
|
open="(" separator="," close=")">
|
#{roleId}
|
</foreach>
|
<if test="module != null and module != ''">
|
and t.module = #{module}
|
</if>
|
<if test="type != null and type != ''">
|
and t.type != #{type}
|
</if>
|
order by t.sort
|
</select>
|
|
<insert id="save" parameterType="com.cloud.model.sys.SysMenu">
|
insert into sys_menu
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="orgId != null">
|
orgId,
|
</if>
|
<if test="parentId != null">
|
parentId,
|
</if>
|
<if test="parentIds != null">
|
parentIds,
|
</if>
|
<if test="orgIdsShow != null">
|
orgIdsShow,
|
</if>
|
<if test="orgIdsHide != null">
|
orgIdsHide,
|
</if>
|
<if test="name != null">
|
name,
|
</if>
|
<if test="sort != null">
|
sort,
|
</if>
|
<if test="url != null">
|
url,
|
</if>
|
<if test="icon != null">
|
icon,
|
</if>
|
<if test="type != null">
|
type,
|
</if>
|
<if test="isSystem != null">
|
isSystem,
|
</if>
|
<if test="permission != null">
|
permission,
|
</if>
|
<if test="remarks != null">
|
remarks,
|
</if>
|
<if test="enabled != null">
|
enabled,
|
</if>
|
<if test="delFlag != null">
|
delFlag,
|
</if>
|
<if test="createTime != null">
|
createTime,
|
</if>
|
<if test="updateTime != null">
|
updateTime,
|
</if>
|
<if test="revJson != null">
|
revJson,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="orgId != null">
|
#{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="parentId != null">
|
#{parentId,jdbcType=INTEGER},
|
</if>
|
<if test="parentIds != null">
|
#{parentIds,jdbcType=VARCHAR},
|
</if>
|
<if test="orgIdsShow != null">
|
#{orgIdsShow,jdbcType=VARCHAR},
|
</if>
|
<if test="orgIdsHide != null">
|
#{orgIdsHide,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
#{name,jdbcType=VARCHAR},
|
</if>
|
<if test="sort != null">
|
#{sort,jdbcType=INTEGER},
|
</if>
|
<if test="url != null">
|
#{url,jdbcType=VARCHAR},
|
</if>
|
<if test="icon != null">
|
#{icon,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
#{type,jdbcType=INTEGER},
|
</if>
|
<if test="isSystem != null">
|
#{isSystem,jdbcType=INTEGER},
|
</if>
|
<if test="permission != null">
|
#{permission,jdbcType=VARCHAR},
|
</if>
|
<if test="remarks != null">
|
#{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="enabled != null">
|
#{enabled},
|
</if>
|
<if test="delFlag != null">
|
#{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="revJson != null">
|
#{revJson,jdbcType=CHAR},
|
</if>
|
</trim>
|
</insert>
|
|
<update id="update" parameterType="com.cloud.model.sys.SysMenu">
|
update sys_menu
|
<set>
|
<if test="orgId != null">
|
orgId = #{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="parentId != null">
|
parentId = #{parentId,jdbcType=INTEGER},
|
</if>
|
<if test="parentIds != null">
|
parentIds = #{parentIds,jdbcType=VARCHAR},
|
</if>
|
<if test="orgIdsShow != null">
|
orgIdsShow = #{orgIdsShow,jdbcType=VARCHAR},
|
</if>
|
<if test="orgIdsHide != null">
|
orgIdsHide = #{orgIdsHide,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="sort != null">
|
sort = #{sort,jdbcType=INTEGER},
|
</if>
|
<if test="url != null">
|
url = #{url,jdbcType=VARCHAR},
|
</if>
|
<if test="icon != null">
|
icon = #{icon,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=INTEGER},
|
</if>
|
<if test="isSystem != null">
|
isSystem = #{isSystem,jdbcType=INTEGER},
|
</if>
|
<if test="permission != null">
|
permission = #{permission,jdbcType=VARCHAR},
|
</if>
|
<if test="remarks != null">
|
remarks = #{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="enabled != null">
|
enabled = #{enabled,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
delFlag = #{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="revJson != null">
|
revJson = #{revJson,jdbcType=CHAR},
|
</if>
|
</set>
|
where id = #{id,jdbcType=INTEGER}
|
and orgId = #{orgId,jdbcType=INTEGER}
|
</update>
|
|
<delete id="delete">
|
delete from sys_menu
|
where id = #{id,jdbcType=INTEGER}
|
and orgId = #{orgId,jdbcType=INTEGER}
|
</delete>
|
|
<select id="findById" resultType="com.cloud.model.sys.SysMenu">
|
select *
|
from sys_menu
|
where id = #{id,jdbcType=INTEGER}
|
and orgId = #{orgId,jdbcType=INTEGER}
|
</select>
|
|
<delete id="deleteRolePermissionByParams">
|
delete from sys_role_menu
|
<where>
|
<if test="id != null">
|
and roleId = #{id}
|
</if>
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
</where>
|
</delete>
|
|
<select id="findMenuByUser" resultType="map">
|
SELECT
|
c.`name` as lable,c.module as value,c.icon,c.id
|
FROM
|
sys_role_user a
|
LEFT JOIN sys_role_menu b ON a.roleId = b.roleId
|
LEFT JOIN sys_menu c ON b.menuId = c.id
|
<where>
|
c.delFlag = #{delFlag}
|
<if test="userId != null">
|
and a.userId = #{userId}
|
</if>
|
<if test="type != null">
|
and c.type = #{type}
|
</if>
|
<if test="tags != null">
|
AND json_extract (c.revJson, '$.tags') LIKE "%${tags}%"
|
</if>
|
<if test="orgId != null">
|
and a.orgId = #{orgId}
|
and b.orgId = #{orgId}
|
</if>
|
</where>
|
GROUP BY c.id
|
</select>
|
<select id="findAllMenuByUser" resultType="map">
|
SELECT T.*,CASE WHEN #{userId} is not NULL THEN 1 ELSE 0 END as state from (SELECT
|
a.icon,a.id,a.module,a.`name`,a.orgId,a.url
|
FROM
|
sys_menu a
|
LEFT JOIN sys_role_menu b ON a.id = b.menuId
|
LEFT JOIN sys_role_user c ON c.roleId = b.roleId AND c.userId = #{userId}
|
<where>
|
a.delFlag = #{delFlag}
|
<if test="type != null">
|
and a.type = #{type}
|
</if>
|
<if test="tags != null">
|
AND json_extract (a.revJson, '$.tags') LIKE "%${tags}%"
|
</if>
|
</where>
|
GROUP BY a.id,a.icon,a.module,a.`name`,a.orgId,a.url)T
|
</select>
|
|
</mapper>
|