You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.8 KiB
75 lines
2.8 KiB
<?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.epmet.dao.RoleScopeDao">
|
|
|
|
<resultMap type="com.epmet.entity.RoleScopeEntity" id="roleScopeMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="roleId" column="ROLE_ID"/>
|
|
<result property="operationKey" column="OPERATION_KEY"/>
|
|
<result property="scopeKey" column="SCOPE_KEY"/>
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
</resultMap>
|
|
|
|
<!--权限配置:列出scope项-->
|
|
<select id="listScopeOptionsForAccessConfig" resultType="com.epmet.dto.result.AccessConfigScopeResultDTO">
|
|
SELECT os.SCOPE_KEY,
|
|
os.SCOPE_NAME,
|
|
os.SCOPE_INDEX,
|
|
rs.OPERATION_KEY,
|
|
rs.ROLE_ID,
|
|
CASE
|
|
WHEN rs.ROLE_ID IS NULL
|
|
THEN FALSE
|
|
ELSE TRUE
|
|
END AS assigned
|
|
FROM operation_scope os
|
|
LEFT JOIN role_scope rs
|
|
ON (os.SCOPE_KEY = rs.SCOPE_KEY AND rs.DEL_FLAG = 0 AND rs.ROLE_ID = #{roleId} AND
|
|
OPERATION_KEY = #{operationKey})
|
|
WHERE os.DEL_FLAG = 0
|
|
ORDER BY os.SORT ASC
|
|
</select>
|
|
|
|
<!--根据角色ID和操作key删除-->
|
|
<delete id="deleteByRoleIdAndOpeKey">
|
|
DELETE
|
|
FROM role_scope
|
|
WHERE ROLE_ID = #{roleId}
|
|
AND OPERATION_KEY = #{operationKey}
|
|
AND SCOPE_KEY IN
|
|
<foreach collection="scopeKeys2Remove" item="scopeKey" open="(" separator="," close=")">
|
|
#{scopeKey}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<!--启用-->
|
|
<update id="enableByRoleIdAndOpeKey">
|
|
DELETE
|
|
FROM role_scope
|
|
WHERE ROLE_ID = #{roleId}
|
|
AND OPERATION_KEY = #{operationKey}
|
|
AND SCOPE_KEY = #{scopeKey}
|
|
</update>
|
|
|
|
<!--根据角色ID+操作key+范围Key查询。此处不要过滤DEL_FLAG-->
|
|
<select id="getByRoleIdAndOpeKey" resultType="com.epmet.entity.RoleScopeEntity">
|
|
SELECT ro.*
|
|
FROM role_scope ro
|
|
WHERE ro.ROLE_ID = #{roleId}
|
|
AND ro.OPERATION_KEY = #{operationKey}
|
|
AND ro.SCOPE_KEY = #{scopeKey}
|
|
</select>
|
|
|
|
<select id="listScopeEntities" resultType="com.epmet.entity.RoleScopeEntity">
|
|
SELECT rs.*
|
|
FROM role_scope rs
|
|
WHERE rs.ROLE_ID = #{roleId}
|
|
AND rs.OPERATION_KEY = #{operationKey}
|
|
</select>
|
|
</mapper>
|