From 77defdddf00a4f9d5050682f0c2648a4adbbbeb1 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sat, 13 Apr 2019 23:54:09 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E5=A2=9E=E5=8A=A0@PreAuth=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/springblade/develop/controller/CodeController.java | 3 +++ .../main/java/org/springblade/flowable/FlowApplication.java | 2 +- .../springblade/system/controller/AuthClientController.java | 3 +++ .../org/springblade/system/controller/DeptController.java | 3 +++ .../org/springblade/system/controller/DictController.java | 3 +++ .../org/springblade/system/controller/MenuController.java | 3 +++ .../org/springblade/system/controller/RoleController.java | 3 +++ .../org/springblade/system/service/impl/RoleServiceImpl.java | 4 ++-- .../springblade/system/user/controller/UserController.java | 3 +++ doc/nacos/{blade-flowable-dev.yaml => blade-flow-dev.yaml} | 0 10 files changed, 24 insertions(+), 3 deletions(-) rename doc/nacos/{blade-flowable-dev.yaml => blade-flow-dev.yaml} (100%) diff --git a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java index 713fdf44..f8abb7fe 100644 --- a/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java +++ b/blade-ops/blade-develop/src/main/java/org/springblade/develop/controller/CodeController.java @@ -22,7 +22,9 @@ 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.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.Func; import org.springblade.develop.entity.Code; import org.springblade.develop.service.ICodeService; @@ -43,6 +45,7 @@ import java.util.Map; @AllArgsConstructor @RequestMapping("/code") @Api(value = "代码生成", tags = "代码生成") +@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) public class CodeController extends BladeController { private ICodeService codeService; diff --git a/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java b/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java index f1d474eb..cbb79dd2 100644 --- a/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java +++ b/blade-service/blade-flow/src/main/java/org/springblade/flowable/FlowApplication.java @@ -31,7 +31,7 @@ import org.springframework.cloud.client.SpringCloudApplication; public class FlowApplication { public static void main(String[] args) { - BladeApplication.run(AppConstant.APPLICATION_FLOWABLE_NAME, FlowApplication.class, args); + BladeApplication.run(AppConstant.APPLICATION_FLOW_NAME, FlowApplication.class, args); } } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java index 4a4b14f3..06067e75 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/AuthClientController.java @@ -24,7 +24,9 @@ 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.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.AuthClient; import org.springblade.system.service.IAuthClientService; @@ -43,6 +45,7 @@ import javax.validation.Valid; @RequestMapping("/client") @ApiIgnore @Api(value = "应用管理", tags = "接口") +@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) public class AuthClientController extends BladeController { private IAuthClientService clientService; 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 65e890e8..cc4c26cf 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 @@ -22,8 +22,10 @@ import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Dept; @@ -46,6 +48,7 @@ import java.util.Map; @AllArgsConstructor @RequestMapping("/dept") @Api(value = "部门", tags = "部门") +@PreAuth(RoleConstant.HAS_ROLE_ADMIN) public class DeptController extends BladeController { private IDeptService deptService; diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java index 82cce269..439de825 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java @@ -20,7 +20,9 @@ import io.swagger.annotations.*; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Dict; @@ -47,6 +49,7 @@ import static org.springblade.common.cache.CacheNames.DICT_VALUE; @AllArgsConstructor @RequestMapping("/dict") @Api(value = "字典", tags = "字典") +@PreAuth(RoleConstant.HAS_ROLE_ADMIN) public class DictController extends BladeController { private IDictService dictService; 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 af8bdc3c..1f8f42bb 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 @@ -21,7 +21,9 @@ import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Menu; @@ -48,6 +50,7 @@ import static org.springblade.common.cache.CacheNames.AUTH_ROUTES; @AllArgsConstructor @RequestMapping("/menu") @Api(value = "菜单", tags = "菜单") +@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) public class MenuController extends BladeController { private IMenuService menuService; 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 4e32e8c6..6d5e672a 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 @@ -22,8 +22,10 @@ import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.node.INode; import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.Role; @@ -46,6 +48,7 @@ import java.util.Map; @AllArgsConstructor @RequestMapping("/role") @Api(value = "角色", tags = "角色") +@PreAuth(RoleConstant.HAS_ROLE_ADMIN) public class RoleController extends BladeController { private IRoleService roleService; 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 2129d3c9..9e4eb964 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 @@ -59,8 +59,8 @@ public class RoleServiceImpl extends ServiceImpl implements IR public List tree(String tenantCode) { String userRole = SecureUtil.getUserRole(); String excludeRole = null; - if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN)) { - excludeRole = RoleConstant.ADMIN; + if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) { + excludeRole = RoleConstant.ADMINISTRATOR; } return ForestNodeMerger.merge(baseMapper.tree(tenantCode, excludeRole)); } diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java index f2a73a03..1920ef95 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java @@ -27,8 +27,10 @@ import lombok.AllArgsConstructor; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.BladeUser; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.Func; import org.springblade.system.feign.IDictClient; import org.springblade.system.user.entity.User; @@ -49,6 +51,7 @@ import java.util.Map; @RestController @RequestMapping @AllArgsConstructor +@PreAuth(RoleConstant.HAS_ROLE_ADMIN) public class UserController { private IUserService userService; diff --git a/doc/nacos/blade-flowable-dev.yaml b/doc/nacos/blade-flow-dev.yaml similarity index 100% rename from doc/nacos/blade-flowable-dev.yaml rename to doc/nacos/blade-flow-dev.yaml