Explorar o código

重构权限,增加通用的权限设置,菜单合并到权限模块

zhouhao %!s(int64=8) %!d(string=hai) anos
pai
achega
31971fdf72
Modificáronse 61 ficheiros con 2094 adicións e 439 borrados
  1. 8 3
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java
  2. 57 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationSettingController.java
  3. 17 20
      hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java
  4. 3 3
      hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java
  5. 9 12
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java
  6. 27 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java
  7. 27 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java
  8. 2 2
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java
  9. 2 2
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java
  10. 2 2
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java
  11. 1 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/PermissionRoleDao.java
  12. 67 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml
  13. 64 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml
  14. 68 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml
  15. 7 9
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml
  16. 5 5
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml
  17. 4 4
      hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuMapper.xml
  18. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml
  19. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml
  20. 119 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java
  21. 96 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java
  22. 107 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java
  23. 5 5
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuEntity.java
  24. 12 40
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java
  25. 6 12
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java
  26. 1 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/PermissionRoleEntity.java
  27. 3 3
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java
  28. 133 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java
  29. 117 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java
  30. 106 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java
  31. 11 11
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java
  32. 12 51
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java
  33. 7 14
      hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java
  34. 5 12
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java
  35. 5 7
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java
  36. 7 3
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java
  37. 89 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java
  38. 23 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java
  39. 29 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java
  40. 62 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java
  41. 2 2
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java
  42. 3 4
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java
  43. 3 2
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java
  44. 77 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/PermissionSettingDTO.java
  45. 44 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/PermissionSettingDetailDTO.java
  46. 17 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java
  47. 6 5
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java
  48. 1 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java
  49. 44 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java
  50. 59 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java
  51. 327 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java
  52. 4 5
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java
  53. 13 80
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java
  54. 12 6
      hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java
  55. 4 4
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java
  56. 35 74
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java
  57. 11 0
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfigration.java
  58. 71 2
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js
  59. 21 16
      hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java
  60. 1 7
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/LoginTests.java
  61. 12 10
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/UserTests.java

+ 8 - 3
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java

@@ -22,11 +22,12 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
 import org.hswebframework.web.BusinessException;
 import org.hswebframework.web.BusinessException;
 import org.hswebframework.web.NotFoundException;
 import org.hswebframework.web.NotFoundException;
-import org.hswebframework.web.WebUtil;
 import org.hswebframework.web.authorization.Authentication;
 import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.authorization.AuthenticationInitializeService;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
 import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
 import org.hswebframework.web.authorization.listener.event.*;
 import org.hswebframework.web.authorization.listener.event.*;
+import org.hswebframework.web.commons.entity.DataStatus;
 import org.hswebframework.web.controller.message.ResponseMessage;
 import org.hswebframework.web.controller.message.ResponseMessage;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.logging.AccessLogger;
 import org.hswebframework.web.logging.AccessLogger;
@@ -51,6 +52,10 @@ public class AuthorizationController {
     @Autowired
     @Autowired
     private UserService userService;
     private UserService userService;
 
 
+    @Autowired
+    private AuthenticationInitializeService authenticationInitializeService;
+
+
     @Autowired
     @Autowired
     private AuthorizationListenerDispatcher authorizationListenerDispatcher;
     private AuthorizationListenerDispatcher authorizationListenerDispatcher;
 
 
@@ -90,7 +95,7 @@ public class AuthorizationController {
                 reason = AuthorizationFailedEvent.Reason.USER_NOT_EXISTS;
                 reason = AuthorizationFailedEvent.Reason.USER_NOT_EXISTS;
                 throw new NotFoundException("{user_not_exists}");
                 throw new NotFoundException("{user_not_exists}");
             }
             }
-            if (Boolean.FALSE.equals(entity.isEnabled())) {
+            if (!DataStatus.STATUS_ENABLED.equals(entity.getStatus())) {
                 reason = AuthorizationFailedEvent.Reason.USER_DISABLED;
                 reason = AuthorizationFailedEvent.Reason.USER_DISABLED;
                 throw new BusinessException("{user_is_disabled}", 400);
                 throw new BusinessException("{user_is_disabled}", 400);
             }
             }
@@ -100,7 +105,7 @@ public class AuthorizationController {
                 throw new BusinessException("{password_error}", 400);
                 throw new BusinessException("{password_error}", 400);
             }
             }
             // 验证通过
             // 验证通过
-            Authentication authentication = userService.initUserAuthorization(entity.getId());
+            Authentication authentication = authenticationInitializeService.initUserAuthorization(entity.getId());
             AuthorizationSuccessEvent event = new AuthorizationSuccessEvent(authentication, parameterGetter);
             AuthorizationSuccessEvent event = new AuthorizationSuccessEvent(authentication, parameterGetter);
             authorizationListenerDispatcher.doEvent(event);
             authorizationListenerDispatcher.doEvent(event);
             return ok(entity.getId());
             return ok(entity.getId());

+ 57 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationSettingController.java

