소스 검색

:tada: 2.0.4.RELEASE

smallchill 7 년 전
부모
커밋
1baab4d5c0
31개의 변경된 파일814개의 추가작업 그리고 35개의 파일을 삭제
  1. 14 6
      doc/sql/bladex-datascope-update.sql
  2. 1 1
      pom.xml
  3. 26 2
      src/main/java/org/springblade/core/secure/utils/SecureUtil.java
  4. 114 0
      src/main/java/org/springblade/modules/system/controller/DataScopeController.java
  5. 1 1
      src/main/java/org/springblade/modules/system/controller/DeptController.java
  6. 12 4
      src/main/java/org/springblade/modules/system/controller/MenuController.java
  7. 4 7
      src/main/java/org/springblade/modules/system/controller/RoleController.java
  8. 82 0
      src/main/java/org/springblade/modules/system/entity/DataScope.java
  9. 17 5
      src/main/java/org/springblade/modules/system/entity/Dept.java
  10. 65 0
      src/main/java/org/springblade/modules/system/entity/RoleScope.java
  11. 30 0
      src/main/java/org/springblade/modules/system/mapper/DataScopeMapper.java
  12. 5 0
      src/main/java/org/springblade/modules/system/mapper/DataScopeMapper.xml
  13. 2 0
      src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
  14. 15 0
      src/main/java/org/springblade/modules/system/mapper/MenuMapper.java
  15. 94 0
      src/main/java/org/springblade/modules/system/mapper/MenuMapper.xml
  16. 29 0
      src/main/java/org/springblade/modules/system/mapper/RoleScopeMapper.java
  17. 12 0
      src/main/java/org/springblade/modules/system/mapper/RoleScopeMapper.xml
  18. 30 0
      src/main/java/org/springblade/modules/system/service/IDataScopeService.java
  19. 8 0
      src/main/java/org/springblade/modules/system/service/IDeptService.java
  20. 16 0
      src/main/java/org/springblade/modules/system/service/IMenuService.java
  21. 29 0
      src/main/java/org/springblade/modules/system/service/IRoleScopeService.java
  22. 4 3
      src/main/java/org/springblade/modules/system/service/IRoleService.java
  23. 34 0
      src/main/java/org/springblade/modules/system/service/impl/DataScopeServiceImpl.java
  24. 11 0
      src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
  25. 15 1
      src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
  26. 33 0
      src/main/java/org/springblade/modules/system/service/impl/RoleScopeServiceImpl.java
  27. 25 3
      src/main/java/org/springblade/modules/system/service/impl/RoleServiceImpl.java
  28. 35 0
      src/main/java/org/springblade/modules/system/vo/CheckedTreeVO.java
  29. 6 1
      src/main/java/org/springblade/modules/system/vo/DeptVO.java
  30. 35 0
      src/main/java/org/springblade/modules/system/vo/GrantTreeVO.java
  31. 10 1
      src/main/java/org/springblade/modules/system/wrapper/DeptWrapper.java

+ 14 - 6
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);

+ 1 - 1
pom.xml

@@ -20,7 +20,7 @@
         <swagger.version>2.9.2</swagger.version>
         <swagger.models.version>1.5.21</swagger.models.version>
         <swagger.bootstrapui.version>1.9.4</swagger.bootstrapui.version>
-        <mybatis.plus.version>3.1.1</mybatis.plus.version>
+        <mybatis.plus.version>3.1.0</mybatis.plus.version>
         <protostuff.version>1.6.0</protostuff.version>
         <flowable.version>6.4.1</flowable.version>
 

+ 26 - 2
src/main/java/org/springblade/core/secure/utils/SecureUtil.java

