SSM实现角色权限管理,批量删除,filter

本文介绍了使用SSM(Spring Security、Spring MVC、MyBatis)框架实现角色权限管理的功能,包括Role和UserRole实体类的创建、RoleDao接口及Mapper的配置、RoleServiceImpl服务实现、Controller中角色管理和批量删除的接口设计,以及一个过滤器类的使用。通过示例展示了批量删除操作的执行和结果验证,以及在角色管理中为用户分配角色的过程,确保数据在数据库中正确更新。

我们接着之前的项目进行开发。
因为要进行角色管理,我们根据数据库结构,添加两个bean类Role和UserRole,属性结构如下:

  • Role类
    在这里插入图片描述
  • UserRole类
    在这里插入图片描述

之后添加RoleDao接口,对bean进行管理

public interface RoleDao {
   
   
    List<Integer> findRoleIdByUserId(int userId);
    List<Role> findRoleByUserId(int id);
    void addRole(UserRole userRole);
}

同样,创建新的Mapper,来对应RoleDao

<mapper namespace="com.zhongruan.dao.RoleDao" >
    <select id="findRoleIdByUserId" parameterType="int" resultType="int">
        select roleId from user_role where userId=#{userId}
            </select>
    <select id="findRoleByUserId" parameterType="int" resultType="role">
        select * from tb_role where id not in (select roleId from user_role where userId=#{id})
    </select>
    <insert
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值