@@ -0,0 +1,57 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+
+package org.hswebframework.web.controller.authorization;
+
+import org.hswebframework.web.authorization.annotation.Authorize;
+import org.hswebframework.web.commons.entity.param.QueryParamEntity;
+import org.hswebframework.web.controller.GenericEntityController;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity;
+import org.hswebframework.web.logging.AccessLogger;
+import org.hswebframework.web.service.authorization.AuthorizationSettingService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 权限设置
+ *
+ * @author hsweb-generator-online
+ */
+@RestController
+@RequestMapping("${hsweb.web.mappings.autz-setting:autz-setting}")
+@Authorize(permission = "autz-setting")
+@AccessLogger("权限设置")
+public class AuthorizationSettingController implements GenericEntityController<AuthorizationSettingEntity, String, QueryParamEntity, AuthorizationSettingEntity> {
+
+    private AuthorizationSettingService authorizationSettingService;
+
+    @Override
+    public AuthorizationSettingEntity modelToEntity(AuthorizationSettingEntity model, AuthorizationSettingEntity entity) {
+        return model;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingService(AuthorizationSettingService authorizationSettingService) {
+        this.authorizationSettingService = authorizationSettingService;
+    }
+
+    @Override
+    public AuthorizationSettingService getService() {
+        return authorizationSettingService;
+    }
+}

+ 17 - 20
hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuController.java

@@ -16,31 +16,28 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.controller.menu;
+package org.hswebframework.web.controller.authorization;
 
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
 import org.hswebframework.web.authorization.Authentication;
 import org.hswebframework.web.authorization.Authentication;
-import org.hswebframework.web.authorization.Role;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.annotation.Authorize;
-import org.hswebframework.web.commons.entity.TreeSupportEntity;
 import org.hswebframework.web.commons.entity.param.QueryParamEntity;
 import org.hswebframework.web.commons.entity.param.QueryParamEntity;
-import org.hswebframework.web.controller.GenericEntityController;
 import org.hswebframework.web.controller.SimpleGenericEntityController;
 import org.hswebframework.web.controller.SimpleGenericEntityController;
 import org.hswebframework.web.controller.message.ResponseMessage;
 import org.hswebframework.web.controller.message.ResponseMessage;
-import org.hswebframework.web.entity.menu.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
+import org.hswebframework.web.entity.authorization.UserMenuEntity;
 import org.hswebframework.web.logging.AccessLogger;
 import org.hswebframework.web.logging.AccessLogger;
-import org.hswebframework.web.service.menu.MenuGroupService;
-import org.hswebframework.web.service.menu.MenuService;
+import org.hswebframework.web.service.authorization.MenuGroupService;
+import org.hswebframework.web.service.authorization.MenuService;
+import org.hswebframework.web.service.authorization.UserMenuManagerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
-import java.util.stream.Collectors;
 
 
 import static org.hswebframework.web.controller.message.ResponseMessage.ok;
 import static org.hswebframework.web.controller.message.ResponseMessage.ok;
 
 
@@ -60,6 +57,8 @@ public class MenuController implements SimpleGenericEntityController<MenuEntity,
 
 
     private MenuGroupService menuGroupService;
     private MenuGroupService menuGroupService;
 
 
+    private UserMenuManagerService userMenuManagerService;
+
     @Autowired
     @Autowired
     public void setMenuService(MenuService menuService) {
     public void setMenuService(MenuService menuService) {
         this.menuService = menuService;
         this.menuService = menuService;
@@ -70,6 +69,11 @@ public class MenuController implements SimpleGenericEntityController<MenuEntity,
         this.menuGroupService = menuGroupService;
         this.menuGroupService = menuGroupService;
     }
     }
 
 
+    @Autowired
+    public void setUserMenuManagerService(UserMenuManagerService userMenuManagerService) {
+        this.userMenuManagerService = userMenuManagerService;
+    }
+
     @Override
     @Override
     public MenuService getService() {
     public MenuService getService() {
         return menuService;
         return menuService;
@@ -78,21 +82,14 @@ public class MenuController implements SimpleGenericEntityController<MenuEntity,
     @GetMapping("/user-own/list")
     @GetMapping("/user-own/list")
     @Authorize(merge = false)
     @Authorize(merge = false)
     @ApiOperation("获取当前用户的菜单列表")
     @ApiOperation("获取当前用户的菜单列表")
-    public ResponseMessage<List<MenuEntity>> getUserMenuAsList(@ApiParam(hidden = true) Authentication authentication) {
-        List<MenuEntity> menuEntities = menuGroupService
-                .getMenuByGroupId(authentication.getRoles()
-                        .stream()
-                        .map(Role::getId)
-                        .collect(Collectors.toList()));
-        return ok(menuEntities);
+    public ResponseMessage<List<UserMenuEntity>> getUserMenuAsList(@ApiParam(hidden = true) Authentication authentication) {
+        return ok(userMenuManagerService.getUserMenuAsList(authentication.getUser().getId()));
     }
     }
 
 
     @GetMapping("/user-own/tree")
     @GetMapping("/user-own/tree")
     @Authorize(merge = false)
     @Authorize(merge = false)
     @ApiOperation("获取当前用户的菜单树")
     @ApiOperation("获取当前用户的菜单树")
-    public ResponseMessage<List<MenuEntity>> getUserMenuAsTree(@ApiParam(hidden = true) Authentication authentication) {
-        List<MenuEntity> menuEntities = getUserMenuAsList(authentication).getResult();
-        //list转tree
-        return ok(TreeSupportEntity.list2tree(menuEntities, (menu, children) -> menu.setChildren(new ArrayList<>(children))));
+    public ResponseMessage<List<UserMenuEntity>> getUserMenuAsTree(@ApiParam(hidden = true) Authentication authentication) {
+        return ok(userMenuManagerService.getUserMenuAsTree(authentication.getUser().getId()));
     }
     }
 }
 }

+ 3 - 3
hsweb-system/hsweb-system-menu/hsweb-system-menu-controller/src/main/java/org/hswebframework/web/controller/menu/MenuGroupController.java

@@ -15,14 +15,14 @@
  *  
  *  
  */
  */
 
 
-package org.hswebframework.web.controller.menu;
+package org.hswebframework.web.controller.authorization;
 
 
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.commons.entity.param.QueryParamEntity;
 import org.hswebframework.web.commons.entity.param.QueryParamEntity;
 import org.hswebframework.web.controller.GenericEntityController;
 import org.hswebframework.web.controller.GenericEntityController;
-import org.hswebframework.web.entity.menu.MenuGroupEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupEntity;
 import org.hswebframework.web.logging.AccessLogger;
 import org.hswebframework.web.logging.AccessLogger;
-import org.hswebframework.web.service.menu.MenuGroupService;
+import org.hswebframework.web.service.authorization.MenuGroupService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;

+ 9 - 12
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/CacheConstants.java

@@ -1,30 +1,27 @@
 /*
 /*
  *  Copyright 2016 http://www.hswebframework.org
  *  Copyright 2016 http://www.hswebframework.org
- *
+ *  
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
  *  You may obtain a copy of the License at
  *
  *
  *        http://www.apache.org/licenses/LICENSE-2.0
  *        http://www.apache.org/licenses/LICENSE-2.0
- *
+ *  
  *  Unless required by applicable law or agreed to in writing, software
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  *  limitations under the License.
- *
- *
+ *  
  */
  */
+package org.hswebframework.web.dao.authorization;
 
 
-package org.hswebframework.web.service.menu.simple;
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity;
 
 
 /**
 /**
- * 缓存使用到的常量
- *
- * @author zhouhao
- * @see org.springframework.cache.annotation.Cacheable
- * @see org.springframework.cache.annotation.CacheEvict
+*  权限设置 DAO接口
+*  @author hsweb-generator-online
  */
  */
-public interface CacheConstants {
-    String MENU_CACHE_NAME = "hsweb-menu:";
+public interface AuthorizationSettingDao extends CrudDao<AuthorizationSettingEntity,String> {
 }
 }

+ 27 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java

@@ -0,0 +1,27 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.dao.authorization;
+
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingDetailEntity;
+
+/**
+*  权限设置详情 DAO接口
+*  @author hsweb-generator-online
+ */
+public interface AuthorizationSettingDetailDao extends CrudDao<AuthorizationSettingDetailEntity,String> {
+}

+ 27 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java

@@ -0,0 +1,27 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.dao.authorization;
+
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity;
+
+/**
+*  权限菜单 DAO接口
+*  @author hsweb-generator-online
+ */
+public interface AuthorizationSettingMenuDao extends CrudDao<AuthorizationSettingMenuEntity,String> {
+}

+ 2 - 2
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuDao.java

@@ -16,10 +16,10 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.dao.menu;
+package org.hswebframework.web.dao.authorization;
 
 
 import org.hswebframework.web.dao.CrudDao;
 import org.hswebframework.web.dao.CrudDao;
-import org.hswebframework.web.entity.menu.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
 
 
 /**
 /**
  * TODO 完成注释
  * TODO 完成注释

+ 2 - 2
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupBindDao.java

@@ -14,10 +14,10 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.dao.menu;
+package org.hswebframework.web.dao.authorization;
 
 
 import org.hswebframework.web.dao.CrudDao;
 import org.hswebframework.web.dao.CrudDao;
-import org.hswebframework.web.entity.menu.MenuGroupBindEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupBindEntity;
 
 
 /**
 /**
 *  菜单分组关联 DAO接口
 *  菜单分组关联 DAO接口

+ 2 - 2
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-api/src/main/java/org/hswebframework/web/dao/menu/MenuGroupDao.java

@@ -14,10 +14,10 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.dao.menu;
+package org.hswebframework.web.dao.authorization;
 
 
 import org.hswebframework.web.dao.CrudDao;
 import org.hswebframework.web.dao.CrudDao;
-import org.hswebframework.web.entity.menu.MenuGroupEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupEntity;
 
 
 /**
 /**
 *  菜单分组 DAO接口
 *  菜单分组 DAO接口

+ 1 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/PermissionRoleDao.java

@@ -10,6 +10,7 @@ import java.util.List;
  *
  *
  * @author zhouhao
  * @author zhouhao
  */
  */
+@Deprecated
 public interface PermissionRoleDao extends Dao {
 public interface PermissionRoleDao extends Dao {
     int insert(PermissionRoleEntity permissionRoleBean);
     int insert(PermissionRoleEntity permissionRoleBean);
 
 

+ 67 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Copyright 2016 http://www.hswebframework.org
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  ~
+  -->
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.hswebframework.web.dao.authorization.AuthorizationSettingDetailDao">
+    <resultMap id="AuthorizationSettingDetailResultMap" type="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingDetailEntity">
+        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+        <result property="permissionId" column="permission_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="settingId" column="setting_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="actions" column="actions" javaType="java.util.Set" jdbcType="CLOB"/>
+        <result property="dataAccesses" column="data_accesses" javaType="java.util.List" jdbcType="CLOB"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="DECIMAL"/>
+        <result property="priority" column="priority" jdbcType="DECIMAL" javaType="Long"/>
+        <result property="merge" column="is_merge" jdbcType="DECIMAL" javaType="Boolean"/>
+    </resultMap>
+
+    <!--用于动态生成sql所需的配置-->
+    <sql id="config">
+        <bind name="resultMapId" value="'AuthorizationSettingDetailResultMap'"/>
+        <bind name="tableName" value="'s_autz_detail'"/>
+    </sql>
+
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingDetailEntity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildInsertSql"/>
+    </insert>
+
+    <delete id="deleteByPk" parameterType="String">
+        delete from s_autz_detail where u_id =#{id}
+    </delete>
+
+    <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildDeleteSql"/>
+    </delete>
+
+    <update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
+    </update>
+
+    <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="AuthorizationSettingDetailResultMap">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildSelectSql"/>
+    </select>
+
+    <select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildTotalSql"/>
+    </select>
+</mapper>

+ 64 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Copyright 2016 http://www.hswebframework.org
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  ~
+  -->
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.hswebframework.web.dao.authorization.AuthorizationSettingDao">
+    <resultMap id="AuthorizationSettingResultMap" type="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingEntity">
+        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+            <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
+            <result property="settingFor" column="setting_for" javaType="String" jdbcType="VARCHAR"/>
+            <result property="status" column="status" javaType="Byte" jdbcType="DECIMAL"/>
+            <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <!--用于动态生成sql所需的配置-->
+    <sql id="config">
+        <bind name="resultMapId" value="'AuthorizationSettingResultMap'"/>
+        <bind name="tableName" value="'s_autz_setting'"/>
+    </sql>
+  
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingEntity" >
+        <include refid="config"/>
+        <include refid="BasicMapper.buildInsertSql"/>
+    </insert>
+
+    <delete id="deleteByPk" parameterType="String">
+        delete from s_autz_setting where u_id =#{id}
+    </delete>
+
+    <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildDeleteSql"/>
+    </delete>
+
+    <update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
+    </update>
+
+    <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="AuthorizationSettingResultMap">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildSelectSql"/>
+    </select>
+
+    <select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildTotalSql"/>
+    </select>
+</mapper>

+ 68 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  ~ Copyright 2016 http://www.hswebframework.org
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  ~
+  -->
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.hswebframework.web.dao.authorization.AuthorizationSettingMenuDao">
+    <resultMap id="AuthorizationSettingMenuResultMap" type="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingMenuEntity">
+        <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+        <result property="menuId" column="menu_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="settingId" column="setting_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
+        <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="DECIMAL"/>
+        <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
+        <result property="level" column="level" javaType="Long" jdbcType="DECIMAL"/>
+        <result property="config" column="config" javaType="String" jdbcType="CLOB"/>
+    </resultMap>
+
+    <!--用于动态生成sql所需的配置-->
+    <sql id="config">
+        <bind name="resultMapId" value="'AuthorizationSettingMenuResultMap'"/>
+        <bind name="tableName" value="'s_autz_menu'"/>
+    </sql>
+
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingMenuEntity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildInsertSql"/>
+    </insert>
+
+    <delete id="deleteByPk" parameterType="String">
+        delete from s_autz_menu where u_id =#{id}
+    </delete>
+
+    <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildDeleteSql"/>
+    </delete>
+
+    <update id="update" parameterType="org.hswebframework.web.commons.entity.Entity">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
+    </update>
+
+    <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="AuthorizationSettingMenuResultMap">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildSelectSql"/>
+    </select>
+
+    <select id="count" parameterType="org.hswebframework.web.commons.entity.Entity" resultType="int">
+        <include refid="config"/>
+        <include refid="BasicMapper.buildTotalSql"/>
+    </select>
+</mapper>

+ 7 - 9
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupBindMapper.xml

@@ -18,33 +18,31 @@
 <!DOCTYPE mapper
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hswebframework.web.dao.menu.MenuGroupBindDao">
-    <resultMap id="MenuGroupBindResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuGroupBindEntity">
+<mapper namespace="org.hswebframework.web.dao.authorization.MenuGroupBindDao">
+    <resultMap id="MenuGroupBindResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuGroupBindEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
         <result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
         <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
         <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
-        <result property="enabled" column="enabled" javaType="Boolean" jdbcType="DECIMAL"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="DECIMAL"/>
         <result property="menuId" column="menu_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="menuId" column="menu_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="groupId" column="group_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="groupId" column="group_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="actions" column="actions" javaType="java.util.List" jdbcType="VARCHAR"/>
-        <result property="dataAccesses" column="data_accesses" javaType="java.util.List" jdbcType="CLOB"/>
     </resultMap>
     </resultMap>
 
 
     <!--用于动态生成sql所需的配置-->
     <!--用于动态生成sql所需的配置-->
     <sql id="config">
     <sql id="config">
         <bind name="resultMapId" value="'MenuGroupBindResultMap'"/>
         <bind name="resultMapId" value="'MenuGroupBindResultMap'"/>
-        <bind name="tableName" value="'S_MENU_GROUP_BIND'"/>
+        <bind name="tableName" value="'s_menu_group_bind'"/>
     </sql>
     </sql>
 
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.menu.SimpleMenuGroupBindEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleMenuGroupBindEntity">
         <include refid="config"/>
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>
     </insert>
 
 
     <delete id="deleteByPk" parameterType="String">
     <delete id="deleteByPk" parameterType="String">
-        delete from S_MENU_GROUP_BIND where u_id =#{id}
+        delete from s_menu_group_bind where u_id =#{id}
     </delete>
     </delete>
 
 
     <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
     <delete id="delete" parameterType="org.hswebframework.web.commons.entity.Entity">
@@ -58,7 +56,7 @@
     </update>
     </update>
 
 
     <select id="queryByGroupId" parameterType="String" resultMap="MenuGroupBindResultMap">
     <select id="queryByGroupId" parameterType="String" resultMap="MenuGroupBindResultMap">
-        select * from S_MENU_GROUP_BIND where group_id =#{id}
+        select * from s_menu_group_bind where group_id =#{id}
     </select>
     </select>
 
 
     <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="MenuGroupBindResultMap">
     <select id="query" parameterType="org.hswebframework.web.commons.entity.Entity" resultMap="MenuGroupBindResultMap">

+ 5 - 5
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuGroupMapper.xml

@@ -18,8 +18,8 @@
 <!DOCTYPE mapper
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.hswebframework.web.dao.menu.MenuGroupDao">
-    <resultMap id="MenuGroupResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuGroupEntity">
+<mapper namespace="org.hswebframework.web.dao.authorization.MenuGroupDao">
+    <resultMap id="MenuGroupResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuGroupEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
@@ -28,17 +28,17 @@
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
         <result property="level" column="level" javaType="Integer" jdbcType="DECIMAL"/>
         <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
         <result property="sortIndex" column="sort_index" javaType="Long" jdbcType="DECIMAL"/>
-        <result property="enabled" column="enabled" javaType="Boolean" jdbcType="DECIMAL"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="DECIMAL"/>
         <collection property="bindInfo" column="u_id" select="org.hswebframework.web.dao.menu.MenuGroupBindDao.queryByGroupId"/>
         <collection property="bindInfo" column="u_id" select="org.hswebframework.web.dao.menu.MenuGroupBindDao.queryByGroupId"/>
     </resultMap>
     </resultMap>
 
 
     <!--用于动态生成sql所需的配置-->
     <!--用于动态生成sql所需的配置-->
     <sql id="config">
     <sql id="config">
         <bind name="resultMapId" value="'MenuGroupResultMap'"/>
         <bind name="resultMapId" value="'MenuGroupResultMap'"/>
-        <bind name="tableName" value="'S_MENU_GROUP'"/>
+        <bind name="tableName" value="'s_menu_group'"/>
     </sql>
     </sql>
 
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.menu.SimpleMenuGroupEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.SimpleMenuGroupEntity">
         <include refid="config"/>
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>
     </insert>

+ 4 - 4
hsweb-system/hsweb-system-menu/hsweb-system-menu-dao/hsweb-system-menu-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/menu/MenuMapper.xml

@@ -20,8 +20,8 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 
-<mapper namespace="org.hswebframework.web.dao.menu.MenuDao">
-    <resultMap id="MenuResultMap" type="org.hswebframework.web.entity.menu.SimpleMenuEntity">
+<mapper namespace="org.hswebframework.web.dao.authorization.MenuDao">
+    <resultMap id="MenuResultMap" type="org.hswebframework.web.entity.authorization.SimpleMenuEntity">
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
@@ -29,7 +29,7 @@
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR"/>
         <result property="url" column="url" javaType="String" jdbcType="VARCHAR"/>
         <result property="url" column="url" javaType="String" jdbcType="VARCHAR"/>
         <result property="permissionId" column="permission_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="permissionId" column="permission_id" javaType="String" jdbcType="VARCHAR"/>
-        <result property="enabled" column="enabled" javaType="boolean" jdbcType="NUMERIC"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="NUMERIC"/>
         <result property="sortIndex" column="sort_index" javaType="long" jdbcType="NUMERIC"/>
         <result property="sortIndex" column="sort_index" javaType="long" jdbcType="NUMERIC"/>
         <result property="icon" column="icon" javaType="String" jdbcType="VARCHAR"/>
         <result property="icon" column="icon" javaType="String" jdbcType="VARCHAR"/>
     </resultMap>
     </resultMap>
@@ -40,7 +40,7 @@
         <bind name="tableName" value="'s_menu'"/>
         <bind name="tableName" value="'s_menu'"/>
     </sql>
     </sql>
 
 
-    <insert id="insert" parameterType="org.hswebframework.web.entity.menu.MenuEntity">
+    <insert id="insert" parameterType="org.hswebframework.web.entity.authorization.MenuEntity">
         <include refid="config"/>
         <include refid="config"/>
         <include refid="BasicMapper.buildInsertSql"/>
         <include refid="BasicMapper.buildInsertSql"/>
     </insert>
     </insert>

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml

@@ -25,7 +25,7 @@
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="string" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="string" jdbcType="VARCHAR"/>
         <result property="describe" column="describe" javaType="string" jdbcType="VARCHAR"/>
-        <result property="enabled" column="enabled" javaType="boolean" jdbcType="NUMERIC"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="NUMERIC"/>
     </resultMap>
     </resultMap>
 
 
     <!--用于动态生成sql所需的配置-->
     <!--用于动态生成sql所需的配置-->

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-mybatis/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml

@@ -27,7 +27,7 @@
         <result property="username" column="username" javaType="string" jdbcType="VARCHAR"/>
         <result property="username" column="username" javaType="string" jdbcType="VARCHAR"/>
         <result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
         <result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
         <result property="salt" column="salt" javaType="String" jdbcType="VARCHAR"/>
         <result property="salt" column="salt" javaType="String" jdbcType="VARCHAR"/>
-        <result property="enabled" column="enabled" javaType="Boolean" jdbcType="NUMERIC"/>
+        <result property="status" column="status" javaType="Byte" jdbcType="NUMERIC"/>
         <result property="createTime" column="create_time" javaType="Long" jdbcType="NUMERIC"/>
         <result property="createTime" column="create_time" javaType="Long" jdbcType="NUMERIC"/>
         <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
     </resultMap>
     </resultMap>

+ 119 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java

@@ -0,0 +1,119 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.GenericEntity;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 权限设置详情 实体
+ *
+ * @author hsweb-generator-online
+ */
+public interface AuthorizationSettingDetailEntity extends GenericEntity<String>, Comparable<AuthorizationSettingDetailEntity> {
+
+    Byte STATE_OK = 1;
+
+   /*-------------------------------------------
+    |               属性名常量                 |
+    ===========================================*/
+    /**
+     * 权限id
+     */
+    String permissionId = "permissionId";
+    /**
+     * 设置id
+     */
+    String settingId    = "settingId";
+    /**
+     * 可操作类型
+     */
+    String actions      = "actions";
+    /**
+     * 数据权限控制
+     */
+    String dataAccesses = "dataAccesses";
+    /**
+     * 状态
+     */
+    String state        = "status";
+
+    /**
+     * @return 权限id
+     */
+    String getPermissionId();
+
+    /**
+     * 设置 权限id
+     */
+    void setPermissionId(String permissionId);
+
+    /**
+     * @return 设置id
+     */
+    String getSettingId();
+
+    /**
+     * 设置 设置id
+     */
+    void setSettingId(String settingId);
+
+    /**
+     * @return 可操作类型
+     */
+    Set<String> getActions();
+
+    /**
+     * 设置 可操作类型
+     */
+    void setActions(Set<String> actions);
+
+    /**
+     * @return 数据权限控制
+     */
+    List<DataAccessEntity> getDataAccesses();
+
+    /**
+     * 设置 数据权限控制
+     */
+    void setDataAccesses(List<DataAccessEntity> dataAccesses);
+
+    /**
+     * @return 状态
+     */
+    Byte getStatus();
+
+    /**
+     * 设置 状态
+     */
+    void setStatus(Byte status);
+
+    Long getPriority();
+
+    void setPriority(Long priority);
+
+    Boolean isMerge();
+
+    void setMerge(Boolean merge);
+
+    @Override
+    default int compareTo(AuthorizationSettingDetailEntity target) {
+        return Long.compare(getPriority() == null ? 0 : getPriority(), target.getPriority() == null ? 0 : target.getPriority());
+    }
+}

+ 96 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java

@@ -0,0 +1,96 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.GenericEntity;
+
+import java.util.List;
+
+/**
+ * 权限设置 实体
+ *
+ * @author hsweb-generator-online
+ */
+public interface AuthorizationSettingEntity extends GenericEntity<String> {
+  /*-------------------------------------------
+    |                属性名常量                |
+    ===========================================*/
+    /**
+     * 类型
+     */
+    String type       = "type";
+    /**
+     * 设置给谁
+     */
+    String settingFor = "settingFor";
+    /**
+     * 状态
+     */
+    String state      = "status";
+    /**
+     * 备注
+     */
+    String describe   = "describe";
+
+    /**
+     * @return 类型
+     */
+    String getType();
+
+    /**
+     * 设置 类型
+     */
+    void setType(String type);
+
+    /**
+     * @return 设置给谁
+     */
+    String getSettingFor();
+
+    /**
+     * 设置 设置给谁
+     */
+    void setSettingFor(String settingFor);
+
+    /**
+     * @return 状态
+     */
+    Byte getStatus();
+
+    /**
+     * 设置 状态
+     */
+    void setStatus(Byte status);
+
+    /**
+     * @return 备注
+     */
+    String getDescribe();
+
+    /**
+     * 设置 备注
+     */
+    void setDescribe(String describe);
+
+    List<AuthorizationSettingDetailEntity> getDetails();
+
+    void setDetails(List<AuthorizationSettingDetailEntity> details);
+
+    List<AuthorizationSettingMenuEntity> getMenus();
+
+    void setMenus(List<AuthorizationSettingMenuEntity> menus);
+}

+ 107 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java

@@ -0,0 +1,107 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.GenericEntity;
+import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
+
+import java.util.List;
+
+/**
+ * 权限菜单 实体
+ *
+ * @author hsweb-generator-online
+ */
+public interface AuthorizationSettingMenuEntity extends TreeSortSupportEntity<String> {
+ /*-------------------------------------------
+    |               属性名常量               |
+    ===========================================*/
+    /**
+     * 菜单id
+     */
+    String menuId    = "menuId";
+    /**
+     * 设置id
+     */
+    String settingId = "settingId";
+    /**
+     * 排序
+     */
+    String sortIndex = "sortIndex";
+    /**
+     * 上级id
+     */
+    String parentId  = "parentId";
+    /**
+     * 状态
+     */
+    String state     = "status";
+    /**
+     * 树路径
+     */
+    String path      = "path";
+    /**
+     * 树层级
+     */
+    String level     = "level";
+    /**
+     * 其他配置内容
+     */
+    String config    = "config";
+
+    /**
+     * @return 菜单id
+     */
+    String getMenuId();
+
+    /**
+     * 设置 菜单id
+     */
+    void setMenuId(String menuId);
+
+    /**
+     * @return 设置id
+     */
+    String getSettingId();
+
+    /**
+     * 设置 设置id
+     */
+    void setSettingId(String settingId);
+
+    /**
+     * @return 状态
+     */
+    Byte getStatus();
+
+    /**
+     * 设置 状态
+     */
+    void setStatus(Byte status);
+
+    /**
+     * @return 其他配置内容
+     */
+    String getConfig();
+
+    /**
+     * 设置 其他配置内容
+     */
+    void setConfig(String config);
+
+    void setChildren(List<AuthorizationSettingMenuEntity> children);
+}

+ 5 - 5
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuEntity.java

@@ -16,9 +16,9 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
-import org.hswebframework.web.commons.entity.*;
+import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -47,11 +47,11 @@ public interface MenuEntity
 
 
     void setIcon(String icon);
     void setIcon(String icon);
 
 
-    Boolean isEnabled();
+    Byte getStatus();
 
 
-    void setEnabled(Boolean enabled);
+    void setStatus(Byte status);
 
 
-    void setChildren(List<MenuEntity> children);
+    void setChildren(List<? extends MenuEntity> children);
 
 
     MenuEntity clone();
     MenuEntity clone();
 }
 }

+ 12 - 40
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupBindEntity.java

@@ -14,10 +14,9 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
 import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
 import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
-import org.hswebframework.web.entity.authorization.DataAccessEntity;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -37,45 +36,37 @@ public interface MenuGroupBindEntity extends TreeSortSupportEntity<String> {
     /**
     /**
      * 父级id
      * 父级id
      */
      */
-    String parentId      = "parentId";
+    String parentId  = "parentId";
     /**
     /**
      * 树层级
      * 树层级
      */
      */
-    String level         = "level";
+    String level     = "level";
     /**
     /**
      * 排序序号
      * 排序序号
      */
      */
-    String sortIndex     = "sortIndex";
+    String sortIndex = "sortIndex";
     /**
     /**
-     * 是否启用
+     * 状态
      */
      */
-    String enable        = "enabled";
+    String state     = "status";
     /**
     /**
      * 菜单id
      * 菜单id
      */
      */
-    String menuId        = "menuId";
+    String menuId    = "menuId";
     /**
     /**
      * 分组id
      * 分组id
      */
      */
-    String groupId       = "groupId";
-    /**
-     * 可选按钮
-     */
-    String actions       = "actions";
-    /**
-     * 行级权限控制配置
-     */
-    String dataAccesses  = "dataAccesses";
+    String groupId   = "groupId";
 
 
     /**
     /**
-     * @return 是否启用
+     * @return 状态
      */
      */
-    Boolean isEnabled();
+    Byte getStatus();
 
 
     /**
     /**
-     * 设置 是否启用
+     * 设置 状态
      */
      */
-    void setEnabled(Boolean enabled);
+    void setStatus(Byte status);
 
 
     /**
     /**
      * @return 菜单id
      * @return 菜单id
@@ -97,25 +88,6 @@ public interface MenuGroupBindEntity extends TreeSortSupportEntity<String> {
      */
      */
     void setGroupId(String groupId);
     void setGroupId(String groupId);
 
 
-    /**
-     * @return 可选按钮
-     */
-    java.util.List<String> getActions();
-
-    /**
-     * 设置 可选按钮
-     */
-    void setActions(java.util.List<String> actions);
-
-    /**
-     * @return 行级权限控制配置
-     */
-    java.util.List<DataAccessEntity> getDataAccesses();
-
-    /**
-     * 设置 行级权限控制配置
-     */
-    void setDataAccesses(java.util.List<DataAccessEntity> dataAccesses);
 
 
     void setChildren(List<MenuGroupBindEntity> children);
     void setChildren(List<MenuGroupBindEntity> children);
 }
 }