@@ -48,6 +48,7 @@ public class SecureUtil {
 	private final static String USER_NAME = TokenConstant.USER_NAME;
 	private final static String NICK_NAME = TokenConstant.NICK_NAME;
 	private final static String USER_ID = TokenConstant.USER_ID;
+	private final static String DEPT_ID = TokenConstant.DEPT_ID;
 	private final static String ROLE_ID = TokenConstant.ROLE_ID;
 	private final static String ROLE_NAME = TokenConstant.ROLE_NAME;
 	private final static String TENANT_ID = TokenConstant.TENANT_ID;
@@ -97,6 +98,7 @@ public class SecureUtil {
 		String clientId = Func.toStr(claims.get(SecureUtil.CLIENT_ID));
 		Long userId = Func.toLong(claims.get(SecureUtil.USER_ID));
 		String tenantId = Func.toStr(claims.get(SecureUtil.TENANT_ID));
+		String deptId = Func.toStr(claims.get(SecureUtil.DEPT_ID));
 		String roleId = Func.toStr(claims.get(SecureUtil.ROLE_ID));
 		String account = Func.toStr(claims.get(SecureUtil.ACCOUNT));
 		String roleName = Func.toStr(claims.get(SecureUtil.ROLE_NAME));
@@ -107,6 +109,7 @@ public class SecureUtil {
 		bladeUser.setUserId(userId);
 		bladeUser.setTenantId(tenantId);
 		bladeUser.setAccount(account);
+		bladeUser.setDeptId(deptId);
 		bladeUser.setRoleId(roleId);
 		bladeUser.setRoleName(roleName);
 		bladeUser.setUserName(userName);
@@ -199,6 +202,27 @@ public class SecureUtil {
 		return (null == user) ? StringPool.EMPTY : user.getNickName();
 	}
 
+	/**
+	 * 获取用户部门
+	 *
+	 * @return userName
+	 */
+	public static String getDeptId() {
+		BladeUser user = getUser();
+		return (null == user) ? StringPool.EMPTY : user.getDeptId();
+	}
+
+	/**
+	 * 获取用户部门
+	 *
+	 * @param request request
+	 * @return userName
+	 */
+	public static String getDeptId(HttpServletRequest request) {
+		BladeUser user = getUser(request);
+		return (null == user) ? StringPool.EMPTY : user.getDeptId();
+	}
+
 	/**
 	 * 获取用户角色
 	 *
@@ -244,7 +268,7 @@ public class SecureUtil {
 	/**
 	 * 获取客户端id
 	 *
-	 * @return tenantId
+	 * @return clientId
 	 */
 	public static String getClientId() {
 		BladeUser user = getUser();
@@ -255,7 +279,7 @@ public class SecureUtil {
 	 * 获取客户端id
 	 *
 	 * @param request request
-	 * @return tenantId
+	 * @return clientId
 	 */
 	public static String getClientId(HttpServletRequest request) {
 		BladeUser user = getUser(request);

+ 114 - 0
src/main/java/org/springblade/modules/system/controller/DataScopeController.java

@@ -0,0 +1,114 @@
+/*
+ *      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.modules.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.launch.constant.AppConstant;
+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.modules.system.entity.DataScope;
+import org.springblade.modules.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(AppConstant.APPLICATION_SYSTEM_NAME + "/data-scope")
+@Api(value = "数据权限", tags = "接口")
+public class DataScopeController extends BladeController {
+
+	private IDataScopeService dataScopeService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperation(value = "详情", notes = "传入dataScope", position = 1)
+	public R<DataScope> detail(DataScope dataScope) {
+		DataScope detail = dataScopeService.getOne(Condition.getQueryWrapper(dataScope));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页
+	 */
+	@GetMapping("/list")
+	@ApiOperation(value = "分页", notes = "传入dataScope", position = 2)
+	public R<IPage<DataScope>> list(DataScope dataScope, Query query) {
+		IPage<DataScope> 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)));
+	}
+
+}

+ 1 - 1
src/main/java/org/springblade/modules/system/controller/DeptController.java

@@ -105,7 +105,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));
 	}
 
 	/**

+ 12 - 4
src/main/java/org/springblade/modules/system/controller/MenuController.java

@@ -29,6 +29,8 @@ import org.springblade.core.tool.support.Kv;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.system.entity.Menu;
 import org.springblade.modules.system.service.IMenuService;
+import org.springblade.modules.system.vo.CheckedTreeVO;
+import org.springblade.modules.system.vo.GrantTreeVO;
 import org.springblade.modules.system.vo.MenuVO;
 import org.springblade.modules.system.wrapper.MenuWrapper;
 import org.springframework.cache.annotation.CacheEvict;
@@ -150,8 +152,11 @@ public class MenuController extends BladeController {
 	 */
 	@GetMapping("/grant-tree")
 	@ApiOperation(value = "权限分配树形结构", notes = "权限分配树形结构", position = 6)
