From df745448f2dc07a7b469aacbcc5a1a336f93f1b9 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 24 Jun 2019 00:50:26 +0800 Subject: [PATCH] :tada: 2.0.4.RELEASE --- blade-auth/pom.xml | 2 +- blade-common/pom.xml | 2 +- blade-gateway/pom.xml | 2 +- blade-ops-api/blade-flow-api/pom.xml | 2 +- blade-ops-api/pom.xml | 4 +- blade-ops/blade-admin/pom.xml | 2 +- blade-ops/blade-develop/pom.xml | 2 +- blade-ops/blade-flow-design/pom.xml | 2 +- blade-ops/blade-flow/pom.xml | 2 +- blade-ops/blade-log/pom.xml | 2 +- blade-ops/blade-resource/pom.xml | 2 +- blade-ops/pom.xml | 4 +- blade-service-api/blade-desk-api/pom.xml | 2 +- blade-service-api/blade-dict-api/pom.xml | 2 +- blade-service-api/blade-system-api/pom.xml | 2 +- .../springblade/system/entity/DataScope.java | 82 +++++++ .../org/springblade/system/entity/Dept.java | 20 +- .../springblade/system/entity/RoleScope.java | 65 ++++++ .../springblade/system/vo/CheckedTreeVO.java | 35 +++ .../org/springblade/system/vo/DeptVO.java | 7 +- .../springblade/system/vo/GrantTreeVO.java | 35 +++ blade-service-api/blade-user-api/pom.xml | 2 +- blade-service-api/pom.xml | 4 +- blade-service/blade-desk/pom.xml | 2 +- blade-service/blade-system/pom.xml | 2 +- .../controller/DataScopeController.java | 113 ++++++++++ .../system/controller/DeptController.java | 2 +- .../system/controller/MenuController.java | 16 +- .../system/controller/RoleController.java | 11 +- .../system/mapper/DataScopeMapper.java | 30 +++ .../system/mapper/DataScopeMapper.xml | 5 + .../springblade/system/mapper/DeptMapper.xml | 2 + .../springblade/system/mapper/MenuMapper.java | 17 +- .../springblade/system/mapper/MenuMapper.xml | 206 +++++++++++++----- .../system/mapper/RoleScopeMapper.java | 29 +++ .../system/mapper/RoleScopeMapper.xml | 12 + .../system/service/IDataScopeService.java | 30 +++ .../system/service/IDeptService.java | 8 + .../system/service/IMenuService.java | 16 ++ .../system/service/IRoleScopeService.java | 29 +++ .../system/service/IRoleService.java | 2 +- .../service/impl/DataScopeServiceImpl.java | 34 +++ .../system/service/impl/DeptServiceImpl.java | 11 + .../system/service/impl/MenuServiceImpl.java | 20 +- .../service/impl/RoleScopeServiceImpl.java | 33 +++ .../system/service/impl/RoleServiceImpl.java | 24 +- .../system/wrapper/DeptWrapper.java | 11 +- blade-service/blade-user/pom.xml | 2 +- blade-service/pom.xml | 4 +- doc/sql/bladex-datascope-update.sql | 20 +- pom.xml | 8 +- script/docker/.env | 2 +- 52 files changed, 870 insertions(+), 115 deletions(-) create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/CheckedTreeVO.java create mode 100644 blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.xml create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.xml create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/IDataScopeService.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleScopeService.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DataScopeServiceImpl.java create mode 100644 blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleScopeServiceImpl.java diff --git a/blade-auth/pom.xml b/blade-auth/pom.xml index c0329157..4c6aa5f0 100644 --- a/blade-auth/pom.xml +++ b/blade-auth/pom.xml @@ -8,7 +8,7 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE blade-auth diff --git a/blade-common/pom.xml b/blade-common/pom.xml index 4234d604..c94c04dd 100644 --- a/blade-common/pom.xml +++ b/blade-common/pom.xml @@ -5,7 +5,7 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-gateway/pom.xml b/blade-gateway/pom.xml index 04cbc383..9339981c 100644 --- a/blade-gateway/pom.xml +++ b/blade-gateway/pom.xml @@ -5,7 +5,7 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops-api/blade-flow-api/pom.xml b/blade-ops-api/blade-flow-api/pom.xml index 697479c1..eda12fe0 100644 --- a/blade-ops-api/blade-flow-api/pom.xml +++ b/blade-ops-api/blade-flow-api/pom.xml @@ -5,7 +5,7 @@ blade-ops-api org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops-api/pom.xml b/blade-ops-api/pom.xml index eb8d5dc4..fdcaf393 100644 --- a/blade-ops-api/pom.xml +++ b/blade-ops-api/pom.xml @@ -5,13 +5,13 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 blade-ops-api ${project.artifactId} - 2.0.3.RELEASE + 2.0.4.RELEASE pom BladeX 微服务API集合 diff --git a/blade-ops/blade-admin/pom.xml b/blade-ops/blade-admin/pom.xml index 9944d72f..20137266 100644 --- a/blade-ops/blade-admin/pom.xml +++ b/blade-ops/blade-admin/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/blade-develop/pom.xml b/blade-ops/blade-develop/pom.xml index da8c36a9..0982bdd6 100644 --- a/blade-ops/blade-develop/pom.xml +++ b/blade-ops/blade-develop/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-ops - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/blade-flow-design/pom.xml b/blade-ops/blade-flow-design/pom.xml index 2b2ecada..97426475 100644 --- a/blade-ops/blade-flow-design/pom.xml +++ b/blade-ops/blade-flow-design/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/blade-flow/pom.xml b/blade-ops/blade-flow/pom.xml index 97050023..351871d1 100644 --- a/blade-ops/blade-flow/pom.xml +++ b/blade-ops/blade-flow/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/blade-log/pom.xml b/blade-ops/blade-log/pom.xml index b5e1fae4..cd6bfff2 100644 --- a/blade-ops/blade-log/pom.xml +++ b/blade-ops/blade-log/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/blade-resource/pom.xml b/blade-ops/blade-resource/pom.xml index 5c6697b8..7cd4636d 100644 --- a/blade-ops/blade-resource/pom.xml +++ b/blade-ops/blade-resource/pom.xml @@ -5,7 +5,7 @@ blade-ops org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-ops/pom.xml b/blade-ops/pom.xml index 0c863271..4c8f5125 100644 --- a/blade-ops/pom.xml +++ b/blade-ops/pom.xml @@ -5,13 +5,13 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 blade-ops ${project.artifactId} - 2.0.3.RELEASE + 2.0.4.RELEASE pom diff --git a/blade-service-api/blade-desk-api/pom.xml b/blade-service-api/blade-desk-api/pom.xml index 93344b77..a511e750 100644 --- a/blade-service-api/blade-desk-api/pom.xml +++ b/blade-service-api/blade-desk-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service-api/blade-dict-api/pom.xml b/blade-service-api/blade-dict-api/pom.xml index da7aa800..c3439bc0 100644 --- a/blade-service-api/blade-dict-api/pom.xml +++ b/blade-service-api/blade-dict-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service-api/blade-system-api/pom.xml b/blade-service-api/blade-system-api/pom.xml index 33b481ce..7803f89d 100644 --- a/blade-service-api/blade-system-api/pom.xml +++ b/blade-service-api/blade-system-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java new file mode 100644 index 00000000..bf49e25e --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/DataScope.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 实体类 + * + * @author BladeX + * @since 2019-06-23 + */ +@Data +@TableName("blade_data_scope") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "DataScope对象", description = "DataScope对象") +public class DataScope extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 菜单主键 + */ + @ApiModelProperty(value = "菜单主键") + private Long menuId; + /** + * 资源编号 + */ + @ApiModelProperty(value = "资源编号") + private String resourceCode; + /** + * 数据权限名称 + */ + @ApiModelProperty(value = "数据权限名称") + private String scopeName; + /** + * 数据权限类名 + */ + @ApiModelProperty(value = "数据权限类名") + private String scopeClass; + /** + * 数据权限字段 + */ + @ApiModelProperty(value = "数据权限字段") + private String scopeColumn; + /** + * 数据权限类型 + */ + @ApiModelProperty(value = "数据权限类型") + private Integer scopeType; + /** + * 数据权限值域 + */ + @ApiModelProperty(value = "数据权限值域") + private String scopeValue; + /** + * 数据权限备注 + */ + @ApiModelProperty(value = "数据权限备注") + private String remark; + + +} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java index 46e23997..348ac2ac 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/Dept.java @@ -62,17 +62,29 @@ public class Dept implements Serializable { private Long parentId; /** - * 部门名 + * 机构名 */ - @ApiModelProperty(value = "部门名") + @ApiModelProperty(value = "机构名") private String deptName; /** - * 部门全称 + * 机构全称 */ - @ApiModelProperty(value = "部门全称") + @ApiModelProperty(value = "机构全称") private String fullName; + /** + * 租级机构主键 + */ + @ApiModelProperty(value = "祖级机构主键") + private String ancestors; + + /** + * 机构类型 + */ + @ApiModelProperty(value = "机构类型") + private Integer deptCategory; + /** * 排序 */ diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java new file mode 100644 index 00000000..84a5160e --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/entity/RoleScope.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 实体类 + * + * @author Chill + */ +@Data +@TableName("blade_role_scope") +@ApiModel(value = "RoleScope对象", description = "RoleScope对象") +public class RoleScope implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.ID_WORKER) + private Long id; + + /** + * 数据权限id + */ + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "数据权限id") + private Long scopeId; + + /** + * 角色id + */ + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "角色id") + private Long roleId; + + +} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/CheckedTreeVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/CheckedTreeVO.java new file mode 100644 index 00000000..4298eeb3 --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/CheckedTreeVO.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.vo; + +import lombok.Data; + +import java.util.List; + +/** + * CheckedTreeVO + * + * @author Chill + */ +@Data +public class CheckedTreeVO { + + private List menu; + + private List scope; + +} diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java index 56d317f0..819e5089 100644 --- a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/DeptVO.java @@ -66,8 +66,13 @@ public class DeptVO extends Dept implements INode { } /** - * 上级部门 + * 上级机构 */ private String parentName; + /** + * 机构类型名称 + */ + private String deptCategoryName; + } diff --git a/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java new file mode 100644 index 00000000..03a1dbd7 --- /dev/null +++ b/blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantTreeVO.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.vo; + +import lombok.Data; + +import java.util.List; + +/** + * GrantTreeVO + * + * @author Chill + */ +@Data +public class GrantTreeVO { + + private List menu; + + private List scope; + +} diff --git a/blade-service-api/blade-user-api/pom.xml b/blade-service-api/blade-user-api/pom.xml index 580ef98e..a1efd30e 100644 --- a/blade-service-api/blade-user-api/pom.xml +++ b/blade-service-api/blade-user-api/pom.xml @@ -5,7 +5,7 @@ blade-service-api org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service-api/pom.xml b/blade-service-api/pom.xml index d6383ed1..6be9d972 100644 --- a/blade-service-api/pom.xml +++ b/blade-service-api/pom.xml @@ -5,13 +5,13 @@ BladeX org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 blade-service-api ${project.artifactId} - 2.0.3.RELEASE + 2.0.4.RELEASE pom BladeX 微服务API集合 diff --git a/blade-service/blade-desk/pom.xml b/blade-service/blade-desk/pom.xml index 205ea6da..5af561be 100644 --- a/blade-service/blade-desk/pom.xml +++ b/blade-service/blade-desk/pom.xml @@ -6,7 +6,7 @@ org.springblade blade-service - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service/blade-system/pom.xml b/blade-service/blade-system/pom.xml index 2c55008c..9220a731 100644 --- a/blade-service/blade-system/pom.xml +++ b/blade-service/blade-system/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java new file mode 100644 index 00000000..fabc440e --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.system.entity.DataScope; +import org.springblade.system.service.IDataScopeService; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; + +/** + * 数据权限控制器 + * + * @author BladeX + * @since 2019-06-23 + */ +@RestController +@AllArgsConstructor +@RequestMapping("data-scope") +@Api(value = "数据权限", tags = "接口") +public class DataScopeController extends BladeController { + + private IDataScopeService dataScopeService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperation(value = "详情", notes = "传入dataScope", position = 1) + public R detail(DataScope dataScope) { + DataScope detail = dataScopeService.getOne(Condition.getQueryWrapper(dataScope)); + return R.data(detail); + } + + /** + * 分页 + */ + @GetMapping("/list") + @ApiOperation(value = "分页", notes = "传入dataScope", position = 2) + public R> list(DataScope dataScope, Query query) { + IPage pages = dataScopeService.page(Condition.getPage(query), Condition.getQueryWrapper(dataScope)); + return R.data(pages); + } + + /** + * 新增 + */ + @PostMapping("/save") + @CacheEvict(cacheNames = {SYS_CACHE}) + @ApiOperation(value = "新增", notes = "传入dataScope", position = 4) + public R save(@Valid @RequestBody DataScope dataScope) { + return R.status(dataScopeService.save(dataScope)); + } + + /** + * 修改 + */ + @PostMapping("/update") + @CacheEvict(cacheNames = {SYS_CACHE}) + @ApiOperation(value = "修改", notes = "传入dataScope", position = 5) + public R update(@Valid @RequestBody DataScope dataScope) { + return R.status(dataScopeService.updateById(dataScope)); + } + + /** + * 新增或修改 + */ + @PostMapping("/submit") + @CacheEvict(cacheNames = {SYS_CACHE}) + @ApiOperation(value = "新增或修改", notes = "传入dataScope", position = 6) + public R submit(@Valid @RequestBody DataScope dataScope) { + return R.status(dataScopeService.saveOrUpdate(dataScope)); + } + + + /** + * 删除 + */ + @PostMapping("/remove") + @CacheEvict(cacheNames = {SYS_CACHE}) + @ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7) + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(dataScopeService.deleteLogic(Func.toLongList(ids))); + } + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index 3c94613e..c835541c 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java @@ -103,7 +103,7 @@ public class DeptController extends BladeController { if (Func.isEmpty(dept.getId())) { dept.setTenantId(user.getTenantId()); } - return R.status(deptService.saveOrUpdate(dept)); + return R.status(deptService.submit(dept)); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index 32763568..5db82ccd 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java @@ -28,6 +28,8 @@ import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Menu; import org.springblade.system.service.IMenuService; +import org.springblade.system.vo.CheckedTreeVO; +import org.springblade.system.vo.GrantTreeVO; import org.springblade.system.vo.MenuVO; import org.springblade.system.wrapper.MenuWrapper; import org.springframework.cache.annotation.CacheEvict; @@ -139,8 +141,11 @@ public class MenuController extends BladeController { */ @GetMapping("/grant-tree") @ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构", position = 6) - public R> grantTree(BladeUser user) { - return R.data(menuService.grantTree(user)); + public R grantTree(BladeUser user) { + GrantTreeVO vo = new GrantTreeVO(); + vo.setMenu(menuService.grantTree(user)); + vo.setScope(menuService.grantScopeTree(user)); + return R.data(vo); } /** @@ -148,8 +153,11 @@ public class MenuController extends BladeController { */ @GetMapping("/role-tree-keys") @ApiOperation(value = "角色所分配的树", notes = "角色所分配的树", position = 7) - public R> roleTreeKeys(String roleIds) { - return R.data(menuService.roleTreeKeys(roleIds)); + public R roleTreeKeys(String roleIds) { + CheckedTreeVO vo = new CheckedTreeVO(); + vo.setMenu(menuService.roleTreeKeys(roleIds)); + vo.setScope(menuService.scopeTreeKeys(roleIds)); + return R.data(vo); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java index 498aba38..929c52cb 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java @@ -116,17 +116,14 @@ public class RoleController extends BladeController { } /** - * 设置菜单权限 - * - * @param roleIds - * @param menuIds - * @return + * 设置角色权限 */ @PostMapping("/grant") @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合", position = 6) public R grant(@ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds, - @ApiParam(value = "menuId集合", required = true) @RequestParam String menuIds) { - boolean temp = roleService.grant(Func.toLongList(roleIds), Func.toLongList(menuIds)); + @ApiParam(value = "menuId集合", required = true) @RequestParam String menuIds, + @ApiParam(value = "scopeId集合") String scopeIds) { + boolean temp = roleService.grant(Func.toLongList(roleIds), Func.toLongList(menuIds), Func.toLongList(scopeIds)); return R.status(temp); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.java new file mode 100644 index 00000000..959ef558 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springblade.system.entity.DataScope; + +/** + * Mapper 接口 + * + * @author BladeX + * @since 2019-06-23 + */ +public interface DataScopeMapper extends BaseMapper { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.xml new file mode 100644 index 00000000..cbb46594 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DataScopeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml index 2c60cf74..a47d8515 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/DeptMapper.xml @@ -8,6 +8,8 @@ + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java index d1fdbd4e..289a6706 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.java @@ -24,6 +24,7 @@ import org.springblade.system.vo.MenuVO; import java.util.List; + /** * Mapper 接口 * @@ -62,6 +63,21 @@ public interface MenuMapper extends BaseMapper { */ List grantTreeByRole(List roleId); + /** + * 数据权限授权树形结构 + * + * @return + */ + List grantScopeTree(); + + /** + * 数据权限授权树形结构 + * + * @param roleId + * @return + */ + List grantScopeTreeByRole(List roleId); + /** * 所有菜单 * @@ -95,7 +111,6 @@ public interface MenuMapper extends BaseMapper { /** * 获取配置的角色权限 - * * @param roleIds * @return */ diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml index 3d378c22..98bd3069 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/MenuMapper.xml @@ -30,7 +30,7 @@ select - id, code, parent_id, name, alias, path, source, sort, category, action, is_open, remark, is_deleted + id, code, parent_id, name, alias, path, source, sort, category, action, is_open, remark, is_deleted SELECT - * + * FROM - blade_menu + blade_menu WHERE - is_deleted = 0 and category = 1 - and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN - - #{item} - ) + is_deleted = 0 and category = 1 + and id IN ( SELECT menu_id FROM blade_role_menu WHERE role_id IN + + #{item} + ) - + SELECT + * + FROM + ( + SELECT + id, + parent_id, + NAME AS title, + id AS 'value', + id AS 'key' + FROM + blade_menu + WHERE + category = 1 + AND is_deleted = 0 + AND id IN ( SELECT menu_id FROM blade_data_scope WHERE is_deleted = 0 AND menu_id IS NOT NULL ) + ORDER BY + sort + ) menu + + UNION ALL + SELECT - GROUP_CONCAT(r.role_alias) as alias, - m.path + id, + menu_id AS parent_id, + scope_name AS title, + id AS 'value', + id AS 'key' FROM - blade_role_menu rm - LEFT JOIN blade_menu m ON rm.menu_id = m.id - LEFT JOIN blade_role r ON rm.role_id = r.id + blade_data_scope WHERE - rm.role_id IN - - #{item} - - AND m.path IS NOT NULL and m.is_deleted = 0 + is_deleted = 0 + AND menu_id IS NOT NULL + + + + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.java new file mode 100644 index 00000000..7b225743 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springblade.system.entity.RoleScope; + +/** + * Mapper 接口 + * + * @author Chill + */ +public interface RoleScopeMapper extends BaseMapper { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.xml b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.xml new file mode 100644 index 00000000..c6a0f0d7 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleScopeMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDataScopeService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDataScopeService.java new file mode 100644 index 00000000..7b674dc4 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDataScopeService.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.service; + +import org.springblade.core.mp.base.BaseService; +import org.springblade.system.entity.DataScope; + +/** + * 服务类 + * + * @author BladeX + * @since 2019-06-23 + */ +public interface IDataScopeService extends BaseService { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java index db4d0236..66cf53eb 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java @@ -63,4 +63,12 @@ public interface IDeptService extends IService { */ boolean removeDept(String ids); + /** + * 提交 + * + * @param dept + * @return + */ + boolean submit(Dept dept); + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java index 6d632e71..34c69243 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java @@ -72,6 +72,14 @@ public interface IMenuService extends IService { */ List grantTree(BladeUser user); + /** + * 数据权限授权树形结构 + * + * @param user + * @return + */ + List grantScopeTree(BladeUser user); + /** * 默认选中节点 * @@ -80,6 +88,14 @@ public interface IMenuService extends IService { */ List roleTreeKeys(String roleIds); + /** + * 默认选中节点 + * + * @param roleIds + * @return + */ + List scopeTreeKeys(String roleIds); + /** * 获取配置的角色权限 * diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleScopeService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleScopeService.java new file mode 100644 index 00000000..d3d63764 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleScopeService.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.springblade.system.entity.RoleScope; + +/** + * 服务类 + * + * @author Chill + */ +public interface IRoleScopeService extends IService { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleService.java index 67375b55..91dd117e 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleService.java @@ -55,7 +55,7 @@ public interface IRoleService extends IService { * @param menuIds 菜单id集合 * @return 是否成功 */ - boolean grant(@NotEmpty List roleIds, @NotEmpty List menuIds); + boolean grant(@NotEmpty List roleIds, @NotEmpty List menuIds, List scopeIds); /** * 获取角色名 diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DataScopeServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DataScopeServiceImpl.java new file mode 100644 index 00000000..e69a4c38 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DataScopeServiceImpl.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.service.impl; + +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.system.entity.DataScope; +import org.springblade.system.mapper.DataScopeMapper; +import org.springblade.system.service.IDataScopeService; +import org.springframework.stereotype.Service; + +/** + * 服务实现类 + * + * @author BladeX + * @since 2019-06-23 + */ +@Service +public class DataScopeServiceImpl extends BaseServiceImpl implements IDataScopeService { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java index 1cbfe5fc..392dbde5 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringPool; import org.springblade.system.entity.Dept; import org.springblade.system.mapper.DeptMapper; import org.springblade.system.service.IDeptService; @@ -62,4 +63,14 @@ public class DeptServiceImpl extends ServiceImpl implements ID return removeByIds(Func.toLongList(ids)); } + @Override + public boolean submit(Dept dept) { + if (dept.getParentId() > 0) { + Dept parent = getById(dept.getParentId()); + String ancestors = parent.getAncestors() + StringPool.COMMA + dept.getParentId(); + dept.setAncestors(ancestors); + } + return saveOrUpdate(dept); + } + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java index cd1b52b7..ddfedc14 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java @@ -30,9 +30,11 @@ import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.dto.MenuDTO; import org.springblade.system.entity.Menu; import org.springblade.system.entity.RoleMenu; +import org.springblade.system.entity.RoleScope; import org.springblade.system.mapper.MenuMapper; import org.springblade.system.service.IMenuService; import org.springblade.system.service.IRoleMenuService; +import org.springblade.system.service.IRoleScopeService; import org.springblade.system.vo.MenuVO; import org.springblade.system.wrapper.MenuWrapper; import org.springframework.cache.annotation.Cacheable; @@ -53,6 +55,7 @@ import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE; public class MenuServiceImpl extends ServiceImpl implements IMenuService { private IRoleMenuService roleMenuService; + private IRoleScopeService roleScopeService; @Override public IPage selectMenuPage(IPage page, MenuVO menu) { @@ -66,6 +69,10 @@ public class MenuServiceImpl extends ServiceImpl implements IM } List allMenus = baseMapper.allMenu(); List roleMenus = baseMapper.roleMenu(Func.toLongList(roleId)); + return buildRoutes(allMenus, roleMenus); + } + + private List buildRoutes(List allMenus, List roleMenus) { List routes = new LinkedList<>(roleMenus); roleMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu)); routes.sort(Comparator.comparing(Menu::getSort)); @@ -74,7 +81,7 @@ public class MenuServiceImpl extends ServiceImpl implements IM return menuWrapper.listNodeVO(collect); } - public void recursion(List allMenus, List routes, Menu roleMenu) { + private void recursion(List allMenus, List routes, Menu roleMenu) { Optional menu = allMenus.stream().filter(x -> Func.equals(x.getId(), roleMenu.getParentId())).findFirst(); if (menu.isPresent() && !routes.contains(menu.get())) { routes.add(menu.get()); @@ -99,12 +106,23 @@ public class MenuServiceImpl extends ServiceImpl implements IM return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId()))); } + @Override + public List grantScopeTree(BladeUser user) { + return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantScopeTree() : baseMapper.grantScopeTreeByRole(Func.toLongList(user.getRoleId()))); + } + @Override public List roleTreeKeys(String roleIds) { List roleMenus = roleMenuService.list(Wrappers.query().lambda().in(RoleMenu::getRoleId, Func.toLongList(roleIds))); return roleMenus.stream().map(roleMenu -> Func.toStr(roleMenu.getMenuId())).collect(Collectors.toList()); } + @Override + public List scopeTreeKeys(String roleIds) { + List roleScopes = roleScopeService.list(Wrappers.query().lambda().in(RoleScope::getRoleId, Func.toLongList(roleIds))); + return roleScopes.stream().map(roleScope -> Func.toStr(roleScope.getScopeId())).collect(Collectors.toList()); + } + @Override @Cacheable(cacheNames = MENU_CACHE, key = "'auth:routes:' + #user.roleId") public List authRoutes(BladeUser user) { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleScopeServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleScopeServiceImpl.java new file mode 100644 index 00000000..76b19c58 --- /dev/null +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleScopeServiceImpl.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package org.springblade.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springblade.system.entity.RoleScope; +import org.springblade.system.mapper.RoleScopeMapper; +import org.springblade.system.service.IRoleScopeService; +import org.springframework.stereotype.Service; + +/** + * 服务实现类 + * + * @author Chill + */ +@Service +public class RoleScopeServiceImpl extends ServiceImpl implements IRoleScopeService { + +} diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java index 20ae2106..9883d9dc 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java @@ -27,6 +27,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Role; import org.springblade.system.entity.RoleMenu; +import org.springblade.system.entity.RoleScope; import org.springblade.system.mapper.RoleMapper; import org.springblade.system.service.IRoleMenuService; import org.springblade.system.service.IRoleService; @@ -68,7 +69,8 @@ public class RoleServiceImpl extends ServiceImpl implements IR @Override @Transactional(rollbackFor = Exception.class) - public boolean grant(@NotEmpty List roleIds, @NotEmpty List menuIds) { + public boolean grant(@NotEmpty List roleIds, @NotEmpty List menuIds, List scopeIds) { + // 菜单权限模块 // 删除角色配置的菜单集合 roleMenuService.remove(Wrappers.update().lambda().in(RoleMenu::getRoleId, roleIds)); // 组装配置 @@ -80,7 +82,25 @@ public class RoleServiceImpl extends ServiceImpl implements IR roleMenus.add(roleMenu); })); // 新增配置 - return roleMenuService.saveBatch(roleMenus); + roleMenuService.saveBatch(roleMenus); + + // 数据权限模块 + if (CollectionUtil.isNotEmpty(scopeIds)) { + // 删除角色配置的数据权限集合 + roleScopeService.remove(Wrappers.update().lambda().in(RoleScope::getRoleId, roleIds)); + // 组装配置 + List roleScopes = new ArrayList<>(); + roleIds.forEach(roleId -> scopeIds.forEach(scopeId -> { + RoleScope roleScope = new RoleScope(); + roleScope.setRoleId(roleId); + roleScope.setScopeId(scopeId); + roleScopes.add(roleScope); + })); + // 新增配置 + roleScopeService.saveBatch(roleScopes); + } + + return true; } @Override diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java index c680104b..ddf1945a 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java @@ -22,11 +22,13 @@ import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.system.cache.DictCache; import org.springblade.system.cache.SysCache; import org.springblade.system.entity.Dept; import org.springblade.system.vo.DeptVO; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -50,12 +52,19 @@ public class DeptWrapper extends BaseEntityWrapper { Dept parent = SysCache.getDept(dept.getParentId()); deptVO.setParentName(parent.getDeptName()); } + String category = DictCache.getValue("org_category", dept.getDeptCategory()); + deptVO.setDeptCategoryName(category); return deptVO; } public List listNodeVO(List list) { - List collect = list.stream().map(dept -> BeanUtil.copy(dept, DeptVO.class)).collect(Collectors.toList()); + List collect = list.stream().map(dept -> { + DeptVO deptVO = BeanUtil.copy(dept, DeptVO.class); + String category = DictCache.getValue("org_category", dept.getDeptCategory()); + Objects.requireNonNull(deptVO).setDeptCategoryName(category); + return deptVO; + }).collect(Collectors.toList()); return ForestNodeMerger.merge(collect); } diff --git a/blade-service/blade-user/pom.xml b/blade-service/blade-user/pom.xml index 55212db1..7490a999 100644 --- a/blade-service/blade-user/pom.xml +++ b/blade-service/blade-user/pom.xml @@ -5,7 +5,7 @@ blade-service org.springblade - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 diff --git a/blade-service/pom.xml b/blade-service/pom.xml index b74d6bba..e2d4efa1 100644 --- a/blade-service/pom.xml +++ b/blade-service/pom.xml @@ -6,14 +6,14 @@ org.springblade BladeX - 2.0.3.RELEASE + 2.0.4.RELEASE 4.0.0 blade-service ${project.artifactId} - 2.0.3.RELEASE + 2.0.4.RELEASE pom BladeX 微服务集合 diff --git a/doc/sql/bladex-datascope-update.sql b/doc/sql/bladex-datascope-update.sql index f5af03da..7a938fdf 100644 --- a/doc/sql/bladex-datascope-update.sql +++ b/doc/sql/bladex-datascope-update.sql @@ -70,9 +70,17 @@ UPDATE `blade_dept` SET `tenant_id` = '000000', `parent_id` = 112359881373867520 INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675227, 0, 'org_category', -1, '机构类型', 7, NULL, 0); INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675228, 1123598814738675227, 'org_category', 1, '公司', 1, NULL, 0); INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675229, 1123598814738675227, 'org_category', 2, '部门', 2, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675230, 0, 'data_scope', -1, '数据权限', 8, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675231, 1123598814738675230, 'data_scope', 1, '全部可见', 1, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675232, 1123598814738675230, 'data_scope', 2, '本人可见', 2, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675233, 1123598814738675230, 'data_scope', 3, '所在机构可见', 3, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675234, 1123598814738675230, 'data_scope', 4, '所在机构及子级可见', 4, NULL, 0); -INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675235, 1123598814738675230, 'data_scope', 5, '自定义', 5, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675230, 1123598814738675227, 'org_category', 3, '小组', 3, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675231, 0, 'scope_type', -1, '数据权限', 8, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675232, 1123598814738675230, 'scope_type', 1, '全部可见', 1, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675233, 1123598814738675230, 'scope_type', 2, '本人可见', 2, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675234, 1123598814738675230, 'scope_type', 3, '所在机构可见', 3, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675235, 1123598814738675230, 'scope_type', 4, '所在机构及子级可见', 4, NULL, 0); +INSERT INTO `blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_deleted`) VALUES (1123598814738675236, 1123598814738675230, 'scope_type', 5, '自定义', 5, NULL, 0); + +-- ---------------------------- +-- 增加数据权限菜单及权限 +-- ---------------------------- +UPDATE `blade_menu` SET `name` = '机构管理' WHERE `id` = 1123598815738675205; +INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`) VALUES (1123598815738675306, 1123598815738675207, 'menu_data_scope', '数据权限', 'datascope', NULL, 'setting', 5, 2, 2, 1, NULL, 0); +INSERT INTO `blade_role_menu`(`id`, `menu_id`, `role_id`) VALUES (1132812106487730179, 1123598815738675306, 1123598816738675201); diff --git a/pom.xml b/pom.xml index ada7a45f..57a1dc00 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,12 @@ org.springblade BladeX - 2.0.3.RELEASE + 2.0.4.RELEASE pom - 2.0.3.RELEASE - 2.0.3.RELEASE + 2.0.4.RELEASE + 2.0.4.RELEASE 1.8 3.8.1 @@ -20,7 +20,7 @@ 2.9.2 1.5.21 1.9.4 - 3.1.1 + 3.1.0 4.0.1 1.6.0 6.4.1 diff --git a/script/docker/.env b/script/docker/.env index e52177ea..595308ba 100644 --- a/script/docker/.env +++ b/script/docker/.env @@ -1,2 +1,2 @@ REGISTER=192.168.0.157/blade -TAG=2.0.3.RELEASE +TAG=2.0.4.RELEASE