+ 6 - 12
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/MenuGroupEntity.java

@@ -14,7 +14,7 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
 import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
 import org.hswebframework.web.commons.entity.TreeSortSupportEntity;
 
 
@@ -44,7 +44,7 @@ public interface MenuGroupEntity extends TreeSortSupportEntity<String> {
     /**
     /**
      * 树结构编码
      * 树结构编码
      */
      */
-    String path     = "path";
+    String path         = "path";
     /**
     /**
      * 父级id
      * 父级id
      */
      */
@@ -58,9 +58,9 @@ public interface MenuGroupEntity extends TreeSortSupportEntity<String> {
      */
      */
     String sortIndex    = "sortIndex";
     String sortIndex    = "sortIndex";
     /**
     /**
-     * 是否启用
+     * 状态
      */
      */
-    String enabled      = "enabled";
+    String state        = "status";
 
 
     /**
     /**
      * @return 分组名称
      * @return 分组名称
@@ -92,15 +92,9 @@ public interface MenuGroupEntity extends TreeSortSupportEntity<String> {
      */
      */
     void setDefaultGroup(Boolean defaultGroup);
     void setDefaultGroup(Boolean defaultGroup);
 
 
-    /**
-     * @return 是否启用
-     */
-    Boolean isEnabled();
+    Byte getStatus();
 
 
-    /**
-     * 设置 是否启用
-     */
-    void setEnabled(Boolean enabled);
+    void setStatus(Byte status);
 
 
     List<MenuGroupBindEntity> getBindInfo();
     List<MenuGroupBindEntity> getBindInfo();
 
 

+ 1 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/PermissionRoleEntity.java

@@ -9,6 +9,7 @@ import java.util.List;
  *
  *
  * @author zhouhao
  * @author zhouhao
  */
  */
+@Deprecated
 public interface PermissionRoleEntity extends CloneableEntity {
 public interface PermissionRoleEntity extends CloneableEntity {
 
 
     void setRoleId(String roleId);
     void setRoleId(String roleId);

+ 3 - 3
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java

@@ -11,7 +11,7 @@ public interface RoleEntity extends GenericEntity<String> {
 
 
     String name     = "name";
     String name     = "name";
     String describe = "describe";
     String describe = "describe";
-    String enabled  = "enabled";
+    String status   = "status";
 
 
     String getName();
     String getName();
 
 
@@ -21,7 +21,7 @@ public interface RoleEntity extends GenericEntity<String> {
 
 
     void setDescribe(String describe);
     void setDescribe(String describe);
 
 
-    void setEnabled(Boolean enabled);
+    void setStatus(Byte status);
 
 
-    Boolean isEnabled();
+    Byte getStatus();
 }
 }

+ 133 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java

@@ -0,0 +1,133 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.SimpleGenericEntity;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 权限设置详情
+ *
+ * @author hsweb-generator-online
+ */
+public class SimpleAuthorizationSettingDetailEntity extends SimpleGenericEntity<String> implements AuthorizationSettingDetailEntity {
+    //权限id
+    private String                 permissionId;
+    //设置id
+    private String                 settingId;
+    //可操作类型
+    private Set<String>            actions;
+    //数据权限控制
+    private List<DataAccessEntity> dataAccesses;
+    //状态
+    private Byte                   status;
+    //优先级
+    private Long                   priority;
+    //是否合并
+    private Boolean                merge;
+
+    /**
+     * @return 权限id
+     */
+    public String getPermissionId() {
+        return this.permissionId;
+    }
+
+    /**
+     * 设置 权限id
+     */
+    public void setPermissionId(String permissionId) {
+        this.permissionId = permissionId;
+    }
+
+    /**
+     * @return 设置id
+     */
+    public String getSettingId() {
+        return this.settingId;
+    }
+
+    /**
+     * 设置 设置id
+     */
+    public void setSettingId(String settingId) {
+        this.settingId = settingId;
+    }
+
+    /**
+     * @return 可操作类型
+     */
+    public Set<String> getActions() {
+        return this.actions;
+    }
+
+    /**
+     * 设置 可操作类型
+     */
+    public void setActions(Set<String> actions) {
+        this.actions = actions;
+    }
+
+    /**
+     * @return 数据权限控制
+     */
+    public List<DataAccessEntity> getDataAccesses() {
+        return this.dataAccesses;
+    }
+
+    /**
+     * 设置 数据权限控制
+     */
+    public void setDataAccesses(List<DataAccessEntity> dataAccesses) {
+        this.dataAccesses = dataAccesses;
+    }
+
+    /**
+     * @return 状态
+     */
+    public Byte getStatus() {
+        return this.status;
+    }
+
+    /**
+     * 设置 状态
+     */
+    public void setStatus(Byte status) {
+        this.status = status;
+    }
+
+    @Override
+    public Long getPriority() {
+        return priority;
+    }
+
+    @Override
+    public void setPriority(Long priority) {
+        this.priority = priority;
+    }
+
+    public Boolean isMerge() {
+        return merge;
+    }
+
+    @Override
+    public void setMerge(Boolean merge) {
+        this.merge = merge;
+    }
+}

+ 117 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java

@@ -0,0 +1,117 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.SimpleGenericEntity;
+
+import java.util.List;
+
+/**
+ * 权限设置
+ *
+ * @author hsweb-generator-online
+ */
+public class SimpleAuthorizationSettingEntity extends SimpleGenericEntity<String> implements AuthorizationSettingEntity {
+    //类型
+    private String type;
+    //设置给谁
+    private String settingFor;
+    //状态
+    private Byte   status;
+    //备注
+    private String describe;
+
+    private List<AuthorizationSettingMenuEntity> menus;
+
+    private List<AuthorizationSettingDetailEntity> details;
+
+    @Override
+    public List<AuthorizationSettingDetailEntity> getDetails() {
+        return details;
+    }
+
+    @Override
+    public void setDetails(List<AuthorizationSettingDetailEntity> details) {
+        this.details = details;
+    }
+
+    @Override
+    public List<AuthorizationSettingMenuEntity> getMenus() {
+        return menus;
+    }
+
+    @Override
+    public void setMenus(List<AuthorizationSettingMenuEntity> menus) {
+        this.menus = menus;
+    }
+
+    /**
+     * @return 类型
+     */
+    public String getType() {
+        return this.type;
+    }
+
+    /**
+     * 设置 类型
+     */
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    /**
+     * @return 设置给谁
+     */
+    public String getSettingFor() {
+        return this.settingFor;
+    }
+
+    /**
+     * 设置 设置给谁
+     */
+    public void setSettingFor(String settingFor) {
+        this.settingFor = settingFor;
+    }
+
+    /**
+     * @return 状态
+     */
+    public Byte getStatus() {
+        return this.status;
+    }
+
+    /**
+     * 设置 状态
+     */
+    public void setStatus(Byte status) {
+        this.status = status;
+    }
+
+    /**
+     * @return 备注
+     */
+    public String getDescribe() {
+        return this.describe;
+    }
+
+    /**
+     * 设置 备注
+     */
+    public void setDescribe(String describe) {
+        this.describe = describe;
+    }
+}

+ 106 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java

@@ -0,0 +1,106 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
+
+import java.util.List;
+
+/**
+ * 权限菜单
+ *
+ * @author hsweb-generator-online
+ */
+public class SimpleAuthorizationSettingMenuEntity extends SimpleTreeSortSupportEntity<String> implements AuthorizationSettingMenuEntity {
+    //菜单id
+    private String menuId;
+    //设置id
+    private String settingId;
+    //状态
+    private Byte   status;
+    //其他配置内容
+    private String config;
+
+    private List<AuthorizationSettingMenuEntity> children;
+
+    /**
+     * @return 菜单id
+     */
+    public String getMenuId() {
+        return this.menuId;
+    }
+
+    /**
+     * 设置 菜单id
+     */
+    public void setMenuId(String menuId) {
+        this.menuId = menuId;
+    }
+
+    /**
+     * @return 设置id
+     */
+    public String getSettingId() {
+        return this.settingId;
+    }
+
+    /**
+     * 设置 设置id
+     */
+    public void setSettingId(String settingId) {
+        this.settingId = settingId;
+    }
+
+
+    /**
+     * @return 状态
+     */
+    public Byte getStatus() {
+        return this.status;
+    }
+
+    /**
+     * 设置 状态
+     */
+    public void setStatus(Byte status) {
+        this.status = status;
+    }
+
+    /**
+     * @return 其他配置内容
+     */
+    public String getConfig() {
+        return this.config;
+    }
+
+    /**
+     * 设置 其他配置内容
+     */
+    public void setConfig(String config) {
+        this.config = config;
+    }
+
+    @Override
+    public List<AuthorizationSettingMenuEntity> getChildren() {
+        return children;
+    }
+
+    @Override
+    public void setChildren(List<AuthorizationSettingMenuEntity> chidren) {
+        this.children = children;
+    }
+}

+ 11 - 11
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuEntity.java

@@ -16,7 +16,7 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
 
 
@@ -25,10 +25,12 @@ import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
- * TODO 完成注释
+ * 菜单实体
  *
  *
  * @author zhouhao
  * @author zhouhao
+ * @since 3.0
  */
  */
+@SuppressWarnings("unchecked")
 public class SimpleMenuEntity extends SimpleTreeSortSupportEntity<String>
 public class SimpleMenuEntity extends SimpleTreeSortSupportEntity<String>
         implements MenuEntity {
         implements MenuEntity {
 
 
@@ -47,22 +49,20 @@ public class SimpleMenuEntity extends SimpleTreeSortSupportEntity<String>
     //图标
     //图标
     private String icon;
     private String icon;
 
 
-    //是否启用
-    private Boolean enabled;
+    //状态
+    private Byte status;
 
 
     //子菜单
     //子菜单
     private List<SimpleMenuEntity> children;
     private List<SimpleMenuEntity> children;
 
 
     @Override
     @Override
-    @SuppressWarnings("unchecked")
     public List<SimpleMenuEntity> getChildren() {
     public List<SimpleMenuEntity> getChildren() {
         if (children == null) return null;
         if (children == null) return null;
         return new ArrayList<>(children);
         return new ArrayList<>(children);
     }
     }
 
 
     @Override
     @Override
-    public void setChildren(List<MenuEntity> children) {
-        // TODO: 17-4-6 有待优化
+    public void setChildren(List<? extends MenuEntity> children) {
         this.children = ((List) children);
         this.children = ((List) children);
     }
     }
 
 
@@ -106,12 +106,12 @@ public class SimpleMenuEntity extends SimpleTreeSortSupportEntity<String>
         this.icon = icon;
         this.icon = icon;
     }
     }
 
 
-    public Boolean isEnabled() {
-        return enabled;
+    public Byte getStatus() {
+        return status;
     }
     }
 
 
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
+    public void setStatus(Byte status) {
+        this.status = status;
     }
     }
 
 
     @Override
     @Override

+ 12 - 51
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupBindEntity.java

@@ -14,10 +14,9 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
-import org.hswebframework.web.entity.authorization.DataAccessEntity;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
@@ -28,31 +27,21 @@ import java.util.List;
  * @author hsweb-generator-online
  * @author hsweb-generator-online
  */
  */
 public class SimpleMenuGroupBindEntity extends SimpleTreeSortSupportEntity<String> implements MenuGroupBindEntity {
 public class SimpleMenuGroupBindEntity extends SimpleTreeSortSupportEntity<String> implements MenuGroupBindEntity {
-    //是否启用
-    private Boolean                           enabled;
+    //状态
+    private Byte                      status;
     //菜单id
     //菜单id
-    private String                            menuId;
+    private String                    menuId;
     //分组id
     //分组id
-    private String                            groupId;
-    //可选按钮
-    private java.util.List<String>            actions;
-    //行级权限控制配置
-    private java.util.List<DataAccessEntity>  dataAccesses;
+    private String                    groupId;
     //子节点
     //子节点
-    private List<SimpleMenuGroupBindEntity>   children;
+    private List<MenuGroupBindEntity> children;
 
 
-    /**
-     * @return 是否启用
-     */
-    public Boolean isEnabled() {
-        return this.enabled;
+    public Byte getStatus() {
+        return status;
     }
     }
 
 
-    /**
-     * 设置 是否启用
-     */
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
+    public void setStatus(Byte status) {
+        this.status = status;
     }
     }
 
 
     /**
     /**
@@ -83,41 +72,13 @@ public class SimpleMenuGroupBindEntity extends SimpleTreeSortSupportEntity<Strin
         this.groupId = groupId;
         this.groupId = groupId;
     }
     }
 
 
-    /**
-     * @return 可选按钮
-     */
-    public java.util.List<String> getActions() {
-        return this.actions;
-    }
-
-    /**
-     * 设置 可选按钮
-     */
-    public void setActions(java.util.List<String> actions) {
-        this.actions = actions;
-    }
-
-    /**
-     * @return 行级权限控制配置
-     */
-    public java.util.List<DataAccessEntity> getDataAccesses() {
-        return this.dataAccesses;
-    }
-
-    /**
-     * 设置 行级权限控制配置
-     */
-    public void setDataAccesses(java.util.List<DataAccessEntity> dataAccesses) {
-        this.dataAccesses = dataAccesses;
-    }
-
 
 
-    public List<SimpleMenuGroupBindEntity> getChildren() {
+    public List<MenuGroupBindEntity> getChildren() {
         return children;
         return children;
     }
     }
 
 
     @Override
     @Override
     public void setChildren(List<MenuGroupBindEntity> children) {
     public void setChildren(List<MenuGroupBindEntity> children) {
-        this.children = new ArrayList(children);
+        this.children = children;
     }
     }
 }
 }

+ 7 - 14
hsweb-system/hsweb-system-menu/hsweb-system-menu-entity/src/main/java/org/hswebframework/web/entity/menu/SimpleMenuGroupEntity.java

@@ -14,7 +14,7 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.entity.menu;
+package org.hswebframework.web.entity.authorization;
 
 
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
 import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
 
 
@@ -34,8 +34,8 @@ public class SimpleMenuGroupEntity extends SimpleTreeSortSupportEntity<String> i
     private String  describe;
     private String  describe;
     //是否默认
     //是否默认
     private Boolean defaultGroup;
     private Boolean defaultGroup;
-    //是否启用
-    private Boolean enabled;
+    //状态
+    private Byte    status;
 
 
     private List<SimpleMenuGroupEntity> children;
     private List<SimpleMenuGroupEntity> children;
 
 
@@ -101,21 +101,14 @@ public class SimpleMenuGroupEntity extends SimpleTreeSortSupportEntity<String> i
 
 
     @Override
     @Override
     public void setBindInfo(List<MenuGroupBindEntity> bindInfo) {
     public void setBindInfo(List<MenuGroupBindEntity> bindInfo) {
-        // TODO: 17-4-5 可优化?
         this.bindInfo = new LinkedList(bindInfo);
         this.bindInfo = new LinkedList(bindInfo);
     }
     }
 
 
-    /**
-     * @return 是否启用
-     */
-    public Boolean isEnabled() {
-        return this.enabled;
+    public Byte getStatus() {
+        return status;
     }
     }
 
 
-    /**
-     * 设置 是否启用
-     */
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
+    public void setStatus(Byte status) {
+        this.status = status;
     }
     }
 }
 }

