micro-fast-IIDYB 角色的权限管理接口开发
This commit is contained in:
@@ -2,6 +2,7 @@ package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsPermission;
|
||||
import com.micro.fast.upms.pojo.UpmsSystem;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -33,8 +34,30 @@ public interface UpmsPermissionMapper extends SsmMapper<UpmsPermission,Integer>
|
||||
int deleteByPrimaryKeys(List<Integer> integers);
|
||||
|
||||
|
||||
@Deprecated
|
||||
List<UpmsPermission> selectByUserIdAndType(@Param("userId") Integer userId, @Param("pType") Integer pType, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* 查询角色已拥有的角色
|
||||
*
|
||||
* @param roleId
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<UpmsPermission> selectByRoleIdAndType(@Param("roleId") Integer roleId, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* 分页查询角色未拥有的角色
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @param type 权限的类型
|
||||
* @param systemId 系统的id
|
||||
* @param name 权限的名称
|
||||
* @return
|
||||
*/
|
||||
List<UpmsPermission> selectPageRoleUnHavePermissionByCondition(@Param("roleId") Integer roleId,
|
||||
@Param("type") Integer type,
|
||||
@Param("systemId") Integer systemId,
|
||||
@Param("name") String name);
|
||||
}
|
||||
|
||||
|
||||
+15
-16
@@ -2,26 +2,25 @@ package com.micro.fast.upms.dao;
|
||||
|
||||
import com.micro.fast.common.dao.SsmMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsRolePermission;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UpmsRolePermissionMapper extends SsmMapper<UpmsRolePermission,Integer> {
|
||||
@Override
|
||||
int deleteByPrimaryKey(Integer rolePermissionId);
|
||||
/**
|
||||
* 批量增加角色的权限
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @return
|
||||
*/
|
||||
int batchInsert(@Param("roleId") Integer roleId,@Param("permissionIds") List<Integer> permissionIds);
|
||||
|
||||
@Override
|
||||
int insert(UpmsRolePermission record);
|
||||
|
||||
@Override
|
||||
int insertSelective(UpmsRolePermission record);
|
||||
|
||||
@Override
|
||||
UpmsRolePermission selectByPrimaryKey(Integer rolePermissionId);
|
||||
|
||||
@Override
|
||||
int updateByPrimaryKeySelective(UpmsRolePermission record);
|
||||
|
||||
@Override
|
||||
int updateByPrimaryKey(UpmsRolePermission record);
|
||||
/**
|
||||
* 批量删除角色的权限
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @return
|
||||
*/
|
||||
int batchDelete(@Param("roleId") Integer roleId,@Param("permissionIds") List<Integer> permissionIds);
|
||||
|
||||
}
|
||||
+253
-232
@@ -1,238 +1,259 @@
|
||||
<?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.micro.fast.upms.dao.UpmsPermissionMapper">
|
||||
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
<constructor>
|
||||
<idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="system_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="pid" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="description" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="type" javaType="java.lang.Byte" jdbcType="TINYINT" />
|
||||
<arg column="permission_value" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="uri" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="icon" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT" />
|
||||
<arg column="orders" javaType="java.lang.Long" jdbcType="BIGINT" />
|
||||
<arg column="ctime" javaType="java.lang.Long" jdbcType="BIGINT" />
|
||||
<arg column="uptime" javaType="java.lang.Long" jdbcType="BIGINT" />
|
||||
<arg column="version" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
</constructor>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, system_id, pid, name, description, type, permission_value, uri, icon, status,
|
||||
orders, ctime, uptime, version
|
||||
</sql>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
update upms_permission
|
||||
<set>
|
||||
<if test="systemId != null">
|
||||
system_id = #{systemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
pid = #{pid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
permission_value = #{permissionValue,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
uri = #{uri,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
orders = #{orders,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null">
|
||||
version = #{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
update upms_permission
|
||||
set system_id = #{systemId,jdbcType=INTEGER},
|
||||
pid = #{pid,jdbcType=INTEGER},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
type = #{type,jdbcType=TINYINT},
|
||||
permission_value = #{permissionValue,jdbcType=VARCHAR},
|
||||
uri = #{uri,jdbcType=VARCHAR},
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
orders = #{orders,jdbcType=BIGINT},
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
version = #{version,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
<constructor>
|
||||
<idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER"/>
|
||||
<arg column="system_id" javaType="java.lang.Integer" jdbcType="INTEGER"/>
|
||||
<arg column="pid" javaType="java.lang.Integer" jdbcType="INTEGER"/>
|
||||
<arg column="name" javaType="java.lang.String" jdbcType="VARCHAR"/>
|
||||
<arg column="description" javaType="java.lang.String" jdbcType="VARCHAR"/>
|
||||
<arg column="type" javaType="java.lang.Byte" jdbcType="TINYINT"/>
|
||||
<arg column="permission_value" javaType="java.lang.String" jdbcType="VARCHAR"/>
|
||||
<arg column="uri" javaType="java.lang.String" jdbcType="VARCHAR"/>
|
||||
<arg column="icon" javaType="java.lang.String" jdbcType="VARCHAR"/>
|
||||
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT"/>
|
||||
<arg column="orders" javaType="java.lang.Long" jdbcType="BIGINT"/>
|
||||
<arg column="ctime" javaType="java.lang.Long" jdbcType="BIGINT"/>
|
||||
<arg column="uptime" javaType="java.lang.Long" jdbcType="BIGINT"/>
|
||||
<arg column="version" javaType="java.lang.Integer" jdbcType="INTEGER"/>
|
||||
</constructor>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, system_id, pid, name, description, type, permission_value, uri, icon, status,
|
||||
orders, ctime, uptime, version
|
||||
</sql>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
update upms_permission
|
||||
<set>
|
||||
<if test="systemId != null">
|
||||
system_id = #{systemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
pid = #{pid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
permission_value = #{permissionValue,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
uri = #{uri,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
orders = #{orders,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null">
|
||||
version = #{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
UPDATE upms_permission
|
||||
SET system_id = #{systemId,jdbcType=INTEGER},
|
||||
pid = #{pid,jdbcType=INTEGER},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
type = #{type,jdbcType=TINYINT},
|
||||
permission_value = #{permissionValue,jdbcType=VARCHAR},
|
||||
uri = #{uri,jdbcType=VARCHAR},
|
||||
icon = #{icon,jdbcType=VARCHAR},
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
orders = #{orders,jdbcType=BIGINT},
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
version = #{version,jdbcType=INTEGER}
|
||||
WHERE id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from upms_permission
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from upms_permission
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
insert into upms_permission (id, system_id, pid,
|
||||
name, description, type,
|
||||
permission_value, uri, icon,
|
||||
status, orders, ctime,
|
||||
uptime, version)
|
||||
values (#{id,jdbcType=INTEGER}, #{systemId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER},
|
||||
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT},
|
||||
#{permissionValue,jdbcType=VARCHAR}, #{uri,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=TINYINT}, #{orders,jdbcType=BIGINT}, #{ctime,jdbcType=BIGINT},
|
||||
#{uptime,jdbcType=BIGINT}, #{version,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
insert into upms_permission
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="systemId != null">
|
||||
system_id,
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
pid,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
permission_value,
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
uri,
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
orders,
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
ctime,
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
uptime,
|
||||
</if>
|
||||
<if test="version != null">
|
||||
version,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="systemId != null">
|
||||
#{systemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
#{pid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
#{permissionValue,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
#{uri,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
#{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
#{orders,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
#{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
#{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null">
|
||||
#{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from upms_permission
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
DELETE FROM upms_permission
|
||||
WHERE id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
INSERT INTO upms_permission (id, system_id, pid,
|
||||
name, description, type,
|
||||
permission_value, uri, icon,
|
||||
status, orders, ctime,
|
||||
uptime, version)
|
||||
VALUES (#{id,jdbcType=INTEGER}, #{systemId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER},
|
||||
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
|
||||
#{type,jdbcType=TINYINT},
|
||||
#{permissionValue,jdbcType=VARCHAR}, #{uri,jdbcType=VARCHAR},
|
||||
#{icon,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=TINYINT}, #{orders,jdbcType=BIGINT}, #{ctime,jdbcType=BIGINT},
|
||||
#{uptime,jdbcType=BIGINT}, #{version,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
insert into upms_permission
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="systemId != null">
|
||||
system_id,
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
pid,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type,
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
permission_value,
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
uri,
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
icon,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
orders,
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
ctime,
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
uptime,
|
||||
</if>
|
||||
<if test="version != null">
|
||||
version,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="systemId != null">
|
||||
#{systemId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
#{pid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="permissionValue != null">
|
||||
#{permissionValue,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="uri != null">
|
||||
#{uri,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="icon != null">
|
||||
#{icon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="orders != null">
|
||||
#{orders,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="ctime != null">
|
||||
#{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null">
|
||||
#{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null">
|
||||
#{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!--自定义的sql-->
|
||||
<select id="selectByCondition" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT <include refid="Base_Column_List"/> FROM upms_permission
|
||||
<where>
|
||||
<if test="systemId != null">
|
||||
and system_id = #{systemId}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
and name like #{name}
|
||||
</if>
|
||||
<if test="description != null">
|
||||
and description like #{description}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByUserIdAndType" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT <include refid="Base_Column_List"/> FROM upms_permission WHERE type = #{pType}
|
||||
and id in (select permission_id from upms_user_permission where user_id = #{userId} and type =#{type} )
|
||||
</select>
|
||||
<select id="selectByRoleIdAndType" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT <include refid="Base_Column_List"/> FROM upms_permission WHERE type = #{type}
|
||||
and id in (select permission_id from upms_role_permission where role_id = #{roleId})
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKeys">
|
||||
DELETE FROM upms_permission WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")" >
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
<!--自定义的sql-->
|
||||
<select id="selectByCondition" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM upms_permission
|
||||
<where>
|
||||
<if test="systemId != null">
|
||||
and system_id = #{systemId}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
and name like #{name}
|
||||
</if>
|
||||
<if test="description != null">
|
||||
and description like #{description}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByUserIdAndType" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM upms_permission WHERE type = #{pType}
|
||||
and id in (select permission_id from upms_user_permission where user_id = #{userId} and type =#{type} )
|
||||
</select>
|
||||
<select id="selectByRoleIdAndType" resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM upms_permission WHERE type = #{type}
|
||||
and id in (select permission_id from upms_role_permission where role_id = #{roleId})
|
||||
</select>
|
||||
<select id="selectPageRoleUnHavePermissionByCondition"
|
||||
resultType="com.micro.fast.upms.pojo.UpmsPermission">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM upms_permission WHERE id NOT IN
|
||||
(SELECT permission_id FROM upms_role_permission WHERE role_id = #{roleId}) and type = #{type}
|
||||
<if test="systemId != null">
|
||||
and systemId = #{systemId}
|
||||
</if>
|
||||
<if test="name != null">
|
||||
and name = #{name}
|
||||
</if>
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKeys">
|
||||
DELETE FROM upms_permission WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
+14
-90
@@ -1,6 +1,7 @@
|
||||
<?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.micro.fast.upms.dao.UpmsRolePermissionMapper" >
|
||||
<cache flushInterval="60000" readOnly="true" size="1200" />
|
||||
<resultMap id="BaseResultMap" type="com.micro.fast.upms.pojo.UpmsRolePermission" >
|
||||
<constructor >
|
||||
<idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" />
|
||||
@@ -14,95 +15,18 @@
|
||||
<sql id="Base_Column_List" >
|
||||
id, role_id, permission_id, ctime, uptime, version
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from upms_role_permission
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
|
||||
delete from upms_role_permission
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
<!--自定义-->
|
||||
<insert id="batchInsert">
|
||||
INSERT INTO upms_role_permission (role_id,permission_id,ctime,version) VALUES
|
||||
<foreach collection="permissionIds" close=" " item="permissionId" open=" " separator=",">
|
||||
(#{roleId},#{permissionId},unix_timestamp(now()),0)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="batchDelete">
|
||||
DELETE FROM upms_role_permission WHERE role_id = #{roleId} and permission_id in
|
||||
<foreach collection="permissionIds" separator="," open="(" close=")" item="permissionId" >
|
||||
#{permissionId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.micro.fast.upms.pojo.UpmsRolePermission" >
|
||||
insert into upms_role_permission (id, role_id, permission_id,
|
||||
ctime, uptime, version
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}, #{permissionId,jdbcType=INTEGER},
|
||||
#{ctime,jdbcType=BIGINT}, #{uptime,jdbcType=BIGINT}, #{version,jdbcType=INTEGER}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.micro.fast.upms.pojo.UpmsRolePermission" >
|
||||
insert into upms_role_permission
|
||||
<trim prefix="(" suffix=")" suffixOverrides="," >
|
||||
<if test="id != null" >
|
||||
id,
|
||||
</if>
|
||||
<if test="roleId != null" >
|
||||
role_id,
|
||||
</if>
|
||||
<if test="permissionId != null" >
|
||||
permission_id,
|
||||
</if>
|
||||
<if test="ctime != null" >
|
||||
ctime,
|
||||
</if>
|
||||
<if test="uptime != null" >
|
||||
uptime,
|
||||
</if>
|
||||
<if test="version != null" >
|
||||
version,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
||||
<if test="id != null" >
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="roleId != null" >
|
||||
#{roleId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="permissionId != null" >
|
||||
#{permissionId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="ctime != null" >
|
||||
#{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null" >
|
||||
#{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null" >
|
||||
#{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.micro.fast.upms.pojo.UpmsRolePermission" >
|
||||
update upms_role_permission
|
||||
<set >
|
||||
<if test="roleId != null" >
|
||||
role_id = #{roleId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="permissionId != null" >
|
||||
permission_id = #{permissionId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="ctime != null" >
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="uptime != null" >
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="version != null" >
|
||||
version = #{version,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.micro.fast.upms.pojo.UpmsRolePermission" >
|
||||
update upms_role_permission
|
||||
set role_id = #{roleId,jdbcType=INTEGER},
|
||||
permission_id = #{permissionId,jdbcType=INTEGER},
|
||||
ctime = #{ctime,jdbcType=BIGINT},
|
||||
uptime = #{uptime,jdbcType=BIGINT},
|
||||
version = #{version,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
+7
-2
@@ -2,7 +2,6 @@ package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.common.service.SsmService;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
@@ -22,6 +21,12 @@ public interface UpmsPermissionService<T,ID> extends SsmService<T,ID>{
|
||||
ServerResponse getPermissionByRoleAndType(Integer type,Integer roleId);
|
||||
|
||||
/**
|
||||
* 按照类型
|
||||
* 根据权限的类型,权限所属系统,权限的名称查询角色未拥有的权限
|
||||
* @param roleId 角色的id
|
||||
* @param type 权限的类型
|
||||
* @param systemId 系统的id
|
||||
* @param name 权限的名称
|
||||
* @return
|
||||
*/
|
||||
ServerResponse getUnHavePermissionByRoleIdAndTypeOrSystemIdOrPermissionName(Integer roleId, Integer type, Integer systemId, String name, Integer pageNum, Integer pageSzie);
|
||||
}
|
||||
+20
@@ -1,8 +1,28 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色权限管理接口
|
||||
* @author lsy
|
||||
*/
|
||||
public interface UpmsRolePermissionService{
|
||||
|
||||
/**
|
||||
* 批量增加角色权限
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchAddRolePermission(Integer roleId,List<Integer> permissionIds);
|
||||
|
||||
/**
|
||||
* 批量删除角色权限
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @return
|
||||
*/
|
||||
ServerResponse batchDeleteRolePermission(Integer roleId,List<Integer> permissionIds);
|
||||
}
|
||||
+7
-8
@@ -5,6 +5,7 @@ import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.service.UpmsRolePermissionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -15,10 +16,10 @@ import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* 角色权限管理
|
||||
* @author lsy
|
||||
*/
|
||||
@Api("upmsRolePermission")
|
||||
@Api("角色权限管理")
|
||||
@RestController
|
||||
@RequestMapping("/upmsRolePermission")
|
||||
public class UpmsRolePermissionController {
|
||||
@@ -29,15 +30,13 @@ public class UpmsRolePermissionController {
|
||||
@ApiOperation("给角色批量添加权限")
|
||||
@PostMapping("/addRolePermission")
|
||||
public ServerResponse addRolePermission(@RequestParam("roleId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入角色id") Integer roleId,
|
||||
@RequestParam("permissionIds") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入权限id的集合") ArrayList<Integer> permissionIds){
|
||||
// todo
|
||||
return null;
|
||||
@RequestParam("permissionIds") @NotEmpty(message = BaseConst.BASEMSG_PREFIX+"请传入权限id的集合") ArrayList<Integer> permissionIds){
|
||||
return upmsRolePermissionService.batchAddRolePermission(roleId,permissionIds);
|
||||
}
|
||||
@ApiOperation("给角色批量删除权限")
|
||||
@PostMapping("/deleteRolePermission")
|
||||
public ServerResponse deleteRolePermission(@RequestParam("roleId") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入角色id") Integer roleId,
|
||||
@RequestParam("permissionIds") @NotNull(message = BaseConst.BASEMSG_PREFIX+"请传入权限id的集合") ArrayList<Integer> permissionIds){
|
||||
// todo
|
||||
return null;
|
||||
@RequestParam("permissionIds") @NotEmpty ArrayList<Integer> permissionIds){
|
||||
return upmsRolePermissionService.batchDeleteRolePermission(roleId,permissionIds);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user