1.期末项目--基于springboot开发的员工管理系统数据库2.node.js的删除安装及vue-admin-template的下载3.前端菜单初始化4.登陆页修改5.前端项目初始化6.前端项目创建7.注销接口8.获取用户信息接口9.登录接口10.公共响应类11.Mybatis-plus代码生成12.创建后端项目13.登陆接口梳理14.标签栏导航15.删除功能16.用户修改 17.密码加密18.表单提交19.表单验证20.新增接口&页面布局21.用户列表查询对接后端22.用户列表查询接口23.用户管理页面布局24.前后端对接25.遗留小问题26.jwt整合27.角色权限设置显示28.角色管理29.Swagger整合30.jwt验证拦截器31.用户角色修改&删除32.用户角色回显33.用户角色提交34.用户角色选项35.角色权限修改&删除36.角色权限回显
37.角色权限新增提交
1. 拿到每个树节点用来作为唯一标识的属性
2. 获取选中的key
测试一下
拿到半选状态的数据
3. RoleServiceImpl
点击查看代码
package com.example.sys.service.impl;
import com.example.sys.entity.Role;
import com.example.sys.mapper.RoleMapper;
import com.example.sys.mapper.RoleMenuMapper;
import com.example.sys.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* <p>
* 服务实现类
* </p>
*
* @author CanisRufus
* @since 2023-06-30
*/
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
@Resource
@Transactional
private RoleMenuMapper roleMenuMapper;
@Override
public void addRole(Role role){
//写入角色表
this.baseMapper.insert(role);
//写入角色菜单
if (null != role.getMenuIdList()){
for (Integer menuId : role.getMenuIdList()){
roleMenuMapper.insert(new RoleMenu(null,role.getRoleId(),menuId));
}
}
}
}
4. role的实体类
点击查看代码
@Data
@TableName("x_role")
@AllArgsConstructor
@NoArgsConstructor
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "role_id", type = IdType.AUTO)
private Integer roleId;
private String roleName;
private String roleDesc;
@TableField(exist = false)
private List<Integer> menuIdList;
}
5. RoleMenu
点击查看代码
@TableName("x_role_menu")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RoleMenu implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer roleId;
private Integer menuId;
}
6. 测试(已解决)
数据库中表x_user_menu没有变化,为什么?(插个飞雷神先)
其他的还是有
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现