+ 5 - 12
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java

@@ -12,7 +12,7 @@ public class SimpleRoleEntity extends SimpleGenericEntity<String> implements Rol
 
 
     private String describe;
     private String describe;
 
 
-    private Boolean enabled;
+    private Byte status;
 
 
     public String getName() {
     public String getName() {
         return name;
         return name;
@@ -30,24 +30,17 @@ public class SimpleRoleEntity extends SimpleGenericEntity<String> implements Rol
         this.describe = describe;
         this.describe = describe;
     }
     }
 
 
-    @Override
-    public Boolean isEnabled() {
-        return enabled;
+    public Byte getStatus() {
+        return status;
     }
     }
 
 
-    @Override
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
+    public void setStatus(Byte status) {
+        this.status = status;
     }
     }
 
 
     @Override
     @Override
     public SimpleRoleEntity clone() {
     public SimpleRoleEntity clone() {
         SimpleRoleEntity target = ((SimpleRoleEntity) super.clone());
         SimpleRoleEntity target = ((SimpleRoleEntity) super.clone());
-//        target.setId(getId());
-//        target.setName(getName());
-//        target.setDescribe(getDescribe());
-//        target.setProperties(cloneProperties());
-//        target.setEnabled(isEnabled());
         return target;
         return target;
     }
     }
 }
 }

+ 5 - 7
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java

@@ -20,7 +20,7 @@ public class SimpleUserEntity extends SimpleGenericEntity<String> implements Use
 
 
     private String creatorId;
     private String creatorId;
 
 
-    private Boolean enabled;
+    private Byte status;
 
 
     @Override
     @Override
     public String getName() {
     public String getName() {
@@ -78,14 +78,12 @@ public class SimpleUserEntity extends SimpleGenericEntity<String> implements Use
         this.creatorId = creatorId;
         this.creatorId = creatorId;
     }
     }
 
 
-    @Override
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
+    public Byte getStatus() {
+        return status;
     }
     }
 
 
-    @Override
-    public Boolean isEnabled() {
-        return enabled;
+    public void setStatus(Byte status) {
+        this.status = status;
     }
     }
 
 
     @Override
     @Override

+ 7 - 3
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java

@@ -32,7 +32,7 @@ public interface UserEntity extends GenericEntity<String>, RecordCreationEntity
     String salt     = "salt";
     String salt     = "salt";
     @SuppressWarnings("unchecked")
     @SuppressWarnings("unchecked")
     String password = "password";
     String password = "password";
-    String enabled = "enabled";
+    String status = "status";
 
 
     void setName(String name);
     void setName(String name);
 
 
@@ -50,9 +50,13 @@ public interface UserEntity extends GenericEntity<String>, RecordCreationEntity
 
 
     String getSalt();
     String getSalt();
 
 
-    Boolean isEnabled();
+    /**
+     * @return 数据状态
+     * @see org.hswebframework.web.commons.entity.DataStatus
+     */
+    Byte getStatus();
 
 
-    void setEnabled(Boolean enabled);
+    void setStatus(Byte status);
 
 
     @Override
     @Override
     UserEntity clone();
     UserEntity clone();

+ 89 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java

@@ -0,0 +1,89 @@
+package org.hswebframework.web.entity.authorization;
+
+import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity;
+
+import java.util.List;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public class UserMenuEntity extends SimpleTreeSortSupportEntity<String> {
+
+    private String menuId;
+
+    //菜单名称
+    private String name;
+
+    //备注
+    private String describe;
+
+    //权限ID
+    private String permissionId;
+
+    //菜单对应的url
+    private String url;
+
+    //图标
+    private String icon;
+
+    private List<UserMenuEntity> children;
+
+    public String getMenuId() {
+        return menuId;
+    }
+
+    public void setMenuId(String menuId) {
+        this.menuId = menuId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescribe() {
+        return describe;
+    }
+
+    public void setDescribe(String describe) {
+        this.describe = describe;
+    }
+
+    public String getPermissionId() {
+        return permissionId;
+    }
+
+    public void setPermissionId(String permissionId) {
+        this.permissionId = permissionId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    @Override
+    public List<UserMenuEntity> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<UserMenuEntity> children) {
+        this.children = children;
+    }
+}

+ 23 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java

@@ -0,0 +1,23 @@
+package org.hswebframework.web.service.authorization;
+
+import org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity;
+import org.hswebframework.web.service.CrudService;
+import org.hswebframework.web.service.TreeService;
+
+import java.util.List;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public interface AuthorizationSettingMenuService extends
+        CrudService<AuthorizationSettingMenuEntity, String>
+        , TreeService<AuthorizationSettingMenuEntity, String> {
+
+    int deleteBySettingId(String settingId);
+
+    List<AuthorizationSettingMenuEntity> selectBySettingId(String settingId);
+
+    List<AuthorizationSettingMenuEntity> selectBySettingId(List<String> settingId);
+}

+ 29 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java

@@ -0,0 +1,29 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.service.authorization;
+
+import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity;
+import org.hswebframework.web.service.CrudService;
+
+/**
+ *  权限设置 服务类
+ *
+ * @author hsweb-generator-online
+ */
+public interface AuthorizationSettingService extends CrudService<AuthorizationSettingEntity, String> {
+    AuthorizationSettingEntity select(String type, String settingFor);
+}

+ 62 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java

@@ -0,0 +1,62 @@
+package org.hswebframework.web.service.authorization;
+
+
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * 权限设置类型提供者,在初始化权限信息的时候,用于获取被授权用户持有的设置类型.
+ *
+ * @author zhouhao
+ * @since 3.0
+ */
+public interface AuthorizationSettingTypeSupplier {
+
+    String SETTING_TYPE_ROLE = "role";
+    String SETTING_TYPE_USER = "user";
+
+    /**
+     * @param userId 用户ID
+     * @return 用户的设置信息
+     */
+    Set<SettingInfo> get(String userId);
+
+    class SettingInfo {
+
+        //设置类型 如: user,role,position,person等等
+        private String type;
+        //type对应的主键信息,如 user.id
+        private String settingFor;
+
+        @Override
+        public int hashCode() {
+            return String.valueOf(type).concat(settingFor).hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            return obj instanceof SettingInfo && hashCode() == obj.hashCode();
+        }
+
+        public SettingInfo(String type, String settingFor) {
+            this.type = Objects.requireNonNull(type);
+            this.settingFor = Objects.requireNonNull(settingFor);
+        }
+
+        public String getType() {
+            return type;
+        }
+
+        public void setType(String type) {
+            this.type = type;
+        }
+
+        public String getSettingFor() {
+            return settingFor;
+        }
+
+        public void setSettingFor(String settingFor) {
+            this.settingFor = settingFor;
+        }
+    }
+}

+ 2 - 2
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupBindService.java

@@ -14,9 +14,9 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.service.menu;
+package org.hswebframework.web.service.authorization;
 
 
-import org.hswebframework.web.entity.menu.MenuGroupBindEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupBindEntity;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.TreeService;
 import org.hswebframework.web.service.TreeService;
 
 

+ 3 - 4
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuGroupService.java

@@ -14,11 +14,10 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.service.menu;
+package org.hswebframework.web.service.authorization;
 
 
-import org.hswebframework.web.entity.menu.MenuEntity;
-import org.hswebframework.web.entity.menu.MenuGroupBindEntity;
-import org.hswebframework.web.entity.menu.MenuGroupEntity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupEntity;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.TreeService;
 import org.hswebframework.web.service.TreeService;
 
 

+ 3 - 2
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-api/src/main/java/org/hswebframework/web/service/menu/MenuService.java

@@ -16,10 +16,10 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.service.menu;
+package org.hswebframework.web.service.authorization;
 
 
 
 
-import org.hswebframework.web.entity.menu.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.CrudService;
 import org.hswebframework.web.service.TreeService;
 import org.hswebframework.web.service.TreeService;
 
 
@@ -36,4 +36,5 @@ public interface MenuService
     MenuEntity getByPermissionId(String permissionId);
     MenuEntity getByPermissionId(String permissionId);
 
 
     List<MenuEntity> getByPermissionId(List<String> permissionId);
     List<MenuEntity> getByPermissionId(List<String> permissionId);
+
 }
 }

+ 77 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/PermissionSettingDTO.java

@@ -0,0 +1,77 @@
+package org.hswebframework.web.service.authorization;
+
+import org.hswebframework.web.commons.entity.Entity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupEntity;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public class PermissionSettingDTO implements Entity {
+    //配置类型,如 role,user,position,person等
+    private String type;
+
+    //配置给谁,为type对应数据的主键
+    private String settingFor;
+
+    private String describe;
+
+    private List<PermissionSettingDetailDTO> details;
+
+    private Set<MenuEntity> menus;
+
+    private Set<MenuGroupEntity> menuGroups;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getSettingFor() {
+        return settingFor;
+    }
+
+    public void setSettingFor(String settingFor) {
+        this.settingFor = settingFor;
+    }
+
+    public String getDescribe() {
+        return describe;
+    }
+
+    public void setDescribe(String describe) {
+        this.describe = describe;
+    }
+
+    public List<PermissionSettingDetailDTO> getDetails() {
+        return details;
+    }
+
+    public void setDetails(List<PermissionSettingDetailDTO> details) {
+        this.details = details;
+    }
+
+    public Set<MenuEntity> getMenus() {
+        return menus;
+    }
+
+    public void setMenus(Set<MenuEntity> menus) {
+        this.menus = menus;
+    }
+
+    public Set<MenuGroupEntity> getMenuGroups() {
+        return menuGroups;
+    }
+
+    public void setMenuGroups(Set<MenuGroupEntity> menuGroups) {
+        this.menuGroups = menuGroups;
+    }
+}

+ 44 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/PermissionSettingDetailDTO.java

@@ -0,0 +1,44 @@
+package org.hswebframework.web.service.authorization;
+
+import org.hswebframework.web.commons.entity.Entity;
+import org.hswebframework.web.entity.authorization.DataAccessEntity;
+
+import java.util.Set;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public class PermissionSettingDetailDTO implements Entity {
+    private String permissionId;
+
+    private Set<String> actions;
+
+    private Set<DataAccessEntity> dataAccesses;
+
+    public String getPermissionId() {
+        return permissionId;
+    }
+
+    public void setPermissionId(String permissionId) {
+        this.permissionId = permissionId;
+    }
+
+    public Set<String> getActions() {
+        return actions;
+    }
+
+    public void setActions(Set<String> actions) {
+        this.actions = actions;
+    }
+
+    public Set<DataAccessEntity> getDataAccesses() {
+        return dataAccesses;
+    }
+
+    public void setDataAccesses(Set<DataAccessEntity> dataAccesses) {
+        this.dataAccesses = dataAccesses;
+    }
+
+}

+ 17 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java

@@ -0,0 +1,17 @@
+package org.hswebframework.web.service.authorization;
+
+import org.hswebframework.web.entity.authorization.UserMenuEntity;
+
+import java.util.List;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public interface UserMenuManagerService {
+    List<UserMenuEntity> getUserMenuAsList(String userId);
+
+    List<UserMenuEntity> getUserMenuAsTree(String userId);
+
+}

+ 6 - 5
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java

@@ -1,21 +1,20 @@
 package org.hswebframework.web.service.authorization;
 package org.hswebframework.web.service.authorization;
 
 
