2021-02-02 08:30:42 +08:00
|
|
|
<?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">
|
2021-02-14 22:09:36 +08:00
|
|
|
<mapper namespace="ink.wgink.service.role.dao.IRolePermissionDao">
|
2021-02-02 08:30:42 +08:00
|
|
|
|
2021-02-24 21:09:51 +08:00
|
|
|
<cache flushInterval="3600000"/>
|
|
|
|
|
2021-02-02 08:30:42 +08:00
|
|
|
<resultMap id="rolePermissionDTO" type="ink.wgink.pojo.dtos.role.RolePermissionDTO">
|
|
|
|
<result column="role_id" property="roleId"/>
|
2021-02-24 21:09:51 +08:00
|
|
|
<result column="api_tag" property="apiTag"/>
|
|
|
|
<result column="permission_id" property="permissionId"/>
|
|
|
|
<result column="permission_type" property="permissionType"/>
|
2021-02-02 08:30:42 +08:00
|
|
|
</resultMap>
|
|
|
|
|
2021-02-24 21:09:51 +08:00
|
|
|
<!-- 建表 -->
|
|
|
|
<update id="createTable">
|
|
|
|
CREATE TABLE IF NOT EXISTS `sys_role_permission` (
|
|
|
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`role_id` char(36) DEFAULT NULL COMMENT '角色ID',
|
|
|
|
`api_tag` varchar(255) DEFAULT NULL COMMENT '接口标识',
|
|
|
|
`permission_id` char(36) DEFAULT NULL COMMENT '权限ID',
|
|
|
|
`permission_type` char(36) DEFAULT NULL COMMENT '权限类型',
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `role_id` (`role_id`),
|
|
|
|
KEY `permission_type` (`permission_type`)
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
</update>
|
|
|
|
|
2021-02-02 08:30:42 +08:00
|
|
|
<!-- 新增权限角色 -->
|
2021-02-24 21:09:51 +08:00
|
|
|
<insert id="save" parameterType="map" flushCache="true">
|
2021-02-05 16:52:19 +08:00
|
|
|
INSERT INTO sys_role_permission (
|
2021-02-24 21:09:51 +08:00
|
|
|
role_id,
|
|
|
|
api_tag,
|
2021-02-02 08:30:42 +08:00
|
|
|
permission_id,
|
2021-02-24 21:09:51 +08:00
|
|
|
permission_type
|
2021-02-02 08:30:42 +08:00
|
|
|
) VALUES(
|
2021-02-24 21:09:51 +08:00
|
|
|
#{roleId},
|
|
|
|
#{apiTag},
|
2021-02-02 08:30:42 +08:00
|
|
|
#{permissionId},
|
2021-02-24 21:09:51 +08:00
|
|
|
#{permissionType}
|
2021-02-02 08:30:42 +08:00
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
2021-02-24 21:09:51 +08:00
|
|
|
<!-- 删除 -->
|
|
|
|
<delete id="delete" parameterType="map" flushCache="true">
|
2021-02-02 08:30:42 +08:00
|
|
|
DELETE FROM
|
2021-02-05 16:52:19 +08:00
|
|
|
sys_role_permission
|
2021-02-02 08:30:42 +08:00
|
|
|
WHERE
|
|
|
|
role_id = #{roleId}
|
2021-02-24 21:09:51 +08:00
|
|
|
<if test="permissionType != null and permissionType != ''">
|
|
|
|
AND
|
|
|
|
permission_type = #{permissionType}
|
|
|
|
</if>
|
|
|
|
<if test="permissionIds != null and permissionIds.size > 0">
|
2021-02-02 08:30:42 +08:00
|
|
|
AND
|
|
|
|
permission_id IN
|
2021-02-24 21:09:51 +08:00
|
|
|
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{permissionType[${index}]}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
2021-02-02 08:30:42 +08:00
|
|
|
</delete>
|
|
|
|
|
2021-02-24 21:09:51 +08:00
|
|
|
<!-- 权限列表 -->
|
|
|
|
<select id="list" parameterType="map" resultMap="rolePermissionDTO" useCache="true">
|
2021-02-05 16:52:19 +08:00
|
|
|
SELECT
|
2021-02-24 21:09:51 +08:00
|
|
|
t1.role_id,
|
|
|
|
t1.api_tag,
|
|
|
|
t1.permission_id,
|
|
|
|
t1.permission_type
|
2021-02-05 16:52:19 +08:00
|
|
|
FROM
|
|
|
|
sys_role_permission t1
|
|
|
|
WHERE
|
2021-02-24 21:09:51 +08:00
|
|
|
1 = 1
|
|
|
|
<if test="roleId != null and roleId != ''">
|
|
|
|
AND
|
|
|
|
t1.role_id = #{roleId}
|
|
|
|
</if>
|
|
|
|
<if test="permissionType != null and permissionType != ''">
|
|
|
|
AND
|
|
|
|
t1.permission_type = #{permissionType}
|
|
|
|
</if>
|
|
|
|
<if test="permissionIds != null and permissionIds.size > 0">
|
|
|
|
AND
|
|
|
|
t1.permission_id IN
|
|
|
|
<foreach collection="permissionIds" index="index" open="(" separator="," close=")">
|
|
|
|
#{permissionType[${index}]}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
2021-02-05 16:52:19 +08:00
|
|
|
</select>
|
|
|
|
|
2021-02-02 08:30:42 +08:00
|
|
|
</mapper>
|