-	public R<List<MenuVO>> grantTree(BladeUser user) {
-		return R.data(menuService.grantTree(user));
+	public R<GrantTreeVO> grantTree(BladeUser user) {
+		GrantTreeVO vo = new GrantTreeVO();
+		vo.setMenu(menuService.grantTree(user));
+		vo.setScope(menuService.grantScopeTree(user));
+		return R.data(vo);
 	}
 
 	/**
@@ -159,8 +164,11 @@ public class MenuController extends BladeController {
 	 */
 	@GetMapping("/role-tree-keys")
 	@ApiOperation(value = "角色所分配的树", notes = "角色所分配的树", position = 7)
-	public R<List<String>> roleTreeKeys(String roleIds) {
-		return R.data(menuService.roleTreeKeys(roleIds));
+	public R<CheckedTreeVO> roleTreeKeys(String roleIds) {
+		CheckedTreeVO vo = new CheckedTreeVO();
+		vo.setMenu(menuService.roleTreeKeys(roleIds));
+		vo.setScope(menuService.scopeTreeKeys(roleIds));
+		return R.data(vo);
 	}
 
 	/**

+ 4 - 7
src/main/java/org/springblade/modules/system/controller/RoleController.java

@@ -117,17 +117,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);
 	}
 

+ 82 - 0
src/main/java/org/springblade/modules/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.modules.system.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 实体类
+ *
+ * @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;
+
+
+}

+ 17 - 5
src/main/java/org/springblade/modules/system/entity/Dept.java

@@ -62,16 +62,28 @@ public class Dept implements Serializable {
 	private Long parentId;
 
 	/**
-	 * 部门名
+	 * 机构全称
 	 */
-	@ApiModelProperty(value = "部门名")
+	@ApiModelProperty(value = "机构全称")
+	private String fullName;
+
+	/**
+	 * 机构名
+	 */
+	@ApiModelProperty(value = "机构名")
 	private String deptName;
 
 	/**
-	 * 部门全称
+	 * 租级机构主键
 	 */
-	@ApiModelProperty(value = "部门全称")
-	private String fullName;
+	@ApiModelProperty(value = "祖级机构主键")
+	private String ancestors;
+
+	/**
+	 * 机构类型
+	 */
+	@ApiModelProperty(value = "机构类型")
+	private Integer deptCategory;
 
 	/**
 	 * 排序

+ 65 - 0
src/main/java/org/springblade/modules/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.modules.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;
+
+
+}

+ 30 - 0
src/main/java/org/springblade/modules/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.modules.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.modules.system.entity.DataScope;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2019-06-23
+ */
+public interface DataScopeMapper extends BaseMapper<DataScope> {
+
+}

+ 5 - 0
src/main/java/org/springblade/modules/system/mapper/DataScopeMapper.xml

@@ -0,0 +1,5 @@
+<?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="org.springblade.modules.system.mapper.DataScopeMapper">
+
+</mapper>

+ 2 - 0
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml

@@ -8,6 +8,8 @@
         <result column="parent_id" property="parentId"/>
         <result column="dept_name" property="deptName"/>
         <result column="full_name" property="fullName"/>
+        <result column="ancestors" property="ancestors"/>
+        <result column="dept_category" property="deptCategory"/>
         <result column="sort" property="sort"/>
         <result column="remark" property="remark"/>
         <result column="is_deleted" property="isDeleted"/>

+ 15 - 0
src/main/java/org/springblade/modules/system/mapper/MenuMapper.java

@@ -62,6 +62,21 @@ public interface MenuMapper extends BaseMapper<Menu> {
 	 */
 	List<MenuVO> grantTreeByRole(List<Long> roleId);
 
+	/**
+	 * 数据权限授权树形结构
+	 *
+	 * @return
+	 */
+	List<MenuVO> grantScopeTree();
+
+	/**
+	 * 数据权限授权树形结构
+	 *
+	 * @param roleId
+	 * @return
+	 */
+	List<MenuVO> grantScopeTreeByRole(List<Long> roleId);
+
 	/**
 	 * 所有菜单
 	 *

+ 94 - 0
src/main/java/org/springblade/modules/system/mapper/MenuMapper.xml

@@ -139,6 +139,100 @@
         order by sort
     </select>
 
+    <select id="grantScopeTree" resultMap="treeNodeResultMap">
+        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
+            id,
+            menu_id AS parent_id,
+            scope_name AS title,
+            id AS 'value',
+            id AS 'key'
+        FROM
+            blade_data_scope
+        WHERE
+            is_deleted = 0
+          AND menu_id IS NOT NULL
+    </select>
+
+    <select id="grantScopeTreeByRole" resultMap="treeNodeResultMap">
+        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 )
+                  AND id IN ( select menu_id from blade_role_menu where role_id in
+                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach> )
+                    OR id IN (
+                    select parent_id from blade_menu where is_deleted = 0
+                    and id in ( select menu_id from blade_role_menu where role_id in
+                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach> )
+                  )
+                ORDER BY
+                    sort
+            ) menu
+
+        UNION ALL
+
+        SELECT
+            id,
+            menu_id AS parent_id,
+            scope_name AS title,
+            id AS 'value',
+            id AS 'key'
+        FROM
+            blade_data_scope
+        WHERE
+            is_deleted = 0
+            AND menu_id IN ( select menu_id from blade_role_menu where role_id in
+            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach> )
+            OR menu_id IN (
+            select parent_id from blade_menu where is_deleted = 0
+            and id in ( select menu_id from blade_role_menu where role_id in
+            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach> )
+            )
+          AND menu_id IS NOT NULL
+    </select>
+
     <select id="authRoutes" resultType="org.springblade.modules.system.dto.MenuDTO">
         SELECT
             GROUP_CONCAT(r.role_alias) as alias,

+ 29 - 0
src/main/java/org/springblade/modules/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.modules.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.modules.system.entity.RoleScope;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface RoleScopeMapper extends BaseMapper<RoleScope> {
+
+}

+ 12 - 0
src/main/java/org/springblade/modules/system/mapper/RoleScopeMapper.xml

@@ -0,0 +1,12 @@
+<?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="org.springblade.modules.system.mapper.RoleScopeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="roleMenuResultMap" type="org.springblade.modules.system.entity.RoleScope">
+        <id column="id" property="id"/>
+        <result column="scope_id" property="scopeId"/>
+        <result column="role_id" property="roleId"/>
+    </resultMap>
+
+</mapper>

+ 30 - 0
src/main/java/org/springblade/modules/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.modules.system.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.modules.system.entity.DataScope;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2019-06-23
+ */
+public interface IDataScopeService extends BaseService<DataScope> {
+
+}

+ 8 - 0
src/main/java/org/springblade/modules/system/service/IDeptService.java

@@ -63,4 +63,12 @@ public interface IDeptService extends IService<Dept> {
 	 */
 	boolean removeDept(String ids);
 
+	/**
+	 * 提交
+	 *
+	 * @param dept
+	 * @return
+	 */
+	boolean submit(Dept dept);
+
 }

+ 16 - 0
src/main/java/org/springblade/modules/system/service/IMenuService.java

@@ -80,6 +80,14 @@ public interface IMenuService extends IService<Menu> {
 	 */
 	List<MenuVO> grantTree(BladeUser user);
 
+	/**
+	 * 数据权限授权树形结构
+	 *
+	 * @param user
+	 * @return
+	 */
+	List<MenuVO> grantScopeTree(BladeUser user);
+
 	/**
 	 * 默认选中节点
 	 *
@@ -88,6 +96,14 @@ public interface IMenuService extends IService<Menu> {
 	 */
 	List<String> roleTreeKeys(String roleIds);
 
+	/**
+	 * 默认选中节点
+	 *
+	 * @param roleIds
+	 * @return
+	 */
+	List<String> scopeTreeKeys(String roleIds);
+
 	/**
 	 * 获取配置的角色权限
 	 *

+ 29 - 0
src/main/java/org/springblade/modules/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.modules.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.system.entity.RoleScope;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IRoleScopeService extends IService<RoleScope> {
+
+}

+ 4 - 3
src/main/java/org/springblade/modules/system/service/IRoleService.java

@@ -51,11 +51,12 @@ public interface IRoleService extends IService<Role> {
 	/**
 	 * 权限配置
 	 *
-	 * @param roleIds 角色id集合
-	 * @param menuIds 菜单id集合
+	 * @param roleIds  角色id集合
+	 * @param menuIds  菜单id集合
+	 * @param scopeIds 数据权限id集合
 	 * @return 是否成功
 	 */
-	boolean grant(@NotEmpty List<Long> roleIds, @NotEmpty List<Long> menuIds);
+	boolean grant(@NotEmpty List<Long> roleIds, @NotEmpty List<Long> menuIds, List<Long> scopeIds);
 
 	/**
 	 * 获取角色名

+ 34 - 0
src/main/java/org/springblade/modules/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.modules.system.service.impl;
+
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.modules.system.entity.DataScope;
+import org.springblade.modules.system.mapper.DataScopeMapper;
+import org.springblade.modules.system.service.IDataScopeService;
+import org.springframework.stereotype.Service;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2019-06-23
+ */
+@Service
+public class DataScopeServiceImpl extends BaseServiceImpl<DataScopeMapper, DataScope> implements IDataScopeService {
+
+}

+ 11 - 0
src/main/java/org/springblade/modules/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.modules.system.entity.Dept;
 import org.springblade.modules.system.mapper.DeptMapper;
 import org.springblade.modules.system.service.IDeptService;
@@ -62,4 +63,14 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> 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);
+	}
+
 }

+ 15 - 1
src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java

@@ -30,9 +30,11 @@ import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.system.dto.MenuDTO;
 import org.springblade.modules.system.entity.Menu;
 import org.springblade.modules.system.entity.RoleMenu;
+import org.springblade.modules.system.entity.RoleScope;
 import org.springblade.modules.system.mapper.MenuMapper;
 import org.springblade.modules.system.service.IMenuService;
 import org.springblade.modules.system.service.IRoleMenuService;
+import org.springblade.modules.system.service.IRoleScopeService;
 import org.springblade.modules.system.vo.MenuVO;
 import org.springblade.modules.system.wrapper.MenuWrapper;
 import org.springframework.cache.annotation.Cacheable;
@@ -52,7 +54,8 @@ import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
 @AllArgsConstructor
 public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {
 
-	IRoleMenuService roleMenuService;
+	private IRoleMenuService roleMenuService;
+	private IRoleScopeService roleScopeService;
 
 	@Override
 	public IPage<MenuVO> selectMenuPage(IPage<MenuVO> page, MenuVO menu) {
@@ -113,12 +116,23 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
 		return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())));
 	}
 