-import org.hswebframework.web.authorization.AuthenticationInitializeService;
-import org.hswebframework.web.authorization.AuthenticationManager;
+import org.hswebframework.web.entity.authorization.RoleEntity;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.service.CreateEntityService;
 import org.hswebframework.web.service.CreateEntityService;
 import org.hswebframework.web.service.InsertService;
 import org.hswebframework.web.service.InsertService;
 import org.hswebframework.web.service.QueryByEntityService;
 import org.hswebframework.web.service.QueryByEntityService;
 import org.hswebframework.web.service.QueryService;
 import org.hswebframework.web.service.QueryService;
 
 
+import java.util.List;
+
 /**
 /**
  * TODO 完成注释
  * TODO 完成注释
  *
  *
  * @author zhouhao
  * @author zhouhao
  */
  */
 public interface UserService extends
 public interface UserService extends
-        AuthenticationManager,
-        AuthenticationInitializeService,
         CreateEntityService<UserEntity>,
         CreateEntityService<UserEntity>,
         QueryByEntityService<UserEntity>,
         QueryByEntityService<UserEntity>,
         QueryService<UserEntity, String>,
         QueryService<UserEntity, String>,
@@ -25,11 +24,13 @@ public interface UserService extends
 
 
     boolean disable(String userId);
     boolean disable(String userId);
 
 
-    void update(String userId,UserEntity userBean);
+    void update(String userId, UserEntity userBean);
 
 
     UserEntity selectByUsername(String username);
     UserEntity selectByUsername(String username);
 
 
     String encodePassword(String password, String salt);
     String encodePassword(String password, String salt);
 
 
     void updatePassword(String userId, String oldPassword, String newPassword);
     void updatePassword(String userId, String oldPassword, String newPassword);
+
+    List<RoleEntity> getUserRole(String userId);
 }
 }

+ 1 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java

