SpringBoot+Shiro+LayUI权限管理系统项目-4.实现部门管理
1.说明
只讲解关键部分,详细看源码,文章下方捐赠或QQ联系捐赠获取。
2.功能展示
3.业务模型
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_dept")
public class SysDept implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 上级部门ID
*/
private Integer pid;
/**
* 所有上级部门ID, 0为根,格式:0,1,2,
*/
private String pids;
/**
* 部门名称
*/
private String deptName;
/**
* 部门编码
*/
private String deptCode;
@TableField(exist=false)
private String pname;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 创建人
*/
private String createUser;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 修改人
*/
private String updateUser;
}
4.控制器
@Controller
@RequestMapping("/sysDept/")
public class SysDeptController {
@Autowired
private SysDeptService sysDeptService;
@GetMapping("listUI")
public String listUI() {
return "dept/list";
}
@RequestMapping("form")
public String form(Map<String,Object> map) {
return "dept/form";
}
@GetMapping("toSelectTree")
public String toSelectTree() {
return "dept/selectTree";
}
@PostMapping("list")
@ResponseBody
public Result<IPage<SysDept>> list(@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize) {
// 构造分页查询条件
QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
Page<SysDept> page = new Page<>(pageNo,pageSize);
IPage<SysDept> result = sysDeptService.selectDeptList(page, null);
// 设置总记录数
result.setTotal(sysDeptService.count(queryWrapper));
sysDeptService.count(queryWrapper);
return ResultUtil.ok(result);
}
@GetMapping("listTree")
@ResponseBody
public Object listTree() {
// User user = getUserEntity();
// 构建查询条件,从根查找
QueryWrapper<SysDept> queryWrapper = new QueryWrapper<>();
// queryWrapper.like("pids", user.getDept().getPids()+user.getDeptId()).or().eq("id",user.getDeptId());
queryWrapper.like("pids", 0);
List<SysDept> list = sysDeptService.list(queryWrapper);
return list;
}
@OperLog(operModule = "部门管理",operType = "修改",operDesc = "修改部门")
@PostMapping("save")
@ResponseBody
public Result<String> add(@RequestBody SysDept dept){
// 新增
if(dept.getId()==null){
dept.setCreateTime(new Date());
dept.setCreateUser("TODO");
}
// 设置上级部门ID
if(dept.getPid()!=0){
// 获取上级部门的ids然后拼接上级部门id
SysDept parentDept = sysDeptService.getById(dept.getPid());
dept.setPids(parentDept.getPids()+dept.getPid()+",");
}
if(!sysDeptService.saveOrUpdate(dept)){
return ResultUtil.fail("添加失败");
}
return ResultUtil.ok("添加成功");
}
@OperLog(operModule = "部门管理",operType = "删除",operDesc = "删除部门")
@PostMapping("/remove")
@ResponseBody
public Result<String> remove(@RequestParam Integer id){
sysDeptService.removeById(id);
return ResultUtil.ok("删除成功!");
}
@RequestMapping(value="{id}/select",method= RequestMethod.GET)
public String select(Map<String,Object> map,@PathVariable Integer id) {
SysDept sysDept = sysDeptService.getById(id);
map.put("record",sysDept);
return "sysDept/edit";
}
5.前端页面
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<title>部门列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" th:href="@{/static/plugin/layui/css/layui.css}" media="all">
</head>
<body>
<table class="layui-hide" id="SysDept" lay-filter="SysDept"></table>
<input type="text" id="ctx" hidden="hidden" th:value="${#request.getContextPath()}">
<!--编辑表单-->
<div class="layui-row" id="editForm" style="display:none;">
<div class="layui-col-md10">
<form class="layui-form layui-from-pane" action="" style="margin-top:20px">
<input type="text" id="id" name="id" hidden="hidden">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">上级部门</label>
<div class="layui-input-inline">
<input type="text" id="pname" name="pname" required lay-verify="required" autocomplete="off"
placeholder="" class="layui-input">
</div>
<button class="layui-btn layui-btn-sm" id="chooseDeptBtn" type="button">
<i class="layui-icon"></i>
</button>
<input type="hidden" id="pid" name="pid"/>
</div>
<div class="layui-inline">
<label class="layui-form-label">部门名称</label>
<div class="layui-input-inline">
<input type="text" id="deptName" name="deptName" required lay-verify="required" autocomplete="off"
placeholder="" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">部门编码</label>
<div class="layui-input-inline">
<input type="text" id="deptCode" name="deptCode" required lay-verify="required" autocomplete="off"
placeholder="" class="layui-input">
</div>
</div>
</div>
<div class="layui-form-item" style="margin-top:40px">
<div class="layui-input-block">
<button class="layui-btn layui-btn-submit " lay-submit="" lay-filter="confirm">确认</button>
<button type="button" class="layui-btn layui-btn-primary" id="back">关闭</button>
</div>
</div>
</form>
</div>
</div>
<script type="text/html" id="deptToolBar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="add" shiro:hasPermission="dept:add">新增</button>
</div>
</script>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="dept:edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" shiro:hasPermission="dept:remove">删除</a>
</script>
6 获取源码
捐赠任意金额,评论区留下邮箱发送 :)
SpringBoot+Shiro+LayUI权限管理系统项目-4.实现部门管理的更多相关文章
- SpringBoot框架的权限管理系统
springBoot框架的权限管理系统,支持操作权限和数据权限,后端采用springBoot,MyBatis,Shiro,前端使用adminLTE,Vue.js,bootstrap-table.tre ...
- SpringBoot&Shiro实现权限管理
SpringBoot&Shiro实现权限管理 引言 相信大家前来看这篇文章的时候,是有SpringBoot和Shiro基础的,所以本文只介绍整合的步骤,如果哪里写的不好,恳请大家能指出错误,谢 ...
- Asp.Net Core 项目实战之权限管理系统(6) 功能管理
0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...
- SpringBoot+Shiro学习(七):Filter过滤器管理
SpringBoot+Shiro学习(七):Filter过滤器管理 Hiwayz 关注 0.5 2018.09.06 19:09* 字数 1070 阅读 5922评论 1喜欢 20 先从我们写的一个 ...
- spring boot + mybatis + layui + shiro后台权限管理系统
后台管理系统 版本更新 后续版本更新内容 链接入口: springboot + shiro之登录人数限制.登录判断重定向.session时间设置:https://blog.51cto.com/wyai ...
- niaobulashi-一个基于springboot shrio的权限管理系统
github项目地址:https://github.com/niaobulashi/niaobulashi springboot学习地址:http://www.ityouknow.com/spring ...
- .NET Core/.NET5/.NET6 开源项目汇总5:权限管理系统项目
系列目录 [已更新最新开发文章,点击查看详细] 企业管理系统一般包含后台管理UI.组织机构管理.权限管理.日志.数据访问.表单.工作流等常用必备功能.下面收集的几款优秀开源的管理系统,值得大家 ...
- 基于easyUI实现权限管理系统(三)——角色管理
此文章是基于 EasyUI+Knockout实现经典表单的查看.编辑 一. 相关文件介绍 1. role.jsp:角色管理界面 <!DOCTYPE html PUBLIC "-//W3 ...
- springboot + shiro 构建权限模块
权限模块基本流程 权限模块的基本流程:用户申请账号和权限 -->登陆认证 -->安全管控模块认证 -->调用具体权限模块(基于角色的权限控制) --> 登陆成功 -->访 ...
- 基于easyUI实现权限管理系统(四)——用户管理
此文章是基于 EasyUI+Knockout实现经典表单的查看.编辑 一. 相关文件介绍 1. user.jsp:用户管理界面 <!DOCTYPE html PUBLIC "-//W3 ...
随机推荐
- Python Code_03数据类型
数据类型 author : 写bug的盼盼 development time : 2021/8/27 19:59 变量定义 name = '阿哈' print(name) print('标识',id( ...
- [转帖]Kubernetes 1.23:IPv4/IPv6 双协议栈网络达到 GA
https://kubernetes.io/zh-cn/blog/2021/12/08/dual-stack-networking-ga/#:~:text=Kubernetes%201.23%EF%B ...
- [转帖]SQL Server数据库重建索引、更新统计信息
https://vip.kingdee.com/article/183932?productLineId=8 SQL Server数据库有时由于长期未做索引重建,导致SQL执行效率下降,当表的索引碎片 ...
- [粘贴]github-redis-rdb-cli
redis-rdb-cli A tool that can parse, filter, split, merge rdb and analyze memory usage offline. It c ...
- [转帖]数据库系列之TiDB存储引擎TiKV实现机制
TiDB存储引擎TiKV是基于RocksDB存储引擎,通过Raft分布式算法保证数据一致性.本文详细介绍了TiKV存储引擎的实现机制和原理,加深对TiDB底层存储架构的理解. 1.TiDB存储引擎Ti ...
- [转帖]浅谈Armv8-A处理器
https://www.elecfans.com/emb/dsp/202208291886182.html 众所周知,ARM是一家设计并授权处理器和相应IP(比如互连总线,中断处理器,图像处理器等等) ...
- 日常测试进行beans比较的简单方法
日常测试进行beans比较的简单方法 摘要 想每天把有变化的bean抓取出来有新增的beans时能够及时进行分析和介入 保证beans 都是符合规范的. 方式和方法 开启actuator 打开bean ...
- 金蝶Cosmic虚拟机简单使用与总结
背景 知己知彼 简单学习下友商发出来的测试软件 看看有否对自己现在的工作有所指导 也看看对方的部署方式有啥优缺点 当然了仅是测试, 不是生产软件可能有失真. 注意 我没有测试序列号, 登录系统耗时很久 ...
- mysql8 CentOS7 简要安装说明
1. 卸载mariadb rpm -qa |grep mariadb |xargs yum remove -y比较简单的卸载办法. 2. 安装所有的rpm包. yum localinstall *.r ...
- 使用rpm打包nacos然后部署为systemd服务开机自动启动的方法
背景 Nacos是阿里开源的服务注册组件,能够简单的实现微服务的注册与发现机制. 但是官方并没有提供 sytemd的服务脚本, 也没有提供rpm包的方式. 公司里面使用 nacos的场景越来越多, 部 ...