+	@Override
+	public List<MenuVO> grantScopeTree(BladeUser user) {
+		return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantScopeTree() : baseMapper.grantScopeTreeByRole(Func.toLongList(user.getRoleId())));
+	}
+
 	@Override
 	public List<String> roleTreeKeys(String roleIds) {
 		List<RoleMenu> roleMenus = roleMenuService.list(Wrappers.<RoleMenu>query().lambda().in(RoleMenu::getRoleId, Func.toLongList(roleIds)));
 		return roleMenus.stream().map(roleMenu -> Func.toStr(roleMenu.getMenuId())).collect(Collectors.toList());
 	}
 
+	@Override
+	public List<String> scopeTreeKeys(String roleIds) {
+		List<RoleScope> roleScopes = roleScopeService.list(Wrappers.<RoleScope>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<Kv> authRoutes(BladeUser user) {

+ 33 - 0
src/main/java/org/springblade/modules/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.modules.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.system.entity.RoleScope;
+import org.springblade.modules.system.mapper.RoleScopeMapper;
+import org.springblade.modules.system.service.IRoleScopeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+public class RoleScopeServiceImpl extends ServiceImpl<RoleScopeMapper, RoleScope> implements IRoleScopeService {
+
+}

+ 25 - 3
src/main/java/org/springblade/modules/system/service/impl/RoleServiceImpl.java

@@ -27,8 +27,10 @@ import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.system.entity.Role;
 import org.springblade.modules.system.entity.RoleMenu;
+import org.springblade.modules.system.entity.RoleScope;
 import org.springblade.modules.system.mapper.RoleMapper;
 import org.springblade.modules.system.service.IRoleMenuService;
+import org.springblade.modules.system.service.IRoleScopeService;
 import org.springblade.modules.system.service.IRoleService;
 import org.springblade.modules.system.vo.RoleVO;
 import org.springframework.stereotype.Service;
@@ -49,7 +51,8 @@ import java.util.List;
 @AllArgsConstructor
 public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
 
-	IRoleMenuService roleMenuService;
+	private IRoleMenuService roleMenuService;
+	private IRoleScopeService roleScopeService;
 
 	@Override
 	public IPage<RoleVO> selectRolePage(IPage<RoleVO> page, RoleVO role) {
@@ -68,7 +71,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean grant(@NotEmpty List<Long> roleIds, @NotEmpty List<Long> menuIds) {
+	public boolean grant(@NotEmpty List<Long> roleIds, @NotEmpty List<Long> menuIds, List<Long> scopeIds) {
+		// 菜单权限模块
 		// 删除角色配置的菜单集合
 		roleMenuService.remove(Wrappers.<RoleMenu>update().lambda().in(RoleMenu::getRoleId, roleIds));
 		// 组装配置
@@ -80,7 +84,25 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
 			roleMenus.add(roleMenu);
 		}));
 		// 新增配置
-		return roleMenuService.saveBatch(roleMenus);
+		roleMenuService.saveBatch(roleMenus);
+
+		// 数据权限模块
+		if (CollectionUtil.isNotEmpty(scopeIds)) {
+			// 删除角色配置的数据权限集合
+			roleScopeService.remove(Wrappers.<RoleScope>update().lambda().in(RoleScope::getRoleId, roleIds));
+			// 组装配置
+			List<RoleScope> 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

+ 35 - 0
src/main/java/org/springblade/modules/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.modules.system.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * CheckedTreeVO
+ *
+ * @author Chill
+ */
+@Data
+public class CheckedTreeVO {
+
+	private List<String> menu;
+
+	private List<String> scope;
+
+}

+ 6 - 1
src/main/java/org/springblade/modules/system/vo/DeptVO.java

@@ -66,8 +66,13 @@ public class DeptVO extends Dept implements INode {
 	}
 
 	/**
-	 * 上级部门
+	 * 上级机构
 	 */
 	private String parentName;
 
+	/**
+	 * 机构类型名称
+	 */
+	private String deptCategoryName;
+
 }

+ 35 - 0
src/main/java/org/springblade/modules/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.modules.system.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * GrantTreeVO
+ *
+ * @author Chill
+ */
+@Data
+public class GrantTreeVO {
+
+	private List<MenuVO> menu;
+
+	private List<MenuVO> scope;
+
+}

+ 10 - 1
src/main/java/org/springblade/modules/system/wrapper/DeptWrapper.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.system.wrapper;
 
+import org.springblade.common.cache.DictCache;
 import org.springblade.common.cache.SysCache;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.core.mp.support.BaseEntityWrapper;
@@ -27,6 +28,7 @@ import org.springblade.modules.system.entity.Dept;
 import org.springblade.modules.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, DeptVO> {
 			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<INode> listNodeVO(List<Dept> list) {
-		List<INode> collect = list.stream().map(dept -> BeanUtil.copy(dept, DeptVO.class)).collect(Collectors.toList());
+		List<INode> 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);
 	}