@@ -24,6 +24,7 @@ package org.hswebframework.web.service.authorization.simple;
  * @author zhouhao
  * @author zhouhao
  */
  */
 public interface CacheConstants {
 public interface CacheConstants {
+    String MENU_CACHE_NAME = "hsweb-menu-";
 
 
     String USER_CACHE_NAME = "user-";
     String USER_CACHE_NAME = "user-";
 
 

+ 44 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java

@@ -0,0 +1,44 @@
+package org.hswebframework.web.service.authorization.simple;
+
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.authorization.AuthenticationInitializeService;
+import org.hswebframework.web.authorization.AuthenticationManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+
+import static org.hswebframework.web.service.authorization.simple.CacheConstants.USER_AUTH_CACHE_NAME;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+public class SimpleAuthenticationManager implements AuthenticationManager {
+
+    private AuthenticationInitializeService authenticationInitializeService;
+
+    public SimpleAuthenticationManager() {
+    }
+
+    public SimpleAuthenticationManager(AuthenticationInitializeService authenticationInitializeService) {
+        this.authenticationInitializeService = authenticationInitializeService;
+    }
+
+    @Autowired
+    public void setAuthenticationInitializeService(AuthenticationInitializeService authenticationInitializeService) {
+        this.authenticationInitializeService = authenticationInitializeService;
+    }
+
+    @Override
+    @Cacheable(value = USER_AUTH_CACHE_NAME, key = "#userId")
+    public Authentication getByUserId(String userId) {
+        return authenticationInitializeService.initUserAuthorization(userId);
+    }
+
+    @Override
+    @CachePut(value = USER_AUTH_CACHE_NAME, key = "#authentication.user.id")
+    public Authentication sync(Authentication authentication) {
+        return authentication;
+    }
+}

+ 59 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java

@@ -0,0 +1,59 @@
+package org.hswebframework.web.service.authorization.simple;
+
+import org.hswebframework.web.dao.CrudDao;
+import org.hswebframework.web.dao.authorization.AuthorizationSettingMenuDao;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity;
+import org.hswebframework.web.entity.authorization.MenuEntity;
+import org.hswebframework.web.id.IDGenerator;
+import org.hswebframework.web.service.AbstractTreeSortService;
+import org.hswebframework.web.service.authorization.AuthorizationSettingMenuService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * TODO 完成注释
+ *
+ * @author zhouhao
+ */
+@Service("authorizationSettingMenuService")
+public class SimpleAuthorizationSettingMenuService extends AbstractTreeSortService<AuthorizationSettingMenuEntity, String>
+        implements AuthorizationSettingMenuService {
+
+    private AuthorizationSettingMenuDao authorizationSettingMenuDao;
+
+    @Override
+    public int deleteBySettingId(String settingId) {
+        Objects.requireNonNull(settingId);
+        return createDelete().where(AuthorizationSettingMenuEntity.settingId, settingId).exec();
+    }
+
+    @Override
+    public List<AuthorizationSettingMenuEntity> selectBySettingId(String settingId) {
+        Objects.requireNonNull(settingId);
+        return createQuery().where(AuthorizationSettingMenuEntity.settingId, settingId).listNoPaging();
+    }
+
+    @Override
+    public List<AuthorizationSettingMenuEntity> selectBySettingId(List<String> settingId) {
+        Objects.requireNonNull(settingId);
+        return createQuery().where().in(AuthorizationSettingMenuEntity.settingId, settingId).listNoPaging();
+    }
+
+    @Override
+    protected IDGenerator<String> getIDGenerator() {
+        return IDGenerator.MD5;
+    }
+
+    @Override
+    public AuthorizationSettingMenuDao getDao() {
+        return authorizationSettingMenuDao;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingMenuDao(AuthorizationSettingMenuDao authorizationSettingMenuDao) {
+        this.authorizationSettingMenuDao = authorizationSettingMenuDao;
+    }
+}

+ 327 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java

@@ -0,0 +1,327 @@
+/*
+ *  Copyright 2016 http://www.hswebframework.org
+ *  
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  
+ */
+package org.hswebframework.web.service.authorization.simple;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.authorization.AuthenticationInitializeService;
+import org.hswebframework.web.authorization.Permission;
+import org.hswebframework.web.authorization.access.DataAccessConfig;
+import org.hswebframework.web.authorization.simple.SimpleAuthentication;
+import org.hswebframework.web.authorization.simple.SimplePermission;
+import org.hswebframework.web.authorization.simple.SimpleRole;
+import org.hswebframework.web.authorization.simple.SimpleUser;
+import org.hswebframework.web.commons.entity.DataStatus;
+import org.hswebframework.web.commons.entity.TreeSupportEntity;
+import org.hswebframework.web.dao.authorization.AuthorizationSettingDao;
+import org.hswebframework.web.dao.authorization.AuthorizationSettingDetailDao;
+import org.hswebframework.web.entity.authorization.*;
+import org.hswebframework.web.id.IDGenerator;
+import org.hswebframework.web.service.DefaultDSLDeleteService;
+import org.hswebframework.web.service.DefaultDSLQueryService;
+import org.hswebframework.web.service.GenericEntityService;
+import org.hswebframework.web.service.authorization.*;
+import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier.SettingInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hswebframework.web.entity.authorization.AuthorizationSettingDetailEntity.STATE_OK;
+import static org.hswebframework.web.entity.authorization.AuthorizationSettingEntity.settingFor;
+import static org.hswebframework.web.entity.authorization.AuthorizationSettingEntity.type;
+import static org.hswebframework.web.service.authorization.simple.CacheConstants.USER_AUTH_CACHE_NAME;
+
+/**
+ * 默认的服务实现
+ *
+ * @author hsweb-generator-online
+ */
+@Service("authorizationSettingService")
+@CacheConfig(cacheNames = USER_AUTH_CACHE_NAME)
+public class SimpleAuthorizationSettingService extends GenericEntityService<AuthorizationSettingEntity, String>
+        implements AuthorizationSettingService, AuthenticationInitializeService, UserMenuManagerService {
+
+    private AuthorizationSettingDao authorizationSettingDao;
+
+    private AuthorizationSettingDetailDao authorizationSettingDetailDao;
+
+    private AuthorizationSettingMenuService authorizationSettingMenuService;
+
+    private MenuService menuService;
+
+    private UserService userService;
+
+    private List<AuthorizationSettingTypeSupplier> authorizationSettingTypeSuppliers;
+
+    private DataAccessFactory dataAccessFactory;
+
+    @Override
+    protected IDGenerator<String> getIDGenerator() {
+        return IDGenerator.MD5;
+    }
+
+    @Override
+    public AuthorizationSettingDao getDao() {
+        return authorizationSettingDao;
+    }
+
+    @Override
+    public AuthorizationSettingEntity select(String type, String settingFor) {
+        return createQuery().where(AuthorizationSettingEntity.type, type)
+                .and(AuthorizationSettingEntity.settingFor, settingFor)
+                .single();
+    }
+
+    @Override
+    @CacheEvict(allEntries = true)
+    public String insert(AuthorizationSettingEntity entity) {
+        entity.setStatus(DataStatus.STATUS_ENABLED);
+        String id = super.insert(entity);
+        if (entity.getMenus() != null) {
+            TreeSupportEntity.forEach(entity.getMenus(), menu -> {
+                menu.setStatus(DataStatus.STATUS_ENABLED);
+                menu.setSettingId(id);
+            });
+            authorizationSettingMenuService.insertBatch(entity.getMenus());
+        }
+        if (entity.getDetails() != null) {
+            for (AuthorizationSettingDetailEntity detail : entity.getDetails()) {
+                tryValidate(detail);
+                detail.setId(getIDGenerator().generate());
+                detail.setSettingId(id);
+                detail.setStatus(DataStatus.STATUS_ENABLED);
+                authorizationSettingDetailDao.insert(detail);
+            }
+        }
+        return id;
+    }
+
+    @Override
+    @CacheEvict(allEntries = true)
+    public int updateByPk(String id, AuthorizationSettingEntity entity) {
+        int size = super.updateByPk(id, entity);
+        if (entity.getMenus() != null) {
+            authorizationSettingMenuService.deleteBySettingId(id);
+            TreeSupportEntity.forEach(entity.getMenus(), menu -> {
+                menu.setStatus(DataStatus.STATUS_ENABLED);
+                menu.setSettingId(id);
+            });
+            authorizationSettingMenuService.insertBatch(entity.getMenus());
+        }
+        if (entity.getDetails() != null) {
+            DefaultDSLDeleteService
+                    .createDelete(authorizationSettingDetailDao)
+                    .where(AuthorizationSettingDetailEntity.settingId, id)
+                    .exec();
+            for (AuthorizationSettingDetailEntity detail : entity.getDetails()) {
+                detail.setSettingId(id);
+                detail.setStatus(DataStatus.STATUS_ENABLED);
+                authorizationSettingDetailDao.insert(detail);
+            }
+        }
+        return size;
+    }
+
+    @Override
+    @CacheEvict(allEntries = true)
+    public int deleteByPk(String id) {
+        authorizationSettingMenuService.deleteBySettingId(id);
+        return super.deleteByPk(id);
+    }
+
+    private List<AuthorizationSettingEntity> getUserSetting(String userId) {
+        Map<String, List<SettingInfo>> settingInfo =
+                authorizationSettingTypeSuppliers.stream()
+                        .map(supplier -> supplier.get(userId))
+                        .flatMap(Set::stream)
+                        .collect(Collectors.groupingBy(SettingInfo::getType));
+        Stream<Map.Entry<String, List<SettingInfo>>> settingInfoStream = settingInfo.entrySet().stream();
+        //大于1 使用并行处理
+        if (settingInfo.size() > 1)
+            settingInfoStream.parallel();
+        return settingInfoStream
+                .map(entry ->
+                        createQuery()
+                                // where type = ? and setting_for in (?,?,?....)
+                                .where(type, entry.getKey())
+                                .and()
+                                .in(settingFor, entry.getValue().stream().map(SettingInfo::getSettingFor).collect(Collectors.toList()))
+                                .list())
+                .flatMap(List::stream)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    @Cacheable(key = "'user-menu-list:'+#userId")
+    public List<UserMenuEntity> getUserMenuAsList(String userId) {
+        if (null == userId) return null;
+        UserEntity userEntity = userService.selectByPk(userId);
+        if (userEntity == null) return null;
+        List<AuthorizationSettingEntity> entities = getUserSetting(userId);
+        //用户持有的权限设置id集合
+        List<String> settingIdList = entities.stream()
+                .map(AuthorizationSettingEntity::getId)
+                .collect(Collectors.toList());
+        //获取全部设置的菜单
+        List<AuthorizationSettingMenuEntity> menuEntities = authorizationSettingMenuService
+                .selectBySettingId(settingIdList);
+        //得到菜单id
+        List<String> menuIdList = menuEntities.stream()
+                .map(AuthorizationSettingMenuEntity::getMenuId)
+                .distinct()
+                .collect(Collectors.toList());
+        //获取全部菜单,并创建缓存备用
+        Map<String, MenuEntity> menuCache = menuService
+                .selectByPk(menuIdList)
+                .stream()
+                .collect(Collectors.toMap(MenuEntity::getId, Function.identity()));
+        //根据配置,重新构造菜单结构
+        List<UserMenuEntity> reBuildMenu = new LinkedList<>();
+        for (AuthorizationSettingMenuEntity entity : menuEntities) {
+            MenuEntity cache = menuCache.get(entity.getId());
+            if (null != cache && cache.getStatus() == 1) {
+                UserMenuEntity menu = entityFactory.newInstance(UserMenuEntity.class, cache);
+                menu.setSortIndex(entity.getSortIndex());
+                menu.setLevel(entity.getLevel());
+                menu.setId(entity.getId());
+                menu.setParentId(entity.getParentId());
+                menu.setMenuId(cache.getId());
+                reBuildMenu.add(menu);
+            }
+        }
+        return reBuildMenu;
+    }
+
+    @Override
+    @Cacheable(key = "'menu-tree:'+#userId")
+    public List<UserMenuEntity> getUserMenuAsTree(String userId) {
+        return TreeSupportEntity.list2tree(getUserMenuAsList(userId), UserMenuEntity::setChildren,
+                (Predicate<UserMenuEntity>) menuEntity ->
+                        // parentId为空或者为-1的菜单则认为是根菜单
+                        menuEntity.getParentId() == null || "-1".equals(menuEntity.getParentId()));
+    }
+
+    @Override
+    public Authentication initUserAuthorization(String userId) {
+        if (null == userId) return null;
+        UserEntity userEntity = userService.selectByPk(userId);
+        if (userEntity == null) return null;
+        SimpleAuthentication authentication = new SimpleAuthentication();
+        // 用户信息
+        authentication.setUser(new SimpleUser(userId, userEntity.getUsername(), userEntity.getName()));
+        //角色
+        authentication.setRoles(userService.getUserRole(userId)
+                .stream().map(role -> new SimpleRole(role.getId(), role.getName()))
+                .collect(Collectors.toList()));
+
+        List<String> settingIdList = getUserSetting(userId).stream()
+                .map(AuthorizationSettingEntity::getId)
+                .collect(Collectors.toList());
+
+        if (settingIdList.isEmpty()) {
+            authentication.setPermissions(new ArrayList<>());
+            return authentication;
+        }
+
+        // where status=1 and setting_id in (?,?,?)
+        List<AuthorizationSettingDetailEntity> detailList = DefaultDSLQueryService
+                .createQuery(authorizationSettingDetailDao)
+                .where(AuthorizationSettingDetailEntity.state, STATE_OK)
+                .and().in(AuthorizationSettingDetailEntity.settingId, settingIdList)
+                .list();
+        //权限
+        Map<String, List<AuthorizationSettingDetailEntity>> settings = detailList
+                .stream()
+                .collect(Collectors.groupingBy(AuthorizationSettingDetailEntity::getPermissionId));
+        List<Permission> permissions = new ArrayList<>();
+        settings.forEach((permissionId, details) -> {
+            SimplePermission permission = new SimplePermission();
+            permission.setId(permissionId);
+            Set<String> actions = new HashSet<>();
+            Set<DataAccessConfig> dataAccessConfigs = new HashSet<>();
+            //排序,根据优先级进行排序
+            Collections.sort(details);
+            for (AuthorizationSettingDetailEntity detail : details) {
+                //如果指定不合并相同的配置,则清空之前的配置
+                if (!Boolean.TRUE.equals(detail.isMerge())) {
+                    actions.clear();
+                    dataAccessConfigs.clear();
+                }
+                // actions
+                if (null != detail.getActions()) {
+                    actions.addAll(detail.getActions());
+                }
+                // 数据权限控制配置
+                if (null != detail.getDataAccesses()) {
+                    dataAccessConfigs.addAll(detail.getDataAccesses()
+                            .stream()
+                            .map(dataAccessFactory::create)
+                            .collect(Collectors.toSet()));
+                }
+            }
+            permission.setActions(actions);
+            permission.setDataAccesses(dataAccessConfigs);
+            permissions.add(permission);
+        });
+        authentication.setPermissions(permissions);
+        return authentication;
+    }
+
+
+    @Autowired
+    public void setDataAccessFactory(DataAccessFactory dataAccessFactory) {
+        this.dataAccessFactory = dataAccessFactory;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingTypeSuppliers(List<AuthorizationSettingTypeSupplier> authorizationSettingTypeSuppliers) {
+        this.authorizationSettingTypeSuppliers = authorizationSettingTypeSuppliers;
+    }
+
+    @Autowired
+    public void setUserService(UserService userService) {
+        this.userService = userService;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingDao(AuthorizationSettingDao authorizationSettingDao) {
+        this.authorizationSettingDao = authorizationSettingDao;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingDetailDao(AuthorizationSettingDetailDao authorizationSettingDetailDao) {
+        this.authorizationSettingDetailDao = authorizationSettingDetailDao;
+    }
+
+    @Autowired
+    public void setAuthorizationSettingMenuService(AuthorizationSettingMenuService authorizationSettingMenuService) {
+        this.authorizationSettingMenuService = authorizationSettingMenuService;
+    }
+
+    @Autowired
+    public void setMenuService(MenuService menuService) {
+        this.menuService = menuService;
+    }
+}

+ 4 - 5
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupBindService.java

@@ -14,14 +14,13 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.service.menu.simple;
+package org.hswebframework.web.service.authorization.simple;
 
 
-import org.hswebframework.web.dao.menu.MenuGroupBindDao;
-import org.hswebframework.web.entity.menu.MenuGroupBindEntity;
+import org.hswebframework.web.dao.authorization.MenuGroupBindDao;
+import org.hswebframework.web.entity.authorization.MenuGroupBindEntity;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.service.AbstractTreeSortService;
 import org.hswebframework.web.service.AbstractTreeSortService;
-import org.hswebframework.web.service.GenericEntityService;
-import org.hswebframework.web.service.menu.MenuGroupBindService;
+import org.hswebframework.web.service.authorization.MenuGroupBindService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 

+ 13 - 80
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuGroupService.java

@@ -14,24 +14,19 @@
  *  limitations under the License.
  *  limitations under the License.
  *  
  *  
  */
  */
-package org.hswebframework.web.service.menu.simple;
+package org.hswebframework.web.service.authorization.simple;
 
 
 import org.hswebframework.web.commons.entity.TreeSupportEntity;
 import org.hswebframework.web.commons.entity.TreeSupportEntity;
-import org.hswebframework.web.dao.menu.MenuGroupDao;
-import org.hswebframework.web.entity.authorization.PermissionRoleEntity;
-import org.hswebframework.web.entity.authorization.UserEntity;
-import org.hswebframework.web.entity.authorization.bind.BindPermissionRoleEntity;
-import org.hswebframework.web.entity.menu.MenuEntity;
-import org.hswebframework.web.entity.menu.MenuGroupBindEntity;
-import org.hswebframework.web.entity.menu.MenuGroupEntity;
-import org.hswebframework.web.entity.menu.SimpleMenuGroupEntity;
+import org.hswebframework.web.dao.authorization.MenuGroupDao;
+import org.hswebframework.web.entity.authorization.MenuEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupBindEntity;
+import org.hswebframework.web.entity.authorization.MenuGroupEntity;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.service.AbstractTreeSortService;
 import org.hswebframework.web.service.AbstractTreeSortService;
 import org.hswebframework.web.service.DefaultDSLUpdateService;
 import org.hswebframework.web.service.DefaultDSLUpdateService;
-import org.hswebframework.web.service.authorization.RoleService;
-import org.hswebframework.web.service.menu.MenuGroupBindService;
-import org.hswebframework.web.service.menu.MenuGroupService;
-import org.hswebframework.web.service.menu.MenuService;
+import org.hswebframework.web.service.authorization.MenuGroupBindService;
+import org.hswebframework.web.service.authorization.MenuGroupService;
+import org.hswebframework.web.service.authorization.MenuService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CacheEvict;
@@ -39,14 +34,11 @@ import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
-import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.List;
-import java.util.function.Consumer;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
-import static org.hswebframework.web.service.menu.simple.CacheConstants.MENU_CACHE_NAME;
+import static org.hswebframework.web.service.authorization.simple.CacheConstants.MENU_CACHE_NAME;
 
 
 /**
 /**
  * 默认的服务实现
  * 默认的服务实现
@@ -61,9 +53,6 @@ public class SimpleMenuGroupService
     @Autowired
     @Autowired
     private MenuGroupDao menuGroupDao;
     private MenuGroupDao menuGroupDao;
 
 
-    @Autowired(required = false)
-    private RoleService roleService;
-
     @Autowired
     @Autowired
     private MenuService menuService;
     private MenuService menuService;
 
 
@@ -80,14 +69,6 @@ public class SimpleMenuGroupService
         return menuGroupDao;
         return menuGroupDao;
     }
     }
 
 
-    private boolean checkRoleServiceIsEnable() {
-        if (roleService == null) {
-            logger.warn("roleService为空,将不会自动同步角色信息!");
-            return false;
-        }
-        return true;
-    }
-
     @Cacheable(key = "'group-id-list:'+#groupId==null?0:#groupId.hashCode()")
     @Cacheable(key = "'group-id-list:'+#groupId==null?0:#groupId.hashCode()")
     public List<MenuEntity> getMenuByGroupId(List<String> groupId) {
     public List<MenuEntity> getMenuByGroupId(List<String> groupId) {
         List<MenuGroupBindEntity> bindEntities = menuGroupBindService.selectByPk(groupId);
         List<MenuGroupBindEntity> bindEntities = menuGroupBindService.selectByPk(groupId);
@@ -100,17 +81,16 @@ public class SimpleMenuGroupService
 
 
     @CacheEvict(allEntries = true)
     @CacheEvict(allEntries = true)
     public String insert(MenuGroupEntity entity) {
     public String insert(MenuGroupEntity entity) {
-        entity.setEnabled(true);
+        entity.setStatus((byte) 1);
         String id = super.insert(entity);
         String id = super.insert(entity);
         List<MenuGroupBindEntity> bindEntities = entity.getBindInfo();
         List<MenuGroupBindEntity> bindEntities = entity.getBindInfo();
         if (bindEntities != null && !bindEntities.isEmpty()) {
         if (bindEntities != null && !bindEntities.isEmpty()) {
             TreeSupportEntity.forEach(bindEntities, bindEntity -> {
             TreeSupportEntity.forEach(bindEntities, bindEntity -> {
                 bindEntity.setGroupId(id);
                 bindEntity.setGroupId(id);
-                bindEntity.setEnabled(true);
+                entity.setStatus((byte) 1);
             });
             });
             menuGroupBindService.insertBatch(bindEntities);
             menuGroupBindService.insertBatch(bindEntities);
         }
         }
-        trySyncRoleInfo(entity);
         return id;
         return id;
     }
     }
 
 
@@ -122,7 +102,6 @@ public class SimpleMenuGroupService
         if (bindEntities != null && !bindEntities.isEmpty()) {
         if (bindEntities != null && !bindEntities.isEmpty()) {
             TreeSupportEntity.forEach(bindEntities, bindEntity -> {
             TreeSupportEntity.forEach(bindEntities, bindEntity -> {
                 bindEntity.setGroupId(entity.getId());
                 bindEntity.setGroupId(entity.getId());
-                bindEntity.setEnabled(true);
             });
             });
             menuGroupBindService.deleteByGroupId(entity.getId());
             menuGroupBindService.deleteByGroupId(entity.getId());
             menuGroupBindService.insertBatch(bindEntities);
             menuGroupBindService.insertBatch(bindEntities);
@@ -148,23 +127,14 @@ public class SimpleMenuGroupService
         return super.deleteByPk(id);
         return super.deleteByPk(id);
     }
     }
 
 
-    @Override
-    public String saveOrUpdateForSingle(MenuGroupEntity entity) {
-        String id = super.saveOrUpdateForSingle(entity);
-        trySyncRoleInfo(entity);
-        return id;
-    }
-
     @Override
     @Override
     @CacheEvict(allEntries = true)
     @CacheEvict(allEntries = true)
     public void enable(String id) {
     public void enable(String id) {
         tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}");
         tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}");
         createUpdate()
         createUpdate()
-                .set(MenuGroupEntity.enabled, true)
+                .set(MenuGroupEntity.state, 1)
                 .where(MenuGroupEntity.id, id)
                 .where(MenuGroupEntity.id, id)
                 .exec();
                 .exec();
-        if (checkRoleServiceIsEnable())
-            roleService.enable(id);
     }
     }
 
 
     @Override
     @Override
@@ -173,45 +143,8 @@ public class SimpleMenuGroupService
         tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}");
         tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}");
         DefaultDSLUpdateService
         DefaultDSLUpdateService
                 .createUpdate(getDao())
                 .createUpdate(getDao())
-                .set(MenuGroupEntity.enabled, false)
+                .set(MenuGroupEntity.state, 0)
                 .where(MenuGroupEntity.id, id)
                 .where(MenuGroupEntity.id, id)
                 .exec();
                 .exec();
-        if (checkRoleServiceIsEnable())
-            roleService.disable(id);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void trySyncRoleInfo(MenuGroupEntity menuGroupEntity) {
-        if (!checkRoleServiceIsEnable()) return;
-        //角色的操作,新增or更新
-        Consumer<BindPermissionRoleEntity<PermissionRoleEntity>> roleEntityConsumer =
-                roleService.selectByPk(menuGroupEntity.getId()) == null
-                        ? roleService::insert
-                        : roleService::update;
-
-        //设置属性
-        BindPermissionRoleEntity<PermissionRoleEntity> roleEntity = entityFactory.newInstance(BindPermissionRoleEntity.class);
-        roleEntity.setId(menuGroupEntity.getId());
-        roleEntity.setName(menuGroupEntity.getName());
-        roleEntity.setEnabled(menuGroupEntity.isEnabled());
-        roleEntity.setDescribe(menuGroupEntity.getDescribe());
-        List<MenuGroupBindEntity> bindEntities = menuGroupEntity.getBindInfo();
-        if (bindEntities != null && bindEntities.size() > 0) {
-            roleEntity.setPermissions(bindEntities.stream()
-                    .sorted()
-                    .map(bind -> {
-                                //转换 MenuGroupBindEntity 为PermissionRoleEntity
-                                PermissionRoleEntity permission = entityFactory.newInstance(PermissionRoleEntity.class, bind);
-                                permission.setRoleId(bind.getGroupId());
-                                MenuEntity menuEntity = menuService.selectByPk(bind.getMenuId());
-                                assertNotNull(menuEntity, "menu " + bind.getMenuId() + " not found");
-                                permission.setPermissionId(menuEntity.getPermissionId());
-                                return permission;
-                            }
-                    ).collect(Collectors.toList()));
-        }
-
-        roleEntityConsumer.accept(roleEntity);
     }
     }
-
 }
 }

+ 12 - 6
hsweb-system/hsweb-system-menu/hsweb-system-menu-service/hsweb-system-menu-service-simple/src/main/java/org/hswebframework/web/service/menu/simple/SimpleMenuService.java

@@ -16,13 +16,13 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.service.menu.simple;
+package org.hswebframework.web.service.authorization.simple;
 
 
-import org.hswebframework.web.dao.menu.MenuDao;
-import org.hswebframework.web.entity.menu.MenuEntity;
+import org.hswebframework.web.dao.authorization.MenuDao;
+import org.hswebframework.web.entity.authorization.MenuEntity;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.service.AbstractTreeSortService;
 import org.hswebframework.web.service.AbstractTreeSortService;
-import org.hswebframework.web.service.menu.MenuService;
+import org.hswebframework.web.service.authorization.MenuService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CacheEvict;
@@ -68,11 +68,17 @@ public class SimpleMenuService
     @Override
     @Override
     @CacheEvict(allEntries = true)
     @CacheEvict(allEntries = true)
     public String insert(MenuEntity entity) {
     public String insert(MenuEntity entity) {
-        if(entity.isEnabled()==null)
-            entity.setEnabled(true);
+        if (entity.getStatus() == null)
+            entity.setStatus((byte) 1);
         return super.insert(entity);
         return super.insert(entity);
     }
     }
 
 
+    @Override
+    @Cacheable(key = "'ids:'+#id==null?'0':#id.hashCode()")
+    public List<MenuEntity> selectByPk(List<String> id) {
+        return super.selectByPk(id);
+    }
+
     @Override
     @Override
     @CacheEvict(allEntries = true)
     @CacheEvict(allEntries = true)
     public int deleteByPk(String id) {
     public int deleteByPk(String id) {

+ 4 - 4
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java

@@ -17,7 +17,7 @@
 
 
 package org.hswebframework.web.service.authorization.simple;
 package org.hswebframework.web.service.authorization.simple;
 
 
-import org.hswebframework.web.commons.entity.GenericEntity;
+import org.hswebframework.web.commons.entity.DataStatus;
 import org.hswebframework.web.dao.authorization.PermissionRoleDao;
 import org.hswebframework.web.dao.authorization.PermissionRoleDao;
 import org.hswebframework.web.dao.authorization.RoleDao;
 import org.hswebframework.web.dao.authorization.RoleDao;
 import org.hswebframework.web.entity.authorization.PermissionRoleEntity;
 import org.hswebframework.web.entity.authorization.PermissionRoleEntity;
@@ -71,7 +71,7 @@ public class SimpleRoleService extends AbstractService<RoleEntity, String>
     public <T extends PermissionRoleEntity> String insert(BindPermissionRoleEntity<T> roleEntity) {
     public <T extends PermissionRoleEntity> String insert(BindPermissionRoleEntity<T> roleEntity) {
         tryValidateProperty(StringUtils.hasLength(roleEntity.getId()), RoleEntity.id, "id {not_be_null}");
         tryValidateProperty(StringUtils.hasLength(roleEntity.getId()), RoleEntity.id, "id {not_be_null}");
         tryValidateProperty(null == selectByPk(roleEntity.getId()), RoleEntity.id, "{role_exists}");
         tryValidateProperty(null == selectByPk(roleEntity.getId()), RoleEntity.id, "{role_exists}");
-        roleEntity.setEnabled(true);
+        roleEntity.setStatus(DataStatus.STATUS_ENABLED);
         tryValidate(roleEntity);
         tryValidate(roleEntity);
         roleDao.insert(roleEntity);
         roleDao.insert(roleEntity);
         syncPermissions(roleEntity.getId(), roleEntity.getPermissions());
         syncPermissions(roleEntity.getId(), roleEntity.getPermissions());
@@ -82,7 +82,7 @@ public class SimpleRoleService extends AbstractService<RoleEntity, String>
     public void enable(String roleId) {
     public void enable(String roleId) {
         tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}");
         tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}");
         DefaultDSLUpdateService.createUpdate(getDao())
         DefaultDSLUpdateService.createUpdate(getDao())
-                .set(RoleEntity.enabled, true)
+                .set(RoleEntity.status, DataStatus.STATUS_ENABLED)
                 .where(RoleEntity.id, roleId)
                 .where(RoleEntity.id, roleId)
                 .exec();
                 .exec();
     }
     }
@@ -91,7 +91,7 @@ public class SimpleRoleService extends AbstractService<RoleEntity, String>
     public void disable(String roleId) {
     public void disable(String roleId) {
         tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}");
         tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}");
         DefaultDSLUpdateService.createUpdate(getDao())
         DefaultDSLUpdateService.createUpdate(getDao())
-                .set(RoleEntity.enabled, false)
+                .set(RoleEntity.status, DataStatus.STATUS_DISABLED)
                 .where(RoleEntity.id, roleId)
                 .where(RoleEntity.id, roleId)
                 .exec();
                 .exec();
     }
     }

+ 35 - 74
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java

@@ -1,10 +1,14 @@
 package org.hswebframework.web.service.authorization.simple;
 package org.hswebframework.web.service.authorization.simple;
 
 
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.commons.entity.DataStatus;
 import org.hswebframework.web.commons.entity.GenericEntity;
 import org.hswebframework.web.commons.entity.GenericEntity;
-import org.hswebframework.web.dao.authorization.*;
-import org.hswebframework.web.entity.authorization.*;
+import org.hswebframework.web.dao.authorization.RoleDao;
+import org.hswebframework.web.dao.authorization.UserDao;
+import org.hswebframework.web.dao.authorization.UserRoleDao;
+import org.hswebframework.web.entity.authorization.RoleEntity;
+import org.hswebframework.web.entity.authorization.UserEntity;
+import org.hswebframework.web.entity.authorization.UserRoleEntity;
 import org.hswebframework.web.entity.authorization.bind.BindRoleUserEntity;
 import org.hswebframework.web.entity.authorization.bind.BindRoleUserEntity;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.id.IDGenerator;
 import org.hswebframework.web.service.AbstractService;
 import org.hswebframework.web.service.AbstractService;
@@ -15,8 +19,6 @@ import org.hswebframework.web.validate.ValidationException;
 import org.hswebframwork.utils.ListUtils;
 import org.hswebframwork.utils.ListUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.cache.annotation.Caching;
 import org.springframework.cache.annotation.Caching;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -30,14 +32,15 @@ import static org.hswebframework.web.service.authorization.simple.CacheConstants
 import static org.hswebframework.web.service.authorization.simple.CacheConstants.USER_CACHE_NAME;
 import static org.hswebframework.web.service.authorization.simple.CacheConstants.USER_CACHE_NAME;
 
 
 /**
 /**
- * TODO 完成注释
+ * 默认的用户服务实现
  *
  *
  * @author zhouhao
  * @author zhouhao
+ * @since 3.0
  */
  */
 @Transactional(rollbackFor = Throwable.class)
 @Transactional(rollbackFor = Throwable.class)
 @Service("userService")
 @Service("userService")
 public class SimpleUserService extends AbstractService<UserEntity, String>
 public class SimpleUserService extends AbstractService<UserEntity, String>
-        implements DefaultDSLQueryService<UserEntity, String>, UserService {
+        implements DefaultDSLQueryService<UserEntity, String>, UserService, AuthorizationSettingTypeSupplier {
 
 
     @Autowired(required = false)
     @Autowired(required = false)
     private PasswordStrengthValidator passwordStrengthValidator;
     private PasswordStrengthValidator passwordStrengthValidator;
@@ -48,36 +51,15 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
     @Autowired(required = false)
     @Autowired(required = false)
     private PasswordEncoder passwordEncoder = (password, salt) -> DigestUtils.md5Hex(String.format("hsweb.%s.framework.%s", password, salt));
     private PasswordEncoder passwordEncoder = (password, salt) -> DigestUtils.md5Hex(String.format("hsweb.%s.framework.%s", password, salt));
 
 
-    @Autowired(required = false)
-    private DataAccessFactory dataAccessFactory;
-
     @Autowired
     @Autowired
     private UserDao userDao;
     private UserDao userDao;
 
 
     @Autowired
     @Autowired
     private UserRoleDao userRoleDao;
     private UserRoleDao userRoleDao;
 
 
-    @Autowired
-    private PermissionRoleDao permissionRoleDao;
-
-    @Autowired
-    private PermissionDao permissionDao;
-
     @Autowired
     @Autowired
     private RoleDao roleDao;
     private RoleDao roleDao;
 
 
-    @Override
-    @Cacheable(value = USER_AUTH_CACHE_NAME, key = "#userId")
-    public Authentication getByUserId(String userId) {
-        return initUserAuthorization(userId);
-    }
-
-    @Override
-    @CachePut(value = USER_AUTH_CACHE_NAME, key = "#authentication.user.id")
-    public Authentication sync(Authentication authentication) {
-        return authentication;
-    }
-
     @Override
     @Override
     public String encodePassword(String password, String salt) {
     public String encodePassword(String password, String salt) {
         return passwordEncoder.encode(password, salt);
         return passwordEncoder.encode(password, salt);
@@ -87,7 +69,6 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
     @Transactional(readOnly = true)
     @Transactional(readOnly = true)
     public UserEntity selectByUsername(String username) {
     public UserEntity selectByUsername(String username) {
         tryValidateProperty(StringUtils.hasLength(username), UserEntity.username, "id:{not_be_null}");
         tryValidateProperty(StringUtils.hasLength(username), UserEntity.username, "id:{not_be_null}");
-
         Assert.notNull(username, "username:{not_be_null}");
         Assert.notNull(username, "username:{not_be_null}");
         return createQuery().where("username", username).single();
         return createQuery().where("username", username).single();
     }
     }
@@ -117,7 +98,7 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
         userEntity.setCreateTime(System.currentTimeMillis());
         userEntity.setCreateTime(System.currentTimeMillis());
         userEntity.setId(IDGenerator.MD5.generate());
         userEntity.setId(IDGenerator.MD5.generate());
         userEntity.setSalt(IDGenerator.RANDOM.generate());
         userEntity.setSalt(IDGenerator.RANDOM.generate());
-        userEntity.setEnabled(true);
+        userEntity.setStatus(DataStatus.STATUS_ENABLED);
         //验证其他属性
         //验证其他属性
         tryValidate(userEntity);
         tryValidate(userEntity);
         //密码MD5
         //密码MD5
@@ -184,7 +165,7 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
     @Override
     @Override
     public boolean enable(String userId) {
     public boolean enable(String userId) {
         return DefaultDSLUpdateService.createUpdate(getDao())
         return DefaultDSLUpdateService.createUpdate(getDao())
-                .set(UserEntity.enabled, true)
+                .set(UserEntity.status, DataStatus.STATUS_ENABLED)
                 .where(GenericEntity.id, userId)
                 .where(GenericEntity.id, userId)
                 .exec() > 0;
                 .exec() > 0;
     }
     }
@@ -192,7 +173,7 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
     @Override
     @Override
     public boolean disable(String userId) {
     public boolean disable(String userId) {
         return DefaultDSLUpdateService.createUpdate(getDao())
         return DefaultDSLUpdateService.createUpdate(getDao())
-                .set(UserEntity.enabled, false)
+                .set(UserEntity.status, DataStatus.STATUS_DISABLED)
                 .where(GenericEntity.id, userId)
                 .where(GenericEntity.id, userId)
                 .exec() > 0;
                 .exec() > 0;
     }
     }
@@ -212,56 +193,36 @@ public class SimpleUserService extends AbstractService<UserEntity, String>
                 .exec();
                 .exec();
     }
     }
 
 
+
     @Override
     @Override
-    public Authentication initUserAuthorization(String userId) {
-        UserEntity userEntity = selectByPk(userId);
-        assertNotNull(userEntity);
-        //用户持有的角色
+    public List<RoleEntity> getUserRole(String userId) {
+        Objects.requireNonNull(userId);
         List<UserRoleEntity> roleEntities = userRoleDao.selectByUserId(userId);
         List<UserRoleEntity> roleEntities = userRoleDao.selectByUserId(userId);
-        if (ListUtils.isNullOrEmpty(roleEntities)) {
-            return SimpleAuthenticationBuilder.build(userEntity, new ArrayList<>(), new ArrayList<>(), dataAccessFactory);
-        }
+        if (roleEntities.isEmpty()) return new ArrayList<>();
         List<String> roleIdList = roleEntities.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toList());
         List<String> roleIdList = roleEntities.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toList());
-
-        List<RoleEntity> roleEntityList = DefaultDSLQueryService.createQuery(roleDao).where().in(GenericEntity.id, roleIdList).noPaging().list();
-        //权限角色关联信息
-        List<PermissionRoleEntity> permissionRoleEntities = permissionRoleDao.selectByRoleIdList(roleIdList);
-        return SimpleAuthenticationBuilder.build(userEntity, roleEntityList, permissionRoleEntities, dataAccessFactory);
+        return DefaultDSLQueryService
+                .createQuery(roleDao).where()
+                .in(GenericEntity.id, roleIdList)
+                .noPaging()
+                .list();
     }
     }
 
 
     @Override
     @Override
-    public Authentication initAdminAuthorization(String userId) {
-        UserEntity userEntity = selectByPk(userId);
-        assertNotNull(userEntity);
-        //所有权限信息
-        List<PermissionEntity> permissionEntities = DefaultDSLQueryService
-                .createQuery(permissionDao).noPaging().list();
-        List<PermissionRoleEntity> permissionRoleEntities = permissionEntities
-                .stream().map(permission -> {
-                    PermissionRoleEntity entity = entityFactoryIsEnabled()
-                            ? entityFactory.newInstance(PermissionRoleEntity.class)
-                            : new SimplePermissionRoleEntity();
-                    entity.setRoleId("admin");  //always admin
-                    entity.setPermissionId(permission.getId());
-                    entity.setActions(permission.getActions()
-                            .stream()
-                            .map(ActionEntity::getAction)
-                            .collect(Collectors.toList()));
-                    return entity;
-                }).collect(Collectors.toList());
-        List<RoleEntity> roleEntityList = DefaultDSLQueryService.createQuery(roleDao).noPaging().list();
-        if (roleEntityList.isEmpty()) {
-            RoleEntity admin = entityFactory.newInstance(RoleEntity.class);
-            admin.setId("admin");
-            admin.setName("admin");
-            roleEntityList.add(admin);
-        }
-        return SimpleAuthenticationBuilder.build(userEntity, roleEntityList, permissionRoleEntities, dataAccessFactory);
+    public UserDao getDao() {
+        return userDao;
     }
     }
 
 
-
     @Override
     @Override
-    public UserDao getDao() {
-        return userDao;
+    public Set<SettingInfo> get(String userId) {
+        UserEntity userEntity = selectByPk(userId);
+        if (null == userEntity) return new HashSet<>();
+        List<UserRoleEntity> roleEntities = userRoleDao.selectByUserId(userId);
+        //使用角色配置
+        Set<SettingInfo> settingInfo = roleEntities.stream()
+                .map(entity -> new SettingInfo(SETTING_TYPE_ROLE, entity.getRoleId()))
+                .collect(Collectors.toSet());
+        //使用用户的配置
+        settingInfo.add(new SettingInfo(SETTING_TYPE_USER, userId));
+        return settingInfo;
     }
     }
 }
 }

+ 11 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfigration.java

@@ -18,11 +18,15 @@
 
 
 package org.hswebframework.web.authorization.starter;
 package org.hswebframework.web.authorization.starter;
 
 
+import org.hswebframework.web.authorization.AuthenticationInitializeService;
+import org.hswebframework.web.authorization.AuthenticationManager;
 import org.hswebframework.web.authorization.listener.AuthorizationListener;
 import org.hswebframework.web.authorization.listener.AuthorizationListener;
 import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
 import org.hswebframework.web.authorization.listener.AuthorizationListenerDispatcher;
 import org.hswebframework.web.authorization.listener.event.AuthorizationEvent;
 import org.hswebframework.web.authorization.listener.event.AuthorizationEvent;
+import org.hswebframework.web.service.authorization.simple.SimpleAuthenticationManager;
 import org.hswebframwork.utils.ClassUtils;
 import org.hswebframwork.utils.ClassUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
@@ -47,4 +51,11 @@ public class AuthorizationAutoConfigration {
         }
         }
         return dispatcher;
         return dispatcher;
     }
     }
+
+    @Bean
+    @ConditionalOnMissingBean(AuthenticationManager.class)
+    @ConditionalOnBean(AuthenticationInitializeService.class)
+    public AuthenticationManager authenticationManager(AuthenticationInitializeService authenticationInitializeService) {
+        return new SimpleAuthenticationManager(authenticationInitializeService);
+    }
 }
 }

+ 71 - 2
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js

@@ -42,7 +42,7 @@ function install(context) {
         .addColumn().name("username").varchar(128).notNull().comment("用户名").commit()
         .addColumn().name("username").varchar(128).notNull().comment("用户名").commit()
         .addColumn().name("password").varchar(128).notNull().comment("密码").commit()
         .addColumn().name("password").varchar(128).notNull().comment("密码").commit()
         .addColumn().name("salt").varchar(128).notNull().comment("密码盐").commit()
         .addColumn().name("salt").varchar(128).notNull().comment("密码盐").commit()
-        .addColumn().name("enabled").number(1).notNull().comment("是否启用").commit()
+        .addColumn().name("status").number(4).notNull().comment("用户状态").commit()
         .addColumn().name("last_login_ip").varchar(128).comment("上一次登录的ip地址").commit()
         .addColumn().name("last_login_ip").varchar(128).comment("上一次登录的ip地址").commit()
         .addColumn().name("last_login_time").number(32).comment("上一次登录时间").commit()
         .addColumn().name("last_login_time").number(32).comment("上一次登录时间").commit()
         .addColumn().name("creator_id").varchar(32).notNull().comment("创建者ID").commit()
         .addColumn().name("creator_id").varchar(32).notNull().comment("创建者ID").commit()
@@ -53,7 +53,7 @@ function install(context) {
         .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
         .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
         .addColumn().name("name").varchar(128).notNull().comment("角色名称").commit()
         .addColumn().name("name").varchar(128).notNull().comment("角色名称").commit()
         .addColumn().name("describe").varchar(128).comment("说明").commit()
         .addColumn().name("describe").varchar(128).comment("说明").commit()
-        .addColumn().name("enabled").number(1).notNull().comment("是否启用").commit()
+        .addColumn().name("status").number(4).notNull().comment("状态").commit()
         .comment("角色表").commit();
         .comment("角色表").commit();
 
 
     database.createOrAlter("s_permission")
     database.createOrAlter("s_permission")
@@ -78,6 +78,75 @@ function install(context) {
         .addColumn().name("user_id").varchar(32).notNull().comment("用户ID").commit()
         .addColumn().name("user_id").varchar(32).notNull().comment("用户ID").commit()
         .comment("用户与角色关联表").commit();
         .comment("用户与角色关联表").commit();
 
 
+    //权限设置
+    database.createOrAlter("s_autz_setting")
+        .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
+        .addColumn().name("type").varchar(32).notNull().comment("权限类型").commit()
+        .addColumn().name("setting_for").varchar(64).notNull().comment("设置给谁").commit()
+        .addColumn().name("describe").varchar(256).notNull().comment("备注").commit()
+        .addColumn().name("status").number(4, 0).notNull().comment("设置给谁").commit()
+        .comment("权限设置表").commit();
+
+    database.createOrAlter("s_autz_detail")
+        .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
+        .addColumn().name("permission_id").varchar(32).notNull().comment("权限ID").commit()
+        .addColumn().name("setting_id").varchar(64).notNull().comment("设置ID").commit()
+        .addColumn().name("actions").clob().comment("可操作类型").commit()
+        .addColumn().name("data_accesses").clob().comment("数据权限控制").commit()
+        .addColumn().name("status").number(4, 0).comment("状态").commit()
+        .addColumn().name("priority").number(32, 0).comment("优先级").commit()
+        .addColumn().name("is_merge").number(4, 0).comment("是否合并").commit()
+        .comment("权限设置详情表").commit();
+
+    database.createOrAlter("s_autz_menu")
+        .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
+        .addColumn().name("parent_id").varchar(32).comment("父级ID").commit()
+        .addColumn().name("menu_id").varchar(32).notNull().comment("菜单ID").commit()
+        .addColumn().name("setting_id").varchar(64).notNull().comment("设置ID").commit()
+        .addColumn().name("path").varchar(2048).notNull().comment("树编码").commit()
+        .addColumn().name("sort_index").number(32).notNull().comment("树编码").commit()
+        .addColumn().name("status").number(4, 0).comment("状态").commit()
+        .addColumn().name("level").number(32, 0).comment("树深度").commit()
+        .addColumn().name("config").clob().comment("其他配置").commit()
+        .comment("权限设置菜单表").commit();
+
+    // 菜单
+    database.createOrAlter("s_menu")
+        .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit()
+        .addColumn().name("name").varchar(64).notNull().comment("名称").commit()
+        .addColumn().name("parent_id").varchar(32).comment("父级ID").commit()
+        .addColumn().name("permission_id").varchar(32).comment("权限ID").commit()
+        .addColumn().name("path").varchar(2048).notNull().comment("树编码").commit()
+        .addColumn().name("sort_index").number(32).notNull().comment("树编码").commit()
+        .addColumn().name("describe").varchar(128).comment("备注").commit()
+        .addColumn().name("url").varchar(2000).comment("URL").commit()
+        .addColumn().name("icon").varchar(512).comment("图标").commit()
+        .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
+        .comment("系统菜单表").commit()
+
+    database.createOrAlter("s_menu_group")
+        .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
+        .addColumn().name("parent_id").varchar(32).comment("父级ID").commit()
+        .addColumn().name("name").alias("name").comment("分组名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("describe").alias("describe").comment("分组描述").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit()
+        .addColumn().name("default_group").alias("defaultGroup").comment("是否默认").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
+        .addColumn().name("path").alias("path").comment("树路径").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit()
+        .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("level").alias("level").comment("树层级").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
+        .comment("菜单分组").commit();
+
+    database.createOrAlter("s_menu_group_bind")
+        .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit()
+        .addColumn().name("menu_id").alias("menuId").comment("菜单id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("group_id").alias("groupId").comment("分组id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("path").alias("path").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(4000).commit()
+        .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit()
+        .addColumn().name("level").alias("level").comment("树层级").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit()
+        .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit()
+        .comment("菜单分组关联").commit();
 }
 }
 
 
 //设置依赖
 //设置依赖

+ 21 - 16
hsweb-system/hsweb-system-menu/hsweb-system-menu-starter/src/test/java/org/hswebframework/web/starter/menu/MenuGroupTests.java

@@ -16,12 +16,13 @@
  *
  *
  */
  */
 
 
-package org.hswebframework.web.starter.menu;
+package org.hswebframework.web.starter.authorization;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import org.hswebframework.web.entity.menu.MenuGroupEntity;
-import org.hswebframework.web.entity.menu.SimpleMenuGroupEntity;
+import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity;
+import org.hswebframework.web.entity.authorization.SimpleAuthorizationSettingEntity;
+import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier;
 import org.hswebframework.web.starter.convert.FastJsonHttpMessageConverter;
 import org.hswebframework.web.starter.convert.FastJsonHttpMessageConverter;
 import org.hswebframework.web.tests.SimpleWebApplicationTests;
 import org.hswebframework.web.tests.SimpleWebApplicationTests;
 import org.junit.Assert;
 import org.junit.Assert;
@@ -35,53 +36,57 @@ import org.springframework.http.MediaType;
  *
  *
  * @author hsweb-generator-online
  * @author hsweb-generator-online
  */
  */
-public class MenuGroupTests extends SimpleWebApplicationTests {
+public class AuthorizationSettingTests extends SimpleWebApplicationTests {
 
 
     @Autowired
     @Autowired
     private FastJsonHttpMessageConverter fastJsonHttpMessageConverter;
     private FastJsonHttpMessageConverter fastJsonHttpMessageConverter;
 
 
     @Test
     @Test
     public void testCrud() throws Exception {
     public void testCrud() throws Exception {
-        MenuGroupEntity entity = entityFactory.newInstance(MenuGroupEntity.class);
+        AuthorizationSettingEntity entity = entityFactory.newInstance(AuthorizationSettingEntity.class);
         //todo 设置测试属性
         //todo 设置测试属性
-        entity.setName("test");
         entity.setId("test");
         entity.setId("test");
+        entity.setType(AuthorizationSettingTypeSupplier.SETTING_TYPE_USER);
+        entity.setSettingFor("test");
+        entity.setDescribe("测试");
 
 
         // test add data
         // test add data
         String requestBody = JSON.toJSONString(entity);
         String requestBody = JSON.toJSONString(entity);
-        JSONObject result = testPost("/menu-group").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson();
+        JSONObject result = testPost("/autz-setting").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson();
         Assert.assertEquals(200, result.get("status"));
         Assert.assertEquals(200, result.get("status"));
         String id = result.getString("result");
         String id = result.getString("result");
         Assert.assertNotNull(id);
         Assert.assertNotNull(id);
         entity.setId(id);
         entity.setId(id);
         // test get data
         // test get data
-        result = testGet("/menu-group/" + id).exec().resultAsJson();
-        entity = result.getObject("result", entityFactory.getInstanceType(MenuGroupEntity.class));
+        result = testGet("/autz-setting/" + id).exec().resultAsJson();
+        entity = result.getObject("result", entityFactory.getInstanceType(AuthorizationSettingEntity.class));
 
 
         Assert.assertEquals(200, result.get("status"));
         Assert.assertEquals(200, result.get("status"));
         Assert.assertNotNull(result.getJSONObject("result"));
         Assert.assertNotNull(result.getJSONObject("result"));
 
 
         Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity),
         Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity),
-                fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(MenuGroupEntity.class))));
+                fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(AuthorizationSettingEntity.class))));
         //todo 修改测试属性
         //todo 修改测试属性
-        MenuGroupEntity newEntity = entityFactory.newInstance(MenuGroupEntity.class);
-        newEntity.setName("test");
+        AuthorizationSettingEntity newEntity = entityFactory.newInstance(AuthorizationSettingEntity.class);
+        newEntity.setId("test");
 
 
-        result = testPut("/menu-group/" + id)
+        newEntity.setDescribe("测试2");
+
+        result = testPut("/autz-setting/" + id)
                 .setUp(setup ->
                 .setUp(setup ->
                         setup.contentType(MediaType.APPLICATION_JSON)
                         setup.contentType(MediaType.APPLICATION_JSON)
                                 .content(JSON.toJSONString(newEntity)))
                                 .content(JSON.toJSONString(newEntity)))
                 .exec().resultAsJson();
                 .exec().resultAsJson();
         Assert.assertEquals(200, result.get("status"));
         Assert.assertEquals(200, result.get("status"));
 
 
-        result = testGet("/menu-group/" + id).exec().resultAsJson();
+        result = testGet("/autz-setting/" + id).exec().resultAsJson();
         result = result.getJSONObject("result");
         result = result.getJSONObject("result");
         Assert.assertNotNull(result);
         Assert.assertNotNull(result);
 
 
-        result = testDelete("/menu-group/" + id).exec().resultAsJson();
+        result = testDelete("/autz-setting/" + id).exec().resultAsJson();
         Assert.assertEquals(200, result.get("status"));
         Assert.assertEquals(200, result.get("status"));
 
 
-        result = testGet("/menu-group/" + id).exec().resultAsJson();
+        result = testGet("/autz-setting/" + id).exec().resultAsJson();
         Assert.assertEquals(404, result.get("status"));
         Assert.assertEquals(404, result.get("status"));
     }
     }
 }
 }

+ 1 - 7
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/LoginTests.java

@@ -56,15 +56,9 @@ public class LoginTests extends SimpleWebApplicationTests {
         userEntity.setCreateTimeNow();
         userEntity.setCreateTimeNow();
         userService.insert(userEntity);
         userService.insert(userEntity);
 
 
-//        //获取publicKey
-//        String publicKey = testGet("/authorize/public-key").exec().resultAsJson().getString("result");
-//        Assert.notNull(publicKey);
-//        RSAPublicEncrypt publicEncrypt = Encrypt.rsa().publicEncrypt(publicKey);
-//        String username = Base64.encodeBase64String(publicEncrypt.encrypt("test".getBytes()));
-//        String password = Base64.encodeBase64String(publicEncrypt.encrypt("password_1234".getBytes()));
         JSONObject json = testPost("/authorize/login").setUp((builder) -> {
         JSONObject json = testPost("/authorize/login").setUp((builder) -> {
             builder.param("username", userEntity.getUsername());
             builder.param("username", userEntity.getUsername());
-            builder.param("password","password_1234");
+            builder.param("password", "password_1234");
         }).exec().resultAsJson();
         }).exec().resultAsJson();
 
 
         org.junit.Assert.assertEquals(json.get("result"), userEntity.getId());
         org.junit.Assert.assertEquals(json.get("result"), userEntity.getId());

+ 12 - 10
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/UserTests.java

@@ -18,6 +18,8 @@
 package org.hswebframework.web.starter.authorization;
 package org.hswebframework.web.starter.authorization;
 
 
 import org.hswebframework.web.authorization.Authentication;
 import org.hswebframework.web.authorization.Authentication;
+import org.hswebframework.web.authorization.AuthenticationInitializeService;
+import org.hswebframework.web.commons.entity.DataStatus;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.service.authorization.PasswordStrengthValidator;
 import org.hswebframework.web.service.authorization.PasswordStrengthValidator;
 import org.hswebframework.web.service.authorization.UserService;
 import org.hswebframework.web.service.authorization.UserService;
@@ -66,6 +68,9 @@ public class UserTests extends SimpleWebApplicationTests {
     @Autowired
     @Autowired
     private UserService userService;
     private UserService userService;
 
 
+    @Autowired
+    private AuthenticationInitializeService authenticationInitializeService;
+
     @After
     @After
     public void clear() throws SQLException {
     public void clear() throws SQLException {
         sqlExecutor.delete("delete from s_user");
         sqlExecutor.delete("delete from s_user");
@@ -85,10 +90,7 @@ public class UserTests extends SimpleWebApplicationTests {
     @Test
     @Test
     public void testInitAuth() {
     public void testInitAuth() {
         UserEntity entity = createTestUser();
         UserEntity entity = createTestUser();
-        Authentication authentication = userService.initAdminAuthorization(entity.getId());
-        Assert.assertNotNull(authentication);
-        Assert.assertEquals(authentication.getUser().getUsername(), entity.getUsername());
-        authentication = userService.initUserAuthorization(entity.getId());
+        Authentication authentication = authenticationInitializeService.initUserAuthorization(entity.getId());
         Assert.assertNotNull(authentication);
         Assert.assertNotNull(authentication);
         Assert.assertEquals(authentication.getUser().getUsername(), entity.getUsername());
         Assert.assertEquals(authentication.getUser().getUsername(), entity.getUsername());
     }
     }
@@ -118,13 +120,13 @@ public class UserTests extends SimpleWebApplicationTests {
         Assert.assertEquals(userEntity.getPassword().length(), 32);
         Assert.assertEquals(userEntity.getPassword().length(), 32);
 
 
         UserEntity entityInDb = userService.selectByUsername(userEntity.getUsername());
         UserEntity entityInDb = userService.selectByUsername(userEntity.getUsername());
-        Assert.assertEquals(entityInDb.isEnabled(), true);
+        Assert.assertEquals(entityInDb.getStatus(), DataStatus.STATUS_ENABLED);
         Assert.assertNotNull(entityInDb.getCreateTime());
         Assert.assertNotNull(entityInDb.getCreateTime());
 
 
         Assert.assertEquals(entityInDb.getPassword(), userService.encodePassword("password_1234", entityInDb.getSalt()));
         Assert.assertEquals(entityInDb.getPassword(), userService.encodePassword("password_1234", entityInDb.getSalt()));
 
 
         entityInDb = userService.selectByUsername(userEntity.getUsername());
         entityInDb = userService.selectByUsername(userEntity.getUsername());
-        Assert.assertEquals(entityInDb.isEnabled(), true);
+        Assert.assertEquals(entityInDb.getStatus(), DataStatus.STATUS_ENABLED);
         Assert.assertNotNull(entityInDb.getCreateTime());
         Assert.assertNotNull(entityInDb.getCreateTime());
         try {
         try {
             userService.updatePassword(id, "test", "test");
             userService.updatePassword(id, "test", "test");
@@ -139,24 +141,24 @@ public class UserTests extends SimpleWebApplicationTests {
         entityInDb.setId(anotherId);
         entityInDb.setId(anotherId);
         entityInDb.setName("新名字");
         entityInDb.setName("新名字");
         try {
         try {
-            userService.update(anotherId,entityInDb);
+            userService.update(anotherId, entityInDb);
             Assert.assertTrue(false);
             Assert.assertTrue(false);
         } catch (ValidationException e) {
         } catch (ValidationException e) {
             Assert.assertEquals(e.getResults().get(0).getMessage(), "{username_exists}");
             Assert.assertEquals(e.getResults().get(0).getMessage(), "{username_exists}");
         }
         }
         entityInDb.setId(id);
         entityInDb.setId(id);
-        userService.update(id,entityInDb);
+        userService.update(id, entityInDb);
         entityInDb = userService.selectByUsername(userEntity.getUsername());
         entityInDb = userService.selectByUsername(userEntity.getUsername());
         Assert.assertEquals("新名字", entityInDb.getName());
         Assert.assertEquals("新名字", entityInDb.getName());
 
 
 
 
         userService.disable(id);
         userService.disable(id);
         entityInDb = userService.selectByUsername(userEntity.getUsername());
         entityInDb = userService.selectByUsername(userEntity.getUsername());
-        Assert.assertFalse(entityInDb.isEnabled());
+        Assert.assertEquals(DataStatus.STATUS_DISABLED, entityInDb.getStatus());
 
 
         userService.enable(id);
         userService.enable(id);
         entityInDb = userService.selectByUsername(userEntity.getUsername());
         entityInDb = userService.selectByUsername(userEntity.getUsername());
-        Assert.assertTrue(entityInDb.isEnabled());
+        Assert.assertEquals(DataStatus.STATUS_ENABLED, entityInDb.getStatus());
 
 
     }
     }
 }
 }