From b6033ba794df89741bafbd68704d288d776e5e1b Mon Sep 17 00:00:00 2001 From: zhou-hao Date: Fri, 27 Sep 2019 11:09:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=B3=A2=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 133 +-- .../hsweb-authorization-api/pom.xml | 5 - .../access/ScriptDataAccessHandler.java | 2 +- .../simple/SimpleOAuth2RequestService.java | 2 +- .../simple/SimpleOAuth2SessionBuilder.java | 4 +- .../provider/HswebResponseConvertSupport.java | 4 +- .../simple/session/DefaultOAuth2Session.java | 2 +- .../HswebResponseConvertSupportTests.java | 4 +- hsweb-boost/README.md | 1 - hsweb-boost/hsweb-boost-aop/README.md | 3 - hsweb-boost/hsweb-boost-aop/pom.xml | 59 -- hsweb-boost/hsweb-boost-excel/pom.xml | 29 - .../web/excel/DefaultExcelImporter.java | 303 ------- .../org/hswebframework/web/excel/Excel.java | 60 -- .../web/excel/ExcelCellConverter.java | 11 - .../web/excel/ExcelImporter.java | 66 -- .../web/excel/DefaultExcelImporterTest.java | 57 -- .../src/test/resources/test.xls | Bin 18944 -> 0 bytes hsweb-boost/hsweb-boost-ftp/pom.xml | 36 - .../web/ftp/DefaultFTPOperation.java | 80 -- .../hswebframework/web/ftp/FTPOperation.java | 35 - .../web/ftp/pool/FTPClientFactory.java | 76 -- .../web/ftp/pool/FTPClientPool.java | 22 - .../web/ftp/pool/FTPClientProperties.java | 25 - hsweb-boost/pom.xml | 40 - hsweb-commons/hsweb-commons-bean/pom.xml | 52 -- .../hswebframework/web/commons/bean/Bean.java | 38 - .../web/commons/bean/BeanValidator.java | 46 -- .../bean/BeanValidatorAutoConfiguration.java | 38 - .../web/commons/bean/ValidateBean.java | 22 - .../main/resources/META-INF/spring.factories | 3 - .../web/commons/bean/BeanValidatorTest.groovy | 43 - .../web/commons/bean/TestBean.java | 20 - .../hsweb-commons-controller/README.md | 85 -- .../hsweb-commons-controller/pom.xml | 78 -- .../web/controller/CreateController.java | 87 -- .../web/controller/CrudController.java | 53 -- .../web/controller/DeleteController.java | 50 -- .../controller/GenericEntityController.java | 41 - .../web/controller/QueryController.java | 116 --- .../web/controller/SimpleCrudController.java | 54 -- .../SimpleGenericEntityController.java | 42 - .../web/controller/UpdateController.java | 101 --- .../message/MapResponseMessage.java | 46 -- .../controller/message/ResponseMessage.java | 267 ------ .../src/main/resources/hsweb-module.json | 9 - hsweb-commons/hsweb-commons-crud/pom.xml | 14 + .../web/crud/entity/Entity.java} | 12 +- .../web/crud/entity/LogicalDeleteEntity.java | 19 + .../web/crud/entity/PagerResult.java | 3 +- .../web/crud/entity/RecordCreationEntity.java | 30 + .../web/crud/entity/RecordModifierEntity.java | 29 + .../entity/factory/DefaultMapperFactory.java | 12 + .../entity/factory/DefaultPropertyCopier.java | 10 + .../crud/entity/factory/EntityFactory.java | 113 +++ .../entity/factory/MapperEntityFactory.java | 240 ++++++ .../crud/entity/factory/PropertyCopier.java | 11 + .../web/crud/events/EntityCreatedEvent.java | 15 + .../web/crud/events/EntityModifyEvent.java | 20 + .../web/crud/service/CrudService.java | 90 +++ .../web/crud/service/DefaultCrudService.java | 16 + .../web/crud/service/ReactiveCrudService.java | 15 + hsweb-commons/hsweb-commons-entity/pom.xml | 2 +- .../entity/factory/MapperEntityFactory.java | 2 +- hsweb-commons/hsweb-commons-model/pom.xml | 45 -- .../web/commons/model/Model.java | 29 - .../hsweb-commons-service-api/pom.xml | 42 - .../web/service/CreateEntityService.java | 41 - .../web/service/CrudService.java | 34 - .../web/service/DeleteService.java | 33 - .../web/service/InsertService.java | 33 - .../web/service/QueryByEntityService.java | 67 -- .../web/service/QueryService.java | 55 -- .../web/service/TreeService.java | 71 -- .../web/service/UpdateService.java | 49 -- .../hswebframework/web/service/Validator.java | 12 - .../hsweb-commons-service-simple/README.md | 43 - .../hsweb-commons-service-simple/pom.xml | 81 -- .../web/service/AbstractService.java | 147 ---- .../web/service/AbstractTreeSortService.java | 184 ----- .../web/service/DefaultDSLDeleteService.java | 56 -- .../web/service/DefaultDSLQueryService.java | 91 --- .../web/service/DefaultDSLUpdateService.java | 49 -- .../web/service/DefaultDeleteService.java | 33 - .../DefaultLogicPrimaryKeyValidator.java | 263 ------ .../service/DefaultQueryByEntityService.java | 134 ---- ...ableCacheAllEvictGenericEntityService.java | 72 -- .../EnableCacheAllEvictTreeSortService.java | 94 --- .../EnableCacheGenericEntityService.java | 93 --- .../service/EnableCacheTreeSortService.java | 95 --- .../web/service/GenericEntityService.java | 209 ----- .../web/service/GenericService.java | 39 - .../GenericsPayloadApplicationEvent.java | 49 -- .../src/main/resources/hsweb-module.json | 8 - .../service/AbstractTreeSortServiceTests.java | 99 --- .../DefaultLogicPrimaryKeyValidatorTest.java | 145 ---- .../EnableCacheAllEvictTestService.java | 29 - .../EnableCacheAllEvictTreeTestService.java | 29 - .../web/service/EnableCacheTestService.java | 28 - .../web/service/EnableCacheTests.java | 150 ---- .../service/EnableCacheTreeTestService.java | 28 - .../web/service/GenericEntityServiceTest.java | 126 --- .../web/service/ModifyEventTests.java | 85 -- .../web/service/SpringTestApplication.java | 41 - .../web/service/TestEntity.java | 39 - .../web/service/TestEntityService.java | 27 - .../web/service/TestModifyEntity.java | 37 - .../web/service/TestModifyEntity2.java | 37 - .../web/service/TestModifyEntityService.java | 44 - .../web/service/TestTreeEntityService.java | 27 - hsweb-commons/hsweb-commons-service/pom.xml | 53 -- .../java/org/hswebframework/web/AopUtils.java | 4 +- .../org/hswebframework/web/ModuleUtils.java | 2 +- .../java/org/hswebframework/web/Sqls.java | 4 +- .../web/context/ContextKey.java | 1 - .../web/context/ContextUtils.java | 18 +- .../web/context/MapContext.java | 4 +- hsweb-core/pom.xml | 6 + .../java/org/hswebframework/web/Describe.java | 35 - .../org/hswebframework/web/ScriptScope.java | 14 - .../web/aop}/MethodInterceptorContext.java | 2 +- .../web/aop}/MethodInterceptorHolder.java | 28 +- .../org/hswebframework/web/audit/Audit.java | 31 - .../web/audit/AuditFieldMeta.java | 20 - .../hswebframework/web/audit/AuditMeta.java | 28 - .../web/audit/AuditMetaParser.java | 12 - .../hswebframework/web/audit/Strategy.java | 11 - .../hswebframework/web/context/Context.java | 15 + .../web/context/ContextKey.java | 31 + .../web/context/ContextUtils.java | 37 + .../web/context/MapContext.java | 33 + .../org/hswebframework/web/dict/Dict.java | 30 +- .../hswebframework/web/dict/DictDefine.java | 2 - .../web/dict/DictDefineRepository.java | 3 - .../hswebframework/web/dict/DictParser.java | 13 - .../web/dict/DictSupportApi.java | 19 - .../org/hswebframework/web/dict/EnumDict.java | 3 +- .../org/hswebframework/web/dict/Item.java | 31 - .../web/dict/apply/DefaultDictApply.java | 48 -- .../web/dict/apply/DictApply.java | 13 - .../web/dict/apply/DictWrapper.java | 15 - .../dict/defaults/DefaultClassDictDefine.java | 1 - .../defaults/DefaultDictDefineRepository.java | 14 +- .../web/dict/defaults/DefaultDictParser.java | 39 - .../dict/defaults/DefaultDictSupportApi.java | 54 -- .../{dict/defaults => enums}/TrueOrFalse.java | 6 +- .../{ => exception}/BusinessException.java | 2 +- .../{ => exception}/NotFoundException.java | 2 +- .../web/utils/AnnotationUtils.java | 113 +++ .../web/validate/SimpleValidateResults.java | 88 -- .../web/validate/ValidateResults.java | 41 - .../web/validate/ValidationException.java | 51 -- .../web/validator/DuplicateKeyException.java | 24 - .../web/validator/LogicPrimaryKey.java | 56 -- .../validator/LogicPrimaryKeyValidator.java | 66 -- .../exception/DataSourceClosedException.java | 2 +- .../DataSourceNotFoundException.java | 2 +- .../RestControllerExceptionTranslator.java | 5 +- .../hsweb-system-authorization-api/pom.xml | 30 - .../entity/authorization/ActionEntity.java | 56 -- .../AuthorizationSettingDetailEntity.java | 123 --- .../AuthorizationSettingEntity.java | 103 --- .../AuthorizationSettingMenuEntity.java | 106 --- .../authorization/DataAccessEntity.java | 34 - .../web/entity/authorization/MenuEntity.java | 59 -- .../authorization/MenuGroupBindEntity.java | 93 --- .../entity/authorization/MenuGroupEntity.java | 102 --- .../entity/authorization/OptionalField.java | 38 - .../authorization/ParentPermission.java | 24 - .../authorization/PermissionEntity.java | 70 -- .../web/entity/authorization/RoleEntity.java | 27 - ...impleAuthorizationSettingDetailEntity.java | 51 -- .../SimpleAuthorizationSettingEntity.java | 50 -- .../SimpleAuthorizationSettingMenuEntity.java | 46 -- .../authorization/SimpleMenuEntity.java | 74 -- .../SimpleMenuGroupBindEntity.java | 44 - .../authorization/SimpleMenuGroupEntity.java | 48 -- .../authorization/SimplePermissionEntity.java | 59 -- .../authorization/SimpleRoleEntity.java | 26 - .../authorization/SimpleUserEntity.java | 38 - .../authorization/SimpleUserRoleEntity.java | 28 - .../web/entity/authorization/UserEntity.java | 67 -- .../entity/authorization/UserMenuEntity.java | 39 - .../entity/authorization/UserRoleEntity.java | 17 - .../authorization/UserSettingEntity.java | 54 -- .../bind/BindRoleUserEntity.java | 14 - .../bind/SimpleBindRoleUserEntity.java | 29 - .../AuthorizationSettingMenuService.java | 42 - .../AuthorizationSettingService.java | 80 -- .../AuthorizationSettingTypeSupplier.java | 71 -- .../authorization/DataAccessFactory.java | 17 - .../authorization/MenuGroupBindService.java | 33 - .../authorization/MenuGroupService.java | 40 - .../service/authorization/MenuService.java | 37 - .../authorization/PasswordEncoder.java | 37 - .../PasswordStrengthValidator.java | 12 - .../authorization/PermissionService.java | 14 - .../service/authorization/RoleService.java | 30 - .../authorization/UserMenuManagerService.java | 35 - .../service/authorization/UserService.java | 129 --- .../authorization/UserSettingService.java | 16 - .../authorization/UsernameValidator.java | 12 - .../ClearUserAuthorizationCacheEvent.java | 17 - .../events/TotpTwoFactorCreatedEvent.java | 18 - .../events/UserCreatedEvent.java | 16 - .../events/UserModifiedEvent.java | 23 - .../hsweb-system-authorization-local/pom.xml | 53 -- .../AuthorizationSettingDao.java | 27 - .../AuthorizationSettingDetailDao.java | 27 - .../AuthorizationSettingMenuDao.java | 27 - .../web/dao/authorization/MenuDao.java | 29 - .../dao/authorization/MenuGroupBindDao.java | 27 - .../web/dao/authorization/MenuGroupDao.java | 27 - .../web/dao/authorization/PermissionDao.java | 10 - .../web/dao/authorization/RoleDao.java | 10 - .../web/dao/authorization/UserDao.java | 10 - .../web/dao/authorization/UserRoleDao.java | 22 - .../web/dao/authorization/UserSettingDao.java | 11 - .../authorization/simple/CacheConstants.java | 37 - .../simple/DefaultDataAccessFactory.java | 27 - .../simple/InServiceUserSettingManager.java | 41 - .../simple/SimpleAuthenticationManager.java | 119 --- ...SimpleAuthorizationSettingMenuService.java | 61 -- .../SimpleAuthorizationSettingService.java | 671 ---------------- .../simple/SimpleMenuGroupBindService.java | 53 -- .../simple/SimpleMenuGroupService.java | 152 ---- .../simple/SimpleMenuService.java | 109 --- .../simple/SimplePermissionService.java | 59 -- .../simple/SimpleRoleService.java | 81 -- .../simple/SimpleUserService.java | 310 ------- .../simple/SimpleUserSettingService.java | 108 --- .../CustomUserSqlTermAutoConfiguration.java | 22 - .../simple/terms/UserInRoleSqlTerm.java | 41 - .../simple/totp/Base32String.java | 145 ---- .../simple/totp/HexEncoding.java | 56 -- .../simple/totp/TotpTwoFactorProvider.java | 63 -- .../authorization/simple/totp/TotpUtil.java | 235 ------ .../src/main/resources/hsweb-module.json | 9 - .../AuthorizationSettingDetailMapper.xml | 73 -- .../AuthorizationSettingMapper.xml | 67 -- .../AuthorizationSettingMenuMapper.xml | 74 -- .../authorization/MenuGroupBindMapper.xml | 73 -- .../mappers/authorization/MenuGroupMapper.xml | 70 -- .../mappers/authorization/MenuMapper.xml | 73 -- .../authorization/PermissionMapper.xml | 71 -- .../mappers/authorization/RoleMapper.xml | 66 -- .../mappers/authorization/UserMapper.xml | 70 -- .../mappers/authorization/UserRoleMapper.xml | 60 -- .../authorization/UserSettingMapper.xml | 71 -- .../pom.xml | 99 --- .../AuthorizationAutoConfiguration.java | 97 --- .../starter/AutoSyncPermission.java | 189 ----- ...itional-spring-configuration-metadata.json | 10 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 199 ----- .../authorization/starter/FixBug89Test.groovy | 73 -- .../authorization/starter/FixBug91Test.groovy | 69 -- .../starter/TestApplication.java | 24 - .../starter/TotpTwoFactorProviderTests.groovy | 37 - .../starter/UserSettingControllerTest.groovy | 146 ---- .../starter/AuthorizationSettingTests.java | 88 -- .../starter/AutoSyncPermissionTest.java | 99 --- .../web/authorization/starter/LoginTests.java | 67 -- .../starter/PermissionTests.java | 84 -- .../web/authorization/starter/UserTests.java | 161 ---- .../src/test/resources/application.yml | 29 - .../hsweb-system-authorization-web/pom.xml | 40 - .../AuthorizationSettingController.java | 86 -- .../controller/MenuController.java | 85 -- .../controller/PermissionController.java | 53 -- .../controller/RoleController.java | 72 -- .../controller/UserController.java | 144 ---- .../controller/UserSettingController.java | 81 -- .../controller/model/ActionModel.java | 69 -- .../controller/model/DataAccessModel.java | 78 -- .../controller/model/FieldAccessModel.java | 71 -- .../controller/model/PermissionRoleModel.java | 56 -- .../model/SimplePermissionRoleModel.java | 74 -- .../controller/model/SimpleUserModel.java | 68 -- .../controller/model/UserModel.java | 44 - .../src/main/resources/hsweb-module.json | 9 - .../hsweb-system-authorization/pom.xml | 14 +- .../authorization/entity/ActionEntity.java | 18 + .../authorization/entity/OptionalField.java | 17 + .../entity/ParentPermission.java | 22 + .../entity/PermissionEntity.java | 59 ++ .../authorization/entity/UserEntity.java | 54 ++ .../system/authorization/enums/UserState.java | 22 + hsweb-system/hsweb-system-config/README.md | 5 - .../hsweb-system-config-api/pom.xml | 42 - .../web/entity/config/ConfigContent.java | 77 -- .../web/entity/config/ConfigEntity.java | 93 --- .../web/entity/config/SimpleConfigEntity.java | 148 ---- .../web/service/config/ConfigService.java | 34 - .../hsweb-system-config-local/pom.xml | 51 -- .../web/dao/config/ConfigDao.java | 30 - .../config/simple/SimpleConfigService.java | 91 --- .../mybatis/mappers/config/ConfigMapper.xml | 52 -- .../hsweb-system-config-starter/pom.xml | 62 -- .../starter/ConfigAutoConfiguration.java | 31 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 64 -- .../web/starter/config/ConfigTests.java | 109 --- .../src/test/resources/application.yml | 16 - .../hsweb-system-config-web/pom.xml | 46 -- .../controller/config/ConfigController.java | 59 -- hsweb-system/hsweb-system-config/pom.xml | 40 - .../hsweb-system-dashboard-api/pom.xml | 27 - .../web/dashboard/DashBoardConfigEntity.java | 54 -- .../web/dashboard/DashBoardService.java | 10 - .../dashboard/executor/DashBoardExecutor.java | 8 - .../hsweb-system-dashboard-local/pom.xml | 28 - .../local/DashBoardExecutorStrategy.java | 11 - .../local/DefaultDashBoardService.java | 37 - .../local/DefaultDashBordExecutor.java | 35 - .../local/dao/DashBoardConfigDao.java | 7 - .../strategy/ScriptExecutorStrategy.java | 58 -- .../dashboard/DashBoardConfigMapper.xml | 56 -- .../hsweb-system-dashboard-starter/pom.xml | 76 -- .../starter/DashboardAutoConfiguration.java | 16 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 52 -- .../hsweb-system-dashboard-web/pom.xml | 36 - .../dashboard/DashBoardConfigController.java | 53 -- .../DashBoardUserConfigController.java | 96 --- .../model/UserDashBoardResponse.java | 23 - hsweb-system/hsweb-system-dashboard/pom.xml | 22 - .../hsweb-system-database-manager/README.md | 5 - .../hsweb-system-database-manager-api/pom.xml | 28 - .../manager/DatabaseManagerService.java | 16 - .../database/manager/SqlExecuteRequest.java | 22 - .../database/manager/SqlExecuteResult.java | 23 - .../web/database/manager/SqlInfo.java | 18 - .../exception/SqlExecuteException.java | 17 - .../database/manager/meta/ObjectMetadata.java | 37 - .../manager/meta/table/ColumnMetadata.java | 56 -- .../manager/meta/table/Constraint.java | 50 -- .../manager/meta/table/ForeignConstraint.java | 15 - .../manager/meta/table/TableMetadata.java | 25 - .../AbstractSqlTableMetaDataParser.java | 120 --- .../meta/table/parser/MetaDataParser.java | 13 - .../table/parser/MetaDataParserRegister.java | 8 - .../table/parser/MetaDataParserSupplier.java | 10 - .../table/parser/TableMetaDataParser.java | 7 - .../parser/support/H2TableMetaDataParser.java | 44 - .../support/MysqlTableMetaDataParser.java | 44 - .../support/OracleTableMetaDataParser.java | 45 -- .../support/PostgresTableMetaDataParser.java | 48 -- .../support/SqlServerTableMetaDataParser.java | 43 - .../web/database/manager/sql/SqlExecutor.java | 10 - .../database/manager/sql/TransactionInfo.java | 22 - .../manager/sql/TransactionSqlExecutor.java | 55 -- .../support/H2TableMetaDataParserTest.java | 44 - .../pom.xml | 28 - .../DefaultLocalTransactionExecutor.java | 246 ------ .../simple/NonTransactionSqlExecutor.java | 55 -- .../manager/simple/QueryResult.java | 15 - .../manager/simple/QueryResultWrapper.java | 46 -- .../simple/SimpleDatabaseManagerService.java | 155 ---- .../manager/simple/TransactionExecutor.java | 24 - .../src/main/resources/hsweb-module.json | 8 - .../pom.xml | 44 - .../DataBaseManagerAutoConfiguration.java | 25 - .../TableMetaDataParserAutoConfiguration.java | 85 -- .../main/resources/META-INF/spring.factories | 3 - .../SimpleDatabaseManagerServiceTest.java | 83 -- .../src/test/resources/application.yml | 16 - .../hsweb-system-database-manager-web/pom.xml | 27 - .../web/DataBaseManagerController.java | 159 ---- .../hsweb-system-database-manager/pom.xml | 22 - .../hsweb-system-datasource/README.md | 5 - .../hsweb-system-datasource-api/pom.xml | 24 - .../datasource/DataSourceConfigEntity.java | 72 -- .../SimpleDataSourceConfigEntity.java | 25 - .../datasource/DataSourceConfigService.java | 13 - .../hsweb-system-datasource-local/pom.xml | 46 -- .../dao/datasource/DataSourceConfigDao.java | 11 - .../simple/InDBDataSourceRepository.java | 73 -- .../simple/InDBDynamicDataSourceConfig.java | 33 - .../simple/InDBDynamicDataSourceService.java | 134 ---- .../InDBJtaDynamicDataSourceService.java | 87 -- .../simple/SimpleDataSourceConfigService.java | 35 - .../datasource/DataSourceConfigMapper.xml | 50 -- .../hsweb-system-datasource-starter/pom.xml | 80 -- ...nDBDynamicDataSourceAutoConfiguration.java | 73 -- .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 44 - .../hsweb-system-datasource-web/pom.xml | 34 - .../DataSourceConfigController.java | 36 - hsweb-system/hsweb-system-datasource/pom.xml | 26 - hsweb-system/hsweb-system-dev-tools/pom.xml | 49 -- .../dev/tools/DevToolsAutoConfiguration.java | 27 - .../web/dev/tools/EnableDevTools.java | 17 - .../web/dev/tools/reader/FileInfo.java | 45 -- .../web/FileManagerDevToolsController.java | 87 -- .../web/dev/tools/writer/ClassWriter.java | 79 -- .../web/dev/tools/writer/CodeWriter.java | 11 - .../dev/tools/writer/DefaultCodeWriter.java | 61 -- .../web/dev/tools/writer/GeneratedCode.java | 31 - .../hsweb-system-dictionary/README.md | 7 - .../hsweb-system-dictionary-api/pom.xml | 27 - .../web/dictionary/api/DictionaryInfo.java | 41 - .../dictionary/api/DictionaryInfoService.java | 15 - .../dictionary/api/DictionaryItemService.java | 34 - .../web/dictionary/api/DictionaryParser.java | 43 - .../api/DictionaryParserService.java | 33 - .../web/dictionary/api/DictionaryService.java | 34 - .../web/dictionary/api/DictionaryWrapper.java | 28 - .../api/builder/DictionaryParserBuilder.java | 11 - .../api/entity/DictionaryEntity.java | 102 --- .../api/entity/DictionaryItemEntity.java | 178 ---- .../api/entity/DictionaryParserEntity.java | 138 ---- .../api/entity/SimpleDictionaryEntity.java | 149 ---- .../entity/SimpleDictionaryItemEntity.java | 76 -- .../entity/SimpleDictionaryParserEntity.java | 189 ----- .../api/events/ClearDictionaryCacheEvent.java | 14 - .../api/parser/SingleDictParser.java | 17 - .../hsweb-system-dictionary-local/pom.xml | 32 - .../simple/BoostDictDefineRepository.java | 94 --- .../simple/DefaultDictionaryHelper.java | 12 - .../simple/DefaultDictionaryWrapper.java | 164 ---- .../simple/DictionaryWrapperObject.java | 13 - .../simple/SimpleDictionaryItemService.java | 92 --- .../simple/SimpleDictionaryParser.java | 117 --- .../simple/SimpleDictionaryParserService.java | 64 -- .../simple/SimpleDictionaryService.java | 74 -- .../SimpleDictionaryParserBuilder.java | 30 - .../dictionary/simple/dao/DictionaryDao.java | 27 - .../simple/dao/DictionaryItemDao.java | 27 - .../simple/dao/DictionaryParserDao.java | 27 - .../simple/parser/DictParserFormat.java | 79 -- .../simple/parser/DictParserFormatter.java | 12 - .../simple/parser/FormatterResult.java | 39 - .../simple/parser/ScriptSingleDictParser.java | 38 - .../parser/SimpleDictParserFormatter.java | 72 -- .../simple/parser/SimpleSingleDictParser.java | 276 ------- .../dictionary/DictionaryItemMapper.xml | 75 -- .../mappers/dictionary/DictionaryMapper.xml | 67 -- .../dictionary/DictionaryParserMapper.xml | 70 -- .../simple/DefaultDictionaryWrapperTest.java | 79 -- .../web/dictionary/simple/EmptyDictBean.java | 12 - .../web/dictionary/simple/TestBean.java | 20 - .../web/dictionary/simple/TestDict.java | 86 -- .../hsweb-system-dictionary-starter/pom.xml | 85 -- .../DictionaryFactoryAutoConfiguration.java | 33 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 99 --- .../starter/DictionaryParserTests.java | 85 -- .../dictionary/starter/DictionaryTests.java | 114 --- .../src/test/resources/application.yml | 13 - .../hsweb-system-dictionary-web/pom.xml | 32 - .../dictionary/DictionaryController.java | 94 --- .../dictionary/DictionaryItemController.java | 60 -- .../DictionaryParserController.java | 58 -- hsweb-system/hsweb-system-dictionary/pom.xml | 39 - .../hsweb-system-dynamic-form/README.md | 5 - .../hsweb-system-dynamic-form-api/pom.xml | 24 - .../web/entity/form/DictConfig.java | 31 - .../form/DynamicFormColumnBindEntity.java | 42 - .../entity/form/DynamicFormColumnEntity.java | 205 ----- .../form/DynamicFormDeployLogEntity.java | 78 -- .../web/entity/form/DynamicFormEntity.java | 222 ----- .../form/SimpleDynamicFormColumnEntity.java | 45 -- .../SimpleDynamicFormDeployLogEntity.java | 95 --- .../entity/form/SimpleDynamicFormEntity.java | 47 -- .../web/service/form/DatabaseRepository.java | 18 - .../form/DynamicFormColumnService.java | 13 - .../form/DynamicFormDeployLogService.java | 20 - .../form/DynamicFormOperationService.java | 39 - .../web/service/form/DynamicFormService.java | 43 - .../web/service/form/FormDeployService.java | 18 - .../service/form/OptionalConvertBuilder.java | 16 - .../form/events/DatabaseInitEvent.java | 17 - .../events/FormDataInsertBeforeEvent.java | 20 - .../form/events/FormDataQueryBeforeEvent.java | 21 - .../events/FormDataUpdateBeforeEvent.java | 21 - .../service/form/events/FormDeployEvent.java | 14 - .../form/events/FormUnDeployEvent.java | 14 - .../initialize/ColumnInitializeContext.java | 13 - .../DynamicFormInitializeCustomizer.java | 12 - .../initialize/TableInitializeContext.java | 18 - .../hsweb-system-dynamic-form-local/pom.xml | 58 -- .../web/dao/form/DynamicFormColumnDao.java | 11 - .../web/dao/form/DynamicFormDao.java | 15 - .../web/dao/form/DynamicFormDeployLogDao.java | 11 - .../form/simple/DynamicFormException.java | 17 - .../form/simple/SimpleDatabaseRepository.java | 114 --- .../SimpleDynamicFormColumnService.java | 32 - .../SimpleDynamicFormDeployLogService.java | 94 --- .../SimpleDynamicFormOperationService.java | 249 ------ .../form/simple/SimpleDynamicFormService.java | 758 ------------------ .../form/simple/cluster/ClusterDatabase.java | 51 -- .../simple/cluster/ClusterDatabaseInit.java | 49 -- .../simple/convert/SmartValueConverter.java | 34 - .../dict/DefaultOptionalConvertBuilder.java | 47 -- ...tionaryOptionalConvertBuilderStrategy.java | 79 -- .../simple/dict/EnumDictOptionConverter.java | 80 -- .../simple/dict/EnumDictValueConverter.java | 128 --- .../dict/OptionalConvertBuilderStrategy.java | 27 - .../validator/DynamicBeanValidator.java | 30 - .../DynamicBeanValidatorFactory.java | 183 ----- .../validator/JSR303AnnotationInfo.java | 14 - .../JSR303AnnotationParserStrategy.java | 14 - .../form/simple/validator/MapBean.java | 110 --- .../validator/jsr303/AbstractStrategy.java | 117 --- .../validator/jsr303/EmailStrategy.java | 28 - .../validator/jsr303/LengthStrategy.java | 27 - .../validator/jsr303/NotBlankStrategy.java | 21 - .../validator/jsr303/NotNullStrategy.java | 20 - .../validator/jsr303/RangeStrategy.java | 26 - .../mappers/form/DynamicFormColumnMapper.xml | 60 -- .../form/DynamicFormDeployLogMapper.xml | 50 -- .../mappers/form/DynamicFormMapper.xml | 66 -- .../hsweb-system-dynamic-form-starter/pom.xml | 77 -- .../form/DynamicFormAutoConfiguration.java | 35 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 89 -- .../simple/SimpleDynamicFormServiceTest.java | 107 --- .../src/test/resources/application.yml | 16 - .../hsweb-system-dynamic-form-web/pom.xml | 39 - .../DynamicFormAuthorizeDefinitionParser.java | 32 - .../form/DynamicFormColumnController.java | 65 -- .../form/DynamicFormController.java | 107 --- .../form/DynamicFormDeployLogController.java | 46 -- .../form/DynamicFormOperationController.java | 119 --- .../hsweb-system-dynamic-form/pom.xml | 23 - hsweb-system/hsweb-system-file/README.md | 74 -- .../hsweb-system-file-api/pom.xml | 23 - .../web/entity/file/FileInfoEntity.java | 115 --- .../web/entity/file/SimpleFileInfoEntity.java | 36 - .../web/service/file/FileInfoService.java | 15 - .../web/service/file/FileService.java | 58 -- .../hsweb-system-file-local/pom.xml | 39 - .../web/dao/file/FileInfoDao.java | 11 - .../service/file/fastdfs/FdfsFileService.java | 131 --- .../service/file/simple/LocalFileService.java | 224 ------ .../file/simple/SimpleFileInfoService.java | 105 --- .../mybatis/mappers/file/FileInfoMapper.xml | 54 -- .../hsweb-system-file-oauth2/pom.xml | 29 - .../oauth2/OAuth2FileAutoConfiguration.java | 28 - .../file/oauth2/OAuth2FileInfoService.java | 50 -- .../file/oauth2/OAuth2FileService.java | 86 -- .../main/resources/META-INF/spring.factories | 3 - .../hsweb-system-file-starter/pom.xml | 84 -- .../FastdfsServiceAutoConfiguration.java | 22 - .../file/starter/FileAutoConfiguration.java | 26 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 51 -- .../web/service/file/FileUploadTests.java | 64 -- .../web/service/file/FixBug93Test.java | 32 - .../src/test/resources/application.yml | 30 - .../hsweb-system-file-web/pom.xml | 43 - .../web/controller/file/FileController.java | 304 ------- .../controller/file/FileInfoController.java | 37 - hsweb-system/hsweb-system-file/pom.xml | 23 - .../hsweb-system-oauth2-client-api/pom.xml | 30 - .../client/OAuth2ServerConfigEntity.java | 166 ---- .../oauth2/client/OAuth2UserTokenEntity.java | 184 ----- .../SimpleOAuth2ServerConfigEntity.java | 196 ----- .../client/SimpleOAuth2UserTokenEntity.java | 219 ----- .../client/OAuth2ServerConfigService.java | 29 - .../oauth2/client/OAuth2UserTokenService.java | 30 - .../hsweb-system-oauth2-client-local/pom.xml | 40 - .../server/client/OAuth2ServerConfigDao.java | 27 - .../server/client/OAuth2UserTokenDao.java | 27 - .../SimpleOAuth2ServerConfigService.java | 97 --- .../simple/SimpleOAuth2UserTokenService.java | 158 ---- .../client/OAuth2ServerConfigMapper.xml | 72 -- .../oauth2/client/OAuth2UserTokenMapper.xml | 72 -- .../pom.xml | 85 -- .../OAuth2ClientAutoConfiguration.java | 35 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 87 -- .../client/OAuth2ServerConfigTests.java | 120 --- .../client/QQResponseConvertSupport.java | 57 -- .../oauth2/client/QQResponseJudgeSupport.java | 88 -- .../src/test/resources/application.yml | 13 - .../hsweb-system-oauth2-client-web/pom.xml | 37 - .../controller/OAuth2ClientController.java | 118 --- .../OAuth2ServerConfigController.java | 59 -- .../controller/OAuth2UserTokenController.java | 56 -- .../hsweb-system-oauth2-client/pom.xml | 40 - .../hsweb-system-oauth2-server-local/pom.xml | 42 - .../oauth2/server/AuthorizationCodeDao.java | 34 - .../dao/oauth2/server/OAuth2AccessDao.java | 35 - .../dao/oauth2/server/OAuth2ClientDao.java | 30 - .../server/AuthorizationCodeEntity.java | 29 - .../oauth2/server/OAuth2AccessEntity.java | 28 - .../oauth2/server/OAuth2ClientEntity.java | 81 -- .../server/SimpleAuthorizationCodeEntity.java | 99 --- .../server/SimpleOAuth2AccessEntity.java | 53 -- .../server/SimpleOAuth2ClientEntity.java | 58 -- .../oauth2/server/simple/CodeGenerator.java | 28 - .../simple/SimpleAccessTokenService.java | 128 --- .../SimpleAuthorizationCodeService.java | 80 -- .../simple/SimpleClientConfigRepository.java | 104 --- .../server/simple/SimplePasswordService.java | 49 -- .../oauth2/server/simple/TokenGenerator.java | 28 - .../mappers/oauth2/OAuth2AccessMapper.xml | 67 -- .../mappers/oauth2/OAuth2ClientMapper.xml | 75 -- .../mappers/oauth2/OAuth2CodeMapper.xml | 60 -- .../pom.xml | 70 -- .../web/oauth2/OAuth2GrantEventListener.java | 26 - .../OAuth2GranterAutoConfiguration.java | 183 ----- .../authorization/OAuth2UserTokenParser.java | 77 -- .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 95 --- .../hsweb-system-oauth2-server-web/pom.xml | 39 - .../controller/OAuth2AuthorizeController.java | 106 --- .../OAuth2ClientConfigController.java | 71 -- .../controller/OAuth2TokenController.java | 114 --- .../controller/OAuth2UserInfoController.java | 78 -- .../oauth2/model/AccessTokenModel.java | 77 -- .../oauth2/model/AuthorizationCodeModel.java | 55 -- .../model/ImplicitAccessTokenModel.java | 77 -- .../hsweb-system-oauth2-server/pom.xml | 40 - .../hsweb-system-organizational/README.md | 29 - .../hsweb-system-organizational-api/pom.xml | 29 - .../organizational/DepartmentEntity.java | 108 --- .../entity/organizational/DistrictEntity.java | 126 --- .../organizational/OrganizationalEntity.java | 132 --- .../organizational/PersonAuthBindEntity.java | 35 - .../entity/organizational/PersonEntity.java | 160 ---- .../organizational/PersonPositionEntity.java | 42 - .../organizational/PersonUserEntity.java | 29 - .../entity/organizational/PositionEntity.java | 108 --- .../organizational/RelationDefineEntity.java | 57 -- .../organizational/RelationInfoEntity.java | 99 --- .../SimpleDepartmentEntity.java | 47 -- .../organizational/SimpleDistrictEntity.java | 34 - .../SimpleOrganizationalEntity.java | 63 -- .../SimplePersonAuthBindEntity.java | 32 - .../organizational/SimplePersonEntity.java | 58 -- .../SimplePersonPositionEntity.java | 41 - .../organizational/SimplePositionEntity.java | 49 -- .../SimpleRelationDefineEntity.java | 26 - .../SimpleRelationInfoEntity.java | 32 - .../organizational/DepartmentService.java | 42 - .../organizational/DistrictService.java | 21 - .../organizational/OrganizationalService.java | 42 - .../service/organizational/PersonService.java | 55 -- .../organizational/PositionService.java | 30 - .../organizational/RelationDefineService.java | 13 - .../organizational/RelationInfoService.java | 15 - .../event/ClearPersonCacheEvent.java | 9 - .../README.md | 34 - .../pom.xml | 47 -- ...efaultPersonnelAuthenticationSupplier.java | 41 - .../authorization/Department.java | 17 - .../authorization/District.java | 31 - .../authorization/Organization.java | 36 - ...ationalAuthorizationAutoConfiguration.java | 112 --- .../authorization/Personnel.java | 22 - .../PersonnelAuthentication.java | 150 ---- .../PersonnelAuthenticationHolder.java | 72 -- .../PersonnelAuthenticationManager.java | 12 - ...nnelAuthenticationSettingTypeSupplier.java | 64 -- .../PersonnelAuthenticationSupplier.java | 15 - .../authorization/Position.java | 18 - .../authorization/TreeNode.java | 102 --- .../authorization/access/DataAccessType.java | 126 --- .../access/DepartmentAttachEntity.java | 28 - .../access/DistrictAttachEntity.java | 18 - .../authorization/access/OrgAttachEntity.java | 21 - .../access/PersonAttachEntity.java | 19 - .../access/PositionAttachEntity.java | 18 - .../relation/DepartmentRelations.java | 27 - .../relation/LinkedRelations.java | 153 ---- .../authorization/relation/OrgRelations.java | 28 - .../relation/PersonRelations.java | 15 - .../authorization/relation/Relation.java | 150 ---- .../relation/RelationTargetHolder.java | 26 - .../relation/RelationTargetSupplier.java | 14 - .../RelationTargetSupplierAutoRegister.java | 23 - .../authorization/relation/Relations.java | 217 ----- .../relation/RelationsManager.java | 26 - .../relation/SimpleRelation.java | 26 - .../relation/SimpleRelations.java | 32 - .../authorization/simple/CustomScope.java | 42 - .../CustomScopeDataAccessConfigConvert.java | 37 - .../simple/ScopeByUserDataAccessConfig.java | 46 -- .../ScopeByUserDataAccessConfigConvert.java | 35 - .../simple/ScopeDataAccessConfigConvert.java | 36 - .../SimpleCustomScopeDataAccessConfig.java | 29 - .../simple/SimpleDepartment.java | 24 - .../authorization/simple/SimpleDistrict.java | 23 - .../simple/SimpleOrganization.java | 25 - .../authorization/simple/SimplePersonnel.java | 21 - .../simple/SimplePersonnelAuthentication.java | 98 --- .../SimplePersonnelAuthorizationBuilder.java | 56 -- .../authorization/simple/SimplePosition.java | 27 - .../simple/SimpleScopeDataAccessConfig.java | 64 -- .../AbstractScopeDataAccessHandler.java | 183 ----- .../simple/handler/CustomScopeHandler.java | 41 - .../DepartmentScopeDataAccessHandler.java | 61 -- .../DistrictScopeDataAccessHandler.java | 59 -- .../handler/OrgScopeDataAccessHandler.java | 61 -- .../handler/PersonScopeDataAccessHandler.java | 63 -- .../PositionScopeDataAccessHandler.java | 61 -- .../simple/handler/ScopeByUserHandler.java | 476 ----------- .../main/resources/META-INF/spring.factories | 3 - ...plePersonnelAuthenticationBuilderTest.java | 35 - .../hsweb-system-organizational-local/pom.xml | 42 - .../web/dao/organizational/DepartmentDao.java | 27 - .../web/dao/organizational/DistrictDao.java | 11 - .../dao/organizational/OrganizationalDao.java | 27 - .../web/dao/organizational/PersonDao.java | 33 - .../dao/organizational/PersonPositionDao.java | 34 - .../web/dao/organizational/PositionDao.java | 27 - .../dao/organizational/RelationDefineDao.java | 11 - .../dao/organizational/RelationInfoDao.java | 11 - .../simple/SimpleDepartmentService.java | 147 ---- .../simple/SimpleDistrictService.java | 140 ---- .../simple/SimpleOrganizationalService.java | 138 ---- .../simple/SimplePersonService.java | 539 ------------- .../simple/SimplePositionService.java | 87 -- .../simple/SimpleRelationDefineService.java | 59 -- .../simple/SimpleRelationInfoService.java | 71 -- .../relations/DefaultDepartmentRelations.java | 241 ------ .../relations/DefaultLinkedRelations.java | 138 ---- .../simple/relations/DefaultOrgRelations.java | 48 -- .../relations/DefaultPersonRelations.java | 46 -- .../relations/DefaultRelationsManager.java | 48 -- .../simple/relations/ServiceContext.java | 31 - .../terms/CustomSqlTermConfiguration.java | 386 --------- .../simple/terms/InServiceTreeInSqlTerm.java | 52 -- .../simple/terms/UserInDepartmentSqlTerm.java | 64 -- .../simple/terms/UserInDistSqlTerm.java | 65 -- .../simple/terms/UserInOrgSqlTerm.java | 63 -- .../simple/terms/UserInPositionSqlTerm.java | 67 -- .../simple/terms/UserInSqlTerm.java | 128 --- .../organizational/DepartmentMapper.xml | 69 -- .../mappers/organizational/DistrictMapper.xml | 55 -- .../organizational/OrganizationalMapper.xml | 71 -- .../mappers/organizational/PersonMapper.xml | 77 -- .../organizational/PersonPositionMapper.xml | 57 -- .../mappers/organizational/PositionMapper.xml | 69 -- .../organizational/RelationDefineMapper.xml | 48 -- .../organizational/RelationInfoMapper.xml | 51 -- .../pom.xml | 85 -- .../AuthorizationAutoConfigration.java | 31 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 167 ---- .../organizational/DepartmentTests.java | 84 -- .../organizational/OrganizationalTests.java | 84 -- .../starter/organizational/PersonTests.java | 84 -- .../starter/organizational/PositionTests.java | 84 -- .../RelationsManagerTests.groovy | 193 ----- .../organizational/TestApplication.java | 14 - .../src/test/resources/application.yml | 16 - .../hsweb-system-organizational-web/pom.xml | 32 - .../organizational/DepartmentController.java | 55 -- .../organizational/DistrictController.java | 93 --- .../OrganizationalController.java | 86 -- .../organizational/PersonController.java | 149 ---- .../organizational/PositionController.java | 54 -- .../RelationDefineController.java | 36 - .../RelationInfoController.java | 36 - .../hsweb-system-organizational/pom.xml | 40 - hsweb-system/hsweb-system-schedule/README.md | 4 - .../hsweb-system-schedule-api/pom.xml | 26 - .../entity/schedule/ScheduleJobEntity.java | 141 ---- .../schedule/SimpleScheduleJobEntity.java | 163 ---- .../service/schedule/ScheduleJobExecutor.java | 10 - .../service/schedule/ScheduleJobService.java | 16 - .../schedule/ScheduleTriggerBuilder.java | 12 - .../hsweb-system-schedule-local/pom.xml | 33 - .../web/dao/schedule/ScheduleJobDao.java | 11 - .../DefaultScriptScheduleJobExecutor.java | 54 -- .../service/schedule/simple/DynamicJob.java | 19 - .../schedule/simple/DynamicJobFactory.java | 42 - .../simple/SimpleScheduleJobService.java | 157 ---- .../simple/SmartScheduleTriggerBuilder.java | 28 - .../mappers/schedule/ScheduleJobMapper.xml | 54 -- .../hsweb-system-schedule-starter/pom.xml | 85 -- .../configuration/AutoCreateTable.java | 53 -- .../ScheduleAutoConfiguration.java | 93 --- .../configuration/SchedulerProperties.java | 43 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 50 -- .../resources/quartz/sql/quartz-h2-create.sql | 247 ------ .../quartz/sql/quartz-mysql-create.sql | 143 ---- .../quartz/sql/quartz-oracle-create.sql | 157 ---- .../quartz/sql/quartz-postgresql-create.sql | 171 ---- .../schedule/test/DynamicScheduleTests.java | 57 -- .../web/schedule/test/ScheduleTests.java | 38 - .../src/test/resources/application.yml | 24 - .../hsweb-system-schedule-web/pom.xml | 31 - .../schedule/ScheduleJobController.java | 72 -- hsweb-system/hsweb-system-schedule/pom.xml | 29 - hsweb-system/hsweb-system-script/README.md | 4 - .../hsweb-system-script-api/pom.xml | 21 - .../web/entity/script/ScriptEntity.java | 113 --- .../web/entity/script/SimpleScriptEntity.java | 129 --- .../service/script/ScriptExecutorService.java | 11 - .../web/service/script/ScriptService.java | 13 - .../hsweb-system-script-local/pom.xml | 31 - .../web/dao/script/ScriptDao.java | 11 - .../simple/DefaultScriptExecutorService.java | 48 -- .../script/simple/SimpleScriptService.java | 35 - .../mybatis/mappers/script/ScriptMapper.xml | 52 -- .../hsweb-system-script-starter/pom.xml | 71 -- .../DynamicScriptAutoConfiguration.java | 23 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 47 -- .../web/workflow/flowable/ControllerTest.java | 34 - .../src/test/resources/application.yml | 21 - .../hsweb-system-script-web/pom.xml | 31 - .../controller/script/ScriptController.java | 69 -- hsweb-system/hsweb-system-script/pom.xml | 22 - hsweb-system/hsweb-system-template/README.md | 4 - .../hsweb-system-template-api/pom.xml | 22 - .../entity/template/SimpleTemplateEntity.java | 112 --- .../web/entity/template/TemplateEntity.java | 106 --- .../template/TemplateRendeFacotry.java | 15 - .../web/service/template/TemplateRender.java | 11 - .../web/service/template/TemplateService.java | 13 - .../hsweb-system-template-local/pom.xml | 31 - .../web/dao/template/TemplateDao.java | 11 - .../simple/SimpleTemplateService.java | 51 -- .../mappers/template/TemplateMapper.xml | 51 -- .../hsweb-system-template-starter/pom.xml | 71 -- .../starter/TemplateAutoConfiguration.java | 14 - .../main/resources/META-INF/spring.factories | 3 - .../src/main/resources/hsweb-starter.js | 45 -- .../hsweb-system-template-web/pom.xml | 31 - .../template/TemplateController.java | 36 - hsweb-system/hsweb-system-template/pom.xml | 21 - hsweb-system/hsweb-system-workflow/README.md | 19 - .../hsweb-system-workflow-local/pom.xml | 189 ----- .../web/workflow/dao/ActivityConfigDao.java | 11 - .../workflow/dao/ProcessDefineConfigDao.java | 12 - .../web/workflow/dao/ProcessHistoryDao.java | 11 - .../dao/entity/ActivityConfigEntity.java | 58 -- .../workflow/dao/entity/ListenerConfig.java | 19 - .../dao/entity/ProcessDefineConfigEntity.java | 54 -- .../dao/entity/ProcessHistoryEntity.java | 56 -- .../dimension/CandidateDimension.java | 16 - .../dimension/CandidateDimensionParser.java | 10 - .../DefaultCandidateDimensionParser.java | 70 -- .../DefaultPermissionDimensionParser.java | 18 - .../workflow/dimension/DimensionContext.java | 32 - .../dimension/PermissionDimensionParser.java | 12 - .../CandidateDimensionParserStrategy.java | 43 - ...tmentCandidateDimensionParserStrategy.java | 47 -- .../OrgCandidateDimensionParserStrategy.java | 45 -- ...itionCandidateDimensionParserStrategy.java | 45 -- .../RoleCandidateDimensionParserStrategy.java | 38 - ...ScriptCandiateDimensionParserStrategy.java | 111 --- .../UserCandidateDimensionParserStrategy.java | 24 - .../web/workflow/enums/ModelType.java | 9 - .../flowable/FlowableAutoConfiguration.java | 71 -- .../flowable/utils/ActivitiUserUtil.java | 44 - .../utils/CustomGroupEntityManager.java | 57 -- .../CustomGroupEntityManagerFactory.java | 32 - .../utils/CustomUserEntityManager.java | 68 -- .../utils/CustomUserEntityManagerFactory.java | 24 - .../workflow/flowable/utils/JumpTaskCmd.java | 41 - .../GlobalEventListenerDispatcher.java | 87 -- .../web/workflow/listener/ProcessEvent.java | 13 - .../listener/ProcessEventListener.java | 11 - .../web/workflow/listener/TaskEvent.java | 14 - .../workflow/listener/TaskEventListener.java | 9 - .../service/ActivityConfigService.java | 17 - .../workflow/service/BpmActivityService.java | 109 --- .../workflow/service/BpmProcessService.java | 82 -- .../web/workflow/service/BpmTaskService.java | 154 ---- .../service/ProcessDefineConfigService.java | 18 - .../service/ProcessHistoryService.java | 12 - .../workflow/service/WorkFlowFormService.java | 25 - .../service/config/ActivityConfiguration.java | 42 - .../service/config/CandidateInfo.java | 23 - .../service/config/ProcessConfiguration.java | 22 - .../config/ProcessConfigurationService.java | 10 - .../service/imp/AbstractFlowableService.java | 28 - .../imp/ActivityConfigServiceImpl.java | 108 --- .../service/imp/BpmActivityServiceImpl.java | 256 ------ .../service/imp/BpmProcessServiceImpl.java | 166 ---- .../service/imp/BpmTaskServiceImpl.java | 533 ------------ .../imp/ProcessConfigurationServiceImpl.java | 248 ------ .../imp/ProcessDefineConfigServiceImpl.java | 110 --- .../imp/ProcessHistoryServiceImpl.java | 40 - .../service/imp/WorkFlowFormServiceImpl.java | 296 ------- .../service/request/CompleteTaskRequest.java | 58 -- .../service/request/JumpTaskRequest.java | 39 - .../service/request/RejectTaskRequest.java | 36 - .../service/request/SaveFormRequest.java | 30 - .../service/request/StartProcessRequest.java | 67 -- .../web/workflow/terms/ClaimSqlTerm.java | 42 - .../web/workflow/terms/CompletedSqlTerm.java | 42 - .../terms/ProcessParticipateSqlTerm.java | 45 -- .../web/workflow/terms/TodoSqlTerm.java | 42 - .../terms/WorkflowTermsAutoConfiguration.java | 33 - .../web/workflow/util/QueryUtils.java | 97 --- .../web/FlowableDeploymentController.java | 216 ----- .../web/FlowableModelManagerController.java | 241 ------ .../web/FlowableProcessController.java | 388 --------- .../web/ProcessActivityConfigController.java | 45 -- .../web/ProcessDefineConfigController.java | 32 - ...rocessDefinitionDiagramLayoutResource.java | 498 ------------ ...rocessDefinitionDiagramLayoutResource.java | 24 - .../ProcessInstanceDiagramLayoutResource.java | 26 - .../ProcessInstanceHighlightsResource.java | 259 ------ .../web/request/ModelCreateRequest.java | 22 - .../workflow/web/response/ActivityInfo.java | 38 - .../web/response/CandidateDetail.java | 59 -- .../web/response/ProcessDefinitionInfo.java | 40 - .../workflow/web/response/ProcessInfo.java | 46 -- .../web/workflow/web/response/TaskInfo.java | 44 - .../src/main/resources/hsweb-starter.js | 92 --- .../mappers/workflow/ActivityConfigMapper.xml | 57 -- .../workflow/ProcessDefineConfigMapper.xml | 58 -- .../mappers/workflow/ProcessHistoryMapper.xml | 61 -- .../src/main/resources/processes/README.md | 0 ...DefaultCandidateDimensionParserTest.groovy | 78 -- .../workflow/flowable/TestApplication.java | 13 - .../flowable/WorkFlowModelTests.groovy | 64 -- .../flowable/WorkFlowProcessTests.groovy | 86 -- .../src/test/resources/application-dev.yml | 6 - .../src/test/resources/application.yml | 21 - .../src/test/resources/processes/README.md | 0 .../processes/SimpleProcess.bpmn20.xml | 76 -- .../hsweb-system-workflow-starter/pom.xml | 83 -- .../starter/WorkFlowAutoConfiguration.java | 17 - .../main/resources/META-INF/spring.factories | 3 - hsweb-system/hsweb-system-workflow/pom.xml | 25 - hsweb-tests/pom.xml | 76 -- .../tests/HswebCrudWebApiSpecification.groovy | 121 --- .../web/tests/HswebSpecification.groovy | 36 - .../web/tests/HswebTestApplication.groovy | 15 - .../web/tests/SimpleWebApplicationTests.java | 117 --- .../hswebframework/web/tests/TestProcess.java | 8 - .../web/tests/TestProcessSetUp.java | 7 - .../hswebframework/web/tests/TestResult.java | 30 - .../HswebCrudWebApiSpecificationTest.groovy | 88 -- .../web/tests/TestController.java | 101 --- .../hswebframework/web/tests/TestEntity.java | 10 - .../src/test/resources/application.yml | 19 - hsweb-thirdparty/README.md | 6 - .../hsweb-thirdparty-ueditor/README.md | 42 - .../hsweb-thirdparty-ueditor/pom.xml | 49 -- .../java/com/baidu/ueditor/ActionEnter.java | 121 --- .../java/com/baidu/ueditor/ConfigManager.java | 167 ---- .../main/java/com/baidu/ueditor/Context.java | 9 - .../main/java/com/baidu/ueditor/Encoder.java | 24 - .../java/com/baidu/ueditor/PathFormat.java | 151 ---- .../com/baidu/ueditor/define/ActionMap.java | 43 - .../com/baidu/ueditor/define/ActionState.java | 5 - .../com/baidu/ueditor/define/AppInfo.java | 81 -- .../com/baidu/ueditor/define/BaseState.java | 78 -- .../com/baidu/ueditor/define/FileType.java | 35 - .../com/baidu/ueditor/define/MIMEType.java | 22 - .../com/baidu/ueditor/define/MultiState.java | 76 -- .../java/com/baidu/ueditor/define/State.java | 18 - .../com/baidu/ueditor/hunter/FileManager.java | 77 -- .../com/baidu/ueditor/hunter/ImageHunter.java | 129 --- .../baidu/ueditor/upload/Base64Uploader.java | 51 -- .../baidu/ueditor/upload/BinaryUploader.java | 89 -- .../baidu/ueditor/upload/StorageManager.java | 147 ---- .../com/baidu/ueditor/upload/Uploader.java | 30 - .../ueditor/UeditorAutoConfiguration.java | 13 - .../thirdpart/ueditor/UeditorController.java | 90 --- ...itional-spring-configuration-metadata.json | 10 - .../main/resources/META-INF/spring.factories | 3 - .../baidu/ueditor/define/MultiStateTest.java | 20 - hsweb-thirdparty/pom.xml | 19 - pom.xml | 10 +- 967 files changed, 1122 insertions(+), 56087 deletions(-) delete mode 100644 hsweb-boost/README.md delete mode 100644 hsweb-boost/hsweb-boost-aop/README.md delete mode 100644 hsweb-boost/hsweb-boost-aop/pom.xml delete mode 100644 hsweb-boost/hsweb-boost-excel/pom.xml delete mode 100644 hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/DefaultExcelImporter.java delete mode 100644 hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/Excel.java delete mode 100644 hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelCellConverter.java delete mode 100644 hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelImporter.java delete mode 100644 hsweb-boost/hsweb-boost-excel/src/test/java/org/hswebframework/web/excel/DefaultExcelImporterTest.java delete mode 100644 hsweb-boost/hsweb-boost-excel/src/test/resources/test.xls delete mode 100644 hsweb-boost/hsweb-boost-ftp/pom.xml delete mode 100644 hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/DefaultFTPOperation.java delete mode 100644 hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/FTPOperation.java delete mode 100644 hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientFactory.java delete mode 100644 hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientPool.java delete mode 100644 hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientProperties.java delete mode 100644 hsweb-boost/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-bean/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/Bean.java delete mode 100644 hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidator.java delete mode 100644 hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidatorAutoConfiguration.java delete mode 100644 hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/ValidateBean.java delete mode 100644 hsweb-commons/hsweb-commons-bean/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/BeanValidatorTest.groovy delete mode 100644 hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/TestBean.java delete mode 100644 hsweb-commons/hsweb-commons-controller/README.md delete mode 100644 hsweb-commons/hsweb-commons-controller/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CreateController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CrudController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/DeleteController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/QueryController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleCrudController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleGenericEntityController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/UpdateController.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/MapResponseMessage.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java delete mode 100644 hsweb-commons/hsweb-commons-controller/src/main/resources/hsweb-module.json rename hsweb-commons/{hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Service.java => hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/Entity.java} (78%) create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/LogicalDeleteEntity.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordCreationEntity.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordModifierEntity.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultMapperFactory.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultPropertyCopier.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/EntityFactory.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/MapperEntityFactory.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/PropertyCopier.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityCreatedEvent.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityModifyEvent.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/CrudService.java create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/DefaultCrudService.java delete mode 100644 hsweb-commons/hsweb-commons-model/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-model/src/main/java/org/hswebframework/web/commons/model/Model.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CreateEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CrudService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/DeleteService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/InsertService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryByEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/TreeService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Validator.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/README.md delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/pom.xml delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLDeleteService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLQueryService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLUpdateService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDeleteService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidator.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictGenericEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictTreeSortService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheGenericEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheTreeSortService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericsPayloadApplicationEvent.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/resources/hsweb-module.json delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/AbstractTreeSortServiceTests.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidatorTest.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTestService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTreeTestService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTestService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTests.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTreeTestService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/GenericEntityServiceTest.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/ModifyEventTests.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/SpringTestApplication.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntity.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity2.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestTreeEntityService.java delete mode 100644 hsweb-commons/hsweb-commons-service/pom.xml delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/Describe.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/ScriptScope.java rename {hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context => hsweb-core/src/main/java/org/hswebframework/web/aop}/MethodInterceptorContext.java (97%) rename {hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context => hsweb-core/src/main/java/org/hswebframework/web/aop}/MethodInterceptorHolder.java (81%) delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/audit/Audit.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/audit/AuditFieldMeta.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMeta.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMetaParser.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/audit/Strategy.java create mode 100644 hsweb-core/src/main/java/org/hswebframework/web/context/Context.java create mode 100644 hsweb-core/src/main/java/org/hswebframework/web/context/ContextKey.java create mode 100644 hsweb-core/src/main/java/org/hswebframework/web/context/ContextUtils.java create mode 100644 hsweb-core/src/main/java/org/hswebframework/web/context/MapContext.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/DictParser.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/DictSupportApi.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/Item.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DefaultDictApply.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictApply.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictWrapper.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictParser.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictSupportApi.java rename hsweb-core/src/main/java/org/hswebframework/web/{dict/defaults => enums}/TrueOrFalse.java (73%) rename hsweb-core/src/main/java/org/hswebframework/web/{ => exception}/BusinessException.java (97%) rename hsweb-core/src/main/java/org/hswebframework/web/{ => exception}/NotFoundException.java (95%) create mode 100644 hsweb-core/src/main/java/org/hswebframework/web/utils/AnnotationUtils.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validate/SimpleValidateResults.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validate/ValidateResults.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validate/ValidationException.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validator/DuplicateKeyException.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKey.java delete mode 100644 hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKeyValidator.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/DataAccessEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupBindEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/OptionalField.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ParentPermission.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/PermissionEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupBindEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimplePermissionEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserRoleEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserSettingEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/BindRoleUserEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/SimpleBindRoleUserEntity.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/DataAccessFactory.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupBindService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordEncoder.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordStrengthValidator.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PermissionService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/RoleService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserSettingService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UsernameValidator.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/ClearUserAuthorizationCacheEvent.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/TotpTwoFactorCreatedEvent.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserCreatedEvent.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserModifiedEvent.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupBindDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/PermissionDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/RoleDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserRoleDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserSettingDao.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/DefaultDataAccessFactory.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/InServiceUserSettingManager.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupBindService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimplePermissionService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserSettingService.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/CustomUserSqlTermAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/UserInRoleSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/Base32String.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/HexEncoding.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpTwoFactorProvider.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpUtil.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/hsweb-module.json delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserSettingMapper.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AutoSyncPermission.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug89Test.groovy delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug91Test.groovy delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TestApplication.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TotpTwoFactorProviderTests.groovy delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/UserSettingControllerTest.groovy delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AuthorizationSettingTests.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AutoSyncPermissionTest.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/LoginTests.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/PermissionTests.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/UserTests.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/AuthorizationSettingController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/MenuController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/PermissionController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/RoleController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserSettingController.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/ActionModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/DataAccessModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/FieldAccessModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/PermissionRoleModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimplePermissionRoleModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimpleUserModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/UserModel.java delete mode 100644 hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/resources/hsweb-module.json create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ActionEntity.java create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/OptionalField.java create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ParentPermission.java create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/PermissionEntity.java create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/UserEntity.java create mode 100644 hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/enums/UserState.java delete mode 100644 hsweb-system/hsweb-system-config/README.md delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigContent.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/SimpleConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/service/config/ConfigService.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/dao/config/ConfigDao.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/service/config/simple/SimpleConfigService.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/config/ConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/java/org/hswebframework/web/config/starter/ConfigAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/java/org/hswebframework/web/starter/config/ConfigTests.java delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-config/hsweb-system-config-web/src/main/java/org/hswebframework/web/controller/config/ConfigController.java delete mode 100644 hsweb-system/hsweb-system-config/pom.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboardAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardUserConfigController.java delete mode 100644 hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/model/UserDashBoardResponse.java delete mode 100644 hsweb-system/hsweb-system-dashboard/pom.xml delete mode 100644 hsweb-system/hsweb-system-database-manager/README.md delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/DatabaseManagerService.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteRequest.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteResult.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlInfo.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/exception/SqlExecuteException.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/ObjectMetadata.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ColumnMetadata.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/Constraint.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ForeignConstraint.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/TableMetadata.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/AbstractSqlTableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserRegister.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserSupplier.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/TableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/MysqlTableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/OracleTableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/PostgresTableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/SqlServerTableMetaDataParser.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/SqlExecutor.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionInfo.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionSqlExecutor.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/test/src/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParserTest.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/DefaultLocalTransactionExecutor.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/NonTransactionSqlExecutor.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResult.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResultWrapper.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerService.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/TransactionExecutor.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/resources/hsweb-module.json delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/DataBaseManagerAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/TableMetaDataParserAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerServiceTest.java delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/src/main/java/org/hswebframework/web/database/manager/web/DataBaseManagerController.java delete mode 100644 hsweb-system/hsweb-system-database-manager/pom.xml delete mode 100644 hsweb-system/hsweb-system-datasource/README.md delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/DataSourceConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/SimpleDataSourceConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/service/datasource/DataSourceConfigService.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/dao/datasource/DataSourceConfigDao.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDataSourceRepository.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceConfig.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceService.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBJtaDynamicDataSourceService.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/SimpleDataSourceConfigService.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/datasource/DataSourceConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/java/org/hswebframework/web/datasource/starter/InDBDynamicDataSourceAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/src/main/java/org/hswebframework/web/controller/datasource/DataSourceConfigController.java delete mode 100644 hsweb-system/hsweb-system-datasource/pom.xml delete mode 100644 hsweb-system/hsweb-system-dev-tools/pom.xml delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/DevToolsAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/EnableDevTools.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/reader/FileInfo.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/web/FileManagerDevToolsController.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/ClassWriter.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/CodeWriter.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/DefaultCodeWriter.java delete mode 100644 hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/GeneratedCode.java delete mode 100644 hsweb-system/hsweb-system-dictionary/README.md delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfo.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfoService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryItemService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParser.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParserService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryWrapper.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/builder/DictionaryParserBuilder.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryItemEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryParserEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryItemEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryParserEntity.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/events/ClearDictionaryCacheEvent.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/parser/SingleDictParser.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/BoostDictDefineRepository.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryHelper.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapper.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DictionaryWrapperObject.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryItemService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParser.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParserService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryService.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/builder/SimpleDictionaryParserBuilder.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryDao.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryItemDao.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryParserDao.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormat.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormatter.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/FormatterResult.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/ScriptSingleDictParser.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleDictParserFormatter.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleSingleDictParser.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryItemMapper.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryMapper.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryParserMapper.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapperTest.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/EmptyDictBean.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestBean.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestDict.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/java/org/hswebframework/web/dictionary/starter/DictionaryFactoryAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryParserTests.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryTests.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryItemController.java delete mode 100644 hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryParserController.java delete mode 100644 hsweb-system/hsweb-system-dictionary/pom.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/README.md delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DictConfig.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnBindEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormDeployLogEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormColumnEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormDeployLogEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormEntity.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DatabaseRepository.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormColumnService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormDeployLogService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/FormDeployService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/OptionalConvertBuilder.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/DatabaseInitEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataInsertBeforeEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataQueryBeforeEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataUpdateBeforeEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDeployEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormUnDeployEvent.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/ColumnInitializeContext.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/DynamicFormInitializeCustomizer.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/TableInitializeContext.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormColumnDao.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDao.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDeployLogDao.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/DynamicFormException.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDatabaseRepository.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormColumnService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormDeployLogService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormService.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabase.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabaseInit.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/convert/SmartValueConverter.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DefaultOptionalConvertBuilder.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DictionaryOptionalConvertBuilderStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictOptionConverter.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictValueConverter.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/OptionalConvertBuilderStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidator.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidatorFactory.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationInfo.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/MapBean.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/AbstractStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/EmailStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/LengthStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotBlankStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotNullStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/RangeStrategy.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormColumnMapper.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormDeployLogMapper.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormMapper.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/java/org/hswebframework/web/form/DynamicFormAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormAuthorizeDefinitionParser.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormColumnController.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormController.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormDeployLogController.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormOperationController.java delete mode 100644 hsweb-system/hsweb-system-dynamic-form/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/README.md delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/FileInfoEntity.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/SimpleFileInfoEntity.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileInfoService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/dao/file/FileInfoDao.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/fastdfs/FdfsFileService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/SimpleFileInfoService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/file/FileInfoMapper.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileInfoService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileService.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FastdfsServiceAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FileAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FileUploadTests.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FixBug93Test.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileController.java delete mode 100644 hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileInfoController.java delete mode 100644 hsweb-system/hsweb-system-file/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2ServerConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2UserTokenEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2ServerConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2UserTokenEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2ServerConfigService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2UserTokenService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2ServerConfigDao.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2UserTokenDao.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2ServerConfigService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2ServerConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2UserTokenMapper.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/java/org/hswebframework/web/service/oauth2/client/starter/OAuth2ClientAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/OAuth2ServerConfigTests.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseConvertSupport.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseJudgeSupport.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-client/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/AuthorizationCodeDao.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2AccessDao.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2ClientDao.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/AuthorizationCodeEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2AccessEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2ClientEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleAuthorizationCodeEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2AccessEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2ClientEntity.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/CodeGenerator.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAccessTokenService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAuthorizationCodeService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleClientConfigRepository.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimplePasswordService.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/TokenGenerator.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2AccessMapper.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2ClientMapper.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2CodeMapper.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GrantEventListener.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GranterAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/authorization/OAuth2UserTokenParser.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2AuthorizeController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2TokenController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserInfoController.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AccessTokenModel.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AuthorizationCodeModel.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/ImplicitAccessTokenModel.java delete mode 100644 hsweb-system/hsweb-system-oauth2-server/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/README.md delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DepartmentEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DistrictEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/OrganizationalEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonAuthBindEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonPositionEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonUserEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PositionEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationDefineEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationInfoEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDepartmentEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDistrictEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleOrganizationalEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonAuthBindEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonPositionEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePositionEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationDefineEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationInfoEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DepartmentService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DistrictService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/OrganizationalService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PersonService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PositionService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationDefineService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationInfoService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/event/ClearPersonCacheEvent.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/README.md delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/DefaultPersonnelAuthenticationSupplier.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Department.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/District.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Organization.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/OrganizationalAuthorizationAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Personnel.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthentication.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationHolder.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationManager.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSettingTypeSupplier.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSupplier.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Position.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/TreeNode.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DataAccessType.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DepartmentAttachEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DistrictAttachEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/OrgAttachEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PersonAttachEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PositionAttachEntity.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/DepartmentRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/LinkedRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/OrgRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/PersonRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relation.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetHolder.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplier.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplierAutoRegister.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationsManager.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelation.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScope.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScopeDataAccessConfigConvert.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfig.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfigConvert.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeDataAccessConfigConvert.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleCustomScopeDataAccessConfig.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDepartment.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDistrict.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleOrganization.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnel.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthentication.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthorizationBuilder.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePosition.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleScopeDataAccessConfig.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/AbstractScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/CustomScopeHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DepartmentScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DistrictScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/OrgScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PersonScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PositionScopeDataAccessHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/ScopeByUserHandler.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/test/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthenticationBuilderTest.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DepartmentDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DistrictDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/OrganizationalDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonPositionDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PositionDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationDefineDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationInfoDao.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDepartmentService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDistrictService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleOrganizationalService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePersonService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePositionService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationDefineService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationInfoService.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultDepartmentRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultLinkedRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultOrgRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultPersonRelations.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultRelationsManager.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/ServiceContext.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/CustomSqlTermConfiguration.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/InServiceTreeInSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDepartmentSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDistSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInOrgSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInPositionSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DepartmentMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DistrictMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/OrganizationalMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonPositionMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PositionMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationDefineMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationInfoMapper.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/java/org/hswebframework/web/organizational/starter/AuthorizationAutoConfigration.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/DepartmentTests.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/OrganizationalTests.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PersonTests.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PositionTests.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/RelationsManagerTests.groovy delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/TestApplication.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DepartmentController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DistrictController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/OrganizationalController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PersonController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PositionController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationDefineController.java delete mode 100644 hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationInfoController.java delete mode 100644 hsweb-system/hsweb-system-organizational/pom.xml delete mode 100644 hsweb-system/hsweb-system-schedule/README.md delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/ScheduleJobEntity.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/SimpleScheduleJobEntity.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobExecutor.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobService.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleTriggerBuilder.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/dao/schedule/ScheduleJobDao.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DefaultScriptScheduleJobExecutor.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJob.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJobFactory.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SimpleScheduleJobService.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SmartScheduleTriggerBuilder.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/schedule/ScheduleJobMapper.xml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/AutoCreateTable.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/ScheduleAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/SchedulerProperties.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-h2-create.sql delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-mysql-create.sql delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-oracle-create.sql delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-postgresql-create.sql delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/src/main/java/org/hswebframework/web/controller/schedule/ScheduleJobController.java delete mode 100644 hsweb-system/hsweb-system-schedule/pom.xml delete mode 100644 hsweb-system/hsweb-system-script/README.md delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptExecutorService.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/DefaultScriptExecutorService.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/java/org/hswebframework/web/service/dynamic/script/DynamicScriptAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/java/org/hswebframework/web/workflow/flowable/ControllerTest.java delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-script/hsweb-system-script-web/src/main/java/org/hswebframework/web/controller/script/ScriptController.java delete mode 100644 hsweb-system/hsweb-system-script/pom.xml delete mode 100644 hsweb-system/hsweb-system-template/README.md delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/pom.xml delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/SimpleTemplateEntity.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/TemplateEntity.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRendeFacotry.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRender.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateService.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/dao/template/TemplateDao.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/service/template/simple/SimpleTemplateService.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/template/TemplateMapper.xml delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/java/org/hswebframework/web/template/starter/TemplateAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-web/pom.xml delete mode 100644 hsweb-system/hsweb-system-template/hsweb-system-template-web/src/main/java/org/hswebframework/web/controller/template/TemplateController.java delete mode 100644 hsweb-system/hsweb-system-template/pom.xml delete mode 100644 hsweb-system/hsweb-system-workflow/README.md delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/pom.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ActivityConfigDao.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessDefineConfigDao.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessHistoryDao.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ActivityConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ListenerConfig.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessDefineConfigEntity.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessHistoryEntity.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimension.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimensionParser.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParser.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultPermissionDimensionParser.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DimensionContext.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/PermissionDimensionParser.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/CandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/DepartmentCandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/OrgCandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/PositionCandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/RoleCandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/ScriptCandiateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/UserCandidateDimensionParserStrategy.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/enums/ModelType.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/FlowableAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/ActivitiUserUtil.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManager.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManagerFactory.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManager.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManagerFactory.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/JumpTaskCmd.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/GlobalEventListenerDispatcher.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEvent.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEventListener.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEvent.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEventListener.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ActivityConfigService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmActivityService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmProcessService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmTaskService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessDefineConfigService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessHistoryService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/WorkFlowFormService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ActivityConfiguration.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/CandidateInfo.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfiguration.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfigurationService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/AbstractFlowableService.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ActivityConfigServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmActivityServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmProcessServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmTaskServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessConfigurationServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessDefineConfigServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessHistoryServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/WorkFlowFormServiceImpl.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/CompleteTaskRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/JumpTaskRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/RejectTaskRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/SaveFormRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/StartProcessRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ClaimSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/CompletedSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ProcessParticipateSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/TodoSqlTerm.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/WorkflowTermsAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/util/QueryUtils.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableDeploymentController.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableModelManagerController.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableProcessController.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessActivityConfigController.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessDefineConfigController.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/BaseProcessDefinitionDiagramLayoutResource.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessDefinitionDiagramLayoutResource.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceDiagramLayoutResource.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceHighlightsResource.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/request/ModelCreateRequest.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ActivityInfo.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/CandidateDetail.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessDefinitionInfo.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessInfo.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/TaskInfo.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/hsweb-starter.js delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ActivityConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessDefineConfigMapper.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessHistoryMapper.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/processes/README.md delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParserTest.groovy delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/TestApplication.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowModelTests.groovy delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowProcessTests.groovy delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application-dev.yml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application.yml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/README.md delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/SimpleProcess.bpmn20.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/pom.xml delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/java/org/hswebframework/web/workflow/starter/WorkFlowAutoConfiguration.java delete mode 100644 hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-system/hsweb-system-workflow/pom.xml delete mode 100644 hsweb-tests/pom.xml delete mode 100644 hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecification.groovy delete mode 100644 hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebSpecification.groovy delete mode 100644 hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebTestApplication.groovy delete mode 100644 hsweb-tests/src/main/java/org/hswebframework/web/tests/SimpleWebApplicationTests.java delete mode 100644 hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcess.java delete mode 100644 hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcessSetUp.java delete mode 100644 hsweb-tests/src/main/java/org/hswebframework/web/tests/TestResult.java delete mode 100644 hsweb-tests/src/test/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecificationTest.groovy delete mode 100644 hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestController.java delete mode 100644 hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestEntity.java delete mode 100644 hsweb-tests/src/test/resources/application.yml delete mode 100644 hsweb-thirdparty/README.md delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/README.md delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/pom.xml delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ActionEnter.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ConfigManager.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Context.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Encoder.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/PathFormat.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionMap.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionState.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/AppInfo.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/BaseState.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/FileType.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MIMEType.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MultiState.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/State.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/FileManager.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/StorageManager.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Uploader.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorAutoConfiguration.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorController.java delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/additional-spring-configuration-metadata.json delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/spring.factories delete mode 100644 hsweb-thirdparty/hsweb-thirdparty-ueditor/src/test/java/com/baidu/ueditor/define/MultiStateTest.java delete mode 100644 hsweb-thirdparty/pom.xml diff --git a/README.md b/README.md index 97dcc875a..09c3cb631 100644 --- a/README.md +++ b/README.md @@ -4,136 +4,5 @@ [![Build Status](https://travis-ci.org/hs-web/hsweb-framework.svg?branch=master)](https://travis-ci.org/hs-web/hsweb-framework) [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html) - [贡献代码](CONTRIBUTING.md) [用户手册](https://docs.hsweb.io) -## 应用场景 -1. 完全开源的后台管理系统. -2. 细粒度(按钮,行,列)权限控制的后台管理系统. -3. 模块化的后台管理系统. -4. 功能可拓展的后台管理系统. -5. 集成各种常用功能的后台管理系统. -6. 前后分离的后台管理系统. - -注意: -项目主要基于`spring-boot`,`mybatis`. 在使用`hsweb`之前,你应该对`spring-boot`有一定的了解. - -项目模块太多?不要被吓到.我们不推荐将本项目直接`clone`后修改,运行.而是使用maven依赖的方式使用`hsweb`. -选择自己需要的模块进行依赖,正式版发布后,所有模块都将发布到maven中央仓库. -你可以参照[demo](https://github.com/hs-web/hsweb3-demo)进行使用. - -## 文档 -各个模块的使用方式查看对应模块下的 `README.md`,在使用之前, -你可以先粗略浏览一下各个模块,对每个模块的作用有大致的了解. - -## 核心技术选型 - -1. Java 8 -2. Maven3 -3. Spring Boot 1.5.x -4. Mybatis -5. Hsweb Easy Orm (使用`hsweb-easy-orm`拓展`Myabtis`实现动态条件) - -## 模块简介 - -| 模块 | 说明 | 进度 | -| ------------- |:-------------:| ----| -|[hsweb-authorization](hsweb-authorization)|权限控制| 100%| -|[hsweb-commons](hsweb-commons) |基础通用功能| 100%| -|[hsweb-concurrent](hsweb-concurrent)|并发包,缓存,锁,计数器等| 80%| -|[hsweb-core](hsweb-core)|框架核心,基础工具类| 100%| -|[hsweb-datasource](hsweb-datasource)|数据源| 100%| -|[hsweb-logging](hsweb-logging)| 日志| 100%| -|[hsweb-starter](hsweb-starter)|模块启动器| 100%| -|[hsweb-system](hsweb-system)|**系统常用功能**| 80%| -|[hsweb-thirdparty](hsweb-thirdparty)| 第三方插件 | 100% | - -## 核心特性 -1. DSL风格,可拓展的通用curd,支持前端直接传参数,无需担心任何sql注入. -```java - //where name = #{name} limit 0,20 - createQuery().where("name",name).list(0,20); - - //update s_user set name = #{user.name} where id = #{user.id} - createUpdate().set(user::getName).where(user::getId).exec(); -``` - -2. 灵活的权限控制 -```java - -@PostMapping("/account") -@Authorize(permission="account-manager",action="add") -public ResponseMessage addAccount(@RequestBody Account account){ - return ok(accountService.addAccount(account)); -} - -@GettMapping("/account") -@Authorize(permission="account-manager",action="query",dataAccess=@RequiresDataAccess)//开启数据权限控制 -public ResponseMessage> addAccount(QueryParamEntity query){ - - //用户设置了数据权限后,query的参数属性将被修改 - - return ok(accountService.selectPager(query)); -} - - -``` - -3. 灵活的模块版本维护脚本 - -`resources/hsweb-starter.js` - -```js -//组件信息 -var info = { - groupId: "com.company", - artifactId: "module-name", - version: "1.0.2", - website: "company.com", - author: "作者", - comment: "模块名称" -}; - -//版本更新信息 -var versions = [ - { - version: "1.0.2", //当info.version大于等于此版本号时,执行upgrade - upgrade: function (context) { - var database = context.database; - //增加冻结金额字段 - database.createOrAlter("acc_account") - .addColumn().name("freeze_balance").jdbcType(JDBCType.BIGINT).comment("冻结金额").commit() - .comment("资金账户") - .commit(); - } - } - -]; -var JDBCType = java.sql.JDBCType; - -//首次引入依赖,将执行安装操作 -function install(context) { - var database = context.database; - database.createOrAlter("acc_account") - .addColumn().name("id").varchar(32).notNull().primaryKey().comment("ID").commit() - .addColumn().name("account_no").varchar(32).notNull().comment("资金账户号").commit() - //更多字段 - //索引 - .index().name("idx_acc_account_no") - .column("account_no").commit()//account_no索引 - .comment("资金账户").commit(); -} - -//设置依赖,固定代码,无需修改 -dependency.setup(info) - .onInstall(install) //安装时执行 - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) //过滤版本信息 - .upgrade(function (newVer) { //执行更新 - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); -``` +# 基于spring-boot2,全响应式的后台管理框架 diff --git a/hsweb-authorization/hsweb-authorization-api/pom.xml b/hsweb-authorization/hsweb-authorization-api/pom.xml index 2373bb980..1ebbda60c 100644 --- a/hsweb-authorization/hsweb-authorization-api/pom.xml +++ b/hsweb-authorization/hsweb-authorization-api/pom.xml @@ -12,11 +12,6 @@ 授权,权限管理API hsweb-authorization-api - - org.hswebframework.web - hsweb-boost-aop - ${project.version} - org.hswebframework.web hsweb-core diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/ScriptDataAccessHandler.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/ScriptDataAccessHandler.java index 5fc5880a0..121574e03 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/ScriptDataAccessHandler.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/handler/access/ScriptDataAccessHandler.java @@ -4,7 +4,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.hswebframework.expands.script.engine.DynamicScriptEngine; import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.BusinessException; +import org.hswebframework.web.exception.BusinessException; import org.hswebframework.web.authorization.access.DataAccessConfig; import org.hswebframework.web.authorization.access.DataAccessHandler; import org.hswebframework.web.authorization.access.ScriptDataAccessConfig; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2RequestService.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2RequestService.java index 15d7e3dc7..49e21f255 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2RequestService.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2RequestService.java @@ -19,7 +19,7 @@ package org.hswebframework.web.authorization.oauth2.client.simple; import org.hswebframework.utils.ClassUtils; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.NotFoundException; import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestBuilderFactory; import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestService; import org.hswebframework.web.authorization.oauth2.client.OAuth2ServerConfig; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java index ee26011d0..87282baf1 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java @@ -18,7 +18,7 @@ package org.hswebframework.web.authorization.oauth2.client.simple; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.NotFoundException; import org.hswebframework.web.authorization.oauth2.client.*; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Session; import org.hswebframework.web.authorization.oauth2.client.simple.session.AuthorizationCodeSession; @@ -28,9 +28,7 @@ import org.hswebframework.web.authorization.oauth2.client.simple.session.Passwor import org.hswebframework.web.oauth2.core.GrantType; import org.hswebframework.web.oauth2.core.OAuth2Constants; -import java.util.List; import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; import java.util.function.Supplier; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupport.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupport.java index e454ad953..ca939a651 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupport.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupport.java @@ -22,7 +22,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; -import org.hswebframework.web.BusinessException; +import org.hswebframework.web.exception.BusinessException; import org.hswebframework.web.authorization.Authentication; import org.hswebframework.web.authorization.builder.AuthenticationBuilderFactory; import org.hswebframework.web.authorization.oauth2.client.exception.OAuth2RequestException; @@ -30,8 +30,6 @@ import org.hswebframework.web.authorization.oauth2.client.request.definition.Res import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response; import org.hswebframework.web.controller.message.ResponseMessage; import org.hswebframework.web.oauth2.core.ErrorType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import java.util.*; import java.util.function.Function; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java index 7b317c611..fe87f280d 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java @@ -19,7 +19,7 @@ package org.hswebframework.web.authorization.oauth2.client.simple.session; import org.apache.commons.codec.binary.Base64; -import org.hswebframework.web.BusinessException; +import org.hswebframework.web.exception.BusinessException; import org.hswebframework.web.authorization.oauth2.client.*; import org.hswebframework.web.authorization.oauth2.client.exception.OAuth2RequestException; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Request; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/test/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupportTests.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/test/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupportTests.java index 6a24630c5..5f15c40dd 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/test/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupportTests.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/test/java/org/hswebframework/web/authorization/oauth2/client/simple/provider/HswebResponseConvertSupportTests.java @@ -1,7 +1,7 @@ package org.hswebframework.web.authorization.oauth2.client.simple.provider; import com.alibaba.fastjson.JSON; -import org.hswebframework.web.BusinessException; +import org.hswebframework.web.exception.BusinessException; import org.hswebframework.web.authorization.oauth2.client.exception.OAuth2RequestException; import org.hswebframework.web.authorization.simple.SimpleUser; import org.hswebframework.web.authorization.simple.builder.SimpleAuthenticationBuilderFactory; @@ -12,8 +12,6 @@ import org.junit.Test; import java.math.BigDecimal; -import static org.junit.Assert.*; - /** * TODO 完成注释 * diff --git a/hsweb-boost/README.md b/hsweb-boost/README.md deleted file mode 100644 index def1f29b2..000000000 --- a/hsweb-boost/README.md +++ /dev/null @@ -1 +0,0 @@ -# 增强模块,提供一些增强工具如验证器 \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-aop/README.md b/hsweb-boost/hsweb-boost-aop/README.md deleted file mode 100644 index b7c6e2c32..000000000 --- a/hsweb-boost/hsweb-boost-aop/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# AOP增强模块 -提供aop常用操作需要的公共类 - \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-aop/pom.xml b/hsweb-boost/hsweb-boost-aop/pom.xml deleted file mode 100644 index faf8900ca..000000000 --- a/hsweb-boost/hsweb-boost-aop/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - hsweb-boost - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-boost-aop - - 对AOP提供一些增强功能 - - - - org.hswebframework.web - hsweb-commons-utils - ${project.version} - - - - org.springframework.boot - spring-boot-starter-web - true - - - org.aspectj - aspectjweaver - - - org.slf4j - slf4j-api - - - org.hswebframework - hsweb-utils - - - \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-excel/pom.xml b/hsweb-boost/hsweb-boost-excel/pom.xml deleted file mode 100644 index ac333e968..000000000 --- a/hsweb-boost/hsweb-boost-excel/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - hsweb-boost - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-boost-excel - - 便捷EXCEL操作工具 - - - - org.hswebframework - hsweb-expands-office - ${hsweb.expands.version} - - - org.hswebframework.web - hsweb-commons-entity - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/DefaultExcelImporter.java b/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/DefaultExcelImporter.java deleted file mode 100644 index 57fb10a0c..000000000 --- a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/DefaultExcelImporter.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.hswebframework.web.excel; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.expands.office.excel.ExcelIO; -import org.hswebframework.web.ApplicationContextHolder; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dict.ItemDefine; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -import java.io.InputStream; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; -import java.util.function.Supplier; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Slf4j -@SuppressWarnings("all") -public class DefaultExcelImporter implements ExcelImporter { - - protected static Map> headerMappings = new ConcurrentHashMap<>(); - - protected static ExcelCellConverter DEFAULT_CONVERTER = new ExcelCellConverter() { - @Override - public Object convertFromCell(Object from) { - return from; - } - - @Override - public Object convertToCell(Object from) { - if (from instanceof EnumDict) { - return ((EnumDict) from).getText(); - } - return from; - } - }; - - protected ExcelCellConverter defaultConvert = DEFAULT_CONVERTER; - - protected Map createHeaderMapping(Class type) { - //一些基本类型不做处理 - if (type == String.class - || Number.class.isAssignableFrom(type) - || ClassUtils.isPrimitiveWrapper(type) - || type.isPrimitive() - || type.isEnum() - || type.isArray() - || Date.class.isAssignableFrom(type)) { - return new java.util.HashMap<>(); - } - AtomicInteger index = new AtomicInteger(0); - Map headerMapperMap = new HashMap<>(); - ReflectionUtils.doWithFields(type, field -> { - Excel excel = field.getAnnotation(Excel.class); - ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class); - if ((excel == null && apiModelProperty == null) || (excel != null && excel.ignore())) { - return; - } - String header = excel == null ? apiModelProperty.value() : excel.value(); - HeaderMapping mapping = new HeaderMapping(); - mapping.header = header; - mapping.field = field.getName(); - mapping.index = excel == null || excel.exportOrder() == -1 ? index.getAndAdd(1) : excel.exportOrder(); - if (null != excel) { - mapping.enableImport = excel.enableImport(); - mapping.enableExport = excel.enableExport(); - mapping.children = () -> getHeaderMapper(field.getType(), excel.group()); - for (Class group : excel.group()) { - headerMapperMap.computeIfAbsent(group, DefaultHeaderMapper::new) - .mappings - .add(mapping); - } - mapping.converter = createConvert(excel.converter(), field.getType()); - } else { - mapping.converter = createConvert(ExcelCellConverter.class, field.getType()); - mapping.children = () -> getHeaderMapper(field.getType()); - headerMapperMap.computeIfAbsent(Void.class, DefaultHeaderMapper::new) - .mappings - .add(mapping); - - } - }); - - return (Map) headerMapperMap; - } - - @SneakyThrows - protected ExcelCellConverter createConvert(Class converterClass, Class type) { - if (converterClass != ExcelCellConverter.class) { - try { - return ApplicationContextHolder.get().getBean(converterClass); - } catch (Exception e) { - log.warn("can not get bean ({}) from spring context.", converterClass, e); - return converterClass.newInstance(); - } - } - return defaultConvert; - } - - @Getter - class HeaderMapping implements Comparable { - private String field; - - private String header; - - private int index; - - private boolean enableExport = true; - - private boolean enableImport = true; - - private Supplier children; - - private ExcelCellConverter converter; - - public HeaderMapping copy() { - HeaderMapping mapping = new HeaderMapping(); - mapping.children = children; - mapping.field = field; - mapping.header = header; - mapping.index = index; - mapping.enableImport = enableImport; - mapping.enableExport = enableExport; - mapping.children = children; - mapping.converter = converter; - return mapping; - } - - @Override - public int compareTo(HeaderMapping o) { - return Integer.compare(index, o.index); - } - } - - - class DefaultHeaderMapper implements HeaderMapper { - - @Getter - private Class group; - - public DefaultHeaderMapper(Class group) { - this.group = group; - } - - private Map fastMapping = new HashMap<>(); - - private final List mappings = new ArrayList() { - private static final long serialVersionUID = 5995980497414973311L; - - @Override - public boolean add(HeaderMapping o) { - fastMapping.put(o.header, o); - fastMapping.put(o.field, o); - return super.add(o); - } - }; - - - @Override - public Optional getMapping(String key) { - return Optional.ofNullable(fastMapping.computeIfAbsent(key, k -> { - //尝试获取嵌套的属性 - for (HeaderMapping mapping : mappings) { - String newKey = key; - //字段嵌套 - if (newKey.startsWith(mapping.field)) { - newKey = newKey.substring(mapping.field.length()); - } - //表头嵌套 - else if (newKey.startsWith(mapping.header)) { - newKey = newKey.substring(mapping.header.length()); - } else { - continue; - } - HeaderMapper mapper = mapping.children.get(); - if (null != mapper) { - HeaderMapping map = mapper.getMapping(newKey).orElse(null); - if (map != null) { - map = map.copy(); - map.field = mapping.field.concat(".").concat(map.field); - map.header = mapping.header.concat(map.header); - return map; - } - } - } - return null; - })); - } - } - - interface HeaderMapper { - Optional getMapping(String key); - } - - protected HeaderMapper getHeaderMapper(Class type, Class... group) { - Map mapperMap = headerMappings.computeIfAbsent(type, this::createHeaderMapping); - - if (group != null && group.length > 0) { - return Arrays.stream(group) - .map(mapperMap::get) - .filter(Objects::nonNull) - .findFirst() - .orElse(null); - } else { - return mapperMap.get(Void.class); - } - } - - @Override - @SneakyThrows - public Result doImport(InputStream inputStream, Class type, Function afterParsed, Class... group) { - AtomicInteger counter = new AtomicInteger(0); - AtomicInteger errorCounter = new AtomicInteger(0); - List data = new ArrayList<>(); - List errors = new ArrayList<>(); - HeaderMapper headerMapper = getHeaderMapper(type, group); - if (headerMapper == null) { - throw new UnsupportedOperationException("不支持导入此类型"); - } - ExcelIO.read(inputStream, row -> { - counter.getAndAdd(1); - Map mapValue = row.getResult(); - - Map newValue = new HashMap<>(); - - for (Map.Entry entry : mapValue.entrySet()) { - String key = entry.getKey(); - HeaderMapping mapping = headerMapper.getMapping(key).orElse(null); - - if (mapping == null || !mapping.enableImport) { - continue; - } - Object value = mapping.getConverter().convertFromCell(entry.getValue()); - - String field = mapping.getField(); - //嵌套的字段 - if (field.contains(".")) { - String tmpField = field; - Map nestMapValue = newValue; - - while (tmpField.contains(".")) { - - // nest.obj.name => [nest,obj.name] - String[] nestFields = tmpField.split("[.]", 2); - - //nest - String nestField = nestFields[0]; - - //obj.name - tmpField = nestFields[1]; - - Object nestValue = nestMapValue.get(nestField); - //构造嵌套对象为map - if (nestValue == null) { - nestMapValue.put(nestField, nestMapValue = new HashMap<>()); - } else { - if (nestValue instanceof Map) { - nestMapValue = ((Map) nestValue); - } else { - //这里几乎不可能进入... - nestMapValue.put(nestField, nestMapValue = FastBeanCopier.copy(nestValue, new HashMap<>())); - } - } - } - //最后nestMapValue就为最里层嵌套的对象了 - nestMapValue.put(tmpField, value); - } else { - newValue.put(field, value); - } - } - //创建实例并将map复制到实例中 - T instance = FastBeanCopier.getBeanFactory().newInstance(type); - - FastBeanCopier.copy(newValue, instance); - - data.add(instance); - - Error error = afterParsed.apply(instance); - if (null != error) { - errorCounter.getAndAdd(1); - error.setRowIndex(counter.get()); - error.setSheetIndex(row.getSheet()); - errors.add(error); - } - }); - return Result.builder() - .data(data) - .errors(errors) - .success(counter.get() - errorCounter.get()) - .total(counter.get()) - .error(errorCounter.get()) - .build(); - } -} diff --git a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/Excel.java b/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/Excel.java deleted file mode 100644 index 762e1fcc6..000000000 --- a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/Excel.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.hswebframework.web.excel; - -import io.swagger.annotations.ApiModelProperty; - -import java.lang.annotation.*; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Excel { - - /** - * @return EXCEL表头 - * @see ApiModelProperty#value() - */ - String value() default ""; - - /** - * @return 读取指定的工作薄,-1为默认 - */ - int sheetIndex() default -1; - - /** - * @return 是否取消EXCEL导入导出功能 - */ - boolean ignore() default false; - - /** - * @return 是否开启导入, 开启后的字段才能进行导入 - */ - boolean enableImport() default true; - - /** - * @return 是否开启导出, 开启后的字段才能进行导出 - */ - boolean enableExport() default true; - - /** - * @return 导出时, 表头的顺序 - */ - int exportOrder() default -1; - - /** - * @return 导出分组, 可通过分组导入导出不同的字段信息 - */ - Class[] group() default Void.class; - - /** - * 自定义单元格转换器, 用于对数据字典等字段进行自定义转换 - * - * @return 实例必须注入到spring容器中 - * @see org.springframework.context.ApplicationContext#getBean(Class) - */ - Class converter() default ExcelCellConverter.class; - -} diff --git a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelCellConverter.java b/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelCellConverter.java deleted file mode 100644 index fed489456..000000000 --- a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelCellConverter.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.excel; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ExcelCellConverter { - T convertFromCell(Object from); - - Object convertToCell(T from); -} diff --git a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelImporter.java b/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelImporter.java deleted file mode 100644 index 406f3e4f5..000000000 --- a/hsweb-boost/hsweb-boost-excel/src/main/java/org/hswebframework/web/excel/ExcelImporter.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.hswebframework.web.excel; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.bean.FastBeanCopier; - -import java.io.InputStream; -import java.util.List; -import java.util.function.Function; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ExcelImporter { - - ExcelImporter instance = new DefaultExcelImporter(); - - /** - * 解析excel为指定的class对象,并返回解析结果.类上的属性需要注解{@link Excel}或者{@link io.swagger.annotations.ApiModelProperty}. - * - * @param inputStream excel文件流,支持xls和xlsx - * @param type 要解析为的类型 - * @param afterParsed 每解析完一个对象都会调用此接口,用于自定义操作,如: 数据校验 - * @param group 导入的分组 {@link Excel#group()},如果不指定则为 {@link Void#getClass()} - * @param 泛型 - * @return 导入结果, 包含了成功, 失败信息 - * @see Excel - * @see FastBeanCopier#getBeanFactory() - * @see ExcelImporter#instance 默认的实现 - */ - Result doImport(InputStream inputStream, Class type, Function afterParsed, Class... group); - - @Builder - @Getter - @Setter - class Result { - int total; - int success; - int error; - List
headers; - List data; - List errors; - } - - @Builder - @Getter - @Setter - class Error { - int sheetIndex; - int rowIndex; - int errorType; - Object reason; - } - - @Builder - @Getter - @Setter - class Header { - int sheetIndex; - @SuppressWarnings("all") - String header; - String field; - } -} diff --git a/hsweb-boost/hsweb-boost-excel/src/test/java/org/hswebframework/web/excel/DefaultExcelImporterTest.java b/hsweb-boost/hsweb-boost-excel/src/test/java/org/hswebframework/web/excel/DefaultExcelImporterTest.java deleted file mode 100644 index 61254463c..000000000 --- a/hsweb-boost/hsweb-boost-excel/src/test/java/org/hswebframework/web/excel/DefaultExcelImporterTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.hswebframework.web.excel; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.serializer.SerializerFeature; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.hswebframework.web.commons.bean.Bean; -import org.hswebframework.web.commons.entity.DataStatusEnum; -import org.junit.Assert; -import org.junit.Test; - - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public class DefaultExcelImporterTest { - - - @Test - public void test() { - ExcelImporter.Result result = ExcelImporter - .instance - .doImport(this.getClass().getResourceAsStream("/test.xls"), TestBean.class, bean -> null); - - Assert.assertEquals(result.success, 1); - System.out.println(JSON.toJSONString(result.getData(), SerializerFeature.PrettyFormat)); - TestBean bean = result.getData().get(0); - Assert.assertNotNull(bean.status); - Assert.assertNotNull(bean.nest); - Assert.assertNotNull(bean.nest.nest); - - } - - @Getter - @Setter - @ToString - public static class TestBean implements Bean { - - private static final long serialVersionUID = -5394537136669692305L; - - @Excel("姓名") - private String name; - - @Excel("年龄") - private int age; - - @Excel("状态") - private DataStatusEnum status; - - @Excel("嵌套-") - private TestBean nest; - } - - -} \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-excel/src/test/resources/test.xls b/hsweb-boost/hsweb-boost-excel/src/test/resources/test.xls deleted file mode 100644 index 5cf009a354847e329fc32be2d4dc7c833712b45a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18944 zcmeG^2Urx>x@VUK78L<0A}B1dQWvC1QB<%u5KwFZl_H9Yk_aLeiUlhwf)$AxmDr-h z-V4_@v4Yz-~Z1ryUXs(Ud(;D@4okP_|D9n|D5yp^Pe(1T>9Oh{D)m; z_e4TI!Bj|HNsmrMgM5+d5G}e)U3qY|V#@l2h~ODvU!+ngf^8tfe`VsgC2yu3+Zj?Lp|}x5WYXvZV`30rmjul$|DD; zJ~t?c8!;lUpocUq3!R$GA$;D#umM2`$MoL;zXf>wh$?=B>u|um$Wdx&D)J)$4%y&{ zrwN6JSC4;$>vQ1OVZnb3G}4@-eIpLICks55gHH(uoYs%3yz1bFEOfEG5d~M(gC~o; zXm>8V7;xb4qy)DRI1x=^NO;!dq0}0Jp#-uGaV5TlhJ+Jm1*nC<6N0NLTk|l|pTv-n zWEe+BZy1d&R6Du=EiP(worRz?5fTgTuIec>NX8IH;!b!Yh^UT1M|hIUi*R33zqY>Y zY%Q!oJJwV$y01U=Y#|s-9N>>4#zh9dzsO%i1SXXJHC5nd6kN5v2L(4}+AlLOSlM`GVv_2a#a2Z`^s(oVyzHHQ}UoC&N zBm!E`1~RyT0S%|+LXWD$58mT1!{3B~!}z8As*bLzT(n_Iohk*m-cfLrhT4)fk|T%7#Fm>s`zO;s^anDurG~YhrzF;X9AN1 zn;wKr`zxfLy;S+3{Y_>Ux;==)H6Gh>@JZuoDyJI({$Pf9rVEY8bYw`D{E1*f-pmwX zXOdD6j$Wog1TZgX5O)uhnMt}7j49Fgrm)K6t0F-cW{|{;Lcy5CAi+t8NgPOUJTXWJ ztn%cEK_Z6`Qio)zk~lc%wP8D91dDh=($dnX%{g{#!~)Z1feBe)s2;>8EnY3dhfE>N z&o4;^0Qw=57|9x-9t?jBl9*9{5(&mQ1_^9^88+a~aH0TWbgb+$EfkQr zd!TzW=_`({Skj*99*=lzgEWH1irwN#LdK%kJPuh6kbhJ+eMPxE9{8BX$I{wXI`G9(%#W)z#t zG+-E6%a9-^zrDPu!U>%4$Y2~g!NWdg7{!cY(+LYF1C>IR7?23S-WYl7D;7hLGK^6+ z3u5K**;>XOrR*YA5%Y+avWUuo)E1D)ebLX)Pu776q>3;mkSfBMK&l910%?AJz6>AZ z0eEl-M5)9P-R+?AuVadBfG9H0;SBb`lm;9vaN7)R$)q|Y&PvYU0QGz-;GoSE=PeGZ zj?hf*f^4CW#Z#22I?1Rai!5v^yOy&8)#3oQFxLR8ZDdqY)^w7tY<6WfU1c2_$fjF8 zHvgn@++|d$VFa^30I0-a5)Y_kOycg*z{xd5$r0KD5-r&RX7}#hGOEnDQ-m?&P7%h8 zJ4F~X?xfOU89ojvJQbvf8O63BWHGU_pLi)CAuu-NiHT!!h-@vVjKo_3NpU~}IZ^f< zA3!1>SYX6|CVzX1>Q@eDW!8P`vCbxc1C-c7ffK18+bq+75!+FL6Fg^^r?0R?Cj}(M z0c@N!KpZ~`3FDp8be_x-%nYEi8p+`Ut#l&I7MhW41ugP;M9L>V!%xjeadP-paQxDg z@Vwv%xHS>MVXBCwL53Swk)U} z0kygwG-_jbT_YsC`kW#EMm3Jf>QsmTd7CQHcBLFQOjN20$u!vg)672y0{6rIM&cy7!ylX9idRlI%=h& zBSsJ%2pvF;pXJ<7g&MCVP{SHVW-FALdz`Zw+XZA+*Mml_O|0RVo|iH-TWAXGBalu! zo|%+KQifs)J=sP*2W$qlP|JZ_4`S3q&p6)*6+LLQ06kz0&4o6^TwwOaFjZ#Ff!Pe5Sa35GAoG}&QKGa1xU3i}( zAUy5ZRjWksdMR6IQ6ImCz7+Obb+rsr4#-r+{Buj~BId?OMyoRA2~5fB>26kVbgI_$ zY$3#2t>T$Mstc#AG9hr(C<|dI6M`8b0wPJ*rUIKYa>X65*#@B#aHXyXEwF&Nq-y{P z0cn%219u&mMZi5!nX2xg2UfuvMptg?xnk3mjashcx^hQdjat|zl(wCcuK0~XS4=I# zjR$hWJ@2zkRrbJ*x*jxY9nd4_q%!W@QWc%>8-Y%+hT+0fz5lSSSKQV553acBdBRII z24W;qj)Bf9F_4*RtcbUIi?MO%q1IvycLL&*E~NaZUAh+Bb>SVf%-hislq{%WAoF&{ z=vMINR;`z_h21u4xnl&^B^~74pd%=A(@e$IGtp z;+AR!VxqVnynTo8_GMXqG*`?uh43b?M;}@tyxC-h!kmM!;Jz9He6K~w+TCmXA(kEY|64ScI>+?`eUC{nbk|l z?cs;SV>>SFIk@t2jl=!!Pn~QV@qIq?P(V4`zh3(iR|Q84UT_?4!p626GW>jKV7$4v z{;}qjX+xeJTRQTojk~q>{!aI8lbUtwv!LbHVPjVsOgr=D!jU{;ny~9H8Fo!{|#e{&R97|jS#O5ITl^489An? zVA!?~7X36#vfDm+Ke^|uB`zP=X4&f+#5lZopCI|P{fK4ix0=t-nA%;__!#fU3N9u{3`B5@=Wpchas&WR0=-X?%h3bhnJI%_12g9_PhfJYz>=5q)o2c zA9Q@OV}_Z~-qLY%ax3$G;~H5#+R*pVe;Fbccc^^-w&UBEgOdtE zFI_w_@0{-bIk)|#&d*G=?j`p9{p`l?+{PTcv&Flw)Xe{3`<-{6cz?WbVx87{QTp;n z;Q{LweSVi(u&dB){ils5Cl{36+&MJ)r1YKH<70C^9C&56>|;T}J?&W&_I1CTPdnWEHx%I+jaG1YsriIVF=RHy`-T20* zO-QhA_eonFY$eOrjCJm;XKG3Oc@Ej)w+}j;G&J)6oMg~Cy5G^R%})0ZoR#G2zV>m~ z8AHtbdrY-17w5E+PMs6cbJ_3_zrL@2yKwZKr_Fcy0ybF}Rj z1)LmwH?6wnz`Chv9Y4M(%PF{(9C<%YTD9kH>gQ73*(ss!Q)}N|_FLg=t?zm1Ev4Y@zDT^Ais zjnsJ~pINud`$yraw;8hodaiOWu#B<__d4M7)74%dbhGp(-&j)FVb{{|?5*b?TSXOj zdv|TG`9^U<$>T@86AHPM=e=`*wAW&vz5n&NAM0XZAKDg5G zV7iu3(}>{fRekMTc190vVp-O2j*cY!)YARcJ~`|3Tj)hEJ6?6{k(1rhAqN-FUg=g+ zy?yGns<3-il6Fy%sZW0@E1$5bO;1;w?1#zwLNZS->inp3)b^vjjbC`)>~%MJrC{0f zHCe8YO-?q$Czz@3?cihoxbhzx;(tB+I*5L z&*q?))q<|eH+LvI|Ln=gUoHg1H~MiPZ(#D)U0c%KFONSxsp9pOC$Iba_WaSgS&u{4 z#fc*m^$gt_Rc~ltRyig1=$M^1WBNExbu?Ny#I)@YOz_{v@ll}Ca#uqo= z_;f!a=Ip4f7m+R3CP%lgn5@5S$i{&KcunS~5ALw9L$1|~1KAl_%ikU-U1hR++%G0q zJeMu8$vqug5)$C{`@L_@HE#bQ%s`{!X4D1!U>otm9zKghXL-&VJL&R%l}FB;slAI^{? zCdR}iP&1@_0?Gel^W(!%=LKhH_}dV=jSIHSSn~VWldetXzRWl_t0X0)^rUI)q&E3k zUE6F-A@}UlVy(?@nm@f6RHW7Dh;a6%mo-~Ee%ZOO_TI9`B9q*0S|{&!^*bMXFRA0N zX*17eY}(vf7?%9)oQ>0N?i+D5xMX983vTB5z4p5BfzdeG7SJG+c5IjdjVr~A#e zQR1}COTQa&)pFI^7Uf<6m*1N7zv>;abIF#o(mf|#i`NDnPb-i->@Jw#y)0nNgQy?2 zw5b?yENe^5wksBw_8qMKgPtSV7Yfak=14Y`=$2%yD}Z+9pb~u7qqr2H+bb^!>eLn3 z=!C1$?3$UAh4Jy159=?ry*=;Jjw>3oA9(6|`H4fGJ=fhS5xUHc{AKl+BP+i@YZ&c* z$1Qf7nXrA;^6zqwk3aZqv44M)e)F&Uj{G@d=Hhto=fC( zyh{s0Ytwi7Y+N$vf%V28JD)jnsaMUUl=anXc+*ddk45QEDBn-nv#Ezxs`<-;v?_SgE)2xTiee!nu3tLysELvQ&VS3@2)nb#g*LH6n_^~FS zG_=bWkx887dc~o~$>BR|D%K~N=KLeHYT)qLjFBl7TeiRX_{iZ%nWI~<#w@#^-tcmU zUtQV!;Uj%lhpHb#tJb!=)gmWuiOr^4+TyKyJ1s8Uz36+L2*34R6NVXi|28#Bd@=dl zrAf8v&T-m_Ig}3k|oI>Ypf={Jbi+mFHdi>s`*|C;XB#wR!3C*w};> zt^-rGBq;^%xs_(2@%puzJxW|9OHLI$b(D5|n)y?F*yvr=NxtVquiL$T@WJkpM^>iC z7riMuzB;RFs^3cQn zv~Gv8_GcZ4G*fbeDX)>`NHt-ED>6krQ!8d=9Ln1RISxFBQ^BFISqSc{Nf}uOUVHe# z=t`m-Arn6O$W+?iEEWzSixps5fY|{4LP;cvB60A8^Z_K1Orf3vsh_8hfp0;^!%1E+ z8AFobi;zTx76AYo4PS~R!XcCwiQwVu!whiaZPcbwi#Gu3V&D(!5k8072`a+fDfkzB z0Y((z9wZkI1alQQ1vOF$-^pac=5-MK9p?!l6SAl+AI=ex`X{m-wwU-MAAA|cyF64k z6mE&bXRm|X{)xN@*dzuF8$8sRV3n+Z4dBd~u94R(fv{EM`mN+`Su5%YN00Lv4)jGM zbo#-q-{_lz;I=TqFGdPK*3u(2RT3s3#73?>Hf;&=hC+a$rf}}$mCbhp4$9AAz>D)-}&JUBbZle0lr zuwDlO7ebN(vf^v!=Q=2@fGTSO_O*KQvNp6cGNQ|bkFJ1@fC&O85%Muk;IlLBPdq&e zh6P2~XUY}?w2Fx?@t}n5=n|jOI8)Mq6279O>jY3jjnXAeDB+8Fx}*gq)CXPCh7uUF zt|WvKssrng5=}jok0qo|$WVW}4ymI&bP1`W@6augIw5WAS|W8^bJ2B39U^R99a2ZX zqwA15DIDT|6?hN>c_WfaI`Ny4{gnCqp&h=a#ncK~YVatbXaj3%t_CIF7mgM-C!-Y% z3hs%&b78zb?t$rVz5fgG}DD_;=rtpK{1ZSLwd?F*_U=Y*b>} zE0-BK$DI=|M|)EYfeQRF{h7NyMteoQF?aw>!#Vhs)z`HvXWG{nQp( z9T`96G+epN^s9r@+XlqJmA-&&w5a7>{T4{BJY(JK+Mrnd?MsEk$!^beSAa!8g#p~L z9+#Ln1LIpVoFg|uMt%JZ8Rx~LkWs&9AZtUu0vYF!a>zKxJ%fz16mA`HS%+W6;=Ha8 zcbv^k;f`~N2=2Hau!lQtFN5I@DSZgsk^av>)DrGA_+NiUoFd4G6QA)_gg<1Gf9pb1 ztzsVaT=UR}uW^Nka${1yV_)Pw5EjzWWFjoD6CjU*1+$2BC&>Vdfu*>-AIc?Am|&sU zpu}ZAgHn^r5M9|@5t*b;4ybk*5XS;q}6 zBOjQ!e1xfI@G-VPzed?H*+WKF!yzM|BOyadM?E1NVc4%PY@&i-ONAC62^*|vuy_}^ zj{$3sgpExM)L>GS74?8WsPKfVGkBXTae*s-3F!hbZ@5#tC!hIJS^?+>7A;0AB^+R~A_RclyuPK!5Nv+`3~_nE>~R zu*LtHWC9+;NQgeE{C`B)aN&m{l#{`2Fi@XJ#=#K-@-dFBxmpk@oJ0>8whV;%C)(B9UlEJ&I#-tib^JWxj6_XaDBqI80g zL>Tw+0O3ydb@JobZ76+=v-JOFQ)LNvug4CMh|$Bz$0B1ZQOrH}FZ4Jz&L^gpfv zGy}RKSNum`;fnugM|JVv6zbuZ0q{9Lyv~5!5;D#S_>C9NrTC25y6*WiI?&(g->QNC E0-T2v`v3p{ diff --git a/hsweb-boost/hsweb-boost-ftp/pom.xml b/hsweb-boost/hsweb-boost-ftp/pom.xml deleted file mode 100644 index c83d79250..000000000 --- a/hsweb-boost/hsweb-boost-ftp/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - hsweb-boost - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-boost-ftp - - ftp操作工具,使用ftp连接池. - - - - org.apache.commons - commons-pool2 - - - commons-net - commons-net - 3.4 - - - org.springframework.boot - spring-boot-starter - true - - - org.jooq - jool-java-8 - - - \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/DefaultFTPOperation.java b/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/DefaultFTPOperation.java deleted file mode 100644 index d582239f7..000000000 --- a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/DefaultFTPOperation.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.hswebframework.web.ftp; - -import lombok.AllArgsConstructor; -import lombok.SneakyThrows; -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; -import org.hswebframework.web.ftp.pool.FTPClientPool; -import org.jooq.lambda.Unchecked; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * @author zhouhao - * @since 3.0 - */ -@AllArgsConstructor -public class DefaultFTPOperation implements FTPOperation { - - private FTPClientPool pool; - - @SneakyThrows - protected FTPClient getClient() { - return pool.borrowObject(); - } - - protected void returnClient(FTPClient client) { - pool.returnObject(client); - } - - public T doExecute(Function function) { - FTPClient client = getClient(); - try { - return function.apply(client); - } finally { - returnClient(client); - } - } - - @Override - public boolean delete(String fileName) { - return doExecute(Unchecked.function(client -> client.deleteFile(fileName))); - } - - @Override - public boolean rename(String from, String to) { - return doExecute(Unchecked.function(client -> client.rename(from, to))); - } - - @Override - public boolean download(String fileName, OutputStream outputStream) { - return doExecute(Unchecked.function(client -> client.retrieveFile(fileName, outputStream))); - } - - @Override - public boolean upload(String fileName, InputStream input) { - return doExecute(Unchecked.function(client -> client.storeFile(fileName, input))); - } - - @Override - public boolean upload(String fileName, String text) { - return doExecute(Unchecked.function(client -> { - try (ByteArrayInputStream inputStream = new ByteArrayInputStream(text.getBytes())) { - return client.storeFile(fileName, inputStream); - } - })); - } - - @Override - public void list(String path, Consumer consumer) { - doExecute(Unchecked.function(client -> { - Arrays.stream(client.listFiles(path)).forEach(consumer); - return null; - })); - } -} diff --git a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/FTPOperation.java b/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/FTPOperation.java deleted file mode 100644 index e76a3d09a..000000000 --- a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/FTPOperation.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.ftp; - -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface FTPOperation { - - boolean delete(String fileName); - - boolean rename(String from, String to); - - boolean download(String fileName, OutputStream outputStream); - - boolean upload(String fileName, InputStream input); - - boolean upload(String fileName, String text); - - void list(String path, Consumer consumer); - - T doExecute(Function command); - - interface HandleExceptionFunction{ - T apply(FTPClient client) throws Exception; - } - -} diff --git a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientFactory.java b/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientFactory.java deleted file mode 100644 index 9b9306448..000000000 --- a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientFactory.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.hswebframework.web.ftp.pool; - -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPReply; -import org.apache.commons.pool2.PooledObject; -import org.apache.commons.pool2.PooledObjectFactory; -import org.apache.commons.pool2.impl.DefaultPooledObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.ConnectException; - - -public class FTPClientFactory implements PooledObjectFactory { - private static Logger logger = LoggerFactory.getLogger(FTPClientFactory.class); - private FTPClientProperties config; - - public FTPClientFactory(FTPClientProperties config) { - this.config = config; - } - - public PooledObject makeObject() throws Exception { - FTPClient ftpClient = new FTPClient(); - ftpClient.setConnectTimeout(config.getClientTimeout()); - ftpClient.connect(config.getHost(), config.getPort()); - int reply = ftpClient.getReplyCode(); - if (!FTPReply.isPositiveCompletion(reply)) { - ftpClient.disconnect(); - logger.warn("FTPServer refused connection"); - return null; - } - boolean result = ftpClient.login(config.getUsername(), config.getPassword()); - if (!result) { - throw new ConnectException("ftp登陆失败:" + config.getUsername() + "/password:" + config.getPassword() + "@" + config.getHost()); - } - ftpClient.setFileType(config.getTransferFileType()); - ftpClient.setBufferSize(1024); - ftpClient.setControlEncoding(config.getEncoding()); - if (config.isPassiveMode()) { - ftpClient.enterLocalPassiveMode(); - } - return new DefaultPooledObject<>(ftpClient); - - } - - @Override - public void destroyObject(PooledObject p) throws Exception { - try { - p.getObject().logout(); - } finally { - p.getObject().disconnect(); - } - } - - @Override - public boolean validateObject(PooledObject p) { - try { - p.getObject().sendNoOp(); - } catch (IOException e) { - logger.warn("validateObject ftp error!", e); - return false; - } - return p.getObject().isConnected() && p.getObject().isAvailable(); - } - - @Override - public void activateObject(PooledObject p) throws Exception { - p.getObject().sendNoOp(); - } - - @Override - public void passivateObject(PooledObject p) { - - } -} \ No newline at end of file diff --git a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientPool.java b/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientPool.java deleted file mode 100644 index 04aa2e8e4..000000000 --- a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientPool.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.ftp.pool; - -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.pool2.PooledObjectFactory; -import org.apache.commons.pool2.impl.AbandonedConfig; -import org.apache.commons.pool2.impl.GenericObjectPool; -import org.apache.commons.pool2.impl.GenericObjectPoolConfig; - -public class FTPClientPool extends GenericObjectPool { - - public FTPClientPool(PooledObjectFactory factory) { - super(factory); - } - - public FTPClientPool(PooledObjectFactory factory, GenericObjectPoolConfig config) { - super(factory, config); - } - - public FTPClientPool(PooledObjectFactory factory, GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) { - super(factory, config, abandonedConfig); - } -} diff --git a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientProperties.java b/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientProperties.java deleted file mode 100644 index 9f3961ae9..000000000 --- a/hsweb-boost/hsweb-boost-ftp/src/main/java/org/hswebframework/web/ftp/pool/FTPClientProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.ftp.pool; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.pool2.impl.GenericObjectPoolConfig; - -@Getter -@Setter -@ToString -public class FTPClientProperties extends GenericObjectPoolConfig { - private String host; - private int port = 22; - private String username; - private String password; - private boolean passiveMode = true; - private String encoding = "utf-8"; - private int clientTimeout = 10 * 1000; - private int threadNum = 20; - private int transferFileType = FTPClient.BINARY_FILE_TYPE; - private boolean renameUploaded = false; - private int retryTimes = 3; - -} \ No newline at end of file diff --git a/hsweb-boost/pom.xml b/hsweb-boost/pom.xml deleted file mode 100644 index 90bb6d9f2..000000000 --- a/hsweb-boost/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - hsweb-framework - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - 一些增强功能 - hsweb-boost - pom - - hsweb-boost-aop - hsweb-boost-ftp - hsweb-boost-excel - - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-bean/pom.xml b/hsweb-commons/hsweb-commons-bean/pom.xml deleted file mode 100644 index 2b7c6dc58..000000000 --- a/hsweb-commons/hsweb-commons-bean/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - hsweb-commons - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-commons-bean - - 通用增删改查-通用Bean模块 - - - - - org.hswebframework.web - hsweb-core - ${project.version} - - - org.hibernate - hibernate-validator - - - org.springframework.boot - spring-boot-starter - true - - - - org.spockframework - spock-core - test - - - - com.athaydes - spock-reports - 1.2.13 - test - - - org.glassfish - javax.el - test - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/Bean.java b/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/Bean.java deleted file mode 100644 index 06d167ed7..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/Bean.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.commons.bean; - -import org.hswebframework.web.bean.FastBeanCopier; - -import java.io.Serializable; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface Bean extends Serializable { - /** - * 从指定的对象中复制属性到本对象 - * - * @param from 要复制的对象 - * @param ignore 不复制的字段 - * @param 对象类型 - * @return 原始对象 - * @see FastBeanCopier - */ - @SuppressWarnings("all") - default T copyFrom(Object from, String... ignore) { - return (T) FastBeanCopier.copy(from, this, ignore); - } - - /** - * 将对象的属性复制到指定的对象中 - * - * @param to 要复制到的对象 - * @param ignore 不复制的字段 - * @param 对象类型 - * @return 复制后的对象 - * @see FastBeanCopier - */ - default T copyTo(T to, String... ignore) { - return FastBeanCopier.copy(this, to, ignore); - } -} diff --git a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidator.java b/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidator.java deleted file mode 100644 index b166e4b9e..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidator.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.commons.bean; - -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.web.validate.SimpleValidateResults; -import org.hswebframework.web.validate.ValidationException; - -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import java.util.Set; - -/** - * @author zhouhao - * @since 3.0 - */ -@Slf4j -public final class BeanValidator { - - private BeanValidator() { - } - - static volatile Validator validator; - - public static Validator getValidator() { - if (validator == null) { - synchronized (BeanValidator.class) { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - return validator = factory.getValidator(); - } - } - return validator; - } - - public static T tryValidate(T bean, Class... group) { - Set> violations = getValidator().validate(bean, group); - if (!violations.isEmpty()) { - SimpleValidateResults results = new SimpleValidateResults(); - for (ConstraintViolation violation : violations) { - results.addResult(violation.getPropertyPath().toString(), violation.getMessage()); - } - throw new ValidationException(results); - } - return bean; - } -} diff --git a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidatorAutoConfiguration.java b/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidatorAutoConfiguration.java deleted file mode 100644 index 47f20afaa..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/BeanValidatorAutoConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.commons.bean; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -public class BeanValidatorAutoConfiguration implements BeanPostProcessor { - @Bean(name = "validator") - @ConditionalOnMissingBean(Validator.class) - public Validator validator() { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - return factory.getValidator(); - } - - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof Validator) { - BeanValidator.validator = ((Validator) bean); - } - return bean; - } -} diff --git a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/ValidateBean.java b/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/ValidateBean.java deleted file mode 100644 index d504f4821..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/main/java/org/hswebframework/web/commons/bean/ValidateBean.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.commons.bean; - -/** - * 支持验证的bean - * - * @author zhouhao - * @since 3.0 - */ -public interface ValidateBean extends Bean { - - /** - * 尝试验证此bean,如果验证未通过,将抛出{@link org.hswebframework.web.validate.ValidationException} - * - * @param group 验证分组 - * @param 当前对象类型 - * @return 当前对象 - */ - default T tryValidate(Class... group) { - BeanValidator.tryValidate(this, group); - return (T) this; - } -} diff --git a/hsweb-commons/hsweb-commons-bean/src/main/resources/META-INF/spring.factories b/hsweb-commons/hsweb-commons-bean/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 0bdb7216a..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.commons.bean.BeanValidatorAutoConfiguration \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/BeanValidatorTest.groovy b/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/BeanValidatorTest.groovy deleted file mode 100644 index 73777f9dc..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/BeanValidatorTest.groovy +++ /dev/null @@ -1,43 +0,0 @@ -package org.hswebframework.web.commons.bean - -import org.hibernate.validator.constraints.NotBlank -import org.hswebframework.web.validator.group.CreateGroup -import org.hswebframework.web.validator.group.UpdateGroup - -/** - * @author zhouhao - * @since 3.0.2 - */ -class BeanValidatorTest extends spock.lang.Specification { - - def "测试初始化验证器"() { - given: "初始化" - def validator = BeanValidator.getValidator(); - expect: "成功" - null != validator - } - - - def doValidate(TestBean bean, Class group) { - try { - bean.tryValidate(group); - return null; - } catch (Exception e) { - return e.message; - } - } - - def "测试group验证"() { - expect: "验证多个group" - doValidate(new TestBean(name: name), group as Class) == message - where: - name | group | message - null | CreateGroup.class | "姓名不能为空" - "" | CreateGroup.class | "姓名不能为空" - null | UpdateGroup.class | null - "" | UpdateGroup.class | "长度必须在2-20之间" - "张三" | UpdateGroup.class | null - } - - -} diff --git a/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/TestBean.java b/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/TestBean.java deleted file mode 100644 index d93a7c51d..000000000 --- a/hsweb-commons/hsweb-commons-bean/src/test/groovy/org/hswebframework/web/commons/bean/TestBean.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.commons.bean; - -import lombok.Data; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.validator.group.CreateGroup; -import org.hswebframework.web.validator.group.UpdateGroup; - -/** - * @author zhouhao - * @since 3.0.2 - */ -@Data -public class TestBean implements ValidateBean { - - @NotBlank(groups = CreateGroup.class, message = "姓名不能为空") - @Length(min = 2, max = 20, message = "长度必须在2-20之间", groups = UpdateGroup.class) - private String name; - -} diff --git a/hsweb-commons/hsweb-commons-controller/README.md b/hsweb-commons/hsweb-commons-controller/README.md deleted file mode 100644 index 814bed58d..000000000 --- a/hsweb-commons/hsweb-commons-controller/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# 通用Controller -提供增删改查的restful接口 - - 以`RequestMapping("/user)`为例 - -| 功能 | http method&url | 响应 | 说明 | -| ------------- | -------------| ------------- | ----| -|查询|GET /user|HTTP Status:200 {"status":200,"result":{"data":[],"total":0}} |可进行[动态查询](#动态查询)| -|不分页查询|GET /user/no-paging|HTTP Status:200 {"status":200,"result":[]} |可进行[动态查询](#动态查询)| -|获取指定id的数据|GET /user/{id}|HTTP Status:200 {"status":200,"result":{"name":""} |可进行[动态查询](#动态查询)| -|新增|POST /user|HTTP Status:201 {"status":201,"result":"{id}"} |contentType='application/json' | -|更新|PUT /user/{id}|HTTP Status:200 {"status":200} |contentType='application/json'| -|新增或者更新|PATCH /user|HTTP Status:200 {"status":200,"result":"{id}"} |contentType='application/json' | -|删除|DELETE /user/{id}|HTTP Status:200 {"status":200} | | - -# 动态查询 - -目前支持动态查询条件类 `QueryParamEntity`: -前端传参数: -1. 普通条件 -```html -terms[0].column=name&terms[0].termType=like&terms[0].value=张三 -``` -等同于sql -```sql -where name like ? -where name like '张三' -``` - -2. 复杂条件 -```html -terms[0].column=name&terms[0].termType=eq&terms[0].value=张三 -&terms[1].column=name&terms[1].termType=eq&terms[1].type=or&terms[1].value=李四 -``` -等同于sql -```sql -where name =? or name = ? -where name = '张三' or name = '李四' -``` - -3. 嵌套条件 -```html -terms[0].column=name&terms[0].termType=like&terms[0].value=张% -&terms[1].type=and -&terms[1].terms[0].column=age&terms[1].terms[0].termType=gt&terms[1].terms[0].value=10 -&terms[1].terms[1].column=age&terms[1].terms[1].termType=lt&terms[1].terms[1].value=18 - -``` -等同于sql -```sql -where name like ? and (age>? and age 10 and age <18) - -``` - -4. 排序 -```html -sorts[0].name=age&sorts[0].order=desc -``` -等同于sql -```sql -order by age desc -``` - -5. 分页 -```html -pageIndex=0&pageSize=20 -``` - -不分页查询 -```html -paging=false -``` - -6. 指定要查询的列 -```html -includes=id,name,age -``` -等同于sql -```sql -select id,name,age from ...... -``` -不查询的列参数为excludes,如:`excludes=comment,phone` - -注意: 以上参数都进行了验证,不会有sql注入问题。 diff --git a/hsweb-commons/hsweb-commons-controller/pom.xml b/hsweb-commons/hsweb-commons-controller/pom.xml deleted file mode 100644 index 0f0efd6f1..000000000 --- a/hsweb-commons/hsweb-commons-controller/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - hsweb-commons - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-commons-controller - - 通用增删改查-通用Controller模块 - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - com.alibaba - fastjson - - - org.hswebframework - hsweb-easy-orm-rdb - - - org.hswebframework.web - hsweb-access-logging-api - ${project.version} - - - org.hswebframework.web - hsweb-authorization-api - ${project.version} - - - org.springframework - spring-webmvc - - - org.hswebframework.web - hsweb-commons-model - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CreateController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CreateController.java deleted file mode 100644 index 526467352..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CreateController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 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; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.CreateEntityService; -import org.hswebframework.web.service.InsertService; -import org.hswebframework.web.validator.group.CreateGroup; -import org.springframework.http.HttpStatus; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 通用新增控制器
- * 使用:实现该接口,注解@RestController 以及@RequestMapping("/myController") - * 客户端调用: 通过POST请求,contentType为application/json 。参数为E泛型的json格式 - *
- * curl -l -H "Content-type: application/json" -X POST -d '{"field1":"value1","field2":"value2"}' http://domain/contextPath/myController
- * 
- * - * @author zhouhao - * @since 3.0 - */ -public interface CreateController { - - @Authorize(ignore = true) - & CreateEntityService> S getService(); - - @Authorize(action = Permission.ACTION_ADD) - @PostMapping - @ResponseStatus(HttpStatus.CREATED) - @ApiOperation(value = "新增") - default ResponseMessage add(@RequestBody M data) { - E entity = modelToEntity(data, getService().createEntity()); - //自动添加创建人和创建时间 - if (entity instanceof RecordCreationEntity) { - RecordCreationEntity creationEntity = (RecordCreationEntity) entity; - creationEntity.setCreateTimeNow(); -// creationEntity.setCreatorId(Authentication.current() -// .map(Authentication::getUser) -// .map(User::getId) -// .orElse(null)); - } - //修改人和修改时间 - if (entity instanceof RecordModifierEntity) { - RecordModifierEntity creationEntity = (RecordModifierEntity) entity; - creationEntity.setModifyTimeNow(); -// creationEntity.setModifierId(Authentication.current() -// .map(Authentication::getUser) -// .map(User::getId) -// .orElse(null)); - } - return ok(getService().insert(entity)); - } - - @Authorize(ignore = true) - E modelToEntity(M model, E entity); -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CrudController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CrudController.java deleted file mode 100644 index 789b405a1..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/CrudController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.service.CrudService; - -/** - * 通用增删改查控制器 - * - * @author zhouhao - * @see QueryController - * @see CreateController - * @see UpdateController - * @see DeleteController - * @see CrudService - * @since 3.0 - */ -public interface CrudController - extends QueryController - , UpdateController - , CreateController - , DeleteController { - - @Override - @SuppressWarnings("unchecked") - @Authorize(ignore = true) - CrudService getService(); - - @Override - @Authorize(ignore = true) - default E modelToEntity(M model, E entity) { - return FastBeanCopier.copy(model, entity); - } -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/DeleteController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/DeleteController.java deleted file mode 100644 index 6be2125c2..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/DeleteController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019 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; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.DeleteService; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 通用删除控制器 - * - * @author zhouhao - */ -public interface DeleteController { - - @Authorize(ignore = true) - DeleteService getService(); - - @Authorize(action = Permission.ACTION_DELETE) - @DeleteMapping(path = "/{id:.+}") - @ApiOperation("删除数据") - default ResponseMessage deleteByPrimaryKey(@PathVariable PK id) { - return ok(getService().deleteByPk(id)); - } - -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityController.java deleted file mode 100644 index 98e2429a8..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 通用实体的增删改查控制器 - * - * @author zhouhao - * @see GenericEntity - * @see CrudController - * @see CrudService - */ -public interface GenericEntityController, PK, Q extends Entity, M> - extends CrudController { - - @Override - @Authorize(ignore = true) - CrudService getService(); - -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/QueryController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/QueryController.java deleted file mode 100644 index 8f2fe97b9..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/QueryController.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2019 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; - -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.service.QueryByEntityService; -import org.hswebframework.web.service.QueryService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.List; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 通用查询控制器。 - * - * @param 实体类型 - * @param 主键类型 - * @param 查询条件实体类型,默认提供{@link QueryParamEntity}实现 - * @author zhouhao - * @see QueryParamEntity - * @see 3.0 - */ -public interface QueryController { - - /** - * 获取实现了{@link QueryByEntityService}和{@link QueryService}的服务类 - * - * @param 服务类泛型 - * @return 服务类实例 - */ - @Authorize(ignore = true) - & QueryService> T getService(); - - /** - * 根据参数动态查询。
- * 参数泛型如果为QueryParamEntity, - * 客户的参数 ?terms[0].column=name&terms[0].value=小明 - * 则执行查询条件 where name = '小明' - * 具体使用方法参照 {@link QueryParamEntity} - * - * @param param 参数 - * @return 查询结果 - */ - @Authorize(action = Permission.ACTION_QUERY) - @GetMapping - @ApiOperation(value = "根据动态条件查询", responseReference = "get") - default ResponseMessage> list(Q param) { - return ok(getService().selectPager(param)); - } - - @Authorize(action = Permission.ACTION_QUERY) - @GetMapping("/no-paging") - @ApiOperation(value = "不分页动态查询", responseReference = "get") - default ResponseMessage> listNoPaging(Q param) { - if (param instanceof QueryParamEntity) { - ((QueryParamEntity) param).setPaging(false); - } - return ok(getService().select(param)); - } - - @Authorize(action = Permission.ACTION_QUERY) - @GetMapping("/count") - @ApiOperation(value = "根据动态条件统计", responseReference = "get") - default ResponseMessage count(Q param) { - return ok(getService().count(param)); - } - - - @Authorize(action = Permission.ACTION_GET) - @GetMapping(path = "/{id:.+}") - @ApiOperation("根据主键查询") - default ResponseMessage getByPrimaryKey(@PathVariable PK id) { - return ok(assertNotNull(getService().selectByPk(id))); - } - - @Authorize(action = Permission.ACTION_GET) - @GetMapping(path = "/ids") - @ApiOperation("根据主键查询多条记录") - default ResponseMessage> getByPrimaryKey(@RequestParam List ids) { - return ok(assertNotNull(getService().selectByPk(ids))); - } - - @Authorize(ignore = true) - static T assertNotNull(T obj) { - if (null == obj) { - throw new NotFoundException("{data_not_exist}"); - } - return obj; - } - -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleCrudController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleCrudController.java deleted file mode 100644 index b0ab97b4b..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleCrudController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.service.CrudService; -import org.springframework.beans.BeanUtils; - -/** - * 通用增删改查控制器 - * - * @author zhouhao - * @see QueryController - * @see CreateController - * @see UpdateController - * @see DeleteController - * @see CrudService - * @since 3.0 - */ -public interface SimpleCrudController - extends QueryController - , UpdateController - , CreateController - , DeleteController { - - @Override - @SuppressWarnings("unchecked") - @Authorize(ignore = true) - CrudService getService(); - - @Override - @Authorize(ignore = true) - default E modelToEntity(E model, E entity) { - // model = entity - return model; - } -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleGenericEntityController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleGenericEntityController.java deleted file mode 100644 index 963d9516d..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/SimpleGenericEntityController.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 通用实体的增删改查控制器 - * - * @author zhouhao - * @see GenericEntity - * @see CrudController - * @see CrudService - */ -public interface SimpleGenericEntityController, PK, Q extends Entity> - extends SimpleCrudController { - - @Override - @Authorize(ignore = true) - CrudService getService(); - - -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/UpdateController.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/UpdateController.java deleted file mode 100644 index bab572039..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/UpdateController.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2019 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; - - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.Logical; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.CreateEntityService; -import org.hswebframework.web.service.UpdateService; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * 通用更新控制器 - * - * @author zhouhao - */ -public interface UpdateController { - & CreateEntityService> S getService(); - - @Authorize(action = Permission.ACTION_UPDATE) - @PutMapping(path = "/{id}") - @ApiOperation("修改数据") - default ResponseMessage updateByPrimaryKey(@PathVariable PK id, @RequestBody M data) { - E entity = modelToEntity(data, getService().createEntity()); - if (entity instanceof RecordModifierEntity) { - RecordModifierEntity creationEntity = (RecordModifierEntity) entity; - creationEntity.setModifyTimeNow(); - creationEntity.setModifierId(Authentication.current() - .map(Authentication::getUser) - .map(User::getId) - .orElse(null)); - } - return ResponseMessage.ok(getService().updateByPk(id, entity)); - } - - @Authorize(action = {Permission.ACTION_UPDATE, Permission.ACTION_ADD}, logical = Logical.AND) - @PatchMapping - @ApiOperation("新增或者修改") - default ResponseMessage saveOrUpdate(@RequestBody M data) { - E entity = modelToEntity(data, getService().createEntity()); - //自动添加创建人和创建时间 - if (entity instanceof RecordCreationEntity) { - RecordCreationEntity creationEntity = (RecordCreationEntity) entity; - creationEntity.setCreateTimeNow(); - creationEntity.setCreatorId(Authentication.current() - .map(Authentication::getUser) - .map(User::getId) - .orElse(null)); - } - //修改人和修改时间 - if (entity instanceof RecordModifierEntity) { - RecordModifierEntity creationEntity = (RecordModifierEntity) entity; - creationEntity.setModifyTimeNow(); - creationEntity.setModifierId(Authentication.current() - .map(Authentication::getUser) - .map(User::getId) - .orElse(null)); - } - return ResponseMessage.ok(getService().saveOrUpdate(entity)); - } - - /** - * 将model转为entity - * - * @param model - * @param entity - * @return 转换后的结果 - * @see org.hswebframework.web.commons.model.Model - * @see org.hswebframework.web.commons.entity.Entity - */ - @Authorize(ignore = true) - E modelToEntity(M model, E entity); -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/MapResponseMessage.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/MapResponseMessage.java deleted file mode 100644 index e78025b63..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/MapResponseMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.controller.message; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * @author zhouhao - */ -public class MapResponseMessage extends ResponseMessage> { - public MapResponseMessage() { - result(new LinkedHashMap<>()); - } - - public MapResponseMessage put(String key, Object value) { - result.put(key, value); - return this; - } - - public static MapResponseMessage ok() { - return new MapResponseMessage(); - } - - public static MapResponseMessage ok(String message) { - MapResponseMessage responseMessage = new MapResponseMessage(); - responseMessage.message = message; - return responseMessage; - } - - public static MapResponseMessage error() { - return new MapResponseMessage(); - } - - - public static MapResponseMessage error(String message) { - MapResponseMessage mapResponseMessage = new MapResponseMessage(); - mapResponseMessage.message = message; - return mapResponseMessage; - } - - public static MapResponseMessage error(int status, String message) { - MapResponseMessage mapResponseMessage = new MapResponseMessage(); - mapResponseMessage.message = message; - mapResponseMessage.status = status; - return mapResponseMessage; - } -} diff --git a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java b/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java deleted file mode 100644 index b5be97fad..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * - * * Copyright 2019 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.message; - - -import com.alibaba.fastjson.JSON; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; -import java.lang.reflect.Field; -import java.util.*; - -/** - * 响应消息,controller中处理后,返回此对象,响应请求结果给客户端。 - * - * @since 2.0 - */ -@ApiModel(description = "响应结果") -public class ResponseMessage implements Serializable { - private static final long serialVersionUID = 8992436576262574064L; - - protected String message; - - protected T result; - - protected int status; - - private Long timestamp; - - /** - * @since 3.0.0-RC - */ - private String code; - - @ApiModelProperty("调用结果消息") - public String getMessage() { - return message; - } - - @ApiModelProperty(value = "状态码", required = true) - public int getStatus() { - return status; - } - - @ApiModelProperty("成功时响应数据") - public T getResult() { - return result; - } - - @ApiModelProperty(value = "时间戳", required = true, dataType = "Long") - public Long getTimestamp() { - return timestamp; - } - - @ApiModelProperty(value = "业务代码") - public String getCode() { - return code; - } - - public static ResponseMessage error(String message) { - return error(500, message); - } - - public static ResponseMessage error(int status, String message) { - ResponseMessage msg = new ResponseMessage<>(); - msg.message = message; - msg.status(status); - return msg.putTimeStamp(); - } - - public static ResponseMessage ok() { - return ok(null); - } - - private ResponseMessage putTimeStamp() { - this.timestamp = System.currentTimeMillis(); - return this; - } - - public static ResponseMessage ok(T result) { - return new ResponseMessage() - .result(result) - .putTimeStamp() - .status(200); - } - - public ResponseMessage result(T result) { - this.result = result; - return this; - } - - - public ResponseMessage code(String code) { - this.code = code; - return this; - } - - /** - * 过滤字段:指定需要序列化的字段 - */ - private transient Map, Set> includes; - - /** - * 过滤字段:指定不需要序列化的字段 - */ - private transient Map, Set> excludes; - - public ResponseMessage() { - - } - - public ResponseMessage include(Class type, String... fields) { - return include(type, Arrays.asList(fields)); - } - - public ResponseMessage include(Class type, Collection fields) { - if (includes == null) { - includes = new HashMap<>(); - } - if (fields == null || fields.isEmpty()) { - return this; - } - fields.forEach(field -> { - if (field.contains(".")) { - String tmp[] = field.split("[.]", 2); - try { - Field field1 = type.getDeclaredField(tmp[0]); - if (field1 != null) { - include(field1.getType(), tmp[1]); - } - } catch (Exception ignore) { - } - } else { - getStringListFromMap(includes, type).add(field); - } - }); - return this; - } - - public ResponseMessage exclude(Class type, Collection fields) { - if (excludes == null) { - excludes = new HashMap<>(); - } - if (fields == null || fields.isEmpty()) { - return this; - } - fields.forEach(field -> { - if (field.contains(".")) { - String tmp[] = field.split("[.]", 2); - try { - Field field1 = type.getDeclaredField(tmp[0]); - if (field1 != null) { - exclude(field1.getType(), tmp[1]); - } - } catch (Exception ignore) { - } - } else { - getStringListFromMap(excludes, type).add(field); - } - }); - return this; - } - - public ResponseMessage exclude(Collection fields) { - if (excludes == null) { - excludes = new HashMap<>(); - } - if (fields == null || fields.isEmpty()) { - return this; - } - Class type; - if (getResult() != null) { - type = getResult().getClass(); - } else { - return this; - } - exclude(type, fields); - return this; - } - - public ResponseMessage include(Collection fields) { - if (includes == null) { - includes = new HashMap<>(); - } - if (fields == null || fields.isEmpty()) { - return this; - } - Class type; - if (getResult() != null) { - type = getResult().getClass(); - } else { - return this; - } - include(type, fields); - return this; - } - - public ResponseMessage exclude(Class type, String... fields) { - return exclude(type, Arrays.asList(fields)); - } - - public ResponseMessage exclude(String... fields) { - return exclude(Arrays.asList(fields)); - } - - public ResponseMessage include(String... fields) { - return include(Arrays.asList(fields)); - } - - protected Set getStringListFromMap(Map, Set> map, Class type) { - return map.computeIfAbsent(type, k -> new HashSet<>()); - } - - @Override - public String toString() { - return JSON.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss"); - } - - public ResponseMessage status(int status) { - this.status = status; - return this; - } - - @ApiModelProperty(hidden = true) - public Map, Set> getExcludes() { - return excludes; - } - - @ApiModelProperty(hidden = true) - public Map, Set> getIncludes() { - return includes; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setResult(T result) { - this.result = result; - } - - public void setStatus(int status) { - this.status = status; - } - - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-controller/src/main/resources/hsweb-module.json b/hsweb-commons/hsweb-commons-controller/src/main/resources/hsweb-module.json deleted file mode 100644 index c7f79f0ae..000000000 --- a/hsweb-commons/hsweb-commons-controller/src/main/resources/hsweb-module.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "groupId": "${project.groupId}", - "artifactId": "${project.artifactId}", - "path": "hsweb-commons/hsweb-commons-controller", - - "gitCommitHash": "${git.commit.hash}", - "gitRepository": "http://github.com/hs-web/hsweb-framework", - "version": "${project.version}" -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-crud/pom.xml b/hsweb-commons/hsweb-commons-crud/pom.xml index 6ba479877..9d8a36019 100644 --- a/hsweb-commons/hsweb-commons-crud/pom.xml +++ b/hsweb-commons/hsweb-commons-crud/pom.xml @@ -28,7 +28,21 @@ spring-tx + + org.hswebframework.web + hsweb-core + ${project.version} + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + + + + org.hibernate.validator + hibernate-validator + diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Service.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/Entity.java similarity index 78% rename from hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Service.java rename to hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/Entity.java index 07f258b3c..4b40796de 100644 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Service.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/Entity.java @@ -16,10 +16,18 @@ * */ -package org.hswebframework.web.service; +package org.hswebframework.web.crud.entity; + + +import java.io.Serializable; /** + * 实体总接口,所有实体需实现此接口 + * * @author zhouhao + * @since 3.0 */ -public interface Service { +public interface Entity extends Serializable { + + } diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/LogicalDeleteEntity.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/LogicalDeleteEntity.java new file mode 100644 index 000000000..75a6a5164 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/LogicalDeleteEntity.java @@ -0,0 +1,19 @@ +package org.hswebframework.web.crud.entity; + +/** + * 逻辑删除 + * + * @author zhouhao + * @since 3.0.6 + */ +public interface LogicalDeleteEntity { + + Boolean getDeleted(); + + void setDeleted(boolean deleted); + + Long getDeleteTime(); + + void setDeleteTime(Long deleteTime); + +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/PagerResult.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/PagerResult.java index cbd5e336e..636aa68cf 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/PagerResult.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/PagerResult.java @@ -21,6 +21,7 @@ package org.hswebframework.web.crud.entity; import lombok.Getter; import lombok.Setter; +import org.hswebframework.ezorm.core.param.QueryParam; import java.util.ArrayList; import java.util.List; @@ -38,7 +39,7 @@ public class PagerResult { return new PagerResult<>(total, list); } - public static PagerResult of(int total, List list, QueryParamEntity entity) { + public static PagerResult of(int total, List list, QueryParam entity) { PagerResult pagerResult = new PagerResult<>(total, list); pagerResult.setPageIndex(entity.getThinkPageIndex()); pagerResult.setPageSize(entity.getPageSize()); diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordCreationEntity.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordCreationEntity.java new file mode 100644 index 000000000..f1514d12d --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordCreationEntity.java @@ -0,0 +1,30 @@ +package org.hswebframework.web.crud.entity; + +/** + * 记录创建信息的实体类,包括创建人和创建时间。 + * 此实体类与行级权限控制相关联:只能操作自己创建的数据 + * + * @author zhouhao + * @since 3.0 + */ +public interface RecordCreationEntity extends Entity { + + String creatorId = "creatorId"; + String createTime = "createTime"; + + String getCreatorId(); + + void setCreatorId(String creatorId); + + Long getCreateTime(); + + void setCreateTime(Long createTime); + + default void setCreateTimeNow() { + setCreateTime(System.currentTimeMillis()); + } + + default String getCreatorIdProperty() { + return creatorId; + } +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordModifierEntity.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordModifierEntity.java new file mode 100644 index 000000000..f45b439d2 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/RecordModifierEntity.java @@ -0,0 +1,29 @@ +package org.hswebframework.web.crud.entity; + +/** + * 记录修改信息的实体类,包括修改人和修改时间。 + * + * @author zhouhao + * @since 3.0.6 + */ +public interface RecordModifierEntity extends Entity { + + String modifierId = "modifierId"; + String modifyTime = "modifyTime"; + + String getModifierId(); + + void setModifierId(String modifierId); + + Long getModifyTime(); + + void setModifyTime(Long modifyTime); + + default void setModifyTimeNow() { + setModifyTime(System.currentTimeMillis()); + } + + default String getModifierIdProperty() { + return modifierId; + } +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultMapperFactory.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultMapperFactory.java new file mode 100644 index 000000000..bb828b1a0 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultMapperFactory.java @@ -0,0 +1,12 @@ +package org.hswebframework.web.crud.entity.factory; + +import java.util.function.Function; + +/** + * 默认的实体映射 + * + * @author zhouhao + */ +@FunctionalInterface +public interface DefaultMapperFactory extends Function { +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultPropertyCopier.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultPropertyCopier.java new file mode 100644 index 000000000..6dba6d76d --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/DefaultPropertyCopier.java @@ -0,0 +1,10 @@ +package org.hswebframework.web.crud.entity.factory; + +/** + * 默认的属性复制器 + * + * @author zhouhao + */ +@FunctionalInterface +public interface DefaultPropertyCopier extends PropertyCopier { +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/EntityFactory.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/EntityFactory.java new file mode 100644 index 000000000..1939c644a --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/EntityFactory.java @@ -0,0 +1,113 @@ +/* + * + * * Copyright 2019 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.crud.entity.factory; + + +/** + * 实体工厂接口,系统各个地方使用此接口来创建实体,在实际编码中也应该使用此接口来创建实体,而不是使用new方式来创建 + * + * @author zhouhao + * @see MapperEntityFactory + * @since 3.0 + */ +public interface EntityFactory { + /** + * 根据类型创建实例 + *

+ * e.g. + *

+     *  entityFactory.newInstance(UserEntity.class);
+     * 
+ * + * @param entityClass 要创建的class + * @param 类型 + * @return 创建结果 + */ + T newInstance(Class entityClass); + + + /** + * 根据类型创建实例,如果类型无法创建,则使用默认类型进行创建 + *

+ * e.g. + *

+     *  entityFactory.newInstance(UserEntity.class,SimpleUserEntity.class);
+     * 
+ * + * @param entityClass 要创建的class + * @param defaultClass 默认class,当{@code entityClass}无法创建时使用此类型进行创建 + * @param 类型 + * @return 实例 + */ + T newInstance(Class entityClass, Class defaultClass); + + /** + * 创建实体并设置默认的属性 + * + * @param entityClass 实体类型 + * @param defaultProperties 默认属性 + * @param 默认属性的类型 + * @param 实体类型 + * @return 创建结果 + * @see EntityFactory#copyProperties(Object, Object) + */ + default T newInstance(Class entityClass, S defaultProperties) { + return copyProperties(defaultProperties, newInstance(entityClass)); + } + + /** + * 创建实体并设置默认的属性 + * + * @param entityClass 实体类型 + * @param defaultClass 默认class + * @param defaultProperties 默认属性 + * @param 默认属性的类型 + * @param 实体类型 + * @return 创建结果 + * @see EntityFactory#copyProperties(Object, Object) + */ + default T newInstance(Class entityClass, Class defaultClass, S defaultProperties) { + return copyProperties(defaultProperties, newInstance(entityClass, defaultClass)); + } + + + /** + * 根据类型获取实体的真实的实体类型, + * 可通过此方法获取获取已拓展的实体类型,如:
+ * + * factory.getInstanceType(MyBeanInterface.class); + * + * + * @param entityClass 类型 + * @param 泛型 + * @return 实体类型 + */ + Class getInstanceType(Class entityClass); + + /** + * 拷贝对象的属性 + * + * @param source 要拷贝到的对象 + * @param target 被拷贝的对象 + * @param 要拷贝对象的类型 + * @param 被拷贝对象的类型 + * @return 被拷贝的对象 + */ + T copyProperties(S source, T target); +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/MapperEntityFactory.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/MapperEntityFactory.java new file mode 100644 index 000000000..0e66922e2 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/MapperEntityFactory.java @@ -0,0 +1,240 @@ +/* + * + * * Copyright 2019 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.crud.entity.factory; + +import lombok.SneakyThrows; +import org.hswebframework.utils.ClassUtils; +import org.hswebframework.web.exception.NotFoundException; +import org.hswebframework.web.bean.BeanFactory; +import org.hswebframework.web.bean.FastBeanCopier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.function.Supplier; + +/** + * @author zhouhao + * @since 3.0 + */ +@SuppressWarnings("unchecked") +public class MapperEntityFactory implements EntityFactory, BeanFactory { + private Map realTypeMapper = new HashMap<>(); + private Logger logger = LoggerFactory.getLogger(this.getClass()); + private Map copierCache = new HashMap<>(); + + private static final DefaultMapperFactory DEFAULT_MAPPER_FACTORY = clazz -> { + String simpleClassName = clazz.getPackage().getName().concat(".Simple").concat(clazz.getSimpleName()); + try { + return defaultMapper(Class.forName(simpleClassName)); + } catch (ClassNotFoundException ignore) { + // throw new NotFoundException(e.getMessage()); + } + return null; + }; + + /** + * 默认的属性复制器 + */ + private static final DefaultPropertyCopier DEFAULT_PROPERTY_COPIER = FastBeanCopier::copy; + + private DefaultMapperFactory defaultMapperFactory = DEFAULT_MAPPER_FACTORY; + + private DefaultPropertyCopier defaultPropertyCopier = DEFAULT_PROPERTY_COPIER; + + + public MapperEntityFactory() { + } + + public MapperEntityFactory(Map, Mapper> realTypeMapper) { + this.realTypeMapper.putAll(realTypeMapper); + } + + public MapperEntityFactory addMapping(Class target, Mapper mapper) { + realTypeMapper.put(target, mapper); + return this; + } + + public MapperEntityFactory addCopier(PropertyCopier copier) { + Class source = ClassUtils.getGenericType(copier.getClass(), 0); + Class target = ClassUtils.getGenericType(copier.getClass(), 1); + if (source == null || source == Object.class) { + throw new UnsupportedOperationException("generic type " + source + " not support"); + } + if (target == null || target == Object.class) { + throw new UnsupportedOperationException("generic type " + target + " not support"); + } + addCopier(source, target, copier); + return this; + } + + public MapperEntityFactory addCopier(Class source, Class target, PropertyCopier copier) { + copierCache.put(getCopierCacheKey(source, target), copier); + return this; + } + + private String getCopierCacheKey(Class source, Class target) { + return source.getName().concat("->").concat(target.getName()); + } + + @Override + public T copyProperties(S source, T target) { + Objects.requireNonNull(source); + Objects.requireNonNull(target); + try { + PropertyCopier copier = copierCache.get(getCopierCacheKey(source.getClass(), target.getClass())); + if (null != copier) { + return copier.copyProperties(source, target); + } + + return (T) defaultPropertyCopier.copyProperties(source, target); + } catch (Exception e) { + logger.warn("copy properties error", e); + } + return target; + } + + protected Mapper initCache(Class beanClass) { + Mapper mapper = null; + Class realType = null; + ServiceLoader serviceLoader = ServiceLoader.load(beanClass, this.getClass().getClassLoader()); + Iterator iterator = serviceLoader.iterator(); + if (iterator.hasNext()) { + realType = (Class) iterator.next().getClass(); + } + //尝试使用 Simple类,如: package.SimpleUserBean + if (realType == null) { + mapper = defaultMapperFactory.apply(beanClass); + } + if (!Modifier.isInterface(beanClass.getModifiers()) && !Modifier.isAbstract(beanClass.getModifiers())) { + realType = beanClass; + } + if (mapper == null && realType != null) { + if (logger.isDebugEnabled() && realType != beanClass) { + logger.debug("use instance {} for {}", realType, beanClass); + } + mapper = new Mapper<>(realType, new DefaultInstanceGetter(realType)); + } + if (mapper != null) { + realTypeMapper.put(beanClass, mapper); + } + return mapper; + } + + @Override + public T newInstance(Class beanClass) { + return newInstance(beanClass, null); + } + + @Override + public T newInstance(Class beanClass, Class defaultClass) { + if (beanClass == null) { + return null; + } + Mapper mapper = realTypeMapper.get(beanClass); + if (mapper != null) { + return mapper.getInstanceGetter().get(); + } + mapper = initCache(beanClass); + if (mapper != null) { + return mapper.getInstanceGetter().get(); + } + if (defaultClass != null) { + return newInstance(defaultClass); + } + if (Map.class == beanClass) { + return (T) new HashMap<>(); + } + if (List.class == beanClass) { + return (T) new ArrayList<>(); + } + if (Set.class == beanClass) { + return (T) new HashSet<>(); + } + + throw new NotFoundException("can't create instance for " + beanClass); + } + + @Override + @SuppressWarnings("unchecked") + public Class getInstanceType(Class beanClass) { + Mapper mapper = realTypeMapper.get(beanClass); + if (null != mapper) { + return mapper.getTarget(); + } + mapper = initCache(beanClass); + if (mapper != null) { + return mapper.getTarget(); + } + + return Modifier.isAbstract(beanClass.getModifiers()) + || Modifier.isInterface(beanClass.getModifiers()) + ? null : beanClass; + } + + public void setDefaultMapperFactory(DefaultMapperFactory defaultMapperFactory) { + Objects.requireNonNull(defaultMapperFactory); + this.defaultMapperFactory = defaultMapperFactory; + } + + public void setDefaultPropertyCopier(DefaultPropertyCopier defaultPropertyCopier) { + this.defaultPropertyCopier = defaultPropertyCopier; + } + + public static class Mapper { + Class target; + Supplier instanceGetter; + + public Mapper(Class target, Supplier instanceGetter) { + this.target = target; + this.instanceGetter = instanceGetter; + } + + public Class getTarget() { + return target; + } + + public Supplier getInstanceGetter() { + return instanceGetter; + } + } + + public static Mapper defaultMapper(Class target) { + return new Mapper<>(target, defaultInstanceGetter(target)); + } + + public static Supplier defaultInstanceGetter(Class clazz) { + return new DefaultInstanceGetter<>(clazz); + } + + static class DefaultInstanceGetter implements Supplier { + Class type; + + public DefaultInstanceGetter(Class type) { + this.type = type; + } + + @Override + @SneakyThrows + public T get() { + return type.newInstance(); + } + } +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/PropertyCopier.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/PropertyCopier.java new file mode 100644 index 000000000..871ee51ce --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/entity/factory/PropertyCopier.java @@ -0,0 +1,11 @@ +package org.hswebframework.web.crud.entity.factory; + +/** + * 属性复制接口,用于自定义属性复制 + * + * @author zhouhao + * @since 3.0 + */ +public interface PropertyCopier { + T copyProperties(S source, T target); +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityCreatedEvent.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityCreatedEvent.java new file mode 100644 index 000000000..0fc895e24 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityCreatedEvent.java @@ -0,0 +1,15 @@ +package org.hswebframework.web.crud.events; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.io.Serializable; + +@AllArgsConstructor +@Getter +public class EntityCreatedEvent implements Serializable { + + private E entity; + + private Class entityType; +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityModifyEvent.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityModifyEvent.java new file mode 100644 index 000000000..aca86f013 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityModifyEvent.java @@ -0,0 +1,20 @@ +package org.hswebframework.web.crud.events; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.io.Serializable; + +@AllArgsConstructor +@Getter +public class EntityModifyEvent implements Serializable{ + + private static final long serialVersionUID = -7158901204884303777L; + + private E before; + + private E after; + + private Class entityType; + +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/CrudService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/CrudService.java new file mode 100644 index 000000000..7a8264e8d --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/CrudService.java @@ -0,0 +1,90 @@ +package org.hswebframework.web.crud.service; + +import org.hswebframework.ezorm.core.param.QueryParam; +import org.hswebframework.ezorm.rdb.mapping.SyncDelete; +import org.hswebframework.ezorm.rdb.mapping.SyncQuery; +import org.hswebframework.ezorm.rdb.mapping.SyncRepository; +import org.hswebframework.ezorm.rdb.mapping.SyncUpdate; +import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult; +import org.hswebframework.web.crud.entity.PagerResult; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +public interface CrudService { + SyncRepository getRepository(); + + default SyncQuery createQuery() { + return getRepository().createQuery(); + } + + default SyncUpdate createUpdate() { + return getRepository().createUpdate(); + } + + default SyncDelete createDelete() { + return getRepository().createDelete(); + } + + @Transactional(readOnly = true) + default Optional findById(K id) { + return getRepository() + .findById(id); + } + + @Transactional(readOnly = true) + default List findById(Collection id) { + return getRepository() + .findById(id); + } + + @Transactional + default SaveResult save(E... entityArr) { + return getRepository() + .save(entityArr); + } + + @Transactional + default SaveResult save(Collection entityArr) { + return getRepository() + .save(entityArr); + } + + @Transactional + default int deleteById(K... idArr) { + return getRepository().deleteById(idArr); + } + + @Transactional + default int deleteById(Collection idArr) { + return getRepository().deleteById(idArr); + } + + @Transactional(readOnly = true) + default List query(QueryParam queryParam) { + return createQuery().setParam(queryParam).fetch(); + } + + @Transactional(readOnly = true) + default PagerResult queryPager(QueryParam param) { + + int count = count(param); + if (count == 0) { + return PagerResult.empty(); + } + param.rePaging(count); + + return PagerResult.of(count, query(param), param); + } + + @Transactional(readOnly = true) + default Integer count(QueryParam param) { + return getRepository() + .createQuery() + .setParam(param) + .count(); + } + +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/DefaultCrudService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/DefaultCrudService.java new file mode 100644 index 000000000..b91fdbd47 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/DefaultCrudService.java @@ -0,0 +1,16 @@ +package org.hswebframework.web.crud.service; + +import org.hswebframework.ezorm.rdb.mapping.SyncRepository; +import org.springframework.beans.factory.annotation.Autowired; + +public class DefaultCrudService implements CrudService { + + @Autowired + private SyncRepository repository; + + @Override + public SyncRepository getRepository() { + return repository; + } + +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveCrudService.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveCrudService.java index 136ca6059..98af26852 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveCrudService.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveCrudService.java @@ -1,7 +1,10 @@ package org.hswebframework.web.crud.service; import org.hswebframework.ezorm.core.param.QueryParam; +import org.hswebframework.ezorm.rdb.mapping.ReactiveDelete; +import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery; import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository; +import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate; import org.hswebframework.ezorm.rdb.mapping.defaults.SaveResult; import org.hswebframework.web.crud.entity.PagerResult; import org.reactivestreams.Publisher; @@ -15,6 +18,18 @@ public interface ReactiveCrudService { ReactiveRepository getRepository(); + default ReactiveQuery createQuery() { + return getRepository().createQuery(); + } + + default ReactiveUpdate createUpdate() { + return getRepository().createUpdate(); + } + + default ReactiveDelete createDelete() { + return getRepository().createDelete(); + } + @Transactional(readOnly = true) default Mono findById(Mono publisher) { return getRepository().findById(publisher); diff --git a/hsweb-commons/hsweb-commons-entity/pom.xml b/hsweb-commons/hsweb-commons-entity/pom.xml index e86c3ba71..6b84542ff 100644 --- a/hsweb-commons/hsweb-commons-entity/pom.xml +++ b/hsweb-commons/hsweb-commons-entity/pom.xml @@ -52,7 +52,7 @@ ${project.version} - org.hibernate + org.hibernate.validator hibernate-validator diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java index 1a2bf1ab8..15f695e94 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java @@ -19,7 +19,7 @@ package org.hswebframework.web.commons.entity.factory; import lombok.SneakyThrows; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.NotFoundException; import org.hswebframework.utils.ClassUtils; import org.hswebframework.web.bean.BeanFactory; import org.hswebframework.web.bean.FastBeanCopier; diff --git a/hsweb-commons/hsweb-commons-model/pom.xml b/hsweb-commons/hsweb-commons-model/pom.xml deleted file mode 100644 index cf11e910f..000000000 --- a/hsweb-commons/hsweb-commons-model/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - hsweb-commons - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - 通用增删改查-通用model模块 - - hsweb-commons-model - - - - io.swagger - swagger-annotations - - - org.hswebframework.web - hsweb-commons-bean - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-model/src/main/java/org/hswebframework/web/commons/model/Model.java b/hsweb-commons/hsweb-commons-model/src/main/java/org/hswebframework/web/commons/model/Model.java deleted file mode 100644 index 1b8749cb6..000000000 --- a/hsweb-commons/hsweb-commons-model/src/main/java/org/hswebframework/web/commons/model/Model.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2019 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.commons.model; - -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.io.Serializable; - -/** - * @author zhouhao - */ -public interface Model extends ValidateBean { -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/pom.xml b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/pom.xml deleted file mode 100644 index 3aa5afd2c..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - hsweb-commons-service - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 通用增删改查-通用服务接口模块 - - hsweb-commons-service-api - - - - org.hswebframework.web - hsweb-commons-dao-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CreateEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CreateEntityService.java deleted file mode 100644 index 2313559d1..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CreateEntityService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019 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; - -/** - * 实体创建服务接口,通过此接口创建实体.在创建实体类时,建议使用此接口进行创建,而不是使用new - * 如: - * - * YourBean bean = service.createEntity(); - * - * - * @author zhouhao - * @since 3.0 - */ -public interface CreateEntityService extends Service { - /** - * 创建实体 - * - * @return 实体 - */ - E createEntity(); - - Class getEntityInstanceType(); - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CrudService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CrudService.java deleted file mode 100644 index 5f4ef89e1..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/CrudService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019 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; - -/** - * 通用Service,实现增删改查 - * - * @author zhouhao - * @since 3.0 - */ -public interface CrudService extends - QueryByEntityService, - UpdateService, - InsertService, - DeleteService, - CreateEntityService, - QueryService { -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/DeleteService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/DeleteService.java deleted file mode 100644 index f629378f7..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/DeleteService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019 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; - -/** - * @author zhouhao - */ -public interface DeleteService extends Service { - /** - * 根据主键删除记录 - * - * @param pk 主键 - * @return 影响记录数 - */ - E deleteByPk(PK pk); - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/InsertService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/InsertService.java deleted file mode 100644 index e1a4209b0..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/InsertService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019 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; - -/** - * @author zhouhao - */ -public interface InsertService extends Service { - - /** - * 添加一条数据 - * - * @param data 要添加的数据 - * @return 添加后生成的主键 - */ - PK insert(E data); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryByEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryByEntityService.java deleted file mode 100644 index 776a6d76a..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryByEntityService.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.PagerResult; - -import java.util.List; - -/** - * 根据实体类参数执行各种查询的通用服务类 - * - * @param 实体类型 - * @author zhouhao - * @see org.hswebframework.web.commons.entity.param.QueryParamEntity - * @since 3.0 - */ -public interface QueryByEntityService extends Service { - - /** - * 按分页查询 - * - * @param param 参数 - * @return 分页查询结果 - */ - PagerResult selectPager(Entity param); - - /** - * 直接查询 - * - * @param param 查询参数 - * @return 查询结果 - */ - List select(Entity param); - - /** - * 查询总数 - * - * @param param 查询参数 - * @return 总数 - */ - int count(Entity param); - - /** - * 查询单条数据,如果存在多条数据,则返回第一条 - * - * @param param 查询参数 - * @return 查询结果 - */ - E selectSingle(Entity param); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java deleted file mode 100644 index 20fae458c..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/QueryService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 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; - -import java.util.List; - -/** - * 查询服务接口,提供基本的查询功能 - * @author zhouhao - * @since 3.0 - * @see QueryByEntityService - */ -public interface QueryService extends Service { - - /** - * 根据主键查询 - * @param id 主键 - * @return 查询结果,无结果时返回{@code null} - */ - E selectByPk(PK id); - - /** - * 根据多个主键查询 - * @param id 主键集合 - * @return 查询结果,如果无结果返回空集合,而不是返回{@code null} - */ - List selectByPk(List id); - - /** - * 查询所有结果 - * @return 所有结果,如果无结果则返回空集合,而不是返回{@code null} - */ - List select(); - - /** - * 查询结果总数 - * @return 结果总数 - */ - int count(); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/TreeService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/TreeService.java deleted file mode 100644 index 8cb37aca5..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/TreeService.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 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; - -import org.hswebframework.web.commons.entity.TreeSupportEntity; - -import java.util.Collection; -import java.util.List; - -/** - * 树结构实体服务,提供对树结果实体的常用操作 - * - * @author zhouhao - * @since 3.0 - */ -public interface TreeService extends Service { - - /** - * 查询所有父节点 - * @param childId 子节点id - * @return 父节点集合 - */ - List selectParentNode(PK childId); - - /** - * 根据父节点id获取子节点数据 - * - * @param parentId 父节点ID - * @return 子节点数据 - */ - List selectChildNode(PK parentId); - - /** - * 根据父节点id,获取所有子节点的数据,包含字节点的字节点 - * - * @param parentId 父节点ID - * @return 所有子节点的数据 - */ - List selectAllChildNode(PK parentId); - - /** - * 批量修改数据,如果集合中的数据不存在,则将会进行新增 - * - * @param data 数据集合 - * @return 修改的数量 - */ - int updateBatch(Collection data); - - /** - * 批量添加数据 - * - * @param data 数据集合 - * @return 被添加数据集合的主键 - */ - List insertBatch(Collection data); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java deleted file mode 100644 index 90fedeb6a..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import java.util.List; - -public interface UpdateService extends Service { - /** - * 修改记录信息 - * - * @param data 要修改的对象 - * @return 影响记录数 - */ - int updateByPk(PK id, E data); - - /** - * 批量修改记录 - * - * @param data 要修改的记录集合 - * @return 影响记录数 - */ - int updateByPk(List data); - - /** - * 保存或修改 - * - * @param e 要修改的数据 - * @return 影响记录数 - */ - PK saveOrUpdate(E e); - - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Validator.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Validator.java deleted file mode 100644 index e99e26373..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/Validator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.service; - -/** - * @author zhouhao - */ -public interface Validator { - boolean validate(T data); - - default String getErrorMessage() { - return "{validation_fail}"; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/README.md b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/README.md deleted file mode 100644 index 7bf14afd3..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# 通用服务类 - 提供通用增删改查服务 - -## DSL查改删 -查询,实现`DefaultDSLQueryService`接口 -```java - // select * from user where name = ? limit 0,1 - createQuery().where("name","张三").single(); -``` -```java - // select * from user where name = ? or name = ? - createQuery().where("name","张三").or().is("name","李四").list(); -``` - -```java - //select * from user where name = ? and (age> ? and age - - - - - hsweb-commons-service - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - - hsweb-commons-service-simple - - 通用增删改查-通用服务本地实现模块 - - - - src/main/resources - true - - - - - - org.slf4j - slf4j-api - - - org.springframework - spring-tx - - - org.springframework - spring-context - - - org.hibernate - hibernate-validator - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-api - ${project.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework - spring-aspects - test - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractService.java deleted file mode 100644 index df60a9568..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractService.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.utils.ClassUtils; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.validate.SimpleValidateResults; -import org.hswebframework.web.validate.ValidationException; -import org.hswebframework.web.validator.LogicPrimaryKeyValidator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.annotation.PostConstruct; -import javax.validation.ConstraintViolation; -import javax.validation.Validator; -import java.util.Set; -import java.util.function.Supplier; - -/** - * 抽象服务类,提供通用模板方法、类,如验证器,实体工厂等 - * - * @author zhouhao - * @see CreateEntityService - * @see Service - */ -public abstract class AbstractService implements CreateEntityService, Service { - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - protected Validator validator; - - protected EntityFactory entityFactory; - - protected LogicPrimaryKeyValidator logicPrimaryKeyValidator; - - @Autowired(required = false) - public void setValidator(Validator validator) { - this.validator = validator; - } - - @Autowired(required = false) - public void setEntityFactory(EntityFactory entityFactory) { - this.entityFactory = entityFactory; - } - - @Autowired(required = false) - public void setLogicPrimaryKeyValidator(LogicPrimaryKeyValidator logicPrimaryKeyValidator) { - this.logicPrimaryKeyValidator = logicPrimaryKeyValidator; - } - - protected Class entityType; - - protected Class primaryKeyType; - - @SuppressWarnings("unchecked") - public AbstractService() { - primaryKeyType = (Class) ClassUtils.getGenericType(this.getClass(), 1); - entityType = (Class) ClassUtils.getGenericType(this.getClass(), 0); - } - - protected boolean entityFactoryIsEnabled() { - if (entityFactory == null) { - logger.warn("entityFactory is null!"); - } - return null != entityFactory; - } - - @Override - public Class getEntityInstanceType() { - return entityFactory.getInstanceType(getEntityType()); - } - - public Class getEntityType() { - return entityType; - } - - protected Class getPrimaryKeyType() { - return primaryKeyType; - } - - @Override - public E createEntity() { - if (!entityFactoryIsEnabled()) { - throw new UnsupportedOperationException("{unsupported_operation}"); - } - return entityFactory.newInstance(getEntityType()); - } - - protected void tryValidateProperty(org.hswebframework.web.service.Validator validator, String property, T value) { - if (validator != null) { - if (!validator.validate(value)) { - throw new ValidationException(validator.getErrorMessage(), property); - } - } - } - - protected void tryValidateProperty(org.hswebframework.web.service.Validator validator, String property, T value, String message) { - if (validator != null) { - if (!validator.validate(value)) { - throw new ValidationException(message, property); - } - } - } - - protected void tryValidateProperty(boolean success, String property, String message) { - if (!success) { - throw new ValidationException(message, property); - } - } - - protected void tryValidate(Object data, String property, Class... groups) { - validate(() -> validator.validateProperty(data, property, groups)); - } - - protected void tryValidate(Class type, String property, Object value, Class... groups) { - validate(() -> validator.validateValue(type, property, value, groups)); - } - - protected void tryValidate(Object data, Class... groups) { - validate(() -> validator.validate(data, groups)); - } - - private void validate(Supplier>> validatorSetFunction) { - if (validator == null) { - logger.warn("validator is null!"); - return; - } - SimpleValidateResults results = new SimpleValidateResults(); - validatorSetFunction.get() - .forEach(violation -> results.addResult(violation.getPropertyPath().toString(), violation.getMessage())); - if (!results.isSuccess()) { - throw new ValidationException(results); - } - } - - public static void assertNotNull(Object data) { - assertNotNull(data, "{data_not_found}"); - } - - public static void assertNotNull(Object data, String message) { - if (null == data) { - throw new NotFoundException(message); - } - } - - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java deleted file mode 100644 index 618b0a3a7..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2019 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; - -import org.hswebframework.utils.RandomUtil; -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.hswebframework.web.commons.entity.TreeSupportEntity; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 抽象树形结构服务类 - * - * @author zhouhao - * @see TreeSortSupportEntity - * @since 3.0 - */ -public abstract class AbstractTreeSortService, PK> - extends GenericEntityService implements TreeService { - - @Override - @Transactional(readOnly = true) - public List selectParentNode(PK childId) { - assertNotNull(childId); - E old = selectByPk(childId); - if (null == old) { - return new ArrayList<>(); - } - return createQuery() - .where() - // where ? like concat(path,'%') - .and("path$like$reverse$startWith", old.getPath()) - .listNoPaging(); - } - - @Override - @Transactional(readOnly = true) - public List selectAllChildNode(PK parentId) { - assertNotNull(parentId); - E old = selectByPk(parentId); - if (null == old) { - return new ArrayList<>(); - } - return createQuery() - .where() - .like$(TreeSupportEntity.path, old.getPath()) - .listNoPaging(); - } - - @Override - @Transactional(readOnly = true) - public List selectChildNode(PK parentId) { - assertNotNull(parentId); - return createQuery() - .where(TreeSupportEntity.parentId, parentId) - .listNoPaging(); - } - - //当父节点不存在时,创建parentId - @SuppressWarnings("unchecked") - protected PK createParentIdOnExists() { - if (getPrimaryKeyType() == String.class) { - return (PK) "-1"; - } - return null; - } - - protected void applyPath(E entity) { - if (StringUtils.isEmpty(entity.getParentId())) { - if (entity.getSortIndex() == null) { - entity.setSortIndex(0L); - } - entity.setParentId(createParentIdOnExists()); - entity.setLevel(0); - entity.setPath(RandomUtil.randomChar(4)); - return; - } - if (!StringUtils.isEmpty(entity.getPath())) { - return; - } - - TreeSortSupportEntity parent = selectByPk(entity.getParentId()); - if (null == parent) { - if (entity.getSortIndex() == null) { - entity.setSortIndex(0L); - } - entity.setParentId(createParentIdOnExists()); - entity.setPath(RandomUtil.randomChar(4)); - entity.setLevel(0); - } else { - if (entity.getSortIndex() == null && parent.getSortIndex() != null) { - entity.setSortIndex(parent.getSortIndex() * 10); - } - entity.setPath(parent.getPath() + "-" + RandomUtil.randomChar(4)); - entity.setLevel(entity.getPath().split("[-]").length); - } - } - - @Override - public PK insert(E entity) { - if (StringUtils.isEmpty(entity.getId())) { - entity.setId(getIDGenerator().generate()); - } - applyPath(entity); - List childrenList = new ArrayList<>(); - TreeSupportEntity.expandTree2List(entity, childrenList, getIDGenerator()); - childrenList.forEach(this::saveOrUpdateForSingle); - return entity.getId(); - } - - @Override - public List insertBatch(Collection data) { - return data.stream() - .map(this::insert) - .collect(Collectors.toList()); - } - - @Override - public int updateBatch(Collection data) { - assertNotNull(data); - return data.stream() - .mapToInt(this::updateByPk) - .sum(); - } - - @Override - public int updateByPk(E entity) { - assertNotNull(entity); - List childrenList = new ArrayList<>(); - TreeSupportEntity.expandTree2List(entity, childrenList, getIDGenerator()); - childrenList.forEach(this::saveOrUpdateForSingle); - return childrenList.size() + 1; - } - - protected PK saveOrUpdateForSingle(E entity) { - assertNotNull(entity); - PK id = entity.getId(); - if (StringUtils.isEmpty(id) || this.selectByPk(id) == null) { - if (StringUtils.isEmpty(id)) { - entity.setId(getIDGenerator().generate()); - } - applyPath(entity); - return super.insert(entity); - } - super.updateByPk(entity); - return id; - } - - @Override - public E deleteByPk(PK id) { - E old = selectByPk(id); - assertNotNull(old); - if (StringUtils.isEmpty(old.getPath())) { - getDao().deleteByPk(id); - } else { - DefaultDSLDeleteService.createDelete(getDao()) - // where path like 'path%' - .where().like$(TreeSupportEntity.path, old.getPath()) - .exec(); - } - return old; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLDeleteService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLDeleteService.java deleted file mode 100644 index 2f9b912f5..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLDeleteService.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.ezorm.core.dsl.Delete; -import org.hswebframework.web.commons.entity.param.DeleteParamEntity; -import org.hswebframework.web.dao.dynamic.DeleteByEntityDao; - -/** - * @author zhouhao - */ -public interface DefaultDSLDeleteService extends DefaultDeleteService { - DeleteByEntityDao getDao(); - - default Delete createDelete() { - Delete delete = new Delete<>(new DeleteParamEntity()); - delete.setExecutor(getDao()::delete); - return delete; - } - - static Delete createDelete(DeleteByEntityDao deleteDao) { - Delete update = new Delete<>(new DeleteParamEntity()); - update.setExecutor(deleteDao::delete); - return update; - } - - /** - * 自定义一个删除执行器。创建dsl数据删除操作对象 - * - * @param executor 执行器 - * @return {@link Delete} - * @since 3.0 - */ - static Delete createDelete(Delete.Executor executor) { - Delete update = new Delete<>(new DeleteParamEntity()); - update.setExecutor(executor); - return update; - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLQueryService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLQueryService.java deleted file mode 100644 index 261c03719..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLQueryService.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; - -import java.util.List; - -public interface DefaultDSLQueryService - extends DefaultQueryByEntityService, QueryService { - - @Override - default List select() { - return createQuery().noPaging().list(); - } - - @Override - default int count() { - return createQuery().total(); - } - - /** - * 创建本服务的dsl查询操作对象 - * 可通过返回的Query对象进行dsl方式操作如:
- * - * createQuery().where("id",1).single(); - * - * - * @return {@link Query} - * @see Query - * @see org.hswebframework.ezorm.core.Conditional - * @since 3.0 - */ - default Query createQuery() { - Query query = Query.empty(new QueryParamEntity()); - query.setListExecutor(this::select); - query.setTotalExecutor(this::count); - query.setSingleExecutor(this::selectSingle); - query.noPaging(); - return query; - } - - /** - * 指定一个dao映射接口,接口需继承{@link QueryByEntityDao}创建dsl数据查询对象
- * 可通过返回的Query对象进行dsl方式操作如:
- * - * createQuery(userMapper).where("id",1).single(); - * - * - * @param dao dao接口 - * @param PO泛型 - * @return {@link Query} - * @see Query - * @see org.hswebframework.ezorm.core.Conditional - * @since 3.0 - */ - static Query createQuery(QueryByEntityDao dao) { - Query query = new Query<>(new QueryParamEntity()); - query.setListExecutor(dao::query); - query.setTotalExecutor(dao::count); - query.setSingleExecutor((param) -> { - param.doPaging(0, 1); - List list = dao.query(param); - if (null == list || list.isEmpty()) { - return null; - } else { - return list.get(0); - } - }); - query.noPaging(); - return query; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLUpdateService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLUpdateService.java deleted file mode 100644 index 3a53948ed..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDSLUpdateService.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.ezorm.core.dsl.Update; -import org.hswebframework.web.dao.dynamic.UpdateByEntityDao; -import org.hswebframework.web.commons.entity.param.UpdateParamEntity; - -/** - * 默认的DSL方式更新服务 - * - * @author zhouhao - */ -public interface DefaultDSLUpdateService extends UpdateService { - - UpdateByEntityDao getDao(); - - default Update> createUpdate(E data) { - return createUpdate(getDao(), data); - } - - default Update> createUpdate() { - return createUpdate(getDao()); - } - - static Update> createUpdate(UpdateByEntityDao dao) { - return Update.build(dao::update, new UpdateParamEntity<>()); - } - - static Update> createUpdate(UpdateByEntityDao dao, E data) { - return Update.build(dao::update, new UpdateParamEntity<>(data)); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDeleteService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDeleteService.java deleted file mode 100644 index 0abc03a29..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultDeleteService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019 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; - -/** - * @author zhouhao - */ -public interface DefaultDeleteService extends DeleteService { - /** - * 根据主键删除记录 - * - * @param pk 主键 - * @return 影响记录数 - */ - @Override - E deleteByPk(PK pk); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidator.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidator.java deleted file mode 100644 index f5a43b986..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidator.java +++ /dev/null @@ -1,263 +0,0 @@ -package org.hswebframework.web.service; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.CollectionUtils; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.validator.LogicPrimaryKey; -import org.hswebframework.web.validator.LogicPrimaryKeyValidator; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@SuppressWarnings("all") -@Slf4j -public class DefaultLogicPrimaryKeyValidator implements LogicPrimaryKeyValidator { - - private static final Map> validatorCache = new HashMap<>(); - - - private static final DefaultLogicPrimaryKeyValidator instrance = new DefaultLogicPrimaryKeyValidator(); - - protected DefaultLogicPrimaryKeyValidator() { - } - - public static DefaultLogicPrimaryKeyValidator getInstrance() { - return instrance; - } - - private static final Validator ALWAYS_PASSED_VALIDATOR = bean -> { - return Result.passed(); - }; - - public static void registerQuerySuppiler(Class type, Function> querySupplier) { - validatorCache.computeIfAbsent(type, instrance::createValidator) - .values() - .stream() - .filter(DefaultValidator.class::isInstance) - .map(DefaultValidator.class::cast) - .forEach(validator -> validator.querySupplier = querySupplier); - } - - @Override - public Result validate(Object bean, Class... groups) { - - Class target = ClassUtils.getUserClass(bean); - Result result; - if (null != groups && groups.length > 0) { - result = Arrays.stream(groups) - .map(group -> - validatorCache.computeIfAbsent(target, this::createValidator) - .getOrDefault(group, ALWAYS_PASSED_VALIDATOR) - .doValidate(bean)) - .filter(Result::isError) - .findFirst() - .orElseGet(Result::passed); - - } else { - result = validatorCache.computeIfAbsent(target, this::createValidator) - .getOrDefault(Void.class, ALWAYS_PASSED_VALIDATOR) - .doValidate(bean); - } - return result; - - } - - protected Map createValidator(Class target) { - //属性名:注解 - Map keys = new HashMap<>(); - - ReflectionUtils.doWithFields(target, field -> { - LogicPrimaryKey primaryKey = field.getAnnotation(LogicPrimaryKey.class); - if (primaryKey != null) { - keys.put(field.getName(), primaryKey); - } - }); - - //获取类上的注解 - Class[] tempClass = new Class[]{target}; - LogicPrimaryKey classAnn = null; - Class[] empty = new Class[0]; - - while (tempClass.length != 0) { - - for (Class group : tempClass) { - classAnn = AnnotationUtils.findAnnotation(group, LogicPrimaryKey.class); - if (null != classAnn) { - if (classAnn.value().length > 0) { - for (String field : classAnn.value()) { - keys.put(field, classAnn); - } - tempClass = empty; - continue; - } else { - //如果注解没有指定字段则从group中获取 - tempClass = classAnn.groups(); - if (tempClass.length == 1 && tempClass[0] == Void.class) { - log.warn("类{}的注解{}无效,请设置value属性或者group属性", classAnn, tempClass); - continue; - } - } - } else { - tempClass = empty; - continue; - } - } - } - - if (keys.isEmpty()) { - return new java.util.HashMap<>(); - } - return keys.entrySet() - .stream() - .flatMap(entry -> Stream.of(entry.getValue().groups()) - .flatMap(group -> Optional.ofNullable(entry.getValue().value()) - .map(Arrays::asList) - .filter(CollectionUtils::isNotEmpty) - .orElse(Arrays.asList(entry.getKey())) - .stream() - .map(field -> LogicPrimaryKeyField.builder() - .field(field) - .termType(entry.getValue().termType()) - .condition(entry.getValue().condition()) - .matchNullOrEmpty(entry.getValue().matchNullOrEmpty()) - .group(group) - .build()) - )) - .collect(Collectors.groupingBy( - //按group分组 - LogicPrimaryKeyField::getGroup, - //将每一组的集合构造为验证器对象 - Collectors.collectingAndThen( - Collectors.mapping(Function.identity(), Collectors.toSet()) - , list -> DefaultValidator.builder() - .infos(list) - .targetType(target) - .build()) - ) - ); - - } - - interface Validator { - Result doValidate(T bean); - } - - @Builder - static class DefaultValidator implements Validator { - private Set infos = new HashSet<>(); - - private Class targetType; - - private volatile Function> querySupplier; - - public Result doValidate(T bean) { - if (querySupplier == null) { - log.warn("未设置查询函数," + - "你可以在服务初始化的时候通过调用" + - "DefaultLogicPrimaryKeyValidator" + - ".registerQuerySuppiler({},bean -> this.createQuery().not(\"id\", bean.getId()))" + - "进行设置" - , targetType); - return Result.passed(); - } - - Query query = querySupplier.apply(bean); - - //转为map - Map mapBean = FastBeanCopier.copy(bean, new HashMap<>()); - - Map properties = new HashMap<>(); - - for (LogicPrimaryKeyField info : infos) { - String field = info.getField(); - Object value = mapBean.get(field); - //为空,可能是有字段嵌套,也有可能是真的null - if (value == null) { - String tmpField = field; - Object tmpValue = null; - Map tempMapBean = mapBean; - //嵌套的场景 - while (tmpValue == null && tmpField.contains(".")) { - String[] nest = tmpField.split("[.]", 2); - Object nestObject = tempMapBean.get(nest[0]); - if (nestObject == null) { - break; - } - if (nestObject instanceof Map) { - tempMapBean = ((Map) nestObject); - } else { - tempMapBean = FastBeanCopier.copy(nestObject, new HashMap<>()); - } - tmpField = nest[1]; - tmpValue = tempMapBean.get(tmpField); - } - value = tmpValue; - } - if (StringUtils.isEmpty(value)) { - if (info.matchNullOrEmpty) { - if (value == null) { - query.isNull(info.getField()); - } else { - query.isEmpty(info.getField()); - } - } - } else { - String termType = StringUtils.isEmpty(info.termType) ? TermType.eq : info.termType; - query.and(info.getField(), termType, value); - } - properties.put(info.getField(), value); - } - - T result = query.single(); - - if (result != null) { - Result validateResult = new Result(); - validateResult.setError(true); - validateResult.setData(result); - validateResult.setProperties(properties); - return validateResult; - } - return Result.passed(); - } - } - - @Getter - @Setter - @Builder - private static class LogicPrimaryKeyField { - private String field; - - private String condition; - - private boolean matchNullOrEmpty; - - private String termType; - - private Class group; - - @Override - public int hashCode() { - return field.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof LogicPrimaryKeyField) { - return hashCode() == obj.hashCode(); - } - return false; - } - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java deleted file mode 100644 index 668af39e1..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -public interface DefaultQueryByEntityService - extends QueryByEntityService { - - QueryByEntityDao getDao(); - - /** - * 分页进行查询数据,查询条件同 {@link DefaultQueryByEntityService#select} - * - * @param param 查询参数 - * @return 分页查询结果 - * @see QueryParamEntity - * @see QueryParamEntity#newQuery() - */ - @Override - default PagerResult selectPager(Entity param) { - PagerResult pagerResult = new PagerResult<>(); - - if (param instanceof QueryParamEntity) { - QueryParamEntity entity = ((QueryParamEntity) param); - //不分页,不进行count - if (!entity.isPaging()) { - pagerResult.setData(getDao().query(param)); - pagerResult.setTotal(pagerResult.getData().size()); - pagerResult.setPageIndex(entity.getThinkPageIndex()); - pagerResult.setPageSize(pagerResult.getData().size()); - return pagerResult; - } - } - int total = getDao().count(param); - pagerResult.setTotal(total); - - //根据实际记录数量重新指定分页参数 - if (param instanceof QueryParamEntity) { - QueryParamEntity paramEntity = (QueryParamEntity) param; - paramEntity.rePaging(total); - pagerResult.setPageSize(paramEntity.getPageSize()); - pagerResult.setPageIndex(paramEntity.getThinkPageIndex()); - } - - if (total == 0) { - pagerResult.setData(new java.util.ArrayList<>()); - } else { - pagerResult.setData(select(param)); - } - return pagerResult; - } - - /** - * 根据查询参数进行查询,参数可使用 {@link Query}进行构建 - * - * @param param 查询参数 - * @return 查询结果 - * @see QueryParamEntity - * @see QueryParamEntity#newQuery() - */ - @Override - @Transactional(readOnly = true) - default List select(Entity param) { - if (param == null) { - param = QueryParamEntity.empty(); - } - return getDao().query(param); - } - - - /** - * 查询记录总数,用于分页等操作。查询条件同 {@link DefaultQueryByEntityService#select} - * - * @param param 查询参数 - * @return 查询结果,实现mapper中的sql应指定默认值,否则可能抛出异常 - * @see QueryParamEntity - * @see QueryParamEntity#newQuery() - */ - @Override - @Transactional(readOnly = true) - default int count(Entity param) { - if (param == null) { - param = QueryParamEntity.empty(); - } - return getDao().count(param); - } - - /** - * 查询只返回单个结果,如果有多个结果,只返回第一个 - * - * @param param 查询条件 - * @return 单个查询结果 - * @see QueryParamEntity - * @see QueryParamEntity#newQuery() - */ - @Override - @Transactional(readOnly = true) - default E selectSingle(Entity param) { - if (param instanceof QueryParamEntity) { - ((QueryParamEntity) param).doPaging(0, 1); - } - List list = this.select(param); - if (list.isEmpty()) { - return null; - } else { - return list.get(0); - } - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictGenericEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictGenericEntityService.java deleted file mode 100644 index ce38d8cbd..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictGenericEntityService.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; - -import java.util.List; - -/** - * @author zhouhao - * @see org.springframework.cache.annotation.CacheConfig - * @see Cacheable - * @see CacheEvict - * @since 3.0 - */ -public abstract class EnableCacheAllEvictGenericEntityService, PK> extends GenericEntityService { - - @Override - @Cacheable(key = "'id:'+#pk") - public E selectByPk(PK pk) { - return super.selectByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(PK pk, E entity) { - return super.updateByPk(pk, entity); - } - - @Override - @CacheEvict(allEntries = true) - public PK insert(E entity) { - return super.insert(entity); - } - - @Override - @CacheEvict(allEntries = true) - public E deleteByPk(PK pk) { - return super.deleteByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public PK saveOrUpdate(E entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Cacheable(key = "'all'") - public List select() { - return super.select(); - } - - @Override - @Cacheable(key = "'id-in:'+#id.hashCode()") - public List selectByPk(List id) { - return super.selectByPk(id); - } - - @Override - @Cacheable(key = "'count'") - public int count() { - return super.count(); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictTreeSortService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictTreeSortService.java deleted file mode 100644 index 9c8813f5a..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheAllEvictTreeSortService.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; - -import java.util.Collection; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public abstract class EnableCacheAllEvictTreeSortService, PK> - extends AbstractTreeSortService { - - @Override - @Cacheable(key = "'parent:'+#parentId") - public List selectParentNode(PK parentId) { - return super.selectParentNode(parentId); - } - - @Override - @Cacheable(key = "'chidlren:'+#parentId") - public List selectChildNode(PK parentId) { - return super.selectChildNode(parentId); - } - - @Override - @Cacheable(key = "'all-chidlren:'+#parentId") - public List selectAllChildNode(PK parentId) { - return super.selectAllChildNode(parentId); - } - - @Override - @CacheEvict(allEntries = true) - public int updateBatch(Collection data) { - return super.updateBatch(data); - } - - @Override - @Cacheable(key = "'id:'+#pk") - public E selectByPk(PK pk) { - return super.selectByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(PK pk, E entity) { - return super.updateByPk(pk, entity); - } - - @Override - @CacheEvict(allEntries = true) - public PK insert(E entity) { - return super.insert(entity); - } - - @Override - @CacheEvict(allEntries = true) - public E deleteByPk(PK pk) { - return super.deleteByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public PK saveOrUpdate(E entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Cacheable(key = "'id-in:'+#id.hashCode()") - public List selectByPk(List id) { - return super.selectByPk(id); - } - - @Override - @Cacheable(key = "'all'") - public List select() { - return super.select(); - } - - @Override - @Cacheable(key = "'count'") - public int count() { - return super.count(); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheGenericEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheGenericEntityService.java deleted file mode 100644 index 9025a4a76..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheGenericEntityService.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; - -import java.util.List; - -/** - * 启用缓冲的通用实体曾删改查服务,继承此类 - * 在类上注解{@link org.springframework.cache.annotation.CacheConfig}即可 - * - * @author zhouhao - * @see org.springframework.cache.annotation.CacheConfig - * @see Cacheable - * @see CacheEvict - * @since 3.0 - */ -public abstract class EnableCacheGenericEntityService, PK> extends GenericEntityService { - - @Override - @Cacheable(key = "'id:'+#pk") - public E selectByPk(PK pk) { - return super.selectByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#pk"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public int updateByPk(PK pk, E entity) { - return super.updateByPk(pk, entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#result"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public PK insert(E entity) { - return super.insert(entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#pk"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public E deleteByPk(PK pk) { - return super.deleteByPk(pk); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#result"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public PK saveOrUpdate(E entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Cacheable(key = "'all'") - public List select() { - return super.select(); - } - - @Override - @Cacheable(key = "'count'") - public int count() { - return super.count(); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheTreeSortService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheTreeSortService.java deleted file mode 100644 index 945207ac3..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/EnableCacheTreeSortService.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; - -import java.util.Collection; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public abstract class EnableCacheTreeSortService, PK> - extends AbstractTreeSortService { - - @Override - @CacheEvict(allEntries = true) - public int updateBatch(Collection data) { - return super.updateBatch(data); - } - - @Override - @Cacheable(key = "'id:'+#pk") - public E selectByPk(PK pk) { - return super.selectByPk(pk); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#pk"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public int updateByPk(PK pk, E entity) { - return super.updateByPk(pk, entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#result"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public PK insert(E entity) { - return super.insert(entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#pk"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public E deleteByPk(PK pk) { - return super.deleteByPk(pk); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'id:'+#result"), - @CacheEvict(key = "'all'"), - @CacheEvict(key = "'count'") - } - ) - public PK saveOrUpdate(E entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Cacheable(key = "'all'") - public List select() { - return super.select(); - } - - @Override - @Cacheable(key = "'count'") - public int count() { - return super.count(); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java deleted file mode 100644 index 8ae200e6a..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericEntityService.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.LogicalDeleteEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.commons.entity.events.EntityCreatedEvent; -import org.hswebframework.web.commons.entity.events.EntityModifyEvent; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.validator.group.CreateGroup; -import org.hswebframework.web.validator.group.UpdateGroup; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import javax.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.List; - -/** - * 通用实体服务类,提供增删改查的默认实现 - * - * @author zhouhao - */ -@Transactional(rollbackFor = Throwable.class) -public abstract class GenericEntityService, PK> - extends AbstractService - implements GenericService { - - @SuppressWarnings("unchecked") - public GenericEntityService() { - super(); - } - - /** - * 获取ID生成器,在insert的时候,如果ID为空,则调用生成器进行生成 - * - * @return IDGenerator - * @see IDGenerator - */ - protected abstract IDGenerator getIDGenerator(); - - protected ApplicationEventPublisher eventPublisher; - - @Autowired(required = false) - public void setEventPublisher(ApplicationEventPublisher eventPublisher) { - this.eventPublisher = eventPublisher; - } - - @PostConstruct - public void init() { - if (logicPrimaryKeyValidator instanceof DefaultLogicPrimaryKeyValidator) { - DefaultLogicPrimaryKeyValidator.registerQuerySuppiler(getEntityInstanceType(), bean -> this.createQuery().not("id", bean.getId())); - } - } - - @Override - public E deleteByPk(PK pk) { - E old = selectByPk(pk); - if (old == null) { - return null; - } - if (old instanceof LogicalDeleteEntity) { - LogicalDeleteEntity deleteEntity = (LogicalDeleteEntity) old; - deleteEntity.setDeleted(true); - deleteEntity.setDeleteTime(System.currentTimeMillis()); - createUpdate() - .set(deleteEntity::getDeleted) - .set(deleteEntity::getDeleteTime) - .where(GenericEntity.id, pk) - .exec(); - } else { - if (!physicalDeleteByPk(pk)) { - logger.warn("物理删除数据失败,主键:{}", pk); - } - } - return old; - } - - protected boolean physicalDeleteByPk(PK pk) { - //createDelete().where(GenericEntity.id,pk).exec()>0; - - return getDao().deleteByPk(pk) > 0; - } - - protected boolean pushModifyEvent() { - return RecordModifierEntity.class.isAssignableFrom(entityType); - } - - protected boolean pushCreatedEvent() { - return RecordCreationEntity.class.isAssignableFrom(entityType); - } - - @Override - public int updateByPk(PK pk, E entity) { - Assert.notNull(pk, "primary key can not be null"); - Assert.hasText(String.valueOf(pk), "primary key can not be null"); - Assert.notNull(entity, "entity can not be null"); - entity.setId(pk); - - tryValidate(entity, UpdateGroup.class); - //尝试推送 EntityModifyEvent 事件. - if (eventPublisher != null && pushModifyEvent()) { - E old = selectByPk(pk); - eventPublisher.publishEvent(new GenericsPayloadApplicationEvent<>(this, new EntityModifyEvent<>(old, entity, getEntityType()), getEntityType())); - } - return createUpdate(entity) - //如果是RecordCreationEntity则不修改creator_id和creator_time - .when(entity instanceof RecordCreationEntity, - update -> update.and().excludes(((RecordCreationEntity) entity).getCreatorIdProperty(), RecordCreationEntity.createTime)) - .where(GenericEntity.id, pk) - .exec(); - } - - protected int updateByPk(E entity) { - return updateByPk(entity.getId(), entity); - } - - @Override - public int updateByPk(List data) { - return data.stream() - .map(this::updateByPk) - .reduce(Math::addExact) - .orElse(0); - } - - @Override - public PK saveOrUpdate(E entity) { - if (dataExisted(entity)) { - updateByPk(entity); - } else { - insert(entity); - } - return entity.getId(); - } - - @SuppressWarnings("unchecked") - protected boolean dataExisted(E entity) { - if (null != logicPrimaryKeyValidator) { - logicPrimaryKeyValidator - .validate(entity) - .ifError(result -> entity.setId(result.getData().getId())); - } - return null != entity.getId() && null != selectByPk(entity.getId()); - } - - @Override - public PK insert(E entity) { - if (!StringUtils.isEmpty(entity.getId())) { - if ((entity.getId() instanceof String) && !StringUtils.isEmpty(entity.getId())) { - tryValidateProperty(entity.getId().toString().matches("[a-zA-Z0-9_\\-]+"), "id", "只能由数字,字母,下划线,和-组成"); - } - tryValidateProperty(selectByPk(entity.getId()) == null, "id", entity.getId() + "已存在"); - } - if (StringUtils.isEmpty(entity.getId()) && getIDGenerator() != null) { - entity.setId(getIDGenerator().generate()); - } - if (entity instanceof RecordCreationEntity) { - ((RecordCreationEntity) entity).setCreateTimeNow(); - } - tryValidate(entity, CreateGroup.class); - getDao().insert(entity); - - if (eventPublisher != null && pushCreatedEvent()) { - eventPublisher.publishEvent(new GenericsPayloadApplicationEvent<>(this, new EntityCreatedEvent<>(entity, getEntityType()), getEntityType())); - } - return entity.getId(); - } - - @Override - @Transactional(readOnly = true) - public E selectByPk(PK pk) { - if (StringUtils.isEmpty(pk)) { - return null; - } - return createQuery().where(GenericEntity.id, pk).single(); - } - - @Override - @Transactional(readOnly = true) - public List selectByPk(List id) { - if (CollectionUtils.isEmpty(id)) { - return new ArrayList<>(); - } - return createQuery().where().in(GenericEntity.id, id).listNoPaging(); - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericService.java deleted file mode 100644 index 1be091792..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import org.hswebframework.web.dao.CrudDao; - -/** - * - * @author zhouhao - * @see DefaultDSLQueryService - * @see DefaultDSLUpdateService - * @see DefaultDSLDeleteService - * @see CrudService - * @see CrudDao - */ -public interface GenericService extends - DefaultDSLQueryService, - DefaultDSLUpdateService, - DefaultDSLDeleteService, - CrudService { - @Override - CrudDao getDao(); -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericsPayloadApplicationEvent.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericsPayloadApplicationEvent.java deleted file mode 100644 index f238477ee..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/GenericsPayloadApplicationEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.hswebframework.web.service; - -import org.springframework.context.PayloadApplicationEvent; -import org.springframework.core.ResolvableType; - -/** - * 动态泛型事件,用于动态发布支持泛型的事件 - *
- *     //相当于发布事件: EntityModifyEvent<UserEntity>
- *     eventPublisher
- *          .publishEvent(new GenericsPayloadApplicationEvent<>(this, new EntityModifyEvent<>(oldEntity, newEntity), UserEntity.class));
- *
- *      //只监听相同泛型事件
- *      @EventListener
- *      public handleEvent(EntityModifyEvent<UserEntity> event){
- *
- *      }
- * 
- * - * @author zhouhao - * @since 3.0.7 - */ -public class GenericsPayloadApplicationEvent extends PayloadApplicationEvent { - - private static final long serialVersionUID = 3745888943307798710L; - - //泛型列表 - private transient Class[] generics; - - //事件类型 - private transient Class eventType; - - /** - * @param source 事件源 - * @param payload 事件,不能使用匿名内部类 - * @param generics 泛型列表 - */ - public GenericsPayloadApplicationEvent(Object source, E payload, Class... generics) { - super(source, payload); - this.generics = generics; - this.eventType = payload.getClass(); - } - - @Override - public ResolvableType getResolvableType() { - return ResolvableType.forClassWithGenerics(PayloadApplicationEvent.class - , ResolvableType.forClassWithGenerics(eventType, generics)); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/resources/hsweb-module.json b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/resources/hsweb-module.json deleted file mode 100644 index 462e62eb7..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/resources/hsweb-module.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "groupId": "${project.groupId}", - "artifactId": "${project.artifactId}", - "path": "hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple", - "gitCommitHash": "${git.commit.hash}", - "gitRepository": "http://github.com/hs-web/hsweb-framework", - "version": "${project.version}" -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/AbstractTreeSortServiceTests.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/AbstractTreeSortServiceTests.java deleted file mode 100644 index 132f930cf..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/AbstractTreeSortServiceTests.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.hswebframework.web.service; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.commons.entity.factory.MapperEntityFactory; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.CrudDao; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; - -import javax.validation.Validation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; - -/** - * @author zhouhao - * @since 3.0 - */ -@RunWith(MockitoJUnitRunner.class) -public class AbstractTreeSortServiceTests { - - @InjectMocks - private TestTreeEntityService entityService = new TestTreeEntityService(); - - @Mock - private CrudDao dao; - - private List entities = new ArrayList<>(); - - @Before - public void init() { - entityService.setEntityFactory(new MapperEntityFactory()); - - TestEntity entity = TestEntity.builder() - .age((byte) 10) - .enabled(true) - .name("test") - .build(); - entity.setId("testId"); - - when(dao.query(any())) - .thenReturn(new ArrayList<>()); - - when(dao.count(any())).thenReturn(1); - -// when(dao.update(any())).thenReturn(1); - - when(dao.delete(any())).thenReturn(1); - when(dao.deleteByPk("test")).thenReturn(1); - - // doNothing().when(dao).insert(anyObject()); - doAnswer(invocationOnMock -> { - TestEntity t = invocationOnMock.getArgumentAt(0, TestEntity.class); - entities.add(t); - return t.getId(); - }).when(dao).insert(anyObject()); - - doAnswer(invocationOnMock -> { - TestEntity t = invocationOnMock.getArgumentAt(0, TestEntity.class); - entities.add(t); - return t.getId(); - }).when(dao).update(anyObject()); - } - - @Test - public void testBatchInsert() { - String treeJson = "{'id':'1','parentId':'-1','name':'父节点','children':[" + - "{'id':'101','parentId':'1','name':'子节点1'}," + - "{'id':'102','parentId':'1','name':'子节点2'}" + - "]}"; - TestEntity entity = JSON.parseObject(treeJson, TestEntity.class); - - entityService.insert(entity); - - Assert.assertEquals(entities.size(), 3); - entities.clear(); - - entityService.updateByPk(entity); - Assert.assertEquals(entities.size(), 3); - entities.clear(); - - entityService.updateBatch(Arrays.asList(entity)); - Assert.assertEquals(entities.size(), 3); - } -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidatorTest.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidatorTest.java deleted file mode 100644 index 0781c9dce..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/DefaultLogicPrimaryKeyValidatorTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.hswebframework.web.service; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.validator.LogicPrimaryKey; -import org.hswebframework.web.validator.group.CreateGroup; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public class DefaultLogicPrimaryKeyValidatorTest { - DefaultLogicPrimaryKeyValidator validator = new DefaultLogicPrimaryKeyValidator(); - - @Test - public void testSimple() { - DefaultLogicPrimaryKeyValidator.registerQuerySuppiler(TestBean.class, bean -> - Query.empty(QueryParamEntity.empty()) - .setSingleExecutor(param -> { - Assert.assertNotNull(param.getTerms()); - Assert.assertEquals(param.getTerms().size(), 2); - return new TestBean("test", "1"); - })); - - TestBean bean = new TestBean("test", "1"); - Assert.assertTrue(validator.validate(bean).isError()); - } - - - @Test - public void testClassAnn() { - DefaultLogicPrimaryKeyValidator.registerQuerySuppiler(ClassAnnTestBean.class, bean -> - Query.empty(QueryParamEntity.empty()) - .setSingleExecutor(param -> { - Assert.assertNotNull(param.getTerms()); - Assert.assertEquals(param.getTerms().size(), 2); - return new ClassAnnTestBean("test", "1"); - })); - - ClassAnnTestBean bean = new ClassAnnTestBean("test", "1"); - Assert.assertTrue(validator.validate(bean).isError()); - } - - - @Test - public void testGroupAnn() { - DefaultLogicPrimaryKeyValidator.registerQuerySuppiler(GroupAnnTestBean.class, bean -> - Query.empty(QueryParamEntity.empty()) - .setSingleExecutor(param -> { - Assert.assertNotNull(param.getTerms()); - Assert.assertEquals(param.getTerms().size(), 2); - return new GroupAnnTestBean("test", "1"); - })); - - GroupAnnTestBean bean = new GroupAnnTestBean("test", "1"); - Assert.assertTrue(validator.validate(bean).isPassed()); - - Assert.assertTrue(validator.validate(bean, TestGroup.class).isError()); - } - - - @Test - public void testNestProperty() { - NestTestBean nestTestBean=new NestTestBean(new TestBean("test","1"),"test"); - - DefaultLogicPrimaryKeyValidator.registerQuerySuppiler(NestTestBean.class, bean -> - Query.empty(QueryParamEntity.empty()) - .setSingleExecutor(param -> { - Assert.assertNotNull(param.getTerms()); - Assert.assertEquals(param.getTerms().size(), 2); - return nestTestBean; - })); - - Assert.assertTrue(validator.validate(nestTestBean).isError()); - } - - - @Getter - @Setter - @AllArgsConstructor - @LogicPrimaryKey(groups = TestGroup.class) - public class GroupAnnTestBean { - - private String name; - - private String org; - - } - - @Getter - @Setter - @AllArgsConstructor - @LogicPrimaryKey({"name", "org"}) - public class ClassAnnTestBean { - - private String name; - - private String org; - - } - - @Getter - @Setter - @AllArgsConstructor - public class GroupTestBean { - - @LogicPrimaryKey(groups = CreateGroup.class) - private String name; - - @LogicPrimaryKey - private String org; - - } - - @Getter - @Setter - @AllArgsConstructor - public class NestTestBean { - @LogicPrimaryKey("nest.name") - private TestBean nest; - - @LogicPrimaryKey - private String org; - } - @Getter - @Setter - @AllArgsConstructor - public class TestBean { - @LogicPrimaryKey - private String name; - - @LogicPrimaryKey - private String org; - } - - @LogicPrimaryKey(value = {"name", "org"}, groups = TestGroup.class) - public interface TestGroup { - - } -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTestService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTestService.java deleted file mode 100644 index 4454886de..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTestService.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.springframework.cache.annotation.CacheConfig; - -/** - * @author zhouhao - * @since 1.0 - */ -@CacheConfig(cacheNames = "test-2-entity") -public class EnableCacheAllEvictTestService extends EnableCacheAllEvictGenericEntityService { - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTreeTestService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTreeTestService.java deleted file mode 100644 index 4ab3ac106..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheAllEvictTreeTestService.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.springframework.cache.annotation.CacheConfig; - -/** - * @author zhouhao - * @since 1.0 - */ -@CacheConfig(cacheNames = "test-2-tree-entity") -public class EnableCacheAllEvictTreeTestService extends EnableCacheAllEvictTreeSortService { - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTestService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTestService.java deleted file mode 100644 index 3adfe8082..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTestService.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.springframework.cache.annotation.CacheConfig; - -/** - * @author zhouhao - * @since 1.0 - */ -@CacheConfig(cacheNames = "test-entity") -public class EnableCacheTestService extends EnableCacheGenericEntityService { - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTests.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTests.java deleted file mode 100644 index f6358bda6..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTests.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.factory.MapperEntityFactory; -import org.hswebframework.web.dao.CrudDao; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.theories.suppliers.TestedOn; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.junit4.SpringRunner; - -import javax.validation.Validation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -/** - * @author zhouhao - * @since 3.0 - */ -@SpringBootTest(classes = SpringTestApplication.class) -@RunWith(value = SpringRunner.class) -public class EnableCacheTests { - - @Autowired - private EnableCacheTestService enableCacheTestService; - - @Autowired - private EnableCacheAllEvictTestService enableCacheAllEvictTestService; - @Autowired - private EnableCacheTreeTestService enableCacheTreeTestService; - @Autowired - private EnableCacheAllEvictTreeTestService enableCacheAllEvictTreeTestService; - - private AtomicInteger counter = new AtomicInteger(); - - @Before - public void init() { - CrudDao dao = Mockito.mock(CrudDao.class); - enableCacheTestService.setEntityFactory(new MapperEntityFactory()); - - TestEntity entity = TestEntity.builder() - .age((byte) 10) - .enabled(true) - .name("test") - .build(); - entity.setId("testId"); - - when(dao.query(any())) - .then((Answer>) invocationOnMock -> { - //模拟命中数据库 - counter.incrementAndGet(); - return new ArrayList<>(Arrays.asList(entity)); - }); - - when(dao.count(any())).then((Answer) invocationOnMock -> { - //模拟命中数据库 - counter.incrementAndGet(); - return 1; - }); - - when(dao.update(any())).thenReturn(1); - - when(dao.delete(any())).thenReturn(1); - when(dao.deleteByPk(anyString())).thenReturn(1); - - doNothing().when(dao).insert(anyObject()); - - enableCacheTestService.setDao(dao); - - enableCacheAllEvictTestService.setDao(dao); - - enableCacheTreeTestService.setDao(dao); - - enableCacheAllEvictTreeTestService.setDao(dao); - } - - @Test - public void testSimpleCacheEnableService() { - doTest(enableCacheTestService); - } - - @Test - public void testEnableCacheAllEvictTestService() { - doTest(enableCacheAllEvictTestService); - } - - @Test - public void testEnableCacheTreeTestService() { - doTest(enableCacheTreeTestService); - } - - @Test - public void testEnableCacheAllEvictTreeTestService() { - doTest(enableCacheAllEvictTreeTestService); - } - - - - public void doTest(CrudService service) { - service.selectByPk("testId"); //db 1 - service.selectByPk("testId");//cache - Assert.assertEquals(counter.get(), 1); - - service.select(); //db 2 - service.select();//cache - Assert.assertEquals(counter.get(), 2); - - service.count(); //db 3 - service.count(); //cache - Assert.assertEquals(counter.get(), 3); - - service.updateByPk("testId", new TestEntity()); //evict cache - - service.select(); //db 4 - service.selectByPk("testId");//db 5 - service.count();//db 6 - - service.select(); //cache - service.selectByPk("testId");//cache - service.count();//cache - Assert.assertEquals(counter.get(), 6); - - service.deleteByPk("testId"); //evict cache - //删除前会查询 - counter.decrementAndGet(); - service.select(); //db 7 - service.selectByPk("testId");//db 8 - service.count();//db 9 - - service.select(); //cache - service.selectByPk("testId");//cache - service.count();//cache - Assert.assertEquals(counter.get(), 9); - - } - - -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTreeTestService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTreeTestService.java deleted file mode 100644 index fa865932a..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/EnableCacheTreeTestService.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.springframework.cache.annotation.CacheConfig; - -/** - * @author zhouhao - * @since 1.0 - */ -@CacheConfig(cacheNames = "test-tree-entity") -public class EnableCacheTreeTestService extends EnableCacheTreeSortService { - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/GenericEntityServiceTest.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/GenericEntityServiceTest.java deleted file mode 100644 index c716ca1f6..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/GenericEntityServiceTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.factory.MapperEntityFactory; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.validate.ValidationException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; - -import javax.validation.Validation; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.mockito.Mockito.*; - -/** - * @author zhouhao - * @since 3.0 - */ -@RunWith(MockitoJUnitRunner.class) -public class GenericEntityServiceTest { - - @InjectMocks - private TestEntityService entityService = new TestEntityService(); - - @Mock - private CrudDao dao; - - private QueryParamEntity queryParamEntity = new QueryParamEntity(); - - @Before - public void init() { - entityService.setEntityFactory(new MapperEntityFactory()); - entityService.setValidator(Validation.buildDefaultValidatorFactory().getValidator()); - TestEntity entity = TestEntity.builder() - .age((byte) 10) - .enabled(true) - .name("test") - .build(); - entity.setId("testId"); - - when(dao.query(any())) - .then((Answer>) invocationOnMock -> new ArrayList<>(Arrays.asList(entity))); - - when(dao.count(any())).thenReturn(1); - - when(dao.update(any())).thenReturn(1); - - when(dao.delete(any())).thenReturn(1); - when(dao.deleteByPk("test")).thenReturn(1); - - doNothing().when(dao).insert(anyObject()); - - } - - @Test - public void testSimple() { - Assert.assertEquals(entityService.getEntityType(), TestEntity.class); - - Assert.assertEquals(entityService.getEntityInstanceType(), TestEntity.class); - - Assert.assertEquals(entityService.getPrimaryKeyType(), String.class); - } - - @Test - public void testQuery() { - PagerResult result = entityService.selectPager(queryParamEntity); - Assert.assertEquals(result.getTotal(), 1); - Assert.assertEquals(result.getData().size(), 1); - - TestEntity entity = entityService.selectByPk(result.getData().get(0).getId()); - Assert.assertNotNull(entity); - - List testEntities = entityService.selectByPk(Arrays.asList(result.getData().get(0).getId())); - Assert.assertTrue(!testEntities.isEmpty()); - } - - - @Test - public void testInsert() { - TestEntity testEntity = TestEntity.builder() - .age((byte) 1) - .enabled(true) -// .name("测试") - .build(); - try { - entityService.insert(testEntity); - Assert.assertFalse(true); - } catch (ValidationException e) { - Assert.assertFalse(e.getResults().isEmpty()); - Assert.assertEquals(e.getResults().get(0).getField(), "name"); - testEntity.setId(null); - } - testEntity.setName("测试"); - String id = entityService.insert(testEntity); - Assert.assertNotNull(id); - } - - @Test - public void testUpdate() { - TestEntity testEntity = TestEntity.builder() - .age((byte) 1) - .enabled(true) - .name("测试") - .build(); - testEntity.setId("testEntity"); - - int i = entityService.updateByPk("testEntity", testEntity); - entityService.updateByPk(testEntity); - entityService.updateByPk(Arrays.asList(testEntity)); - String id = entityService.saveOrUpdate(testEntity); - Assert.assertEquals(id, testEntity.getId()); - Assert.assertEquals(i, 1); - } - -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/ModifyEventTests.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/ModifyEventTests.java deleted file mode 100644 index 3f4240d2d..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/ModifyEventTests.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.events.EntityModifyEvent; -import org.hswebframework.web.commons.entity.factory.MapperEntityFactory; -import org.hswebframework.web.dao.CrudDao; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.stubbing.Answer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.mockito.Mockito.*; - -/** - * @author zhouhao - * @since 3.0 - */ -@SpringBootTest(classes = SpringTestApplication.class) -@RunWith(value = SpringRunner.class) -@Component -public class ModifyEventTests { - - @Autowired - private TestModifyEntityService modifyEntityService; - - private AtomicInteger counter = new AtomicInteger(); - - @Before - public void init() { - CrudDao dao = Mockito.mock(CrudDao.class); - modifyEntityService.setEntityFactory(new MapperEntityFactory()); - modifyEntityService.setDao(dao); - TestModifyEntity entity = TestModifyEntity.builder() - .age((byte) 10) - .enabled(true) - .name("test") - .build(); - entity.setId("testId"); - - when(dao.query(any())) - .then((Answer>) invocationOnMock -> { - //模拟命中数据库 - counter.incrementAndGet(); - return new ArrayList<>(Arrays.asList(entity)); - }); - - when(dao.count(any())).then((Answer) invocationOnMock -> { - //模拟命中数据库 - counter.incrementAndGet(); - return 1; - }); - - when(dao.update(any())).thenReturn(1); - - when(dao.delete(any())).thenReturn(1); - when(dao.deleteByPk(anyString())).thenReturn(1); - - doNothing().when(dao).insert(anyObject()); - - } - - - @Test - public void modifyTest() { - TestModifyEntity entity = new TestModifyEntity(); - entity.setId("testId"); - entity.setAge((byte) 10); - - modifyEntityService.updateByPk("test", entity); - Assert.assertTrue(TestModifyEntityService.eventCounter.get() != 0); - } - - -} \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/SpringTestApplication.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/SpringTestApplication.java deleted file mode 100644 index 8fe2be968..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/SpringTestApplication.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.junit.Before; -import org.mockito.Mockito; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; - -/** - * @author zhouhao - * @since 3.0 - */ -@SpringBootApplication -@EnableCaching -@Configuration -@EnableAspectJAutoProxy(proxyTargetClass = true) -public class SpringTestApplication { - - @Bean - public EnableCacheTestService enableCacheTestService() { - return new EnableCacheTestService(); - } - - @Bean - public EnableCacheAllEvictTestService enableCacheAllEvictTestService() { - return new EnableCacheAllEvictTestService(); - } - - @Bean - public EnableCacheTreeTestService enableCacheTreeTestService() { - return new EnableCacheTreeTestService(); - } - - @Bean - public EnableCacheAllEvictTreeTestService enableCacheAllEvictTreeTestService() { - return new EnableCacheAllEvictTreeTestService(); - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntity.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntity.java deleted file mode 100644 index 2286ff8d9..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntity.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.service; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; -import org.hswebframework.web.validator.LogicPrimaryKey; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * @author zhouhao - * @since 1.0 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TestEntity extends SimpleTreeSortSupportEntity -// implements RecordModifierEntity -{ - - @NotBlank(groups = CreateGroup.class) - private String name; - - private Byte age; - - private Boolean enabled; - - private List children; - - private String modifierId; - - private Long modifyTime; - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntityService.java deleted file mode 100644 index 6e5d8accc..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestEntityService.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; - -/** - * @author zhouhao - * @since 3.0 - */ -public class TestEntityService extends GenericEntityService { - - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity.java deleted file mode 100644 index f5b9ae923..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.service; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * @author zhouhao - * @since 1.0 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TestModifyEntity extends SimpleTreeSortSupportEntity - implements RecordModifierEntity -{ - - @NotBlank(groups = CreateGroup.class) - private String name; - - private Byte age; - - private Boolean enabled; - - private List children; - - private String modifierId; - - private Long modifyTime; - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity2.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity2.java deleted file mode 100644 index 19c9d50f3..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntity2.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.service; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * @author zhouhao - * @since 1.0 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class TestModifyEntity2 extends SimpleTreeSortSupportEntity - implements RecordModifierEntity -{ - - @NotBlank(groups = CreateGroup.class) - private String name; - - private Byte age; - - private Boolean enabled; - - private List children; - - private String modifierId; - - private Long modifyTime; - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntityService.java deleted file mode 100644 index 679f8e002..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestModifyEntityService.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.commons.entity.RecordModifierEntity; -import org.hswebframework.web.commons.entity.events.EntityModifyEvent; -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - -import java.util.concurrent.atomic.AtomicLong; - -/** - * @author zhouhao - * @since 3.0 - */ -@Service -public class TestModifyEntityService extends GenericEntityService { - - private CrudDao dao; - - public static AtomicLong eventCounter = new AtomicLong(); - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } - - @EventListener - public void handleEvent(EntityModifyEvent modifyEvent){ - eventCounter.incrementAndGet(); - System.out.println(modifyEvent); - } - -} diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestTreeEntityService.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestTreeEntityService.java deleted file mode 100644 index 83940bfe0..000000000 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/test/java/org/hswebframework/web/service/TestTreeEntityService.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.service; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; - -/** - * @author zhouhao - * @since 3.0 - */ -public class TestTreeEntityService extends AbstractTreeSortService { - - private CrudDao dao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dao; - } - - public void setDao(CrudDao dao) { - this.dao = dao; - } -} diff --git a/hsweb-commons/hsweb-commons-service/pom.xml b/hsweb-commons/hsweb-commons-service/pom.xml deleted file mode 100644 index 7860d4ad5..000000000 --- a/hsweb-commons/hsweb-commons-service/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - hsweb-commons - org.hswebframework.web - 4.0.0-SNAPSHOT - - ../pom.xml - - 4.0.0 - - 通用增删改查-通用服务模块 - - hsweb-commons-service - pom - - hsweb-commons-service-simple - hsweb-commons-service-api - - - - - org.hswebframework - hsweb-easy-orm-rdb - - - org.hswebframework.web - hsweb-commons-entity - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/AopUtils.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/AopUtils.java index d74df9e57..9db177ca3 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/AopUtils.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/AopUtils.java @@ -26,7 +26,6 @@ import org.springframework.util.ReflectionUtils; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.*; -import java.util.stream.Stream; public final class AopUtils { @@ -42,8 +41,7 @@ public final class AopUtils { m = ClassUtils.getMostSpecificMethod(m, targetClass); a = AnnotationUtils.findAnnotation(m, annClass); if (a == null) { - List supers = new ArrayList<>(); - supers.addAll(Arrays.asList(targetClass.getInterfaces())); + List supers = new ArrayList<>(Arrays.asList(targetClass.getInterfaces())); if (targetClass.getSuperclass() != Object.class) { supers.add(targetClass.getSuperclass()); } diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java index bdae6e699..8b651dbb9 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java @@ -127,7 +127,7 @@ public abstract class ModuleUtils { public String getGitLocation() { String gitCommitHash = this.gitCommitHash; - if (gitCommitHash == null || gitCommitHash.contains("$")) { + if (gitCommitHash == null || gitCommitHash.contains("$") || gitCommitHash.contains("@")) { gitCommitHash = "master"; } return gitRepository + "/blob/" + gitCommitHash + "/" + path + "/"; diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/Sqls.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/Sqls.java index ad7c2a786..e0f29a30a 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/Sqls.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/Sqls.java @@ -23,7 +23,7 @@ public class Sqls { s1 = s1.substring(0, s1.length() - 1); if (!StringUtils.isEmpty(s1)) tmp.add(s1); - sqlList.add(String.join("\n", tmp.toArray(new String[tmp.size()]))); + sqlList.add(String.join("\n", tmp.toArray(new String[0]))); tmp.clear(); } else { if (!StringUtils.isEmpty(s1)) @@ -31,7 +31,7 @@ public class Sqls { } }); if (!tmp.isEmpty()) { - sqlList.add(String.join("\n", tmp.toArray(new String[tmp.size()]))); + sqlList.add(String.join("\n", tmp.toArray(new String[0]))); tmp.clear(); } return sqlList; diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextKey.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextKey.java index f2e1abb98..c9a6ae6b9 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextKey.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextKey.java @@ -6,7 +6,6 @@ import lombok.Getter; @AllArgsConstructor public final class ContextKey { - @Getter private String key; diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextUtils.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextUtils.java index 36aa32dbd..fb78c1318 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextUtils.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/ContextUtils.java @@ -7,7 +7,7 @@ import java.util.function.Consumer; import java.util.function.Function; /** - * @since 3.1.0 + * @since 4.0.0 */ public class ContextUtils { @@ -34,20 +34,4 @@ public class ContextUtils { }; } - - public static void main(String[] args) { - - currentContext() - .flatMap(ctx ->doRequest()) - .subscriberContext(acceptContext(ctx -> ctx.put(ContextKey.integer("test"), 100))) - .subscribe(System.out::println); - - } - - public static Mono doRequest() { - return currentContext() - .map(context -> context.get(ContextKey.integer("test")).orElse(0)); - } - - } diff --git a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/MapContext.java b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/MapContext.java index d438c02a7..80e93f071 100644 --- a/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/MapContext.java +++ b/hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/context/MapContext.java @@ -6,7 +6,7 @@ import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @SuppressWarnings("all") -public class MapContext implements Context { +class MapContext implements Context { private Map map = new ConcurrentHashMap<>(); @@ -18,7 +18,7 @@ public class MapContext implements Context { @Override public T getOrDefault(ContextKey key, T defaultValue) { - return (T)map.computeIfAbsent(key.getKey(), __ -> defaultValue); + return (T) map.computeIfAbsent(key.getKey(), __ -> defaultValue); } @Override diff --git a/hsweb-core/pom.xml b/hsweb-core/pom.xml index 9002f8578..02c93ba31 100644 --- a/hsweb-core/pom.xml +++ b/hsweb-core/pom.xml @@ -44,6 +44,12 @@ com.alibaba fastjson
+ + + org.springframework + spring-aspects + + org.spockframework spock-core diff --git a/hsweb-core/src/main/java/org/hswebframework/web/Describe.java b/hsweb-core/src/main/java/org/hswebframework/web/Describe.java deleted file mode 100644 index 56153ec80..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/Describe.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019 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; - -import java.lang.annotation.*; - -/** - * 功能描述 - * - * @author zhouhao - */ -@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Describe { - String value(); - - Class type() default Object.class; -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/ScriptScope.java b/hsweb-core/src/main/java/org/hswebframework/web/ScriptScope.java deleted file mode 100644 index 9030f0271..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/ScriptScope.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web; - -import java.lang.annotation.*; - -/** - * @author zhouhao - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface ScriptScope { - - String value() default ""; -} diff --git a/hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorContext.java b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorContext.java similarity index 97% rename from hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorContext.java rename to hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorContext.java index 4579fbe89..92377be60 100644 --- a/hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorContext.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorContext.java @@ -16,7 +16,7 @@ * */ -package org.hswebframework.web.boost.aop.context; +package org.hswebframework.web.aop; import java.io.Serializable; import java.lang.annotation.Annotation; diff --git a/hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorHolder.java b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java similarity index 81% rename from hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorHolder.java rename to hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java index 583c5fa3d..1b75be203 100644 --- a/hsweb-boost/hsweb-boost-aop/src/main/java/org/hswebframework/web/boost/aop/context/MethodInterceptorHolder.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java @@ -16,11 +16,10 @@ * */ -package org.hswebframework.web.boost.aop.context; +package org.hswebframework.web.aop; import org.aopalliance.intercept.MethodInvocation; -import org.hswebframework.web.AopUtils; -import org.hswebframework.web.ThreadLocalUtils; +import org.hswebframework.web.utils.AnnotationUtils; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer; import org.springframework.util.DigestUtils; @@ -41,18 +40,6 @@ public class MethodInterceptorHolder { */ public static final ParameterNameDiscoverer nameDiscoverer = new LocalVariableTableParameterNameDiscoverer(); - public static MethodInterceptorHolder current() { - return ThreadLocalUtils.get(MethodInterceptorHolder.class.getName()); - } - - public static MethodInterceptorHolder clear() { - return ThreadLocalUtils.getAndRemove(MethodInterceptorHolder.class.getName()); - } - - public static MethodInterceptorHolder setCurrent(MethodInterceptorHolder holder) { - return ThreadLocalUtils.put(MethodInterceptorHolder.class.getName(), holder); - } - public static MethodInterceptorHolder create(MethodInvocation invocation) { String id = DigestUtils.md5DigestAsHex(String.valueOf(invocation.getMethod().hashCode()).getBytes()); String[] argNames = nameDiscoverer.getParameterNames(invocation.getMethod()); @@ -74,11 +61,6 @@ public class MethodInterceptorHolder { private Map args; - public MethodInterceptorHolder set() { - MethodInterceptorHolder.setCurrent(this); - return this; - } - public MethodInterceptorHolder(String id, Method method, Object target, Map args) { Objects.requireNonNull(id); Objects.requireNonNull(method); @@ -107,15 +89,15 @@ public class MethodInterceptorHolder { } public T findMethodAnnotation(Class annClass) { - return AopUtils.findMethodAnnotation(annClass, method, annClass); + return AnnotationUtils.findMethodAnnotation(annClass, method, annClass); } public T findClassAnnotation(Class annClass) { - return AopUtils.findAnnotation(target.getClass(), annClass); + return AnnotationUtils.findAnnotation(target.getClass(), annClass); } public T findAnnotation(Class annClass) { - return AopUtils.findAnnotation(target.getClass(), method, annClass); + return AnnotationUtils.findAnnotation(target.getClass(), method, annClass); } public MethodInterceptorContext createParamContext() { diff --git a/hsweb-core/src/main/java/org/hswebframework/web/audit/Audit.java b/hsweb-core/src/main/java/org/hswebframework/web/audit/Audit.java deleted file mode 100644 index 7cdfec752..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/audit/Audit.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.audit; - -import java.lang.annotation.*; - -/** - * 审计信息注解,用于在修改更新数据的时候记录被修改的内容. - * @since 3.0.7 - * - */ -@Target({ElementType.FIELD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Audit { - - //审计信息简介,如功能,字段. - String value(); - - //审计信息的说明 - String comment() default ""; - - //是否忽略审计 - boolean ignore() default false; - - //字段生效策略,如果为MANUAL,修改数据时,字段将不会立即修改,而是需要手动审核通过后生效. - Strategy strategy() default Strategy.AUTO; - - //如果设置了审核权限,当进行审核或者回退的时候将进行权限验证. - //如: permission:user:audit - //role:admin - String auditPermission() default ""; -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditFieldMeta.java b/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditFieldMeta.java deleted file mode 100644 index 205502bb5..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditFieldMeta.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.audit; - -import lombok.Getter; -import lombok.Setter; - -/** - * @author zhouhao - * @since 3.0.7 - */ -@Getter -@Setter -public class AuditFieldMeta { - private String field; - - private String comment; - - private String type; - - private Strategy strategy; -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMeta.java b/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMeta.java deleted file mode 100644 index fc3e401d6..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMeta.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.audit; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.function.Consumer; - -/** - * 审计信息注解,用于在修改更新数据的时候记录被修改的内容. - * - * @since 3.0.7 - */ -@Getter -@Setter -public class AuditMeta { - - private String type; - - private String comment; - - private List fields; - - public boolean isEmpty() { - return CollectionUtils.isEmpty(fields); - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMetaParser.java b/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMetaParser.java deleted file mode 100644 index b9ee1c5ec..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/audit/AuditMetaParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.audit; - -import java.util.Optional; - -/** - * @author zhouhao - * @since 3.0.7 - */ -public interface AuditMetaParser { - - Optional parse(Class type); -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/audit/Strategy.java b/hsweb-core/src/main/java/org/hswebframework/web/audit/Strategy.java deleted file mode 100644 index 683163532..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/audit/Strategy.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.audit; - -/** - * 生效策略 - * - * @since 3.0.7 - */ -public enum Strategy { - AUTO, - MANUAL; -} \ No newline at end of file diff --git a/hsweb-core/src/main/java/org/hswebframework/web/context/Context.java b/hsweb-core/src/main/java/org/hswebframework/web/context/Context.java new file mode 100644 index 000000000..8f55fc29d --- /dev/null +++ b/hsweb-core/src/main/java/org/hswebframework/web/context/Context.java @@ -0,0 +1,15 @@ +package org.hswebframework.web.context; + +import java.util.Map; +import java.util.Optional; + +public interface Context { + + Optional get(ContextKey key); + + T getOrDefault(ContextKey key, T defaultValue); + + void put(ContextKey key, T value); + + Map getAll(); +} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/context/ContextKey.java b/hsweb-core/src/main/java/org/hswebframework/web/context/ContextKey.java new file mode 100644 index 000000000..c9a6ae6b9 --- /dev/null +++ b/hsweb-core/src/main/java/org/hswebframework/web/context/ContextKey.java @@ -0,0 +1,31 @@ +package org.hswebframework.web.context; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +public final class ContextKey { + + @Getter + private String key; + + public static ContextKey of(String key) { + return new ContextKey<>(key); + } + + public static ContextKey of(Class key) { + return new ContextKey<>(key.getName()); + } + + public static ContextKey string(String key) { + return of(key); + } + + public static ContextKey integer(String key) { + return of(key); + } + + public static ContextKey bool(String key) { + return of(key); + } +} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/context/ContextUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/context/ContextUtils.java new file mode 100644 index 000000000..fb78c1318 --- /dev/null +++ b/hsweb-core/src/main/java/org/hswebframework/web/context/ContextUtils.java @@ -0,0 +1,37 @@ +package org.hswebframework.web.context; + + +import reactor.core.publisher.Mono; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * @since 4.0.0 + */ +public class ContextUtils { + + + public static Mono currentContext() { + return Mono.subscriberContext() + .handle((context, sink) -> { + if (context.hasKey(Context.class)) { + sink.next(context.get(Context.class)); + } + }) + .subscriberContext(acceptContext(ctx->{ + + })); + } + + public static Function acceptContext(Consumer contextConsumer) { + return context -> { + if (!context.hasKey(Context.class)) { + context = context.put(Context.class, new MapContext()); + } + contextConsumer.accept(context.get(Context.class)); + return context; + }; + } + +} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/context/MapContext.java b/hsweb-core/src/main/java/org/hswebframework/web/context/MapContext.java new file mode 100644 index 000000000..80e93f071 --- /dev/null +++ b/hsweb-core/src/main/java/org/hswebframework/web/context/MapContext.java @@ -0,0 +1,33 @@ +package org.hswebframework.web.context; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; + +@SuppressWarnings("all") +class MapContext implements Context { + + private Map map = new ConcurrentHashMap<>(); + + @Override + public Optional get(ContextKey key) { + return Optional.ofNullable(map.get(key.getKey())) + .map(v -> ((T) v)); + } + + @Override + public T getOrDefault(ContextKey key, T defaultValue) { + return (T) map.computeIfAbsent(key.getKey(), __ -> defaultValue); + } + + @Override + public void put(ContextKey key, T value) { + map.put(key.getKey(), value); + } + + @Override + public Map getAll() { + return new HashMap<>(map); + } +} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/Dict.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/Dict.java index 239e3280b..8f60f4b43 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/Dict.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/Dict.java @@ -1,6 +1,5 @@ package org.hswebframework.web.dict; -import org.hswebframework.web.dict.defaults.DefaultDictParser; import java.lang.annotation.*; @@ -8,28 +7,19 @@ import java.lang.annotation.*; * @author zhouhao * @since 3.0 */ -@Target({ElementType.METHOD, ElementType.FIELD,ElementType.TYPE}) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Dict { /** - * 如果id对应的字典已经存在,则设置此属性进行关联,除了{@link Dict#parserId}属性的其他属性将被忽略
- * 如果id对应的字典不存在,则将使用其他属性进行定义 - * * @return 字典ID * @see DictDefine#getId() * @see DictDefineRepository */ - String id() default ""; + String value() default ""; /** - * 字典别名,如果指定了别名: - *
    - *
  • 在序列化为json后,会添加一个字段到json中. - * 字段的名称为此属性的值,字段的值为{@link Dict#parserId}对应的解析器的解析结果
  • - *
  • 在反序列化json时,如果被注解的字段值为null,将尝试解析别名字段的值并设置到注解的字段
  • - *
- * + * 字典别名 * @return 别名 */ String alias() default ""; @@ -39,19 +29,5 @@ public @interface Dict { */ String comments() default ""; - /** - * 字典解析器ID - * - * @return 字典解析器的id, 默认为default, 如果对应的解析器不存在,也将使用default - * @see DictParser - * @see DefaultDictParser - */ - String parserId() default "default"; - /** - * 如果要直接在注解上定义字典,通过设置此属性进行定义 - * - * @return 字典选项 - */ - Item[] items() default {}; } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefine.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefine.java index 4669c3c60..f23fb096e 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefine.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefine.java @@ -14,8 +14,6 @@ public interface DictDefine extends Serializable { String getComments(); - String getParserId(); - List> getItems(); } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefineRepository.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefineRepository.java index 347e590d8..9f0ff51c1 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefineRepository.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictDefineRepository.java @@ -11,8 +11,5 @@ public interface DictDefineRepository { List getAllDefine(); - @Deprecated - List getDefine(Class type); - void addDefine(DictDefine dictDefine); } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictParser.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictParser.java deleted file mode 100644 index 43fad705d..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictParser.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.dict; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DictParser { - String getId(); - - String parseText(DictDefine dictDefine, Object value); - - String parseValue(DictDefine dictDefine, String text); -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictSupportApi.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/DictSupportApi.java deleted file mode 100644 index 948d8d1c0..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/DictSupportApi.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.hswebframework.web.dict; - -/** - * @author zhouhao - * @since 3.0 - */ -@Deprecated -public interface DictSupportApi { - DictParser getParser(String id, String defaultId); - - default DictParser getParser(String id) { - return getParser(id, "default"); - } - - T wrap(T target); - - T unwrap(T target); - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java index 544c24d71..c160185ed 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java @@ -19,7 +19,6 @@ import java.util.function.Supplier; /** * 枚举字典,使用枚举来实现数据字典,可通过集成此接口来实现一些有趣的功能. * ⚠️:如果使用了位运算来判断枚举,枚举数量不要超过64个,且顺序不要随意变动! - * 如果枚举数量大于64,你应该使用{@link org.hswebframework.web.dict.apply.DictApply}来处理. * ⚠️:如果要开启在反序列化json的时候,支持将对象反序列化枚举,由于fastJson目前的版本还不支持从父类获取注解, * 所以需要在实现类上注解:@JSONType(deserializer = EnumDict.EnumDictJSONDeserializer.class). * @@ -48,7 +47,7 @@ public interface EnumDict extends JSONSerializable { String getText(); /** - * {@link Enum#ordinal} + * {@link Enum#ordinal()} * * @return 枚举序号, 如果枚举顺序改变, 此值将被变动 */ diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/Item.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/Item.java deleted file mode 100644 index 15722bd19..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/Item.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.dict; - -import java.lang.annotation.*; - -/** - * 字典选项注解 - * - * @author zhouhao - * @see Dict - * @since 3.0 - */ -@Target({ElementType.ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Item { - - /** - * @return 选项文本, 如: 男 - */ - String text() default ""; - - /** - * @return 选项值, 如: 1 - */ - String value() default ""; - - /** - * @return 字典说明 - */ - String[] comments() default {}; -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DefaultDictApply.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DefaultDictApply.java deleted file mode 100644 index a6516cec4..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DefaultDictApply.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.hswebframework.web.dict.apply; - -import org.hswebframework.web.dict.DictDefineRepository; -import org.hswebframework.web.dict.EnumDict; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author zhouhao - * @since 3.0 - */ -public class DefaultDictApply implements DictApply { - - private DictDefineRepository repository; - - protected Map cache = new ConcurrentHashMap<>(); - - @Override - public T apply(T bean) { - cache.computeIfAbsent(ClassUtils.getUserClass(bean.getClass()), this::createCache) - .wrap(bean, repository); - return bean; - } - - protected DictWrapper createCache(Class bean) { - StringBuilder method = new StringBuilder() - .append("public void wrap(Object bean, org.hswebframework.web.dict.DictDefineRepository repository)") - .append("{\n") - .append(bean.getName()).append(" target=(").append(bean.getName()).append(")bean;\n"); - - ReflectionUtils.doWithFields(bean, field -> { - Class type = field.getType(); - if (type.isArray()) { - type = type.getComponentType(); - } - //枚举字典并且枚举数量大于64 - if (type.isEnum() && EnumDict.class.isAssignableFrom(type) && type.getEnumConstants().length >= 64) { - - } - }); - method.append("\n}"); - return DictWrapper.empty; - } - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictApply.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictApply.java deleted file mode 100644 index 62db8fea4..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictApply.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.dict.apply; - -/** - * 数据字典应用类 - * - * @author zhouhao - * @since 3.0 - */ -public interface DictApply { - - T apply(T bean); - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictWrapper.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictWrapper.java deleted file mode 100644 index 83b334c98..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/apply/DictWrapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.dict.apply; - -import org.hswebframework.web.dict.DictDefineRepository; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DictWrapper { - DictWrapper empty = (bean, repository) -> {}; - - void wrap(Object bean, DictDefineRepository repository); - - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultClassDictDefine.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultClassDictDefine.java index 85ac24b15..bc2bb1c88 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultClassDictDefine.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultClassDictDefine.java @@ -24,6 +24,5 @@ public class DefaultClassDictDefine implements ClassDictDefine { private String id; private String alias; private String comments; - private String parserId; private List> items; } diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictDefineRepository.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictDefineRepository.java index 16e4d8fd0..2f1ba8258 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictDefineRepository.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictDefineRepository.java @@ -34,8 +34,7 @@ public class DefaultDictDefineRepository implements DictDefineRepository { DefaultClassDictDefine define = new DefaultClassDictDefine(); define.setField(""); if (dict != null) { - define.setId(dict.id()); - define.setParserId(dict.parserId()); + define.setId(dict.value()); define.setComments(dict.comments()); define.setAlias(dict.alias()); } else { @@ -43,10 +42,7 @@ public class DefaultDictDefineRepository implements DictDefineRepository { define.setAlias(type.getName()); define.setComments(type.getSimpleName()); } - - List dicts = Arrays.asList(type.getEnumConstants()); - - define.setItems(new ArrayList<>(dicts)); + define.setItems(new ArrayList<>(Arrays.asList(type.getEnumConstants()))); return define; @@ -62,12 +58,6 @@ public class DefaultDictDefineRepository implements DictDefineRepository { return new ArrayList<>(parsedDict.values()); } - @Override - public List getDefine(Class type) { - return new java.util.ArrayList<>(); - } - - @Override public void addDefine(DictDefine dictDefine) { registerDefine(dictDefine); diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictParser.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictParser.java deleted file mode 100644 index 530ea09dc..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictParser.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.dict.defaults; - -import org.hswebframework.web.dict.DictDefine; -import org.hswebframework.web.dict.DictParser; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dict.ItemDefine; - -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -public class DefaultDictParser implements DictParser { - @Override - public String getId() { - return "default"; - } - - @Override - public String parseText(DictDefine dictDefine, Object value) { - return dictDefine.getItems() - .stream() - .filter(itemDefine -> itemDefine.eq(value)) - .map(EnumDict::getText) - .collect(Collectors.joining(",")); - } - - @Override - public String parseValue(DictDefine dictDefine, String text) { - return dictDefine.getItems() - .stream() - .filter(itemDefine -> itemDefine.eq(text)) - .map(EnumDict::getValue) - .map(String::valueOf) - .findFirst() - .orElse(text); - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictSupportApi.java b/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictSupportApi.java deleted file mode 100644 index b02bded6a..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictSupportApi.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.hswebframework.web.dict.defaults; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.beanutils.BeanUtils; -import org.hswebframework.web.dict.ClassDictDefine; -import org.hswebframework.web.dict.DictDefineRepository; -import org.hswebframework.web.dict.DictParser; -import org.hswebframework.web.dict.DictSupportApi; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -@Slf4j -public class DefaultDictSupportApi implements DictSupportApi { - - private DictDefineRepository repository; - - private Map parserRepo = new HashMap<>(); - - public DefaultDictSupportApi(DictDefineRepository repository) { - this.repository = repository; - DictParser defaultParser = new DefaultDictParser(); - parserRepo.put(defaultParser.getId(), defaultParser); - } - - @Override - public DictParser getParser(String id, String defaultId) { - return Optional.ofNullable(parserRepo.get(id)).orElseGet(() -> parserRepo.get(defaultId)); - } - - @Override - @SuppressWarnings("all") - public T unwrap(T target) { - return target; - } - - @Override - @SuppressWarnings("all") - public T wrap(T target) { - return target; - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/TrueOrFalse.java b/hsweb-core/src/main/java/org/hswebframework/web/enums/TrueOrFalse.java similarity index 73% rename from hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/TrueOrFalse.java rename to hsweb-core/src/main/java/org/hswebframework/web/enums/TrueOrFalse.java index 9ed6e7656..2d2156263 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/TrueOrFalse.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/enums/TrueOrFalse.java @@ -1,13 +1,15 @@ -package org.hswebframework.web.dict.defaults; +package org.hswebframework.web.enums; import lombok.AllArgsConstructor; import lombok.Getter; +import org.hswebframework.web.dict.Dict; import org.hswebframework.web.dict.EnumDict; @Getter @AllArgsConstructor +@Dict("true-or-false") public enum TrueOrFalse implements EnumDict { - + TRUE((byte) 1, "是"), FALSE((byte) 0, "否"); diff --git a/hsweb-core/src/main/java/org/hswebframework/web/BusinessException.java b/hsweb-core/src/main/java/org/hswebframework/web/exception/BusinessException.java similarity index 97% rename from hsweb-core/src/main/java/org/hswebframework/web/BusinessException.java rename to hsweb-core/src/main/java/org/hswebframework/web/exception/BusinessException.java index bd7acb07c..0ad7041e8 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/BusinessException.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/exception/BusinessException.java @@ -16,7 +16,7 @@ * */ -package org.hswebframework.web; +package org.hswebframework.web.exception; import lombok.Getter; diff --git a/hsweb-core/src/main/java/org/hswebframework/web/NotFoundException.java b/hsweb-core/src/main/java/org/hswebframework/web/exception/NotFoundException.java similarity index 95% rename from hsweb-core/src/main/java/org/hswebframework/web/NotFoundException.java rename to hsweb-core/src/main/java/org/hswebframework/web/exception/NotFoundException.java index dd7e5e1e4..d288e2633 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/NotFoundException.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/exception/NotFoundException.java @@ -16,7 +16,7 @@ * */ -package org.hswebframework.web; +package org.hswebframework.web.exception; /** * diff --git a/hsweb-core/src/main/java/org/hswebframework/web/utils/AnnotationUtils.java b/hsweb-core/src/main/java/org/hswebframework/web/utils/AnnotationUtils.java new file mode 100644 index 000000000..82ccd8383 --- /dev/null +++ b/hsweb-core/src/main/java/org/hswebframework/web/utils/AnnotationUtils.java @@ -0,0 +1,113 @@ +/* + * Copyright 2019 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.utils; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.util.ClassUtils; +import org.springframework.util.ReflectionUtils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.*; + +public final class AnnotationUtils { + + private AnnotationUtils() { + } + + public static T findMethodAnnotation(Class targetClass, Method method, Class annClass) { + Method m = method; + T a = org.springframework.core.annotation.AnnotationUtils.findAnnotation(m, annClass); + if (a != null) { + return a; + } + m = ClassUtils.getMostSpecificMethod(m, targetClass); + a = org.springframework.core.annotation.AnnotationUtils.findAnnotation(m, annClass); + if (a == null) { + List supers = new ArrayList<>(Arrays.asList(targetClass.getInterfaces())); + if (targetClass.getSuperclass() != Object.class) { + supers.add(targetClass.getSuperclass()); + } + + for (Class aClass : supers) { + if(aClass==null){ + continue; + } + Method ims[] = new Method[1]; + + ReflectionUtils.doWithMethods(aClass, im -> { + if (im.getName().equals(method.getName()) && im.getParameterCount() == method.getParameterCount()) { + ims[0] = im; + } + }); + + if (ims[0] != null) { + a = findMethodAnnotation(aClass, ims[0], annClass); + if (a != null) { + return a; + } + } + } + } + return a; + } + + public static T findAnnotation(Class targetClass, Class annClass) { + return org.springframework.core.annotation.AnnotationUtils.findAnnotation(targetClass, annClass); + } + + public static T findAnnotation(Class targetClass, Method method, Class annClass) { + T a = findMethodAnnotation(targetClass, method, annClass); + if (a != null) { + return a; + } + return findAnnotation(targetClass, annClass); + } + + public static T findAnnotation(JoinPoint pjp, Class annClass) { + MethodSignature signature = (MethodSignature) pjp.getSignature(); + Method m = signature.getMethod(); + Class targetClass = pjp.getTarget().getClass(); + return findAnnotation(targetClass, m, annClass); + } + + public static String getMethodBody(JoinPoint pjp) { + StringBuilder methodName = new StringBuilder(pjp.getSignature().getName()).append("("); + MethodSignature signature = (MethodSignature) pjp.getSignature(); + String[] names = signature.getParameterNames(); + Class[] args = signature.getParameterTypes(); + for (int i = 0, len = args.length; i < len; i++) { + if (i != 0) { + methodName.append(","); + } + methodName.append(args[i].getSimpleName()).append(" ").append(names[i]); + } + return methodName.append(")").toString(); + } + + public static Map getArgsMap(JoinPoint pjp) { + MethodSignature signature = (MethodSignature) pjp.getSignature(); + Map args = new LinkedHashMap<>(); + String names[] = signature.getParameterNames(); + for (int i = 0, len = names.length; i < len; i++) { + args.put(names[i], pjp.getArgs()[i]); + } + return args; + } +} \ No newline at end of file diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validate/SimpleValidateResults.java b/hsweb-core/src/main/java/org/hswebframework/web/validate/SimpleValidateResults.java deleted file mode 100644 index 427248eec..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validate/SimpleValidateResults.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * * Copyright 2019 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.validate; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author zhouhao - */ -public class SimpleValidateResults implements ValidateResults { - - private static final long serialVersionUID = -3355828475840578917L; - private List results = new ArrayList<>(); - - public SimpleValidateResults addResult(String field, String message) { - results.add(new Result(field, message)); - return this; - } - - public SimpleValidateResults addResult(ValidateResults.Result result) { - results.add(result); - return this; - } - - @Override - public boolean isSuccess() { - return results == null || results.isEmpty(); - } - - @Override - public List getResults() { - return results; - } - - class Result implements ValidateResults.Result { - private static final long serialVersionUID = -4717219071013488363L; - private String field; - private String message; - - public Result(String field, String message) { - this.field = field; - this.message = message; - } - - @Override - public String getField() { - return field; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public String toString() { - return "{" + - "\"field\":\"" + field + '\"' + - ", \"message:\"" + message + '\"' + - '}'; - } - } - - @Override - public String toString() { - if (isSuccess()) { - return "success"; - } - return results.toString(); - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidateResults.java b/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidateResults.java deleted file mode 100644 index 7cb532841..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidateResults.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019 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.validate; - -import java.io.Serializable; -import java.util.List; - -/** - * 验证结果 - * - * @author zhouhao - */ -public interface ValidateResults extends Serializable { - - boolean isSuccess(); - - List getResults(); - - interface Result extends Serializable { - String getField(); - - String getMessage(); - } - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidationException.java b/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidationException.java deleted file mode 100644 index 4c8944a44..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validate/ValidationException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * Copyright 2019 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.validate; - - -import org.hswebframework.web.BusinessException; - -import java.util.Collections; -import java.util.List; - -public class ValidationException extends BusinessException { - private static final long serialVersionUID = 7807607467371210082L; - private ValidateResults results; - - public ValidationException(String message) { - super(message, 400); - } - - public ValidationException(String message, String field) { - super(message, 400); - results = new SimpleValidateResults().addResult(field, message); - } - - public ValidationException(ValidateResults results) { - super(results.getResults().get(0).getMessage(), 400); - this.results = results; - } - - public List getResults() { - if (results == null) { - return new java.util.ArrayList<>(); - } - return results.getResults(); - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validator/DuplicateKeyException.java b/hsweb-core/src/main/java/org/hswebframework/web/validator/DuplicateKeyException.java deleted file mode 100644 index 3a28ded3d..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validator/DuplicateKeyException.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.validator; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.BusinessException; - -import java.util.Map; - -@Getter -@Setter -public class DuplicateKeyException extends BusinessException { - - private static final long serialVersionUID = 8449360528527473673L; - private LogicPrimaryKeyValidator.Result result; - - public DuplicateKeyException(LogicPrimaryKeyValidator.Result result) { - this(result, result.getMessage()); - } - - public DuplicateKeyException(LogicPrimaryKeyValidator.Result result, String message) { - super(message, 400); - this.result = result; - } -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKey.java b/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKey.java deleted file mode 100644 index 4a96056b3..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKey.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.validator; - - -import java.lang.annotation.*; - -/** - * 逻辑主键,用于在新增或者修改前进行重复数据判断. - * 可在类或者字段上进行注解 - * - * @see DuplicateKeyException - * @since 3.0.0-RC - */ -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface LogicPrimaryKey { - - /** - * 属性名称,如果注解在类上,值为空的时候必须指定{@link this#groups()},并且group对应的类上必须有合法的LogicPrimaryKey注解 - * - * @return 属性名集合, 在字段上此属性无效 - */ - String[] value() default {}; - - /** - * 验证条件,值为一个spel表达式,可在验证的时候根据实体中不同的属性,使用不同的规则,例如: - *
-     *     #object.name!=null
-     * 
- * - * @return spel表达式, 为空时不进行判断 - */ - String condition() default ""; - - /** - * 查询条件类型,基于hsweb-commons-dao中的termType,可指定此字段查询的方式,默认为:'eq'(=) - * - * @return 自定义查询条件类型 - */ - String termType() default ""; - - /** - * 是否匹配空值,如果为true,并且值为null时,进行where field is null,如果值为"",则进行where field =''。否则将跳过该字段验证 - * - * @return 是否匹配空值 - */ - boolean matchNullOrEmpty() default false; - - /** - * 验证分组,如果在验证的时候指定了分组,则只会验证对应分组的规则 - * - * @return 分组 - */ - Class[] groups() default Void.class; - -} diff --git a/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKeyValidator.java b/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKeyValidator.java deleted file mode 100644 index 86442c0dc..000000000 --- a/hsweb-core/src/main/java/org/hswebframework/web/validator/LogicPrimaryKeyValidator.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.hswebframework.web.validator; - -import lombok.Getter; -import lombok.Setter; -import lombok.SneakyThrows; - -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * 逻辑主键验证器 - * - * @see LogicPrimaryKey - * @see Result - */ -public interface LogicPrimaryKeyValidator { - - Result validate(T bean, Class... group); - - @Getter - @Setter - class Result { - - public static Result passed() { - Result result = new Result(); - result.setError(false); - return result; - } - - private boolean error=false; - - private T data; - - private Map properties; - - private String message = "存在相同数据"; - - public boolean isPassed() { - return !error; - } - - public void ifPassed(Consumer> consumer) { - if (isPassed()) { - consumer.accept(this); - } - } - - public void ifError(Consumer> consumer) { - if (isError()) { - consumer.accept(this); - } - } - - public void ifErrorThrow() { - ifErrorThrow(DuplicateKeyException::new); - } - - @SneakyThrows - public void ifErrorThrow(Function, Exception> exceptionGetter) { - if (isError()) { - throw exceptionGetter.apply(this); - } - } - } -} diff --git a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceClosedException.java b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceClosedException.java index f772cb575..f31f43f5d 100644 --- a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceClosedException.java +++ b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceClosedException.java @@ -1,6 +1,6 @@ package org.hswebframework.web.datasource.exception; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.NotFoundException; /** * @author zhouhao diff --git a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceNotFoundException.java b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceNotFoundException.java index d66ca0cbd..b10349ce9 100644 --- a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceNotFoundException.java +++ b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/exception/DataSourceNotFoundException.java @@ -1,6 +1,6 @@ package org.hswebframework.web.datasource.exception; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.NotFoundException; /** * @author zhouhao diff --git a/hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/RestControllerExceptionTranslator.java b/hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/RestControllerExceptionTranslator.java index 1dba64e31..cacd4e89e 100644 --- a/hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/RestControllerExceptionTranslator.java +++ b/hsweb-starter/hsweb-spring-boot-starter/src/main/java/org/hswebframework/web/starter/RestControllerExceptionTranslator.java @@ -18,8 +18,8 @@ package org.hswebframework.web.starter; import com.alibaba.fastjson.JSONException; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.NotFoundException; +import org.hswebframework.web.exception.BusinessException; +import org.hswebframework.web.exception.NotFoundException; import org.hswebframework.web.authorization.exception.AccessDenyException; import org.hswebframework.web.authorization.exception.NeedTwoFactorException; import org.hswebframework.web.authorization.exception.UnAuthorizedException; @@ -30,7 +30,6 @@ import org.hswebframework.web.validate.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DuplicateKeyException; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml deleted file mode 100644 index a9ecc5007..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - hsweb-system-authorization - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-authorization-api - - 业务模块-权限管理API - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - - org.hswebframework.web - hsweb-authorization-api - ${project.version} - - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java deleted file mode 100644 index 5ea5fed9a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ActionEntity.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.*; -import org.hswebframework.web.commons.entity.CloneableEntity; -import org.springframework.util.StringUtils; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class ActionEntity implements CloneableEntity { - - private static final long serialVersionUID = -5756333786703175612L; - - private String action; - - private String describe; - - private boolean defaultCheck; - - private Map properties; - - public ActionEntity(String action) { - this.action = action; - } - - @Override - @SneakyThrows - public ActionEntity clone() { - return (ActionEntity) super.clone(); - } - - public static List create(String... actions) { - return Arrays.stream(actions).map(ActionEntity::new).collect(Collectors.toList()); - } - - @Override - public int hashCode() { - return getAction().hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof ActionEntity && obj.hashCode() == hashCode(); - } - - @Override - public String toString() { - return action + (StringUtils.hasText(describe) ? "(" + describe + ")" : ""); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java deleted file mode 100644 index 200b1820c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingDetailEntity.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2019 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.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; -import java.util.Set; - -/** - * 权限设置详情 实体 - * - * @author hsweb-generator-online - */ -public interface AuthorizationSettingDetailEntity extends GenericEntity, Comparable { - - Byte STATE_OK = 1; - - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 权限id - */ - String permissionId = "permissionId"; - /** - * 设置id - */ - String settingId = "settingId"; - /** - * 可操作类型 - */ - String actions = "actions"; - /** - * 数据权限控制 - */ - String dataAccesses = "dataAccesses"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 权限id - */ - @NotBlank(groups = CreateGroup.class) - String getPermissionId(); - - /** - * 设置 权限id - */ - void setPermissionId(String permissionId); - - /** - * @return 设置id - */ - @NotBlank(groups = CreateGroup.class) - String getSettingId(); - - /** - * 设置 设置id - */ - void setSettingId(String settingId); - - /** - * @return 可操作类型 - */ - Set getActions(); - - /** - * 设置 可操作类型 - */ - void setActions(Set actions); - - /** - * @return 数据权限控制 - */ - List getDataAccesses(); - - /** - * 设置 数据权限控制 - */ - void setDataAccesses(List dataAccesses); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - Long getPriority(); - - void setPriority(Long priority); - - Boolean getMerge(); - - void setMerge(Boolean merge); - - @Override - default int compareTo(AuthorizationSettingDetailEntity target) { - return Long.compare(getPriority() == null ? 0 : getPriority(), target.getPriority() == null ? 0 : target.getPriority()); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java deleted file mode 100644 index 60b25921d..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2019 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.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * 权限设置 实体 - * - * @author hsweb-generator-online - */ -public interface AuthorizationSettingEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 设置类型(维度),如: role - * - * @see org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier - */ - String type = "type"; - /** - * 设置给谁,通常是{@link this#type}对应的id - * @see org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier - */ - String settingFor = "settingFor"; - /** - * 状态 - */ - String status = "status"; - /** - * 备注 - */ - String describe = "describe"; - - /** - * @return 类型 - */ - @NotBlank(groups = CreateGroup.class) - String getType(); - - /** - * 设置 类型 - */ - void setType(String type); - - /** - * @return 设置给谁 - */ - @NotBlank(groups = CreateGroup.class) - String getSettingFor(); - - /** - * 设置 设置给谁 - */ - void setSettingFor(String settingFor); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - /** - * @return 备注 - */ - String getDescribe(); - - /** - * 设置 备注 - */ - void setDescribe(String describe); - - List getDetails(); - - void setDetails(List details); - - List getMenus(); - - void setMenus(List menus); -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java deleted file mode 100644 index e6fd88c7b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/AuthorizationSettingMenuEntity.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2019 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.TreeSortSupportEntity; - -import java.util.List; - -/** - * 权限菜单 实体 - * - * @author hsweb-generator-online - */ -public interface AuthorizationSettingMenuEntity extends TreeSortSupportEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 菜单id - */ - String menuId = "menuId"; - /** - * 设置id - */ - String settingId = "settingId"; - /** - * 排序 - */ - String sortIndex = "sortIndex"; - /** - * 上级id - */ - String parentId = "parentId"; - /** - * 状态 - */ - String status = "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 children); -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/DataAccessEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/DataAccessEntity.java deleted file mode 100644 index b972e424c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/DataAccessEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.commons.entity.CloneableEntity; - -/** - * @author zhouhao - */ -@Getter -@Setter -@EqualsAndHashCode -public class DataAccessEntity implements CloneableEntity { - private static final long serialVersionUID = 2198771924746804915L; - - private String action; - - private String describe; - - private String type; - - private String config; - - @Override - public DataAccessEntity clone() { - DataAccessEntity target = new DataAccessEntity(); - target.setDescribe(getDescribe()); - target.setAction(getAction()); - target.setConfig(getConfig()); - target.setType(getType()); - return target; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuEntity.java deleted file mode 100644 index 49eea0f1c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuEntity.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2019 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.TreeSortSupportEntity; - -import java.util.List; - -/** - * @author zhouhao - */ -public interface MenuEntity - extends TreeSortSupportEntity { - - String getName(); - - void setName(String name); - - String getDescribe(); - - void setDescribe(String describe); - - String getPermissionId(); - - void setPermissionId(String permissionId); - - String getUrl(); - - void setUrl(String url); - - String getIcon(); - - void setIcon(String icon); - - Byte getStatus(); - - void setStatus(Byte status); - - void setChildren(List children); - - @Override - MenuEntity clone(); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupBindEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupBindEntity.java deleted file mode 100644 index f1d70903e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupBindEntity.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2019 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.TreeSortSupportEntity; - -import java.util.List; - -/** - * 菜单分组关联 实体 - * - * @author hsweb-generator-online - */ -public interface MenuGroupBindEntity extends TreeSortSupportEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 树结构编码 - */ - String path = "path"; - /** - * 父级id - */ - String parentId = "parentId"; - /** - * 树层级 - */ - String level = "level"; - /** - * 排序序号 - */ - String sortIndex = "sortIndex"; - /** - * 状态 - */ - String status = "status"; - /** - * 菜单id - */ - String menuId = "menuId"; - /** - * 分组id - */ - String groupId = "groupId"; - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - /** - * @return 菜单id - */ - String getMenuId(); - - /** - * 设置 菜单id - */ - void setMenuId(String menuId); - - /** - * @return 分组id - */ - String getGroupId(); - - /** - * 设置 分组id - */ - void setGroupId(String groupId); - - - void setChildren(List children); -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupEntity.java deleted file mode 100644 index 5fa27f1f0..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/MenuGroupEntity.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2019 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.TreeSortSupportEntity; - -import java.util.List; - -/** - * 菜单分组 实体 - * - * @author hsweb-generator-online - */ -public interface MenuGroupEntity extends TreeSortSupportEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 分组名称 - */ - String name = "name"; - /** - * 分组描述 - */ - String describe = "describe"; - /** - * 是否默认 - */ - String defaultGroup = "defaultGroup"; - /** - * 树结构编码 - */ - String path = "path"; - /** - * 父级id - */ - String parentId = "parentId"; - /** - * 树层级 - */ - String level = "level"; - /** - * 排序序号 - */ - String sortIndex = "sortIndex"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 分组名称 - */ - String getName(); - - /** - * 设置 分组名称 - */ - void setName(String name); - - /** - * @return 分组描述 - */ - String getDescribe(); - - /** - * 设置 分组描述 - */ - void setDescribe(String describe); - - /** - * @return 是否默认 - */ - Boolean getDefaultGroup(); - - /** - * 设置 是否默认 - */ - void setDefaultGroup(Boolean defaultGroup); - - Byte getStatus(); - - void setStatus(Byte status); - - List getBindInfo(); - - void setBindInfo(List bindInfo); -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/OptionalField.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/OptionalField.java deleted file mode 100644 index 2a64808ec..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/OptionalField.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import org.hswebframework.web.commons.entity.CloneableEntity; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class OptionalField implements CloneableEntity { - private String name; - - private String describe; - - 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; - } - - @Override - public OptionalField clone() { - OptionalField optionalField = new OptionalField(); - optionalField.setName(name); - optionalField.setDescribe(describe); - return optionalField; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ParentPermission.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ParentPermission.java deleted file mode 100644 index 6efad0770..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/ParentPermission.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.Entity; - -import java.util.Set; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class ParentPermission implements Entity { - - private static final long serialVersionUID = -7099575758680437572L; - - private String permission; - - private Set actions; - - private Set preActions; -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/PermissionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/PermissionEntity.java deleted file mode 100644 index 16706b38f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/PermissionEntity.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2019 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 javax.validation.constraints.Pattern; -import java.util.List; - -/** - * @author zhouhao - */ -public interface PermissionEntity extends GenericEntity { - - @Override - @Pattern(regexp = "[a-zA-Z0-9_\\-]+") - String getId(); - - String getName(); - - String getDescribe(); - - Byte getStatus(); - - void setStatus(Byte status); - - String getType(); - - void setType(String type); - - void setName(String name); - - void setDescribe(String comment); - - List getActions(); - - void setActions(List actions); - - /** - * 此权限支持的数据权限类型,此字段只用于前端使用,在分配权限的时候,可以通过此字段来展示相应的数据权限设置,后台并没有使用此字段 - * @return 支持的数据权限类型 - */ - List getSupportDataAccessTypes(); - - void setSupportDataAccessTypes(List supportDataAccessTypes); - - void setOptionalFields(List fields); - - List getOptionalFields(); - - //直接关联其他权限 - List getParents(); - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java deleted file mode 100644 index a1910abe0..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/RoleEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 角色实体 - * - * @author zhouhao - */ -public interface RoleEntity extends GenericEntity { - - String name = "name"; - String describe = "describe"; - String status = "status"; - - String getName(); - - void setName(String name); - - String getDescribe(); - - void setDescribe(String describe); - - void setStatus(Byte status); - - Byte getStatus(); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java deleted file mode 100644 index 40c19e7cb..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingDetailEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.List; -import java.util.Set; - -/** - * 权限设置详情 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleAuthorizationSettingDetailEntity extends SimpleGenericEntity implements AuthorizationSettingDetailEntity { - private static final long serialVersionUID = -4284551748747749521L; - //权限id - private String permissionId; - //设置id - private String settingId; - //可操作类型 - private Set actions; - //数据权限控制 - private List dataAccesses; - //状态 - private Byte status; - //优先级 - private Long priority; - //是否合并 - private Boolean merge; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java deleted file mode 100644 index 0608dabb3..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingEntity.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.List; - -/** - * 权限设置 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleAuthorizationSettingEntity extends SimpleGenericEntity implements AuthorizationSettingEntity { - private static final long serialVersionUID = -6036823477895044483L; - //类型 - private String type; - //设置给谁 - private String settingFor; - //状态 - private Byte status; - //备注 - private String describe; - - private List menus; - - private List details; - - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java deleted file mode 100644 index ce33466af..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleAuthorizationSettingMenuEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 权限菜单 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleAuthorizationSettingMenuEntity extends SimpleTreeSortSupportEntity implements AuthorizationSettingMenuEntity { - private static final long serialVersionUID = 4311480526446922229L; - //菜单id - private String menuId; - //设置id - private String settingId; - //状态 - private Byte status; - //其他配置内容 - private String config; - private List children; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuEntity.java deleted file mode 100644 index d7a6c7d81..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuEntity.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * 菜单实体 - * - * @author zhouhao - * @since 3.0 - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleMenuEntity extends SimpleTreeSortSupportEntity - implements MenuEntity { - - private static final long serialVersionUID = 6942822850955576468L; - //菜单名称 - private String name; - - //备注 - private String describe; - - //权限ID - private String permissionId; - - //菜单对应的url - private String url; - - //图标 - private String icon; - - //状态 - private Byte status; - - //子菜单 - private List children; - - @Override - public SimpleMenuEntity clone() { - SimpleMenuEntity target = (SimpleMenuEntity) super.clone(); - target.setProperties(cloneProperties()); - if (null != getChildren()) { - target.setChildren(getChildren().stream() - .map(MenuEntity::clone) - .collect(Collectors.toList())); - } - return target; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupBindEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupBindEntity.java deleted file mode 100644 index bc2c3380a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupBindEntity.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 菜单分组关联 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleMenuGroupBindEntity extends SimpleTreeSortSupportEntity implements MenuGroupBindEntity { - private static final long serialVersionUID = -8671671135008425741L; - //状态 - private Byte status; - //菜单id - private String menuId; - //分组id - private String groupId; - //子节点 - private List children; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupEntity.java deleted file mode 100644 index 651e86dfa..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleMenuGroupEntity.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 菜单分组 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleMenuGroupEntity extends SimpleTreeSortSupportEntity implements MenuGroupEntity { - private static final long serialVersionUID = 349586524046467254L; - //分组名称 - private String name; - //分组描述 - private String describe; - //是否默认 - private Boolean defaultGroup; - //状态 - private Byte status; - - private List children; - - private List bindInfo; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimplePermissionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimplePermissionEntity.java deleted file mode 100644 index 63dec7348..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimplePermissionEntity.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class SimplePermissionEntity extends SimpleGenericEntity implements PermissionEntity { - private static final long serialVersionUID = -5505339187716888516L; - @NotBlank - private String name; - - private String describe; - - private Byte status; - - private String type; - - //支持的数据权限控制类型 - private List supportDataAccessTypes; - - //可选事件 - private List actions; - - private List optionalFields; - - //直接关联其他权限 - private List parents; - - @Override - public SimplePermissionEntity clone() { - SimplePermissionEntity target = (SimplePermissionEntity) super.clone(); - if (actions != null) { - target.setActions(getActions().stream().map(ActionEntity::clone).collect(Collectors.toList())); - } - if (parents != null) { - target.setParents(new ArrayList<>(getParents())); - } - if (optionalFields != null) { - target.setOptionalFields(getOptionalFields().stream().map(OptionalField::clone).collect(Collectors.toList())); - } - if (supportDataAccessTypes != null) { - target.setSupportDataAccessTypes(new ArrayList<>(supportDataAccessTypes)); - } - return target; - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java deleted file mode 100644 index b1b892ca6..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleRoleEntity.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleRoleEntity extends SimpleGenericEntity implements RoleEntity { - private static final long serialVersionUID = -2857131363164004807L; - private String name; - - private String describe; - - private Byte status; - - @Override - public SimpleRoleEntity clone() { - return ((SimpleRoleEntity) super.clone()); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java deleted file mode 100644 index 798e73ed7..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserEntity.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.bean.ToString; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleUserEntity extends SimpleGenericEntity implements UserEntity { - private static final long serialVersionUID = -2625681326256009807L; - - private String name; - - private String username; - - @ToString.Ignore - private String password; - - @ToString.Ignore(cover = false) - private String salt; - - private Long createTime; - - private String creatorId; - - private Byte status; - - @Override - public SimpleUserEntity clone() { - return ((SimpleUserEntity) super.clone()); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserRoleEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserRoleEntity.java deleted file mode 100644 index 4b078ebef..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/SimpleUserRoleEntity.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleUserRoleEntity implements UserRoleEntity { - - private static final long serialVersionUID = -8831232608833695774L; - - private String userId; - - private String roleId; - - @Override - public SimpleUserRoleEntity clone() { - SimpleUserRoleEntity target = new SimpleUserRoleEntity(); - target.setRoleId(getRoleId()); - target.setUserId(getUserId()); - return target; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java deleted file mode 100644 index a30f0c45e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2019 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.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -/** - * @author zhouhao - */ -public interface UserEntity extends GenericEntity, RecordCreationEntity { - String name = "name"; - String username = "username"; - String salt = "salt"; - @SuppressWarnings("all") - String password = "password"; - String status = "status"; - - void setName(String name); - - /** - * @return 用户名, 只读, 只能新增, 不能修改 - */ - String getUsername(); - - void setUsername(String username); - - @NotBlank(groups = CreateGroup.class) - String getName(); - - void setPassword(String password); - - String getPassword(); - - void setSalt(String salt); - - String getSalt(); - - /** - * @return 数据状态 - * @see org.hswebframework.web.commons.entity.DataStatus - */ - Byte getStatus(); - - void setStatus(Byte status); - - @Override - UserEntity clone(); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java deleted file mode 100644 index 8b1b5bde6..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserMenuEntity.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class UserMenuEntity extends SimpleTreeSortSupportEntity { - - private static final long serialVersionUID = 7839545362972442294L; - - private String menuId; - - //菜单名称 - private String name; - - //备注 - private String describe; - - //权限ID - private String permissionId; - - //菜单对应的url - private String url; - - //图标 - private String icon; - - private List children; - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java deleted file mode 100644 index 0eee8f5b2..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserRoleEntity.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import org.hswebframework.web.commons.entity.CloneableEntity; - -/** - * @author zhouhao - */ -public interface UserRoleEntity extends CloneableEntity { - - String getUserId(); - - void setUserId(String userId); - - String getRoleId(); - - void setRoleId(String roleId); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserSettingEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserSettingEntity.java deleted file mode 100644 index 93780c75a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/UserSettingEntity.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.hswebframework.web.entity.authorization; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.authorization.setting.UserSettingPermission; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.Date; - -/** - * @author zhouhao - * @since 3.0 - */ -@Getter -@Setter -@NoArgsConstructor -public class UserSettingEntity extends SimpleGenericEntity { - @NotBlank(groups = CreateGroup.class) - private String userId; - - @NotBlank(groups = CreateGroup.class) - private String key; - - @NotBlank(groups = CreateGroup.class) - private String settingId; - - @NotBlank(groups = CreateGroup.class) - private String setting; - - private String describe; - - private String name; - - private Date createTime; - - private Date updateTime; - - private UserSettingPermission permission; - - public boolean hasPermission(UserSettingPermission... permissions) { - if (permission == null) { - return true; - } - if (permission == UserSettingPermission.NONE) { - return false; - } - - return permission.in(permissions); - - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/BindRoleUserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/BindRoleUserEntity.java deleted file mode 100644 index 2ede71a43..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/BindRoleUserEntity.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.entity.authorization.bind; - -import org.hswebframework.web.entity.authorization.UserEntity; - -import java.util.List; - -/** - * @author zhouhao - */ -public interface BindRoleUserEntity extends UserEntity { - List getRoles(); - - void setRoles(List roles); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/SimpleBindRoleUserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/SimpleBindRoleUserEntity.java deleted file mode 100644 index 7cc27c908..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/entity/authorization/bind/SimpleBindRoleUserEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.hswebframework.web.entity.authorization.bind; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.entity.authorization.SimpleUserEntity; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -public class SimpleBindRoleUserEntity extends SimpleUserEntity implements BindRoleUserEntity { - - private List roles; - - @Override - public SimpleBindRoleUserEntity clone() { - SimpleBindRoleUserEntity target = ((SimpleBindRoleUserEntity) super.clone()); - if (roles != null) { - target.setRoles(new ArrayList<>(getRoles())); - } - return target; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java deleted file mode 100644 index 378aab02d..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingMenuService.java +++ /dev/null @@ -1,42 +0,0 @@ -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; - -/** - * 权限菜单设置 - * - * @author zhouhao - * @see AuthorizationSettingService - */ -public interface AuthorizationSettingMenuService extends - CrudService - , TreeService { - - /** - * 根据设置id删除菜单配置 - * - * @param settingId 设置id {@link org.hswebframework.web.entity.authorization.AuthorizationSettingEntity#id} - * @return 删除的数量 - */ - int deleteBySettingId(String settingId); - - /** - * 获取设置id对应的所有权限菜单配置 - * - * @param settingId 设置id {@link org.hswebframework.web.entity.authorization.AuthorizationSettingEntity#id} - * @return 永远不为nul .权限菜单设置,如果没有则返回空集合 - */ - List selectBySettingId(String settingId); - - /** - * 获取多个设置id对应的所有权限菜单配置 - * - * @param settingId 设置id {@link org.hswebframework.web.entity.authorization.AuthorizationSettingEntity#id} - * @return 永远不为nul .权限菜单设置,如果没有则返回空集合 - */ - List selectBySettingId(List settingId); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java deleted file mode 100644 index ed768ddb8..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingService.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2019 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.authorization.Permission; -import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * 权限设置 服务类,提供通用的权限设置. 通过此服务,可实现对用户权限的多维度,自定义,可拓展的权限设置.
- * 例如: 可对用户自身设置权限信息,可对角色设置权限信息,可对机构,部门设置权限信息。各个维度的权限使用{@link AuthorizationSettingTypeSupplier}进行绑定. - * - * @author zhouhao - * @see AuthorizationSettingTypeSupplier - * @see org.hswebframework.web.authorization.AuthenticationInitializeService - * @since 3.0 - */ -public interface AuthorizationSettingService extends CrudService { - /** - * 根据类型和被设置者获取配置 - * - * @param type 设置类型 {@link AuthorizationSettingEntity#getType()} - * @param settingFor {@link AuthorizationSettingEntity#getSettingFor()} - * @return 设置内容, 不存在时返回 null - */ - AuthorizationSettingEntity select(String type, String settingFor); - - /** - * 根据权限ID获取所有维度的权限设置,{@link AuthorizationSettingEntity#getDetails()}中只包含对应权限的信息,不会包含全部信息 - * - * @param permissionId 权限ID - * @return 配置了权限的全部权限设置信息 - * @since 3.0.9 - */ - List selectByPermissionId(String permissionId); - - /** - * 合并保存权限信息,如果权限信息不存在则新增,如果已存在,则合并,而不是覆盖 - * - * @param settings 权限信息集合 - * @since 3.0.9 - */ - void mergeSetting(List settings); - - /** - * 删除权限设置的单个权限 - * - * @param settingId 权限设置ID - * @param permissionId 权限ID - * @since 3.0.9 - */ - void deleteDetail(String settingId, String permissionId); - - /** - * 根据类型和被设置者初始化对应的权限信息 - * - * @param type 设置类型 {@link AuthorizationSettingEntity#getType()} - * @param settingFor {@link AuthorizationSettingEntity#getSettingFor()} - * @return 权限信息, 如果没有设置则返回new java.util.ArrayList - * @see Permission - * @since 3.0.3 - */ - List initPermission(String type, String settingFor); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java deleted file mode 100644 index dd4ac3c82..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/AuthorizationSettingTypeSupplier.java +++ /dev/null @@ -1,71 +0,0 @@ -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 get(String userId); - - class SettingInfo { - - /** - * 设置类型 如: user,role,position,person等等 - * - * @see org.hswebframework.web.entity.authorization.AuthorizationSettingEntity#type - */ - private String type; - - /** - * type对应的主键信息,如 user.id - * - * @see org.hswebframework.web.entity.authorization.AuthorizationSettingEntity#settingFor - */ - 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; - } - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/DataAccessFactory.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/DataAccessFactory.java deleted file mode 100644 index a71333161..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/DataAccessFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.builder.DataAccessConfigBuilderFactory; -import org.hswebframework.web.entity.authorization.DataAccessEntity; - -/** - * 数据权限配置工厂,用户将动态数据权限配置转为权限框架需要的配置,便于实现自定义数据权限 - * - * @author zhouhao - * @since 3.0 - * @see DataAccessConfig - * @see DataAccessConfigBuilderFactory - */ -public interface DataAccessFactory { - DataAccessConfig create(DataAccessEntity entity); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupBindService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupBindService.java deleted file mode 100644 index ed733ef75..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupBindService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2019 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.MenuGroupBindEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -/** - * 菜单分组关联 服务类 - * - * @author hsweb-generator-online - */ -public interface MenuGroupBindService extends - CrudService - , TreeService { - - int deleteByGroupId(String groupId); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupService.java deleted file mode 100644 index 4f07eb882..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuGroupService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019 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.MenuEntity; -import org.hswebframework.web.entity.authorization.MenuGroupEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 菜单分组 服务类 - * - * @author hsweb-generator-online - */ -public interface MenuGroupService extends - CrudService - , TreeService { - - List getMenuByGroupId(List groupId); - - void enable(String id); - - void disable(String id); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuService.java deleted file mode 100644 index f8639ad8b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/MenuService.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 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.MenuEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 菜单服务类 - * - * @author zhouhao - */ -public interface MenuService - extends CrudService - , TreeService { - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordEncoder.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordEncoder.java deleted file mode 100644 index 002af2a7c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordEncoder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 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; - -/** - * 密码编码器,用于将明文密码编码成密文 - * - * @author zhouhao - * @since 3.0 - */ -public interface PasswordEncoder { - - /** - * 编码,相同的参数,编码的结果永远相同. - * - * @param password 明文密码,不能为null - * @param salt 加密盐 - * @return 加密结果 - */ - String encode(String password, String salt); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordStrengthValidator.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordStrengthValidator.java deleted file mode 100644 index 68f3ad429..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PasswordStrengthValidator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.service.Validator; - -/** - * 密码强度验证器,在保存用户信息,需要修改密码的时候,会调用此接口来验证密码强度. - * - * @author zhouhao - * @since 3.0 - */ -public interface PasswordStrengthValidator extends Validator { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PermissionService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PermissionService.java deleted file mode 100644 index be8ffab6b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/PermissionService.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 权限管理服务,就一个简单的crud - * - * @author zhouhao - * @since 3.0 - */ -public interface PermissionService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/RoleService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/RoleService.java deleted file mode 100644 index 3a8e8379f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/RoleService.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 角色服务,就是一个简单的crud - * - * @author zhouhao - * @since 3.0 - */ -public interface RoleService extends CrudService { - /** - * 启用角色 - * - * @param roleId 角色ID - * @see RoleEntity#setStatus(Byte) - * @see org.hswebframework.web.commons.entity.DataStatus#STATUS_ENABLED - */ - void enable(String roleId); - - /** - * 禁用角色 - * - * @param roleId 角色ID - * @see RoleEntity#setStatus(Byte) - * @see org.hswebframework.web.commons.entity.DataStatus#STATUS_DISABLED - */ - void disable(String roleId); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java deleted file mode 100644 index db5bc849b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserMenuManagerService.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.entity.authorization.UserMenuEntity; - -import java.util.Collection; -import java.util.List; -import java.util.function.BiConsumer; - -/** - * 用户菜单管理服务,用户获取用户分配的菜单信息 - * - * @author zhouhao - * @see AuthorizationSettingService - * @since 3.0 - */ -public interface UserMenuManagerService { - /** - * 获取用户菜单,返回平铺的list结果,{@link UserMenuEntity#getChildren()} 永远返回null - * - * @param userId 用户ID,不能为空 - * @return 永远不为null,用户不存在或者没有任何菜单时,返回空集合 - */ - List getUserMenuAsList(String userId); - - /** - * 获取用户菜单,返回树形结构的根节点,通过{@link UserMenuEntity#getChildren()} 获取子节点 - * - * @param userId 用户ID,不能为空 - * @return 永远不为null,用户不存在或者没有任何菜单时,返回空集合 - * @see org.hswebframework.web.commons.entity.TreeSupportEntity#list2tree(Collection, BiConsumer) - * @see UserMenuEntity#getChildren() - */ - List getUserMenuAsTree(String userId); - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java deleted file mode 100644 index 0671c147f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.entity.authorization.bind.BindRoleUserEntity; -import org.hswebframework.web.service.CreateEntityService; -import org.hswebframework.web.service.InsertService; -import org.hswebframework.web.service.QueryByEntityService; -import org.hswebframework.web.service.QueryService; -import org.hswebframework.web.validate.ValidationException; - -import java.util.List; - -/** - * 用户服务,提供对用户信息对常用操作 - * - * @author zhouhao - * @since 3.0 - */ -public interface UserService extends - CreateEntityService, - QueryByEntityService, - QueryService, - InsertService { - - /** - * 新增用户 - * - * @param data 要添加的数据 - * @return 用户id - * @see org.hswebframework.web.service.authorization.events.UserCreatedEvent - * @see BindRoleUserEntity - */ - @Override - String insert(UserEntity data); - - /** - * 启用用户 - * - * @param userId 用户Id - * @return 是否启用成功 - * @see UserEntity#setStatus(Byte) - * @see org.hswebframework.web.commons.entity.DataStatus#STATUS_ENABLED - */ - boolean enable(String userId); - - /** - * 禁用用户 - * - * @param userId 用户Id - * @return 是否启用成功 - * @see UserEntity#setStatus(Byte) - * @see org.hswebframework.web.commons.entity.DataStatus#STATUS_DISABLED - */ - boolean disable(String userId); - - /** - * 修改用户信息,如果传入对实体实现了{@link BindRoleUserEntity},将更新用户的权限信息,更新逻辑:
- * 删除用户的权限信息,将新的权限信息重新insert,⚠️注意: 如果{@link BindRoleUserEntity#getRoles()}等于null,将不更新角色信息.
- * 用户信息更新后,将发布事件:{@link org.hswebframework.web.service.authorization.events.UserModifiedEvent},在其他服务可通过监听此事件来 - * 来实现特定的操作,如清空用户权限缓存等.
- * - * @param userId 用户ID - * @param userBean 用户信息实体类 - * @see org.hswebframework.web.service.authorization.events.UserModifiedEvent - * @see org.springframework.context.ApplicationListener - * @see org.springframework.context.event.EventListener - * @see BindRoleUserEntity - */ - void update(String userId, UserEntity userBean); - - /** - * 根据用户名查询用户信息 - * - * @param username 用户名,区分大小写,不能为空 - * @return 用户信息, 如果不存在则返回 null - */ - UserEntity selectByUsername(String username); - - /** - * 根据用户名和密码查询用户信息,在验证用户名密码是否正确是可以使用此方法 - * - * @param plainUsername 用户名,区分大小写,不能为空 - * @param plainPassword 明文密码,区分大小写,不能为空 - * @return 用户信息, 如果用户名或者密码错误, 则返回null - * @see PasswordEncoder - */ - UserEntity selectByUserNameAndPassword(String plainUsername, String plainPassword); - - /** - * 对密码进行加密混淆 - * - * @param password 明文密码,不能为空 - * @param salt 混淆盐,不能为空 - * @return 加密后对密码 - * @see PasswordEncoder - */ - String encodePassword(String password, String salt); - - /** - * 修改用户密码 - * - * @param userId 用户ID,不能为空 - * @param oldPassword 旧的明文密码,不能为空 - * @param newPassword 新的明文密码,不能为空 - * @throws ValidationException 旧密码错误时抛出此异常 - * @see PasswordEncoder - * @see org.hswebframework.web.service.authorization.events.UserModifiedEvent - * @see org.springframework.context.ApplicationListener - * @see java.util.EventListener - */ - void updatePassword(String userId, String oldPassword, String newPassword) throws ValidationException; - - /** - * 获取用户的全部角色信息 - * - * @param userId 用户ID,不能为空 - * @return 永远不为null, 如果用户不存在或者用户没有任何角色, 返回空集合. - */ - List getUserRole(String userId); - - /** - * 根据角色id集合获取对应的全部用户 - * - * @param roleIdList 角色ID集合 - * @return 用户, 不存在时返回空集合,不会返回null - */ - List selectByUserByRole(List roleIdList); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserSettingService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserSettingService.java deleted file mode 100644 index e6b7264ee..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UserSettingService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.entity.authorization.UserSettingEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface UserSettingService extends CrudService { - List selectByUser(String userId, String key); - - UserSettingEntity selectByUser(String userId, String key, String settingId); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UsernameValidator.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UsernameValidator.java deleted file mode 100644 index 5f1af6ef2..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/UsernameValidator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.service.authorization; - -import org.hswebframework.web.service.Validator; - -/** - * 用户名验证器,在保存用户信息的时候,用于验证用户名是否合法 - * - * @author zhouhao - * @since 3.0 - */ -public interface UsernameValidator extends Validator { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/ClearUserAuthorizationCacheEvent.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/ClearUserAuthorizationCacheEvent.java deleted file mode 100644 index 58ad96630..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/ClearUserAuthorizationCacheEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.service.authorization.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author zhouhao - * @see org.springframework.context.event.EventListener - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class ClearUserAuthorizationCacheEvent { - private String userId; - - private boolean all; -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/TotpTwoFactorCreatedEvent.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/TotpTwoFactorCreatedEvent.java deleted file mode 100644 index 271a78e3a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/TotpTwoFactorCreatedEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.service.authorization.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.entity.authorization.UserEntity; - -/** - * @author zhouhao - * @since 3.0.4 - */ -@Getter -@AllArgsConstructor -public class TotpTwoFactorCreatedEvent { - private UserEntity userEntity; - - private String totpUrl; -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserCreatedEvent.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserCreatedEvent.java deleted file mode 100644 index 238d4bf3f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserCreatedEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.service.authorization.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.entity.authorization.UserEntity; - -/** - * @author zhouhao - * @since 3.0.4 - */ -@Getter -@AllArgsConstructor -public class UserCreatedEvent { - UserEntity userEntity; -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserModifiedEvent.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserModifiedEvent.java deleted file mode 100644 index 12f9a38e9..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/service/authorization/events/UserModifiedEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.service.authorization.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.web.entity.authorization.UserEntity; - -/** - * 用户密码发生修改时事件 - * - * @author zhouhao - * @see org.springframework.context.event.EventListener - * @see org.springframework.context.ApplicationEventPublisher - * @since 3.0 - */ -@AllArgsConstructor -@Getter -public class UserModifiedEvent { - private UserEntity userEntity; - - private boolean passwordModified; - - private boolean roleModified; -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/pom.xml deleted file mode 100644 index e8138287e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - hsweb-system-authorization - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-authorization-local - - - - - src/main/resources - true - - - src/main/resources/org - false - - - - - 业务模块-权限管理本地实现 - - - org.hswebframework - hsweb-expands-security - ${hsweb.expands.version} - - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDao.java deleted file mode 100644 index b1ae42d0f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.AuthorizationSettingEntity; - -/** -* 权限设置 DAO接口 -* @author hsweb-generator-online - */ -public interface AuthorizationSettingDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java deleted file mode 100644 index 5f33fce5f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingDetailDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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 { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java deleted file mode 100644 index 0d3378eb5..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/AuthorizationSettingMenuDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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 { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuDao.java deleted file mode 100644 index 3a8513d46..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuDao.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2019 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.MenuEntity; - -/** - * - * @author zhouhao - */ -public interface MenuDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupBindDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupBindDao.java deleted file mode 100644 index 09128c5a4..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupBindDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.MenuGroupBindEntity; - -/** -* 菜单分组关联 DAO接口 -* @author hsweb-generator-online - */ -public interface MenuGroupBindDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupDao.java deleted file mode 100644 index e63f6515c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/MenuGroupDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.MenuGroupEntity; - -/** -* 菜单分组 DAO接口 -* @author hsweb-generator-online - */ -public interface MenuGroupDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/PermissionDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/PermissionDao.java deleted file mode 100644 index d3d79ccb4..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/PermissionDao.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.dao.authorization; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.authorization.PermissionEntity; - -/** - * @author zhouhao - */ -public interface PermissionDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/RoleDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/RoleDao.java deleted file mode 100644 index 14f10be9a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/RoleDao.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.dao.authorization; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.authorization.RoleEntity; - -/** - * @author zhouhao - */ -public interface RoleDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserDao.java deleted file mode 100644 index 01b9addda..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserDao.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.dao.authorization; - -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.dao.CrudDao; - -/** - * @author zhouhao - */ -public interface UserDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserRoleDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserRoleDao.java deleted file mode 100644 index 66db83f7e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserRoleDao.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.dao.authorization; - -import org.hswebframework.web.dao.Dao; -import org.hswebframework.web.entity.authorization.UserRoleEntity; - -import java.util.List; - -/** - * @author zhouhao - */ -public interface UserRoleDao extends Dao { - int deleteByUserId(String userId); - - int deleteByRoleId(String roleId); - - void insert(UserRoleEntity userRoleBean); - - List selectByUserId(String userId); - - List selectByRoleId(String roleId); - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserSettingDao.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserSettingDao.java deleted file mode 100644 index 36e04edbd..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/dao/authorization/UserSettingDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.authorization; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.authorization.UserSettingEntity; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface UserSettingDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java deleted file mode 100644 index 24c91f78f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/CacheConstants.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 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.hswebframework.web.authorization.AuthenticationManager; - -/** - * 缓存所需常量 - * - * @author zhouhao - */ -public interface CacheConstants { - String MENU_CACHE_NAME = "hsweb-menu-"; - - String USER_MENU_CACHE_NAME = "hsweb-user-menu-"; - - String USER_CACHE_NAME = "user-"; - - String USER_AUTH_CACHE_NAME = AuthenticationManager.USER_AUTH_CACHE_NAME; - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/DefaultDataAccessFactory.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/DefaultDataAccessFactory.java deleted file mode 100644 index 016786580..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/DefaultDataAccessFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.builder.DataAccessConfigBuilderFactory; -import org.hswebframework.web.entity.authorization.DataAccessEntity; -import org.hswebframework.web.service.authorization.DataAccessFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * @author zhouhao - */ -@Component -public class DefaultDataAccessFactory implements DataAccessFactory { - private DataAccessConfigBuilderFactory dataAccessConfigBuilderFactory; - - @Autowired - public void setDataAccessConfigBuilderFactory(DataAccessConfigBuilderFactory dataAccessConfigBuilderFactory) { - this.dataAccessConfigBuilderFactory = dataAccessConfigBuilderFactory; - } - - @Override - public DataAccessConfig create(DataAccessEntity entity) { - return dataAccessConfigBuilderFactory.create().fromJson(JSON.toJSONString(entity)).build(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/InServiceUserSettingManager.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/InServiceUserSettingManager.java deleted file mode 100644 index 56ae3d2c4..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/InServiceUserSettingManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import org.hswebframework.web.authorization.setting.SettingValueHolder; -import org.hswebframework.web.authorization.setting.StringSourceSettingHolder; -import org.hswebframework.web.authorization.setting.UserSettingManager; -import org.hswebframework.web.authorization.setting.UserSettingPermission; -import org.hswebframework.web.entity.authorization.UserSettingEntity; -import org.hswebframework.web.service.authorization.UserSettingService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author zhouhao - * @since 3.0.4 - */ -@Service -public class InServiceUserSettingManager implements UserSettingManager { - - @Autowired - private UserSettingService userSettingService; - - @Override - public SettingValueHolder getSetting(String userId, String key) { - UserSettingEntity entity = userSettingService.selectByUser(userId, "user-setting", key); - if (entity == null) { - return SettingValueHolder.NULL; - } - return StringSourceSettingHolder.of(entity.getSetting(), entity.getPermission()); - } - - @Override - public void saveSetting(String userId, String key, String value, UserSettingPermission permission) { - UserSettingEntity entity = new UserSettingEntity(); - entity.setUserId(userId); - entity.setKey("user-setting"); - entity.setSettingId(key); - entity.setSetting(value); - entity.setPermission(permission); - userSettingService.saveOrUpdate(entity); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java deleted file mode 100644 index a9f0f2b6a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthenticationManager.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationInitializeService; -import org.hswebframework.web.authorization.AuthenticationManager; -import org.hswebframework.web.authorization.AuthenticationRequest; -import org.hswebframework.web.authorization.simple.PlainTextUsernamePasswordAuthenticationRequest; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.validate.ValidationException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.Cache; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; - -import java.util.function.Supplier; - -/** - * @author zhouhao - */ -public class SimpleAuthenticationManager implements AuthenticationManager { - - private AuthenticationInitializeService authenticationInitializeService; - - @Setter - @Getter - private AuthenticationManager parent; - - @Autowired - private UserService userService; - - @Autowired(required = false) - private CacheManager cacheManager; - - public SimpleAuthenticationManager() { - } - - public SimpleAuthenticationManager(AuthenticationInitializeService authenticationInitializeService) { - this.authenticationInitializeService = authenticationInitializeService; - } - - public SimpleAuthenticationManager(AuthenticationInitializeService authenticationInitializeService, AuthenticationManager parent) { - this.authenticationInitializeService = authenticationInitializeService; - this.parent = parent; - } - - @Autowired - public void setAuthenticationInitializeService(AuthenticationInitializeService authenticationInitializeService) { - this.authenticationInitializeService = authenticationInitializeService; - } - - @Override - public Authentication authenticate(AuthenticationRequest request) { - if (null != parent) { - try { - Authentication authentication = parent.authenticate(request); - if (null != authentication) { - return authentication; - } - } catch (Exception ignore) { - // ignore errors - } - } - if (request instanceof PlainTextUsernamePasswordAuthenticationRequest) { - String username = ((PlainTextUsernamePasswordAuthenticationRequest) request).getUsername(); - String password = ((PlainTextUsernamePasswordAuthenticationRequest) request).getPassword(); - UserEntity userEntity = userService.selectByUserNameAndPassword(username, password); - if (userEntity == null) { - throw new ValidationException("用户名或密码错误"); - } - if (!DataStatus.STATUS_ENABLED.equals(userEntity.getStatus())) { - throw new ValidationException("用户已被禁用", "username"); - } - return getByUserId(userEntity.getId()); - } - return null; - } - - @Override -// @Cacheable(value = USER_AUTH_CACHE_NAME, key = "#userId") - public Authentication getByUserId(String userId) { - Supplier supplier = () -> { - Authentication authentication = null; - if (parent != null) { - authentication = parent.getByUserId(userId); - } - if (authentication == null) { - authentication = authenticationInitializeService.initUserAuthorization(userId); - } - return authentication; - }; - - if (null != cacheManager) { - Cache cache = cacheManager.getCache(USER_AUTH_CACHE_NAME); - Cache.ValueWrapper wrapper = cache.get(userId); - if (wrapper == null) { - Authentication authentication = supplier.get(); - cache.put(userId, authentication); - return authentication; - } else { - return (Authentication) wrapper.get(); - } - } - return supplier.get(); - } - - @Override - @CachePut(value = USER_AUTH_CACHE_NAME, key = "#authentication.user.id") - public Authentication sync(Authentication authentication) { - if (parent != null) { - parent.sync(authentication); - } - return authentication; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java deleted file mode 100644 index 50a663e21..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingMenuService.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import org.hswebframework.web.service.authorization.AuthorizationSettingMenuService; -import org.hswebframework.web.dao.authorization.AuthorizationSettingMenuDao; -import org.hswebframework.web.entity.authorization.AuthorizationSettingMenuEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * - * @author zhouhao - */ -@Service("authorizationSettingMenuService") -public class SimpleAuthorizationSettingMenuService extends AbstractTreeSortService - implements AuthorizationSettingMenuService { - - private AuthorizationSettingMenuDao authorizationSettingMenuDao; - - @Override - public int deleteBySettingId(String settingId) { - Objects.requireNonNull(settingId); - return createDelete().where(AuthorizationSettingMenuEntity.settingId, settingId).exec(); - } - - @Override - public List selectBySettingId(String settingId) { - Objects.requireNonNull(settingId); - return createQuery().where(AuthorizationSettingMenuEntity.settingId, settingId).listNoPaging(); - } - - @Override - public List selectBySettingId(List settingId) { - if(CollectionUtils.isEmpty(settingId)){ - return new ArrayList<>(); - } - return createQuery().where().in(AuthorizationSettingMenuEntity.settingId, settingId).listNoPaging(); - } - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public AuthorizationSettingMenuDao getDao() { - return authorizationSettingMenuDao; - } - - @Autowired - public void setAuthorizationSettingMenuDao(AuthorizationSettingMenuDao authorizationSettingMenuDao) { - this.authorizationSettingMenuDao = authorizationSettingMenuDao; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java deleted file mode 100644 index d4e6af04d..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorizationSettingService.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright 2019 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 lombok.Getter; -import lombok.Setter; -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.events.AuthorizationInitializeEvent; -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.bean.FastBeanCopier; -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.DefaultDSLUpdateService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.authorization.*; -import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier.SettingInfo; -import org.hswebframework.web.service.authorization.events.ClearUserAuthorizationCacheEvent; -import org.hswebframework.web.validator.group.CreateGroup; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.event.TransactionalEventListener; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -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 java.util.Optional.*; -import static org.apache.commons.collections.CollectionUtils.isEmpty; -import static org.apache.commons.collections.CollectionUtils.isNotEmpty; -import static org.hswebframework.web.commons.entity.DataStatus.STATUS_ENABLED; -import static org.hswebframework.web.entity.authorization.AuthorizationSettingDetailEntity.*; -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; -import static org.hswebframework.web.service.authorization.simple.CacheConstants.USER_MENU_CACHE_NAME; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("authorizationSettingService") -public class SimpleAuthorizationSettingService extends GenericEntityService - implements AuthorizationSettingService, AuthenticationInitializeService, UserMenuManagerService { - - private AuthorizationSettingDao authorizationSettingDao; - - private AuthorizationSettingDetailDao authorizationSettingDetailDao; - - private AuthorizationSettingMenuService authorizationSettingMenuService; - - private MenuService menuService; - - private UserService userService; - - private PermissionService permissionService; - - private List authorizationSettingTypeSuppliers; - - private DataAccessFactory dataAccessFactory; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public AuthorizationSettingDao getDao() { - return authorizationSettingDao; - } - - @Override - public AuthorizationSettingEntity select(String type, String settingFor) { - tryValidateProperty(type != null, AuthorizationSettingEntity.type, "{can not be null}"); - tryValidateProperty(settingFor != null, AuthorizationSettingEntity.settingFor, "{can not be null}"); - return createQuery().where(AuthorizationSettingEntity.type, type) - .and(AuthorizationSettingEntity.settingFor, settingFor) - .single(); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public String saveOrUpdate(AuthorizationSettingEntity entity) { - AuthorizationSettingEntity old = select(entity.getType(), entity.getSettingFor()); - if (old != null) { - updateByPk(old.getId(), entity); - return old.getId(); - } - return insert(entity); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public String insert(AuthorizationSettingEntity entity) { - tryValidateProperty(select(entity.getType(), entity.getSettingFor()) == null, AuthorizationSettingEntity.settingFor, "存在相同的配置!"); - entity.setStatus(STATUS_ENABLED); - String id = super.insert(entity); - if (entity.getMenus() != null) { - TreeSupportEntity.forEach(entity.getMenus(), menu -> { - menu.setStatus(STATUS_ENABLED); - menu.setSettingId(id); - }); - authorizationSettingMenuService.insertBatch(entity.getMenus()); - } - if (entity.getDetails() != null) { - for (AuthorizationSettingDetailEntity detail : entity.getDetails()) { - detail.setId(getIDGenerator().generate()); - detail.setSettingId(id); - detail.setStatus(STATUS_ENABLED); - tryValidate(detail, CreateGroup.class); - authorizationSettingDetailDao.insert(detail); - } - } - return id; - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, 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(STATUS_ENABLED); - menu.setSettingId(id); - }); - authorizationSettingMenuService.insertBatch(entity.getMenus()); - } - if (entity.getDetails() != null) { - DefaultDSLDeleteService - .createDelete(authorizationSettingDetailDao) - .where(settingId, id) - .exec(); - for (AuthorizationSettingDetailEntity detail : entity.getDetails()) { - detail.setId(getIDGenerator().generate()); - detail.setSettingId(id); - detail.setStatus(STATUS_ENABLED); - tryValidate(detail, CreateGroup.class); - authorizationSettingDetailDao.insert(detail); - } - } - return size; - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public AuthorizationSettingEntity deleteByPk(String id) { - Objects.requireNonNull(id, "id can not be null"); - authorizationSettingMenuService.deleteBySettingId(id); - DefaultDSLDeleteService.createDelete(authorizationSettingDetailDao) - .where(AuthorizationSettingDetailEntity.settingId, id).exec(); - return super.deleteByPk(id); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public void deleteDetail(String settingId, String permissionId) { - - DefaultDSLDeleteService.createDelete(authorizationSettingDetailDao) - .where(AuthorizationSettingDetailEntity.settingId, settingId) - .and(AuthorizationSettingDetailEntity.permissionId, permissionId) - .exec(); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.USER_AUTH_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public void mergeSetting(List settings) { - for (AuthorizationSettingEntity setting : settings) { - AuthorizationSettingEntity old = select(setting.getType(), setting.getSettingFor()); - if (old == null) { - setting.setStatus(STATUS_ENABLED); - insert(setting); - continue; - } - setting.setId(old.getId()); - if (!CollectionUtils.isEmpty(setting.getDetails())) { - for (AuthorizationSettingDetailEntity detail : setting.getDetails()) { - detail.setSettingId(setting.getId()); - //删除权限信息 - if (Byte.valueOf((byte) -100).equals(detail.getStatus())) { - DefaultDSLDeleteService.createDelete(authorizationSettingDetailDao) - .where(detail::getSettingId) - .and(detail::getPermissionId) - .exec(); - continue; - } - int i = DefaultDSLUpdateService - .createUpdate(authorizationSettingDetailDao, detail) - .where(detail::getSettingId) - .and(detail::getPermissionId) - .exec(); - if (i == 0) { - detail.setStatus(STATUS_ENABLED); - detail.setId(IDGenerator.MD5.generate()); - authorizationSettingDetailDao.insert(detail); - } - } - } - if (!CollectionUtils.isEmpty(setting.getMenus())) { - Set menus = old.getMenus().stream() - .map(AuthorizationSettingMenuEntity::getMenuId) - .collect(Collectors.toSet()); - for (AuthorizationSettingMenuEntity menu : setting.getMenus()) { - menu.setSettingId(setting.getId()); - if (menus.contains(menu.getMenuId())) { - continue; - } - menu.setStatus(STATUS_ENABLED); - menus.add(menu.getMenuId()); - authorizationSettingMenuService.saveOrUpdate(menu); - } - } - } - } - - @Transactional(readOnly = true) - public List selectByPermissionId(String permissionId) { - List detailEntities = DefaultDSLQueryService - .createQuery(authorizationSettingDetailDao) - .where(AuthorizationSettingDetailEntity::getPermissionId, permissionId) - .listNoPaging(); - - if (CollectionUtils.isEmpty(detailEntities)) { - return new ArrayList<>(); - } - - List settingIdList = detailEntities - .stream() - .map(AuthorizationSettingDetailEntity::getSettingId) - .collect(Collectors.toList()); - - List allSettings = selectByPk(settingIdList) - .stream() - //复制为新对象,防止加载一些没用的信息 - .map(entity -> FastBeanCopier.copy(entity, entityFactory.newInstance(AuthorizationSettingEntity.class), "details", "menus")) - .collect(Collectors.toList()); - - Map> details = detailEntities.stream() - .collect(Collectors.groupingBy(AuthorizationSettingDetailEntity::getSettingId)); - - for (AuthorizationSettingEntity allSetting : allSettings) { - ofNullable(details.get(allSetting.getId())).ifPresent(allSetting::setDetails); - } - - return allSettings; - } - - private List getUserSetting(String userId) { - Map> settingInfo = - authorizationSettingTypeSuppliers.stream() - .map(supplier -> supplier.get(userId)) - .flatMap(Set::stream) - .collect(Collectors.groupingBy(SettingInfo::getType)); - Stream>> settingInfoStream = settingInfo.entrySet().stream(); - //大于1 使用并行处理 - if (settingInfo.size() > 1) { - settingInfoStream = 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())) - .listNoPaging()) - .flatMap(List::stream) - .collect(Collectors.toList()); - } - - @Override - @Cacheable(cacheNames = USER_MENU_CACHE_NAME, key = "'user-menu-list:'+#userId") - public List getUserMenuAsList(String userId) { - if (null == userId) { - return new java.util.ArrayList<>(); - } - UserEntity userEntity = userService.selectByPk(userId); - if (userEntity == null) { - return new java.util.ArrayList<>(); - } - List entities = getUserSetting(userId); - if (entities.isEmpty()) { - return new java.util.ArrayList<>(); - } - //用户持有的权限设置id集合 - List settingIdList = entities.stream() - .map(AuthorizationSettingEntity::getId) - .collect(Collectors.toList()); - //获取全部设置的菜单 - List menuEntities = authorizationSettingMenuService - .selectBySettingId(settingIdList); - //得到菜单id - List menuIdList = menuEntities.stream() - .map(AuthorizationSettingMenuEntity::getMenuId) - .distinct() - .collect(Collectors.toList()); - if (menuIdList.isEmpty()) { - return new ArrayList<>(); - } - //获取全部菜单,并创建缓存备用 - Map menuCache = menuService - .selectByPk(menuIdList) - .stream() - .collect(Collectors.toMap(MenuEntity::getId, Function.identity())); - - //根据配置,重新构造菜单结构 - List reBuildMenu = new LinkedList<>(); - for (MenuEntity menuEntity : menuCache.values()) { - UserMenuEntity menu = entityFactory.newInstance(UserMenuEntity.class, menuEntity); - menu.setSortIndex(menuEntity.getSortIndex()); - menu.setLevel(menuEntity.getLevel()); - menu.setId(menuEntity.getId()); - menu.setParentId(menuEntity.getParentId()); - menu.setMenuId(menuEntity.getId()); - reBuildMenu.add(menu); - } - -// for (AuthorizationSettingMenuEntity entity : menuEntities) { -// MenuEntity cache = menuCache.get(entity.getMenuId()); -// if (null != cache && DataStatus.STATUS_ENABLED.equals(cache.getStatus())) { -// 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); -// } -// } - Collections.sort(reBuildMenu); - return reBuildMenu; - } - - @Override - @Cacheable(cacheNames = USER_MENU_CACHE_NAME, key = "'menu-tree:'+#userId") - public List getUserMenuAsTree(String userId) { - return TreeSupportEntity.list2tree(getUserMenuAsList(userId), UserMenuEntity::setChildren, - (Predicate) menuEntity -> - // parentId为空或者为-1的菜单则认为是根菜单 - StringUtils.isEmpty(menuEntity.getParentId()) || "-1".equals(menuEntity.getParentId())); - } - - @TransactionalEventListener(condition = "#event.all") - @Caching(evict = { - @CacheEvict(cacheNames = USER_MENU_CACHE_NAME, allEntries = true), - @CacheEvict(cacheNames = USER_AUTH_CACHE_NAME, allEntries = true) - }) - public void clearAllUserCache(ClearUserAuthorizationCacheEvent event) { - logger.debug("clear all user authorization cache"); - } - - @TransactionalEventListener(condition = "!#event.all") - @Caching( - evict = { - @CacheEvict(value = CacheConstants.USER_AUTH_CACHE_NAME, key = "#event.getUserId()"), - @CacheEvict(value = CacheConstants.USER_MENU_CACHE_NAME, key = "'user-menu-list:'+#event.getUserId()"), - @CacheEvict(value = CacheConstants.USER_MENU_CACHE_NAME, key = "'menu-tree:'+#event.getUserId()") - } - ) - public void clearUserCache(ClearUserAuthorizationCacheEvent event) { - logger.debug("clear user:{} authorization cache", event.getUserId()); - } - - - @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(SimpleUser.builder() - .id(userId) - .username(userEntity.getUsername()) - .name(userEntity.getName()) - .type("default") - .build()); - //角色 - authentication.setRoles(userService.getUserRole(userId) - .stream() - .map(role -> new SimpleRole(role.getId(), role.getName())) - .collect(Collectors.toList())); - - List 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 detailList = DefaultDSLQueryService - .createQuery(authorizationSettingDetailDao) - .where(status, STATE_OK) - .and().in(settingId, settingIdList) - .listNoPaging(); - - authentication.setPermissions(initPermission(detailList)); - eventPublisher.publishEvent(new AuthorizationInitializeEvent(authentication)); - return authentication; - } - - @Override - public List initPermission(String type, String settingFor) { - AuthorizationSettingEntity entity = select(type, settingFor); - if (entity == null) { - return new ArrayList<>(); - } - List detailList = DefaultDSLQueryService - .createQuery(authorizationSettingDetailDao) - .where(status, STATE_OK) - .and().is(settingId, entity.getId()) - .listNoPaging(); - if (CollectionUtils.isEmpty(detailList)) { - return new ArrayList<>(); - } - return initPermission(detailList); - } - - @Getter - @Setter - static class ParentPermissionDetail extends ParentPermission { - private String sourcePermission; - - public static Stream of(PermissionEntity entity) { - if (isEmpty(entity.getParents())) { - return Stream.empty(); - } - return entity.getParents() - .stream() - .filter(Objects::nonNull) - .map(parent -> { - ParentPermissionDetail permissionDetail = new ParentPermissionDetail(); - permissionDetail.setActions(parent.getActions()); - permissionDetail.setSourcePermission(entity.getId()); - permissionDetail.setPreActions(parent.getPreActions()); - permissionDetail.setPermission(parent.getPermission()); - return permissionDetail; - }); - } - } - - private List initPermission(List detailList) { - //权限id集合 -// List permissionIds = detailList.stream() -// .map(AuthorizationSettingDetailEntity::getPermissionId) -// .distinct() -// .collect(Collectors.toList()); - //权限信息缓存 - Map permissionEntityCache = permissionService.select() - .stream() - .collect(Collectors.toMap(PermissionEntity::getId, Function.identity())); - - //防止越权 - detailList = detailList.stream().filter(detail -> { - PermissionEntity entity = permissionEntityCache.get(detail.getPermissionId()); - if (entity == null || !STATUS_ENABLED.equals(entity.getStatus())) { - return false; - } - List allActions = entity.getActions().stream().map(ActionEntity::getAction).collect(Collectors.toList()); - - if (isNotEmpty(entity.getActions()) && isNotEmpty(detail.getActions())) { - - detail.setActions(detail.getActions().stream().filter(allActions::contains).collect(Collectors.toSet())); - } - if (isEmpty(entity.getSupportDataAccessTypes())) { - detail.setDataAccesses(new java.util.ArrayList<>()); - } else if (isNotEmpty(detail.getDataAccesses()) && !entity.getSupportDataAccessTypes().contains("*")) { - //重构为权限支持的数据权限控制方式,防止越权设置权限 - detail.setDataAccesses(detail - .getDataAccesses() - .stream() - .filter(access -> - //以设置支持的权限开头就认为拥有该权限 - //比如支持的权限为CUSTOM_SCOPE_ORG_SCOPE - //设置的权限为CUSTOM_SCOPE 则通过检验 - entity.getSupportDataAccessTypes().stream() - .anyMatch(type -> type.startsWith(access.getType()))) - .collect(Collectors.toList())); - } - return true; - }).collect(Collectors.toList()); - - //全部权限设置 - Map> settings = detailList - .stream() - .collect(Collectors.groupingBy(AuthorizationSettingDetailEntity::getPermissionId)); - - List permissions = new ArrayList<>(); - - settings.forEach((permissionId, details) -> { - PermissionEntity entity = permissionEntityCache.get(permissionId); - if (entity == null || !DataStatus.STATUS_ENABLED.equals(entity.getStatus())) { - return; - } - SimplePermission permission = new SimplePermission(); - permission.setName(entity.getName()); - permission.setId(permissionId); - Set actions = new HashSet<>(); - Set dataAccessConfigs = new HashSet<>(); - //排序,根据优先级进行排序 - Collections.sort(details); - for (AuthorizationSettingDetailEntity detail : details) { - //如果指定不合并相同的配置,则清空之前的配置 - if (Boolean.FALSE.equals(detail.getMerge())) { - actions.clear(); - dataAccessConfigs.clear(); - } - // actions - if (isNotEmpty(detail.getActions())) { - actions.addAll(detail.getActions()); - } - // 数据权限控制配置 - if (isNotEmpty(detail.getDataAccesses())) { - dataAccessConfigs.addAll(detail.getDataAccesses() - .stream() - .map(dataAccessFactory::create) - .collect(Collectors.toSet())); - } - } - - permission.setActions(actions); - permission.setDataAccesses(dataAccessConfigs); - permissions.add(permission); - }); - - /*=============================进行关联权限处理============================================*/ - Map permissionCache = permissions.stream() - .collect(Collectors.toMap(Permission::getId, Function.identity())); - - //获取关联的权限信息 - Map> parentsPermissions = permissionEntityCache - .values() - .stream() - .flatMap(ParentPermissionDetail::of) - .collect(Collectors.groupingBy(ParentPermission::getPermission)); - - //判断是否满足关联权限的条件 - Predicate preActionPredicate = parent -> { - if (isEmpty(parent.getActions())) { - return false; - } - if (isEmpty(parent.getPreActions())) { - return true; - } - Permission source = permissionCache.get(parent.getSourcePermission()); - return source != null && source.getActions().containsAll(parent.getPreActions()); - }; - - for (Permission permission : permissions) { - //有其他权限关联了此权限 - List parents = parentsPermissions.get(permission.getId()); - if (parents != null) { - //添加action - permission.getActions() - .addAll(parents.stream() - .filter(preActionPredicate) - .map(ParentPermission::getActions) - .flatMap(Collection::stream) - .collect(Collectors.toSet())); - //删除被合并的权限配置 - parentsPermissions.remove(permission.getId()); - } - } - //没有赋予被关联的权限时,直接关联权限 - parentsPermissions.forEach((per, all) -> { - PermissionEntity entity = permissionEntityCache.get(per); - if (entity == null || !DataStatus.STATUS_ENABLED.equals(entity.getStatus())) { - return; - } - SimplePermission permission = new SimplePermission(); - permission.setId(per); - permission.setName(entity.getName()); - permission.setActions(all.stream() - .filter(preActionPredicate) - .map(ParentPermission::getActions) - .flatMap(Collection::stream) - .collect(Collectors.toSet())); - if (isEmpty(permission.getActions())) { - return; - } - permissions.add(permission); - }); - parentsPermissions.clear(); - permissionCache.clear(); - - return permissions; - } - - - @Autowired - public void setDataAccessFactory(DataAccessFactory dataAccessFactory) { - this.dataAccessFactory = dataAccessFactory; - } - - @Autowired - public void setAuthorizationSettingTypeSuppliers(List 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; - } - - @Autowired - public void setPermissionService(PermissionService permissionService) { - this.permissionService = permissionService; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupBindService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupBindService.java deleted file mode 100644 index 01f37fec9..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupBindService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2019 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.hswebframework.web.dao.authorization.MenuGroupBindDao; -import org.hswebframework.web.entity.authorization.MenuGroupBindEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.hswebframework.web.service.authorization.MenuGroupBindService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("menuGroupBindService") -public class SimpleMenuGroupBindService extends AbstractTreeSortService - implements MenuGroupBindService { - @Autowired - private MenuGroupBindDao menuGroupBindDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public MenuGroupBindDao getDao() { - return menuGroupBindDao; - } - - @Override - public int deleteByGroupId(String groupId) { - tryValidateProperty(groupId != null, MenuGroupBindEntity.groupId, "groups id can not be null"); - return createDelete().where(MenuGroupBindEntity.groupId, groupId).exec(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupService.java deleted file mode 100644 index a547229e8..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuGroupService.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2019 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.hswebframework.web.service.authorization.MenuGroupService; -import org.hswebframework.web.commons.entity.TreeSupportEntity; -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.service.AbstractTreeSortService; -import org.hswebframework.web.service.DefaultDSLUpdateService; -import org.hswebframework.web.service.authorization.MenuGroupBindService; -import org.hswebframework.web.service.authorization.MenuService; -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 org.springframework.util.StringUtils; - -import java.util.LinkedList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("menuGroupService") -@CacheConfig(cacheNames = CacheConstants.MENU_CACHE_NAME) -public class SimpleMenuGroupService - extends AbstractTreeSortService - implements MenuGroupService { - @Autowired - private MenuGroupDao menuGroupDao; - - @Autowired - private MenuService menuService; - - @Autowired - private MenuGroupBindService menuGroupBindService; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public MenuGroupDao getDao() { - return menuGroupDao; - } - - @Override - @Cacheable(key = "'group-id-list:'+(#groupId==null?0:#groupId.hashCode())") - public List getMenuByGroupId(List groupId) { - List bindEntities = menuGroupBindService.selectByPk(groupId); - if (bindEntities == null || bindEntities.isEmpty()) { - return new LinkedList<>(); - } - return menuService.selectByPk(bindEntities.stream() - .map(MenuGroupBindEntity::getMenuId) - .distinct() - .collect(Collectors.toList())); - } - - @Override - @CacheEvict(allEntries = true) - public String insert(MenuGroupEntity entity) { - entity.setStatus((byte) 1); - String id = super.insert(entity); - List bindEntities = entity.getBindInfo(); - if (bindEntities != null && !bindEntities.isEmpty()) { - TreeSupportEntity.forEach(bindEntities, bindEntity -> { - bindEntity.setGroupId(id); - entity.setStatus((byte) 1); - }); - menuGroupBindService.insertBatch(bindEntities); - } - return id; - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(MenuGroupEntity entity) { - int size = super.updateByPk(entity); - List bindEntities = entity.getBindInfo(); - if (bindEntities != null && !bindEntities.isEmpty()) { - TreeSupportEntity.forEach(bindEntities, bindEntity -> { - bindEntity.setGroupId(entity.getId()); - }); - menuGroupBindService.deleteByGroupId(entity.getId()); - menuGroupBindService.insertBatch(bindEntities); - } - return size; - } - - @CacheEvict(allEntries = true) - @Override - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(String id, MenuGroupEntity entity) { - return super.updateByPk(id, entity); - } - - @Override - @CacheEvict(allEntries = true) - public MenuGroupEntity deleteByPk(String id) { - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public void enable(String id) { - tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}"); - createUpdate() - .set(MenuGroupEntity.status, 1) - .where(MenuGroupEntity.id, id) - .exec(); - } - - @Override - @CacheEvict(allEntries = true) - public void disable(String id) { - tryValidateProperty(StringUtils.hasLength(id), MenuGroupEntity.id, "{id_is_null}"); - DefaultDSLUpdateService - .createUpdate(getDao()) - .set(MenuGroupEntity.status, 0) - .where(MenuGroupEntity.id, id) - .exec(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuService.java deleted file mode 100644 index 04b56ec44..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleMenuService.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2019 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.hswebframework.web.dao.authorization.MenuDao; -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.MenuService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.List; - -/** - * @author zhouhao - */ -@Service("menuService") -public class SimpleMenuService - extends AbstractTreeSortService - implements MenuService { - - private MenuDao menuDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Autowired - public void setMenuDao(MenuDao menuDao) { - this.menuDao = menuDao; - } - - @Override - public MenuDao getDao() { - return menuDao; - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public int updateByPk(MenuEntity entity) { - return super.updateByPk(entity); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public String saveOrUpdate(MenuEntity entity) { - return super.saveOrUpdate(entity); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public int updateBatch(Collection data) { - return super.updateBatch(data); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public int updateByPk(String id, MenuEntity entity) { - return super.updateByPk(id, entity); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public String insert(MenuEntity entity) { - if (entity.getStatus() == null) { - entity.setStatus((byte) 1); - } - return super.insert(entity); - } - - @Override - @Cacheable(cacheNames = CacheConstants.MENU_CACHE_NAME, key = "'ids:'+(#id==null?'0':#id.hashCode())") - public List selectByPk(List id) { - return super.selectByPk(id); - } - - @Override - @CacheEvict(cacheNames = {CacheConstants.MENU_CACHE_NAME, CacheConstants.USER_MENU_CACHE_NAME}, allEntries = true) - public MenuEntity deleteByPk(String id) { - return super.deleteByPk(id); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimplePermissionService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimplePermissionService.java deleted file mode 100644 index 39a22545b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimplePermissionService.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.authorization.PermissionDao; -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.authorization.PermissionService; -import org.hswebframework.web.service.authorization.events.ClearUserAuthorizationCacheEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -import java.util.Optional; - -/** - * 权限管理 - * - * @author zhouhao - */ -@Service("permissionService") -public class SimplePermissionService extends GenericEntityService - implements PermissionService { - @Autowired - private PermissionDao permissionDao; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public PermissionDao getDao() { - return permissionDao; - } - - @Override - public String insert(PermissionEntity entity) { - entity.setStatus(DataStatus.STATUS_ENABLED); - return super.insert(entity); - } - - @Override - public int updateByPk(String id, PermissionEntity entity) { - int len = super.updateByPk(id, entity); - eventPublisher.publishEvent(new ClearUserAuthorizationCacheEvent(null, true)); - return len; - } - - @Override - public PermissionEntity deleteByPk(String id) { - PermissionEntity old = super.deleteByPk(id); - eventPublisher.publishEvent(new ClearUserAuthorizationCacheEvent(null, true)); - return old; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java deleted file mode 100644 index e3f428b1b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleRoleService.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2019 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.hswebframework.web.service.authorization.RoleService; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.authorization.RoleDao; -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLUpdateService; -import org.hswebframework.web.service.GenericEntityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@Service("roleService") -public class SimpleRoleService extends GenericEntityService implements RoleService { - - @Autowired - private RoleDao roleDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public RoleDao getDao() { - return roleDao; - } - - @Override - public String insert(RoleEntity entity) { - entity.setStatus(DataStatus.STATUS_ENABLED); - return super.insert(entity); - } - - @Override - public int updateByPk(String s, RoleEntity entity) { - entity.setStatus(null); - return super.updateByPk(s, entity); - } - - @Override - public void enable(String roleId) { - tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}"); - DefaultDSLUpdateService.createUpdate(getDao()) - .set(RoleEntity.status, DataStatus.STATUS_ENABLED) - .where(RoleEntity.id, roleId) - .exec(); - } - - @Override - public void disable(String roleId) { - tryValidateProperty(StringUtils.hasLength(roleId), RoleEntity.id, "{id_is_null}"); - DefaultDSLUpdateService.createUpdate(getDao()) - .set(RoleEntity.status, DataStatus.STATUS_DISABLED) - .where(RoleEntity.id, roleId) - .exec(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java deleted file mode 100644 index a6d0550b9..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserService.java +++ /dev/null @@ -1,310 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.web.service.authorization.*; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.GenericEntity; -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.id.IDGenerator; -import org.hswebframework.web.service.AbstractService; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.authorization.events.ClearUserAuthorizationCacheEvent; -import org.hswebframework.web.service.authorization.events.UserCreatedEvent; -import org.hswebframework.web.service.authorization.events.UserModifiedEvent; -import org.hswebframework.web.service.authorization.simple.terms.UserInRoleSqlTerm; -import org.hswebframework.web.validate.ValidationException; -import org.hswebframework.utils.ListUtils; -import org.hswebframework.web.validator.group.CreateGroup; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Caching; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.stream.Collectors; - -import static org.hswebframework.web.service.DefaultDSLUpdateService.*; - -/** - * 默认的用户服务实现 - * - * @author zhouhao - * @since 3.0 - */ -@Transactional(rollbackFor = Throwable.class) -@Service("userService") -public class SimpleUserService extends AbstractService - implements DefaultDSLQueryService, UserService, AuthorizationSettingTypeSupplier { - - @Autowired(required = false) - private PasswordStrengthValidator passwordStrengthValidator; - - @Autowired(required = false) - private UsernameValidator usernameValidator; - - @Autowired(required = false) - private PasswordEncoder passwordEncoder = (password, salt) -> DigestUtils.md5Hex(String.format("hsweb.%s.framework.%s", password, salt)); - - @Autowired - private UserDao userDao; - - @Autowired - private UserRoleDao userRoleDao; - - @Autowired - private RoleDao roleDao; - - @Autowired - private ApplicationEventPublisher publisher; - - @Override - public String encodePassword(String password, String salt) { - return passwordEncoder.encode(password, salt); - } - - @Override - public UserEntity createEntity() { - return entityFactory.newInstance(BindRoleUserEntity.class); - } - - protected IDGenerator getIdGenerator() { - return IDGenerator.MD5; - } - - @Override - @Transactional(readOnly = true) - public UserEntity selectByUsername(String username) { - if (!StringUtils.hasLength(username)) { - return null; - } - return createQuery().where("username", username).single(); - } - - @Override - @Transactional(readOnly = true) - public UserEntity selectByUserNameAndPassword(String plainUsername, String plainPassword) { - Assert.hasLength(plainUsername, "用户名不能为空"); - Assert.hasLength(plainPassword, "密码不能为空"); - - return Optional.ofNullable(selectByUsername(plainUsername)) - .filter(user -> encodePassword(plainPassword, user.getSalt()).equals(user.getPassword())) - .orElse(null); - } - - @Override - @Transactional(readOnly = true) - public UserEntity selectByPk(String id) { - if (!StringUtils.hasLength(id)) { - return null; - } - UserEntity userEntity = createQuery().where(UserEntity.id, id).single(); - if (null != userEntity) { - - List roleId = userRoleDao - .selectByUserId(id) - .stream() - .map(UserRoleEntity::getRoleId) //转换为roleId - .collect(Collectors.toList()); - BindRoleUserEntity roleUserEntity = entityFactory.newInstance(BindRoleUserEntity.class, userEntity); - roleUserEntity.setRoles(roleId); - return roleUserEntity; - } - return null; - } - - @Override - public List selectByPk(List id) { - if (CollectionUtils.isEmpty(id)) { - return new ArrayList<>(); - } - return createQuery().where().in(UserEntity.id, id).listNoPaging(); - } - - @Override - @CacheEvict(value = CacheConstants.USER_CACHE_NAME, key = "#userEntity.id") - public String insert(UserEntity userEntity) { - //用户名合法性验证 - tryValidateProperty(usernameValidator, UserEntity.username, userEntity.getUsername()); - //判断用户是否已经存在 - tryValidateProperty(null == selectByUsername(userEntity.getUsername()), UserEntity.username, "用户名已存在"); - //密码强度验证 - tryValidateProperty(passwordStrengthValidator, UserEntity.password, userEntity.getPassword()); - userEntity.setCreateTime(System.currentTimeMillis()); - userEntity.setId(getIdGenerator().generate()); - userEntity.setSalt(IDGenerator.RANDOM.generate()); - userEntity.setStatus(DataStatus.STATUS_ENABLED); - //验证其他属性 - tryValidate(userEntity, CreateGroup.class); - //密码MD5 - userEntity.setPassword(encodePassword(userEntity.getPassword(), userEntity.getSalt())); - //创建用户 - userDao.insert(userEntity); - if (userEntity instanceof BindRoleUserEntity) { - BindRoleUserEntity bindRoleUserEntity = ((BindRoleUserEntity) userEntity); - //插入权限信息 - if (!ListUtils.isNullOrEmpty(bindRoleUserEntity.getRoles())) { - trySyncUserRole(userEntity.getId(), bindRoleUserEntity.getRoles()); - } - } - publisher.publishEvent(new UserCreatedEvent(userEntity)); - return userEntity.getId(); - } - - protected void trySyncUserRole(final String userId, final List roleIdList) { - new HashSet<>(roleIdList).stream() - .map(roleId -> { - UserRoleEntity roleEntity = entityFactory.newInstance(UserRoleEntity.class); - roleEntity.setRoleId(roleId); - roleEntity.setUserId(userId); - return roleEntity; - }) - .forEach(userRoleDao::insert); - } - - @Override - @Caching(evict = { - @CacheEvict(value = CacheConstants.USER_CACHE_NAME, key = "#userId") - }) - public void update(String userId, UserEntity userEntity) { - userEntity.setId(userId); - UserEntity oldUser = selectByPk(userId); - assertNotNull(oldUser); - boolean roleModified = false; - boolean passwordModified = false; - - //不修改的字段 - List excludeProperties = new ArrayList<>(Arrays.asList( - UserEntity.username - , UserEntity.password - , UserEntity.salt - , UserEntity.status)); - //修改密码 - if (StringUtils.hasLength(userEntity.getPassword())) { - //密码强度验证 - tryValidateProperty(passwordStrengthValidator, UserEntity.password, userEntity.getPassword()); - //密码MD5 - userEntity.setPassword(encodePassword(userEntity.getPassword(), oldUser.getSalt())); - excludeProperties.remove(UserEntity.password); - passwordModified = true; - } - //修改数据 - createUpdate(getDao(), userEntity) - .excludes(excludeProperties.toArray(new String[excludeProperties.size()])) - .where(GenericEntity.id, userEntity.getId()) - .exec(); - if (userEntity instanceof BindRoleUserEntity) { - BindRoleUserEntity bindRoleUserEntity = ((BindRoleUserEntity) userEntity); - if (bindRoleUserEntity.getRoles() != null) { - //删除旧的数据 - userRoleDao.deleteByUserId(bindRoleUserEntity.getId()); - //同步角色信息 - trySyncUserRole(userEntity.getId(), bindRoleUserEntity.getRoles()); - roleModified = true; - } - } - if (excludeProperties.contains(UserEntity.password)) { - publisher.publishEvent(new UserModifiedEvent(userEntity, passwordModified, roleModified)); - } - publisher.publishEvent(new ClearUserAuthorizationCacheEvent(userId, false)); - - } - - @Override - public boolean enable(String userId) { - if (!StringUtils.hasLength(userId)) { - return false; - } - return createUpdate(getDao()) - .set(UserEntity.status, DataStatus.STATUS_ENABLED) - .where(GenericEntity.id, userId) - .exec() > 0; - } - - @Override - public boolean disable(String userId) { - if (!StringUtils.hasLength(userId)) { - return false; - } - return createUpdate(getDao()) - .set(UserEntity.status, DataStatus.STATUS_DISABLED) - .where(GenericEntity.id, userId) - .exec() > 0; - } - - @Override - public void updatePassword(String userId, String oldPassword, String newPassword) { - UserEntity userEntity = selectByPk(userId); - assertNotNull(userEntity); - oldPassword = encodePassword(oldPassword, userEntity.getSalt()); - if (!userEntity.getPassword().equals(oldPassword)) { - throw new ValidationException("密码错误", "password"); - } - tryValidateProperty(passwordStrengthValidator, UserEntity.password, newPassword); - - newPassword = encodePassword(newPassword, userEntity.getSalt()); - createUpdate(getDao()) - .set(UserEntity.password, newPassword) - .where(GenericEntity.id, userId) - .exec(); - publisher.publishEvent(new UserModifiedEvent(userEntity, true, false)); - } - - - @Override - public List getUserRole(String userId) { - Assert.hasLength(userId, "参数不能为空"); - List roleEntities = userRoleDao.selectByUserId(userId); - if (roleEntities.isEmpty()) { - return new ArrayList<>(); - } - List roleIdList = roleEntities.stream().map(UserRoleEntity::getRoleId).collect(Collectors.toList()); - return DefaultDSLQueryService - .createQuery(roleDao).where() - .in(GenericEntity.id, roleIdList) - .noPaging() - .list(); - } - - @Override - public UserDao getDao() { - return userDao; - } - - @Override - public Set get(String userId) { - UserEntity userEntity = selectByPk(userId); - if (null == userEntity) { - return new HashSet<>(); - } - List roleEntities = userRoleDao.selectByUserId(userId); - //使用角色配置 - Set 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; - } - - @Override - public List selectByUserByRole(List roleIdList) { - if (CollectionUtils.isEmpty(roleIdList)) { - return new java.util.ArrayList<>(); - } - // org.hswebframework.web.service.authorization.simple.terms.UserInRoleSqlTerm - return createQuery() - .where("id", "user-in-role", roleIdList) - .listNoPaging(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserSettingService.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserSettingService.java deleted file mode 100644 index 81fe56180..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleUserSettingService.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.hswebframework.web.service.authorization.simple; - -import org.hswebframework.web.service.authorization.UserSettingService; -import org.hswebframework.web.dao.authorization.UserSettingDao; -import org.hswebframework.web.entity.authorization.UserSettingEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -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.cache.annotation.Caching; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; -import java.util.Objects; - -/** - * @author zhouhao - * @since 3.0 - */ -@Service -@CacheConfig(cacheNames = "user-setting") -public class SimpleUserSettingService extends EnableCacheGenericEntityService - implements UserSettingService { - - @Autowired - private UserSettingDao userSettingDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public UserSettingDao getDao() { - return userSettingDao; - } - - @Override - protected boolean dataExisted(UserSettingEntity entity) { - UserSettingEntity old = createQuery() - .where(entity::getUserId) - .and(entity::getKey) - .and(entity::getSettingId) - .single(); - if (old != null) { - entity.setId(old.getId()); - return true; - } - return false; - } - - @Override - @Cacheable(key = "'user:'+#userId+'.'+#key") - public List selectByUser(String userId, String key) { - Objects.requireNonNull(userId); - Objects.requireNonNull(key); - - return createQuery().where("userId", userId).and("key", key).listNoPaging(); - } - - @Override - @Cacheable(key = "'user:'+#userId+'.'+#key+'.'+#settingId") - public UserSettingEntity selectByUser(String userId, String key, String settingId) { - Objects.requireNonNull(userId); - Objects.requireNonNull(key); - Objects.requireNonNull(settingId); - return createQuery().where("userId", userId).and("key", key).and("settingId", settingId).single(); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key+'.'+#entity.settingId"), - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key") - } - ) - public String insert(UserSettingEntity entity) { - entity.setCreateTime(new Date()); - entity.setUpdateTime(new Date()); - return super.insert(entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key+'.'+#entity.settingId"), - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key") - } - ) - public String saveOrUpdate(UserSettingEntity entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key+'.'+#entity.settingId"), - @CacheEvict(key = "'user:'+#entity.userId+'.'+#entity.key") - } - ) - public int updateByPk(String id, UserSettingEntity entity) { - entity.setUpdateTime(new Date()); - return super.updateByPk(id, entity); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/CustomUserSqlTermAutoConfiguration.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/CustomUserSqlTermAutoConfiguration.java deleted file mode 100644 index b0209841e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/CustomUserSqlTermAutoConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.terms; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Configuration -public class CustomUserSqlTermAutoConfiguration { - - @Bean - public UserInRoleSqlTerm userInRoleSqlTerm() { - return new UserInRoleSqlTerm(false); - } - - @Bean - public UserInRoleSqlTerm userNotInRoleSqlTerm() { - return new UserInRoleSqlTerm(true); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/UserInRoleSqlTerm.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/UserInRoleSqlTerm.java deleted file mode 100644 index 5394c7dda..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/terms/UserInRoleSqlTerm.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public class UserInRoleSqlTerm extends AbstractSqlTermCustomizer { - - private boolean not; - - public UserInRoleSqlTerm(boolean not) { - super("user" + (not ? "-not-in" : "-in") + "-role"); - this.not = not; - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - SqlAppender appender = new SqlAppender(); - appender.add(not ? "not " : "", "exists(select 1 from s_user_role tmp where tmp.user_id =", - createColumnName(column, tableAlias)); - - List positionIdList = BoostTermTypeMapper.convertList(column, termValue.getOld()); - if (!positionIdList.isEmpty()) { - appender.add(" and tmp.role_id"); - termValue.setValue(appendCondition(positionIdList, wherePrefix, appender)); - } - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/Base32String.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/Base32String.java deleted file mode 100644 index 1580e4cfb..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/Base32String.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.totp; /** - */ -import java.util.HashMap; -import java.util.Locale; - -/** - * Encodes arbitrary byte arrays as case-insensitive base-32 strings. - *

- * The implementation is slightly different than in RFC 4648. During encoding, - * padding is not added, and during decoding the last incomplete chunk is not - * taken into account. The result is that multiple strings decode to the same - * byte array, for example, string of sixteen 7s ("7...7") and seventeen 7s both - * decode to the same byte array. - * TODO(sarvar): Revisit this encoding and whether this ambiguity needs fixing. - * - * @author sweis@google.com (Steve Weis) - * @author Neal Gafter - */ -public class Base32String { - // singleton - - private static final Base32String INSTANCE = - new Base32String("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); // RFC 4648/3548 - - static Base32String getInstance() { - return INSTANCE; - } - - // 32 alpha-numeric characters. - private String ALPHABET; - private char[] DIGITS; - private int MASK; - private int SHIFT; - private HashMap CHAR_MAP; - - static final String SEPARATOR = "-"; - - protected Base32String(String alphabet) { - this.ALPHABET = alphabet; - DIGITS = ALPHABET.toCharArray(); - MASK = DIGITS.length - 1; - SHIFT = Integer.numberOfTrailingZeros(DIGITS.length); - CHAR_MAP = new HashMap<>(); - for (int i = 0; i < DIGITS.length; i++) { - CHAR_MAP.put(DIGITS[i], i); - } - } - - public static byte[] decode(String encoded) throws DecodingException { - return getInstance().decodeInternal(encoded); - } - - protected byte[] decodeInternal(String encoded) throws DecodingException { - // Remove whitespace and separators - encoded = encoded.trim().replaceAll(SEPARATOR, "").replaceAll(" ", ""); - - // Remove padding. Note: the padding is used as hint to determine how many - // bits to decode from the last incomplete chunk (which is commented out - // below, so this may have been wrong to start with). - encoded = encoded.replaceFirst("[=]*$", ""); - - // Canonicalize to all upper case - encoded = encoded.toUpperCase(Locale.US); - if (encoded.length() == 0) { - return new byte[0]; - } - int encodedLength = encoded.length(); - int outLength = encodedLength * SHIFT / 8; - byte[] result = new byte[outLength]; - int buffer = 0; - int next = 0; - int bitsLeft = 0; - for (char c : encoded.toCharArray()) { - if (!CHAR_MAP.containsKey(c)) { - throw new DecodingException("Illegal character: " + c); - } - buffer <<= SHIFT; - buffer |= CHAR_MAP.get(c) & MASK; - bitsLeft += SHIFT; - if (bitsLeft >= 8) { - result[next++] = (byte) (buffer >> (bitsLeft - 8)); - bitsLeft -= 8; - } - } - // We'll ignore leftover bits for now. - // - // if (next != outLength || bitsLeft >= SHIFT) { - // throw new DecodingException("Bits left: " + bitsLeft); - // } - return result; - } - - public static String encode(byte[] data) { - return getInstance().encodeInternal(data); - } - - protected String encodeInternal(byte[] data) { - if (data.length == 0) { - return ""; - } - - // SHIFT is the number of bits per output character, so the length of the - // output is the length of the input multiplied by 8/SHIFT, rounded up. - if (data.length >= (1 << 28)) { - // The computation below will fail, so don't do it. - throw new IllegalArgumentException(); - } - - int outputLength = (data.length * 8 + SHIFT - 1) / SHIFT; - StringBuilder result = new StringBuilder(outputLength); - - int buffer = data[0]; - int next = 1; - int bitsLeft = 8; - while (bitsLeft > 0 || next < data.length) { - if (bitsLeft < SHIFT) { - if (next < data.length) { - buffer <<= 8; - buffer |= (data[next++] & 0xff); - bitsLeft += 8; - } else { - int pad = SHIFT - bitsLeft; - buffer <<= pad; - bitsLeft += pad; - } - } - int index = MASK & (buffer >> (bitsLeft - SHIFT)); - bitsLeft -= SHIFT; - result.append(DIGITS[index]); - } - return result.toString(); - } - - @Override - // enforce that this class is a singleton - public Object clone() throws CloneNotSupportedException { - throw new CloneNotSupportedException(); - } - - public static class DecodingException extends Exception { - public DecodingException(String message) { - super(message); - } - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/HexEncoding.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/HexEncoding.java deleted file mode 100644 index 417da77a8..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/HexEncoding.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.totp; - -public class HexEncoding { - - /** Hidden constructor to prevent instantiation. */ - private HexEncoding() {} - - private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray(); - - /** - * Encodes the provided data as a hexadecimal string. - */ - public static String encode(byte[] data) { - StringBuilder result = new StringBuilder(data.length * 2); - for (byte b : data) { - result.append(HEX_DIGITS[(b >>> 4) & 0x0f]); - result.append(HEX_DIGITS[b & 0x0f]); - } - return result.toString(); - } - - /** - * Decodes the provided hexadecimal string into an array of bytes. - */ - public static byte[] decode(String encoded) { - // IMPLEMENTATION NOTE: Special care is taken to permit odd number of hexadecimal digits. - int resultLengthBytes = (encoded.length() + 1) / 2; - byte[] result = new byte[resultLengthBytes]; - int resultOffset = 0; - int encodedCharOffset = 0; - if ((encoded.length() % 2) != 0) { - // Odd number of digits -- the first digit is the lower 4 bits of the first result byte. - result[resultOffset++] = (byte) getHexadecimalDigitValue(encoded.charAt(encodedCharOffset)); - encodedCharOffset++; - } - for (int len = encoded.length(); encodedCharOffset < len; encodedCharOffset += 2) { - result[resultOffset++] = (byte) - ((getHexadecimalDigitValue(encoded.charAt(encodedCharOffset)) << 4) - | getHexadecimalDigitValue(encoded.charAt(encodedCharOffset + 1))); - } - return result; - } - - private static int getHexadecimalDigitValue(char c) { - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a') + 0x0a; - } else if ((c >= 'A') && (c <= 'F')) { - return (c - 'A') + 0x0a; - } else if ((c >= '0') && (c <= '9')) { - return c - '0'; - } else { - throw new IllegalArgumentException( - "Invalid hexadecimal digit at position : '" + c + "' (0x" + Integer.toHexString(c) + ")"); - } - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpTwoFactorProvider.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpTwoFactorProvider.java deleted file mode 100644 index 900e1b86e..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpTwoFactorProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.totp; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.authorization.setting.UserSettingManager; -import org.hswebframework.web.authorization.setting.UserSettingPermission; -import org.hswebframework.web.authorization.twofactor.defaults.DefaultTwoFactorValidatorProvider; -import org.hswebframework.web.authorization.twofactor.TwoFactorTokenManager; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.events.TotpTwoFactorCreatedEvent; -import org.hswebframework.web.service.authorization.events.UserCreatedEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.event.EventListener; -import org.springframework.transaction.annotation.Transactional; - -import java.util.function.Function; - -/** - * @author zhouhao - * @since 3.0.4 - */ -@Transactional(rollbackFor = Exception.class) -public class TotpTwoFactorProvider extends DefaultTwoFactorValidatorProvider { - - private UserSettingManager userSettingManager; - - @Getter - @Setter - private String domain = "hsweb.me"; - - @Getter - @Setter - private String settingId = "tow-factor-totp-key"; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - public TotpTwoFactorProvider(UserSettingManager userSettingManager, TwoFactorTokenManager twoFactorTokenManager) { - super("totp", twoFactorTokenManager); - this.userSettingManager = userSettingManager; - } - - @EventListener - public void handleUserCreatedEvent(UserCreatedEvent event) { - //生成totp - String key = TotpUtil.getRandomSecretBase32(64); - UserEntity userEntity = event.getUserEntity(); - String keyUrl = TotpUtil.generateTotpString(userEntity.getUsername(), domain, key); - //创建一个用户没有操作权限的配置 - userSettingManager.saveSetting(userEntity.getId(), settingId, key, UserSettingPermission.NONE); - eventPublisher.publishEvent(new TotpTwoFactorCreatedEvent(userEntity, keyUrl)); - } - - @Override - protected boolean validate(String userId, String code) { - return userSettingManager.getSetting(userId, settingId) - .asString() - .map(key -> TotpUtil.verify(key, code)) - .orElse(false); - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpUtil.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpUtil.java deleted file mode 100644 index 2b7862d6a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/java/org/hswebframework/web/service/authorization/simple/totp/TotpUtil.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.hswebframework.web.service.authorization.simple.totp; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; -import java.lang.reflect.UndeclaredThrowableException; -import java.math.BigInteger; -import java.security.GeneralSecurityException; -import java.security.SecureRandom; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.TimeZone; - -/** - */ -public class TotpUtil { - private static final Logger LOGGER = LoggerFactory.getLogger(TotpUtil.class); - - private TotpUtil() { - } - - /** - * This method uses the JCE to provide the crypto algorithm. - * HMAC computes a Hashed Message Authentication Code with the - * crypto hash algorithm as a parameter. - * - * @param crypto: the crypto algorithm (HmacSHA1, HmacSHA256, - * HmacSHA512) - * @param keyBytes: the bytes to use for the HMAC key - * @param text: the message or text to be authenticated - */ - private static byte[] hmac_sha(String crypto, byte[] keyBytes, - byte[] text) { - try { - Mac hmac; - hmac = Mac.getInstance(crypto); - SecretKeySpec macKey = - new SecretKeySpec(keyBytes, "RAW"); - hmac.init(macKey); - return hmac.doFinal(text); - } catch (GeneralSecurityException gse) { - throw new UndeclaredThrowableException(gse); - } - } - - /** - * This method converts a HEX string to Byte[] - * - * @param hex: the HEX string - * @return: a byte array - */ - private static byte[] hexStr2Bytes(String hex) { - // Adding one byte to get the right conversion - // Values starting with "0" can be converted - byte[] bArray = new BigInteger("10" + hex, 16).toByteArray(); - - // Copy all the REAL bytes, not the "first" - byte[] ret = new byte[bArray.length - 1]; - for (int i = 0; i < ret.length; i++) - ret[i] = bArray[i + 1]; - return ret; - } - - private static final int[] DIGITS_POWER - // 0 1 2 3 4 5 6 7 8 - = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000}; - - /** - * This method generates a TOTP value for the given - * set of parameters. - * - * @param key: the shared secret, HEX encoded - * @param time: a value that reflects a time - * @param returnDigits: number of digits to return - * @return: a numeric String in base 10 that includes truncationDigits digits - */ - public static String generateTOTP(String key, - String time, - String returnDigits) { - return generateTOTP(key, time, returnDigits, "HmacSHA1"); - } - - /** - * This method generates a TOTP value for the given - * set of parameters. - * - * @param key: the shared secret, HEX encoded - * @param time: a value that reflects a time - * @param returnDigits: number of digits to return - * @return: a numeric String in base 10 that includes truncationDigits digits - */ - public static String generateTOTP256(String key, - String time, - String returnDigits) { - return generateTOTP(key, time, returnDigits, "HmacSHA256"); - } - - /** - * This method generates a TOTP value for the given - * set of parameters. - * - * @param key: the shared secret, HEX encoded - * @param time: a value that reflects a time - * @param returnDigits: number of digits to return - * @return: a numeric String in base 10 that includes truncationDigits digits - */ - public static String generateTOTP512(String key, - String time, - String returnDigits) { - return generateTOTP(key, time, returnDigits, "HmacSHA512"); - } - - /** - * This method generates a TOTP value for the given - * set of parameters. - * - * @param key: the shared secret, HEX encoded - * @param time: a value that reflects a time - * @param returnDigits: number of digits to return - * @param crypto: the crypto function to use - * @return: a numeric String in base 10 that includes truncationDigits digits - */ - public static String generateTOTP(String key, - String time, - String returnDigits, - String crypto) { - int codeDigits = Integer.decode(returnDigits); - StringBuilder result; - - // Using the counter - // First 8 bytes are for the movingFactor - // Compliant with base RFC 4226 (HOTP) - StringBuilder timeBuilder = new StringBuilder(time); - while (timeBuilder.length() < 16) - timeBuilder.insert(0, "0"); - time = timeBuilder.toString(); - - // Get the HEX in a Byte[] - byte[] msg = hexStr2Bytes(time); - byte[] k = hexStr2Bytes(key); - - byte[] hash = hmac_sha(crypto, k, msg); - - // put selected bytes into result int - int offset = hash[hash.length - 1] & 0xf; - - int binary = - ((hash[offset] & 0x7f) << 24) | - ((hash[offset + 1] & 0xff) << 16) | - ((hash[offset + 2] & 0xff) << 8) | - (hash[offset + 3] & 0xff); - - int otp = binary % DIGITS_POWER[codeDigits]; - - result = new StringBuilder(Integer.toString(otp)); - while (result.length() < codeDigits) { - result.insert(0, "0"); - } - return result.toString(); - } - - /** - * 验证动态口令是否正确 - * - * @param secretBase32 密钥 - * @param code 待验证的动态口令 - * @return - */ - public static boolean verify(String secretBase32, String code) { - return generate(secretBase32).equals(code); - } - - /** - * 生成totp协议字符串 - * - * @param accoName - * @param domain - * @param secretBase32 - * @return - */ - public static String generateTotpString(String accoName, String domain, String secretBase32) { - return "otpauth://totp/" + accoName + "@" + domain + "?secret=" + secretBase32; - } - - /** - * 根据密钥生成动态口令 - * - * @param secretBase32 base32编码格式的密钥 - * @return - */ - public static String generate(String secretBase32) { - - String secretHex; - try { - secretHex = HexEncoding.encode(Base32String.decode(secretBase32)); - } catch (Base32String.DecodingException e) { - LOGGER.error("解码" + secretBase32 + "出错,", e); - throw new RuntimeException("解码Base32出错"); - } - - long X = 30; - - StringBuilder steps; - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - df.setTimeZone(TimeZone.getTimeZone("UTC")); - - long currentTime = System.currentTimeMillis() / 1000L; - try { - long t = currentTime / X; - steps = new StringBuilder(Long.toHexString(t).toUpperCase()); - while (steps.length() < 16) steps.insert(0, "0"); - - return generateTOTP(secretHex, steps.toString(), "6", - "HmacSHA1"); - } catch (final Exception e) { - LOGGER.error("生成动态口令出错:" + secretBase32, e); - throw new RuntimeException("生成动态口令出错"); - } - } - - /** - * 生成base32编码的随机密钥 - * - * @param length - * @return - */ - public static String getRandomSecretBase32(int length) { - SecureRandom random = new SecureRandom(); - byte[] salt = new byte[length / 2]; - random.nextBytes(salt); - return Base32String.encode(salt); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/hsweb-module.json b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/hsweb-module.json deleted file mode 100644 index 467b62174..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/hsweb-module.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "groupId": "${project.groupId}", - "artifactId": "${project.artifactId}", - "path": "hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local", - "gitCommitHash": "${git.commit.hash}", - "gitRepository": "http://github.com/hs-web/hsweb-framework", - "version": "${project.version}", - "comment": "权限管理" -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml deleted file mode 100644 index df3244caf..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingDetailMapper.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml deleted file mode 100644 index de9e58163..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMapper.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml deleted file mode 100644 index 70b111f0b..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/AuthorizationSettingMenuMapper.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml deleted file mode 100644 index 2608c7bcf..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupBindMapper.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml deleted file mode 100644 index b999be2d2..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuGroupMapper.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} here u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml deleted file mode 100644 index f6eb7a163..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/MenuMapper.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml deleted file mode 100644 index 42a1a946c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/PermissionMapper.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml deleted file mode 100644 index 867f4ea90..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/RoleMapper.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml deleted file mode 100644 index 2dfd1e785..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserMapper.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml deleted file mode 100644 index 85aa7d779..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserRoleMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where role_id =#{id} - - - - - delete from ${_fullTableName} where user_id =#{id} - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserSettingMapper.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserSettingMapper.xml deleted file mode 100644 index 7aa7bd009..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/authorization/UserSettingMapper.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml deleted file mode 100644 index 5c1c926a6..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - hsweb-system-authorization - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-authorization-starter - 业务模块-权限管理自动配置 - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-authorization-local - ${project.version} - - - org.hswebframework.web - hsweb-system-authorization-web - ${project.version} - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - org.hswebframework.web - hsweb-authorization-basic - ${project.version} - true - - - - javax.servlet - javax.servlet-api - provided - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfiguration.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfiguration.java deleted file mode 100644 index 25698794d..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AuthorizationAutoConfiguration.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2019 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.authorization.starter; - -import org.hswebframework.web.authorization.AuthenticationInitializeService; -import org.hswebframework.web.authorization.AuthenticationManager; -import org.hswebframework.web.authorization.basic.embed.EmbedAuthenticationManager; -import org.hswebframework.web.authorization.setting.UserSettingManager; -import org.hswebframework.web.authorization.simple.DefaultAuthorizationAutoConfiguration; -import org.hswebframework.web.authorization.twofactor.TwoFactorTokenManager; -import org.hswebframework.web.authorization.twofactor.defaults.HashMapTwoFactorTokenManager; -import org.hswebframework.web.service.authorization.simple.SimpleAuthenticationManager; -import org.hswebframework.web.service.authorization.simple.totp.TotpTwoFactorProvider; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.*; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.authorization.simple" - , "org.hswebframework.web.authorization.controller"}) -@MapperScan("org.hswebframework.web.authorization.dao") -@AutoConfigureBefore(value = { - DefaultAuthorizationAutoConfiguration.class -}, name = "org.hswebframework.web.authorization.basic.configuration.AuthorizingHandlerAutoConfiguration") -public class AuthorizationAutoConfiguration { - - @ConditionalOnMissingClass("org.hswebframework.web.authorization.basic.embed.EmbedAuthenticationManager") - @Configuration - public static class NoEmbedAuthenticationManagerAutoConfiguration { - @Bean - @Primary - public AuthenticationManager authenticationManager(AuthenticationInitializeService authenticationInitializeService) { - return new SimpleAuthenticationManager(authenticationInitializeService); - } - - } - - @ConditionalOnClass(EmbedAuthenticationManager.class) - @Configuration - public static class EmbedAuthenticationManagerAutoConfiguration { - @Bean - public EmbedAuthenticationManager embedAuthenticationManager() { - return new EmbedAuthenticationManager(); - } - - @Bean - @Primary - public AuthenticationManager authenticationManager(EmbedAuthenticationManager embedAuthenticationManager, - AuthenticationInitializeService authenticationInitializeService) { - return new SimpleAuthenticationManager(authenticationInitializeService, embedAuthenticationManager); - } - } - - @Bean - @ConditionalOnProperty(prefix = "hsweb.authorize", name = "sync", havingValue = "true") - public AutoSyncPermission autoSyncPermission() { - return new AutoSyncPermission(); - } - - @Bean - @ConditionalOnMissingBean(TwoFactorTokenManager.class) - public TwoFactorTokenManager twoFactorTokenManager() { - return new HashMapTwoFactorTokenManager(); - } - - @Bean - @ConditionalOnProperty(prefix = "hsweb.authorize.two-factor.totp", name = "enable", havingValue = "true") - @ConfigurationProperties(prefix = "hsweb.authorize.two-factor.totp") - public TotpTwoFactorProvider totpTwoFactorProvider(UserSettingManager userSettingManager, - TwoFactorTokenManager twoFactorTokenManager) { - return new TotpTwoFactorProvider(userSettingManager, twoFactorTokenManager); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AutoSyncPermission.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AutoSyncPermission.java deleted file mode 100644 index a1b7b5c25..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/java/org/hswebframework/web/authorization/starter/AutoSyncPermission.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.hswebframework.web.authorization.starter; - -import io.swagger.annotations.ApiModelProperty; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.utils.ClassUtils; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.define.AopAuthorizeDefinition; -import org.hswebframework.web.authorization.define.AuthorizeDefinition; -import org.hswebframework.web.authorization.define.AuthorizeDefinitionInitializedEvent; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.entity.authorization.ActionEntity; -import org.hswebframework.web.entity.authorization.OptionalField; -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.service.authorization.PermissionService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Slf4j -public class AutoSyncPermission implements ApplicationListener { - - - private PermissionService permissionService; - - - private EntityFactory entityFactory; - - private static Map actionDescMapping = new HashMap<>(); - - static { - actionDescMapping.put(Permission.ACTION_QUERY, "查询"); - actionDescMapping.put(Permission.ACTION_ADD, "新增"); - actionDescMapping.put(Permission.ACTION_GET, "查看详情"); - actionDescMapping.put(Permission.ACTION_UPDATE, "修改"); - actionDescMapping.put(Permission.ACTION_DELETE, "删除"); - actionDescMapping.put(Permission.ACTION_DISABLE, "禁用"); - actionDescMapping.put(Permission.ACTION_ENABLE, "启用"); - actionDescMapping.put(Permission.ACTION_EXPORT, "导出"); - actionDescMapping.put(Permission.ACTION_IMPORT, "导入"); - - } - - @Autowired - public void setPermissionService(PermissionService permissionService) { - this.permissionService = permissionService; - } - - @Autowired - public void setEntityFactory(EntityFactory entityFactory) { - this.entityFactory = entityFactory; - } - - @Override - public void onApplicationEvent(AuthorizeDefinitionInitializedEvent event) { - List definitions = event.getAllDefinition(); - - Map> grouping = new HashMap<>(); - - //以permissionId分组 - for (AuthorizeDefinition definition : definitions) { - for (String permissionId : definition.getPermissions()) { - grouping.computeIfAbsent(permissionId, id -> new ArrayList<>()) - .add(definition); - } - } - - //创建权限实体 - Map waitToSyncPermissions = new HashMap<>(); - for (Map.Entry> permissionDefinition : grouping.entrySet()) { - String permissionId = permissionDefinition.getKey(); - //一个权限的全部定义(一个permission多个action) - List allDefinition = permissionDefinition.getValue(); - if (allDefinition.isEmpty()) { - return; - } - AuthorizeDefinition tmp = allDefinition.get(0); - //action描述 - List actionDescription = allDefinition.stream() - .map(AuthorizeDefinition::getActionDescription) - .flatMap(Stream::of) - .collect(Collectors.toList()); - //action - List actions = allDefinition - .stream() - .map(AuthorizeDefinition::getActions) - .flatMap(Collection::stream) - .collect(Collectors.toList()); - - //创建action实体 - Set actionEntities = new HashSet<>(actions.size()); - if (!actions.isEmpty()) { - for (int i = 0; i < actions.size(); i++) { - String action = actions.get(i); - String desc = actionDescription.size() > i ? actionDescription.get(i) : actionDescMapping.getOrDefault(actions.get(i), action); - ActionEntity actionEntity = new ActionEntity(); - actionEntity.setAction(action); - actionEntity.setDescribe(desc); - actionEntities.add(actionEntity); - } - } - //创建permission - PermissionEntity entity = entityFactory.newInstance(PermissionEntity.class); - if (tmp instanceof AopAuthorizeDefinition) { - AopAuthorizeDefinition aopAuthorizeDefinition = ((AopAuthorizeDefinition) tmp); - Class type = aopAuthorizeDefinition.getTargetClass(); - Class genType = entityFactory.getInstanceType(ClassUtils.getGenericType(type)); - List optionalFields = new ArrayList<>(); - entity.setOptionalFields(optionalFields); - if (genType != Object.class) { - List fields = new ArrayList<>(); - - ReflectionUtils.doWithFields(genType, fields::add, field -> (field.getModifiers() & Modifier.STATIC) == 0); - - for (Field field : fields) { - if ("id".equals(field.getName())) { - continue; - } - ApiModelProperty property = field.getAnnotation(ApiModelProperty.class); - OptionalField optionalField = new OptionalField(); - optionalField.setName(field.getName()); - if (null != property) { - if (property.hidden()) { - continue; - } - optionalField.setDescribe(property.value()); - } - optionalFields.add(optionalField); - } - } - } - entity.setId(permissionId); - entity.setName(tmp.getPermissionDescription().length > 0 ? tmp.getPermissionDescription()[0] : permissionId); - entity.setActions(new ArrayList<>(actionEntities)); - entity.setType("default"); - entity.setStatus(DataStatus.STATUS_ENABLED); - waitToSyncPermissions.putIfAbsent(entity.getId(), entity); - } - - //查询出全部旧的权限数据并载入缓存 - Map oldCache = permissionService - .select() - .stream() - .collect(Collectors.toMap(PermissionEntity::getId, Function.identity())); - - waitToSyncPermissions.forEach((permissionId, permission) -> { - log.info("try sync permission[{}].{}", permissionId, permission.getActions()); - PermissionEntity oldPermission = oldCache.get(permissionId); - if (oldPermission == null) { - permissionService.insert(permission); - } else { - Set oldAction = new HashSet<>(); - if (oldPermission.getActions() != null) { - oldAction.addAll(oldPermission.getActions()); - } - Map actionCache = oldAction - .stream() - .collect(Collectors.toMap(ActionEntity::getAction, Function.identity())); - boolean permissionChanged = false; - for (ActionEntity actionEntity : permission.getActions()) { - //添加新的action到旧的action - if (actionCache.get(actionEntity.getAction()) == null) { - oldAction.add(actionEntity); - permissionChanged = true; - } - } - if (permissionChanged) { - oldPermission.setActions(new ArrayList<>(oldAction)); - permissionService.updateByPk(oldPermission.getId(), oldPermission); - } - actionCache.clear(); - } - - }); - - oldCache.clear(); - waitToSyncPermissions.clear(); - definitions.clear(); - grouping.clear(); - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index f4cdedd8a..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "properties": [ - { - "name": "hsweb.authorize.sync", - "type": "java.lang.Boolean", - "defaultValue": "false", - "description": "是否自动将解析的权限定义信息同步到数据库,需满足hsweb.authorize.auto-parse=true." - } - ] -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 8e6aa0bd9..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.authorization.starter.AuthorizationAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 1a9491ef2..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2019 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. - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "http://github.com/hs-web/hsweb-framework", - author: "zh.sqy@qq.com", - comment: "权限管理" -}; - -//版本更新信息 -var versions = [ - { - version: "3.0.4", - upgrade: function (context) { - var database = context.database; - database.createOrAlter("s_user_setting") - .addColumn().name("permission").varchar(32).comment("用户可操作权限").commit() - .commit(); - } - } -]; -var JDBCType = java.sql.JDBCType; - -function install(context) { - var database = context.database; - database.createOrAlter("s_user") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("name").varchar(128).notNull().comment("姓名").commit() - .addColumn().name("username").varchar(128).notNull().comment("用户名").commit() - .addColumn().name("password").varchar(128).notNull().comment("密码").commit() - .addColumn().name("salt").varchar(128).notNull().comment("密码盐").commit() - .addColumn().name("status").number(4).notNull().comment("用户状态").commit() - .addColumn().name("last_login_ip").alias("lasLoginIp").varchar(128).comment("上一次登录的ip地址").commit() - .addColumn().name("last_login_time").alias("lastLoginTime").number(32).comment("上一次登录时间").commit() - .addColumn().name("creator_id").alias("creatorId").varchar(32).comment("创建者ID").commit() - .addColumn().name("create_time").alias("createTime").number(32).notNull().comment("创建时间").commit() - //用户名唯一索引 - .index().name("idx_user_username").column("username").unique().commit() - .comment("用户表").commit(); - - database.createOrAlter("s_role") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("name").varchar(128).notNull().comment("角色名称").commit() - .addColumn().name("describe").varchar(128).comment("说明").commit() - .addColumn().name("status").number(4).notNull().comment("状态").commit() - .comment("角色表").commit(); - - database.createOrAlter("s_permission") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("name").varchar(128).notNull().comment("角色名称").commit() - .addColumn().name("describe").varchar(128).comment("说明").commit() - .addColumn().name("status").number(4).notNull().comment("状态").commit() - .addColumn().name("actions").clob().notNull().comment("可选操作(按钮)").commit() - .addColumn().name("spt_da_types").alias("supportDataAccessTypes").clob().comment("支持的数据权限类型").commit() - .addColumn().name("optional_fields").alias("optionalFields").clob().comment("可选字段").commit() - .addColumn().name("parents").clob().comment("关联其他权限").commit() - .addColumn().name("type").varchar(128).comment("类型").commit() - .comment("权限表").commit(); - - database.createOrAlter("s_permission_role") - .addColumn().name("role_id").alias("roleId").varchar(32).notNull().comment("角色ID").commit() - .addColumn().name("permission_id").alias("permissionId").varchar(32).notNull().comment("权限ID").commit() - .addColumn().name("actions").clob().comment("可选操作").commit() - .addColumn().name("data_access").alias("dataAccess").clob().comment("数据级控制配置").commit() - .comment("权限与角色关联表").commit(); - - database.createOrAlter("s_user_role") - .addColumn().name("role_id").alias("roleId").varchar(32).notNull().comment("角色ID").commit() - .addColumn().name("user_id").alias("userId").varchar(32).notNull().comment("用户ID").commit() - .index().name("idx_ur_user_id").column("user_id").commit() - .index().name("idx_ur_role_id").column("role_id").commit() - - .comment("用户与角色关联表").commit(); - - //权限设置 - database.createOrAlter("s_autz_setting") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("type").varchar(32).notNull().comment("权限类型").commit() - .addColumn().name("setting_for").alias("settingFor").varchar(64).notNull().comment("设置给谁").commit() - .addColumn().name("describe").varchar(256).comment("备注").commit() - .addColumn().name("status").number(4, 0).comment("设置给谁").commit() - - .index().name("idx_as_type_setting_for").column("type").column("setting_for").commit() - .comment("权限设置表").commit(); - - database.createOrAlter("s_autz_detail") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("permission_id").alias("permissionId").varchar(32).notNull().comment("权限ID").commit() - .addColumn().name("setting_id").alias("settingId").varchar(64).notNull().comment("设置ID").commit() - .addColumn().name("actions").clob().comment("可操作类型").commit() - .addColumn().name("data_accesses").alias("dataAccesses").clob().comment("数据权限控制").commit() - .addColumn().name("status").number(4, 0).comment("状态").commit() - .addColumn().name("priority").number(32, 0).comment("优先级").commit() - .addColumn().name("is_merge").alias("merge").number(4, 0).comment("是否合并").commit() - .index().name("idx_ad_setting_id").column("setting_id").commit() - - .comment("权限设置详情表").commit(); - - database.createOrAlter("s_autz_menu") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("parent_id").alias("parentId").varchar(32).comment("父级ID").commit() - .addColumn().name("menu_id").alias("menuId").varchar(32).notNull().comment("菜单ID").commit() - .addColumn().name("setting_id").alias("settingId").varchar(64).notNull().comment("设置ID").commit() - .addColumn().name("path").varchar(128).notNull().comment("树编码").commit() - .addColumn().name("sort_index").alias("sortIndex").number(32).comment("树编码").commit() - .addColumn().name("status").number(4, 0).comment("状态").commit() - .addColumn().name("level").number(32, 0).comment("树深度").commit() - .addColumn().name("config").clob().comment("其他配置").commit() - .index().name("idx_ame_setting_id").column("setting_id").commit() - .index().name("idx_ame_parent_id").column("parent_id").commit() - .index().name("idx_ame_path").column("path").commit() - .comment("权限设置菜单表").commit(); - - // 菜单 - database.createOrAlter("s_menu") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("name").varchar(64).notNull().comment("名称").commit() - .addColumn().name("parent_id").alias("parentId").varchar(32).comment("父级ID").commit() - .addColumn().name("permission_id").alias("permissionId").varchar(2048).comment("权限ID").commit() - .addColumn().name("path").varchar(128).notNull().comment("树编码").commit() - .addColumn().name("sort_index").alias("sortIndex").number(32).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() - .index().name("idx_menu_path").column("path").commit() - .index().name("idx_menu_parent_id").column("parent_id").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(128).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(128).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_user_setting") - .addColumn().name("u_id").alias("id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("name").varchar(128).comment("配置名称").commit() - .addColumn().name("describe").varchar(512).comment("说明").commit() - .addColumn().name("user_id").alias("userId").varchar(32).notNull().comment("用户ID").commit() - .addColumn().name("key").varchar(128).notNull().comment("配置标识").commit() - .addColumn().name("setting").clob().comment("配置内容").commit() - .addColumn().name("setting_id").alias("settingId").varchar(32).notNull().comment("自定义配置id").commit() - .addColumn().name("create_time").alias("createTime").datetime().notNull().comment("创建时间").commit() - .addColumn().name("update_time").alias("updateTime").datetime().comment("创建时间").commit() - .index().name("idx_uset_user_id").column("user_id").commit() - .index().name("idx_uset_user_id_key").column("user_id").column("key").commit() - .index().name("idx_uset_user_id_key_setting").column("user_id").column("key").column("setting_id").commit() - .comment("用户设置表").commit(); -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug89Test.groovy b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug89Test.groovy deleted file mode 100644 index a81790926..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug89Test.groovy +++ /dev/null @@ -1,73 +0,0 @@ -package org.hswebframework.web.authorization.starter - -import com.alibaba.fastjson.JSON -import org.hswebframework.web.entity.authorization.UserEntity -import org.hswebframework.web.service.authorization.UserService -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.context.annotation.Configuration -import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import spock.lang.Shared -import spock.lang.Specification -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* - - -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -@Configuration -class FixBug89Test extends Specification { - - @Autowired - private ConfigurableApplicationContext context; - - @Shared - private MockMvc mockMvc; - - @Autowired - private UserService userService; - - - void setup() { - mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); - UserEntity userEntity = userService.createEntity(); - userEntity.setName("test"); - userEntity.setUsername("fix-bug#89"); - userEntity.setPassword("fix-bug#89"); - if (userService.selectByUsername("fix-bug#89") == null) { - userService.insert(userEntity); - } - } - - def doLogin(username, password) { - def response = mockMvc.perform(post("/authorize/login") - .contentType(MediaType.APPLICATION_JSON) - .content("""{"username":"${username}","password":"${password}"}""")) -// .andExpect(status().is(200)) - .andReturn() - .getResponse() - .getContentAsString() - return JSON.parseObject(response).get("status"); - } - - def "测试用户名为空时登录依旧能登录成功问题"() { - given: - def user = userService.selectByUserNameAndPassword("fix-bug#89", "fix-bug#89"); - expect: - user != null - doLogin(username, password) == code - where: - username | password | code - "fix-bug#89" | "fix-bug#89" | 200 - "fix-bug#89" | "" | 400 - "" | "fix-bug#89" | 400 - "" | "" | 400 - - - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug91Test.groovy b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug91Test.groovy deleted file mode 100644 index c9a7d6ba2..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/FixBug91Test.groovy +++ /dev/null @@ -1,69 +0,0 @@ -package org.hswebframework.web.authorization.starter - -import org.hswebframework.web.authorization.AuthenticationManager -import org.hswebframework.web.authorization.simple.PlainTextUsernamePasswordAuthenticationRequest -import org.hswebframework.web.entity.authorization.UserEntity -import org.hswebframework.web.service.authorization.UserService -import org.hswebframework.web.validate.ValidationException -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.context.annotation.Configuration -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import spock.lang.Shared -import spock.lang.Specification - -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -@Configuration -class FixBug91Test extends Specification { - - @Autowired - private ConfigurableApplicationContext context; - - @Shared - private MockMvc mockMvc; - - @Autowired - private AuthenticationManager authenticationManager; - - @Autowired - private UserService userService; - - void setup() { - mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); - UserEntity userEntity = userService.createEntity(); - userEntity.setName("test"); - userEntity.setUsername("fix-bug#91"); - userEntity.setPassword("fix-bug#91"); - if (userService.selectByUsername("fix-bug#91") == null) { - userService.insert(userEntity); - } - } - - boolean authenticationInitSuccess(String username, String password) { - try { - def autz = authenticationManager.authenticate(new PlainTextUsernamePasswordAuthenticationRequest(username, password)); - if (autz != null) { - return null != authenticationManager.getByUserId(autz.getUser().getId()); - } - } catch (ValidationException e) { - return false; - } - return false; - } - - def "同时获取配置文件和数据库中的用户权限"() { - expect: - authenticationInitSuccess(username, password) == success - where: - username | password | success - "fix-bug#91" | "fix-bug#91" | true - "fix-bug-91-in-yml" | "fix-bug-91-in-yml" | true - "not-exists-user" | "not-exists-user" | false - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TestApplication.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TestApplication.java deleted file mode 100644 index 8c2081048..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TestApplication.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.authorization.starter; - -import org.hswebframework.web.authorization.basic.web.AuthorizationController; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.web.WebAppConfiguration; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@SpringBootApplication -@WebAppConfiguration -@Configuration -public class TestApplication { - - @Bean - public AuthorizationController authorizationController() { - return new AuthorizationController(); - } - - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TotpTwoFactorProviderTests.groovy b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TotpTwoFactorProviderTests.groovy deleted file mode 100644 index 7fbbf7ebb..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/TotpTwoFactorProviderTests.groovy +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.authorization.starter - -import org.hswebframework.web.authorization.twofactor.TwoFactorValidatorManager -import org.hswebframework.web.entity.authorization.SimpleUserEntity -import org.hswebframework.web.service.authorization.UserService -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ContextConfiguration -import spock.lang.Specification - -/** - * @author zhouhao - * @since 3.0.4 - */ -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -class TotpTwoFactorProviderTests extends Specification { - - @Autowired - TwoFactorValidatorManager validatorManager; - - @Autowired - private UserService userService; - - - def "测试totp"() { - given: - String id = userService.insert(new SimpleUserEntity( - username: "admin2", - password: "admin2", - name: "admin2" - )) - expect: - !validatorManager.getValidator(id, "", "totp") - .verify("test", 100) - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/UserSettingControllerTest.groovy b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/UserSettingControllerTest.groovy deleted file mode 100644 index 2efcb0252..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/groovy/org/hswebframework/web/authorization/starter/UserSettingControllerTest.groovy +++ /dev/null @@ -1,146 +0,0 @@ -package org.hswebframework.web.authorization.starter - -import com.alibaba.fastjson.JSON -import org.hswebframework.web.authorization.Authentication -import org.hswebframework.web.authorization.AuthenticationInitializeService -import org.hswebframework.web.authorization.access.DataAccessConfig -import org.hswebframework.web.tests.HswebCrudWebApiSpecification -import org.junit.runner.RunWith -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.junit4.SpringRunner -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.MvcResult -import org.springframework.test.web.servlet.ResultHandler -import org.springframework.test.web.servlet.result.MockMvcResultMatchers -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import spock.lang.Shared -import spock.lang.Specification - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; - -/** - * @author zhouhao - * @since 3.0 - */ -class UserSettingControllerTest extends HswebCrudWebApiSpecification { - - @Autowired - private AuthenticationInitializeService initializeService; - - @Override - protected String getBaseApi() { - return "/autz-setting" - } - - - def "Add Permission"() { - def permissions = [ - [ - "id" : "user", - "name" : "用户管理", - "actions" : [["action": "query", "describe": "查询"], ["action": "update", "describe": "修改"]], - "supportDataAccessTypes": [DataAccessConfig.DefaultType.DENY_FIELDS] - ], - [ - "id" : "role", - "name" : "角色管理", - "actions": [["action": "query", "describe": "查询"], ["action": "get", "describe": "查看详情"]] - - ] - ] - permissions.forEach({ permission -> - //添加权限 - mockMvc.perform(patch("/permission") - .contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(permission))) - .andDo({ result -> println result.response.contentAsString }) - .andExpect(status().is(200)) - }) - } - - def "Add User"() { - //添加用户先 - String result = mockMvc - .perform( - post("/user") - .contentType(MediaType.APPLICATION_JSON) - .content( - """ - { - "name":"admin", - "username":"admin", - "password":"admin" - } - """ - )) - .andDo({ result -> println result.response.contentAsString }) - .andExpect(status().is(201)) - .andReturn() - .getResponse() - .getContentAsString() - return JSON.parseObject(result).getString("result") - } - - def "Add User Authentication Setting"() { - setup: - "Add Permission"() - def userId = "Add User"() - //添加用户权限 - doAddRequest(JSON.toJSONString - ([ - type : "user", //设置类型:user - settingFor: userId, //设置给具体的user - describe : "测试", - details : - [ - [ - permissionId: "user", //赋予user权限 - actions : ["query", "update"], - status : 1, - dataAccesses: [ //数据权限,控制查询的时候不能查询password字段 - [ - type : DataAccessConfig.DefaultType.DENY_FIELDS, - action: "query", - config: """{"fields": ["password"]}""" - ] - ] - ], - [ - permissionId: "role", //赋予role权限 - actions : ["query", "get"], - status : 1 - ] - ], - menus : - [ - [ - menuId: "user-menu" - ], - [ - menuId: "role-menu" - ] - ] - ])) - - expect: - userId != null - def autz = initializeService.initUserAuthorization(userId) - autz != null - autz.hasPermission("user", "query") - autz.hasPermission("role", "query", "get") - autz.getPermission("user") - .map({ per -> per.findDenyFields("query") }) - .map({ fields -> fields.contains("password") }) - .orElse(false) - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AuthorizationSettingTests.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AuthorizationSettingTests.java deleted file mode 100644 index 1c76ada11..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AuthorizationSettingTests.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 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.authorization.starter; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity; -import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class AuthorizationSettingTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - AuthorizationSettingEntity entity = entityFactory.newInstance(AuthorizationSettingEntity.class); - //todo 设置测试属性 - entity.setId("test"); - entity.setType(AuthorizationSettingTypeSupplier.SETTING_TYPE_USER); - entity.setSettingFor("test"); - entity.setDescribe("测试"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/autz-setting").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/autz-setting/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(AuthorizationSettingEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(AuthorizationSettingEntity.class)))); - //todo 修改测试属性 - AuthorizationSettingEntity newEntity = entityFactory.newInstance(AuthorizationSettingEntity.class); - newEntity.setId("test"); - newEntity.setDescribe("测试2"); - result = testPut("/autz-setting/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/autz-setting/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/autz-setting/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/autz-setting/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AutoSyncPermissionTest.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AutoSyncPermissionTest.java deleted file mode 100644 index f1eb46895..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/AutoSyncPermissionTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.hswebframework.web.authorization.starter; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionParser; -import org.hswebframework.web.authorization.basic.aop.DefaultAopMethodAuthorizeDefinitionParser; -import org.hswebframework.web.authorization.define.AuthorizeDefinition; -import org.hswebframework.web.authorization.define.AuthorizeDefinitionInitializedEvent; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.commons.entity.factory.MapperEntityFactory; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.authorization.PermissionService; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import static org.mockito.Mockito.*; - -/** - * @author zhouhao - * @since 1.0 - */ -@RunWith(MockitoJUnitRunner.class) -public class AutoSyncPermissionTest { - @Mock - private PermissionService permissionService; - - @InjectMocks - private AutoSyncPermission autoSyncPermission = new AutoSyncPermission(); - - private List newPermissionEntity = new ArrayList<>(); - - @Before - public void init() throws NoSuchMethodException { - when(permissionService.selectByPk(anyString())).thenReturn(null); - when(permissionService.insert(any())).then(invocationOnMock -> { - newPermissionEntity.add(invocationOnMock.getArgumentAt(0, PermissionEntity.class)); - return "new Id"; - }); - autoSyncPermission.setEntityFactory(new MapperEntityFactory()); - } - - @Test - public void test() throws NoSuchMethodException { - AopMethodAuthorizeDefinitionParser parser = new DefaultAopMethodAuthorizeDefinitionParser(); - List definition = Arrays.stream(TestController.class.getMethods()) - .map(method -> parser.parse(TestController.class, method)) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - - - autoSyncPermission.onApplicationEvent(new AuthorizeDefinitionInitializedEvent(definition)); - - Assert.assertTrue(!newPermissionEntity.isEmpty()); - PermissionEntity permissionEntity = newPermissionEntity.get(0); - Assert.assertEquals(permissionEntity.getId(), "test"); - Assert.assertEquals(permissionEntity.getName(), "测试权限"); - Assert.assertTrue(!permissionEntity.getActions().isEmpty()); - - Assert.assertEquals(permissionEntity.getOptionalFields().size(), 3); - } - - @Authorize(permission = "test", description = "测试权限") - @Api(value = "测试", tags = "测试") - public static class TestController implements SimpleGenericEntityController { - - @Override - public CrudService getService() { - return null; - } - } - - @Data - public static class TestEntity extends SimpleGenericEntity { - @ApiModelProperty("姓名") - private String name; - - @ApiModelProperty("用户名") - private String username; - - @ApiModelProperty(value = "密码", hidden = true) - private String password; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/LoginTests.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/LoginTests.java deleted file mode 100644 index 27677e458..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/LoginTests.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019 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.authorization.starter; - -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.authorization.basic.configuration.EnableAopAuthorize; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.After; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; - -import java.sql.SQLException; - -/** - * @author zhouhao - */ -@Configuration -@EnableAopAuthorize -public class LoginTests extends SimpleWebApplicationTests { - - @Autowired - private UserService userService; - - @After - public void clear() throws SQLException { - sqlExecutor.delete("delete from s_user"); - } - - @Test - public void testLogin() throws Exception { - UserEntity userEntity = userService.createEntity(); - userEntity.setName("测试"); - userEntity.setUsername("test"); - userEntity.setPassword("password_1234"); - userEntity.setCreatorId("admin"); - userEntity.setCreateTimeNow(); - userService.insert(userEntity); - - JSONObject json = testPost("/authorize/login").setUp((builder) -> { - builder.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE); - builder.param("username", userEntity.getUsername()); - builder.param("password", "password_1234"); - }).exec().resultAsJson(); - - org.junit.Assert.assertEquals(userEntity.getId(), json.getJSONObject("result").getString("userId")); - - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/PermissionTests.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/PermissionTests.java deleted file mode 100644 index aad59e343..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/PermissionTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 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.authorization.starter; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.entity.authorization.ActionEntity; -import org.hswebframework.web.entity.authorization.DataAccessEntity; -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.service.authorization.PermissionService; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.sql.SQLException; -import java.util.Arrays; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class PermissionTests extends SimpleWebApplicationTests { - - @Autowired - private PermissionService permissionService; - - @Autowired - private SqlExecutor sqlExecutor; - - @After - public void clear() throws SQLException { - sqlExecutor.delete("delete from s_permission"); - } - - @Test - public void testCRUD() throws Exception { - Assert.assertTrue(sqlExecutor.tableExists("s_permission")); - - DataAccessEntity dataAccessEntity = new DataAccessEntity(); - dataAccessEntity.setType(DataAccessConfig.DefaultType.OWN_CREATED); - dataAccessEntity.setAction(Permission.ACTION_QUERY); - dataAccessEntity.setDescribe("只能查询自己创建的数据"); - - PermissionEntity entity = permissionService.createEntity(); - entity.setStatus((byte) 1); - entity.setName("测试"); - entity.setActions(Arrays.asList(new ActionEntity("C"))); - entity.setId("test"); - String id = permissionService.insert(entity); - Assert.assertNotNull(id); - - PermissionEntity data = permissionService.selectByPk("test"); - Assert.assertEquals(data.getId(), entity.getId()); - Assert.assertEquals(data.getName(), entity.getName()); - Assert.assertEquals(data.getStatus(), entity.getStatus()); - - data.setName("测试修改"); - permissionService.updateByPk(data.getId(), data); - PermissionEntity data2 = permissionService.selectByPk("test"); - Assert.assertEquals(data2.getName(), data.getName()); - - permissionService.deleteByPk("test"); - Assert.assertTrue(permissionService.selectByPk("test") == null); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/UserTests.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/UserTests.java deleted file mode 100644 index 36d551aa8..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/authorization/starter/UserTests.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2019 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.authorization.starter; - -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.service.authorization.PasswordStrengthValidator; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.service.authorization.UsernameValidator; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.hswebframework.web.validate.ValidationException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -import java.sql.SQLException; - -/** - * @author zhouhao - */ -@Configuration -@Import(UserTests.Config.class) -public class UserTests extends SimpleWebApplicationTests { - - @Configuration - public static class Config { - @Bean - public PasswordStrengthValidator passwordStrengthValidator() { - return new PasswordStrengthValidator() { - @Override - public boolean validate(String data) { - return data.length() >= 4; - } - - @Override - public String getErrorMessage() { - return "密码强度太弱"; - } - }; - } - - @Bean - public UsernameValidator usernameValidator() { - return (username) -> username.length() >= 4; - } - } - - @Autowired - private UserService userService; - - @Autowired - private AuthenticationInitializeService authenticationInitializeService; - - @After - public void clear() throws SQLException { - sqlExecutor.delete("delete from s_user"); - } - - public UserEntity createTestUser() { - UserEntity userEntity = userService.createEntity(); - userEntity.setName("测试"); - userEntity.setUsername("test"); - userEntity.setPassword("password_1234"); - userEntity.setCreateTimeNow(); - userEntity.setCreatorId("admin"); - userService.insert(userEntity); - return userEntity; - } - - @Test - public void testInitAuth() { - UserEntity entity = createTestUser(); - Authentication authentication = authenticationInitializeService.initUserAuthorization(entity.getId()); - Assert.assertNotNull(authentication); - Assert.assertEquals(authentication.getUser().getUsername(), entity.getUsername()); - } - - @Test - public void testCRUD() { - UserEntity userEntity = userService.createEntity(); - userEntity.setName("测试"); - userEntity.setUsername("test"); - userEntity.setPassword("123"); - userEntity.setCreatorId("admin"); - userEntity.setCreateTimeNow(); - try { - userService.insert(userEntity); - Assert.assertTrue(false); - } catch (ValidationException e) { - Assert.assertEquals(e.getResults().get(0).getMessage(), "密码强度太弱"); - } - userEntity.setPassword("password_1234"); - String id = userService.insert(userEntity); - - UserEntity newUserEntity = userEntity.clone(); - newUserEntity.setUsername("test2"); - String anotherId = userService.insert(newUserEntity); - - Assert.assertNotNull(id); - Assert.assertEquals(userEntity.getPassword().length(), 32); - - UserEntity entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals(entityInDb.getStatus(), DataStatus.STATUS_ENABLED); - Assert.assertNotNull(entityInDb.getCreateTime()); - - Assert.assertEquals(entityInDb.getPassword(), userService.encodePassword("password_1234", entityInDb.getSalt())); - - entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals(entityInDb.getStatus(), DataStatus.STATUS_ENABLED); - Assert.assertNotNull(entityInDb.getCreateTime()); - try { - userService.updatePassword(id, "test", "test"); - Assert.assertTrue(false); - } catch (ValidationException e) { - //密码错误 - } - userService.updatePassword(id, "password_1234", "password_2345"); - entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals(entityInDb.getPassword(), userService.encodePassword("password_2345", entityInDb.getSalt())); - - entityInDb.setId(anotherId); - entityInDb.setName("新名字"); - userService.update(anotherId, entityInDb); - entityInDb.setId(id); - - userService.update(id, entityInDb); - entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals("新名字", entityInDb.getName()); - - - userService.disable(id); - entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals(DataStatus.STATUS_DISABLED, entityInDb.getStatus()); - - userService.enable(id); - entityInDb = userService.selectByUsername(userEntity.getUsername()); - Assert.assertEquals(DataStatus.STATUS_ENABLED, entityInDb.getStatus()); - - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/resources/application.yml deleted file mode 100644 index 7db45d9d7..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/resources/application.yml +++ /dev/null @@ -1,29 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:permission_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 权限管理测试 - version: 3.0.0 - authorize: - sync: false - auto-parse: false - two-factor: - totp: - enable: true - users: - fix-bug-91-in-yml: - username: "fix-bug-91-in-yml" - password: "fix-bug-91-in-yml" - -logging: - level: - org.springframework: WARN - org.hswebframework: WARN - org.hswebframework.web: DEBUG \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/pom.xml b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/pom.xml deleted file mode 100644 index fa081d455..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - hsweb-system-authorization - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-authorization-web - 业务模块-权限管理WEB API模块 - - - - src/main/resources - true - - - - - - javax.servlet - javax.servlet-api - provided - - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/AuthorizationSettingController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/AuthorizationSettingController.java deleted file mode 100644 index 6db550f10..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/AuthorizationSettingController.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.authorization.AuthorizationSettingEntity; -import org.hswebframework.web.service.authorization.AuthorizationSettingService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 权限设置 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.autz-setting:autz-setting}") -@Authorize(permission = "autz-setting", description = "权限设置") -@Api(tags = "权限-权限设置", value = "权限设置") -public class AuthorizationSettingController implements SimpleGenericEntityController { - - private AuthorizationSettingService authorizationSettingService; - - @Autowired - public void setAuthorizationSettingService(AuthorizationSettingService authorizationSettingService) { - this.authorizationSettingService = authorizationSettingService; - } - - @Override - public AuthorizationSettingService getService() { - return authorizationSettingService; - } - - @GetMapping("/{type}/{settingFor}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("根据type和settingFor获取配置") - public ResponseMessage select(@PathVariable String type, @PathVariable String settingFor) { - return ResponseMessage.ok(authorizationSettingService.select(type, settingFor)); - } - - @GetMapping("/permission/{permissionId}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("根据权限ID获取对应的权限配置信息") - public ResponseMessage> selectByPermissionId(@PathVariable String permissionId) { - return ResponseMessage.ok(authorizationSettingService.selectByPermissionId(permissionId)); - } - - @PutMapping("/merge") - @Authorize(action = Permission.ACTION_UPDATE) - @ApiOperation("合并权限信息") - public ResponseMessage mergeSetting(@RequestBody List list) { - authorizationSettingService.mergeSetting(list); - return ResponseMessage.ok(); - } - - @DeleteMapping("/{settingId}/{permissionId}") - @Authorize(action = Permission.ACTION_UPDATE) - @ApiOperation("删除单个权限配置详情") - public ResponseMessage deleteDetail(@PathVariable String settingId, @PathVariable String permissionId) { - authorizationSettingService.deleteDetail(settingId, permissionId); - return ResponseMessage.ok(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/MenuController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/MenuController.java deleted file mode 100644 index e43490eb3..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/MenuController.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.authorization.MenuEntity; -import org.hswebframework.web.entity.authorization.UserMenuEntity; -import org.hswebframework.web.service.authorization.MenuService; -import org.hswebframework.web.service.authorization.UserMenuManagerService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 菜单分组 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.menu:menu}") -@Authorize(permission = "menu",description = "菜单管理") -@Api(value = "系统菜单管理",tags = "权限-菜单管理") -public class MenuController implements SimpleGenericEntityController { - - private MenuService menuService; - - private UserMenuManagerService userMenuManagerService; - - @Autowired - public void setMenuService(MenuService menuService) { - this.menuService = menuService; - } - - @Autowired - public void setUserMenuManagerService(UserMenuManagerService userMenuManagerService) { - this.userMenuManagerService = userMenuManagerService; - } - - @Override - public MenuService getService() { - return menuService; - } - - @GetMapping("/user-own/list") - @Authorize(merge = false) - @ApiOperation("获取当前用户的菜单列表") - public ResponseMessage> getUserMenuAsList(@ApiParam(hidden = true) Authentication authentication) { - return ok(userMenuManagerService.getUserMenuAsList(authentication.getUser().getId())); - } - - @GetMapping("/user-own/tree") - @Authorize(merge = false) - @ApiOperation("获取当前用户的菜单树") - public ResponseMessage> getUserMenuAsTree(@ApiParam(hidden = true) Authentication authentication) { - return ok(userMenuManagerService.getUserMenuAsTree(authentication.getUser().getId())); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/PermissionController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/PermissionController.java deleted file mode 100644 index 594315ae5..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/PermissionController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.authorization.PermissionEntity; -import org.hswebframework.web.service.authorization.PermissionService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 权限管理 - * - * @author zhouhao - */ -@RestController -@RequestMapping("${hsweb.web.mappings.permission:permission}") -@Authorize(permission = "permission", description = "权限管理") -@Api(value = "权限管理",tags = "权限-权限管理") -public class PermissionController implements SimpleGenericEntityController { - - private PermissionService permissionService; - - @Autowired - public void setPermissionService(PermissionService permissionService) { - this.permissionService = permissionService; - } - - @Override - public PermissionService getService() { - return permissionService; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/RoleController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/RoleController.java deleted file mode 100644 index 823154a9c..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/RoleController.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.service.authorization.RoleService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 角色控制器 - * - * @author zhouhao - */ -@RestController -@RequestMapping("${hsweb.web.mappings.role:role}") -@Authorize(permission = "role", description = "角色管理") -@Api(value = "角色管理",tags = "权限-角色管理") -public class RoleController implements SimpleGenericEntityController { - - @Autowired - private RoleService roleService; - - @Override - public RoleService getService() { - return roleService; - } - - @PutMapping("/disable/{id:.+}") - @Authorize(action = Permission.ACTION_DISABLE) - @ApiOperation("禁用角色") - public ResponseMessage disable(@PathVariable String id) { - roleService.disable(id); - return ok(); - } - - @PutMapping("/enable/{id}") - @Authorize(action = Permission.ACTION_ENABLE) - @ApiOperation("启用角色") - public ResponseMessage enable(@PathVariable String id) { - roleService.enable(id); - return ok(); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserController.java deleted file mode 100644 index 428f19d71..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserController.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationManager; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.exception.UnAuthorizedException; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.CreateController; -import org.hswebframework.web.controller.QueryController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.entity.authorization.bind.BindRoleUserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import static org.hswebframework.web.controller.message.ResponseMessage.ok; - -/** - * 用户管理控制器 - * - * @author zhouhao - */ -@RestController -@RequestMapping("${hsweb.web.mappings.user:user}") -@Authorize(permission = "user", description = "用户管理") -@Api(value = "用户管理", tags = "权限-用户管理") -public class UserController implements - QueryController, - CreateController { - - @Autowired - private UserService userService; - - @Autowired - private AuthenticationManager authenticationManager; - - @Override - @SuppressWarnings("unchecked") - public UserService getService() { - return userService; - } - - @Override - @SuppressWarnings("all") - public ResponseMessage> list(QueryParamEntity param) { - param.excludes("password", "salt"); - return QueryController.super.list(param) - .exclude(UserEntity.class, "password", "salt"); - } - - @Override - @SuppressWarnings("all") - public ResponseMessage getByPrimaryKey(@PathVariable String id) { - return QueryController.super.getByPrimaryKey(id) - .exclude(UserEntity.class, "password", "salt"); - } - - @Authorize(action = Permission.ACTION_UPDATE) - @PutMapping(path = "/{id:.+}") - @ApiOperation("根据ID修改用户信息") - public ResponseMessage updateByPrimaryKey(@PathVariable String id, - @RequestBody BindRoleUserEntity userModel) { - getService().update(id, userModel); - return ok(); - } - - @Authorize(action = Permission.ACTION_GET) - @GetMapping(path = "/{id:.+}/authentication") - @ApiOperation("获取用户的权限信息") - public ResponseMessage getUserAuthentication(@PathVariable String id) { - return ok(authenticationManager.getByUserId(id)); - } - - @Authorize(merge = false) - @PutMapping(path = "/password") - @ApiOperation("修改当前登录用户的密码") - public ResponseMessage updateLoginUserPassword(@RequestParam String password, - @RequestParam String oldPassword) { - - Authentication authentication = Authentication.current().orElseThrow(UnAuthorizedException::new); - getService().updatePassword(authentication.getUser().getId(), oldPassword, password); - return ok(); - } - - @Authorize(action = Permission.ACTION_UPDATE) - @PutMapping(path = "/password/{id:.+}") - @ApiOperation("修改指定用户的密码") - public ResponseMessage updateByPasswordPrimaryKey(@PathVariable String id, - @RequestParam String password, - @RequestParam String oldPassword) { - getService().updatePassword(id, oldPassword, password); - return ok(); - } - - @Override - public ResponseMessage add(@RequestBody BindRoleUserEntity data) { - Authentication authentication = Authentication.current().orElse(null); - if (null != authentication) { - data.setCreatorId(authentication.getUser().getId()); - } - return CreateController.super.add(data); - } - - @Authorize(action = Permission.ACTION_ENABLE) - @PutMapping(path = "/{id}/enable") - @ApiOperation("启用用户") - public ResponseMessage enable(@PathVariable String id) { - return ok(getService().enable(id)); - } - - @Authorize(action = Permission.ACTION_DISABLE) - @PutMapping(path = "/{id}/disable") - @ApiOperation("禁用用户") - public ResponseMessage disable(@PathVariable String id) { - return ok(getService().disable(id)); - } - - @Override - public BindRoleUserEntity modelToEntity(BindRoleUserEntity model, BindRoleUserEntity entity) { - return model; - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserSettingController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserSettingController.java deleted file mode 100644 index 82624b8fa..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/UserSettingController.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.hswebframework.web.authorization.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.authorization.setting.UserSettingPermission; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.authorization.UserSettingEntity; -import org.hswebframework.web.service.authorization.UserSettingService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.hswebframework.web.authorization.setting.UserSettingPermission.*; - -/** - * @author zhouhao - * @since 3.0 - */ -@RestController -@RequestMapping("/user-setting") -@Authorize//(permission = "user-setting", description = "用户配置管理") -@Api(value = "用户配置管理", tags = "用户-用户配置管理") -public class UserSettingController { - - @Autowired - private UserSettingService userSettingService; - - @GetMapping("/me/{key}/{id}") - @Authorize(merge = false) - @ApiOperation("获取当前用户的配置") - public ResponseMessage get(Authentication authentication, - @PathVariable String key, - @PathVariable String id) { - UserSettingEntity entity = userSettingService.selectByUser(authentication.getUser().getId(), key, id); - if (entity != null && entity.hasPermission(R, RW)) { - return ResponseMessage.ok(entity); - } - return ResponseMessage.ok(); - } - - @GetMapping("/me/{key}") - @Authorize(merge = false) - @ApiOperation("获取当前用户的配置列表") - public ResponseMessage> get(Authentication authentication, - @PathVariable String key) { - - return ResponseMessage.ok(userSettingService - .selectByUser(authentication.getUser().getId(), key) - .stream() - .filter(setting -> setting.hasPermission(R, RW)) - .collect(Collectors.toList())); - } - - @PatchMapping("/me/{key}") - @Authorize(merge = false) - @ApiOperation("保存当前用户配置") - public ResponseMessage save(Authentication authentication, - @PathVariable String key, - @Validated - @RequestBody UserSettingEntity userSettingEntity) { - userSettingEntity.setId(null); - userSettingEntity.setUserId(authentication.getUser().getId()); - userSettingEntity.setKey(key); - UserSettingEntity old = userSettingService.selectByUser(authentication.getUser().getId(), key, userSettingEntity.getSettingId()); - if (old != null) { - userSettingEntity.setId(old.getId()); - if (!old.hasPermission(RW, R)) { - throw new AccessDenyException("没有权限保存此配置"); - } - } - userSettingEntity.setPermission(RW); - String id = userSettingService.saveOrUpdate(userSettingEntity); - return ResponseMessage.ok(id); - } -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/ActionModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/ActionModel.java deleted file mode 100644 index d6ee69e93..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/ActionModel.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.hswebframework.web.commons.model.Model; - -@ApiModel(description = "操作事件") -public class ActionModel implements Model { - - @ApiModelProperty(value = "事件标识", required = true, allowableValues = "query,get,update,delete,add,....", example = "query") - private String action; - - @ApiModelProperty("描述") - private String describe; - - @ApiModelProperty("是否默认选中") - private boolean defaultCheck; - - public ActionModel() { - } - - public ActionModel(String action) { - this.action = action; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getDescribe() { - return describe; - } - - public void setDescribe(String describe) { - this.describe = describe; - } - - public boolean isDefaultCheck() { - return defaultCheck; - } - - public void setDefaultCheck(boolean defaultCheck) { - this.defaultCheck = defaultCheck; - } - - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/DataAccessModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/DataAccessModel.java deleted file mode 100644 index cbc803633..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/DataAccessModel.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@ApiModel(value = "DataAccessModel",description = "数据级权限控制配置") -public class DataAccessModel { - private String action; - - private String describe; - - private String type; - - private String config; - - @ApiModelProperty(value = "触发控制的事件", example = "query", required = true) - public String getAction() { - return this.action; - } - - public void setAction(String action) { - this.action = action; - } - - @ApiModelProperty("说明") - public String getDescribe() { - return this.describe; - } - - public void setDescribe(String describe) { - this.describe = describe; - } - - @ApiModelProperty(value = "控制的类型", allowableValues = "OWN_CREATED,SCRIPT,CUSTOM", required = true, example = "OWN_CREATED") - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - @ApiModelProperty(value = "控制配置." + - "当控制类型为OWN_CREATED时:可留空." + - "当控制类型为SCRIPT时:值为json string,格式:{\"language\":\"groovy\",\"script\":\"return true;\"}." + - "当控制类型为CUSTOM时,值为一个实现了DataAccessController接口的类") - public String getConfig() { - return this.config; - } - - public void setConfig(String config) { - this.config = config; - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/FieldAccessModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/FieldAccessModel.java deleted file mode 100644 index 217120246..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/FieldAccessModel.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import io.swagger.annotations.*; -import org.hswebframework.web.commons.model.Model; - -import java.util.Collections; -import java.util.List; - -/** - * - * @author zhouhao - */ -@ApiModel(value = "FieldAccessModel", description = "字段级权限控制配置") -public class FieldAccessModel implements Model { - private String field; - - private String describe; - - private List actions; - - @ApiModelProperty(value = "要控制的字段名", required = true, example = "createTime") - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - @ApiModelProperty("字段说明") - public String getDescribe() { - return describe; - } - - public void setDescribe(String describe) { - this.describe = describe; - } - - @ApiModelProperty(value = "触发控制的事件,表示此字段不能进行{action}操作.", -// example = "[{\"action\":\"query\"}]", - required = true, dataType = "ActionModel") - public List getActions() { - if (actions == null) { - actions = new java.util.ArrayList<>(); - } - return actions; - } - - public void setActions(List actions) { - this.actions = actions; - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/PermissionRoleModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/PermissionRoleModel.java deleted file mode 100644 index 171c3e54f..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/PermissionRoleModel.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.hswebframework.web.commons.model.Model; - -import java.util.List; - -/** - * - * @author zhouhao - */ -@ApiModel(value = "PermissionRoleModel", description = "权限配置") -public interface PermissionRoleModel extends Model { -// -// @ApiModelProperty(value = "角色ID", required = true, example = "admin") -// String getRoleId(); -// -// void setRoleId(String roleId); - - @ApiModelProperty(value = "权限ID", required = true, example = "user") - String getPermissionId(); - - void setPermissionId(String permissionId); - - @ApiModelProperty(value = "可操作事件" -// , example = "[\"query\",\"add\"]" - ) - List getActions(); - - void setActions(List actions); - - @ApiModelProperty(value = "数据级权限控制配置", dataType = "DataAccessModel") - List getDataAccesses(); - - void setDataAccesses(List dataAccesses); - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimplePermissionRoleModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimplePermissionRoleModel.java deleted file mode 100644 index 2aec2f3bf..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimplePermissionRoleModel.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import java.util.Collections; -import java.util.List; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class SimplePermissionRoleModel implements PermissionRoleModel { -// private String roleId; - - private String permissionId; - - private List actions; - - private List dataAccesses; - - @Override - public String getPermissionId() { - return permissionId; - } - - @Override - public void setPermissionId(String permissionId) { - this.permissionId = permissionId; - } - - @Override - public List getActions() { - if (this.actions == null) { - return new java.util.ArrayList<>(); - } - return actions; - } - - @Override - public void setActions(List actions) { - this.actions = actions; - } - - @Override - public List getDataAccesses() { - if (this.dataAccesses == null) { - return new java.util.ArrayList<>(); - } - return this.dataAccesses; - } - - @Override - public void setDataAccesses(List dataAccesses) { - this.dataAccesses = dataAccesses; - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimpleUserModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimpleUserModel.java deleted file mode 100644 index e8a680581..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/SimpleUserModel.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - - -import org.hibernate.validator.constraints.NotBlank; - -/** - * @author zhouhao - */ -public class SimpleUserModel implements UserModel { - - @NotBlank - private String name; - - @NotBlank - private String username; - - @NotBlank - private String password; - - @Override - public String getName() { - return name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public String getUsername() { - return username; - } - - @Override - public void setUsername(String username) { - this.username = username; - } - - @Override - public String getPassword() { - return password; - } - - @Override - public void setPassword(String password) { - this.password = password; - } - -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/UserModel.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/UserModel.java deleted file mode 100644 index d8bc07c79..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/java/org/hswebframework/web/authorization/controller/model/UserModel.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2019 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.authorization.controller.model; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.hswebframework.web.commons.model.Model; - -/** - * @author zhouhao - */ -@ApiModel(value = "UserModel", description = "用户信息") -public interface UserModel extends Model { - void setName(String name); - - @ApiModelProperty(value = "用户名", required = true, readOnly = true) - String getUsername(); - - void setUsername(String username); - - @ApiModelProperty(value = "用户姓名", required = true) - String getName(); - - void setPassword(String password); - - @ApiModelProperty(value = "密码", required = true) - String getPassword(); -} diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/resources/hsweb-module.json b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/resources/hsweb-module.json deleted file mode 100644 index f809ee903..000000000 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/resources/hsweb-module.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "groupId": "${project.groupId}", - "artifactId": "${project.artifactId}", - "path": "hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web", - "gitCommitHash": "${git.commit.hash}", - "gitRepository": "http://github.com/hs-web/hsweb-framework", - "version": "${project.version}", - "comment": "权限管理Web层" -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/pom.xml b/hsweb-system/hsweb-system-authorization/pom.xml index b85e88e5a..36c223271 100644 --- a/hsweb-system/hsweb-system-authorization/pom.xml +++ b/hsweb-system/hsweb-system-authorization/pom.xml @@ -11,13 +11,13 @@ 业务模块-权限管理 hsweb-system-authorization - pom - - hsweb-system-authorization-starter - hsweb-system-authorization-api - hsweb-system-authorization-local - hsweb-system-authorization-web - + + + org.hswebframework.web + hsweb-commons-crud + ${project.version} + + \ No newline at end of file diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ActionEntity.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ActionEntity.java new file mode 100644 index 000000000..8543418f3 --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ActionEntity.java @@ -0,0 +1,18 @@ +package org.hswebframework.web.system.authorization.entity; + +import lombok.Getter; +import lombok.Setter; +import org.hswebframework.web.crud.entity.Entity; + +import java.util.Map; + +@Getter +@Setter +public class ActionEntity implements Entity { + + private String action; + + private String describe; + + private Map properties; +} diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/OptionalField.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/OptionalField.java new file mode 100644 index 000000000..665920428 --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/OptionalField.java @@ -0,0 +1,17 @@ +package org.hswebframework.web.system.authorization.entity; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import org.hswebframework.web.crud.entity.Entity; + +import java.util.Map; + +@Data +public class OptionalField implements Entity { + private String name; + + private String describe; + + private Map properties; +} diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ParentPermission.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ParentPermission.java new file mode 100644 index 000000000..32694f3db --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/ParentPermission.java @@ -0,0 +1,22 @@ +package org.hswebframework.web.system.authorization.entity; + +import lombok.Data; +import org.hswebframework.web.crud.entity.Entity; + +import java.util.Map; +import java.util.Set; + +@Data +public class ParentPermission implements Entity { + + private static final long serialVersionUID = -7099575758680437572L; + + private String permission; + + private Set preActions; + + private Set actions; + + private Map properties; + +} diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/PermissionEntity.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/PermissionEntity.java new file mode 100644 index 000000000..5d186e7a3 --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/PermissionEntity.java @@ -0,0 +1,59 @@ +package org.hswebframework.web.system.authorization.entity; + +import lombok.Data; +import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; +import org.hswebframework.ezorm.rdb.mapping.annotation.Comment; +import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.sql.JDBCType; +import java.util.List; +import java.util.Map; + +@Table(name = "s_permission") +@Data +public class PermissionEntity { + + @Id + @Column(length = 32) + private String id; + + @Column + @Comment("权限名称") + private String name; + + @Column + @Comment("说明") + private String describe; + + @Column + @Comment("状态") + private Byte status; + + @Column + @ColumnType(jdbcType = JDBCType.CLOB) + @JsonCodec + @Comment("可选操作") + private List actions; + + @Column(name = "optional_fields") + @ColumnType(jdbcType = JDBCType.CLOB) + @JsonCodec + @Comment("可操作的字段") + private List optionalFields; + + @Column + @ColumnType(jdbcType = JDBCType.CLOB) + @JsonCodec + @Comment("关联权限") + private List parents; + + @Column + @ColumnType(jdbcType = JDBCType.CLOB) + @JsonCodec + @Comment("其他配置") + private Map properties; + +} diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/UserEntity.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/UserEntity.java new file mode 100644 index 000000000..deba1c6a8 --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/entity/UserEntity.java @@ -0,0 +1,54 @@ +package org.hswebframework.web.system.authorization.entity; + +import lombok.Getter; +import lombok.Setter; +import org.hswebframework.web.bean.ToString; +import org.hswebframework.web.crud.entity.Entity; +import org.hswebframework.web.crud.entity.RecordCreationEntity; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.Table; +import javax.validation.constraints.NotBlank; + +@Getter +@Setter +@Table(name = "s_user", indexes = +@Index(name = "user_username_idx", columnList = "username", unique = true) +) +public class UserEntity implements RecordCreationEntity, Entity { + + @Id + @Column(length = 32) + private String id; + + @Column(length = 128, nullable = false) + @NotBlank(message = "姓名不能为空") + private String name; + + @Column(length = 128, nullable = false, updatable = false) + private String username; + + @Column(nullable = false) + @ToString.Ignore(cover = false) + private String password; + + @Column(nullable = false) + @ToString.Ignore(cover = false) + private String salt; + + @Column + private String type; + + @Column + private Byte status; + + @Column(name = "creator_id", updatable = false) + private String creatorId; + + @Column(name = "create_time", updatable = false) + private Long createTime; + + +} diff --git a/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/enums/UserState.java b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/enums/UserState.java new file mode 100644 index 000000000..1e7dca4b4 --- /dev/null +++ b/hsweb-system/hsweb-system-authorization/src/main/java/org/hswebframework/web/system/authorization/enums/UserState.java @@ -0,0 +1,22 @@ +package org.hswebframework.web.system.authorization.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.hswebframework.web.dict.Dict; +import org.hswebframework.web.dict.EnumDict; + +@Getter +@AllArgsConstructor +@Dict("user-state") +public enum UserState implements EnumDict { + enabled("正常"), disabled("已禁用"); + + private String text; + + @Override + public String getValue() { + return name(); + } + + +} diff --git a/hsweb-system/hsweb-system-config/README.md b/hsweb-system/hsweb-system-config/README.md deleted file mode 100644 index a1f9546e8..000000000 --- a/hsweb-system/hsweb-system-config/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## 配置管理功能 -管理配置,可在线更新配置信息,实时生效 - -##API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-api/pom.xml b/hsweb-system/hsweb-system-config/hsweb-system-config-api/pom.xml deleted file mode 100644 index f6d37c608..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-api/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - hsweb-system-config - org.hswebframework.web - 4.0.0-SNAPSHOT - - ../pom.xml - - 4.0.0 - - hsweb-system-config-api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigContent.java b/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigContent.java deleted file mode 100644 index 2185dd225..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigContent.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.hswebframework.web.entity.config; - -import org.hswebframework.web.commons.entity.CloneableEntity; - -import java.math.BigDecimal; - -public class ConfigContent implements CloneableEntity { - private String key; - - private Object value; - - private String comment; - - public ConfigContent() { - } - - public ConfigContent(String key, Object value, String comment) { - this.key = key; - this.value = value; - this.comment = comment; - } - - public String getKey() { - return key; - } - - public Object getValue() { - return value; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public void setKey(String key) { - this.key = key; - } - - public void setValue(Object value) { - this.value = value; - } - - public Number getNumber(Number defaultValue) { - Object val = getValue(); - if (null == val) { - return defaultValue; - } - if (val instanceof Number) { - return ((Number) val); - } - if (val instanceof String) { - return new BigDecimal(((String) val)); - } - return defaultValue; - } - - public Object getValue(Object defaultValue) { - Object val = getValue(); - if (val == null) { - return defaultValue; - } - return val; - } - - @Override - public ConfigContent clone() { - Object val = value; - if (val instanceof CloneableEntity) { - val = ((CloneableEntity) val).clone(); - } - return new ConfigContent(key, val, comment); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigEntity.java b/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigEntity.java deleted file mode 100644 index 90b59ecc6..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/ConfigEntity.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * * Copyright 2019 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.config; - - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; - -import java.util.List; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface ConfigEntity extends GenericEntity,RecordCreationEntity { - - /** - * 获取 备注 - * - * @return String 备注 - */ - String getRemark(); - - /** - * 设置 备注 - * - * @param remark 备注 - */ - void setRemark(String remark); - - /** - * 获取 配置内容 - * - * @return String 配置内容 - */ - List getContent(); - - /** - * 设置 配置内容 - * - * @param content 配置内容 - */ - void setContent(List content); - - /** - * 获取 最后一次修改日期 - * - * @return java.util.Date 最后一次修改日期 - */ - Long getUpdateTime(); - - /** - * 设置 最后一次修改日期 - * - * @param updateDate 最后一次修改日期 - */ - void setUpdateTime(Long updateDate); - - /** - * 获取分类ID - * - * @return 分类ID - */ - String getClassifiedId(); - - /** - * 设置分类ID - * - * @param classifiedId 分类ID - */ - void setClassifiedId(String classifiedId); - - ConfigEntity addContent(String key, Object value, String comment); - - ConfigContent get(String key); -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/SimpleConfigEntity.java b/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/SimpleConfigEntity.java deleted file mode 100644 index 17fb3309f..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/entity/config/SimpleConfigEntity.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * - * * Copyright 2019 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.config; - - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import javax.validation.constraints.NotNull; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author zhouhao - */ -public class SimpleConfigEntity extends SimpleGenericEntity implements ConfigEntity { - - //备注 - private String remark; - - //配置内容 - private List content; - - //创建日期 - @NotNull - private Long createTime; - - //最后一次修改日期 - private Long updateTime; - - //配置分类ID - private String classifiedId; - - @NotNull - private String creatorId; - - private volatile Map cache; - - @Override - public String getCreatorId() { - return creatorId; - } - - @Override - public void setCreatorId(String creatorId) { - this.creatorId = creatorId; - } - - @Override - public String getRemark() { - return remark; - } - - @Override - public void setRemark(String remark) { - this.remark = remark; - } - - @Override - public List getContent() { - return content; - } - - @Override - public ConfigEntity addContent(String key, Object value, String comment) { - if (content == null) { - content = new ArrayList<>(); - } - content.add(new ConfigContent(key, value, comment)); - return this; - } - - @Override - public ConfigContent get(String key) { - if (cache == null) { - synchronized (this) { - if (cache == null) { - if (content == null || content.isEmpty()) { - return null; - } - cache = content.stream() - .collect(Collectors.toMap(ConfigContent::getKey, content -> content)); - } - } - } - return cache.get(key); - } - - @Override - public void setContent(List content) { - this.content = content; - } - - @Override - public Long getCreateTime() { - return createTime; - } - - @Override - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - @Override - public Long getUpdateTime() { - return updateTime; - } - - @Override - public void setUpdateTime(Long updateTime) { - this.updateTime = updateTime; - } - - @Override - public String getClassifiedId() { - return classifiedId; - } - - @Override - public void setClassifiedId(String classifiedId) { - this.classifiedId = classifiedId; - } - - @Override - public SimpleConfigEntity clone() { - SimpleConfigEntity cloned = new SimpleConfigEntity(); - cloned.setId(getId()); - cloned.setCreatorId(getCreatorId()); - this.setCreateTime(getCreateTime()); - cloned.content = getContent().stream().map(ConfigContent::clone).collect(Collectors.toList()); - return cloned; - } -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/service/config/ConfigService.java b/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/service/config/ConfigService.java deleted file mode 100644 index 1c24a5fe3..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-api/src/main/java/org/hswebframework/web/service/config/ConfigService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019 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.config; - -import org.hswebframework.web.entity.config.ConfigEntity; -import org.hswebframework.web.service.CrudService; - -/** - * @author zhouhao - */ -public interface ConfigService extends CrudService { - Number getNumber(String configId, String key, Number defaultValue); - - String getString(String configId, String key, String defaultValue); - - boolean getBoolean(String configId, String key, boolean defaultValue); - -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-local/pom.xml b/hsweb-system/hsweb-system-config/hsweb-system-config-local/pom.xml deleted file mode 100644 index 6ab007a1c..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-local/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - hsweb-system-config - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-config-local - - - org.hswebframework.web - hsweb-system-config-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/dao/config/ConfigDao.java b/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/dao/config/ConfigDao.java deleted file mode 100644 index 2912f5d3c..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/dao/config/ConfigDao.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019 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.config; - -import org.hswebframework.web.entity.config.ConfigEntity; -import org.hswebframework.web.dao.CrudDao; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface ConfigDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/service/config/simple/SimpleConfigService.java b/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/service/config/simple/SimpleConfigService.java deleted file mode 100644 index d8d99246d..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/java/org/hswebframework/web/service/config/simple/SimpleConfigService.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019 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.config.simple; - -import org.hswebframework.web.dao.config.ConfigDao; -import org.hswebframework.web.entity.config.ConfigContent; -import org.hswebframework.web.entity.config.ConfigEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.EnableCacheAllEvictGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.config.ConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.Optional; - -/** - * @author zhouhao - */ -@Service("configService") -@CacheConfig(cacheNames = "hsweb-config") -public class SimpleConfigService extends EnableCacheAllEvictGenericEntityService - implements ConfigService { - - @Autowired - private ConfigDao configDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public ConfigDao getDao() { - return configDao; - } - - protected Optional getConfigContent(String configId, String key) { - ConfigEntity entity = selectByPk(configId); - if (entity == null) { - return Optional.empty(); - } - return Optional.ofNullable(entity.get(key)); - - } - - @Override - @Cacheable(key = "'id:'+#configId+'.'+#key+'-as-number'") - public Number getNumber(String configId, String key, Number defaultValue) { - - return getConfigContent(configId, key) - .map(conf -> conf.getNumber(defaultValue)) - .orElse(defaultValue); - } - - @Override - @Cacheable(key = "'id:'+#configId+'.'+#key+'-as-string'") - public String getString(String configId, String key, String defaultValue) { - return getConfigContent(configId, key) - .map(conf -> conf.getValue(defaultValue)) - .map(String::valueOf) - .orElse(defaultValue); - } - - @Override - @Cacheable(key = "'id:'+#configId+'.'+#key+'-as-boolean'") - public boolean getBoolean(String configId, String key, boolean defaultValue) { - return getConfigContent(configId, key) - .map(conf -> conf.getValue(defaultValue)) - .map(val -> Boolean.TRUE.equals(val) || Integer.valueOf(1).equals(val)) - .orElse(defaultValue); - } -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/config/ConfigMapper.xml b/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/config/ConfigMapper.xml deleted file mode 100644 index 94e555782..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/config/ConfigMapper.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/pom.xml b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/pom.xml deleted file mode 100644 index 175ba71f4..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - hsweb-system-config - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-config-starter - - - - - src/main/resources - true - - - - - - - - org.hswebframework.web - hsweb-system-config-local - ${project.version} - - - org.hswebframework.web - hsweb-system-config-web - ${project.version} - - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/java/org/hswebframework/web/config/starter/ConfigAutoConfiguration.java b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/java/org/hswebframework/web/config/starter/ConfigAutoConfiguration.java deleted file mode 100644 index f8eb64ecf..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/java/org/hswebframework/web/config/starter/ConfigAutoConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2019 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.config.starter; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.config.simple" - , "org.hswebframework.web.controller.config"}) -public class ConfigAutoConfiguration { -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 4263f854c..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.config.starter.ConfigAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 09e24c982..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * * Copyright 2019 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. - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "http://github.com/hs-web/hsweb-framework", - author: "zh.sqy@qq.com", - comment: "配置管理" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.0", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_config") - .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("uid").commit() - .addColumn().name("content").clob().notNull().comment("配置内容").commit() - .addColumn().name("remark").varchar(512).comment("备注").commit() - .addColumn().name("creator_id").varchar(32).notNull().comment("创建人").commit() - .addColumn().name("create_time").number(32).notNull().comment("创建日期").commit() - .addColumn().name("update_time").number(32).comment("修改日期").commit() - .addColumn().name("classified_id").varchar(32).comment("分类id").commit() - .addColumn().name("creator_id").varchar(32).comment("创建者ID").commit() - .comment("系统配置文件表").commit() -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/java/org/hswebframework/web/starter/config/ConfigTests.java b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/java/org/hswebframework/web/starter/config/ConfigTests.java deleted file mode 100644 index f2825c180..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/java/org/hswebframework/web/starter/config/ConfigTests.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.hswebframework.web.starter.config; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.entity.config.ConfigEntity; -import org.hswebframework.web.entity.config.SimpleConfigEntity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.config.ConfigService; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -import java.sql.SQLException; -import java.util.Date; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class ConfigTests extends SimpleWebApplicationTests { - - @Autowired - private SqlExecutor executor; - - @Autowired - private ConfigService configService; - - @After - public void clear() throws SQLException { - executor.delete("delete from s_config"); - } - - @Test - public void testMvc() throws Exception { - //创建bean - ConfigEntity configBean = configService.createEntity(); - Assert.assertEquals(configBean.getClass(), SimpleConfigEntity.class); - configBean.setId(IDGenerator.RANDOM.generate()); - configBean.addContent("test", 1, "测试"); - configBean.setCreateTime(System.currentTimeMillis()); - configBean.setCreatorId("test"); - String jsonStr = JSON.toJSONString(configBean); - - JSONObject jsonObject = testPost("/config") - .setUp(builder -> builder.accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content(jsonStr) - ) - .exec().resultAsJson(); - //{data:id,code:200} - Assert.assertEquals(jsonObject.getString("result"), configBean.getId()); - - JSONObject getRes = testGet("/config/" + configBean.getId()).exec().resultAsJson(); - Assert.assertEquals(getRes - .getObject("result", SimpleConfigEntity.class) - .get("test") - .getNumber(0).intValue(), 1); - - getRes = testGet("/config").setUp(builder -> - builder.param("terms[0].column", "id") - .param("terms[0].value", configBean.getId()) - ).exec().resultAsJson(); - Assert.assertEquals(getRes.getJSONObject("result").getJSONArray("data") - .getObject(0, SimpleConfigEntity.class) - .get("test") - .getNumber(0).intValue(), 1); - - jsonObject = testPut("/config/" + configBean.getId()) - .setUp(builder -> builder.accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content(jsonStr) - ) - .exec().resultAsJson(); - Assert.assertEquals(200, jsonObject.get("status")); - } - - @Test - public void test() throws SQLException { - //判断是否安装成功 - boolean installSuccess = executor.tableExists("s_config"); - Assert.assertTrue(installSuccess); - //创建bean - ConfigEntity configBean = configService.createEntity(); - Assert.assertEquals(configBean.getClass(), SimpleConfigEntity.class); - configBean.setId(IDGenerator.RANDOM.generate()); - configBean.addContent("test", 1, "测试"); - configBean.setCreateTime(System.currentTimeMillis()); - configBean.setCreatorId("test"); - //test insert - configService.insert(configBean); - Assert.assertEquals(configBean.get("test").getNumber(0), 1); - configBean = configService.selectSingle(QueryParamEntity.empty()); - configBean.addContent("test2", "2", ""); - //test update - Assert.assertEquals(configService.updateByPk(configBean.getId(), configBean), 1); - Assert.assertEquals(configBean.get("test2").getNumber(0).intValue(), 2); - configBean = configService.selectSingle(QueryParamEntity.empty()); - //test delete - configService.deleteByPk(configBean.getId()); - Assert.assertEquals(configService.count(QueryParamEntity.empty()), 0); - } - -} diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/resources/application.yml deleted file mode 100644 index 051171eb9..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/resources/application.yml +++ /dev/null @@ -1,16 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:config_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 配置管理测试 - version: 3.0.0 - web: - mappings: - config: /config #default \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-web/pom.xml b/hsweb-system/hsweb-system-config/hsweb-system-config-web/pom.xml deleted file mode 100644 index b1e21cd84..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-web/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - hsweb-system-config - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-config-web - - - - - org.hswebframework.web - hsweb-system-config-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-config/hsweb-system-config-web/src/main/java/org/hswebframework/web/controller/config/ConfigController.java b/hsweb-system/hsweb-system-config/hsweb-system-config-web/src/main/java/org/hswebframework/web/controller/config/ConfigController.java deleted file mode 100644 index 0a16111b6..000000000 --- a/hsweb-system/hsweb-system-config/hsweb-system-config-web/src/main/java/org/hswebframework/web/controller/config/ConfigController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019 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.config; - -import io.swagger.annotations.Api; -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.controller.message.ResponseMessage; -import org.hswebframework.web.entity.config.ConfigEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.config.ConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@RestController -@RequestMapping("${hsweb.web.mappings.config:config}") -@Authorize(permission = "config") -@AccessLogger("配置管理") -@Api(description = "配置管理,用于系统配置信息维护") -public class ConfigController implements GenericEntityController { - - private ConfigService configService; - - @Autowired - public void setConfigService(ConfigService configService) { - this.configService = configService; - } - - @Override - public ConfigService getService() { - return configService; - } - -} diff --git a/hsweb-system/hsweb-system-config/pom.xml b/hsweb-system/hsweb-system-config/pom.xml deleted file mode 100644 index 1652c3edc..000000000 --- a/hsweb-system/hsweb-system-config/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-config - pom - - hsweb-system-config-web - hsweb-system-config-api - hsweb-system-config-local - hsweb-system-config-starter - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml deleted file mode 100644 index f5160137d..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - hsweb-system-dashboard - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dashboard-api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - org.hswebframework.web - hsweb-authorization-api - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java deleted file mode 100644 index f86575f64..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardConfigEntity.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.hswebframework.web.dashboard; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import javax.validation.constraints.NotNull; - -@EqualsAndHashCode(callSuper = true) -@Data -public class DashBoardConfigEntity extends SimpleGenericEntity implements RecordCreationEntity,Comparable { - - private static final long serialVersionUID = 3911748291957287662L; - - @NotBlank(groups = CreateGroup.class) - private String name; - - @NotBlank(groups = CreateGroup.class) - private String type; - - private String template; - - private String script; - - private String scriptLanguage; - - private String permission; - - private Boolean defaultConfig; - - private Byte status; - - @NotBlank(groups = CreateGroup.class) - private String creatorId; - - @NotNull(groups = CreateGroup.class) - private Long createTime; - - private Long sortIndex; - - @Override - public int compareTo(DashBoardConfigEntity o) { - if(sortIndex==null){ - return 0; - } - if(o.sortIndex==null){ - return 1; - } - return Long.compare(sortIndex,o.sortIndex); - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java deleted file mode 100644 index b63aedee8..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/DashBoardService.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.dashboard; - -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -public interface DashBoardService extends CrudService { - - List selectAllDefaults(); -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java deleted file mode 100644 index 0de20666a..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-api/src/main/java/org/hswebframework/web/dashboard/executor/DashBoardExecutor.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hswebframework.web.dashboard.executor; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; - -public interface DashBoardExecutor { - Object execute(DashBoardConfigEntity entity, Authentication authentication); -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml deleted file mode 100644 index 58246d6e0..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - hsweb-system-dashboard - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dashboard-local - - - - org.hswebframework.web - hsweb-system-dashboard-api - ${project.version} - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java deleted file mode 100644 index c3a7b48f1..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DashBoardExecutorStrategy.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dashboard.local; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; - -public interface DashBoardExecutorStrategy { - - boolean support(DashBoardConfigEntity entity); - - Object execute(DashBoardConfigEntity entity, Authentication authentication); -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java deleted file mode 100644 index 222152273..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBoardService.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.dashboard.local; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; -import org.hswebframework.web.dashboard.DashBoardService; -import org.hswebframework.web.dashboard.local.dao.DashBoardConfigDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.EnableCacheAllEvictGenericEntityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -@CacheConfig(cacheNames = "hsweb:dashboard-conf") -public class DefaultDashBoardService extends EnableCacheAllEvictGenericEntityService implements DashBoardService { - - @Autowired - private DashBoardConfigDao dashBoardConfigDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return dashBoardConfigDao; - } - - @Cacheable(key = "'all-defaults'") - public List selectAllDefaults() { - return createQuery().where("defaultConfig", true).or().isNull("defaultConfig").listNoPaging(); - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java deleted file mode 100644 index b8d0eecac..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/DefaultDashBordExecutor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.dashboard.local; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationPredicate; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; -import org.hswebframework.web.dashboard.executor.DashBoardExecutor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -import java.util.List; - -@Component -public class DefaultDashBordExecutor implements DashBoardExecutor { - - @Autowired - private List strategies; - - @Override - public Object execute(DashBoardConfigEntity entity, Authentication authentication) { - - if (entity == null) { - return null; - } - if (StringUtils.hasText(entity.getPermission())) { - AuthenticationPredicate.has(entity.getPermission()).assertHas(authentication); - } - - return strategies.stream() - .filter(strategy -> strategy.support(entity)) - .findFirst() - .map(strategy -> strategy.execute(entity, authentication)) - .orElse(null); - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java deleted file mode 100644 index 95c41dbf0..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/dao/DashBoardConfigDao.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.hswebframework.web.dashboard.local.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; - -public interface DashBoardConfigDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java deleted file mode 100644 index bc37ee26e..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/java/org/hswebframework/web/dashboard/local/strategy/ScriptExecutorStrategy.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.hswebframework.web.dashboard.local.strategy; - -import lombok.SneakyThrows; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; -import org.hswebframework.web.dashboard.local.DashBoardExecutorStrategy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.DigestUtils; -import org.springframework.util.StringUtils; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component -public class ScriptExecutorStrategy implements DashBoardExecutorStrategy { - - @Autowired - private SqlExecutor sqlExecutor; - - static List supportLang = Arrays.asList("js", "javascript", "groovy", "sql"); - - @Override - public boolean support(DashBoardConfigEntity entity) { - return StringUtils.hasText(entity.getScriptLanguage()) && StringUtils.hasText(entity.getScript()) - && supportLang.contains(entity.getScriptLanguage()); - } - - @Override - @SneakyThrows - public Object execute(DashBoardConfigEntity entity, Authentication authentication) { - Map scriptContext = new HashMap<>(); - - scriptContext.put("autz", authentication); - - if ("sql".equals(entity.getScriptLanguage())) { - return sqlExecutor.list(entity.getScript(), scriptContext); - } - - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(entity.getScriptLanguage()); - if (engine != null) { - String id = DigestUtils.md5DigestAsHex(entity.getScript().getBytes()); - - if (!engine.compiled(id)) { - engine.compile(id, entity.getScript()); - } - - return engine.execute(id, scriptContext).getIfSuccess(); - } - - return null; - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml deleted file mode 100644 index ae3fba366..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dashboard/DashBoardConfigMapper.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml deleted file mode 100644 index caea7c84a..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - hsweb-system-dashboard - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dashboard-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-dashboard-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-dashboard-web - ${project.version} - - - org.mybatis - mybatis-spring - 1.3.0 - true - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboardAutoConfiguration.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboardAutoConfiguration.java deleted file mode 100644 index b81bf27ce..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/java/org/hswebframework/web/dashboard/starter/DashboardAutoConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.dashboard.starter; - -import org.hswebframework.web.dao.Dao; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.dashboard.local" - , "org.hswebframework.web.controller.dashboard"}) -@MapperScan(value = "org.hswebframework.web.dashboard.local.dao", markerInterface = Dao.class) -public class DashboardAutoConfiguration { -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 82fafa913..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.dashboard.starter.DashboardAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 3e7f85490..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,52 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "仪表盘配置" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; - -function install(context) { - var database = context.database; - database.createOrAlter("s_dashboard_conf") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("配置名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("type").alias("type").comment("配置类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("template").alias("template").comment("模板").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("script").alias("script").comment("脚本").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("script_lang").alias("scriptLanguage").comment("脚本语言").varchar(32).commit() - .addColumn().name("permission").alias("permission").comment("权限设置").varchar(512).commit() - .addColumn().name("creator_id").alias("creatorId").comment("创建人").varchar(32).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").number(32).commit() - .addColumn().name("sort_index").alias("sortIndex").comment("排序").number(32).commit() - .addColumn().name("status").alias("status").comment("状态").number(4).commit() - .addColumn().name("is_default").alias("defaultConfig").comment("是否默认").number(2).commit() - .comment("仪表盘配置").commit(); -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml deleted file mode 100644 index 45fd7826c..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - hsweb-system-dashboard - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dashboard-web - - - - - org.hswebframework.web - hsweb-system-dashboard-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - org.springframework - spring-webmvc - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java deleted file mode 100644 index 892c6df61..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardConfigController.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.hswebframework.web.controller.dashboard; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; -import org.hswebframework.web.dashboard.DashBoardService; -import org.hswebframework.web.dashboard.executor.DashBoardExecutor; -import org.hswebframework.web.service.CrudService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/dashboard") -@Api(tags = "仪表盘-配置", value = "仪表盘配置") -@Authorize(permission = "dashboard", description = "仪表盘配置") -public class DashBoardConfigController implements SimpleGenericEntityController { - - @Autowired - DashBoardService dashBoardService; - - @Autowired - DashBoardExecutor dashBoardExecutor; - - @Override - public CrudService getService() { - return dashBoardService; - } - - - @Override - public ResponseMessage add(@RequestBody DashBoardConfigEntity data) { - Authentication.current().ifPresent(a -> data.setCreatorId(a.getUser().getId())); - return SimpleGenericEntityController.super.add(data); - } - - @Override - public ResponseMessage saveOrUpdate(@RequestBody DashBoardConfigEntity data) { - Authentication.current().ifPresent(a -> data.setCreatorId(a.getUser().getId())); - return SimpleGenericEntityController.super.saveOrUpdate(data); - } - - @GetMapping("{id}/execute") - @Authorize(merge = false) - @ApiOperation("执行仪表盘配置") - public ResponseMessage execute(@PathVariable String id) { - return ResponseMessage.ok(dashBoardExecutor.execute(dashBoardService.selectByPk(id), Authentication.current().orElse(null))); - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardUserConfigController.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardUserConfigController.java deleted file mode 100644 index ce4b0f5ab..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/DashBoardUserConfigController.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.hswebframework.web.controller.dashboard; - -import com.alibaba.fastjson.JSON; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationPredicate; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.controller.dashboard.model.UserDashBoardResponse; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.dashboard.DashBoardConfigEntity; -import org.hswebframework.web.dashboard.DashBoardService; -import org.hswebframework.web.entity.authorization.UserSettingEntity; -import org.hswebframework.web.service.authorization.UserSettingService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -@RestController -@RequestMapping("/dashboard-user") -@Api(tags = "仪表盘-用户配置", value = "仪表盘用户配置") -@Authorize -public class DashBoardUserConfigController { - - @Autowired - private UserSettingService userSettingService; - - @Autowired - private DashBoardService dashBoardService; - - @GetMapping("/all") - @ApiOperation("获取用户可选择的仪表盘配置") - public ResponseMessage> getUserAllDashBoardConfig(Authentication authentication) { - List configList = dashBoardService.select() - .stream() - .filter(Objects::nonNull) - .filter(config-> DataStatus.STATUS_ENABLED.equals(config.getStatus())) - //过滤权限 - .filter(config -> StringUtils.isEmpty(config) || - AuthenticationPredicate.has(config.getPermission()).test(authentication)) - .map(config -> config.copyTo(new UserDashBoardResponse())) - .collect(Collectors.toList()); - return ResponseMessage.ok(configList); - } - - @GetMapping - @ApiOperation("获取用户自定义的仪表盘配置") - public ResponseMessage> getUserConfigDashBoardConfig(Authentication authentication) { - UserSettingEntity settingEntity = userSettingService.selectByUser(authentication.getUser().getId(), "dashboard-config", "current"); - List configs; - - if (settingEntity == null) { - configs = dashBoardService.selectAllDefaults(); - Collections.sort(configs); - } else { - List ids = JSON.parseArray(settingEntity.getSetting(), String.class); - configs = dashBoardService.selectByPk(ids); - configs.sort(Comparator.comparing(conf -> ids.indexOf(conf.getId()))); - } - List configList = configs.stream() - //过滤权限 - .filter(config -> DataStatus.STATUS_ENABLED.equals(config.getStatus())&&(!StringUtils.hasText(config.getPermission()) || - AuthenticationPredicate.has(config.getPermission()).test(authentication))) - .map(config -> config.copyTo(new UserDashBoardResponse())) - .collect(Collectors.toList()); - - return ResponseMessage.ok(configList); - } - - @PutMapping - @ApiOperation("保存用户自定义的仪表盘配置") - public ResponseMessage saveUserDashBoardConfig(@RequestBody List configIdList, Authentication authentication) { - UserSettingEntity settingEntity = userSettingService.selectByUser(authentication.getUser().getId(), "dashboard-config", "current"); - if (settingEntity == null) { - settingEntity = userSettingService.createEntity(); - settingEntity.setUserId(authentication.getUser().getId()); - settingEntity.setKey("dashboard-config"); - settingEntity.setSettingId("current"); - } - settingEntity.setSetting(JSON.toJSONString(configIdList)); - userSettingService.saveOrUpdate(settingEntity); - - return ResponseMessage.ok(); - } -} diff --git a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/model/UserDashBoardResponse.java b/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/model/UserDashBoardResponse.java deleted file mode 100644 index d79583cad..000000000 --- a/hsweb-system/hsweb-system-dashboard/hsweb-system-dashboard-web/src/main/java/org/hswebframework/web/controller/dashboard/model/UserDashBoardResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.controller.dashboard.model; - -import io.swagger.annotations.ApiModel; -import lombok.Data; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@ApiModel("用户自定义仪表盘配置") -public class UserDashBoardResponse { - private String id; - - private String type; - - private String name; - - private String template; - -// private Object data; - -} diff --git a/hsweb-system/hsweb-system-dashboard/pom.xml b/hsweb-system/hsweb-system-dashboard/pom.xml deleted file mode 100644 index bc6d7c847..000000000 --- a/hsweb-system/hsweb-system-dashboard/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dashboard - pom - - hsweb-system-dashboard-api - hsweb-system-dashboard-local - hsweb-system-dashboard-web - hsweb-system-dashboard-starter - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/README.md b/hsweb-system/hsweb-system-database-manager/README.md deleted file mode 100644 index 1fd523515..000000000 --- a/hsweb-system/hsweb-system-database-manager/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## 数据库维护功能 -获取数据库表结构,创建、更新表结构,执行sql等 - -##API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/pom.xml b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/pom.xml deleted file mode 100644 index 4eb3fd585..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - hsweb-system-database-manager - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-database-manager-api - 数据库维护接口 - - - - org.hswebframework.web - hsweb-datasource-api - ${project.version} - - - - com.h2database - h2 - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/DatabaseManagerService.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/DatabaseManagerService.java deleted file mode 100644 index 29c9b16ee..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/DatabaseManagerService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.database.manager; - -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.database.manager.sql.SqlExecutor; -import org.hswebframework.web.database.manager.sql.TransactionSqlExecutor; -import org.hswebframework.web.datasource.DynamicDataSource; - -import java.util.List; -import java.util.Map; - -/** - * @author zhouhao - */ -public interface DatabaseManagerService extends SqlExecutor,TransactionSqlExecutor { - Map> getMetas(); -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteRequest.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteRequest.java deleted file mode 100644 index 1a488a66b..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.database.manager; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.List; - -/** - * @author zhouhao - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SqlExecuteRequest implements Serializable{ - private static final long serialVersionUID = 8640714319329779262L; - private List sql; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteResult.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteResult.java deleted file mode 100644 index 1627dd622..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlExecuteResult.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.database.manager; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author zhouhao - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SqlExecuteResult { - - private SqlInfo sqlInfo; - - private Object result; - - private boolean success; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlInfo.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlInfo.java deleted file mode 100644 index c59ded490..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/SqlInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.database.manager; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author zhouhao - */ -@Data -public class SqlInfo implements Serializable { - private static final long serialVersionUID = -2119739552930123239L; - private String sql; - - private String datasourceId; - - private String type; -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/exception/SqlExecuteException.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/exception/SqlExecuteException.java deleted file mode 100644 index 6ed4b6e44..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/exception/SqlExecuteException.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.database.manager.exception; - -import org.hswebframework.web.BusinessException; - -public class SqlExecuteException extends BusinessException { - private static final long serialVersionUID = -2109245893594218935L; - private String sql; - - public SqlExecuteException(String message, Throwable cause, String sql) { - super(message, cause); - this.sql = sql; - } - - public String getSql() { - return sql; - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/ObjectMetadata.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/ObjectMetadata.java deleted file mode 100644 index b5d4f1139..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/ObjectMetadata.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.database.manager.meta; - -import java.io.Serializable; - -/** - * @author zhouhao - */ -public abstract class ObjectMetadata implements Serializable { - - private static final long serialVersionUID = -5672781818170734240L; - - protected String name; - - protected ObjectType type; - - public ObjectType getType() { - return type; - } - - public void setType(ObjectType type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public enum ObjectType { - TABLE,//表 - VIEW,//视图 - SEQUENCES//序列 - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ColumnMetadata.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ColumnMetadata.java deleted file mode 100644 index 8f30eb7be..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ColumnMetadata.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table; - -import lombok.Data; - -import java.io.Serializable; -import java.sql.JDBCType; -import java.util.List; - -/** - * @author zhouhao - */ -@Data -public class ColumnMetadata implements Serializable { - private static final long serialVersionUID = 2068679809718583039L; - - /** - * 列名 - */ - private String name; - - /** - * 备注 - */ - private String comment; - - /** - * 数据类型 - */ - private String dataType; - - /** - * 长度 - */ - private int length; - - /** - * 精度 - */ - private int precision; - - /** - * 小数点位数 - */ - private int scale; - - /** - * 是否不能为空 - */ - private boolean notNull; - - /** - * JDBCType - */ - private JDBCType jdbcType; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/Constraint.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/Constraint.java deleted file mode 100644 index 58857a391..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/Constraint.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table; - -import lombok.Data; - -import java.io.Serializable; - -/** - * 约束 - * - * @author zhouhao - * @since 3.0 - */ -@Data -public class Constraint implements Serializable { - private static final long serialVersionUID = 6594361915290310179L; - - /** - * 表名 - * - * @see TableMetadata#getName() - */ - private String table; - - /** - * 列名 - * - * @see ColumnMetadata#getName() - */ - private String column; - - /** - * 约束类型 - */ - private Type type; - - public enum Type { - /** - * 主键 - */ - PrimaryKey, - /** - * 外键 - */ - ForeignKey, - /** - * 唯一约束 - */ - Unique, Check, Default - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ForeignConstraint.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ForeignConstraint.java deleted file mode 100644 index d5609eafe..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/ForeignConstraint.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table; - -import lombok.Data; - -/** - * @author zhouhao - */ -@Data -public class ForeignConstraint extends Constraint { - private static final long serialVersionUID = -7146549641064694467L; - private String targetTable; - - private String targetColumn; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/TableMetadata.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/TableMetadata.java deleted file mode 100644 index b7d14efd4..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/TableMetadata.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table; - -import lombok.*; -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class TableMetadata extends ObjectMetadata { - private static final long serialVersionUID = 1762059989615865556L; - - private String comment; - - private List constraints; - - private List columns; -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/AbstractSqlTableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/AbstractSqlTableMetaDataParser.java deleted file mode 100644 index a0eed8288..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/AbstractSqlTableMetaDataParser.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser; - -import lombok.SneakyThrows; -import org.apache.commons.beanutils.BeanUtilsBean; -import org.hswebframework.ezorm.core.ObjectWrapper; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.ColumnMetadata; -import org.hswebframework.web.database.manager.meta.table.TableMetadata; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.datasource.DatabaseType; - -import java.sql.SQLException; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - -public abstract class AbstractSqlTableMetaDataParser implements TableMetaDataParser, MetaDataParserSupplier { - - private SqlExecutor sqlExecutor; - - private static ColumnMetadataWrapper wrapper = new ColumnMetadataWrapper(); - - public abstract String getSelectTableColumnsSql(); - - public abstract String getSelectTableMetaSql(); - - public abstract String getSelectAllTableSql(); - - public AbstractSqlTableMetaDataParser(SqlExecutor sqlExecutor, DatabaseType... databaseTypes) { - this.sqlExecutor = sqlExecutor; - supportDataBases.addAll(Arrays.asList(databaseTypes)); - } - - private Set supportDataBases = new HashSet<>(); - - @Override - public boolean isSupport(DatabaseType type) { - return supportDataBases.contains(type); - } - - @Override - public MetaDataParser get() { - return this; - } - - @Override - public List parseAll() throws SQLException { - String dsId = DataSourceHolder.switcher().currentDataSourceId(); - return sqlExecutor.list(getSelectAllTableSql()) - .parallelStream() - .map(map -> map.get("name")) - .map(String::valueOf) - .map(tableName -> { - try { - DataSourceHolder.switcher().use(dsId); - return this.parse(tableName); - } finally { - DataSourceHolder.switcher().reset(); - } - }) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - @Override - @SneakyThrows - public TableMetadata parse(String objectName) { - - Map param = new HashMap<>(); - param.put("table", objectName); - - Map tableMetaMap = sqlExecutor.single(getSelectTableMetaSql(), param); - - if (tableMetaMap == null) { - return null; - } - TableMetadata table = new TableMetadata(); - table.setName(objectName); - table.setComment((String) tableMetaMap.getOrDefault("comment", "")); - List columns = sqlExecutor.list(getSelectTableColumnsSql(), param, wrapper); - - table.setColumns(columns); - - return table; - } - - - static class ColumnMetadataWrapper implements ObjectWrapper { - static Map> propertySetters = new HashMap<>(); - - static { - propertySetters.put("name", (columnMetadata, value) -> columnMetadata.setName(String.valueOf(value))); - - } - - @Override - public Class getType() { - return ColumnMetadata.class; - } - - @Override - public ColumnMetadata newInstance() { - return new ColumnMetadata(); - } - - @Override - public void wrapper(ColumnMetadata instance, int index, String attr, Object value) { - try { - BeanUtilsBean.getInstance().setProperty(instance, attr, value); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public boolean done(ColumnMetadata instance) { - return true; - } - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParser.java deleted file mode 100644 index 0f9c81e2f..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParser.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser; - -import org.hswebframework.web.database.manager.meta.ObjectMetadata; - -import java.sql.SQLException; -import java.util.List; - -public interface MetaDataParser { - - List parseAll() throws SQLException; - - M parse(String objectName) throws SQLException; -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserRegister.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserRegister.java deleted file mode 100644 index 3628a7e38..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserRegister.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser; - -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.datasource.DatabaseType; - -public interface MetaDataParserRegister { - void registerMetaDataParser(DatabaseType databaseType, ObjectMetadata.ObjectType objectType, MetaDataParser parser); -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserSupplier.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserSupplier.java deleted file mode 100644 index abb7f942d..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/MetaDataParserSupplier.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser; - -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.datasource.DatabaseType; - -public interface MetaDataParserSupplier { - boolean isSupport(DatabaseType type); - - MetaDataParser get(); -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/TableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/TableMetaDataParser.java deleted file mode 100644 index 8f647061a..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/TableMetaDataParser.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser; - -import org.hswebframework.web.database.manager.meta.table.TableMetadata; - -public interface TableMetaDataParser extends MetaDataParser { - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParser.java deleted file mode 100644 index 7432e2a08..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParser.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.parser.AbstractSqlTableMetaDataParser; -import org.hswebframework.web.datasource.DatabaseType; - -public class H2TableMetaDataParser extends AbstractSqlTableMetaDataParser { - private static final String TABLE_META_SQL = "SELECT " + - "column_name AS \"name\"" + - ",type_name AS \"dataType\"" + - ",character_maximum_length as \"length\"" + - ",numeric_precision as \"precision\"" + - ",numeric_scale as \"scale\"" + - ",case when is_nullable='YES' then 0 else 1 end as \"notNull\"" + - ",remarks as \"comment\" " + - "FROM information_schema.columns WHERE TABLE_NAME = upper(#{table})"; - - private static final String TABLE_COMMENT_SQL = "SELECT " + - "remarks as \"comment\" " + - "FROM information_schema.tables " + - "WHERE table_type='TABLE' and table_name=upper(#{table})"; - - private static final String ALL_TABLE_SQL = "select table_name as \"name\" FROM information_schema.tables where table_type='TABLE'"; - - public H2TableMetaDataParser(SqlExecutor sqlExecutor) { - super(sqlExecutor,DatabaseType.h2); - } - - @Override - public String getSelectTableColumnsSql() { - return TABLE_META_SQL; - } - - @Override - public String getSelectTableMetaSql() { - return TABLE_COMMENT_SQL; - } - - @Override - public String getSelectAllTableSql() { - return ALL_TABLE_SQL; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/MysqlTableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/MysqlTableMetaDataParser.java deleted file mode 100644 index fccbb71ce..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/MysqlTableMetaDataParser.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.parser.AbstractSqlTableMetaDataParser; -import org.hswebframework.web.datasource.DatabaseType; - -public class MysqlTableMetaDataParser extends AbstractSqlTableMetaDataParser { - - private static final String TABLE_META_SQL = " select " + - "column_name as `name`, " + - "data_type as `dataType`, " + - "character_maximum_length as `length`, " + - "numeric_precision as `precision`, " + - "numeric_scale as `scale`, " + - "column_comment as `comment`, " + - "case when is_nullable='YES' then 0 else 1 end as 'notNull' " + - "from information_schema.columns where table_schema=database() and table_name=#{table}"; - - private static final String TABLE_COMMENT_SQL = " select " + - "table_comment as `comment` " + - "from information_schema.tables where table_name=#{table}"; - - private static final String ALL_TABLE_SQL = "select table_name as `name` from information_schema.`TABLES` where table_schema=database()"; - - public MysqlTableMetaDataParser(SqlExecutor sqlExecutor) { - super(sqlExecutor,DatabaseType.mysql); - } - - @Override - public String getSelectTableColumnsSql() { - return TABLE_META_SQL; - } - - @Override - public String getSelectTableMetaSql() { - return TABLE_COMMENT_SQL; - } - - @Override - public String getSelectAllTableSql() { - return ALL_TABLE_SQL; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/OracleTableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/OracleTableMetaDataParser.java deleted file mode 100644 index 3f7e9d0a0..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/OracleTableMetaDataParser.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.parser.AbstractSqlTableMetaDataParser; -import org.hswebframework.web.datasource.DatabaseType; - -public class OracleTableMetaDataParser extends AbstractSqlTableMetaDataParser { - - private final static String TABLE_META_SQL = "select distinct(cols.column_name) as \"name\"" + - ",cols.table_name as \"tableName\"" + - ",cols.data_type as \"dataType\"" + - ",cols.data_length as \"dataLength\"" + - ",cols.data_precision as \"precision\"" + - ",cols.data_scale as \"scale\"" + - ",acc.comments as \"comment\"" + - ",case when cols.nullable='Y' then 0 else 1 end as \"notNull\"" + - ",cols.column_id from user_tab_columns cols " + - "left join all_col_comments acc on acc.column_name=cols.column_name and acc.table_name=cols.table_name " + - "where cols.table_name=upper(#{table}) " + - "order by cols.column_id "; - - private final static String TABLE_COMMENT_SQL = "select comments as \"comment\" from user_tab_comments where table_type='TABLE' and table_name=upper(#{table})"; - - private final static String ALL_TABLE_SQL = "select table_name as \"name\" from user_tab_comments where table_type='TABLE'"; - - public OracleTableMetaDataParser(SqlExecutor sqlExecutor) { - super(sqlExecutor, DatabaseType.oracle); - } - - @Override - public String getSelectTableColumnsSql() { - return TABLE_META_SQL; - } - - @Override - public String getSelectTableMetaSql() { - return TABLE_COMMENT_SQL; - } - - @Override - public String getSelectAllTableSql() { - return ALL_TABLE_SQL; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/PostgresTableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/PostgresTableMetaDataParser.java deleted file mode 100644 index 92d7f0e0c..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/PostgresTableMetaDataParser.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.parser.AbstractSqlTableMetaDataParser; -import org.hswebframework.web.datasource.DatabaseType; - -public class PostgresTableMetaDataParser extends AbstractSqlTableMetaDataParser { - private static final String TABLE_META_SQL = "select column_name as \"name\"" + - " , udt_name as \"dataType\"" + - " , table_name as \"tableName\"" + - " , character_maximum_length as \"dataLength\"" + - " , numeric_precision as \"precision\"" + - " , numeric_scale as \"scale\"" + - " , case when is_nullable = 'YES' then 0 else 1 end as \"notNull\"" + - " ,col_description(a.attrelid,a.attnum) as \"comment\"" + - " from information_schema.columns columns ," + - " pg_class as c,pg_attribute as a" + - " where a.attrelid = c.oid and a.attnum>0 and a.attname = columns.column_name and c.relname=columns.table_name" + - " and table_schema = current_schema()" + - " and table_name = #{table}"; - - private static final String TABLE_COMMENT_SQL = "select cast(obj_description(relfilenode,'pg_class') as varchar)" + - " as \"comment\" from pg_class c" + - " where relname=#{table} and relkind = 'r' and relname not like 'pg_%'" + - " and relname not like 'sql_%'"; - - private static final String ALL_TABLE_SQL = "select table_name as \"name\" from information_schema.TABLES where table_schema=current_schema()"; - - public PostgresTableMetaDataParser(SqlExecutor sqlExecutor) { - super(sqlExecutor, DatabaseType.postgresql); - } - - @Override - public String getSelectTableColumnsSql() { - return TABLE_META_SQL; - } - - @Override - public String getSelectTableMetaSql() { - return TABLE_COMMENT_SQL; - } - - @Override - public String getSelectAllTableSql() { - return ALL_TABLE_SQL; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/SqlServerTableMetaDataParser.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/SqlServerTableMetaDataParser.java deleted file mode 100644 index 59808b5aa..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/meta/table/parser/support/SqlServerTableMetaDataParser.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.parser.AbstractSqlTableMetaDataParser; -import org.hswebframework.web.datasource.DatabaseType; - -public class SqlServerTableMetaDataParser extends AbstractSqlTableMetaDataParser { - private static String TABLE_META_SQL = "SELECT \n" + - "c.name as [name],\n" + - "t.name as [dataType],\n" + - "c.length as [length],\n" + - "c.xscale as [scale],\n" + - "c.xprec as [precision],\n" + - "case when c.isnullable=1 then 0 else 1 end as [notNull],\n" + - "cast(p.value as varchar(500)) as [comment]\n" + - "FROM syscolumns c\n" + - "inner join systypes t on c.xusertype = t.xusertype \n" + - "left join sys.extended_properties p on c.id=p.major_id and c.colid=p.minor_id\n" + - "WHERE c.id = object_id(#{table})"; - - private static String TABLE_COMMENT_SQL = "select cast(p.value as varchar(500)) as [comment] from sys.extended_properties p " + - " where p.major_id=object_id(#{table}) and p.minor_id=0"; - - public SqlServerTableMetaDataParser(SqlExecutor sqlExecutor) { - super(sqlExecutor, DatabaseType.sqlserver, DatabaseType.jtds_sqlserver); - } - - @Override - public String getSelectTableColumnsSql() { - return TABLE_META_SQL; - } - - @Override - public String getSelectTableMetaSql() { - return TABLE_COMMENT_SQL; - } - - @Override - public String getSelectAllTableSql() { - return "select name from sysobjects where xtype='U'"; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/SqlExecutor.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/SqlExecutor.java deleted file mode 100644 index 6e85c156e..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/SqlExecutor.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.database.manager.sql; - -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; - -import java.util.List; - -public interface SqlExecutor { - List execute(SqlExecuteRequest request)throws Exception; -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionInfo.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionInfo.java deleted file mode 100644 index b1b972a48..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.database.manager.sql; - -import lombok.Data; -import org.hswebframework.web.database.manager.SqlInfo; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -@Data -public class TransactionInfo implements Serializable { - private static final long serialVersionUID = -4174268983558799472L; - private String id; - - private List sqlHistory=new ArrayList<>(); - - private Date createTime; - - private Date lastExecuteTime; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionSqlExecutor.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionSqlExecutor.java deleted file mode 100644 index 8aebadae6..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/main/java/org/hswebframework/web/database/manager/sql/TransactionSqlExecutor.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.hswebframework.web.database.manager.sql; - -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.datasource.DynamicDataSource; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; - -public interface TransactionSqlExecutor { - /** - * 开启一个指定默认数据源的事务,并返回事务ID,在其他操作的时候,使用事务ID共享同一个事务 - * - * @param datasourceId 数据源ID {@link DynamicDataSource#getId()} - * @return 事务ID - */ - String newTransaction(String datasourceId); - - /** - * 对默认数据源开启事务,并返回事务ID,在其他操作的时候,使用事务ID共享同一个事务 - * - * @return 事务ID - */ - String newTransaction(); - - /** - * 提交事务 - * - * @param transactionId 事务ID - */ - void commit(String transactionId); - - /** - * 回滚事务 - * - * @param transactionId 事务ID - */ - void rollback(String transactionId); - - /** - * @return 获取全部事务 - */ - List allTransaction(); - - /** - * 执行 - * - * @param transactionId - * @param request - * @return - * @throws Exception - */ - List execute(String transactionId, SqlExecuteRequest request) throws Exception; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/test/src/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParserTest.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/test/src/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParserTest.java deleted file mode 100644 index 500656c10..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-api/src/test/src/org/hswebframework/web/database/manager/meta/table/parser/support/H2TableMetaDataParserTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.database.manager.meta.table.parser.support; - -import org.hswebframework.ezorm.rdb.executor.AbstractJdbcSqlExecutor; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.table.TableMetadata; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -public class H2TableMetaDataParserTest { - H2TableMetaDataParser parser; - - @Before - public void init() throws Exception { - Class.forName("org.h2.Driver"); - Connection connection = DriverManager.getConnection("jdbc:h2:mem:/test;", "sa", ""); - SqlExecutor sqlExecutor = new AbstractJdbcSqlExecutor() { - @Override - public Connection getConnection() { - return connection; - } - - @Override - public void releaseConnection(Connection connection) throws SQLException { - //connection.close(); - } - }; - sqlExecutor.exec("create table test(id varchar(32) not null,name varchar(128) ,age number(32))"); - parser = new H2TableMetaDataParser(sqlExecutor); - } - - @Test - public void testParse() throws SQLException { - TableMetadata metaData = parser.parse("test"); - - Assert.assertNotNull(metaData); - Assert.assertNotNull(metaData.getColumns()); - - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/pom.xml b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/pom.xml deleted file mode 100644 index 065c98687..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - hsweb-system-database-manager - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-database-manager-local - - - - src/main/resources - true - - - - - - org.hswebframework.web - hsweb-system-database-manager-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/DefaultLocalTransactionExecutor.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/DefaultLocalTransactionExecutor.java deleted file mode 100644 index 694751274..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/DefaultLocalTransactionExecutor.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import lombok.SneakyThrows; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.database.manager.SqlInfo; -import org.hswebframework.web.database.manager.exception.SqlExecuteException; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionTemplate; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.concurrent.*; -import java.util.function.Consumer; -import java.util.stream.Collectors; - -/** - * 默认的事务执行器 - * - * @author zhouhao - */ -public class DefaultLocalTransactionExecutor implements TransactionExecutor { - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - private BlockingQueue executionQueue = new LinkedBlockingQueue<>(); - - private SqlExecutor sqlExecutor; - - private SqlRequestExecutor sqlRequestExecutor; - - private String transactionId; - - private String datasourceId; - - private volatile boolean shutdown = false; - - private TransactionStatus transactionStatus; - - private TransactionTemplate transactionTemplate; - - private volatile boolean commit = false; - - private volatile boolean running = false; - - private CountDownLatch waitClose = new CountDownLatch(1); - - public DefaultLocalTransactionExecutor(SqlExecutor sqlExecutor, String transactionId, String datasourceId, TransactionTemplate transactionTemplate) { - this.sqlExecutor = sqlExecutor; - this.transactionId = transactionId; - this.datasourceId = datasourceId; - this.transactionTemplate = transactionTemplate; - } - - @Override - public String getTransactionId() { - return transactionId; - } - - @Override - public String getDatasourceId() { - return datasourceId; - } - - @Override - public void commit() { - commit = true; - shutdown = true; - waitToClose(); - } - - protected void waitToClose() { - try { - executionQueue.add(new NullExecution()); - logger.debug("wait transaction {} close", transactionId); - //等待执行结束 - waitClose.await(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public boolean isRunning() { - return running; - } - - @Override - public void rollback() { - tryRollback(); - waitToClose(); - } - - private void tryRollback() { - running = false; - shutdown = true; - commit = false; - } - - public void setSqlExecutor(SqlExecutor sqlExecutor) { - this.sqlExecutor = sqlExecutor; - } - - public void setSqlRequestExecutor(SqlRequestExecutor sqlRequestExecutor) { - this.sqlRequestExecutor = sqlRequestExecutor; - } - - protected void buildDefaultSqlRequestExecutor() { - sqlRequestExecutor = (executor, sqlInfo) -> new NonTransactionSqlExecutor(executor).doExecute(sqlInfo); - } - - @Override - public void run() { - try { - if (datasourceId != null) { - DataSourceHolder.switcher().use(datasourceId); - } - //开启事务 - transactionStatus = transactionTemplate.getTransactionManager().getTransaction(transactionTemplate); - if (sqlRequestExecutor == null) { - buildDefaultSqlRequestExecutor(); - } - while (!shutdown) { - logger.debug("wait sql execute request {}", transactionId); - Execution execution; - if (transactionTemplate.getTimeout() > 0) { - execution = executionQueue.poll(transactionTemplate.getTimeout(), TimeUnit.MILLISECONDS);//等待有新的sql进来 - if (execution == null) { - throw new TimeoutException("事务[" + transactionId + "]超时"); - } - } else { - execution = executionQueue.take(); - } - if (execution instanceof NullExecution) { - continue; - } - //执行sql - doExecute(execution); - } - } catch (Exception e) { - tryRollback();//回滚 - logger.error("execute sql error {}", transactionId, e); - } finally { - try { - if (commit) { - logger.debug("Commit transaction {}", transactionId); - transactionTemplate.getTransactionManager().commit(transactionStatus); - } else { - logger.debug("Roll Back transaction {}", transactionId); - transactionTemplate.getTransactionManager().rollback(transactionStatus); - } - //结束事务 - waitClose.countDown(); - } finally { - DataSourceHolder.switcher().reset(); - } - } - } - - @SneakyThrows - protected void doExecute(Execution execution) { - running = true; - logger.debug("start execute sql {}", transactionId); - try { - List requests = execution.request.getSql() - .stream() - .map(sqlInfo -> { - try { - if (execution.datasourceId != null) { - DataSourceHolder.switcher().use(execution.datasourceId); - } else { - DataSourceHolder.switcher().useDefault(); - } - //执行sql - return sqlRequestExecutor.apply(sqlExecutor, sqlInfo); - } catch (Exception e) { - return SqlExecuteResult.builder() - .result(e.getMessage()) - .sqlInfo(sqlInfo) - .success(false) - .build(); - } - }) - .collect(Collectors.toList()); - //通过回调返回执行结果 - execution.callback.accept(requests); - } catch (Exception e) { - execution.onError.accept(e); - } finally { - running = false; - } - } - - @Override - public List execute(SqlExecuteRequest request) throws Exception { - if (shutdown) { - throw new UnsupportedOperationException("transaction is close"); - } - //执行倒计时,执行sql是异步的,通过此方式等待sql执行完毕 - CountDownLatch countDownLatch = new CountDownLatch(1); - List results = new ArrayList<>(); - - //异常信息 - Execution execution = new Execution(); - execution.datasourceId = DataSourceHolder.switcher().currentDataSourceId(); - - execution.request = request; - execution.callback = sqlExecuteResults -> { - results.addAll(sqlExecuteResults); - sqlExecuteResults.clear(); - countDownLatch.countDown(); - }; - execution.onError = (e) -> countDownLatch.countDown(); - logger.debug("submit sql execute job {}", transactionId); - executionQueue.add(execution); - //等待sql执行完毕 - countDownLatch.await(); - return results; - } - - private class NullExecution extends Execution { - - } - - protected class Execution { - - protected String datasourceId; - - protected SqlExecuteRequest request; - - protected Consumer> callback; - - protected Consumer onError; - } - - private interface SqlRequestExecutor { - SqlExecuteResult apply(SqlExecutor executor, SqlInfo sqlInfo) throws SQLException; - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/NonTransactionSqlExecutor.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/NonTransactionSqlExecutor.java deleted file mode 100644 index ff71dba04..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/NonTransactionSqlExecutor.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.database.manager.SqlInfo; -import org.hswebframework.web.database.manager.exception.SqlExecuteException; -import org.hswebframework.web.database.manager.sql.SqlExecutor; - -import java.sql.SQLException; -import java.util.List; -import java.util.stream.Collectors; - -public class NonTransactionSqlExecutor implements SqlExecutor { - private org.hswebframework.ezorm.rdb.executor.SqlExecutor executor; - - - public NonTransactionSqlExecutor(org.hswebframework.ezorm.rdb.executor.SqlExecutor executor) { - this.executor = executor; - } - - @Override - public List execute(SqlExecuteRequest request) throws Exception { - return request.getSql().stream().map(this::doExecute).collect(Collectors.toList()); - } - - public SqlExecuteResult doExecute(SqlInfo sqlInfo) { - SqlExecuteResult result = new SqlExecuteResult(); - Object executeResult = null; - try { - switch (sqlInfo.getType().toUpperCase()) { - case "SELECT": - QueryResultWrapper wrapper = new QueryResultWrapper(); - executor.list(sqlInfo.getSql(), wrapper); - executeResult = wrapper.getResult(); - break; - case "INSERT": - case "UPDATE": - executeResult = executor.update(sqlInfo.getSql()); - break; - case "DELETE": - executeResult = executor.delete(sqlInfo.getSql()); - break; - default: - executor.exec(sqlInfo.getSql()); - } - result.setSuccess(true); - } catch (SQLException e) { - throw new SqlExecuteException(e.getMessage(), e, sqlInfo.getSql()); - } - result.setResult(executeResult); - result.setSqlInfo(sqlInfo); - - return result; - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResult.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResult.java deleted file mode 100644 index c85e10648..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResult.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import lombok.Data; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Data -public class QueryResult { - private List columns; - - private List> data=new ArrayList<>(); - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResultWrapper.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResultWrapper.java deleted file mode 100644 index dbc6e8a9c..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/QueryResultWrapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import org.hswebframework.ezorm.core.ObjectWrapper; - -import java.util.ArrayList; -import java.util.List; - -public class QueryResultWrapper implements ObjectWrapper { - private QueryResult result = new QueryResult(); - - private List temp = new ArrayList<>(); - - @Override - public void setUp(List columns) { - result.setColumns(columns); - } - - @Override - public Class getType() { - return QueryResult.class; - } - - @Override - public QueryResult newInstance() { - return result; - } - - @Override - public void wrapper(QueryResult instance, int index, String attr, Object value) { - temp.add(value); - - } - - @Override - public boolean done(QueryResult instance) { - instance.getData().add(new ArrayList<>(temp)); - temp.clear(); - return false; - } - - public QueryResult getResult() { - return result; - } - - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerService.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerService.java deleted file mode 100644 index c1c5008d7..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerService.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.DatabaseManagerService; -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.database.manager.meta.table.parser.MetaDataParser; -import org.hswebframework.web.database.manager.meta.table.parser.MetaDataParserRegister; -import org.hswebframework.web.database.manager.sql.TransactionInfo; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.datasource.DatabaseType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.transaction.support.TransactionTemplate; - -import javax.annotation.PostConstruct; -import java.sql.SQLException; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.stream.Collectors; - -/** - * @author zhouhao - */ -@Slf4j -public class SimpleDatabaseManagerService implements DatabaseManagerService, MetaDataParserRegister { - - private Map transactionExecutorMap = new ConcurrentHashMap<>(); - - private Map transactionInfoMap = new ConcurrentHashMap<>(); - - private ExecutorService executorService; - - private SqlExecutor sqlExecutor; - - private TransactionTemplate transactionTemplate; - - private Map>> parserRepo = new HashMap<>(); - - @Override - public List allTransaction() { - return new ArrayList<>(transactionInfoMap.values()); - } - - @PostConstruct - public void init() { - if (executorService == null) { - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); - } - } - - @Autowired(required = false) - public void setExecutorService(ExecutorService executorService) { - this.executorService = executorService; - } - - @Autowired - public void setTransactionTemplate(TransactionTemplate transactionTemplate) { - this.transactionTemplate = transactionTemplate; - } - - @Autowired - public void setSqlExecutor(SqlExecutor sqlExecutor) { - this.sqlExecutor = sqlExecutor; - } - - @Override - public String newTransaction(String datasourceId) { - String id = UUID.randomUUID().toString(); - DefaultLocalTransactionExecutor executor = new DefaultLocalTransactionExecutor(sqlExecutor, id, datasourceId, transactionTemplate); - transactionExecutorMap.put(id, executor); - executorService.submit(executor); - TransactionInfo info = new TransactionInfo(); - info.setId(id); - info.setCreateTime(new Date()); - transactionInfoMap.put(id, info); - return id; - } - - @Override - public String newTransaction() { - return newTransaction(null); - } - - @Override - public void commit(String transactionId) { - try { - TransactionExecutor executor = transactionExecutorMap.get(transactionId); - if (executor != null) { - executor.commit(); - } - } finally { - transactionExecutorMap.remove(transactionId); - transactionInfoMap.remove(transactionId); - } - } - - @Override - public void rollback(String transactionId) { - try { - TransactionExecutor executor = transactionExecutorMap.get(transactionId); - if (executor != null) { - executor.rollback(); - } - } finally { - transactionExecutorMap.remove(transactionId); - transactionInfoMap.remove(transactionId); - } - } - - @Override - public List execute(String transactionId, SqlExecuteRequest request) throws Exception { - TransactionExecutor executor = transactionExecutorMap.get(transactionId); - if (executor != null) { - TransactionInfo info = transactionInfoMap.get(transactionId); - if (null != info) { - info.setLastExecuteTime(new Date()); - info.getSqlHistory().addAll(request.getSql()); - } - return executor.execute(request); - } - return null; - } - - @Override - public List execute(SqlExecuteRequest request) throws Exception { - return new NonTransactionSqlExecutor(sqlExecutor).execute(request); - } - - @Override - public Map> getMetas() { - return parserRepo - .computeIfAbsent(DataSourceHolder.currentDatabaseType(), t -> new HashMap<>()) - .entrySet() - .stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> { - try { - return entry.getValue().parseAll(); - } catch (SQLException e) { - log.error("parse meta {} error", entry.getKey(), e); - return new ArrayList<>(); - } - })); - } - - @Override - public void registerMetaDataParser(DatabaseType databaseType, ObjectMetadata.ObjectType objectType, MetaDataParser parser) { - parserRepo.computeIfAbsent(databaseType, t -> new HashMap<>()) - .put(objectType, parser); - } -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/TransactionExecutor.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/TransactionExecutor.java deleted file mode 100644 index a43b9901b..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/java/org/hswebframework/web/datasource/manager/simple/TransactionExecutor.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; - -import java.util.List; - -/** - * @author zhouhao - */ -public interface TransactionExecutor extends Runnable { - String getTransactionId(); - - String getDatasourceId(); - - void commit(); - - void rollback(); - - boolean isRunning(); - - List execute(SqlExecuteRequest request)throws Exception; - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/resources/hsweb-module.json b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/resources/hsweb-module.json deleted file mode 100644 index 264cae36d..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local/src/main/resources/hsweb-module.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "groupId": "${project.groupId}", - "artifactId": "${project.artifactId}", - "path": "hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-local", - "gitCommitHash": "${git.commit.hash}", - "gitRepository": "http://github.com/hs-web/hsweb-framework", - "version": "${project.version}" -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/pom.xml b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/pom.xml deleted file mode 100644 index 16bc710c3..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - hsweb-system-database-manager - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-database-manager-starter - - - - org.hswebframework.web - hsweb-system-database-manager-local - ${project.version} - - - org.hswebframework.web - hsweb-system-database-manager-web - ${project.version} - - - - com.alibaba - druid - 1.0.26 - test - - - com.h2database - h2 - test - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/DataBaseManagerAutoConfiguration.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/DataBaseManagerAutoConfiguration.java deleted file mode 100644 index 72e847f78..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/DataBaseManagerAutoConfiguration.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.database.manager; - -import org.hswebframework.web.datasource.manager.simple.SimpleDatabaseManagerService; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan({"org.hswebframework.web.database.manager.web" - , "org.hswebframework.web.datasource.manager.simple"}) -@ImportAutoConfiguration(TableMetaDataParserAutoConfiguration.class) -@AutoConfigureBefore(TableMetaDataParserAutoConfiguration.class) -public class DataBaseManagerAutoConfiguration { - - @Bean - @ConditionalOnMissingBean(DatabaseManagerService.class) - public SimpleDatabaseManagerService simpleDatabaseManagerService() { - return new SimpleDatabaseManagerService(); - } - - -} diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/TableMetaDataParserAutoConfiguration.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/TableMetaDataParserAutoConfiguration.java deleted file mode 100644 index 09bc9129e..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/java/org/hswebframework/web/database/manager/TableMetaDataParserAutoConfiguration.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.hswebframework.web.database.manager; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.database.manager.meta.table.parser.MetaDataParserRegister; -import org.hswebframework.web.database.manager.meta.table.parser.MetaDataParserSupplier; -import org.hswebframework.web.database.manager.meta.table.parser.TableMetaDataParser; -import org.hswebframework.web.database.manager.meta.table.parser.support.*; -import org.hswebframework.web.datasource.DatabaseType; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class TableMetaDataParserAutoConfiguration { - - @Autowired - private SqlExecutor sqlExecutor; - - @Autowired - private MetaDataParserRegister metaDataParserRegister; - - @Bean - @ConditionalOnClass(name = "org.h2.Driver") - public H2TableMetaDataParser h2TableMetaDataParser() { - return new H2TableMetaDataParser(sqlExecutor); - } - - @Bean - @ConditionalOnClass(name = "com.mysql.jdbc.Driver") - public MysqlTableMetaDataParser mysqlTableMetaDataParser() { - return new MysqlTableMetaDataParser(sqlExecutor); - } - - @Bean - @ConditionalOnClass(name = "oracle.jdbc.driver.OracleDriver") - public OracleTableMetaDataParser oracleTableMetaParser() { - return new OracleTableMetaDataParser(sqlExecutor); - } - @Bean - @ConditionalOnClass(name = "org.postgresql.Driver") - public PostgresTableMetaDataParser postgresTableMetaDataParser() { - return new PostgresTableMetaDataParser(sqlExecutor); - } - - - @Bean - @ConditionalOnClass(name = "com.microsoft.sqlserver.jdbc.SQLServerDriver") - public SqlServerTableMetaDataParser sqlServerTableMetaDataParser() { - return new SqlServerTableMetaDataParser(sqlExecutor); - } - - @Bean - @ConditionalOnClass(name = "net.sourceforge.jtds.jdbc.Driver") - public SqlServerTableMetaDataParser jstdSqlServerTableMetaDataParser() { - return new SqlServerTableMetaDataParser(sqlExecutor); - } - - @Bean - public BeanPostProcessor tableMetaDataAutoParserRegister() { - return new BeanPostProcessor() { - @Override - public Object postProcessBeforeInitialization(Object o, String s) throws BeansException { - return o; - } - - @Override - @SuppressWarnings("unchecked") - public Object postProcessAfterInitialization(Object o, String s) throws BeansException { - if (o instanceof MetaDataParserSupplier) { - MetaDataParserSupplier supplier = ((MetaDataParserSupplier) o); - for (DatabaseType databaseType : DatabaseType.values()) { - if (supplier.isSupport(databaseType)) { - metaDataParserRegister.registerMetaDataParser(databaseType, ObjectMetadata.ObjectType.TABLE, supplier.get()); - } - } - } - return o; - } - }; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 21c2b3b3b..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.database.manager.DataBaseManagerAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerServiceTest.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerServiceTest.java deleted file mode 100644 index fe8a2b01d..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerServiceTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.hswebframework.web.datasource.manager.simple; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.database.manager.DatabaseManagerService; -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.database.manager.SqlInfo; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.*; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class SimpleDatabaseManagerServiceTest extends SimpleWebApplicationTests { - - @Autowired - private DatabaseManagerService databaseManagerService; - - @Test - public void testExecuteSql() throws Exception { - String id = databaseManagerService.newTransaction(); - SqlExecuteRequest request = new SqlExecuteRequest(); - SqlInfo sqlInfo = new SqlInfo(); - sqlInfo.setSql("create table t_test(name varchar(32))"); - sqlInfo.setType("create"); - - SqlInfo sqlInfo2 = new SqlInfo(); - sqlInfo2.setSql("insert into t_test values('1234') "); - sqlInfo2.setType("insert"); - - request.setSql(Arrays.asList(sqlInfo)); - List results = databaseManagerService.execute(id, request); -// System.out.println(JSON.toJSONString(results)); - Assert.assertFalse(results.isEmpty()); - request.setSql(Arrays.asList(sqlInfo2)); - int total = 10; - CountDownLatch countDownLatch = new CountDownLatch(total); - - for (int i = 0; i < total; i++) { - new Thread(() -> { - try { - databaseManagerService.execute(id, request); - Thread.sleep(100); - } catch (Exception e) { - throw new RuntimeException(e); - } - countDownLatch.countDown(); - }).start(); - } - countDownLatch.await(30, TimeUnit.SECONDS); - - sqlInfo = new SqlInfo(); - sqlInfo.setSql("select *,name as \"NAME\",1 as \"\" from t_test "); - sqlInfo.setType("select"); - - request.setSql(Arrays.asList(sqlInfo)); - results = databaseManagerService.execute(id, request); - Assert.assertFalse(results.isEmpty()); - -// System.out.println(JSON.toJSONString(results)); - - Assert.assertTrue(sqlExecutor.list("select * from t_test").isEmpty()); - - databaseManagerService.rollback(id); - Assert.assertTrue(sqlExecutor.list("select * from t_test").isEmpty()); - - - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/resources/application.yml deleted file mode 100644 index 3392ad247..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/resources/application.yml +++ /dev/null @@ -1,16 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:dbm_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 数据库管理测试 - version: 3.0.0 -logging: - level: - org.hswebframework: debug \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/pom.xml b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/pom.xml deleted file mode 100644 index 3da25869b..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - hsweb-system-database-manager - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-database-manager-web - - - - org.hswebframework.web - hsweb-system-database-manager-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/src/main/java/org/hswebframework/web/database/manager/web/DataBaseManagerController.java b/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/src/main/java/org/hswebframework/web/database/manager/web/DataBaseManagerController.java deleted file mode 100644 index 66d056c6a..000000000 --- a/hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-web/src/main/java/org/hswebframework/web/database/manager/web/DataBaseManagerController.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.hswebframework.web.database.manager.web; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.hswebframework.web.Sqls; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.database.manager.DatabaseManagerService; -import org.hswebframework.web.database.manager.SqlExecuteRequest; -import org.hswebframework.web.database.manager.SqlExecuteResult; -import org.hswebframework.web.database.manager.SqlInfo; -import org.hswebframework.web.database.manager.meta.ObjectMetadata; -import org.hswebframework.web.database.manager.sql.TransactionInfo; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@RestController -@RequestMapping("/database/manager") -@Api(tags = "开发人员工具-数据库维护", value = "数据库维护") -@Authorize(permission = "database-manager", description = "数据库维护") -public class DataBaseManagerController { - - @Autowired - private DatabaseManagerService databaseManagerService; - - @GetMapping("/metas") - @Authorize(action = Permission.ACTION_QUERY, description = "获取元数据") - @ApiOperation("获取数据库元数据") - public ResponseMessage>> parseAllObject() throws Exception { - return parseAllObject(null); - } - - @GetMapping("/metas/{datasourceId}") - @Authorize(action = Permission.ACTION_QUERY, description = "获取元数据") - @ApiOperation("获取指定数据源的元数据") - public ResponseMessage>> parseAllObject( - @PathVariable - @ApiParam("数据源ID") String datasourceId) throws Exception { - - DataSourceHolder.switcher().use(datasourceId); - return ResponseMessage.ok(databaseManagerService.getMetas()); - } - - @PostMapping(value = "/execute/{datasourceId}", consumes = MediaType.TEXT_PLAIN_VALUE) - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation(value = "指定数据源执行SQL") - public ResponseMessage> execute( - @PathVariable @ApiParam("数据源ID") String datasourceId, - @RequestBody @ApiParam("SQL脚本") String sqlLines) throws Exception { - DataSourceHolder.switcher().use(datasourceId); - return ResponseMessage.ok(databaseManagerService.execute(SqlExecuteRequest.builder() - .sql(parseSql(sqlLines, datasourceId)) - .build())); - - } - - @PostMapping(value = "/execute", consumes = MediaType.TEXT_PLAIN_VALUE) - @ApiOperation(value = "执行SQL") - @Authorize(action = "execute", description = "执行SQL") - public ResponseMessage> execute(@RequestBody - @ApiParam("SQL脚本") String sqlLines) throws Exception { - return ResponseMessage.ok(databaseManagerService - .execute(SqlExecuteRequest.builder() - .sql(parseSql(sqlLines, null)) - .build())); - } - - @PostMapping(value = "/transactional/execute/{transactionalId}", consumes = MediaType.TEXT_PLAIN_VALUE) - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation(value = "开启事务执行SQL") - public ResponseMessage> executeTransactional(@PathVariable @ApiParam("事务ID") String transactionalId, - @ApiParam("SQL脚本") @RequestBody String sqlLines) throws Exception { - return ResponseMessage.ok(databaseManagerService.execute(transactionalId, SqlExecuteRequest.builder() - .sql(parseSql(sqlLines, null)) - .build())); - } - - @PostMapping(value = "/transactional/execute/{transactionalId}/{dataSourceId}", consumes = MediaType.TEXT_PLAIN_VALUE) - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation(value = "开启事务执行指定数据源对SQL") - public ResponseMessage> executeTransactional(@PathVariable @ApiParam("事务ID") String transactionalId, - @PathVariable @ApiParam("数据源ID") String dataSourceId, - @ApiParam("SQL脚本") @RequestBody String sqlLines) throws Exception { - DataSourceHolder.switcher().use(dataSourceId); - return ResponseMessage.ok(databaseManagerService.execute(transactionalId, SqlExecuteRequest.builder() - .sql(parseSql(sqlLines, dataSourceId)) - .build())); - } - - @GetMapping("/transactional/new") - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation("新建事务") - public ResponseMessage newTransaction() throws Exception { - return ResponseMessage.ok(databaseManagerService.newTransaction()); - } - - @GetMapping("/transactional/new/{dataSourceId}") - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation("指定数据源新建事务") - public ResponseMessage newTransaction(@PathVariable String dataSourceId) throws Exception { - DataSourceHolder.switcher().use(dataSourceId); - return ResponseMessage.ok(databaseManagerService.newTransaction(dataSourceId)); - } - - - @GetMapping("/transactional") - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation("获取全部事务信息") - public ResponseMessage> allTransaction() throws Exception { - return ResponseMessage.ok(databaseManagerService.allTransaction()); - } - - @PostMapping("/transactional/{id}/commit") - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation("提交事务") - public ResponseMessage commitTransaction(@PathVariable String id) throws Exception { - databaseManagerService.commit(id); - return ResponseMessage.ok(); - } - - @PostMapping("/transactional/{id}/rollback") - @Authorize(action = "execute", description = "执行SQL") - @ApiOperation("回滚事务") - public ResponseMessage rollbackTransaction(@PathVariable String id) throws Exception { - databaseManagerService.rollback(id); - return ResponseMessage.ok(); - } - - - private List parseSql(String sqlText, String datasourceId) { - // Authentication authentication = Authentication.current().orElse(null); - - List sqlList = Sqls.parse(sqlText); - return sqlList.stream().map(sql -> { - SqlInfo sqlInfo = new SqlInfo(); - sqlInfo.setSql(sql); - sqlInfo.setDatasourceId(datasourceId); - sqlInfo.setType(sql.split("[ ]")[0].toLowerCase()); -// if (authentication != null) { -// if (!authentication.hasPermission("database-manager", sqlInfo.getType())) { -// -// // throw new AccessDenyException("权限不足"); -// } -// } - return sqlInfo; - }).collect(Collectors.toList()); - } - -} diff --git a/hsweb-system/hsweb-system-database-manager/pom.xml b/hsweb-system/hsweb-system-database-manager/pom.xml deleted file mode 100644 index 3e29e6ac2..000000000 --- a/hsweb-system/hsweb-system-database-manager/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-database-manager - pom - 数据库在线维护模块 - - hsweb-system-database-manager-api - hsweb-system-database-manager-local - hsweb-system-database-manager-web - hsweb-system-database-manager-starter - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/README.md b/hsweb-system/hsweb-system-datasource/README.md deleted file mode 100644 index 827285449..000000000 --- a/hsweb-system/hsweb-system-datasource/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## 数据源管理 -动态维护数据源信息,热加载数据源,实现动态数据源以及分布式事务 - -## API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/pom.xml b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/pom.xml deleted file mode 100644 index 15c988e9d..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - hsweb-system-datasource - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 动态数据源配置api - hsweb-system-datasource-api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/DataSourceConfigEntity.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/DataSourceConfigEntity.java deleted file mode 100644 index 9812cce2b..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/DataSourceConfigEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.hswebframework.web.entity.datasource; - -import org.hswebframework.web.commons.entity.GenericEntity; - - -/** - * 数据源配置 实体 - * - * @author hsweb-generator-online - */ -public interface DataSourceConfigEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 数据源名称 - */ - String name = "name"; - /** - * 是否启用 - */ - String enabled = "enabled"; - /** - * 创建日期 - */ - String createDate = "createDate"; - /** - * 备注 - */ - String describe = "describe"; - - /** - * @return 数据源名称 - */ - String getName(); - - /** - * @param name 数据源名称 - */ - void setName(String name); - - /** - * @return 是否启用 - */ - Long getEnabled(); - - /** - * @param enabled 是否启用 - */ - void setEnabled(Long enabled); - - /** - * @return 创建日期 - */ - java.util.Date getCreateDate(); - - /** - * @param createDate 创建日期 - */ - void setCreateDate(java.util.Date createDate); - - /** - * @return 备注 - */ - String getDescribe(); - - /** - * @param describe 备注 - */ - void setDescribe(String describe); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/SimpleDataSourceConfigEntity.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/SimpleDataSourceConfigEntity.java deleted file mode 100644 index b18386b6a..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/entity/datasource/SimpleDataSourceConfigEntity.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.entity.datasource; - -import lombok.*; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 数据源配置 - * - * @author hsweb-generator-online - */ -@EqualsAndHashCode(callSuper = true) -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SimpleDataSourceConfigEntity extends SimpleGenericEntity implements DataSourceConfigEntity { - //数据源名称 - private String name; - //是否启用 - private Long enabled; - //创建日期 - private java.util.Date createDate; - //备注 - private String describe; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/service/datasource/DataSourceConfigService.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/service/datasource/DataSourceConfigService.java deleted file mode 100644 index c69b82438..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-api/src/main/java/org/hswebframework/web/service/datasource/DataSourceConfigService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.datasource; - -import org.hswebframework.web.entity.datasource.DataSourceConfigEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 数据源配置 服务类 - * - * @author hsweb-generator-online - */ -public interface DataSourceConfigService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/pom.xml b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/pom.xml deleted file mode 100644 index 4e9278162..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - hsweb-system-datasource - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 动态数据源配置本地mybatis实现 - - hsweb-system-datasource-local - - - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-datasource-api - ${project.version} - - - org.hswebframework.web - hsweb-datasource-api - ${project.version} - - - org.hswebframework.web - hsweb-datasource-jta - ${project.version} - true - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/dao/datasource/DataSourceConfigDao.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/dao/datasource/DataSourceConfigDao.java deleted file mode 100644 index a2adc7090..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/dao/datasource/DataSourceConfigDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.datasource; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.datasource.DataSourceConfigEntity; - -/** -* 数据源配置 DAO接口 -* @author hsweb-generator-online - */ -public interface DataSourceConfigDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDataSourceRepository.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDataSourceRepository.java deleted file mode 100644 index ccc21ef87..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDataSourceRepository.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.hswebframework.web.service.datasource.simple; - -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.datasource.annotation.UseDefaultDataSource; -import org.hswebframework.web.datasource.config.DynamicDataSourceConfigRepository; -import org.hswebframework.web.entity.datasource.DataSourceConfigEntity; -import org.hswebframework.web.service.datasource.DataSourceConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 1.0 - */ -@Transactional(propagation = Propagation.NOT_SUPPORTED) -public class InDBDataSourceRepository implements DynamicDataSourceConfigRepository { - private DataSourceConfigService dataSourceConfigService; - - public InDBDataSourceRepository(DataSourceConfigService dataSourceConfigService) { - this.dataSourceConfigService = dataSourceConfigService; - } - - public InDBDataSourceRepository() { - } - - public void setDataSourceConfigService(DataSourceConfigService dataSourceConfigService) { - this.dataSourceConfigService = dataSourceConfigService; - } - - protected InDBDynamicDataSourceConfig convert(DataSourceConfigEntity entity) { - if (null == entity) { - return null; - } - Map config = entity.getProperties(); - if (config == null) { - return null; - } - InDBDynamicDataSourceConfig target = FastBeanCopier.copy(config, InDBDynamicDataSourceConfig::new); - target.setId(entity.getId()); - target.setName(entity.getName()); - target.setDescribe(entity.getDescribe()); - target.setProperties(config); - return target; - } - - @Override - public List findAll() { - return dataSourceConfigService.select().stream() - .map(this::convert) - .collect(Collectors.toList()); - } - - @Override - public InDBDynamicDataSourceConfig findById(String dataSourceId) { - return convert(dataSourceConfigService.selectByPk(dataSourceId)); - } - - @Override - public InDBDynamicDataSourceConfig add(InDBDynamicDataSourceConfig config) { - throw new UnsupportedOperationException("add AtomikosDataSourceConfig not support"); - } - - @Override - public InDBDynamicDataSourceConfig remove(String dataSourceId) { - throw new UnsupportedOperationException("remove datasource not support"); - } -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceConfig.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceConfig.java deleted file mode 100644 index 88b057c5f..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.hswebframework.web.service.datasource.simple; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.datasource.config.DynamicDataSourceConfig; - -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -public class InDBDynamicDataSourceConfig extends DynamicDataSourceConfig { - - private static final long serialVersionUID = 89025460456111917L; - - private Map properties; - - @Override - public boolean equals(Object o) { - if (o instanceof InDBDynamicDataSourceConfig) { - return o.hashCode() == hashCode(); - } - return super.equals(o); - } - - @Override - public int hashCode() { - return properties == null ? 0 : properties.hashCode(); - } -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceService.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceService.java deleted file mode 100644 index 7c3ca5783..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBDynamicDataSourceService.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.hswebframework.web.service.datasource.simple; - -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.datasource.DynamicDataSource; -import org.hswebframework.web.datasource.DynamicDataSourceProxy; -import org.hswebframework.web.datasource.annotation.UseDefaultDataSource; -import org.hswebframework.web.datasource.config.DynamicDataSourceConfigRepository; -import org.hswebframework.web.datasource.service.AbstractDynamicDataSourceService; -import org.hswebframework.web.datasource.service.DataSourceCache; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.core.task.TaskExecutor; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ReflectionUtils; - -import javax.sql.DataSource; -import java.io.Closeable; -import java.lang.reflect.Method; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - -/** - * @author zhouhao - * @since 1.0.0 - */ -@Slf4j -@Transactional(propagation = Propagation.NOT_SUPPORTED) -public class InDBDynamicDataSourceService extends AbstractDynamicDataSourceService { - - public InDBDynamicDataSourceService(DynamicDataSourceConfigRepository repository, - DynamicDataSource defaultDataSource) { - - super(repository, defaultDataSource); - } - - ExecutorService executorService = Executors.newFixedThreadPool(2); - - @Override - public DynamicDataSource getDataSource(String dataSourceId) { - try { - DataSourceHolder.switcher().useDefault(); - return super.getDataSource(dataSourceId); - } finally { - DataSourceHolder.switcher().useLast(); - } - } - - protected void closeDataSource(DataSource dataSource) { - if (null == dataSource) { - return; - } - try { - if (dataSource instanceof Closeable) { - ((Closeable) dataSource).close(); - } else { - Method closeMethod = ReflectionUtils.findMethod(dataSource.getClass(), "close"); - if (closeMethod != null) { - ReflectionUtils.invokeMethod(closeMethod, dataSource); - } - } - } catch (Exception e) { - log.warn("关闭数据源[{}]失败", dataSource, e); - } - } - - @Override - @SneakyThrows - protected DataSourceCache createCache(InDBDynamicDataSourceConfig config) { - if (config.getProperties() == null) { - throw new UnsupportedOperationException("配置不存在"); - } - - CountDownLatch initCountDownLatch = new CountDownLatch(1); - DataSourceProperties dataSourceProperties = new DataSourceProperties(); - FastBeanCopier.copy(config.getProperties(), dataSourceProperties); - AtomicReference dataSourceReference = new AtomicReference<>(); - AtomicBoolean closed = new AtomicBoolean(); - AtomicBoolean success = new AtomicBoolean(); - int initTimeOut = Integer.parseInt(String.valueOf(config.getProperties().getOrDefault("InitTimeout", "20"))); - - executorService.submit(() -> { - try { - DataSource dataSource = dataSourceProperties - .initializeDataSourceBuilder() - .build(); - dataSourceReference.set(dataSource); - FastBeanCopier.copy(config.getProperties(), dataSource); - //test datasource init success - dataSource.getConnection().close(); - if (closed.get()) { - closeDataSource(dataSource); - } else { - success.set(true); - } - } catch (Exception e) { - log.warn("初始化数据源[{}]失败", config.getId(), e); - } finally { - initCountDownLatch.countDown(); - } - }); - - try { - @SuppressWarnings("all") - boolean waitSuccess = initCountDownLatch.await(initTimeOut, TimeUnit.SECONDS); - } catch (@SuppressWarnings("all") InterruptedException ignore) { - //ignore - } - if (!success.get()) { - closed.set(true); - closeDataSource(dataSourceReference.get()); - throw new BusinessException("初始化数据源[" + config.getId() + "]失败"); - } - return new DataSourceCache( - config.getProperties().hashCode(), - new DynamicDataSourceProxy(config.getId(), dataSourceReference.get()), - initCountDownLatch, config) { - @Override - public void closeDataSource() { - super.closeDataSource(); - closed.set(true); - InDBDynamicDataSourceService.this.closeDataSource(getDataSource().getNative()); - } - }; - - } -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBJtaDynamicDataSourceService.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBJtaDynamicDataSourceService.java deleted file mode 100644 index 455c6a864..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/InDBJtaDynamicDataSourceService.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.hswebframework.web.service.datasource.simple; - -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.datasource.DatabaseType; -import org.hswebframework.web.datasource.DynamicDataSource; -import org.hswebframework.web.datasource.config.DynamicDataSourceConfigRepository; -import org.hswebframework.web.datasource.jta.AtomikosDataSourceConfig; -import org.hswebframework.web.datasource.jta.JtaDynamicDataSourceService; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 1.0.0 - */ -public class InDBJtaDynamicDataSourceService extends JtaDynamicDataSourceService { - - static AtomikosDataSourceConfig convert(InDBDynamicDataSourceConfig entity) { - if (null == entity) { - return null; - } - Map config = entity.getProperties(); - if (config == null) { - return null; - } - Properties xaProperties = new Properties(); - for (Map.Entry entry : config.entrySet()) { - String key = entry.getKey(); - if (key.startsWith("xaProperties.")) { - xaProperties.put(key.substring("xaProperties.".length()), entry.getValue()); - } - } - AtomikosDataSourceConfig target = FastBeanCopier.copy(config, new AtomikosDataSourceConfig() { - private static final long serialVersionUID = -2704649332301331803L; - - @Override - public int hashCode() { - return entity.hashCode(); - } - - @Override - public boolean equals(Object o) { - return o instanceof AtomikosDataSourceConfig && hashCode() == o.hashCode(); - } - }); - target.setId(entity.getId()); - target.setName(entity.getName()); - target.setDescribe(entity.getDescribe()); - target.setXaProperties(xaProperties); - target.setDatabaseType(Optional.ofNullable(config.get("databaseType")) - .map(String::valueOf) - .map(DatabaseType::valueOf) - .orElse(null)); - return target; - } - - public InDBJtaDynamicDataSourceService(DynamicDataSourceConfigRepository repository, - DynamicDataSource defaultDataSource) { - - super(new DynamicDataSourceConfigRepository() { - @Override - public List findAll() { - return repository.findAll().stream() - .map(InDBJtaDynamicDataSourceService::convert) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - @Override - public AtomikosDataSourceConfig findById(String dataSourceId) { - return convert(repository.findById(dataSourceId)); - } - - @Override - public AtomikosDataSourceConfig add(AtomikosDataSourceConfig config) { - throw new UnsupportedOperationException("不支持添加数据源配置"); - } - - @Override - public AtomikosDataSourceConfig remove(String dataSourceId) { - throw new UnsupportedOperationException("不支持删除数据源配置"); - } - }, defaultDataSource); - } - -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/SimpleDataSourceConfigService.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/SimpleDataSourceConfigService.java deleted file mode 100644 index 9701a0c0f..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/java/org/hswebframework/web/service/datasource/simple/SimpleDataSourceConfigService.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.service.datasource.simple; - -import org.hswebframework.web.dao.datasource.DataSourceConfigDao; -import org.hswebframework.web.entity.datasource.DataSourceConfigEntity; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.datasource.DataSourceConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dataSourceConfigService") -@CacheConfig(cacheNames = "data-source") -public class SimpleDataSourceConfigService extends EnableCacheGenericEntityService - implements DataSourceConfigService { - @Autowired - private DataSourceConfigDao dataSourceConfigDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DataSourceConfigDao getDao() { - return dataSourceConfigDao; - } - -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/datasource/DataSourceConfigMapper.xml b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/datasource/DataSourceConfigMapper.xml deleted file mode 100644 index 665c1dd49..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/datasource/DataSourceConfigMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/pom.xml b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/pom.xml deleted file mode 100644 index 2a45734cf..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - hsweb-system-datasource - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 动态数据源配置整合,集成springMvc,和local实现 - - hsweb-system-datasource-starter - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-datasource-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-datasource-web - ${project.version} - - - - org.hswebframework.web - hsweb-datasource-jta - ${project.version} - true - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/java/org/hswebframework/web/datasource/starter/InDBDynamicDataSourceAutoConfiguration.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/java/org/hswebframework/web/datasource/starter/InDBDynamicDataSourceAutoConfiguration.java deleted file mode 100644 index aa451894d..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/java/org/hswebframework/web/datasource/starter/InDBDynamicDataSourceAutoConfiguration.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2019 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.datasource.starter; - -import org.hswebframework.web.datasource.DynamicDataSourceAutoConfiguration; -import org.hswebframework.web.datasource.DynamicDataSourceProxy; -import org.hswebframework.web.datasource.DynamicDataSourceService; -import org.hswebframework.web.datasource.config.DynamicDataSourceConfigRepository; -import org.hswebframework.web.service.datasource.DataSourceConfigService; -import org.hswebframework.web.service.datasource.simple.InDBDataSourceRepository; -import org.hswebframework.web.service.datasource.simple.InDBDynamicDataSourceConfig; -import org.hswebframework.web.service.datasource.simple.InDBDynamicDataSourceService; -import org.hswebframework.web.service.datasource.simple.InDBJtaDynamicDataSourceService; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -import javax.sql.DataSource; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.datasource.simple" - , "org.hswebframework.web.controller.datasource"}) -@AutoConfigureBefore(value = DynamicDataSourceAutoConfiguration.class, name = "org.hswebframework.web.datasource.jta.AtomikosDataSourceAutoConfiguration") -@SuppressWarnings("all") -public class InDBDynamicDataSourceAutoConfiguration { - - @Bean - @Primary - public DynamicDataSourceConfigRepository inDBDataSourceRepository(DataSourceConfigService dataSourceConfigService) { - return new InDBDataSourceRepository(dataSourceConfigService); - } - - @Bean - @ConditionalOnMissingClass("org.hswebframework.web.datasource.jta.JtaDynamicDataSourceService") - public DynamicDataSourceService inDBDynamicDataSourceService(DynamicDataSourceConfigRepository repository, - DataSource dataSource) { - return new InDBDynamicDataSourceService(repository, new DynamicDataSourceProxy("dataSource", dataSource)); - } - - @Configuration - @ConditionalOnClass(org.hswebframework.web.datasource.jta.JtaDynamicDataSourceService.class) - public static class InDBJtaDynamicDataSourceServiceAutoConfiguration { - @Bean - public DynamicDataSourceService inDBJtaDynamicDataSourceService(DynamicDataSourceConfigRepository repository, - DataSource dataSource) { - return new InDBJtaDynamicDataSourceService(repository, new DynamicDataSourceProxy("dataSource", dataSource)); - } - } - -} diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 8eab437ab..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.datasource.starter.InDBDynamicDataSourceAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 1b093ebfa..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,44 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "数据源配置" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_datasource_conf") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("数据源名称").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("enabled").alias("enabled").comment("是否启用").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("create_date").alias("createDate").comment("创建日期").jdbcType(java.sql.JDBCType.TIMESTAMP).commit() - .addColumn().name("properties").alias("properties").comment("数据源配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("describe").alias("describe").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .comment("数据源配置").commit(); -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/pom.xml b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/pom.xml deleted file mode 100644 index 1bf54659a..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - hsweb-system-datasource - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 动态数据源配置web管理模块 - - hsweb-system-datasource-web - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-datasource-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/src/main/java/org/hswebframework/web/controller/datasource/DataSourceConfigController.java b/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/src/main/java/org/hswebframework/web/controller/datasource/DataSourceConfigController.java deleted file mode 100644 index 5a7cf1403..000000000 --- a/hsweb-system/hsweb-system-datasource/hsweb-system-datasource-web/src/main/java/org/hswebframework/web/controller/datasource/DataSourceConfigController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.controller.datasource; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.datasource.DataSourceConfigEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.datasource.DataSourceConfigService; -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("datasource/config") -@Authorize(permission = "data-source-config",description = "动态数据源管理") -@Api(value = "数据源配置",tags = "动态数据源-数据源配置") -public class DataSourceConfigController implements SimpleGenericEntityController { - - private DataSourceConfigService dataSourceConfigService; - - @Autowired - public void setDataSourceConfigService(DataSourceConfigService dataSourceConfigService) { - this.dataSourceConfigService = dataSourceConfigService; - } - - @Override - public DataSourceConfigService getService() { - return dataSourceConfigService; - } -} diff --git a/hsweb-system/hsweb-system-datasource/pom.xml b/hsweb-system/hsweb-system-datasource/pom.xml deleted file mode 100644 index e26ddda27..000000000 --- a/hsweb-system/hsweb-system-datasource/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - - 动态数据源配置父模块 - - 4.0.0 - pom - hsweb-system-datasource - - - hsweb-system-datasource-starter - hsweb-system-datasource-api - hsweb-system-datasource-local - hsweb-system-datasource-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dev-tools/pom.xml b/hsweb-system/hsweb-system-dev-tools/pom.xml deleted file mode 100644 index 8f5f46d27..000000000 --- a/hsweb-system/hsweb-system-dev-tools/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dev-tools - - - - org.hswebframework - hsweb-utils - - - org.springframework.boot - spring-boot-starter - - - org.springframework - spring-webmvc - true - - - org.hswebframework.web - hsweb-authorization-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - - com.github.javaparser - javaparser-core - 3.6.1 - - - io.swagger - swagger-annotations - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/DevToolsAutoConfiguration.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/DevToolsAutoConfiguration.java deleted file mode 100644 index 724fd01f7..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/DevToolsAutoConfiguration.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.dev.tools; - -import org.hswebframework.web.dev.tools.web.FileManagerDevToolsController; -import org.hswebframework.web.dev.tools.writer.CodeWriter; -import org.hswebframework.web.dev.tools.writer.DefaultCodeWriter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -public class DevToolsAutoConfiguration { - - @Bean - @ConditionalOnMissingBean(CodeWriter.class) - public DefaultCodeWriter defaultCodeWriter() { - return new DefaultCodeWriter(); - } - - @Bean - public FileManagerDevToolsController fileManagerDevToolsController() { - return new FileManagerDevToolsController(); - } -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/EnableDevTools.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/EnableDevTools.java deleted file mode 100644 index d358814c8..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/EnableDevTools.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.dev.tools; - -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; - -import java.lang.annotation.*; - -/** - * @author zhouhao - * @since 3.0 - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@ImportAutoConfiguration(DevToolsAutoConfiguration.class) -public @interface EnableDevTools { -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/reader/FileInfo.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/reader/FileInfo.java deleted file mode 100644 index fe5eb3224..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/reader/FileInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.dev.tools.reader; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.File; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@ApiModel("文件信息") -public class FileInfo { - - @ApiModelProperty("文件名") - private String name; - - @ApiModelProperty("文件长度") - private Long length; - - @ApiModelProperty("父目录") - private String parent; - - @ApiModelProperty("文件长度") - private String absolutePath; - - @ApiModelProperty("是否为文件") - private boolean file; - - @ApiModelProperty("是否为目录") - private boolean dir; - - public static FileInfo from(File file) { - FileInfo info = new FileInfo(); - info.setName(file.getName()); - info.setLength(file.length()); - info.setParent(file.getParent()); - info.setAbsolutePath(file.getAbsolutePath()); - info.setFile(file.isFile()); - info.setDir(file.isDirectory()); - return info; - } -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/web/FileManagerDevToolsController.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/web/FileManagerDevToolsController.java deleted file mode 100644 index 66de1403b..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/web/FileManagerDevToolsController.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.hswebframework.web.dev.tools.web; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.SneakyThrows; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.dev.tools.reader.FileInfo; -import org.hswebframework.web.dev.tools.writer.GeneratedCode; -import org.hswebframework.web.dev.tools.writer.CodeWriter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.StringJoiner; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author zhouhao - * @since 3.0 - */ -@RestController -@RequestMapping("/dev/tools/file") -@Authorize(permission = "dev-tools", description = "开发人员工具-文件管理") -@Api(tags = "开发人员工具-文件管理", value = "开发人员工具-文件管理") -public class FileManagerDevToolsController { - - @Autowired - private CodeWriter codeWriter; - - @PostMapping("/write") - @ApiOperation("写出文件") - @Authorize(action = "write", description = "写出文件") - public ResponseMessage write(@RequestBody List codes) { - return ResponseMessage.ok(codeWriter.write(codes)); - } - - @GetMapping("/list") - @ApiOperation("获取目录下的全部文件,不包含子目录") - @Authorize(action = "read", description = "读取文件") - public ResponseMessage> write(@RequestParam String path) { - File file = new File(path); - if (!file.exists()) { - return ResponseMessage.error(404,"文件不存在"); - } - List list; - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (files == null) { - list = new java.util.ArrayList<>(); - } else { - list = Stream.of(files) - .map(FileInfo::from) - .collect(Collectors.toList()); - } - } else { - list = Collections.singletonList(FileInfo.from(file)); - } - return ResponseMessage.ok(list); - } - - @GetMapping("/read") - @ApiOperation("读取文本文件内容") - @SneakyThrows - @Authorize(action = "read", description = "读取文件") - public ResponseMessage read(@RequestParam String file) { - File fileInfo = new File(file); - if (!fileInfo.exists()) { - return ResponseMessage.error(404,"文件不存在"); - } - if (fileInfo.length() > 2 * 1024 * 1024 * 1024L) { - return ResponseMessage.error(500, "文件过大,无法读取"); - } - List list = Files.readAllLines(Paths.get(file)); - StringJoiner joiner = new StringJoiner("\n"); - list.forEach(joiner::add); - return ResponseMessage.ok(joiner.toString()); - } - -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/ClassWriter.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/ClassWriter.java deleted file mode 100644 index 3a94ad11a..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/ClassWriter.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.hswebframework.web.dev.tools.writer; - -import com.github.javaparser.JavaParser; -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.Modifier; -import com.github.javaparser.ast.body.FieldDeclaration; -import com.github.javaparser.ast.body.MethodDeclaration; -import com.github.javaparser.ast.body.VariableDeclarator; -import com.github.javaparser.ast.comments.Comment; -import com.github.javaparser.ast.expr.AnnotationExpr; -import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; -import lombok.SneakyThrows; -import org.hswebframework.utils.file.FileUtils; - -import java.io.File; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -public class ClassWriter { - @SneakyThrows - public static void writeClass(String file, String code) { - File oldClassFile = new File(file); - if (oldClassFile.exists()) { - CompilationUnit old = JavaParser.parse(oldClassFile); - CompilationUnit newClazz = JavaParser.parse(code); - Map oldFields = old - .findAll(FieldDeclaration.class) - .stream() - .collect(Collectors.toMap(declaration -> declaration.getVariable(0).getNameAsString(), Function.identity())); - - - Map oldMethod = old - .findAll(MethodDeclaration.class) - .stream() - .collect(Collectors.toMap(NodeWithSimpleName::getNameAsString, Function.identity())); - - newClazz.findAll(FieldDeclaration.class).forEach(declaration -> { - String name = declaration.getVariable(0).getNameAsString(); - if (oldFields.get(name) == null) { - VariableDeclarator declarator = declaration.getVariable(0); - FieldDeclaration newField = old.getType(0) - .addField(declarator.getType(), declarator.getNameAsString(), - declaration.getModifiers().toArray(new Modifier[]{})); - - declaration.getJavadocComment().ifPresent(newField::setJavadocComment); - for (Comment comment : declaration.getAllContainedComments()) { - newField.setComment(comment); - } - for (AnnotationExpr annotationExpr : declaration.getAnnotations()) { - newField.addAnnotation(annotationExpr.clone()); - } - } - }); - newClazz.findAll(MethodDeclaration.class).forEach(declaration -> { - String name = declaration.getNameAsString(); - if (oldMethod.get(name) == null) { - MethodDeclaration newMethod = old.getType(0) - .addMethod(name, declaration.getModifiers().toArray(new Modifier[]{})); - - declaration.getJavadocComment().ifPresent(newMethod::setJavadocComment); - for (Comment comment : declaration.getAllContainedComments()) { - newMethod.setComment(comment); - } - for (AnnotationExpr annotationExpr : declaration.getAnnotations()) { - newMethod.addAnnotation(annotationExpr.clone()); - } - } - }); - code = old.toString(); - } - - FileUtils.writeString2File(code, file, "utf-8"); - } -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/CodeWriter.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/CodeWriter.java deleted file mode 100644 index 851054f47..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/CodeWriter.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dev.tools.writer; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface CodeWriter { - String write(List codes); -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/DefaultCodeWriter.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/DefaultCodeWriter.java deleted file mode 100644 index 29fb095b2..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/DefaultCodeWriter.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.hswebframework.web.dev.tools.writer; - -import lombok.SneakyThrows; -import org.hswebframework.utils.file.FileUtils; -import org.springframework.beans.factory.annotation.Value; - -import java.io.File; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public class DefaultCodeWriter implements CodeWriter { - - @Value("${hsweb.dev.workspace:./}") - private String workspace = "./"; - - @SneakyThrows - private void writeCode(String path, GeneratedCode code) { - File file = new File(path); - file.mkdir(); - String type = code.getType(); - - String filePath = path + "/" + code.getFile(); - if ("dir".equals(type)) { - code.getChildren() - .forEach(childrenCode -> writeCode(filePath, childrenCode)); - } else if ("file".equals(type)) { - String template = code.getTemplate(); - String fileName = filePath; - String replaceMod = code.getRepeat(); - File codeFile = new File(fileName); - if (codeFile.exists() && replaceMod != null && !fileName.endsWith(".java")) { - switch (replaceMod) { - case "ignore": - return; - case "append": - String old = FileUtils.reader2String(fileName); - template = old + template; - break; - default: - break; - } - } - if (fileName.endsWith(".java")) { - ClassWriter.writeClass(fileName, template); - } else { - FileUtils.writeString2File(template, fileName, "utf-8"); - } - } - } - - @Override - public String write(List codes) { - - codes.forEach(code -> writeCode(workspace, code)); - - return workspace; - } -} diff --git a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/GeneratedCode.java b/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/GeneratedCode.java deleted file mode 100644 index dad7b9b93..000000000 --- a/hsweb-system/hsweb-system-dev-tools/src/main/java/org/hswebframework/web/dev/tools/writer/GeneratedCode.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.dev.tools.writer; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@ApiModel("文件信息") -public class GeneratedCode { - - @ApiModelProperty("文件名") - private String file; - - @ApiModelProperty("文件类型,file:文件,dir:目录") - private String type; - - @ApiModelProperty("相同文件替换方式,ignore:跳过,append:追加,其他覆盖") - private String repeat; - - @ApiModelProperty("文件内容") - private String template; - - @ApiModelProperty("子文件") - private List children; -} diff --git a/hsweb-system/hsweb-system-dictionary/README.md b/hsweb-system/hsweb-system-dictionary/README.md deleted file mode 100644 index 141979edf..000000000 --- a/hsweb-system/hsweb-system-dictionary/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## 数据字典功能 - -提供数据字典功能,支持字典解析与反解析。支持树形结构的字典。 - -## 字典解析 - -详见: [DictionaryParserTests](hsweb-system-dictionary-service/hsweb-system-dictionary-service-simple/src/test/java/org/hswebframework/web/starter/dictionary/DictionaryParserTests.java) \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/pom.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/pom.xml deleted file mode 100644 index f6a84ef63..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - hsweb-system-dictionary - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dictionary-api - - - - org.hswebframework.web - hsweb-commons-bean - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfo.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfo.java deleted file mode 100644 index 9f5e15e96..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.dictionary.api; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.io.Serializable; - -/** - * 字典信息 - * - * @author zhouhao - * @since 3.0 - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@ToString -public class DictionaryInfo implements ValidateBean, Serializable { - private static final long serialVersionUID = -4017149592047646129L; - - private String id; - - @NotBlank(message = "[字典ID]不能为空") - private String dictionaryId; - - @NotBlank(message = "[目标key]不能为空") - private String targetKey; - - @NotBlank(message = "[目标ID]不能为空") - private String targetId; - - @NotBlank(message = "[值]不能为空") - private String value; - - @NotBlank(message = "[文本说明]不能为空") - private String text; - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfoService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfoService.java deleted file mode 100644 index 252523eb0..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryInfoService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.dictionary.api; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DictionaryInfoService { - int insert(List dictionaryInfo); - - List select(String targetKey, String targetId, String dictionaryId); - - int delete(String targetKey, String targetId, String dictionaryId); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryItemService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryItemService.java deleted file mode 100644 index fcc55ebce..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryItemService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api; - -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 数据字典选项 服务类 - * - * @author hsweb-generator-online - */ -public interface DictionaryItemService extends TreeService - , CrudService { - - List selectByDictId(String dictId); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParser.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParser.java deleted file mode 100644 index 48dff074c..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParser.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api; - -import java.io.Serializable; -import java.util.Optional; - -/** - * 字典解析器接口 - * - * @author zhouhao - */ -public interface DictionaryParser extends Serializable { - - Optional textToValue(String text, Object context); - - Optional valueToText(V value, Object context); - - default Optional textToValue(String text) { - return textToValue(text, null); - } - - default Optional valueToText(V value) { - return valueToText(value, null); - } - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParserService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParserService.java deleted file mode 100644 index c0ca32e65..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryParserService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api; - -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryParserEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 数据字典解析配置 服务类 - * - * @author hsweb-generator-online - */ -public interface DictionaryParserService extends CrudService { - - DictionaryParser getParser(DictionaryEntity dict, String parserId); - - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryService.java deleted file mode 100644 index 886ccfa60..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api; - -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * 数据字典 服务类 - * - * @author hsweb-generator-online - */ -public interface DictionaryService extends CrudService { - - - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryWrapper.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryWrapper.java deleted file mode 100644 index 5e6b856fb..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/DictionaryWrapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.dictionary.api; - -/** - * 字典包装器,用于将实体类中的字段保存到数据库,或者将数据库中的字典信息包装到实体中 - * - * @author zhouhao - * @since 3.0 - */ -public interface DictionaryWrapper { - /** - * 向一个实体类里填充数据字典 - * - * @param id 实体类的id - * @param bean 实体类 - * @param 实体类型 - * @return 填充后的实体类 - */ - T wrap(Object id, T bean); - - /** - * 把实体类中的 - * @param id - * @param bean - * @param - * @return - */ - T persistent(Object id, T bean); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/builder/DictionaryParserBuilder.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/builder/DictionaryParserBuilder.java deleted file mode 100644 index 7af363583..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/builder/DictionaryParserBuilder.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dictionary.api.builder; - - -import org.hswebframework.web.dictionary.api.parser.SingleDictParser; - -/** - * @author zhouhao - */ -public interface DictionaryParserBuilder { - SingleDictParser build(String config); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryEntity.java deleted file mode 100644 index 0627f5350..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryEntity.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; - -import java.util.List; - -/** - * 数据字典 实体 - * - * @author hsweb-generator-online - */ -public interface DictionaryEntity extends GenericEntity, RecordCreationEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 字典名称 - */ - String name = "name"; - /** - * 分类id - */ - String classifiedId = "classifiedId"; - /** - * 说明 - */ - String describe = "describe"; - /** - * 创建时间 - */ - String createTime = "createTime"; - /** - * 创建人id - */ - String creatorId = "creatorId"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 字典名称 - */ - String getName(); - - /** - * 设置 字典名称 - */ - void setName(String name); - - /** - * @return 分类id - */ - String getClassifiedId(); - - /** - * 设置 分类id - */ - void setClassifiedId(String classifiedId); - - /** - * @return 说明 - */ - String getDescribe(); - - /** - * 设置 说明 - */ - void setDescribe(String describe); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte enabled); - - List getItems(); - - void setItems(List items); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryItemEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryItemEntity.java deleted file mode 100644 index 6e1fefe37..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryItemEntity.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dict.ItemDefine; - -import java.util.List; - -/** - * 数据字典选项 实体 - * - * @author hsweb-generator-online - */ -public interface DictionaryItemEntity extends TreeSortSupportEntity, EnumDict { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 字典id - */ - String dictId = "dictId"; - /** - * 名称 - */ - String name = "name"; - /** - * 字典值 - */ - String value = "value"; - /** - * 字典文本 - */ - String text = "text"; - /** - * 字典值类型 - */ - String valueType = "valueType"; - /** - * 是否启用 - */ - String status = "status"; - /** - * 说明 - */ - String describe = "describe"; - /** - * 父级选项 - */ - String parentId = "parentId"; - /** - * 树编码 - */ - String path = "path"; - /** - * 快速搜索码 - */ - String searchCode = "searchCode"; - /** - * 排序索引 - */ - String sortIndex = "sortIndex"; - /** - * 树结构层级 - */ - String level = "level"; - - /** - * @return 字典id - */ - String getDictId(); - - /** - * 设置 字典id - */ - void setDictId(String dictId); - - /** - * @return 名称 - */ - String getName(); - - /** - * 设置 名称 - */ - void setName(String name); - - /** - * @return 字典值 - */ - String getValue(); - - /** - * 设置 字典值 - */ - void setValue(String value); - - /** - * @return 字典文本 - */ - String getText(); - - /** - * 设置 字典文本 - */ - void setText(String text); - - /** - * @return 字典值类型 - */ - String getValueType(); - - /** - * 设置 字典值类型 - */ - void setValueType(String valueType); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - /** - * @return 说明 - */ - String getDescribe(); - - /** - * 设置 说明 - */ - void setDescribe(String describe); - - /** - * @return 快速搜索码 - */ - String getSearchCode(); - - /** - * 设置 快速搜索码 - */ - void setSearchCode(String searchCode); - - void setChildren(List children); - - Integer getOrdinal(); - - void setOrdinal(Integer ordinal); - - @Override - default int ordinal() { - return getOrdinal() == null ? 0 : getOrdinal(); - } - - @Override - default String getComments() { - return getDescribe(); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryParserEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryParserEntity.java deleted file mode 100644 index 7ba81ba44..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/DictionaryParserEntity.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; - -/** - * 数据字典解析配置 实体 - * - * @author hsweb-generator-online - */ -public interface DictionaryParserEntity extends GenericEntity, RecordCreationEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 值到文本转换方式 - */ - String valueToTextParser = "valueToTextParser"; - /** - * 文本到值转换方式 - */ - String textToValueParser = "textToValueParser"; - /** - * 转换失败时的操作 - */ - String onError = "onError"; - /** - * 创建时间 - */ - String createTime = "createTime"; - /** - * 创建人id - */ - String creatorId = "creatorId"; - /** - * 更新时间 - */ - String updateTime = "updateTime"; - /** - * 名称 - */ - String name = "name"; - /** - * 说明 - */ - String describe = "describe"; - /** - * 分类id - */ - String classifiedId = "classifiedId"; - - /** - * @return 值到文本转换方式 - */ - String getValueToTextParser(); - - /** - * 设置 值到文本转换方式 - */ - void setValueToTextParser(String valueToTextParser); - - /** - * @return 文本到值转换方式 - */ - String getTextToValueParser(); - - /** - * 设置 文本到值转换方式 - */ - void setTextToValueParser(String textToValueParser); - - /** - * @return 转换失败时的操作 - */ - String getOnError(); - - /** - * 设置 转换失败时的操作 - */ - void setOnError(String onError); - - /** - * @return 更新时间 - */ - Long getUpdateTime(); - - /** - * 设置 更新时间 - */ - void setUpdateTime(Long updateTime); - - /** - * @return 名称 - */ - String getName(); - - /** - * 设置 名称 - */ - void setName(String name); - - /** - * @return 说明 - */ - String getDescribe(); - - /** - * 设置 说明 - */ - void setDescribe(String describe); - - /** - * @return 分类id - */ - String getClassifiedId(); - - /** - * 设置 分类id - */ - void setClassifiedId(String classifiedId); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryEntity.java deleted file mode 100644 index b3f1efc74..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryEntity.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.List; - -/** - * 数据字典 - * - * @author hsweb-generator-online - */ -public class SimpleDictionaryEntity extends SimpleGenericEntity implements DictionaryEntity { - //字典名称 - private String name; - //分类id - private String classifiedId; - //说明 - private String describe; - //创建时间 - private Long createTime; - //创建人id - private String creatorId; - //状态 - private Byte status; - //字段选项 - private List items; - - /** - * @return 字典名称 - */ - @Override - public String getName() { - return this.name; - } - - /** - * 设置 字典名称 - */ - @Override - public void setName(String name) { - this.name = name; - } - - /** - * @return 分类id - */ - @Override - public String getClassifiedId() { - return this.classifiedId; - } - - /** - * 设置 分类id - */ - @Override - public void setClassifiedId(String classifiedId) { - this.classifiedId = classifiedId; - } - - /** - * @return 说明 - */ - @Override - public String getDescribe() { - return this.describe; - } - - /** - * 设置 说明 - */ - @Override - public void setDescribe(String describe) { - this.describe = describe; - } - - /** - * @return 创建时间 - */ - @Override - public Long getCreateTime() { - return this.createTime; - } - - /** - * 设置 创建时间 - */ - @Override - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - /** - * @return 创建人id - */ - @Override - public String getCreatorId() { - return this.creatorId; - } - - /** - * 设置 创建人id - */ - @Override - public void setCreatorId(String creatorId) { - this.creatorId = creatorId; - } - - /** - * @return 状态 - */ - @Override - public Byte getStatus() { - return this.status; - } - - /** - * 设置 状态 - */ - @Override - public void setStatus(Byte status) { - this.status = status; - } - - @Override - public List getItems() { - return items; - } - - @Override - public void setItems(List items) { - this.items = items; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryItemEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryItemEntity.java deleted file mode 100644 index 188c3092d..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryItemEntity.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import com.alibaba.fastjson.JSONObject; -import lombok.Getter; -import lombok.Setter; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * 数据字典选项 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -public class SimpleDictionaryItemEntity extends SimpleTreeSortSupportEntity implements DictionaryItemEntity { - //字典id - @NotBlank(groups = CreateGroup.class) - private String dictId; - //名称 - private String name; - //字典值 - private String value; - //字典文本 - private String text; - //字典值类型 - private String valueType; - //是否启用 - private Byte status; - //说明 - private String describe; - //快速搜索码 - private String searchCode; - - private Integer ordinal; - - private List children; - - @Override - public Object getWriteJSONObject() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", getId()); - jsonObject.put("name", getName()); - jsonObject.put("dictId", getDictId()); - jsonObject.put("value", getValue()); - jsonObject.put("text", getText()); - jsonObject.put("ordinal", getOrdinal()); - jsonObject.put("sortIndex", getSortIndex()); - jsonObject.put("path", getPath()); - jsonObject.put("mask", getMask()); - jsonObject.put("searchCode", getSearchCode()); - jsonObject.put("status", getStatus()); - jsonObject.put("describe", getDescribe()); - return jsonObject; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryParserEntity.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryParserEntity.java deleted file mode 100644 index f167eb89b..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/entity/SimpleDictionaryParserEntity.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2019 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.dictionary.api.entity; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 数据字典解析配置 - * - * @author hsweb-generator-online - */ -public class SimpleDictionaryParserEntity extends SimpleGenericEntity implements DictionaryParserEntity { - //值到文本转换方式 - private String valueToTextParser; - //文本到值转换方式 - private String textToValueParser; - //转换失败时的操作 - private String onError; - //创建时间 - private Long createTime; - //创建人id - private String creatorId; - //更新时间 - private Long updateTime; - //名称 - private String name; - //说明 - private String describe; - //分类id - private String classifiedId; - - /** - * @return 值到文本转换方式 - */ - @Override - public String getValueToTextParser() { - return this.valueToTextParser; - } - - /** - * 设置 值到文本转换方式 - */ - @Override - public void setValueToTextParser(String valueToTextParser) { - this.valueToTextParser = valueToTextParser; - } - - /** - * @return 文本到值转换方式 - */ - @Override - public String getTextToValueParser() { - return this.textToValueParser; - } - - /** - * 设置 文本到值转换方式 - */ - @Override - public void setTextToValueParser(String textToValueParser) { - this.textToValueParser = textToValueParser; - } - - /** - * @return 转换失败时的操作 - */ - @Override - public String getOnError() { - return this.onError; - } - - /** - * 设置 转换失败时的操作 - */ - @Override - public void setOnError(String onError) { - this.onError = onError; - } - - /** - * @return 创建时间 - */ - @Override - public Long getCreateTime() { - return this.createTime; - } - - /** - * 设置 创建时间 - */ - @Override - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - /** - * @return 创建人id - */ - @Override - public String getCreatorId() { - return this.creatorId; - } - - /** - * 设置 创建人id - */ - @Override - public void setCreatorId(String creatorId) { - this.creatorId = creatorId; - } - - /** - * @return 更新时间 - */ - @Override - public Long getUpdateTime() { - return this.updateTime; - } - - /** - * 设置 更新时间 - */ - @Override - public void setUpdateTime(Long updateTime) { - this.updateTime = updateTime; - } - - /** - * @return 名称 - */ - @Override - public String getName() { - return this.name; - } - - /** - * 设置 名称 - */ - @Override - public void setName(String name) { - this.name = name; - } - - /** - * @return 说明 - */ - @Override - public String getDescribe() { - return this.describe; - } - - /** - * 设置 说明 - */ - @Override - public void setDescribe(String describe) { - this.describe = describe; - } - - /** - * @return 分类id - */ - @Override - public String getClassifiedId() { - return this.classifiedId; - } - - /** - * 设置 分类id - */ - @Override - public void setClassifiedId(String classifiedId) { - this.classifiedId = classifiedId; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/events/ClearDictionaryCacheEvent.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/events/ClearDictionaryCacheEvent.java deleted file mode 100644 index 7e324c75e..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/events/ClearDictionaryCacheEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.dictionary.api.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class ClearDictionaryCacheEvent { - private String dictionaryId; -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/parser/SingleDictParser.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/parser/SingleDictParser.java deleted file mode 100644 index 7d1fc388e..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-api/src/main/java/org/hswebframework/web/dictionary/api/parser/SingleDictParser.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.dictionary.api.parser; - -import java.io.Serializable; -import java.util.Optional; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface SingleDictParser extends Serializable { - Optional parse(String target, Object context); - - default Optional parse(String target) { - return parse(target, null); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/pom.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/pom.xml deleted file mode 100644 index d7d5b8e12..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - hsweb-system-dictionary - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dictionary-local - - - - org.hswebframework.web - hsweb-system-dictionary-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/BoostDictDefineRepository.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/BoostDictDefineRepository.java deleted file mode 100644 index fb472c00a..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/BoostDictDefineRepository.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dict.DictDefine; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dict.defaults.DefaultDictDefine; -import org.hswebframework.web.dict.defaults.DefaultDictDefineRepository; -import org.hswebframework.web.dictionary.api.DictionaryItemService; -import org.hswebframework.web.dictionary.api.DictionaryService; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.dictionary.api.events.ClearDictionaryCacheEvent; -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 org.springframework.transaction.event.TransactionalEventListener; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -@Service -@CacheConfig(cacheNames = "dictionary") -@Slf4j -@SuppressWarnings("all") -public class BoostDictDefineRepository extends DefaultDictDefineRepository { - - @Autowired - private DictionaryService dictionaryService; - - @Autowired - private DictionaryItemService itemService; - - @TransactionalEventListener - @CacheEvict(key = "'dictDefineById:'+#event.dictionaryId", condition = "#event!=null") - public void clearCache(ClearDictionaryCacheEvent event) { - log.info("clear dictionary define cache:{}", event.getDictionaryId()); - } - - @Override - @Cacheable(key = "'dictDefineById:'+#id") - public DictDefine getDefine(String id) { - DictionaryEntity entity = dictionaryService.selectByPk(id); - if (entity == null) { - return super.getDefine(id); - } - List> items = (List) itemService.selectByDictId(id) - .stream() - .filter(e -> DataStatus.STATUS_ENABLED.equals(e.getStatus())) - .collect(Collectors.toList()); - - return DefaultDictDefine.builder() - .id(id) - .comments(entity.getDescribe()) - .items(items) - .build(); - } - - @Override - public List getAllDefine() { - //查询所有的字典项并按字典ID分组 - Map> items = QueryParamEntity.newQuery() - .where(DictionaryItemEntity::getStatus, DataStatus.STATUS_ENABLED) - .noPaging() - .execute(itemService::select) - .stream().collect(Collectors.groupingBy(DictionaryItemEntity::getDictId)); - - //转换为字段 - List all =QueryParamEntity.newQuery() - .where(DictionaryEntity::getStatus,DataStatus.STATUS_ENABLED) - .noPaging() - .execute(dictionaryService::select) - .stream() - .map(dict -> DefaultDictDefine.builder() - .id(dict.getId()) - .comments(dict.getDescribe()) - .items((List) items.getOrDefault(dict.getId(),Collections.emptyList())) - .build()) - .collect(Collectors.toList()); - //添加默认的字典 - all.addAll(super.getAllDefine()); - return all; - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryHelper.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryHelper.java deleted file mode 100644 index b12259322..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryHelper.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DefaultDictionaryHelper { - Object getDictEnum(Object id, String targetKey, String dictId, Class type); - - void persistent(Object id, String targetKey, String dictId, Class type,Object value); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapper.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapper.java deleted file mode 100644 index 0a13db64b..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapper.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import lombok.Setter; -import org.apache.commons.beanutils.BeanUtilsBean; -import org.hswebframework.web.dict.Dict; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dictionary.api.DictionaryInfo; -import org.hswebframework.web.dictionary.api.DictionaryInfoService; -import org.hswebframework.web.dictionary.api.DictionaryWrapper; -import org.hswebframework.web.proxy.Proxy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ClassUtils; - -import java.beans.PropertyDescriptor; -import java.lang.reflect.Array; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author zhouhao - * @since 3.0 - */ -public class DefaultDictionaryWrapper implements DictionaryWrapper, DefaultDictionaryHelper { - static DictionaryWrapperObject EMPTY_WRAPPER = new DictionaryWrapperObject() { - @Override - public void wrap(Object id, Object bean, DefaultDictionaryHelper helper) { - - } - - @Override - public void persistent(Object id, Object bean, DefaultDictionaryHelper helper) { - - } - }; - - @Autowired - @Setter - private DictionaryInfoService dictionaryInfoService; - - protected Map cache = new ConcurrentHashMap<>(); - - protected DictionaryWrapperObject createCache(Class bean) { - String beanName = bean.getName(); - StringBuilder wrapMethod = new StringBuilder() - .append("public void wrap(Object id,Object bean, org.hswebframework.web.dictionary.simple.DefaultDictionaryHelper helper)") - .append("{\n") - .append(bean.getName()).append(" target=(").append(bean.getName()).append(")bean;\n"); - - StringBuilder persistentMethod = new StringBuilder() - .append("public void persistent(Object id,Object bean, org.hswebframework.web.dictionary.simple.DefaultDictionaryHelper helper)") - .append("{\n") - .append(bean.getName()).append(" target=(").append(bean.getName()).append(")bean;\n"); - - PropertyDescriptor[] descriptors = BeanUtilsBean.getInstance().getPropertyUtils().getPropertyDescriptors(bean); - boolean hasDict = false; - for (PropertyDescriptor descriptor : descriptors) { - Class type = descriptor.getPropertyType(); - boolean isArray = type.isArray(); - if (isArray) { - type = type.getComponentType(); - } - //枚举字典并且枚举数量大于64 - if (type.isEnum() && EnumDict.class.isAssignableFrom(type) && type.getEnumConstants().length >= 64) { - String typeName = isArray ? type.getName().concat("[]") : type.getName(); - String dictId = type.getName(); - Dict dict = (Dict) type.getAnnotation(Dict.class); - if (dict != null) { - dictId = dict.id(); - } - wrapMethod.append("{\n"); - wrapMethod.append(typeName).append(" dict=(").append(typeName).append(")helper.getDictEnum(id,") - .append("\"").append(beanName).append(".").append(descriptor.getName()).append("\"").append(",\"").append(dictId).append("\"") - .append(",").append(typeName).append(".class);\n"); - wrapMethod.append("target.").append(descriptor.getWriteMethod().getName()).append("(dict);\n"); - wrapMethod.append("}"); - - persistentMethod.append("helper.persistent(id,") - .append("\"").append(beanName).append(".").append(descriptor.getName()).append("\"").append(",\"").append(dictId).append("\"") - .append(",").append(typeName).append(".class,") - .append("target.").append(descriptor.getReadMethod().getName()).append("()") - .append(");\n"); - - hasDict = true; - } - } - wrapMethod.append("\n}"); - persistentMethod.append("\n}"); - if (hasDict) { - return Proxy.create(DictionaryWrapperObject.class) - .addMethod(wrapMethod.toString()) - .addMethod(persistentMethod.toString()) - .newInstance(); - } - return EMPTY_WRAPPER; - } - - @Override - public T wrap(Object id, T bean) { - cache.computeIfAbsent(ClassUtils.getUserClass(bean.getClass()), this::createCache) - .wrap(id, bean, getHelper()); - return bean; - } - - protected DefaultDictionaryHelper getHelper() { - return this; - } - - @Override - public T persistent(Object id, T bean) { - cache.computeIfAbsent(ClassUtils.getUserClass(bean.getClass()), this::createCache) - .persistent(id, bean, getHelper()); - return bean; - } - - @Override - @SuppressWarnings("all") - public Object getDictEnum(Object id, String targetKey, String dictId, Class type) { - List infos = dictionaryInfoService.select(targetKey, String.valueOf(id), dictId); - Class componentType = type.isArray() ? type.getComponentType() : type; - if (componentType.isEnum() && EnumDict.class.isAssignableFrom(componentType)) { - Stream stream = infos.stream() - .map(DictionaryInfo::getValue) - .map(val -> EnumDict.find(componentType, val).orElse(null)) - .filter(Objects::nonNull); - if (type.isArray()) { - return stream.toArray(len -> Array.newInstance(componentType, len)); - } else { - return stream.findFirst().orElse(null); - } - } - return null; - } - - @Override - public void persistent(Object id, String targetKey, String dictId, Class type, Object value) { - if (value == null) { - return; - } - Class componentType = type.isArray() ? type.getComponentType() : type; - if (componentType.isEnum() && EnumDict.class.isAssignableFrom(componentType)) { - List dicts; - if (type.isArray()) { - dicts = Arrays.asList(((EnumDict[]) value)); - } else { - dicts = Arrays.asList(((EnumDict) value)); - } - dictionaryInfoService.delete(targetKey, String.valueOf(id), dictId); - dictionaryInfoService.insert(dicts.stream().map(dict -> - DictionaryInfo.builder() - .value(String.valueOf(dict.getValue())) - .dictionaryId(dictId) - .text(dict.getText()) - .targetKey(targetKey) - .targetId(String.valueOf(id)) - .build()).collect(Collectors.toList())); - } - - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DictionaryWrapperObject.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DictionaryWrapperObject.java deleted file mode 100644 index ffe94a136..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/DictionaryWrapperObject.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DictionaryWrapperObject { - - void wrap(Object id, Object bean, DefaultDictionaryHelper helper); - - void persistent(Object id, Object bean, DefaultDictionaryHelper helper); - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryItemService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryItemService.java deleted file mode 100644 index 5b3a204a4..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryItemService.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple; - -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.dictionary.api.DictionaryItemService; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.dictionary.api.events.ClearDictionaryCacheEvent; -import org.hswebframework.web.dictionary.simple.dao.DictionaryItemDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -import java.util.Collections; -import java.util.List; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dictionaryItemService") -public class SimpleDictionaryItemService extends AbstractTreeSortService - implements DictionaryItemService { - @Autowired - private DictionaryItemDao dictionaryItemDao; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DictionaryItemDao getDao() { - return dictionaryItemDao; - } - - @Override - public String insert(DictionaryItemEntity entity) { - clearDictCache(entity.getDictId()); - return super.insert(entity); - } - - @Override - public int updateByPk(String id, DictionaryItemEntity entity) { - clearDictCache(entity.getDictId()); - return super.updateByPk(id, entity); - } - - @Override - public DictionaryItemEntity deleteByPk(String id) { - DictionaryItemEntity entity = selectByPk(id); - if (null != entity) { - clearDictCache(entity.getDictId()); - } - return super.deleteByPk(id); - } - - @Override - public List selectByDictId(String dictId) { - if (StringUtils.isNullOrEmpty(dictId)) { - return new java.util.ArrayList<>(); - } - return createQuery() - .where(DictionaryItemEntity.dictId, dictId) - .orderByAsc(DictionaryItemEntity.sortIndex) - .listNoPaging(); - } - - private void clearDictCache(String dictId) { - eventPublisher.publishEvent(new ClearDictionaryCacheEvent(dictId)); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParser.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParser.java deleted file mode 100644 index fc2f264c6..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParser.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import org.hswebframework.web.dictionary.api.DictionaryParser; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.dictionary.api.parser.SingleDictParser; -import org.hswebframework.web.dictionary.simple.parser.SimpleSingleDictParser; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * 简单的字典解析器实现,支持树形结构字典 - *

- * e.g. - *

- *   //字典
- *   [
- *    {text:"苹果",value:1,
- *     children:[
- *      {text:"青苹果",value:101},
- *      {text:"红富士",value:102},
- *      {text:"其他苹果",value:103,textExpression:"其他苹果(${#context.otherApple})"}
- *    ]}
- *    {text:"梨子",value:2}
- *   ]
- *   //调用
- *   parser.valueToText("1,101,103",{otherApple:"其他苹果1"});
- *   //返回结果  苹果(青苹果,其他苹果(其他苹果1))
- *
- *   //调用
- *   parser.textToValue("苹果(青苹果,其他苹果)")
- *   //返回结果 1,101,103
- * 
- * - * @author zhouhao - * @since 3.0 - */ -public class SimpleDictionaryParser implements DictionaryParser { - - private SingleDictParser toTextParser; - - private SingleDictParser toValueParser; - - private Map toTextExpressions = new HashMap<>(); - - private Map toValueExpressions = new HashMap<>(); - - public SimpleDictionaryParser addToTextExpression(String id, String expression) { - toTextExpressions.put(id, expression); - return this; - } - - public SimpleDictionaryParser addToValueExpression(String id, String expression) { - toValueExpressions.put(id, expression); - return this; - } - - public void setToTextExpressions(Map toTextExpressions) { - this.toTextExpressions = toTextExpressions; - } - - public void setToValueExpressions(Map toValueExpressions) { - this.toValueExpressions = toValueExpressions; - } - - public SingleDictParser getToTextParser() { - return toTextParser; - } - - public SingleDictParser getToValueParser() { - return toValueParser; - } - - public void setToTextParser(SingleDictParser toTextParser) { - this.toTextParser = toTextParser; - } - - public void setToValueParser(SingleDictParser toValueParser) { - this.toValueParser = toValueParser; - } - - //设置DictionaryEntity作为配置 - public SimpleDictionaryParser setDict(DictionaryEntity dict) { - SimpleSingleDictParser toTextParser = new SimpleSingleDictParser(); - toTextParser.setDict(dict, DictionaryItemEntity::getValue - , DictionaryItemEntity::getText - , item -> toTextExpressions.get(item.getId())); - - SimpleSingleDictParser toValueParser = new SimpleSingleDictParser(); - toValueParser.setDict(dict, DictionaryItemEntity::getText - , DictionaryItemEntity::getValue, - item -> toValueExpressions.get(item.getId())); - - toValueParser.getTargetFormat().setSplitter(","); - toValueParser.getTargetFormat().setChildStartChar(","); - toValueParser.getTargetFormat().setChildEndChar(""); - toValueParser.getTargetFormat().setChildSplitter(","); - this.setToTextParser(toTextParser); - this.setToValueParser(toValueParser); - return this; - } - - @Override - public Optional valueToText(V value, Object context) { - if (value == null) { - return Optional.empty(); - } - return toTextParser.parse(String.valueOf(value), context); - } - - @Override - public Optional textToValue(String text, Object context) { - return toValueParser.parse(text, context).map(v -> (V) v); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParserService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParserService.java deleted file mode 100644 index 967a767e0..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryParserService.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple; - -import org.hswebframework.web.dictionary.api.DictionaryParser; -import org.hswebframework.web.dictionary.api.DictionaryParserService; -import org.hswebframework.web.dictionary.api.builder.DictionaryParserBuilder; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryParserEntity; -import org.hswebframework.web.dictionary.simple.dao.DictionaryParserDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dictionaryParserService") -public class SimpleDictionaryParserService extends GenericEntityService - implements DictionaryParserService { - @Autowired - private DictionaryParserDao dictionaryParserDao; - - @Autowired - private DictionaryParserBuilder dictionaryParserBuilder; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DictionaryParserDao getDao() { - return dictionaryParserDao; - } - - @Override - public DictionaryParser getParser(DictionaryEntity dict, String parserId) { - DictionaryParserEntity entity = selectByPk(parserId); - assertNotNull(entity); - SimpleDictionaryParser parser = new SimpleDictionaryParser<>(); - parser.setToValueParser(dictionaryParserBuilder.build(entity.getTextToValueParser())); - parser.setToTextParser(dictionaryParserBuilder.build(entity.getValueToTextParser())); - return parser; - } - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryService.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryService.java deleted file mode 100644 index 85a970980..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/SimpleDictionaryService.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple; - -import org.hswebframework.web.dictionary.api.DictionaryService; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.events.ClearDictionaryCacheEvent; -import org.hswebframework.web.dictionary.simple.dao.DictionaryDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dictionaryService") -@CacheConfig(cacheNames = "dictionary") -public class SimpleDictionaryService extends GenericEntityService - implements DictionaryService { - - @Autowired - private DictionaryDao dictionaryDao; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DictionaryDao getDao() { - return dictionaryDao; - } - - @Override - public String insert(DictionaryEntity entity) { - String id = super.insert(entity); - eventPublisher.publishEvent(new ClearDictionaryCacheEvent(id)); - return id; - } - - @Override - public int updateByPk(String id, DictionaryEntity entity) { - eventPublisher.publishEvent(new ClearDictionaryCacheEvent(id)); - return super.updateByPk(id, entity); - } - - @Override - public DictionaryEntity deleteByPk(String id) { - eventPublisher.publishEvent(new ClearDictionaryCacheEvent(id)); - return super.deleteByPk(id); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/builder/SimpleDictionaryParserBuilder.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/builder/SimpleDictionaryParserBuilder.java deleted file mode 100644 index 169e11662..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/builder/SimpleDictionaryParserBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.hswebframework.web.dictionary.simple.builder; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.dictionary.api.builder.DictionaryParserBuilder; -import org.hswebframework.web.dictionary.api.parser.SingleDictParser; -import org.hswebframework.web.dictionary.simple.parser.SimpleSingleDictParser; - -import java.util.Objects; - -/** - * - * @author zhouhao - */ -public class SimpleDictionaryParserBuilder implements DictionaryParserBuilder { - @Override - public SingleDictParser build(String config) { - Objects.requireNonNull(config, "config is null"); - JSONObject object = JSON.parseObject(config); - String type = object.getString("type"); - switch (type) { - case "simple": - return object.getObject("parser", SimpleSingleDictParser.class); - case "script": - // TODO: 17-5-25 - default: - throw new UnsupportedOperationException(config); - } - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryDao.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryDao.java deleted file mode 100644 index 3aa361f15..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; - -/** -* 数据字典 DAO接口 -* @author hsweb-generator-online - */ -public interface DictionaryDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryItemDao.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryItemDao.java deleted file mode 100644 index d0cc18565..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryItemDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; - -/** -* 数据字典选项 DAO接口 -* @author hsweb-generator-online - */ -public interface DictionaryItemDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryParserDao.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryParserDao.java deleted file mode 100644 index e03331fcc..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/dao/DictionaryParserDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.dictionary.simple.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.dictionary.api.entity.DictionaryParserEntity; - -/** -* 数据字典解析配置 DAO接口 -* @author hsweb-generator-online - */ -public interface DictionaryParserDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormat.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormat.java deleted file mode 100644 index 3d88695d3..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormat.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -import java.io.Serializable; -import java.util.StringJoiner; - -/** - * @author zhouhao - */ -public class DictParserFormat implements Serializable { - //字典选项间的分割符 - private String splitter = ","; - - //子节点间的分割符 - private String childSplitter = ","; - - //子节点开始分割符 - private String childStartChar = "("; - - //子节点结束分割符 - private String childEndChar = ")"; - - //前缀 - private String prefix = ""; - - //后缀 - private String suffix = ""; - - public String getSplitter() { - return splitter; - } - - public void setSplitter(String splitter) { - this.splitter = splitter; - } - - public String getChildSplitter() { - return childSplitter; - } - - public void setChildSplitter(String childSplitter) { - this.childSplitter = childSplitter; - } - - public String getChildStartChar() { - return childStartChar; - } - - public void setChildStartChar(String childStartChar) { - this.childStartChar = childStartChar; - } - - public String getChildEndChar() { - return childEndChar; - } - - public void setChildEndChar(String childEndChar) { - this.childEndChar = childEndChar; - } - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - public String getSuffix() { - return suffix; - } - - public void setSuffix(String suffix) { - this.suffix = suffix; - } - - public StringJoiner createJoiner() { - return new StringJoiner(splitter, prefix, suffix); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormatter.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormatter.java deleted file mode 100644 index e3d369910..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/DictParserFormatter.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -import java.util.List; -import java.util.function.BiFunction; - -/** - * @author zhouhao - * @see 3.0 - */ -public interface DictParserFormatter { - List> format(DictParserFormat format, Object value, BiFunction mapping); -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/FormatterResult.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/FormatterResult.java deleted file mode 100644 index 6833bf4d0..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/FormatterResult.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -/** - * - * @author zhouhao - */ -public class FormatterResult { - private V result; - - private String pattern; - - public FormatterResult() { - } - - public FormatterResult(V result) { - this(result, String.valueOf(result)); - } - - public FormatterResult(V result, String pattern) { - this.result = result; - this.pattern = pattern; - } - - public V getResult() { - return result; - } - - public void setResult(V result) { - this.result = result; - } - - public String getPattern() { - return pattern; - } - - public void setPattern(String pattern) { - this.pattern = pattern; - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/ScriptSingleDictParser.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/ScriptSingleDictParser.java deleted file mode 100644 index 3df397ce0..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/ScriptSingleDictParser.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.web.dictionary.api.parser.SingleDictParser; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * @author zhouhao - */ -public class ScriptSingleDictParser implements SingleDictParser { - private String script; - - private String language; - - @Override - public Optional parse(String target, Object context) { - Map vars = new HashMap<>(); - vars.put("context", context); - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(language); - String scriptId = String.valueOf(script.hashCode()); - try { - if (!engine.compiled(scriptId)) { - engine.compile(scriptId, language); - } - Object result = engine.execute(scriptId, vars).getIfSuccess(); - if (result == null) { - return Optional.empty(); - } - return Optional.of(String.valueOf(result)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleDictParserFormatter.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleDictParserFormatter.java deleted file mode 100644 index b87272629..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleDictParserFormatter.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -import org.hswebframework.web.RegexUtils; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -public class SimpleDictParserFormatter implements DictParserFormatter { - - public boolean smartParse = true; - - public int smartLevel = 3; - - public void setSmartParse(boolean smartParse) { - this.smartParse = smartParse; - } - - public boolean needParse(String value, DictParserFormat format) { - return value.contains(format.getSplitter()) - || value.contains(format.getChildSplitter()) - || value.contains(format.getChildStartChar()); - } - - private FormatterResult createResult(T v, String pattern) { - return new FormatterResult<>(v, pattern); - } - - @Override - public List> format(DictParserFormat format - , Object value - , BiFunction mapping) { - if (value == null) { - return new java.util.ArrayList<>(); - } - String stringValue = String.valueOf(value); - if (!needParse(stringValue, format)) { - return Collections.singletonList(createResult(mapping.apply(stringValue, stringValue), stringValue)); - } - - String splitter = "[" + RegexUtils.escape(format.getSplitter() + - " " + format.getChildStartChar() + - " " + format.getChildSplitter() + - " " + format.getChildEndChar()) + - "]"; - return Arrays.stream(stringValue.split(splitter)) - .map(val -> { - T v = mapping.apply(val, val); - if (v == null && smartParse) { - StringBuilder tmp = new StringBuilder(); - char[] arr = val.toCharArray(); - for (int i = 0; i < arr.length; i++) { - tmp.append(arr[i]); - if (i >= smartLevel) { - v = mapping.apply(tmp.toString(), val); - if (null != v) { - break; - } - } - } - } - return createResult(v, val); - }) - .collect(Collectors.toList()); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleSingleDictParser.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleSingleDictParser.java deleted file mode 100644 index 9654392ed..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/java/org/hswebframework/web/dictionary/simple/parser/SimpleSingleDictParser.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.hswebframework.web.dictionary.simple.parser; - -import org.hswebframework.web.ExpressionUtils; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.dictionary.api.parser.SingleDictParser; - -import java.io.Serializable; -import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0 - */ -public class SimpleSingleDictParser implements SingleDictParser { - - private Map mapping = new HashMap<>(); - - private DictParserFormat sourceFormat = new DictParserFormat(); - - private DictParserFormat targetFormat = new DictParserFormat(); - - private DictParserFormatter formatter = new SimpleDictParserFormatter(); - - //设置DictionaryEntity作为配置 - public void setDict(DictionaryEntity dict, - Function keyGetter, - Function valueGetter, - Function expressionGetter) { - dict.getItems().forEach(item -> addMapping(item, keyGetter, valueGetter, expressionGetter)); - } - - public void setSourceFormat(DictParserFormat sourceFormat) { - this.sourceFormat = sourceFormat; - } - - public void setTargetFormat(DictParserFormat targetFormat) { - this.targetFormat = targetFormat; - } - - public DictParserFormat getTargetFormat() { - return targetFormat; - } - - public DictParserFormat getSourceFormat() { - return sourceFormat; - } - - private DictMapping addMapping(DictionaryItemEntity item, - Function keyGetter, - Function valueGetter, - Function expressionGetter) { - DictMapping dictMapping = new DictMapping(); - dictMapping.setValue(valueGetter.apply(item)); - dictMapping.setExpression(expressionGetter.apply(item)); - if (item.getChildren() != null) { - dictMapping.setChildren(item.getChildren().stream() - .map(DictionaryItemEntity.class::cast) - .map(i -> addMapping(i, keyGetter, valueGetter, expressionGetter)).collect(Collectors.toList())); - } - String key = keyGetter.apply(item); - dictMapping.setKey(key); - mapping.put(key, dictMapping); - return dictMapping; - } - - @Override - public Optional parse(String value, Object context) { - if (value == null) { - return Optional.empty(); - } - StringJoiner joiner = targetFormat.createJoiner(); - - List dictMappings = formatter - .format(sourceFormat, value, (key, pattern) -> { - DictMapping dictMapping = mapping.get(key); - if (dictMapping == null) { - return null; - } - dictMapping = dictMapping.clone(); - dictMapping.setDefaultVar(Collections.singletonMap("pattern", pattern)); - return dictMapping; - }) - .stream() - .filter(Objects::nonNull) - .map(FormatterResult::getResult) - .collect(Collectors.toList()); - - Set notAppendList = new HashSet<>(); - List mappingResult = dictMappings.stream() - .filter(Objects::nonNull) - // 过滤子节点 - .peek(dictMapping -> dictMapping.filterChildren((mapping -> { - String strVal = mapping.getValue(); - notAppendList.add(strVal); //子节点不拼接 - int index = dictMappings.indexOf(mappingOfValue(strVal)); - DictMapping tmp = null; - if (-1 != index) { - tmp = dictMappings.get(index); - } - if (null != tmp) { - mapping.setDefaultVar(tmp.getDefaultVar()); - } - return null != tmp; - }))) - .filter(mapping -> !notAppendList.contains(mapping.getValue())) - //字典转为text - .map(dict -> dict.toString(context)) - .collect(Collectors.toList()); - mappingResult.forEach(joiner::add); - return Optional.ofNullable(joiner.toString()); - } - - public void setMapping(Map mapping) { - this.mapping = mapping; - } - - DictMapping mappingOfValue(String value) { - DictMapping mapping = new DictMapping(); - mapping.setValue(value); - return mapping; - } - - protected class DictMapping implements Serializable { - private String key; - private String value; - private String expression; - private String expressionLanguage = "spel"; - private List children; - - private Map defaultVar; - - public void setDefaultVar(Map defaultVar) { - this.defaultVar = defaultVar; - } - - public Map getDefaultVar() { - return defaultVar; - } - - @Override - public int hashCode() { - if (value == null) { - return 0; - } - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - return obj == this || hashCode() == obj.hashCode(); - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public List getChildren() { - return children; - } - - public String getExpression() { - return expression; - } - - public void setExpression(String expression) { - this.expression = expression; - } - - public void setExpressionLanguage(String expressionLanguage) { - this.expressionLanguage = expressionLanguage; - } - - public String getExpressionLanguage() { - if (expressionLanguage == null) { - expressionLanguage = "spel"; - } - return expressionLanguage; - } - - public void setChildren(List children) { - this.children = children; - } - - public String toString(Function getter) { - StringBuilder stringBuilder = new StringBuilder(getter.apply(this)); - if (children != null) { - //根据getter 获取子节点的string - String childrenString = String.join(targetFormat.getChildSplitter(), children.stream() - .map(mapping -> mapping.toString(getter)).collect(Collectors.toList())); - - if (childrenString.isEmpty()) { - return stringBuilder.toString(); - } - //拼接子节点 - stringBuilder.append(targetFormat.getChildStartChar()) - .append(childrenString) - .append(targetFormat.getChildEndChar()); - } - return stringBuilder.toString(); - } - - public String toString(Object context) { - Function textGetter = - context == null ? DictMapping::getValue : - dictMapping -> { - if (dictMapping.getExpression() == null || dictMapping.getExpression().isEmpty()) { - return dictMapping.getValue(); - } - // 解析表达式 - Map var = new HashMap<>(); - if (dictMapping.getDefaultVar() != null) { - var.putAll(dictMapping.getDefaultVar()); - } - var.put("value", dictMapping.getValue()); - var.put("key", dictMapping.getKey()); - var.put("context", context); - var.put("children", dictMapping.getChildren()); - try { - return ExpressionUtils.analytical(dictMapping.getExpression(), var, dictMapping.getExpressionLanguage()); - } catch (Exception e) { - throw new RuntimeException("analytical " + dictMapping.getExpressionLanguage() + " expression :" + dictMapping.getExpression() + " error", e); - } - }; - return toString(textGetter); - } - - public String toTextString() { - return toString(DictMapping::getValue); - } - - public String toValueString() { - return toString(mapping -> String.valueOf(mapping.getValue())); - } - - @Override - public DictMapping clone() { - DictMapping clone = new DictMapping(); - clone.value = value; - clone.key = key; - clone.expression = expression; - clone.expressionLanguage = expressionLanguage; - if (children != null) { - clone.children = children.stream().map(DictMapping::clone).collect(Collectors.toList()); - } - return clone; - } - - public void filterChildren(Predicate mappingPredicate) { - if (children != null) { - children = children.stream() - .filter(mappingPredicate) - .collect(Collectors.toList()); - children.forEach(children -> children.filterChildren(mappingPredicate)); - } - } - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryItemMapper.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryItemMapper.xml deleted file mode 100644 index 59ea2b8da..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryItemMapper.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryMapper.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryMapper.xml deleted file mode 100644 index e652d678d..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryMapper.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryParserMapper.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryParserMapper.xml deleted file mode 100644 index 4edd0936d..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/dictionary/DictionaryParserMapper.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapperTest.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapperTest.java deleted file mode 100644 index 5461e87d7..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/DefaultDictionaryWrapperTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import org.hswebframework.web.dictionary.api.DictionaryInfo; -import org.hswebframework.web.dictionary.api.DictionaryInfoService; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -/** - * TODO 完成注释 - * - * @author zhouhao - * @since - */ -@RunWith(MockitoJUnitRunner.class) -public class DefaultDictionaryWrapperTest { - - @Mock - private DictionaryInfoService dictionaryInfoService; - - @InjectMocks - private DefaultDictionaryWrapper wrapper = new DefaultDictionaryWrapper(); - - @Before - public void init() { - List infos = new ArrayList<>(); - infos.add(DictionaryInfo.builder() - .value(TestDict.CODE0.getValue()) - .build()); - infos.add(DictionaryInfo.builder() - .value(TestDict.CODE1.getValue()) - .build()); - - when(dictionaryInfoService.select("org.hswebframework.web.dictionary.simple.TestBean.dict", "test", "TestDict")) - .thenReturn(infos); - - when(dictionaryInfoService.select("org.hswebframework.web.dictionary.simple.TestBean.dict2", "test", "TestDict")) - .thenReturn(Arrays.asList(infos.get(0))); - - when(dictionaryInfoService.insert(anyList())).then(invocationOnMock -> { - System.out.println(invocationOnMock.getArgumentAt(0, List.class)); - return null; - }); - - when(dictionaryInfoService.delete(anyString(),anyString(),anyString())).then(invocationOnMock -> { - System.out.println(Arrays.toString(invocationOnMock.getArguments())); - return null; - }); - } - - @Test - public void test() { - - TestBean bean = new TestBean(); - wrapper.wrap("test", bean); - System.out.println(bean); - Assert.assertNotNull(bean.getDict()); - Assert.assertEquals(bean.getDict().length, 2); - wrapper.persistent("test", bean); - - wrapper.wrap("test2", new EmptyDictBean()); - wrapper.persistent("test2", new EmptyDictBean()); - - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/EmptyDictBean.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/EmptyDictBean.java deleted file mode 100644 index 5494f7c93..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/EmptyDictBean.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import lombok.Data; - -/** - * @author zhouhao - * @since - */ -@Data -public class EmptyDictBean { - private String id; -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestBean.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestBean.java deleted file mode 100644 index 24be6ef96..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestBean.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * @author zhouhao - * @since - */ -@Data -@Getter -@Setter -@ToString -public class TestBean { - private TestDict[] dict; - - private TestDict dict2; -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestDict.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestDict.java deleted file mode 100644 index ae7bffb71..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-local/src/test/java/org/hswebframework/web/dictionary/simple/TestDict.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.hswebframework.web.dictionary.simple; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.web.dict.Dict; -import org.hswebframework.web.dict.EnumDict; - -@Getter -@AllArgsConstructor -@Dict(id = "TestDict") -public enum TestDict implements EnumDict { - - CODE0("TEST0","TEST0","TEST0"), - CODE1("TEST1","TEST1","TEST1"), - CODE2("TEST2","TEST2","TEST2"), - CODE3("TEST3","TEST3","TEST3"), - CODE4("TEST4","TEST4","TEST4"), - CODE5("TEST5","TEST5","TEST5"), - CODE6("TEST6","TEST6","TEST6"), - CODE7("TEST7","TEST7","TEST7"), - CODE8("TEST8","TEST8","TEST8"), - CODE9("TEST9","TEST9","TEST9"), - CODE10("TEST10","TEST10","TEST10"), - CODE11("TEST11","TEST11","TEST11"), - CODE12("TEST12","TEST12","TEST12"), - CODE13("TEST13","TEST13","TEST13"), - CODE14("TEST14","TEST14","TEST14"), - CODE15("TEST15","TEST15","TEST15"), - CODE16("TEST16","TEST16","TEST16"), - CODE17("TEST17","TEST17","TEST17"), - CODE18("TEST18","TEST18","TEST18"), - CODE19("TEST19","TEST19","TEST19"), - CODE20("TEST20","TEST20","TEST20"), - CODE21("TEST21","TEST21","TEST21"), - CODE22("TEST22","TEST22","TEST22"), - CODE23("TEST23","TEST23","TEST23"), - CODE24("TEST24","TEST24","TEST24"), - CODE25("TEST25","TEST25","TEST25"), - CODE26("TEST26","TEST26","TEST26"), - CODE27("TEST27","TEST27","TEST27"), - CODE28("TEST28","TEST28","TEST28"), - CODE29("TEST29","TEST29","TEST29"), - CODE30("TEST30","TEST30","TEST30"), - CODE31("TEST31","TEST31","TEST31"), - CODE32("TEST32","TEST32","TEST32"), - CODE33("TEST33","TEST33","TEST33"), - CODE34("TEST34","TEST34","TEST34"), - CODE35("TEST35","TEST35","TEST35"), - CODE36("TEST36","TEST36","TEST36"), - CODE37("TEST37","TEST37","TEST37"), - CODE38("TEST38","TEST38","TEST38"), - CODE39("TEST39","TEST39","TEST39"), - CODE40("TEST40","TEST40","TEST40"), - CODE41("TEST41","TEST41","TEST41"), - CODE42("TEST42","TEST42","TEST42"), - CODE43("TEST43","TEST43","TEST43"), - CODE44("TEST44","TEST44","TEST44"), - CODE45("TEST45","TEST45","TEST45"), - CODE46("TEST46","TEST46","TEST46"), - CODE47("TEST47","TEST47","TEST47"), - CODE48("TEST48","TEST48","TEST48"), - CODE49("TEST49","TEST49","TEST49"), - CODE50("TEST50","TEST50","TEST50"), - CODE51("TEST51","TEST51","TEST51"), - CODE52("TEST52","TEST52","TEST52"), - CODE53("TEST53","TEST53","TEST53"), - CODE54("TEST54","TEST54","TEST54"), - CODE55("TEST55","TEST55","TEST55"), - CODE56("TEST56","TEST56","TEST56"), - CODE57("TEST57","TEST57","TEST57"), - CODE58("TEST58","TEST58","TEST58"), - CODE59("TEST59","TEST59","TEST59"), - CODE60("TEST60","TEST60","TEST60"), - CODE61("TEST61","TEST61","TEST61"), - CODE62("TEST62","TEST62","TEST62"), - CODE63("TEST63","TEST63","TEST63"), - CODE64("TEST64","TEST64","TEST64"), - ; - - - private String value; - - private String text; - - private String comments; -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/pom.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/pom.xml deleted file mode 100644 index 3f95aae51..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - hsweb-system-dictionary - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dictionary-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-dictionary-local - ${project.version} - - - org.hswebframework.web - hsweb-system-dictionary-web - ${project.version} - - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/java/org/hswebframework/web/dictionary/starter/DictionaryFactoryAutoConfiguration.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/java/org/hswebframework/web/dictionary/starter/DictionaryFactoryAutoConfiguration.java deleted file mode 100644 index 27950c1e0..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/java/org/hswebframework/web/dictionary/starter/DictionaryFactoryAutoConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.hswebframework.web.dictionary.starter; - -import org.hswebframework.web.dao.Dao; -import org.hswebframework.web.dict.DictDefineRepository; -import org.hswebframework.web.dict.DictSupportApi; -import org.hswebframework.web.dict.defaults.DefaultDictSupportApi; -import org.hswebframework.web.dictionary.api.builder.DictionaryParserBuilder; -import org.hswebframework.web.dictionary.simple.builder.SimpleDictionaryParserBuilder; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.dictionary.simple" - , "org.hswebframework.web.controller.dictionary"}) -@MapperScan(value = "org.hswebframework.web.dictionary.simple.dao",markerInterface = Dao.class) -public class DictionaryFactoryAutoConfiguration { - @Bean - @ConditionalOnMissingBean(DictionaryParserBuilder.class) - public DictionaryParserBuilder dictionaryParserBuilder() { - return new SimpleDictionaryParserBuilder(); - } - - @Bean - public DictSupportApi dictSupportApi(DictDefineRepository repository) { - return new DefaultDictSupportApi(repository); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 88ad14c69..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.dictionary.starter.DictionaryFactoryAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 348391f7f..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2019 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. - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-dictionary", - author: "zh.sqy@qq.com", - comment: "数据字典" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.0", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; - -function install(context) { - var database = context.database; - database.createOrAlter("s_dictionary") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("字典名称").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("classified_id").alias("classifiedId").comment("分类id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("describe").alias("describe").comment("说明").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("creator_id").alias("creatorId").comment("创建人id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .comment("数据字典").commit(); - - database.createOrAlter("s_dict_item") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("dict_id").alias("dictId").comment("字典id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("name").alias("name").comment("名称").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("value").alias("value").comment("字典值").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("text").alias("text").comment("字典文本").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("value_type").alias("valueType").comment("字典值类型").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("describe").alias("describe").comment("说明").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("parent_id").alias("parentId").comment("父级选项").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("path").alias("path").comment("树编码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("search_code").alias("searchCode").comment("快速搜索码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("sort_index").alias("sortIndex").comment("排序索引").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("level_").alias("level").comment("树结构层级").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("ordinal").alias("ordinal").comment("识别码").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("properties").alias("properties").comment("其他自定义属性").jdbcType(java.sql.JDBCType.CLOB).commit() - .index().name("idx_dict_dic_id").column("dict_id").commit() - .index().name("idx_dict_path").column("path").commit() - .index().name("idx_dict_search_code").column("search_code").commit() - .index().name("idx_dict_ordinal").column("ordinal").commit() - .comment("数据字典选项配置").commit(); - - database.createOrAlter("s_dict_parser") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("v_t_parser").alias("valueToTextParser").comment("值到文本转换方式").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("t_v_parser").alias("textToValueParser").comment("文本到值转换方式").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("on_error").alias("onError").comment("转换失败时的操作").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("creator_id").alias("creatorId").comment("创建人id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("update_time").alias("updateTime").comment("更新时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("name").alias("name").comment("名称").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("describe").alias("describe").comment("说明").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("classified_id").alias("classifiedId").comment("分类id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .comment("数据字典解析配置").commit(); - -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryParserTests.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryParserTests.java deleted file mode 100644 index a7edb371e..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryParserTests.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2019 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.dictionary.starter; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.dictionary.api.entity.DictionaryParserEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class DictionaryParserTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - DictionaryParserEntity entity = entityFactory.newInstance(DictionaryParserEntity.class); - //todo 设置测试属性 - entity.setName("test"); - entity.setClassifiedId("1"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/dictionary-parser").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/dictionary-parser/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(DictionaryParserEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(DictionaryParserEntity.class)))); - //todo 修改测试属性 - DictionaryParserEntity newEntity = entityFactory.newInstance(DictionaryParserEntity.class); - newEntity.setName("test"); - newEntity.setClassifiedId("aasd"); - result = testPut("/dictionary-parser/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/dictionary-parser/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/dictionary-parser/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/dictionary-parser/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryTests.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryTests.java deleted file mode 100644 index 7c5bb57ce..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/java/org/hswebframework/web/dictionary/starter/DictionaryTests.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2019 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.dictionary.starter; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -import java.math.BigDecimal; -import java.util.List; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class DictionaryTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - DictionaryEntity entity = entityFactory.newInstance(DictionaryEntity.class); - //todo 设置测试属性 - entity.setName("test"); - entity.setCreatorId("admin"); - entity.setCreateTime(System.currentTimeMillis()); - entity.setId("test"); - entity.setDescribe("test"); - entity.setClassifiedId("test"); - entity.setStatus(DataStatus.STATUS_ENABLED); - String json = "[" + - "{'value':'1','text':'水果','children':" + - "[" + - "{'value':'101','text':'苹果'," + - "'children':[" + - "{'value':'10102','text':'红富士'}" + - ",{'value':'10103','text':'青苹果'}" + - //使用表达式进行解析 - ",{'value':'10105','text':'其他苹果'" + - ",'textExpression':'${#value}[${#context[otherApple]}]'" + - ",'valueExpression':'${(#context.put(\\'otherApple\\',#pattern.split(\"[ \\\\[ \\\\]]\")[1])==null)?#value:#value}'" + - "}" + - "]}" + - ",{'value':'102','text':'梨子'}]" + - "}" + - ",{'value':'2','text':'蔬菜'}" + - "]"; - - List itemEntities = JSON.parseArray(json, DictionaryItemEntity.class); - entity.setItems(itemEntities); - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/dictionary").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/dictionary/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(DictionaryEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(DictionaryEntity.class)))); - //todo 修改测试属性 - DictionaryEntity newEntity = entityFactory.newInstance(DictionaryEntity.class); - newEntity.setName("test"); - - result = testPut("/dictionary/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/dictionary/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/dictionary/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/dictionary/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/resources/application.yml deleted file mode 100644 index 166351836..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-starter/src/test/resources/application.yml +++ /dev/null @@ -1,13 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:dictionary_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 数据字典测试 - version: 3.0.0 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/pom.xml b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/pom.xml deleted file mode 100644 index 1d0da5dd8..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - hsweb-system-dictionary - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dictionary-web - - - - org.hswebframework.web - hsweb-system-dictionary-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - javax.servlet - javax.servlet-api - true - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java deleted file mode 100644 index c2983dc45..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryController.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2019 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.dictionary; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.dict.DictDefine; -import org.hswebframework.web.dict.DictDefineRepository; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.dict.ItemDefine; -import org.hswebframework.web.dictionary.api.DictionaryItemService; -import org.hswebframework.web.dictionary.api.DictionaryService; -import org.hswebframework.web.dictionary.api.entity.DictionaryEntity; -import org.hswebframework.web.dictionary.api.events.ClearDictionaryCacheEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.context.event.EventListener; -import org.springframework.transaction.event.TransactionalEventListener; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import static org.hswebframework.web.controller.message.ResponseMessage.*; - -/** - * 数据字典 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.dictionary:dictionary}") -@Authorize(permission = "dictionary", description = "数据字典管理") -@Api(value = "数据字典", tags = "数据字典-字典配置") -public class DictionaryController implements SimpleGenericEntityController { - - @Autowired - private DictionaryService dictionaryService; - - @Autowired - private DictDefineRepository repository; - - @Override - public DictionaryService getService() { - return dictionaryService; - } - - @GetMapping("/define/all") - @Authorize(merge = false) - @ApiOperation("获取数据全部字典定义信息") - public ResponseMessage> getAllDefineById() { - return ok(repository.getAllDefine()); - } - - @GetMapping("/define/{id:.+}") - @Authorize(merge = false) - @ApiOperation("获取数据字典定义信息") - public ResponseMessage getDefineById(@PathVariable String id) { - return ok(repository.getDefine(id)); - } - - @GetMapping("/define/{id:.+}/items") - @Authorize(merge = false) - @ApiOperation("获取数据字典选项信息") - public ResponseMessage>> getItemDefineById(@PathVariable String id) { - return ok(Optional.ofNullable(repository.getDefine(id)) - .map(DictDefine::getItems) - .orElse(new java.util.ArrayList<>())); - } - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryItemController.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryItemController.java deleted file mode 100644 index 7f730a111..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryItemController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2019 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.dictionary; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.dictionary.api.DictionaryItemService; -import org.hswebframework.web.dictionary.api.entity.DictionaryItemEntity; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 数据字典 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.dictionary-item:dictionary-item}") -@Authorize(permission = "dictionary", description = "数据字典管理") -@Api(value = "数据字典", tags = "数据字典-字典配置") -public class DictionaryItemController implements SimpleGenericEntityController { - - @Autowired - private DictionaryItemService dictionaryService; - - @Override - public DictionaryItemService getService() { - return dictionaryService; - } - - @Authorize(action = Permission.ACTION_UPDATE) - @PatchMapping(path = "/batch") - @ApiOperation("批量修改字典") - public ResponseMessage batchUpdate(@RequestBody List data) { - return ResponseMessage.ok(getService().updateBatch(data)); - } - -} diff --git a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryParserController.java b/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryParserController.java deleted file mode 100644 index f38490332..000000000 --- a/hsweb-system/hsweb-system-dictionary/hsweb-system-dictionary-web/src/main/java/org/hswebframework/web/controller/dictionary/DictionaryParserController.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 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.dictionary; - -import io.swagger.annotations.Api; -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.dictionary.api.DictionaryParserService; -import org.hswebframework.web.dictionary.api.entity.DictionaryParserEntity; -import org.hswebframework.web.logging.AccessLogger; -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.dictionary-parser:dictionary-parser}") -@Authorize(permission = "dictionary-parser", description = "数据字典解析配置") -@Api(value = "数据字典解析配置", tags = "数据字典-字典解析配置") -public class DictionaryParserController implements GenericEntityController { - - private DictionaryParserService dictionaryParserService; - - @Override - public DictionaryParserEntity modelToEntity(DictionaryParserEntity model, DictionaryParserEntity entity) { - return model; - } - - @Autowired - public void setDictionaryParserService(DictionaryParserService dictionaryParserService) { - this.dictionaryParserService = dictionaryParserService; - } - - @Override - public DictionaryParserService getService() { - return dictionaryParserService; - } -} diff --git a/hsweb-system/hsweb-system-dictionary/pom.xml b/hsweb-system/hsweb-system-dictionary/pom.xml deleted file mode 100644 index 1e744874d..000000000 --- a/hsweb-system/hsweb-system-dictionary/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-dictionary - pom - - hsweb-system-dictionary-starter - hsweb-system-dictionary-api - hsweb-system-dictionary-local - hsweb-system-dictionary-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/README.md b/hsweb-system/hsweb-system-dynamic-form/README.md deleted file mode 100644 index 74494aa29..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## 动态表单功能 -在线可视化设计表单,直接生成数据库表结构. 提供统一的CRUD API。 - -## API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/pom.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/pom.xml deleted file mode 100644 index 5c20c35b1..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - hsweb-system-dynamic-form - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-dynamic-form-api - - 动态表单api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DictConfig.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DictConfig.java deleted file mode 100644 index 6d9b7bb3c..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DictConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.entity.form; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.web.commons.bean.Bean; -import org.hswebframework.web.commons.entity.Entity; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0 - */ -@Setter -@Getter -public class DictConfig implements Bean { - - private static final long serialVersionUID = 2115608884837210121L; - - private String type; - - private String toField; - - private Map config=new HashMap<>(); - - private RDBColumnMetaData column; - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnBindEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnBindEntity.java deleted file mode 100644 index 3feece397..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnBindEntity.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.entity.form; - -import org.hswebframework.web.commons.entity.Entity; - -import java.util.List; - -/** - * 动态表单和表单列关联实体 - * - * @author zhouhao - * @since 3.0 - */ -public class DynamicFormColumnBindEntity implements Entity { - private DynamicFormEntity form; - - private List columns; - - - public DynamicFormColumnBindEntity() { - } - - public DynamicFormColumnBindEntity(DynamicFormEntity form, List columns) { - this.form = form; - this.columns = columns; - } - - public DynamicFormEntity getForm() { - return form; - } - - public void setForm(DynamicFormEntity form) { - this.form = form; - } - - public List getColumns() { - return columns; - } - - public void setColumns(List columns) { - this.columns = columns; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnEntity.java deleted file mode 100644 index 8c0cd74ec..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormColumnEntity.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.hswebframework.web.entity.form; - -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import java.util.List; - -/** - * 动态表单 实体 - * - * @author hsweb-generator-online - */ -public interface DynamicFormColumnEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 表单ID - */ - String formId = "formId"; - /** - * 字段名称 - */ - String name = "name"; - /** - * 数据库列 - */ - String columnName = "columnName"; - /** - * 备注 - */ - String describe = "describe"; - /** - * 别名 - */ - String alias = "alias"; - /** - * java类型 - */ - String javaType = "javaType"; - /** - * jdbc类型 - */ - String jdbcType = "jdbcType"; - /** - * 数据类型 - */ - String dataType = "dataType"; - /** - * 长度 - */ - String length = "length"; - /** - * 精度 - */ - String precision = "precision"; - /** - * 小数点位数 - */ - String scale = "scale"; - - /** - * 数据字典配置 - */ - String dictConfig = "dictConfig"; - - /** - * 其他配置 - */ - String properties = "properties"; - - /** - * 排序序号 - */ - String sortIndex = "sortIndex"; - - /** - * @return 表单ID - */ - @NotBlank(groups = CreateGroup.class) - String getFormId(); - - /** - * @param formId 表单ID - */ - void setFormId(String formId); - - /** - * @return 字段名称 - */ - @NotBlank(groups = CreateGroup.class) - String getName(); - - /** - * @param name 字段名称 - */ - void setName(String name); - - /** - * @return 数据库列 - */ - @NotBlank(groups = CreateGroup.class) - String getColumnName(); - - /** - * @param columnName 数据库列 - */ - void setColumnName(String columnName); - - /** - * @return 备注 - */ - String getDescribe(); - - /** - * @param describe 备注 - */ - void setDescribe(String describe); - - /** - * @return 别名 - */ - String getAlias(); - - /** - * @param alias 别名 - */ - void setAlias(String alias); - - /** - * @return java类型 - */ - @NotBlank(groups = CreateGroup.class) - String getJavaType(); - - /** - * @param javaType java类型 - */ - void setJavaType(String javaType); - - /** - * @return jdbc类型 - */ - @NotBlank(groups = CreateGroup.class) - String getJdbcType(); - - /** - * @param jdbcType jdbc类型 - */ - void setJdbcType(String jdbcType); - - /** - * @return 数据类型 - */ - String getDataType(); - - /** - * @param dataType 数据类型 - */ - void setDataType(String dataType); - - /** - * @return 长度 - */ - Integer getLength(); - - /** - * @param length 长度 - */ - void setLength(Integer length); - - /** - * @return 精度 - */ - Integer getPrecision(); - - /** - * @param precision 精度 - */ - void setPrecision(Integer precision); - - /** - * @return 小数点位数 - */ - Integer getScale(); - - /** - * @param scale 小数点位数 - */ - void setScale(Integer scale); - - void setDictConfig(String dictConfig); - - String getDictConfig(); - - Long getSortIndex(); - - void setSortIndex(Long sortIndex); - - List getValidator(); - - void setValidator(List validator); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormDeployLogEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormDeployLogEntity.java deleted file mode 100644 index 82c32a6b6..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormDeployLogEntity.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.hswebframework.web.entity.form; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 表单发布日志 实体 - * - * @author hsweb-generator-online - */ -public interface DynamicFormDeployLogEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 表单ID - */ - String formId = "formId"; - /** - * 发布的版本 - */ - String version = "version"; - /** - * 发布时间 - */ - String deployTime = "deployTime"; - /** - * 部署的元数据 - */ - String metaData = "metaData"; - /** - * 部署状态 - */ - String status = "status"; - - /** - * @return 表单ID - */ - String getFormId(); - - /** - * @param formId 表单ID - */ - void setFormId(String formId); - - /** - * @return 发布的版本 - */ - Long getVersion(); - - /** - * @param version 发布的版本 - */ - void setVersion(Long version); - - /** - * @return 发布时间 - */ - Long getDeployTime(); - - /** - * @param deployTime 发布时间 - */ - void setDeployTime(Long deployTime); - - /** - * @return 部署的元数据 - */ - String getMetaData(); - - /** - * @param metaData 部署的元数据 - */ - void setMetaData(String metaData); - - Byte getStatus(); - - void setStatus(Byte status); -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormEntity.java deleted file mode 100644 index a5edbec70..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/DynamicFormEntity.java +++ /dev/null @@ -1,222 +0,0 @@ -package org.hswebframework.web.entity.form; - -import io.swagger.annotations.ApiModelProperty; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -/** - * 动态表单 实体 - * - * @author hsweb-generator-online - */ -public interface DynamicFormEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 表单名称 - */ - String name = "name"; - /** - * 数据库表名 - */ - String databaseTableName = "databaseTableName"; - /** - * 备注 - */ - String describe = "describe"; - /** - * 版本 - */ - String version = "version"; - /** - * 创建人id - */ - String creatorId = "creatorId"; - /** - * 创建时间 - */ - String createTime = "createTime"; - /** - * 修改时间 - */ - String updateTime = "updateTime"; - /** - * 是否已发布 - */ - String deployed = "deployed"; - /** - * 别名 - */ - String alias = "alias"; - /** - * 触发器 - */ - String triggers = "triggers"; - /** - * 表链接 - */ - String correlations = "correlations"; - /** - * 数据源id,为空使用默认数据源 - */ - String dataSourceId = "dataSourceId"; - /** - * 表单类型 - */ - String type = "type"; - - String tags = "tags"; - - String getDatabaseName(); - - void setDatabaseName(String databaseName); - - /** - * @return 表单名称 - */ - @ApiModelProperty(value = "表单名称", required = true, example = "测试表单") - @NotBlank(groups = CreateGroup.class) - String getName(); - - /** - * @param name 表单名称 - */ - void setName(String name); - - /** - * @return 数据库表名 - */ - @ApiModelProperty(value = "数据库表名", required = true, example = "f_test_form") - @NotBlank(groups = CreateGroup.class) - String getDatabaseTableName(); - - /** - * @param databaseTableName 数据库表名 - */ - void setDatabaseTableName(String databaseTableName); - - /** - * @return 备注 - */ - - String getDescribe(); - - /** - * @param describe 备注 - */ - void setDescribe(String describe); - - /** - * @return 版本 - */ - @ApiModelProperty(value = "版本号,无需设置,每次保存自动自增.", example = "1") - Long getVersion(); - - /** - * @param version 版本 - */ - void setVersion(Long version); - - /** - * @return 创建人id - */ - @ApiModelProperty(value = "创建人,根据当前用户自动获取.", example = "1") - String getCreatorId(); - - /** - * @param creatorId 创建人id - */ - void setCreatorId(String creatorId); - - /** - * @return 创建时间 - */ - @ApiModelProperty(value = "创建时间,新增时自动设置.") - Long getCreateTime(); - - /** - * @param createTime 创建时间 - */ - void setCreateTime(Long createTime); - - /** - * @return 修改时间 - */ - @ApiModelProperty(value = "创建时间,修改时自动设置.") - Long getUpdateTime(); - - /** - * @param updateTime 修改时间 - */ - void setUpdateTime(Long updateTime); - - /** - * @return 是否已发布 - */ - @ApiModelProperty(value = "是否已发布,发布时自动设置.", example = "false") - Boolean getDeployed(); - - /** - * @param deployed 是否已发布 - */ - void setDeployed(Boolean deployed); - - /** - * @return 别名 - */ - @ApiModelProperty(value = "表别名.", example = "testForm") - String getAlias(); - - /** - * @param alias 别名 - */ - void setAlias(String alias); - - /** - * @return 触发器 - */ - @ApiModelProperty(value = "触发器.", example = "[{\"trigger\":\"update.before\",\"language\":\"groovy\",\"script\":\" return true;\"}]") - String getTriggers(); - - /** - * @param triggers 触发器 - */ - void setTriggers(String triggers); - - /** - * @return 表链接 - */ - String getCorrelations(); - - /** - * @param correlations 表链接 - */ - void setCorrelations(String correlations); - - /** - * @return 数据源id, 为空使用默认数据源 - */ - String getDataSourceId(); - - /** - * @param dataSourceId 数据源id,为空使用默认数据源 - */ - void setDataSourceId(String dataSourceId); - - /** - * @return 表单类型 - */ - String getType(); - - /** - * @param type 表单类型 - */ - void setType(String type); - - String getTags(); - - void setTags(String tags); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormColumnEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormColumnEntity.java deleted file mode 100644 index c085f4e52..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormColumnEntity.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.entity.form; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.List; - -/** - * 动态表单 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -public class SimpleDynamicFormColumnEntity extends SimpleGenericEntity implements DynamicFormColumnEntity { - //表单ID - private String formId; - //字段名称 - private String name; - //数据库列 - private String columnName; - //备注 - private String describe; - //别名 - private String alias; - //java类型 - private String javaType; - //jdbc类型 - private String jdbcType; - //数据类型 - private String dataType; - //长度 - private Integer length; - //精度 - private Integer precision; - //小数点位数 - private Integer scale; - //数据字典配置 - private String dictConfig; - //序号 - private Long sortIndex; - //验证器配置 - private List validator; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormDeployLogEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormDeployLogEntity.java deleted file mode 100644 index 6f8d67998..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormDeployLogEntity.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.hswebframework.web.entity.form; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 表单发布日志 - * - * @author hsweb-generator-online - */ -public class SimpleDynamicFormDeployLogEntity extends SimpleGenericEntity implements DynamicFormDeployLogEntity { - //表单ID - private String formId; - //发布的版本 - private Long version; - //发布时间 - private Long deployTime; - //部署的元数据 - private String metaData; - //部署状态 - private Byte status; - - /** - * @return 表单ID - */ - @Override - public String getFormId() { - return this.formId; - } - - /** - * @param formId 表单ID - */ - @Override - public void setFormId(String formId) { - this.formId = formId; - } - - /** - * @return 发布的版本 - */ - @Override - public Long getVersion() { - return this.version; - } - - /** - * @param version 发布的版本 - */ - @Override - public void setVersion(Long version) { - this.version = version; - } - - /** - * @return 发布时间 - */ - @Override - public Long getDeployTime() { - return this.deployTime; - } - - /** - * @param deployTime 发布时间 - */ - @Override - public void setDeployTime(Long deployTime) { - this.deployTime = deployTime; - } - - /** - * @return 部署的元数据 - */ - @Override - public String getMetaData() { - return this.metaData; - } - - /** - * @param metaData 部署的元数据 - */ - @Override - public void setMetaData(String metaData) { - this.metaData = metaData; - } - - @Override - public Byte getStatus() { - return status; - } - - @Override - public void setStatus(Byte status) { - this.status = status; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormEntity.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormEntity.java deleted file mode 100644 index b16b883c1..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/entity/form/SimpleDynamicFormEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.hswebframework.web.entity.form; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 动态表单 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -public class SimpleDynamicFormEntity extends SimpleGenericEntity implements DynamicFormEntity { - //表单名称 - private String name; - //数据库名 - private String databaseName; - //数据库表名 - private String databaseTableName; - //备注 - private String describe; - //版本 - private Long version; - //创建人id - private String creatorId; - //创建时间 - private Long createTime; - //修改时间 - private Long updateTime; - //是否已发布 - private Boolean deployed; - //别名 - private String alias; - //触发器 - private String triggers; - //表链接 - private String correlations; - //数据源id,为空使用默认数据源 - private String dataSourceId; - //表单类型 - private String type; - - private String tags; - - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DatabaseRepository.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DatabaseRepository.java deleted file mode 100644 index 03196850b..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DatabaseRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.ezorm.rdb.RDBDatabase; - -/** - * 数据库仓库,用于获取默认数据库信息,指定数据源的信息以及当前激活的数据库信息 - * - * @author zhouhao - * @see RDBDatabase - * @since 3.0 - */ -public interface DatabaseRepository { - RDBDatabase getDefaultDatabase(String databaseName); - - RDBDatabase getDatabase(String datasourceId,String databaseName); - - RDBDatabase getCurrentDatabase(); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormColumnService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormColumnService.java deleted file mode 100644 index 67aa23481..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormColumnService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 动态表单 服务类 - * - * @author hsweb-generator-online - */ -public interface DynamicFormColumnService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormDeployLogService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormDeployLogService.java deleted file mode 100644 index e82d64dbb..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormDeployLogService.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.web.entity.form.DynamicFormDeployLogEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 表单发布日志 服务类 - * - * @author hsweb-generator-online - */ -public interface DynamicFormDeployLogService extends CrudService { - DynamicFormDeployLogEntity selectLastDeployed(String formId); - - DynamicFormDeployLogEntity selectDeployed(String formId, long version); - - void cancelDeployed(String formId); - - void cancelDeployed(String formId, long version); - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java deleted file mode 100644 index a6d65a4c1..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormOperationService.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.DeleteParamEntity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.commons.entity.param.UpdateParamEntity; - -import java.util.List; - -/** - * 动态表单操作接口,用于对动态表单进行增删改查操作 - * - * @author zhouhao - * @since 3.0 - */ -public interface DynamicFormOperationService { - PagerResult selectPager(String formId, QueryParamEntity paramEntity); - - T selectSingle(String formId, QueryParamEntity paramEntity); - - List select(String formId, QueryParamEntity paramEntity); - - int count(String formId, QueryParamEntity paramEntity); - - int update(String formId, UpdateParamEntity paramEntity); - - T updateById(String formId, Object id, T data); - - T insert(String formId, T entity); - - int delete(String formId, DeleteParamEntity paramEntity); - - int deleteById(String formId, Object id); - - T saveOrUpdate(String formId, T data); - - T selectById(String formId, Object id); - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormService.java deleted file mode 100644 index 1128bae8d..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/DynamicFormService.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.web.entity.form.DynamicFormColumnBindEntity; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * 动态表单 服务类 - * - * @author hsweb-generator-online - */ -public interface DynamicFormService extends CrudService { - void deployAllFromLog(); - - void deployAll(); - - void deploy(String formId); - - void unDeploy(String formId); - - String saveOrUpdate(DynamicFormColumnBindEntity bindEntity); - - String saveOrUpdateColumn(DynamicFormColumnEntity columnEntity); - - List saveOrUpdateColumn(List columnEntities); - - DynamicFormColumnEntity deleteColumn(String id); - - List deleteColumn(List ids); - - List selectColumnsByFormId(String formId); - - DynamicFormColumnBindEntity selectLatestDeployed(String formId); - - DynamicFormColumnBindEntity selectEditing(String formId); - - DynamicFormColumnBindEntity selectDeployed(String formId, int version); - - long selectDeployedVersion(String formId); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/FormDeployService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/FormDeployService.java deleted file mode 100644 index 0953657c3..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/FormDeployService.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface FormDeployService { - void deploy(String formId); - - void deploy(DynamicFormEntity form, List columns, boolean updateMeta); - - void unDeploy(String formId); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/OptionalConvertBuilder.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/OptionalConvertBuilder.java deleted file mode 100644 index 3c0a79126..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/OptionalConvertBuilder.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.service.form; - -import org.hswebframework.ezorm.core.OptionConverter; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.web.entity.form.DictConfig; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; - -/** - * - * @author zhouhao - */ -public interface OptionalConvertBuilder { - OptionConverter build(DictConfig dictConfig); - - ValueConverter buildValueConverter(DictConfig dictConfig); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/DatabaseInitEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/DatabaseInitEvent.java deleted file mode 100644 index 8a36740ec..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/DatabaseInitEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.ezorm.rdb.RDBDatabase; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -public class DatabaseInitEvent { - - @Getter - private RDBDatabase database; - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataInsertBeforeEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataInsertBeforeEvent.java deleted file mode 100644 index ddadd0d4f..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataInsertBeforeEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.ezorm.rdb.RDBTable; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class FormDataInsertBeforeEvent { - private String formId; - - private RDBTable table; - - private T data; - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataQueryBeforeEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataQueryBeforeEvent.java deleted file mode 100644 index 3d69aa3e3..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataQueryBeforeEvent.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.ezorm.rdb.RDBTable; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class FormDataQueryBeforeEvent { - private String formId; - - private RDBTable table; - - private QueryParamEntity param; - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataUpdateBeforeEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataUpdateBeforeEvent.java deleted file mode 100644 index 6cfdebd56..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDataUpdateBeforeEvent.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.hswebframework.ezorm.rdb.RDBTable; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class FormDataUpdateBeforeEvent { - private String formId; - - private RDBTable table; - - private T data; - - private Object id; -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDeployEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDeployEvent.java deleted file mode 100644 index 5e833cd00..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormDeployEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class FormDeployEvent { - private String formId; -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormUnDeployEvent.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormUnDeployEvent.java deleted file mode 100644 index 8249865c1..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/events/FormUnDeployEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.service.form.events; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@AllArgsConstructor -@Getter -public class FormUnDeployEvent { - private String formId; -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/ColumnInitializeContext.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/ColumnInitializeContext.java deleted file mode 100644 index e6feecdf9..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/ColumnInitializeContext.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.form.initialize; - -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; - -/** - * @author zhouhao - */ -public interface ColumnInitializeContext extends TableInitializeContext { - DynamicFormColumnEntity getColumnEntity(); - - RDBColumnMetaData getColumn(); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/DynamicFormInitializeCustomizer.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/DynamicFormInitializeCustomizer.java deleted file mode 100644 index 5bd6fde5b..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/DynamicFormInitializeCustomizer.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.service.form.initialize; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface DynamicFormInitializeCustomizer { - void customTableSetting(TableInitializeContext context); - - void customTableColumnSetting(ColumnInitializeContext context); - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/TableInitializeContext.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/TableInitializeContext.java deleted file mode 100644 index 39a2793af..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-api/src/main/java/org/hswebframework/web/service/form/initialize/TableInitializeContext.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.service.form.initialize; - -import org.hswebframework.ezorm.rdb.RDBDatabase; -import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData; -import org.hswebframework.web.entity.form.DynamicFormEntity; - -/** - * @author zhouhao - */ -public interface TableInitializeContext { - - RDBDatabase getDatabase(); - - DynamicFormEntity getFormEntity(); - - RDBTableMetaData getTable(); - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/pom.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/pom.xml deleted file mode 100644 index 20c1e65a3..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - hsweb-system-dynamic-form - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-dynamic-form-local - - - - - org.glassfish - javax.el - true - - - ch.qos.logback - logback-classic - true - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-dynamic-form-api - ${project.version} - - - org.hswebframework.web - hsweb-concurrent-lock-api - ${project.version} - - - org.hswebframework.web - hsweb-system-dictionary-api - ${project.version} - - - org.hswebframework.web - hsweb-datasource-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormColumnDao.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormColumnDao.java deleted file mode 100644 index 640f367b0..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormColumnDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.form; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; - -/** -* 动态表单 DAO接口 -* @author hsweb-generator-online - */ -public interface DynamicFormColumnDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDao.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDao.java deleted file mode 100644 index a579d384f..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDao.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.dao.form; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.form.DynamicFormEntity; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * 动态表单 DAO接口 - * - * @author hsweb-generator-online - */ -public interface DynamicFormDao extends CrudDao { - void incrementVersion(String formId); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDeployLogDao.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDeployLogDao.java deleted file mode 100644 index ae98321a9..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/dao/form/DynamicFormDeployLogDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.form; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.form.DynamicFormDeployLogEntity; - -/** -* 表单发布日志 DAO接口 -* @author hsweb-generator-online - */ -public interface DynamicFormDeployLogDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/DynamicFormException.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/DynamicFormException.java deleted file mode 100644 index 534452ebb..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/DynamicFormException.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -/** - * 动态表单操作异常 - * - * @author zhouhao - * @since 3.0 - */ -public class DynamicFormException extends RuntimeException { - public DynamicFormException(String message, Throwable cause) { - super(message, cause); - } - - public DynamicFormException(Throwable cause) { - super(cause); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDatabaseRepository.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDatabaseRepository.java deleted file mode 100644 index 763bf43a8..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDatabaseRepository.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import org.hswebframework.ezorm.rdb.RDBDatabase; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.ezorm.rdb.meta.parser.*; -import org.hswebframework.ezorm.rdb.render.dialect.*; -import org.hswebframework.ezorm.rdb.simple.SimpleDatabase; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.datasource.DatabaseType; -import org.hswebframework.web.datasource.DynamicDataSource; -import org.hswebframework.web.service.form.DatabaseRepository; -import org.hswebframework.web.service.form.DynamicFormService; -import org.hswebframework.web.service.form.FormDeployService; -import org.hswebframework.web.service.form.events.DatabaseInitEvent; -import org.hswebframework.web.service.form.simple.cluster.ClusterDatabase; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; - -@Service -public class SimpleDatabaseRepository implements DatabaseRepository { - - private volatile RDBDatabase defaultDatabase = null; - private SqlExecutor sqlExecutor = null; - - @Value("${hsweb.dynamic-form.cluster:false}") - private boolean cluster = false; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - private final Map repository = new HashMap<>(); - private final Map> databaseMetaSuppliers = new EnumMap<>(DatabaseType.class); - - @Autowired - public void setSqlExecutor(SqlExecutor sqlExecutor) { - this.sqlExecutor = sqlExecutor; - } - - @PostConstruct - public void init() { - Objects.requireNonNull(sqlExecutor); - databaseMetaSuppliers.put(DatabaseType.oracle, () -> { - OracleRDBDatabaseMetaData metaData = new OracleRDBDatabaseMetaData(); - metaData.setParser(new OracleTableMetaParser(sqlExecutor)); - return metaData; - }); - - databaseMetaSuppliers.put(DatabaseType.mysql, () -> { - MysqlRDBDatabaseMetaData metaData = new MysqlRDBDatabaseMetaData(); - metaData.setParser(new MysqlTableMetaParser(sqlExecutor)); - return metaData; - }); - - databaseMetaSuppliers.put(DatabaseType.h2, () -> { - H2RDBDatabaseMetaData metaData = new H2RDBDatabaseMetaData(); - metaData.setParser(new H2TableMetaParser(sqlExecutor)); - return metaData; - }); - databaseMetaSuppliers.put(DatabaseType.jtds_sqlserver, () -> { - MSSQLRDBDatabaseMetaData metaData = new MSSQLRDBDatabaseMetaData(); - metaData.setParser(new SqlServer2012TableMetaParser(sqlExecutor)); - return metaData; - }); - databaseMetaSuppliers.put(DatabaseType.sqlserver, databaseMetaSuppliers.get(DatabaseType.jtds_sqlserver)); - - databaseMetaSuppliers.put(DatabaseType.postgresql, () -> { - PGRDBDatabaseMetaData metaData = new PGRDBDatabaseMetaData(); - metaData.setParser(new PGSqlTableMetaParser(sqlExecutor)); - return metaData; - }); - - } - - @Override - public RDBDatabase getDefaultDatabase(String databaseName) { - return repository.computeIfAbsent("DEFAULT." + databaseName, id -> this.initDatabase(DataSourceHolder.defaultDatabaseType(), databaseName)); - } - - @Override - public RDBDatabase getDatabase(String datasourceId, String databaseName) { - DynamicDataSource dynamicDataSource = DataSourceHolder.dataSource(datasourceId); - return repository.computeIfAbsent(datasourceId + "." + databaseName, id -> this.initDatabase(dynamicDataSource.getType(), databaseName)); - } - - @Override - public RDBDatabase getCurrentDatabase() { - return repository - .computeIfAbsent(DataSourceHolder.switcher().currentDataSourceId() - , id -> this.initDatabase(DataSourceHolder.currentDatabaseType(), null)); - } - - - private RDBDatabase initDatabase(DatabaseType databaseType, String databaseName) { - Supplier supplier = databaseMetaSuppliers.get(databaseType); - Objects.requireNonNull(supplier, "database type" + databaseType + " is not support"); - AbstractRDBDatabaseMetaData metaData = supplier.get(); - metaData.setDatabaseName(databaseName); - SimpleDatabase database = cluster ? - new ClusterDatabase(metaData, sqlExecutor) : - new SimpleDatabase(metaData, sqlExecutor); - database.setAutoParse(true); - eventPublisher.publishEvent(new DatabaseInitEvent(database)); - return database; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormColumnService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormColumnService.java deleted file mode 100644 index 426e68e7b..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormColumnService.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import org.hswebframework.web.dao.form.DynamicFormColumnDao; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.form.DynamicFormColumnService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dynamicFormColumnService") -public class SimpleDynamicFormColumnService extends GenericEntityService - implements DynamicFormColumnService { - @Autowired - private DynamicFormColumnDao dynamicFormColumnDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DynamicFormColumnDao getDao() { - return dynamicFormColumnDao; - } - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormDeployLogService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormDeployLogService.java deleted file mode 100644 index bcf2edfce..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormDeployLogService.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.serializer.SerializerFeature; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.form.DynamicFormDeployLogDao; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.entity.form.DynamicFormDeployLogEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.form.DynamicFormDeployLogService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dynamicFormDeployLogService") -public class SimpleDynamicFormDeployLogService extends GenericEntityService - implements DynamicFormDeployLogService { - @Autowired - private DynamicFormDeployLogDao dynamicFormDeployLogDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DynamicFormDeployLogDao getDao() { - return dynamicFormDeployLogDao; - } - - @Override - public DynamicFormDeployLogEntity selectLastDeployed(String formId) { - Objects.requireNonNull(formId); - DynamicFormDeployLogEntity deployed = createQuery() - .where(DynamicFormDeployLogEntity.formId, formId) - .orderByDesc(DynamicFormDeployLogEntity.deployTime) - .single(); - if (null != deployed && DataStatus.STATUS_ENABLED.equals(deployed.getStatus())) { - return deployed; - } - return null; - } - - @Override - public DynamicFormDeployLogEntity selectDeployed(String formId, long version) { - Objects.requireNonNull(formId); - DynamicFormDeployLogEntity deployed = createQuery() - .where(DynamicFormDeployLogEntity.formId, formId) - .and(DynamicFormDeployLogEntity.version, version) - .orderByDesc(DynamicFormDeployLogEntity.deployTime) - .single(); - if (null != deployed && DataStatus.STATUS_ENABLED.equals(deployed.getStatus())) { - return deployed; - } - return null; - } - - @Override - public void cancelDeployed(String formId) { - Objects.requireNonNull(formId); - DynamicFormDeployLogEntity deployed = createQuery() - .where(DynamicFormDeployLogEntity.formId, formId) - .orderByDesc(DynamicFormDeployLogEntity.deployTime) - .single(); - if (deployed != null) { - createUpdate() - .set(DynamicFormDeployLogEntity.status, DataStatus.STATUS_DISABLED) - .where(DynamicFormDeployLogEntity.id, deployed.getId()) - .exec(); - } - } - - @Override - public void cancelDeployed(String formId, long version) { - Objects.requireNonNull(formId); - createUpdate() - .set(DynamicFormDeployLogEntity.status, DataStatus.STATUS_DISABLED) - .where(DynamicFormDeployLogEntity.formId, formId) - .and(DynamicFormDeployLogEntity.version, version) - .exec(); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java deleted file mode 100644 index 961245072..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormOperationService.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.core.Delete; -import org.hswebframework.ezorm.core.Insert; -import org.hswebframework.ezorm.core.Update; -import org.hswebframework.ezorm.rdb.RDBDatabase; -import org.hswebframework.ezorm.rdb.RDBQuery; -import org.hswebframework.ezorm.rdb.RDBTable; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.DeleteParamEntity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.commons.entity.param.UpdateParamEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; -import org.hswebframework.web.service.form.DatabaseRepository; -import org.hswebframework.web.service.form.DynamicFormOperationService; -import org.hswebframework.web.service.form.DynamicFormService; -import org.hswebframework.web.service.form.FormDeployService; -import org.hswebframework.web.service.form.events.FormDataInsertBeforeEvent; -import org.hswebframework.web.service.form.events.FormDataUpdateBeforeEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@Service("dynamicFormOperationService") -@Transactional(rollbackFor = Throwable.class) -@Slf4j -public class SimpleDynamicFormOperationService implements DynamicFormOperationService { - - @Autowired - private DynamicFormService dynamicFormService; - - @Autowired - private DatabaseRepository databaseRepository; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - protected RDBTable getTable(String formId) { - DynamicFormEntity form = dynamicFormService.selectByPk(formId); - if (null == form || Boolean.FALSE.equals(form.getDeployed())) { - throw new NotFoundException("表单不存在"); - } - RDBDatabase database = StringUtils.isEmpty(form.getDataSourceId()) ? - databaseRepository.getDefaultDatabase(form.getDatabaseName()) : - databaseRepository.getDatabase(form.getDataSourceId(),form.getDatabaseName()); - return database.getTable(form.getDatabaseTableName()); - } - - protected RDBDatabase getDatabase(String formId) { - DynamicFormEntity form = dynamicFormService.selectByPk(formId); - if (null == form || Boolean.FALSE.equals(form.getDeployed())) { - throw new NotFoundException("表单不存在"); - } - return StringUtils.isEmpty(form.getDataSourceId()) ? - databaseRepository.getDefaultDatabase(form.getDatabaseName()) : - databaseRepository.getDatabase(form.getDataSourceId(),form.getDatabaseName()); - } - - @Override - @Transactional(readOnly = true) - @SneakyThrows - public PagerResult selectPager(String formId, QueryParamEntity paramEntity) { - RDBTable table = getTable(formId); - RDBQuery query = table.createQuery(); - int total = query.setParam(paramEntity).total(); - if (total == 0) { - return PagerResult.empty(); - } - paramEntity.rePaging(total); - List list = query.setParam(paramEntity).list(paramEntity.getPageIndex(), paramEntity.getPageSize()); - return PagerResult.of(total, list, paramEntity); - } - - @Override - @Transactional(readOnly = true) - @SneakyThrows - public List select(String formId, QueryParamEntity paramEntity) { - RDBTable table = getTable(formId); - RDBQuery query = table.createQuery(); - return query.setParam(paramEntity).list(); - } - - @Override - @Transactional(readOnly = true) - @SneakyThrows - public T selectSingle(String formId, QueryParamEntity paramEntity) { - RDBTable table = getTable(formId); - RDBQuery query = table.createQuery(); - return query.setParam(paramEntity).single(); - } - - @Override - @Transactional(readOnly = true) - @SneakyThrows - public int count(String formId, QueryParamEntity paramEntity) { - RDBTable table = getTable(formId); - RDBQuery query = table.createQuery(); - return query.setParam(paramEntity).total(); - } - - @Override - @SneakyThrows - public int update(String formId, UpdateParamEntity paramEntity) { - if (Objects.requireNonNull(paramEntity).getTerms().isEmpty()) { - throw new UnsupportedOperationException("不能执行无条件的更新操作"); - } - RDBTable table = getTable(formId); - Update update = table.createUpdate(); - return update.setParam(paramEntity).exec(); - } - - @Override - @SneakyThrows - public T insert(String formId, T entity) { - RDBTable table = getTable(formId); - Insert insert = table.createInsert(); - eventPublisher.publishEvent(new FormDataInsertBeforeEvent<>(formId, table, entity)); - insert.value(entity).exec(); - return entity; - } - - private String getIdProperty(RDBTableMetaData tableMetaData) { - return tableMetaData.getColumns() - .stream() - .filter(RDBColumnMetaData::isPrimaryKey) - .findFirst() - .map(RDBColumnMetaData::getAlias) - .orElseThrow(() -> new BusinessException("表[" + tableMetaData.getComment() + "]未设置主键字段")); - } - - @SneakyThrows - protected Object getExistingDataId(String formId, T data) { - RDBTable table = getTable(formId); - String triggerName = "check-data-existing"; - - boolean useTrigger = table.getMeta().triggerIsSupport(triggerName); - String idProperty = getIdProperty(table.getMeta()); - //使用触发器来判断是否存在重复数据 - if (useTrigger) { - Map triggerContext = new HashMap<>(); - triggerContext.put("table", table); - triggerContext.put("database", getDatabase(formId)); - triggerContext.put("data", data); - Object result = table.getMeta().on(triggerName, triggerContext); - if (result instanceof String) { - return result; - } - if (result instanceof Map) { - Object id = ((Map) result).get(idProperty); - if (id == null) { - log.error("table:[{}]触发器返回了数据:[{}],但是不包含主键字段:[{}]", - table.getMeta().getName(), - data, - idProperty); - throw new BusinessException("数据错误,请联系管理员"); - } - return id; - } - } else { - Map mapData = FastBeanCopier.copy(data, new HashMap<>()); - Object id = mapData.get(idProperty); - if (null == id) { - return null; - } - Object existing = selectSingle(formId, QueryParamEntity.single(idProperty, id).includes(idProperty)); - if (null != existing) { - mapData = FastBeanCopier.copy(data, new HashMap<>()); - return mapData.get(idProperty); - } - } - - return null; - - } - - @Override - @SneakyThrows - public T saveOrUpdate(String formId, T data) { - Objects.requireNonNull(formId, "表单ID不能为空"); - Object id = getExistingDataId(formId, data); - if (null == id) { - insert(formId, data); - } else { - updateById(formId, id, data); - } - return data; - } - - @Override - @SneakyThrows - public int delete(String formId, DeleteParamEntity paramEntity) { - if (Objects.requireNonNull(paramEntity).getTerms().isEmpty()) { - throw new UnsupportedOperationException("不能执行无条件的删除操作"); - } - RDBTable table = getTable(formId); - Delete delete = table.createDelete(); - return delete.setParam(paramEntity).exec(); - } - - @Override - @SneakyThrows - public int deleteById(String formId, Object id) { - Objects.requireNonNull(id, "主键不能为空"); - RDBTable table = getTable(formId); - return table.createDelete() - .where(getIdProperty(table.getMeta()), id) - .exec(); - } - - @Override - @SneakyThrows - public T selectById(String formId, Object id) { - Objects.requireNonNull(id, "主键不能为空"); - RDBTable table = getTable(formId); - return table.createQuery() - .where(getIdProperty(table.getMeta()), id) - .single(); - } - - @Override - @SneakyThrows - public T updateById(String formId, Object id, T data) { - Objects.requireNonNull(id, "主键不能为空"); - RDBTable table = getTable(formId); - - eventPublisher.publishEvent(new FormDataUpdateBeforeEvent<>(formId, table, data, id)); - - table.createUpdate() - .set(data) - .where(getIdProperty(table.getMeta()), id) - .exec(); - return data; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormService.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormService.java deleted file mode 100644 index 977c01622..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormService.java +++ /dev/null @@ -1,758 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.ezorm.core.ObjectWrapperFactory; -import org.hswebframework.ezorm.core.Trigger; -import org.hswebframework.ezorm.core.ValidatorFactory; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.ezorm.rdb.RDBDatabase; -import org.hswebframework.ezorm.rdb.meta.Correlation; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData; -import org.hswebframework.ezorm.rdb.meta.converter.*; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.simple.trigger.ScriptTraggerSupport; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.form.DynamicFormColumnDao; -import org.hswebframework.web.dao.form.DynamicFormDao; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.entity.form.*; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLDeleteService; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.DefaultDSLUpdateService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.form.*; -import org.hswebframework.web.service.form.events.FormDeployEvent; -import org.hswebframework.web.service.form.initialize.ColumnInitializeContext; -import org.hswebframework.web.service.form.initialize.DynamicFormInitializeCustomizer; -import org.hswebframework.web.service.form.initialize.TableInitializeContext; -import org.hswebframework.web.service.form.simple.dict.EnumDictValueConverter; -import org.hswebframework.web.validator.group.CreateGroup; -import org.hswebframework.web.validator.group.UpdateGroup; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.sql.JDBCType; -import java.sql.SQLException; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("dynamicFormService") -@CacheConfig(cacheNames = "dyn-form") -public class SimpleDynamicFormService extends GenericEntityService - implements DynamicFormService, FormDeployService { - - @Value("${hsweb.dynamic-form.tags:none}") - private String[] tags; - - @Value("${hsweb.dynamic-form.tag:none}") - private String tag; - - @Value("${hsweb.dynamic-form.load-only-tags:null}") - private String[] loadOnlyTags; - - @Autowired - private DynamicFormDao dynamicFormDao; - - @Autowired - private DynamicFormColumnDao formColumnDao; - - @Autowired - private DatabaseRepository databaseRepository; - - @Autowired - private DynamicFormDeployLogService dynamicFormDeployLogService; - - @Autowired(required = false) - private OptionalConvertBuilder optionalConvertBuilder; - - @Autowired(required = false) - private List initializeCustomizers; - - @Autowired - private ValidatorFactory validatorFactory; - - @Autowired(required = false) - private ObjectWrapperFactory objectWrapperFactory; - - @Autowired - private ApplicationEventPublisher eventPublisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DynamicFormDao getDao() { - return dynamicFormDao; - } - - @Override - @Caching(evict = { - @CacheEvict(value = "dyn-form-deploy", allEntries = true), - @CacheEvict(value = "dyn-form", allEntries = true), - }) - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public void deployAllFromLog() { - - List tags = new ArrayList<>(Arrays.asList(this.tags)); - if (loadOnlyTags != null) { - tags.addAll(Arrays.asList(loadOnlyTags)); - } - List entities = createQuery() - .select(DynamicFormEntity.id) - .where(DynamicFormEntity.deployed, true) - .and() - .in(DynamicFormEntity.tags, tags) - .listNoPaging(); - if (logger.isDebugEnabled()) { - logger.debug("do deploy all form , size:{}", entities.size()); - } - for (DynamicFormEntity form : entities) { - DynamicFormDeployLogEntity logEntity = dynamicFormDeployLogService.selectLastDeployed(form.getId()); - if (null != logEntity) { - deployFromLog(logEntity); - } - } - } - - @Override - @Caching(evict = { - @CacheEvict(value = "dyn-form-deploy", allEntries = true), - @CacheEvict(value = "dyn-form", allEntries = true), - }) - public void deployAll() { - createQuery() - .select(DynamicFormEntity.id) - .listNoPaging() - .forEach(form -> this.deploy(form.getId())); - } - - public DynamicFormDeployLogEntity createDeployLog(DynamicFormEntity form, List columns) { - DynamicFormDeployLogEntity entity = entityFactory.newInstance(DynamicFormDeployLogEntity.class); - entity.setStatus(DataStatus.STATUS_ENABLED); - entity.setDeployTime(System.currentTimeMillis()); - entity.setVersion(form.getVersion()); - entity.setFormId(form.getId()); - DynamicFormColumnBindEntity bindEntity = new DynamicFormColumnBindEntity(); - bindEntity.setForm(form); - bindEntity.setColumns(columns); - entity.setMetaData(JSON.toJSONString(bindEntity)); - return entity; - } - - - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public void deployFromLog(DynamicFormDeployLogEntity logEntity) { - DynamicFormColumnBindEntity entity = JSON.parseObject(logEntity.getMetaData(), DynamicFormColumnBindEntity.class); - DynamicFormEntity form = entity.getForm(); - List columns = entity.getColumns(); - if (logger.isDebugEnabled()) { - logger.debug("do deploy form {} , columns size:{}", form.getName(), columns.size()); - } - - deploy(form, columns, !(loadOnlyTags != null && Arrays.asList(loadOnlyTags).contains(entity.getForm().getTags()))); - } - - - @Override - @CacheEvict(key = "'form_id:'+#entity.id") - public String insert(DynamicFormEntity entity) { - entity.setDeployed(false); - entity.setVersion(1L); - entity.setCreateTime(System.currentTimeMillis()); - entity.setTags(tag); - return super.insert(entity); - } - - @Override - @Cacheable(key = "'form_id:'+#id") - public DynamicFormEntity selectByPk(String id) { - return super.selectByPk(id); - } - - @Override - @CacheEvict(key = "'form_id:'+#id") - public int updateByPk(String id, DynamicFormEntity entity) { - entity.setVersion(null); - entity.setDeployed(null); - entity.setUpdateTime(System.currentTimeMillis()); - getDao().incrementVersion(id); - return super.updateByPk(id, entity); - } - - protected void initDatabase(RDBDatabase database) { - - } - - @Override - @Caching(evict = { - @CacheEvict(value = "dyn-form-deploy", allEntries = true), - @CacheEvict(value = "dyn-form", allEntries = true), - }) - public void unDeploy(String formId) { - DynamicFormEntity form = selectByPk(formId); - assertNotNull(form); - //取消发布 - dynamicFormDeployLogService.cancelDeployed(formId); - //移除表结构定义 - RDBDatabase database = StringUtils.isEmpty(form.getDataSourceId()) - ? databaseRepository.getDefaultDatabase(form.getDatabaseName()) - : databaseRepository.getDatabase(form.getDataSourceId(),form.getDatabaseName()); - database.removeTable(form.getDatabaseTableName()); - createUpdate().set(DynamicFormEntity.deployed, false).where(DynamicFormEntity.id, formId).exec(); - eventPublisher.publishEvent(new FormDeployEvent(formId)); - } - - private String saveOrUpdate0(DynamicFormColumnEntity columnEntity) { - if (StringUtils.isEmpty(columnEntity.getId()) - || DefaultDSLQueryService.createQuery(formColumnDao) - .where(DynamicFormColumnEntity.id, columnEntity.getId()) - .total() == 0) { - if (StringUtils.isEmpty(columnEntity.getId())) { - columnEntity.setId(getIDGenerator().generate()); - } - tryValidate(columnEntity, CreateGroup.class); - formColumnDao.insert(columnEntity); - } else { - tryValidate(columnEntity, UpdateGroup.class); - DefaultDSLUpdateService - .createUpdate(formColumnDao, columnEntity) - .where(DynamicFormColumnEntity.id, columnEntity.getId()) - .exec(); - } - return columnEntity.getId(); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'form-columns:'+#columnEntity.formId"), - @CacheEvict(key = "'form_id:'+#columnEntity.formId"), - - } - ) - public String saveOrUpdateColumn(DynamicFormColumnEntity columnEntity) { - String id = saveOrUpdate0(columnEntity); - getDao().incrementVersion(columnEntity.getFormId()); - return id; - } - - @Override - @CacheEvict(allEntries = true) - public List saveOrUpdateColumn(List columnEntities) { - Set formId = new HashSet<>(); - - List columnIds = columnEntities.stream() - .peek(columnEntity -> formId.add(columnEntity.getFormId())) - .map(this::saveOrUpdateColumn) - .collect(Collectors.toList()); - - formId.forEach(getDao()::incrementVersion); - return columnIds; - - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'form-columns:'+#result"), - @CacheEvict(key = "'form_id:'+#result"), - - } - ) - public String saveOrUpdate(DynamicFormColumnBindEntity bindEntity) { - DynamicFormEntity formEntity = bindEntity.getForm(); - - List columnEntities = bindEntity.getColumns(); - //保存表单 - saveOrUpdate(formEntity); - - //保存表单列 - columnEntities.stream() - .peek(column -> column.setFormId(formEntity.getId())) - .forEach(this::saveOrUpdate0); - - return formEntity.getId(); - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'form-columns:'+#formId"), - @CacheEvict(key = "'form_id:'+#formId"), - - } - ) - public DynamicFormColumnEntity deleteColumn(String formId) { - DynamicFormColumnEntity oldColumn = DefaultDSLQueryService - .createQuery(formColumnDao) - .where(DynamicFormColumnEntity.id, formId) - .single(); - assertNotNull(oldColumn); - DefaultDSLDeleteService.createDelete(formColumnDao) - .where(DynamicFormDeployLogEntity.id, formId) - .exec(); - return oldColumn; - } - - @Override - @Caching( - evict = { - @CacheEvict(key = "'form-columns:'+#id"), - @CacheEvict(key = "'form_id:'+#id") - }) - public DynamicFormEntity deleteByPk(String id) { - Objects.requireNonNull(id, "id can not be null"); - - DefaultDSLDeleteService.createDelete(formColumnDao) - .where(DynamicFormColumnEntity.formId, id) - .exec(); - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public List deleteColumn(List ids) { - Objects.requireNonNull(ids); - if (ids.isEmpty()) { - return new java.util.ArrayList<>(); - } - List oldColumns = DefaultDSLQueryService - .createQuery(formColumnDao) - .where() - .in(DynamicFormColumnEntity.id, ids) - .listNoPaging(); - - DefaultDSLDeleteService.createDelete(formColumnDao) - .where().in(DynamicFormDeployLogEntity.id, ids) - .exec(); - return oldColumns; - } - - @Override - public List selectColumnsByFormId(String formId) { - Objects.requireNonNull(formId); - return DefaultDSLQueryService.createQuery(formColumnDao) - .where(DynamicFormColumnEntity.formId, formId) - .orderByAsc(DynamicFormColumnEntity.sortIndex) - .listNoPaging(); - } - - @Override - @Cacheable(value = "dyn-form-deploy", key = "'form-deploy:'+#formId+':'+#version") - public DynamicFormColumnBindEntity selectDeployed(String formId, int version) { - DynamicFormDeployLogEntity entity = dynamicFormDeployLogService.selectDeployed(formId, version); - if (entity == null) { - return null; - } - return JSON.parseObject(entity.getMetaData(), DynamicFormColumnBindEntity.class); - } - - @Override - @Cacheable(value = "dyn-form-deploy", key = "'form-deploy-version:'+#formId") - public long selectDeployedVersion(String formId) { - DynamicFormColumnBindEntity entity = selectLatestDeployed(formId); - if (null != entity) { - return entity.getForm().getVersion(); - } - return 0L; - } - - @Override - @Cacheable(value = "dyn-form-deploy", key = "'form-deploy:'+#formId+':latest'") - public DynamicFormColumnBindEntity selectLatestDeployed(String formId) { - DynamicFormDeployLogEntity entity = dynamicFormDeployLogService.selectLastDeployed(formId); - if (entity == null) { - return null; - } - return JSON.parseObject(entity.getMetaData(), DynamicFormColumnBindEntity.class); - } - - @Override - public DynamicFormColumnBindEntity selectEditing(String formId) { - Objects.requireNonNull(formId); - return new DynamicFormColumnBindEntity(selectByPk(formId), selectColumnsByFormId(formId)); - } - - @Override - @Caching(evict = { - @CacheEvict(value = "dyn-form-deploy", key = "'form-deploy-version:'+#formId"), - @CacheEvict(value = "dyn-form-deploy", key = "'form-deploy:'+#formId+':latest'"), - @CacheEvict(value = "dyn-form", allEntries = true) - }) - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public void deploy(String formId) { - DynamicFormEntity formEntity = selectByPk(formId); - assertNotNull(formEntity); - if (Boolean.TRUE.equals(formEntity.getDeployed())) { - dynamicFormDeployLogService.cancelDeployed(formId); - } - List columns = selectColumnsByFormId(formId); - deploy(formEntity, columns, true); - createUpdate().set(DynamicFormEntity.deployed, true).where(DynamicFormEntity.id, formId).exec(); - try { - dynamicFormDeployLogService.insert(createDeployLog(formEntity, columns)); - eventPublisher.publishEvent(new FormDeployEvent(formId)); - } catch (Exception e) { - unDeploy(formId); - throw e; - } - } - - public void deploy(DynamicFormEntity form, List columns, boolean updateMeta) { - RDBDatabase database = StringUtils.isEmpty(form.getDataSourceId()) - ? databaseRepository.getDefaultDatabase(form.getDatabaseName()) - : databaseRepository.getDatabase(form.getDataSourceId(),form.getDatabaseName()); - - initDatabase(database); - RDBTableMetaData metaData = buildTable(database, form, columns); - try { - if (!database.getMeta().getParser().tableExists(metaData.getName())) { - database.createTable(metaData); - } else { - if (!updateMeta) { - database.reloadTable(metaData); - } else { - database.alterTable(metaData); - } - } - } catch (SQLException e) { - throw new DynamicFormException("部署失败:" + e.getMessage(), e); - } - } - - protected Set buildCorrelations(String correlations) { - if (StringUtils.isEmpty(correlations)) { - return new LinkedHashSet<>(); - } - JSONArray correlationsConfig = JSON.parseArray(correlations); - Set correlations1 = new LinkedHashSet<>(); - for (int i = 0; i < correlationsConfig.size(); i++) { - JSONObject single = correlationsConfig.getJSONObject(i); - - String target = single.getString("target"); - String alias = single.getString("alias"); - String condition = single.getString("condition"); - Objects.requireNonNull(target); - Objects.requireNonNull(condition); - Correlation correlation = new Correlation(target, alias, condition); - correlation.setJoin(Correlation.JOIN.valueOf(String.valueOf(single.getOrDefault("join", "LEFT")).toUpperCase())); - JSONObject properties = single.getJSONObject("properties"); - - if (properties != null) { - properties.forEach(correlation::setProperty); - } - correlations1.add(correlation); - } - - return correlations1; - - } - - protected Map buildTrigger(String config) { - if (StringUtils.isEmpty(config)) { - return new HashMap<>(); - } - JSONArray triggerConfig = JSON.parseArray(config); - Map triggers = new HashMap<>(); - for (int i = 0; i < triggerConfig.size(); i++) { - JSONObject single = triggerConfig.getJSONObject(i); - String trigger = single.getString("trigger"); - String language = single.getString("language"); - String script = single.getString("script"); - String scriptId = DigestUtils.md5Hex(script); - try { - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(language); - if (engine == null) { - throw new UnsupportedOperationException("not support script language : " + language); - } - if (!engine.compiled(scriptId)) { - engine.compile(scriptId, script); - } - Trigger singleTrigger = new ScriptTraggerSupport(engine, scriptId); - triggers.put(trigger, singleTrigger); - } catch (Exception e) { - throw new BusinessException("compile script error :" + e.getMessage(), e); - } - } - return triggers; - } - - protected RDBTableMetaData buildTable(RDBDatabase database, DynamicFormEntity form, List columns) { - RDBTableMetaData metaData = new RDBTableMetaData(); - metaData.setComment(form.getDescribe()); - metaData.setName(form.getDatabaseTableName()); - if (null != form.getProperties()) { - metaData.setProperties(form.getProperties()); - } - metaData.setProperty("version", form.getVersion()); - metaData.setProperty("formId", form.getId()); - - metaData.setAlias(form.getAlias()); - metaData.setCorrelations(buildCorrelations(form.getCorrelations())); - metaData.setDatabaseMetaData(database.getMeta()); - buildTrigger(form.getTriggers()).forEach(metaData::on); - - columns.forEach(column -> { - RDBColumnMetaData columnMeta = new RDBColumnMetaData(); - columnMeta.setName(column.getColumnName()); - columnMeta.setAlias(column.getAlias()); - columnMeta.setComment(column.getDescribe()); - columnMeta.setLength(column.getLength() == null ? 0 : column.getLength()); - columnMeta.setPrecision(column.getPrecision() == null ? 0 : column.getPrecision()); - columnMeta.setScale(column.getScale() == null ? 0 : column.getScale()); - columnMeta.setJdbcType(JDBCType.valueOf(column.getJdbcType())); - columnMeta.setJavaType(getJavaType(column.getJavaType())); - columnMeta.setProperties(column.getProperties() == null ? new HashMap<>() : column.getProperties()); - if (!CollectionUtils.isEmpty(column.getValidator())) { - columnMeta.setValidator(new HashSet<>(column.getValidator())); - } - if (StringUtils.isEmpty(column.getDataType())) { - Dialect dialect = database.getMeta().getDialect(); - columnMeta.setDataType(dialect.buildDataType(columnMeta)); - } else { - columnMeta.setDataType(column.getDataType()); - } - columnMeta.setValueConverter(initColumnValueConvert(columnMeta.getJdbcType(), columnMeta.getJavaType())); - - if (optionalConvertBuilder != null && null != column.getDictConfig()) { - try { - DictConfig config = JSON.parseObject(column.getDictConfig(), DictConfig.class); - config.setColumn(columnMeta); - columnMeta.setOptionConverter(optionalConvertBuilder.build(config)); - ValueConverter converter = optionalConvertBuilder.buildValueConverter(config); - if (null != converter) { - columnMeta.setValueConverter(converter); - } - } catch (Exception e) { - logger.warn("创建字典转换器失败", e); - } - } - customColumnSetting(database, form, metaData, column, columnMeta); - metaData.addColumn(columnMeta); - }); - if (objectWrapperFactory != null) { - metaData.setObjectWrapper(objectWrapperFactory.createObjectWrapper(metaData)); - } - metaData.setValidator(validatorFactory.createValidator(metaData)); - - customTableSetting(database, form, metaData); - //没有主键并且没有id字段 - if (metaData.getColumns().stream().noneMatch(RDBColumnMetaData::isPrimaryKey) && metaData.findColumn("id") == null) { - RDBColumnMetaData primaryKey = createPrimaryKeyColumn(); - Dialect dialect = database.getMeta().getDialect(); - primaryKey.setDataType(dialect.buildDataType(primaryKey)); - metaData.addColumn(primaryKey); - } - - return metaData; - } - - protected RDBColumnMetaData createPrimaryKeyColumn() { - RDBColumnMetaData id = new RDBColumnMetaData(); - id.setName("id"); - id.setJdbcType(JDBCType.VARCHAR); - id.setJavaType(String.class); - id.setLength(32); - id.setDefaultValue(IDGenerator.MD5::generate); - id.setComment("主键"); - id.setPrimaryKey(true); - id.setNotNull(true); - id.setProperty("read-only", true); - return id; - } - - protected void customTableSetting(RDBDatabase database - , DynamicFormEntity formEntity - , RDBTableMetaData table) { - TableInitializeContext context = new TableInitializeContext() { - @Override - public RDBDatabase getDatabase() { - return database; - } - - @Override - public DynamicFormEntity getFormEntity() { - return formEntity; - } - - @Override - public RDBTableMetaData getTable() { - return table; - } - }; - if (!CollectionUtils.isEmpty(initializeCustomizers)) { - initializeCustomizers.forEach(customizer -> customizer.customTableSetting(context)); - } - } - - protected void customColumnSetting(RDBDatabase database - , DynamicFormEntity formEntity - , RDBTableMetaData table - , DynamicFormColumnEntity columnEntity - , RDBColumnMetaData column) { - ColumnInitializeContext context = new ColumnInitializeContext() { - @Override - public DynamicFormColumnEntity getColumnEntity() { - return columnEntity; - } - - @Override - public RDBColumnMetaData getColumn() { - return column; - } - - @Override - public RDBDatabase getDatabase() { - return database; - } - - @Override - public DynamicFormEntity getFormEntity() { - return formEntity; - } - - @Override - public RDBTableMetaData getTable() { - return table; - } - }; - if (!CollectionUtils.isEmpty(initializeCustomizers)) { - initializeCustomizers.forEach(customer -> customer.customTableColumnSetting(context)); - } - } - - protected ValueConverter initColumnValueConvert(JDBCType jdbcType, Class javaType) { - boolean isBasicClass = !classMapping - .values() - .contains(javaType) || javaType != Map.class || javaType != List.class; - - if (javaType.isEnum() && EnumDict.class.isAssignableFrom(javaType)) { - return new EnumDictValueConverter(() -> (List) Arrays.asList(javaType.getEnumConstants())); - } - switch (jdbcType) { - case BLOB: - if (!isBasicClass) { - return new JSONValueConverter(javaType, new BlobValueConverter()); - } - return new BlobValueConverter(); - case CLOB: - if (!isBasicClass) { - return new JSONValueConverter(javaType, new ClobValueConverter()); - } - return new ClobValueConverter(); - case NUMERIC: - case BIGINT: - case INTEGER: - case SMALLINT: - case TINYINT: - return new NumberValueConverter(javaType); - case DATE: - case TIMESTAMP: - case TIME: - return new DateTimeConverter("yyyy-MM-dd HH:mm:ss", javaType); - default: - if (!isBasicClass) { - return new JSONValueConverter(javaType, new DefaultValueConverter()); - } - if (javaType == String.class && (jdbcType == JDBCType.VARCHAR || jdbcType == JDBCType.NVARCHAR)) { - return new DefaultValueConverter() { - @Override - public Object getData(Object value) { - if (value instanceof Number) { - return value.toString(); - } - return super.getData(value); - } - }; - } - return new DefaultValueConverter(); - } - - } - - private static final Map classMapping = new HashMap<>(); - - static { - classMapping.put("string", String.class); - classMapping.put("String", String.class); - classMapping.put("int", Integer.class); - classMapping.put("Integer", Integer.class); - classMapping.put("byte", Byte.class); - classMapping.put("Byte", Byte.class); - - classMapping.put("byte[]", Byte[].class); - classMapping.put("Byte[]", Byte[].class); - - classMapping.put("short", Short.class); - classMapping.put("Short", Short.class); - classMapping.put("boolean", Boolean.class); - classMapping.put("Boolean", Boolean.class); - classMapping.put("double", Double.class); - classMapping.put("Double", Double.class); - classMapping.put("float", Float.class); - classMapping.put("Float", Float.class); - classMapping.put("long", Long.class); - classMapping.put("Long", Long.class); - classMapping.put("char", Character.class); - classMapping.put("Char", Character.class); - classMapping.put("char[]", Character[].class); - classMapping.put("Char[]", Character[].class); - - classMapping.put("Character", Character.class); - - classMapping.put("BigDecimal", BigDecimal.class); - classMapping.put("BigInteger", BigInteger.class); - - classMapping.put("map", Map.class); - classMapping.put("Map", Map.class); - classMapping.put("list", List.class); - classMapping.put("List", List.class); - - classMapping.put("date", Date.class); - classMapping.put("Date", Date.class); - - } - - private Class getJavaType(String type) { - if (StringUtils.isEmpty(type)) { - return String.class; - } - Class clazz = classMapping.get(type); - if (clazz == null) { - try { - clazz = Class.forName(type); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - return clazz; - } - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabase.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabase.java deleted file mode 100644 index 741de5543..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabase.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.hswebframework.web.service.form.simple.cluster; - -import org.hswebframework.ezorm.rdb.RDBTable; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.ezorm.rdb.meta.RDBDatabaseMetaData; -import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData; -import org.hswebframework.ezorm.rdb.simple.SimpleDatabase; - -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public class ClusterDatabase extends SimpleDatabase { - public ClusterDatabase(RDBDatabaseMetaData metaData, SqlExecutor sqlExecutor) { - super(metaData, sqlExecutor); - } - - private volatile Consumer versionChanged; - - private volatile Function latestVersionGetter; - - public void setVersionChanged(Consumer versionChanged) { - this.versionChanged = versionChanged; - } - - public void setLatestVersionGetter(Function latestVersionGetter) { - this.latestVersionGetter = latestVersionGetter; - } - - @Override - public RDBTable getTable(String name) { - RDBTable table = super.getTable(name); - if (versionChanged == null || latestVersionGetter == null) { - return table; - } - if (table != null) { - long version = table.getMeta().getProperty("version", -1L).getValue(); - if (version == -1L) { - return table; - } - if (version != latestVersionGetter.apply(table.getMeta())) { - versionChanged.accept(table.getMeta()); - } - return super.getTable(name); - } - return null; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabaseInit.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabaseInit.java deleted file mode 100644 index 3983be5fe..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabaseInit.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.hswebframework.web.service.form.simple.cluster; - -import org.hswebframework.ezorm.rdb.RDBDatabase; -import org.hswebframework.web.entity.form.DynamicFormColumnBindEntity; -import org.hswebframework.web.service.form.DynamicFormService; -import org.hswebframework.web.service.form.FormDeployService; -import org.hswebframework.web.service.form.events.DatabaseInitEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -public class ClusterDatabaseInit { - - @Autowired - private DynamicFormService dynamicFormService; - - @Autowired - private FormDeployService formDeployService; - - @EventListener - public void handleDatabaseInit(DatabaseInitEvent event) { - RDBDatabase database = event.getDatabase(); - - if (database instanceof ClusterDatabase) { - ClusterDatabase clusterDatabase = ((ClusterDatabase) database); - clusterDatabase.setVersionChanged(meta -> { - String formId = meta.getProperty("formId").getValue(); - if (formId != null) { - DynamicFormColumnBindEntity entity = dynamicFormService.selectLatestDeployed(formId); - if (null != entity) { - formDeployService.deploy(entity.getForm(), entity.getColumns(), false); - } - } - }); - clusterDatabase.setLatestVersionGetter(meta -> { - String formId = meta.getProperty("formId").getValue(); - if (formId != null) { - return dynamicFormService.selectDeployedVersion(formId); - } - return -1L; - }); - } - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/convert/SmartValueConverter.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/convert/SmartValueConverter.java deleted file mode 100644 index bd71e2262..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/convert/SmartValueConverter.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.hswebframework.web.service.form.simple.convert; - -import org.hswebframework.ezorm.core.ValueConverter; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public class SmartValueConverter implements ValueConverter { - - List converters; - - public SmartValueConverter(List converters) { - this.converters = converters; - } - - @Override - public Object getData(Object value) { - for (ValueConverter converter : converters) { - value = converter.getData(value); - } - return value; - } - - @Override - public Object getValue(Object data) { - for (ValueConverter converter : converters) { - data = converter.getData(data); - } - return data; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DefaultOptionalConvertBuilder.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DefaultOptionalConvertBuilder.java deleted file mode 100644 index 653db2460..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DefaultOptionalConvertBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.hswebframework.web.service.form.simple.dict; - -import org.hswebframework.ezorm.core.OptionConverter; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.web.entity.form.DictConfig; -import org.hswebframework.web.service.form.OptionalConvertBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.Collections; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0 - */ -@Component -public class DefaultOptionalConvertBuilder implements OptionalConvertBuilder { - - @Autowired(required = false) - private List strategies; - - @Override - public OptionConverter build(DictConfig dictConfig) { - if(CollectionUtils.isEmpty(strategies)){ - return null; - } - return strategies.stream() - .filter(strategy -> strategy.support(dictConfig.getType())) - .findFirst() - .map(strategy -> strategy.build(dictConfig)) - .orElse(null); - } - - @Override - public ValueConverter buildValueConverter(DictConfig dictConfig) { - if(CollectionUtils.isEmpty(strategies)){ - return null; - } - return strategies.stream() - .filter(strategy -> strategy.support(dictConfig.getType())) - .findFirst() - .map(strategy -> strategy.buildValueConverter(dictConfig)) - .orElse(null); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DictionaryOptionalConvertBuilderStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DictionaryOptionalConvertBuilderStrategy.java deleted file mode 100644 index 25e3f31b0..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/DictionaryOptionalConvertBuilderStrategy.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.hswebframework.web.service.form.simple.dict; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.ezorm.core.OptionConverter; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.web.dao.mybatis.mapper.dict.DictInTermTypeMapper; -import org.hswebframework.web.dict.DictDefineRepository; -import org.hswebframework.web.dict.EnumDict; -import org.hswebframework.web.entity.form.DictConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -import java.sql.JDBCType; -import java.util.Arrays; -import java.util.List; -import java.util.function.Supplier; - - -/** - * @author zhouhao - * @since 3.0 - */ -@Component -@SuppressWarnings("all") -public class DictionaryOptionalConvertBuilderStrategy implements OptionalConvertBuilderStrategy { - @Autowired(required = false) - private DictDefineRepository dictDefineRepository; - - @Override - public boolean support(String type) { - return "dict".equals(type) && dictDefineRepository != null; - } - - - @Override - public OptionConverter build(DictConfig dictConfig) { - JSONObject conf = new JSONObject(dictConfig.getConfig()); - String dictId = conf.getString("dictId"); - String fieldName = dictConfig.getToField(); - String sppliter = conf.getString("spliter"); - String writeObject = conf.getString("writeObject"); - EnumDictOptionConverter> converter = new EnumDictOptionConverter<>(() -> dictDefineRepository.getDefine(dictId).getItems(), fieldName); - - converter.setWriteObject(!"false".equalsIgnoreCase(writeObject)); - - if (!StringUtils.isEmpty(sppliter)) { - converter.setSplitter(str -> Arrays.asList(str.split(sppliter))); - } - - return converter; - } - - @Override - public ValueConverter buildValueConverter(DictConfig dictConfig) { - JSONObject conf = new JSONObject(dictConfig.getConfig()); - String dictId = conf.getString("dictId"); - boolean multi = !"false".equalsIgnoreCase(conf.getString("multi")); - - Supplier>> supplier = () -> dictDefineRepository.getDefine(dictId).getItems(); - - EnumDictValueConverter> converter = new EnumDictValueConverter<>(supplier); - converter.setMulti(multi); - - RDBColumnMetaData column = dictConfig.getColumn(); - if (multi && (column.getJdbcType() == JDBCType.NUMERIC || column.getJdbcType() == JDBCType.BIGINT)) { - if (supplier.get().size() < 64) { - column.setProperty(DictInTermTypeMapper.USE_DICT_MASK_FLAG, true); - converter.setDataToMask(true); - } else { - throw new UnsupportedOperationException("数据类型为数字,并且数据字典选项数量超过64个,不支持多选!"); - } - } - - return converter; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictOptionConverter.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictOptionConverter.java deleted file mode 100644 index 29fd23140..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictOptionConverter.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.hswebframework.web.service.form.simple.dict; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.core.OptionConverter; -import org.hswebframework.web.dict.EnumDict; - -import java.util.*; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Slf4j -public class EnumDictOptionConverter implements OptionConverter { - - protected Supplier> allOptionSupplier; - - @Getter - @Setter - protected Function, String> dictToText = stream -> stream.collect(Collectors.joining(",")); - - @Setter - @Getter - protected Function> splitter = str -> Arrays.asList(str.split("[, ; ;]")); - - @Getter - @Setter - protected boolean writeObject; - - protected String fieldName; - - public EnumDictOptionConverter(Supplier> supplier, String fieldName) { - this.allOptionSupplier = supplier; - this.fieldName = fieldName; - } - - @Override - public Object getOptions() { - return allOptionSupplier.get(); - } - - @Override - public String getFieldName() { - return fieldName; - } - - @Override - public Object converterData(Object o) { - //什么也不做,EnumDictValueConverter会进行处理 - return o; - } - - @Override - @SuppressWarnings("all") - public Object converterValue(Object o) { - List values; - if (o instanceof String) { - values = splitter.apply((String) o); - } else if (o instanceof Object[]) { - values = Arrays.asList(((Object[]) o)); - } else if (o instanceof Collection) { - values = new ArrayList<>(((Collection) o)); - } else { - values = Collections.singletonList(o); - } - if (writeObject) { - return allOptionSupplier.get() - .stream() - .filter(e -> e.eq(values)) - .collect(Collectors.toSet()); - } - return dictToText.apply(allOptionSupplier.get() - .stream() - .filter(e -> e.eq(values)) - .map(EnumDict::getText) - .map(String::valueOf)); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictValueConverter.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictValueConverter.java deleted file mode 100644 index f708e9796..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/EnumDictValueConverter.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.hswebframework.web.service.form.simple.dict; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.web.dict.EnumDict; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@Slf4j -public class EnumDictValueConverter implements ValueConverter { - - protected Supplier> allOptionSupplier; - - protected Function orElseGet = v -> { - log.warn("选项[{}]在字典中不存在.全部选项:[{}]", v, allOptionSupplier.get()); - return null; - }; - - @Getter - @Setter - protected Function, String> multiValueConvert = stream -> stream.collect(Collectors.joining(",")); - - @Setter - @Getter - protected Function> splitter = str -> Arrays.asList(str.split("[, ; ;]")); - - public EnumDictValueConverter(Supplier> allOptionSupplier) { - this.allOptionSupplier = allOptionSupplier; - } - - public EnumDictValueConverter(Supplier> allOptionSupplier, Function orElseGet) { - this.allOptionSupplier = allOptionSupplier; - this.orElseGet = orElseGet; - } - - @Setter - @Getter - private boolean multi = true; - - @Setter - @Getter - private boolean dataToMask = true; - - protected T find(Object value) { - return allOptionSupplier.get() - .stream() - .filter(e -> e.eq(value)) - .findFirst() - .orElseGet(() -> orElseGet.apply(value)); - - } - - @Override - @SuppressWarnings("all") - public Object getData(Object value) { - if (StringUtils.isEmpty(value)) { - return value; - } - //多选 - if (multi) { - List values; - if (value instanceof String) { - values = splitter.apply((String) value); - } else if (value instanceof Object[]) { - values = Arrays.asList(((Object[]) value)); - } else if (value instanceof Collection) { - values = new ArrayList<>(((Collection) value)); - } else { - values = Collections.singletonList(value); - } - //转为mask - if (dataToMask) { - if (value instanceof Number) { - return ((Number) value).longValue(); - } - return EnumDict.toMask(values.stream() - .map(this::find) - .filter(Objects::nonNull) - .toArray(EnumDict[]::new)); - } - return multiValueConvert - .apply(values.stream() - .map(this::find) - .filter(Objects::nonNull) - .map(EnumDict::getValue) - .map(String::valueOf)); - } - - return Optional.ofNullable(this.find(value)) - .map(EnumDict::getValue) - .orElse(value); - } - - @Override - public Object getValue(Object data) { - if (multi) { - if (dataToMask) { - Long mask = null; - if (org.hswebframework.utils.StringUtils.isNumber(data)) { - mask = org.hswebframework.utils.StringUtils.toLong(data); - } - if (mask != null) { - return multiValueConvert - .apply(EnumDict.getByMask(allOptionSupplier, mask) - .stream() - .map(EnumDict::getValue) - .map(String::valueOf)); - } - } - List lst = splitter.apply(String.valueOf(data)); - return multiValueConvert - .apply(allOptionSupplier.get() - .stream() - .filter(e -> e.eq(lst)) - .map(EnumDict::getValue) - .map(String::valueOf)); - } - return data; - } - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/OptionalConvertBuilderStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/OptionalConvertBuilderStrategy.java deleted file mode 100644 index 295f4659e..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/dict/OptionalConvertBuilderStrategy.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.service.form.simple.dict; - -import org.hswebframework.ezorm.core.OptionConverter; -import org.hswebframework.ezorm.core.ValueConverter; -import org.hswebframework.web.entity.form.DictConfig; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface OptionalConvertBuilderStrategy { - - /** - * @param type 类型是否支持 - */ - boolean support(String type); - - /** - * 根据配置创建选项转换器 - * - * @param dictConfig 配置内容 - * @return 转换器对象 - */ - OptionConverter build(DictConfig dictConfig); - - ValueConverter buildValueConverter(DictConfig dictConfig); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidator.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidator.java deleted file mode 100644 index c81f65855..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator; - -import org.hswebframework.ezorm.core.Validator; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.bean.ValidateBean; -import org.hswebframework.web.validator.group.CreateGroup; -import org.hswebframework.web.validator.group.UpdateGroup; - -import java.util.function.Supplier; - -public class DynamicBeanValidator implements Validator { - - protected Supplier beanSupplier; - - public DynamicBeanValidator(Supplier beanSupplier) { - this.beanSupplier = beanSupplier; - } - - @Override - public boolean validate(Object source, Operation operation) { - ValidateBean validateBean = beanSupplier.get(); - FastBeanCopier.copy(source, validateBean); - if (operation == Operation.INSERT) { - validateBean.tryValidate(CreateGroup.class); - } else { - validateBean.tryValidate(UpdateGroup.class); - } - return true; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidatorFactory.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidatorFactory.java deleted file mode 100644 index 392a5a6d6..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/DynamicBeanValidatorFactory.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import javassist.CtField; -import javassist.bytecode.AnnotationsAttribute; -import javassist.bytecode.ConstPool; -import javassist.bytecode.annotation.Annotation; -import javassist.bytecode.annotation.MemberValue; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.core.Validator; -import org.hswebframework.ezorm.core.ValidatorFactory; -import org.hswebframework.ezorm.core.meta.ColumnMetaData; -import org.hswebframework.ezorm.core.meta.TableMetaData; -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.proxy.Proxy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; - -import java.util.*; -import java.util.stream.Collectors; - -import static org.hswebframework.web.proxy.Proxy.createMemberValue; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class DynamicBeanValidatorFactory implements ValidatorFactory { - - @Autowired - private List strategies; - - private String createSetPropertyCode(TableMetaData tableMetaData) { - StringBuilder builder = new StringBuilder(); - builder.append("public void setProperty(String property,Object value){\n"); - int index = 0; - for (ColumnMetaData column : tableMetaData.getColumns()) { - String propertyName = column.getAlias(); - Class type = column.getJavaType(); - if (index++ > 0) { - builder.append("\nelse "); - } - builder.append("if(property.intern()==\"") - .append(propertyName) - .append("\"||property.intern()==\"") - .append(column.getName()).append("\"){\n") - .append("this.set") - .append(StringUtils.toUpperCaseFirstOne(propertyName)) - .append("((").append(type.getName()).append(")") - .append("org.hswebframework.web.bean.FastBeanCopier.DEFAULT_CONVERT.convert(value,") - .append(type.getName()) - .append(".class,null));") - .append("\n}"); - } - builder.append("}"); - return builder.toString(); - } - - private String createGetPropertyCode(TableMetaData tableMetaData) { - StringBuilder builder = new StringBuilder(); - int index = 0; - builder.append("public Object getProperty(String property){\n"); - for (ColumnMetaData column : tableMetaData.getColumns()) { - String propertyName = column.getAlias(); - if (index++ > 0) { - builder.append("\nelse "); - } - builder.append("if(property.intern()==\"") - .append(propertyName) - .append("\"||property.intern()==\"") - .append(column.getName()) - .append("\"){\n") - .append("return this.get") - .append(StringUtils.toUpperCaseFirstOne(propertyName)) - .append("();") - .append("\n}"); - - } - builder.append("\nreturn null;\n}"); - return builder.toString(); - } - - - protected List createValidatorAnnotation(Set config) { - if (CollectionUtils.isEmpty(config)) { - return new java.util.ArrayList<>(); - } - - return config.stream() - .map(this::createValidatorAnnotation) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - protected JSR303AnnotationInfo createValidatorAnnotation(String config) { - //JSON - if (config.startsWith("{")) { - JSONObject jsonConfig = JSON.parseObject(config); - String type = jsonConfig.getString("type"); - return strategies.stream().filter(strategy -> strategy.support(type)) - .findFirst() - .map(strategy -> strategy.parse(jsonConfig)) - .orElse(null); - } - - return null; - } - - @Override - public Validator createValidator(TableMetaData tableMetaData) { - Proxy proxy = Proxy.create(MapBean.class); - StringBuilder keySet = new StringBuilder("public java.util.Set keySet(){\n return new java.util.HashSet(java.util.Arrays.asList(new String[]{"); - int index = 0; - for (ColumnMetaData column : tableMetaData.getColumns()) { - String propertyName = column.getAlias(); - Class type = column.getJavaType(); - String typeName = type.getName(); - - if (index++ > 0) { - keySet.append(","); - } - - keySet.append("\"") - .append(propertyName) - .append("\""); - - proxy.custom(ctClass -> { - try { - CtField ctField = CtField.make("private " + type.getName() + " " + propertyName + ";", ctClass); - List jsr303 = createValidatorAnnotation(column.getValidator()); - //添加注解 - if (!CollectionUtils.isEmpty(jsr303)) { - ConstPool constPool = ctClass.getClassFile().getConstPool(); - AnnotationsAttribute attributeInfo = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); - for (JSR303AnnotationInfo jsr303AnnotationInfo : jsr303) { - Class jsr303Ann = jsr303AnnotationInfo.getAnnotation(); - Annotation ann = new javassist.bytecode.annotation.Annotation(jsr303Ann.getName(), constPool); - if (!CollectionUtils.isEmpty(jsr303AnnotationInfo.getProperties())) { - jsr303AnnotationInfo.getProperties().forEach((key, value) -> { - MemberValue memberValue = createMemberValue(value, constPool); - if (memberValue != null) { - ann.addMemberValue(key, memberValue); - } - }); - } - attributeInfo.addAnnotation(ann); - } - ctField.getFieldInfo().addAttribute(attributeInfo); - } - ctClass.addField(ctField); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - - proxy.addMethod("public void set" + StringUtils.toUpperCaseFirstOne(propertyName) + "(" + typeName + " " + propertyName + "){\n" + - "this." + propertyName + "=" + propertyName + ";\n" + - "\n};"); - - proxy.addMethod("public " + typeName + " get" + StringUtils.toUpperCaseFirstOne(propertyName) + "(){\n" + - "return this." + propertyName + ";\n" + - "\n};"); - } - - keySet.append("}));\n}"); - - proxy.addMethod(keySet.toString()); - proxy.addMethod(createSetPropertyCode(tableMetaData)); - proxy.addMethod(createGetPropertyCode(tableMetaData)); - - //尝试一下能否创建实例 - MapBean mapBean = proxy.newInstance(); - Assert.notNull(mapBean, "创建验证器失败!"); - return new DynamicBeanValidator(proxy::newInstance); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationInfo.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationInfo.java deleted file mode 100644 index 042ed8104..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator; - -import lombok.Getter; -import lombok.Setter; - -import java.util.Map; - -@Setter -@Getter -public class JSR303AnnotationInfo { - private Class annotation; - - private Map properties; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationParserStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationParserStrategy.java deleted file mode 100644 index 8044d68d4..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/JSR303AnnotationParserStrategy.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator; - -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface JSR303AnnotationParserStrategy { - - boolean support(String type); - - JSR303AnnotationInfo parse(Map configMap); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/MapBean.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/MapBean.java deleted file mode 100644 index ebf28bc4c..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/MapBean.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator; - -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.util.Collection; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0 - */ -public interface MapBean extends Map, ValidateBean { - - @Override - default int size() { - return keySet().size(); - } - - @Override - default boolean isEmpty() { - return values().isEmpty(); - } - - @Override - default boolean containsKey(Object key) { - return keySet().contains(key); - } - - @Override - default boolean containsValue(Object value) { - return values().contains(value); - } - - @Override - default Set> entrySet() { - return keySet() - .stream() - .map(key -> new Entry() { - @Override - public String getKey() { - return key; - } - - @Override - public Object getValue() { - return getProperty(key); - } - - @Override - public Object setValue(Object value) { - Object old = getValue(); - setProperty(key, value); - return old; - } - - @Override - public boolean equals(Object o) { - return getValue() != null && getValue().equals(o); - } - - @Override - public int hashCode() { - return getValue() == null ? 0 : getValue().hashCode(); - } - }) - .collect(Collectors.toSet()); - } - - @Override - default void putAll(Map m) { - m.forEach(this::setProperty); - } - - default void clear() { - for (String property : keySet()) { - setProperty(property, null); - } - } - - @Override - default Collection values() { - return keySet() - .stream() - .map(this::getProperty) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - @Override - Set keySet(); - - @Override - default Object get(Object key) { - return getProperty(String.valueOf(key)); - } - - @Override - default Object put(String key, Object value) { - Object old = get(key); - setProperty(key, value); - return old; - } - - void setProperty(String key, Object value); - - Object getProperty(String key); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/AbstractStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/AbstractStrategy.java deleted file mode 100644 index f46488c56..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/AbstractStrategy.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.service.form.simple.validator.JSR303AnnotationInfo; -import org.hswebframework.web.service.form.simple.validator.JSR303AnnotationParserStrategy; -import org.hswebframework.web.validator.group.CreateGroup; -import org.hswebframework.web.validator.group.UpdateGroup; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.lang.annotation.Annotation; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Slf4j -public abstract class AbstractStrategy implements JSR303AnnotationParserStrategy { - - private List propertyMappings = new ArrayList<>(); - - public AbstractStrategy() { - propertyMappings.add(PropertyMapping.of("message", String.class)); - } - - public void addPropertyMapping(PropertyMapping mapping) { - propertyMappings.add(mapping); - } - - protected String getTypeString() { - return getAnnotationType().getSimpleName(); - } - - protected abstract Class getAnnotationType(); - - @Getter - @Setter - public static class PropertyMapping { - private String name; - private Class type; - - public static PropertyMapping of(String name, Class type) { - PropertyMapping mapping = new PropertyMapping<>(); - - mapping.name = name; - mapping.type = type; - - return mapping; - } - - public static PropertyMapping of(String name, Class type, Function converter) { - PropertyMapping mapping = new PropertyMapping<>(); - mapping.name = name; - mapping.type = type; - mapping.converter = converter; - return mapping; - } - - private Function converter = source -> FastBeanCopier.DEFAULT_CONVERT.convert(source, type, null); - } - - @Override - public boolean support(String type) { - return type != null && (getTypeString().equalsIgnoreCase(type)); - } - - @Override - public JSR303AnnotationInfo parse(Map configMap) { - JSR303AnnotationInfo info = new JSR303AnnotationInfo(); - info.setAnnotation(getAnnotationType()); - - Map properties = new HashMap<>(); - - propertyMappings.forEach(mapping -> { - Object value = mapping.getConverter().apply(configMap.get(mapping.getName())); - if (!StringUtils.isEmpty(value)) { - properties.put(mapping.getName(), value); - } - }); - - List groups = null; - - Object groupObject = new JSONObject(configMap).get("groups"); - if (groupObject instanceof JSONArray) { - groups = ((JSONArray) groupObject); - } - if (groupObject instanceof String) { - groups = Arrays.asList(((String) groupObject).split("[,]")); - } - - if (!CollectionUtils.isEmpty(groups)) { - properties.put("groups", groups.stream().map(obj -> { - if ("create".equals(obj)) { - return CreateGroup.class; - } else if ("update".equals(obj)) { - return UpdateGroup.class; - } else { - try { - return Class.forName(String.valueOf(obj)); - } catch (ClassNotFoundException e) { - return CreateGroup.class; - } - } - }).toArray()); - } - info.setProperties(properties); - return info; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/EmailStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/EmailStrategy.java deleted file mode 100644 index 3ebebb14e..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/EmailStrategy.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import lombok.extern.slf4j.Slf4j; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.Length; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.Pattern; -import java.lang.reflect.Array; -import java.util.Arrays; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class EmailStrategy extends AbstractStrategy { - - public EmailStrategy() { - addPropertyMapping(PropertyMapping.of("regexp", String.class)); - } - - @Override - protected Class getAnnotationType() { - return Email.class; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/LengthStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/LengthStrategy.java deleted file mode 100644 index 7a9cf1a3b..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/LengthStrategy.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import lombok.extern.slf4j.Slf4j; -import org.hibernate.validator.constraints.Length; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class LengthStrategy extends AbstractStrategy { - - public LengthStrategy() { - addPropertyMapping(PropertyMapping.of("min", int.class)); - - addPropertyMapping(PropertyMapping.of("max", int.class)); - } - - @Override - protected Class getAnnotationType() { - return Length.class; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotBlankStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotBlankStrategy.java deleted file mode 100644 index f3404a759..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotBlankStrategy.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import lombok.extern.slf4j.Slf4j; -import org.hibernate.validator.constraints.NotBlank; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class NotBlankStrategy extends AbstractStrategy { - - @Override - protected Class getAnnotationType() { - return NotBlank.class; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotNullStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotNullStrategy.java deleted file mode 100644 index a5b9e71c1..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/NotNullStrategy.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class NotNullStrategy extends AbstractStrategy { - - @Override - protected Class getAnnotationType() { - return NotNull.class; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/RangeStrategy.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/RangeStrategy.java deleted file mode 100644 index 87d2ff4f2..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/validator/jsr303/RangeStrategy.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.service.form.simple.validator.jsr303; - -import lombok.extern.slf4j.Slf4j; -import org.hibernate.validator.constraints.Length; -import org.hibernate.validator.constraints.Range; -import org.springframework.stereotype.Component; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@Slf4j -public class RangeStrategy extends AbstractStrategy { - - public RangeStrategy() { - addPropertyMapping(PropertyMapping.of("min", int.class)); - - addPropertyMapping(PropertyMapping.of("max", int.class)); - } - - @Override - protected Class getAnnotationType() { - return Range.class; - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormColumnMapper.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormColumnMapper.xml deleted file mode 100644 index a7826fe35..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormColumnMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormDeployLogMapper.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormDeployLogMapper.xml deleted file mode 100644 index b9846e31e..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormDeployLogMapper.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormMapper.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormMapper.xml deleted file mode 100644 index 0d3cec7f8..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/form/DynamicFormMapper.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - update ${_fullTableName} set version=version+1 where u_id = #{id} - - - - - - diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/pom.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/pom.xml deleted file mode 100644 index 467866e2f..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - hsweb-system-dynamic-form - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-dynamic-form-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-dynamic-form-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-dynamic-form-web - ${project.version} - - - - com.h2database - h2 - test - - - org.codehaus.groovy - groovy-all - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/java/org/hswebframework/web/form/DynamicFormAutoConfiguration.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/java/org/hswebframework/web/form/DynamicFormAutoConfiguration.java deleted file mode 100644 index c3eccf6d4..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/java/org/hswebframework/web/form/DynamicFormAutoConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.form; - -import org.hswebframework.web.service.form.DynamicFormService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; - -/** - * @author zhouhao - */ -@Configuration -@Order -@ComponentScan({"org.hswebframework.web.service.form.simple" - , "org.hswebframework.web.controller.form"}) -public class DynamicFormAutoConfiguration implements CommandLineRunner { - - private Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private DynamicFormService dynamicFormService; - - @Override - public void run(String... args) throws Exception { - try { - dynamicFormService.deployAllFromLog(); - } catch (Exception e) { - logger.error("deploy form error", e); - } - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 8920dcd50..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.form.DynamicFormAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index de71289d9..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,89 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "动态表单" -}; - -//版本更新信息 -var versions = [ - { - version: "3.0.8", - upgrade: function (context) { - var database = context.database; - database.createOrAlter("s_dyn_form") - .addColumn().name("db_name").alias("databaseName").comment("数据库名").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .comment("动态表单").commit(); - } - } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_dyn_form") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("表单名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("t_name").alias("tableName").comment("数据库表名").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("describe").alias("describe").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("type").alias("type").comment("表单类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("version").alias("version").comment("版本").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("is_deployed").alias("isDeployed").comment("是否已发布").jdbcType(java.sql.JDBCType.DECIMAL).length(1, 0).commit() - .addColumn().name("alias").alias("alias").comment("别名").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("triggers").alias("triggers").comment("触发器").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("correlations").alias("correlations").comment("表链接").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("data_source_id").alias("dataSourceId").comment("数据源id,为空使用默认数据源").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("creator_id").alias("creatorId").comment("创建人id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("update_time").alias("updateTime").comment("修改时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("tags").alias("tags").comment("标签").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .comment("动态表单").commit(); - - database.createOrAlter("s_dyn_form_column") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("form_id").alias("formId").comment("表单ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("name").alias("name").comment("字段名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("column_name").alias("columnName").comment("数据库列").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("describe").alias("describe").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("alias").alias("alias").comment("别名").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("java_type").alias("javaType").comment("java类型").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("jdbc_type").alias("jdbcType").comment("jdbc类型").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("data_type").alias("dataType").comment("数据类型").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("length").alias("length").comment("长度").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("precision").alias("precision").comment("精度").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("scale").alias("scale").comment("小数点位数").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("dict_config").alias("dictConfig").comment("字典配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("sort_index").alias("sortIndex").comment("排序序号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("validator").alias("validator").comment("验证器配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .index().name("idx_dynf_form_id").column("form_id").commit() - - .comment("动态表单列").commit(); - - database.createOrAlter("s_dyn_form_log") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("form_id").alias("formId").comment("表单ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("version").alias("version").comment("发布的版本").jdbcType(java.sql.JDBCType.NUMERIC).length(32, 0).commit() - .addColumn().name("deploy_time").alias("deployTime").comment("发布时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("meta_data").alias("metaData").comment("部署的元数据").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4, 0).commit() - .index().name("idx_dynfl_form_id").column("form_id").commit() - .index().name("idx_dynfl_form_id_ver").column("form_id").column("version").commit() - .comment("表单发布日志").commit(); -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java deleted file mode 100644 index 4c3a085c5..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/java/org/hswebframework/web/service/form/simple/SimpleDynamicFormServiceTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.hswebframework.web.service.form.simple; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.entity.form.DynamicFormColumnBindEntity; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; -import org.hswebframework.web.service.form.DatabaseRepository; -import org.hswebframework.web.service.form.DynamicFormColumnService; -import org.hswebframework.web.service.form.DynamicFormOperationService; -import org.hswebframework.web.service.form.DynamicFormService; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.sql.Array; -import java.sql.JDBCType; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Stream; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class SimpleDynamicFormServiceTest extends SimpleWebApplicationTests { - - @Autowired - private DynamicFormService dynamicFormService; - - @Autowired - private DynamicFormColumnService dynamicFormColumnService; - - @Autowired - private DynamicFormOperationService dynamicFormOperationService; - - @Autowired - private DatabaseRepository databaseRepository; - @Autowired - private SqlExecutor sqlExecutor; - - @Test - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public void testDeploy() throws SQLException { - DynamicFormEntity form = entityFactory.newInstance(DynamicFormEntity.class); - form.setName("test"); - form.setDatabaseName("PUBLIC"); - form.setDatabaseTableName("f_test"); - form.setTriggers("[" + - "{\"trigger\":\"select.wrapper.done\"" +//触发器 在每个查询结果被包装为对象时触发 - ",\"language\":\"groovy\"" + - ",\"script\":\"println('wrapper done:'+instance);return true;\"" + - "}" + - "]"); - form.setCorrelations("[" + - "{\"target\":\"s_dyn_form\",\"alias\":\"form\",\"condition\":\"form.u_id=f_test.id\"}" + - "]"); - - DynamicFormColumnEntity column_name = entityFactory.newInstance(DynamicFormColumnEntity.class); - column_name.setName("姓名"); - column_name.setColumnName("name"); - column_name.setJavaType("string"); - column_name.setJdbcType(JDBCType.VARCHAR.getName()); - column_name.setLength(32); - column_name.setValidator(Arrays.asList("{\"type\":\"NotBlank\",\"groups\":[\"create\"],\"message\":\"姓名不能为空\"}")); - DynamicFormColumnEntity column_age = entityFactory.newInstance(DynamicFormColumnEntity.class); - column_age.setName("年龄"); - column_age.setColumnName("age"); - column_age.setJavaType("int"); - column_age.setJdbcType(JDBCType.NUMERIC.getName()); - column_age.setPrecision(4); - column_age.setScale(0); - -// Stream.of(column_id, column_name, column_age).forEach(dynamicFormColumnService::insert); - DynamicFormColumnBindEntity bindEntity = new DynamicFormColumnBindEntity(); - - bindEntity.setForm(form); - bindEntity.setColumns(Arrays.asList(column_name, column_age)); - - String id = dynamicFormService.saveOrUpdate(bindEntity); - - - dynamicFormService.deploy(id); - - dynamicFormOperationService.insert(form.getId(), new HashMap() { - { - put("name", "张三"); - put("age", 10); - } - }); - - databaseRepository.getDefaultDatabase(form.getDatabaseName()).getTable("s_dyn_form"); - - List objects = dynamicFormOperationService.select(form.getId(), new QueryParamEntity().includes("*", "form.*")); - - Assert.assertTrue(objects.size() == 1); - System.out.println(objects); - System.out.println(dynamicFormService.select()); - System.out.println(sqlExecutor.list("select * from s_dyn_form")); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/resources/application.yml deleted file mode 100644 index 8db8131a2..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-starter/src/test/resources/application.yml +++ /dev/null @@ -1,16 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:form_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 动态表单测试 - version: 3.0.0 -logging: - level: - org.hswebframework: debug \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/pom.xml b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/pom.xml deleted file mode 100644 index 085abac0e..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - hsweb-system-dynamic-form - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-dynamic-form-web - - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-dynamic-form-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - org.hswebframework.web - hsweb-authorization-basic - ${project.version} - true - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormAuthorizeDefinitionParser.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormAuthorizeDefinitionParser.java deleted file mode 100644 index 8a2c91f54..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormAuthorizeDefinitionParser.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.controller.form; - -import org.hswebframework.web.AopUtils; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.basic.aop.AopMethodAuthorizeDefinitionCustomizerParser; -import org.hswebframework.web.authorization.define.AuthorizeDefinition; -import org.hswebframework.web.boost.aop.context.MethodInterceptorContext; -import org.springframework.util.ClassUtils; - -import java.lang.reflect.Method; - -/** - * @author zhouhao - * @since 3.0 - */ -public abstract class DynamicFormAuthorizeDefinitionParser implements AopMethodAuthorizeDefinitionCustomizerParser { - @Override - public AuthorizeDefinition parse(Class target, Method method, MethodInterceptorContext context) { - if (!ClassUtils.getUserClass(target).equals(DynamicFormOperationController.class) - || context == null) { - return null; - } - Authorize methodAuth = AopUtils.findMethodAnnotation(target, method, Authorize.class); - - //获取表单id - return context.getParameter("formId") - .map(formId -> getDefinition(formId, methodAuth == null ? new String[0] : methodAuth.action(), context)) - .orElse(null); - } - - protected abstract AuthorizeDefinition getDefinition(String formId, String[] action, MethodInterceptorContext context); -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormColumnController.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormColumnController.java deleted file mode 100644 index e9baa5834..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormColumnController.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.hswebframework.web.controller.form; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.form.DynamicFormColumnEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.form.DynamicFormService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Arrays; -import java.util.List; - -/** - * 动态表单 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.dynamic-form-column:dynamic/form/column}") -@Authorize(permission = "dynamic-form", description = "动态表单管理") -@Api(value = "动态表单管理",tags = "动态表单-表单管理") -public class DynamicFormColumnController { - - private DynamicFormService dynamicFormService; - - @Autowired - public void setDynamicFormService(DynamicFormService dynamicFormService) { - this.dynamicFormService = dynamicFormService; - } - - @PatchMapping("/batch") - @Authorize(action = Permission.ACTION_ADD) - @ApiOperation("保存多个表单列") - public ResponseMessage> add(@RequestBody List columnEntities) { - return ResponseMessage.ok(dynamicFormService.saveOrUpdateColumn(columnEntities)); - } - - @PatchMapping - @Authorize(action = Permission.ACTION_ADD) - @ApiOperation("保存表单列") - public ResponseMessage add(@RequestBody DynamicFormColumnEntity columnEntity) { - return ResponseMessage.ok(dynamicFormService.saveOrUpdateColumn(columnEntity)); - } - - @DeleteMapping - @Authorize(action = Permission.ACTION_DELETE) - @ApiOperation("删除列") - public ResponseMessage> delete(@ApiParam(value = "要删除的列id,多个列以,分割", example = "1,2,3") - @RequestParam String ids) { - return ResponseMessage.ok(dynamicFormService.deleteColumn(Arrays.asList(ids.split("[,]")))); - } - - @GetMapping("/{formId}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("获取表单的所有列") - public ResponseMessage> getByFormId(@PathVariable String formId) { - return ResponseMessage.ok(dynamicFormService.selectColumnsByFormId(formId)); - } - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormController.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormController.java deleted file mode 100644 index bb7f7237a..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormController.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.hswebframework.web.controller.form; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.Logical; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.form.DynamicFormColumnBindEntity; -import org.hswebframework.web.entity.form.DynamicFormEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.form.DynamicFormService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Objects; - -/** - * 动态表单 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.dynamic-form:dynamic/form}") -@Authorize(permission = "dynamic-form", description = "动态表单管理") -@Api(value = "动态表单管理",tags = "动态表单-表单管理") -public class DynamicFormController implements SimpleGenericEntityController { - - private DynamicFormService dynamicFormService; - - @Autowired - public void setDynamicFormService(DynamicFormService dynamicFormService) { - this.dynamicFormService = dynamicFormService; - } - - @Override - public DynamicFormService getService() { - return dynamicFormService; - } - - - @PatchMapping("/bind") - @ApiOperation("同时保存表单和字段") - @Authorize(action = {Permission.ACTION_ADD, Permission.ACTION_UPDATE}, logical = Logical.OR) - public ResponseMessage saveOrUpdateFormAndColumn(@RequestBody DynamicFormColumnBindEntity bindEntity) { - Authentication authentication = Authentication.current().orElse(null); - Objects.requireNonNull(bindEntity.getForm(), "form can not be null"); - Objects.requireNonNull(bindEntity.getColumns(), "columns can not be null"); - - if (null != authentication) { - bindEntity.getForm().setCreatorId(authentication.getUser().getId()); - } - bindEntity.getForm().setCreateTime(System.currentTimeMillis()); - - return ResponseMessage.ok(dynamicFormService.saveOrUpdate(bindEntity)); - } - - @Override - public ResponseMessage add(@RequestBody DynamicFormEntity data) { - Authentication authentication = Authentication.current().orElse(null); - if (null != authentication) { - data.setCreatorId(authentication.getUser().getId()); - } - data.setCreateTime(System.currentTimeMillis()); - return SimpleGenericEntityController.super.add(data); - } - - @PutMapping("/{id}/deploy") - @Authorize(action = "deploy", description = "发布表单") - @ApiOperation("发布表单") - public ResponseMessage deploy(@PathVariable String id) { - dynamicFormService.deploy(id); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/un-deploy") - @Authorize(action = "deploy", description = "发布表单") - @ApiOperation("取消发布表单") - public ResponseMessage unDeploy(@PathVariable String id) { - dynamicFormService.unDeploy(id); - return ResponseMessage.ok(); - } - - @GetMapping("/{id}/editing") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("获取当前正在编辑的表单") - public ResponseMessage getEditing(@PathVariable String id) { - return ResponseMessage.ok(dynamicFormService.selectEditing(id)); - } - - @GetMapping("/{id}/latest") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("获取最新发布的表单") - public ResponseMessage selectDeployed(@PathVariable String id) { - return ResponseMessage.ok(dynamicFormService.selectLatestDeployed(id)); - } - - @GetMapping("/{id}/{version:\\d+}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("获取指定版本的表单") - public ResponseMessage selectDeployed(@PathVariable String id, @PathVariable int version) { - return ResponseMessage.ok(dynamicFormService.selectDeployed(id, version)); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormDeployLogController.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormDeployLogController.java deleted file mode 100644 index b2a918611..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormDeployLogController.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.controller.form; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.QueryController; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.form.DynamicFormDeployLogEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.QueryByEntityService; -import org.hswebframework.web.service.form.DynamicFormDeployLogService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * 表单发布日志 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.dynamic-form-log:dynamic/form-deploy-log}") -@Authorize(permission = "form-deploy-log",description = "表单发布日志") -@Api(value = "表单发布日志",tags = "动态表单-发布日志") -public class DynamicFormDeployLogController implements QueryController { - - private DynamicFormDeployLogService dynamicFormDeployLogService; - - @Autowired - public void setDynamicFormDeployLogService(DynamicFormDeployLogService dynamicFormDeployLogService) { - this.dynamicFormDeployLogService = dynamicFormDeployLogService; - } - - @Override - @SuppressWarnings("unchecked") - public DynamicFormDeployLogService getService() { - return dynamicFormDeployLogService; - } - - -} diff --git a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormOperationController.java b/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormOperationController.java deleted file mode 100644 index edc673811..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-web/src/main/java/org/hswebframework/web/controller/form/DynamicFormOperationController.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.hswebframework.web.controller.form; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ResponseHeader; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.Logical; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.DeleteParamEntity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.commons.entity.param.UpdateParamEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.service.form.DynamicFormOperationService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; - -/** - * 动态表单常用操作控制器,如增删改查 - * - * @author zhouhao - * @since 3.0 - */ -@RestController -@Api(value = "动态表单操作", tags = "动态表单-数据操作") -@RequestMapping("/dynamic/form/operation") -@Authorize(permission = "dynamic-form-operation", description = "动态表单数据操作") -public class DynamicFormOperationController { - - private DynamicFormOperationService dynamicFormOperationService; - - @Autowired - public void setDynamicFormOperationService(DynamicFormOperationService dynamicFormOperationService) { - this.dynamicFormOperationService = dynamicFormOperationService; - } - - @GetMapping("/{formId}") - @ApiOperation("动态查询") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage> selectPager(@PathVariable String formId, QueryParamEntity paramEntity) { - return ResponseMessage.ok(dynamicFormOperationService.selectPager(formId, paramEntity)); - } - - @GetMapping("/{formId}/no-paging") - @ApiOperation("不分页动态查询") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage> selectNoPaging(@PathVariable String formId, QueryParamEntity paramEntity) { - paramEntity.setPaging(false); - return ResponseMessage.ok(dynamicFormOperationService.select(formId, paramEntity)); - } - - @GetMapping("/{formId}/single") - @ApiOperation("动态查询返回单条数据") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage selectSingle(@PathVariable String formId, QueryParamEntity paramEntity) { - return ResponseMessage.ok(dynamicFormOperationService.selectSingle(formId, paramEntity)); - } - - @GetMapping("/{formId}/count") - @ApiOperation("动态查询返回数据条数") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage selectCount(@PathVariable String formId, QueryParamEntity paramEntity) { - return ResponseMessage.ok(dynamicFormOperationService.count(formId, paramEntity)); - } - - @PostMapping("/{formId}") - @ApiOperation("新增") - @Authorize(action = Permission.ACTION_ADD) - @ResponseStatus(HttpStatus.CREATED) - public ResponseMessage> add(@PathVariable String formId, - @RequestBody Map data) { - return ResponseMessage.ok(dynamicFormOperationService.insert(formId, data)); - } - - @PatchMapping("/{formId}") - @ApiOperation("新增或者修改") - @Authorize(action = {Permission.ACTION_ADD, Permission.ACTION_UPDATE}, logical = Logical.OR) - public ResponseMessage saveOrUpdate(@PathVariable String formId, - @RequestBody Map data) { - return ResponseMessage.ok(dynamicFormOperationService.saveOrUpdate(formId, data)); - } - - @PutMapping("/{formId}") - @ApiOperation("动态修改") - @Authorize(action = Permission.ACTION_UPDATE) - public ResponseMessage dynamicUpdate(@PathVariable String formId, - @RequestBody UpdateParamEntity> paramEntity) { - return ResponseMessage.ok(dynamicFormOperationService.update(formId, paramEntity)); - } - - @GetMapping("/{formId}/{id}") - @ApiOperation("根据主键查询") - @Authorize(action = Permission.ACTION_GET) - public ResponseMessage> selectById(@PathVariable String formId, - @PathVariable String id) { - return ResponseMessage.ok(dynamicFormOperationService.selectById(formId, id)); - } - - @PutMapping("/{formId}/{id}") - @ApiOperation("根据主键修改") - @Authorize(action = Permission.ACTION_UPDATE) - public ResponseMessage> updateById(@PathVariable String formId, - @PathVariable String id, - @RequestBody Map param) { - return ResponseMessage.ok(dynamicFormOperationService.updateById(formId, id, param)); - } - - @DeleteMapping("/{formId}/{id}") - @ApiOperation("根据主键删除") - @Authorize(action = Permission.ACTION_DELETE) - public ResponseMessage deleteById(@PathVariable String formId, - @PathVariable String id) { - return ResponseMessage.ok(dynamicFormOperationService.deleteById(formId, id)); - } -} diff --git a/hsweb-system/hsweb-system-dynamic-form/pom.xml b/hsweb-system/hsweb-system-dynamic-form/pom.xml deleted file mode 100644 index 3f117d975..000000000 --- a/hsweb-system/hsweb-system-dynamic-form/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-dynamic-form - pom - - hsweb-system-dynamic-form-starter - hsweb-system-dynamic-form-api - hsweb-system-dynamic-form-local - hsweb-system-dynamic-form-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/README.md b/hsweb-system/hsweb-system-file/README.md deleted file mode 100644 index fb0f6697f..000000000 --- a/hsweb-system/hsweb-system-file/README.md +++ /dev/null @@ -1,74 +0,0 @@ -## 文件管理 -统一文件管理。提供上传,下载,秒传等API - -## API -上传单个文件: -```bash - POST: /file/upload - Content-Disposition: form-data; name="file"; filename="test.zip" -``` -返回: -```json - { - "result":{"id":"文件id","md5":"文件md5值","name":"test.zip"}, - "status":200 - } -``` - -上传多个文件: -```bash - POST: /file/upload-multi - Content-Disposition: form-data; name="files"; filename="test.zip" - Content-Disposition: form-data; name="files"; filename="test2.zip" -``` -返回: -```json - { - "result":[ - {"id":"文件id","md5":"文件md5值","name":"test.zip"}, - {"id":"文件id","md5":"文件md5值","name":"test2.zip"} - ],"status":200 - } -``` -上传静态文件: -```bash - POST: /file/upload-static - Content-Disposition: form-data; name="file"; filename="test.zip" -``` -返回: -```json - { - "result":"文件的访问路径", - "status":200 - } -``` - -下载文件 -```bash - GET: /file/download/{idOrMd5} - GET: /file/download/{idOrMd5}/{fileName} -``` - -根据md5获取文件信息 -```bash - GET: /file/md5/{md5} -``` -如果文件存在则返回: -```json - { - "result":{ - "id":"文件id", - "name":"文件名", - "md5":"md5值" - ..... - }, - "status":200 - } -``` -否则返回: -```json - { - "status":404, - "message":"...." - } -``` \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-api/pom.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-api/pom.xml deleted file mode 100644 index 0feba0f96..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-api/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - hsweb-system-file - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - 文件服务api - hsweb-system-file-api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/FileInfoEntity.java b/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/FileInfoEntity.java deleted file mode 100644 index 4768fba9e..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/FileInfoEntity.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.hswebframework.web.entity.file; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; - -/** - * 文件信息 实体 - * - * @author hsweb-generator-online - */ -public interface FileInfoEntity extends RecordCreationEntity, GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 文件名称 - */ - String name = "name"; - /** - * 文件相对路径 - */ - String location = "location"; - /** - * 类型 - */ - String type = "type"; - /** - * md5校验值 - */ - String md5 = "md5"; - /** - * 文件大小 - */ - String size = "size"; - /** - * 状态 - */ - String status = "status"; - /** - * 分类 - */ - String classified = "classified"; - - /** - * @return 文件名称 - */ - String getName(); - - /** - * @param name 文件名称 - */ - void setName(String name); - - /** - * @return 路径 - */ - String getLocation(); - - /** - * @param location 文件相对路径 - */ - void setLocation(String location); - - /** - * @return 类型 - */ - String getType(); - - /** - * @param type 类型 - */ - void setType(String type); - - /** - * @return md5校验值 - */ - String getMd5(); - - /** - * @param md5 md5校验值 - */ - void setMd5(String md5); - - /** - * @return 文件大小 - */ - Long getSize(); - - /** - * @param size 文件大小 - */ - void setSize(Long size); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * @param status 状态 - */ - void setStatus(Byte status); - - /** - * @return 分类 - */ - String getClassified(); - - /** - * @param classified 分类 - */ - void setClassified(String classified); - - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/SimpleFileInfoEntity.java b/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/SimpleFileInfoEntity.java deleted file mode 100644 index 56c9b0de9..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/entity/file/SimpleFileInfoEntity.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.entity.file; - -import lombok.*; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 文件信息 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class SimpleFileInfoEntity extends SimpleGenericEntity implements FileInfoEntity { - //文件名称 - private String name; - //路径 - private String location; - //类型 - private String type; - //md5校验值 - private String md5; - //文件大小 - private Long size; - //状态 - private Byte status; - //分类 - private String classified; - //创建时间 - private Long createTime; - //创建人 - private String creatorId; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileInfoService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileInfoService.java deleted file mode 100644 index 38b6aa465..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileInfoService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.service.file; - -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 文件信息 服务类 - * - * @author hsweb-generator-online - */ -public interface FileInfoService extends CrudService { - FileInfoEntity selectByMd5(String md5); - - FileInfoEntity selectByIdOrMd5(String idOrMd5); -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileService.java deleted file mode 100644 index df1d75d82..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-api/src/main/java/org/hswebframework/web/service/file/FileService.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.hswebframework.web.service.file; - -import org.hswebframework.web.entity.file.FileInfoEntity; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * 文件服务,用户保存,读取文件信息 - * - * @author zhouhao - * @since 3.0 - */ -public interface FileService { - - /** - * 根据文件id或者md5获取文件流,如果文件不存在,将抛出{@link org.hswebframework.web.NotFoundException} - * - * @param fileIdOrMd5 文件id或者md5值 - * @return 文件流 - */ - InputStream readFile(String fileIdOrMd5); - - /** - * 保存文件,并返回文件信息,如果存在相同的文件,则不会保存,而是返回已保存的文件 - * - * @param fileStream 文件输入流 - * @param fileName 文件名称 - * @param type 文件类型(contentType) - * @param creatorId 上传人 - * @return 文件信息 - * @throws IOException - * @see FileInfoEntity - */ - FileInfoEntity saveFile(InputStream fileStream, String fileName, String type, String creatorId) throws IOException; - - /** - * 上传静态文件,并返回静态文件访问地址 - * - * @param fileStream 文件输入流 - * @param fileName 文件名 - * @return 上传文件的访问地址 - * @throws IOException - */ - String saveStaticFile(InputStream fileStream, String fileName) throws IOException; - - /** - * 将已上传的文件写出到指定的输出流 - * - * @param fileId 已上传的文件id - * @param out 要写出的流 - * @param skip 跳过写出 {@link InputStream#skip(long)} - * @throws IOException - */ - void writeFile(String fileId, OutputStream out, long skip) throws IOException; - -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/pom.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-local/pom.xml deleted file mode 100644 index caeb25fae..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - hsweb-system-file - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-file-local - - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-file-api - ${project.version} - - - com.luhuiguo - fastdfs-spring-boot-starter - 0.2.0 - true - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/dao/file/FileInfoDao.java b/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/dao/file/FileInfoDao.java deleted file mode 100644 index 1ce2baecb..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/dao/file/FileInfoDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.file; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.file.FileInfoEntity; - -/** -* 文件信息 DAO接口 -* @author hsweb-generator-online - */ -public interface FileInfoDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/fastdfs/FdfsFileService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/fastdfs/FdfsFileService.java deleted file mode 100644 index 95ceaf243..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/fastdfs/FdfsFileService.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.hswebframework.web.service.file.fastdfs; - -import com.luhuiguo.fastdfs.domain.StorePath; -import com.luhuiguo.fastdfs.service.FastFileStorageClient; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.file.FileService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.StreamUtils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.MessageDigest; -import java.util.HashSet; - -/** - * @author zhouhao - * @since 3.0 - */ -@Slf4j -public class FdfsFileService implements FileService { - private FastFileStorageClient fastFileStorageClient; - - private FileInfoService fileInfoService; - - private String staticLocation = "/"; - - @Autowired - public void setFastFileStorageClient(FastFileStorageClient fastFileStorageClient) { - this.fastFileStorageClient = fastFileStorageClient; - } - - @Autowired - public void setFileInfoService(FileInfoService fileInfoService) { - this.fileInfoService = fileInfoService; - } - - public void setStaticLocation(String staticLocation) { - this.staticLocation = staticLocation; - } - - public String getStaticLocation() { - return staticLocation; - } - - @Override - public InputStream readFile(String fileIdOrMd5) { - FileInfoEntity entity = fileInfoService.selectByIdOrMd5(fileIdOrMd5); - StorePath path = StorePath.praseFromUrl(entity.getLocation()); - return fastFileStorageClient.downloadFile(path.getGroup(), path.getPath(), ins -> ins); - } - - @Override - public FileInfoEntity saveFile(InputStream fileStream, String fileName, String type, String creatorId) throws IOException { -// MetaData createIdMeta = new MetaData("creatorId", creatorId); - MessageDigest digest = DigestUtils.getMd5Digest(); - String suffix = fileName.contains(".") ? - fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : ""; - - StorePath path; - int fileSize; - try (InputStream tmp = new InputStream() { - - @Override - public int read(byte[] b, int off, int len) throws IOException { - int r = super.read(b, off, len); - digest.update(b, off, len); - return r; - } - - @Override - public int read() throws IOException { - return fileStream.read(); - } - - @Override - public void close() throws IOException { - fileStream.close(); - super.close(); - } - - @Override - public int available() throws IOException { - return fileStream.available(); - } - }) { - path = fastFileStorageClient.uploadFile(tmp, fileSize = tmp.available(), suffix, new HashSet<>()); - } - String md5 = Hex.encodeHexString(digest.digest()); - FileInfoEntity fileInfo = fileInfoService.createEntity(); - fileInfo.setLocation(path.getFullPath()); - fileInfo.setMd5(md5); - fileInfo.setStatus(DataStatus.STATUS_ENABLED); - fileInfo.setSize((long) fileSize); - fileInfo.setName(fileName); - fileInfo.setType(type); - fileInfo.setCreatorId(creatorId); - fileInfo.setCreateTimeNow(); - fileInfoService.insert(fileInfo); - - return fileInfo; - } - - @Override - public String saveStaticFile(InputStream fileStream, String fileName) throws IOException { - //文件后缀 - String suffix = fileName.contains(".") ? - fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : ""; - - StorePath path = fastFileStorageClient.uploadFile(fileStream, fileStream.available(), suffix, new HashSet<>()); - - return staticLocation.concat(path.getFullPath()); - } - - @Override - public void writeFile(String fileId, OutputStream out, long skip) throws IOException { - try (InputStream inputStream = readFile(fileId)) { - if (skip > 0) { - long len = inputStream.skip(skip); - log.info("skip write {} len:{}", skip, len); - } - StreamUtils.copy(inputStream, out); - } - } - -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java deleted file mode 100644 index 720863772..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.hswebframework.web.service.file.simple; - -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.utils.time.DateFormatter; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.file.FileService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.util.StreamUtils; - -import java.io.*; -import java.security.MessageDigest; -import java.util.Date; - -/** - * 本地文件服务,将文件上传到本地文件系统中 - * - * @author zhouhao - * @since 3.0 - */ -//@Service("fileService") -public class LocalFileService implements FileService { - private FileInfoService fileInfoService; - - private Logger logger = LoggerFactory.getLogger(this.getClass()); - /** - * 静态文件存储目录,不能以/结尾 - */ - private String staticFilePath = "./static/upload"; - - /** - * 静态文件访问地址,上传静态文件后,将返回此地址+文件相对地址,以/结尾 - */ - private String staticLocation = "/upload/"; - - /** - * 文件上传目录 - */ - private String filePath = "./upload/file"; - - @Value("${hsweb.web.upload.static-file-path:./static/upload}") - public void setStaticFilePath(String staticFilePath) { - this.staticFilePath = staticFilePath; - } - - @Value("${hsweb.web.upload.static-location:/upload/}") - public void setStaticLocation(String staticLocation) { - this.staticLocation = staticLocation; - } - - @Value("${hsweb.web.upload.file-path:./upload/file}") - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public String getFilePath() { - return filePath; - } - - public String getStaticFilePath() { - return staticFilePath; - } - - public String getStaticLocation() { - return staticLocation; - } - - @Autowired - public void setFileInfoService(FileInfoService fileInfoService) { - this.fileInfoService = fileInfoService; - } - - @Override - public InputStream readFile(String fileIdOrMd5) { - FileInfoEntity fileInfo = fileInfoService.selectByIdOrMd5(fileIdOrMd5); - if (fileInfo == null || !DataStatus.STATUS_ENABLED.equals(fileInfo.getStatus())) { - throw new NotFoundException("file not found or disabled"); - } - //配置中的文件上传根路径 - String filePath = getFilePath() + "/" + fileInfo.getLocation(); - File file = new File(filePath); - if (!file.exists()) { - throw new NotFoundException("file not found"); - } - try { - return new FileInputStream(file); - } catch (FileNotFoundException ignore) { - // never happen - throw new NotFoundException("file not found"); - } - } - - @Override - public String saveStaticFile(InputStream fileStream, String fileName) throws IOException { - try { - //文件后缀 - String suffix = fileName.contains(".") ? - fileName.substring(fileName.lastIndexOf(".")) : ""; - - //以日期划分目录 - String filePath = DateFormatter.toString(new Date(), "yyyyMMdd"); - - //创建目录 - new File(getStaticFilePath() + "/" + filePath).mkdirs(); - - // 存储的文件名 - String realFileName = System.nanoTime() + suffix; - - String fileAbsName = getStaticFilePath() + "/" + filePath + "/" + realFileName; - try (FileOutputStream out = new FileOutputStream(fileAbsName)) { - StreamUtils.copy(fileStream, out); - } - - //响应上传成功的资源信息 - return getStaticLocation() + filePath + "/" + realFileName; - } finally { - fileStream.close(); - } - } - - @Override - @SuppressWarnings("all") - public FileInfoEntity saveFile(InputStream fileStream, String fileName, String type, String creatorId) throws IOException { - //配置中的文件上传根路径 - String fileBasePath = getFilePath(); - //文件存储的相对路径,以日期分隔,每天创建一个新的目录 - String filePath = DateFormatter.toString(new Date(), "yyyyMMdd"); - //文件存储绝对路径 - String absPath = fileBasePath.concat("/").concat(filePath); - File path = new File(absPath); - if (!path.exists()) { - path.mkdirs(); //创建目录 - } - String newName = String.valueOf(System.nanoTime()); //临时文件名 ,纳秒的md5值 - String fileAbsName = absPath.concat("/").concat(newName); - int fileSize; - MessageDigest digest = DigestUtils.getMd5Digest(); - try (InputStream proxyStream = new InputStream() { - @Override - public int read(byte[] b, int off, int len) throws IOException { - int l = fileStream.read(b, off, len); - digest.update(b, off, len); - return l; - } - - @Override - public void close() throws IOException { - fileStream.close(); - super.close(); - } - - @Override - public int available() throws IOException { - return fileStream.available(); - } - - @Override - public int read() throws IOException { - return fileStream.read(); - } - }; FileOutputStream os = new FileOutputStream(fileAbsName)) { - int remainBytes = fileSize = proxyStream.available(); - byte[] buff = new byte[remainBytes > 1024 * 10 ? 1024 * 10 : remainBytes]; - int bytes; - logger.info("开始写出文件:{}到:{}, size: {} bytes", fileName, fileAbsName, fileSize); - while (remainBytes > 0) { - bytes = proxyStream.read(buff, 0, remainBytes > buff.length ? buff.length : remainBytes); - os.write(buff, 0, bytes); - remainBytes -= bytes; - logger.info("写出文件:{}:{},剩余数据量: {} bytes", fileName, fileAbsName, remainBytes); - } - // StreamUtils.copy(in, os); - } - - String md5 = Hex.encodeHexString(digest.digest()); - - File newFile = new File(fileAbsName); - //获取文件的md5值 - //判断文件是否已经存在 - FileInfoEntity fileInfo = fileInfoService.selectByMd5(md5); - if (fileInfo != null) { - logger.info("文件:{}已上传过", fileAbsName); - if (new File(getFilePath() + "/" + fileInfo.getLocation()).exists()) { - newFile.delete();//文件已存在则删除临时文件不做处理 - } else { - newFile.renameTo(new File(absPath.concat("/").concat(md5))); - } - return fileInfo; - } else { - logger.info("上传文件{}完成:{}->{}", fileName, fileAbsName, absPath.concat("/").concat(md5)); - newFile.renameTo(new File(absPath.concat("/").concat(md5))); - } - FileInfoEntity infoEntity = fileInfoService.createEntity(); - infoEntity.setCreateTimeNow(); - infoEntity.setCreatorId(creatorId); - infoEntity.setLocation(filePath.concat("/").concat(md5)); - infoEntity.setName(fileName); - infoEntity.setType(type); - infoEntity.setSize((long) fileSize); - infoEntity.setMd5(md5); - infoEntity.setStatus(DataStatus.STATUS_ENABLED); - fileInfoService.insert(infoEntity); - return infoEntity; - } - - @Override - public void writeFile(String fileId, OutputStream out, long skip) throws IOException { - try (InputStream inputStream = readFile(fileId)) { - if (skip > 0) { - long len = inputStream.skip(skip); - logger.info("skip write stream {},{}", skip, len); - } - StreamUtils.copy(inputStream, out); - } - } - -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/SimpleFileInfoService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/SimpleFileInfoService.java deleted file mode 100644 index 34a59c787..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/java/org/hswebframework/web/service/file/simple/SimpleFileInfoService.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.hswebframework.web.service.file.simple; - -import org.hswebframework.web.dao.file.FileInfoDao; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.file.FileInfoService; -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.cache.annotation.Caching; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("fileInfoService") -@CacheConfig(cacheNames = "file-info") -public class SimpleFileInfoService extends GenericEntityService - implements FileInfoService { - private FileInfoDao fileInfoDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public FileInfoDao getDao() { - return fileInfoDao; - } - - @Autowired - public void setFileInfoDao(FileInfoDao fileInfoDao) { - this.fileInfoDao = fileInfoDao; - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'md5:'+#entity.md5"), - @CacheEvict(key = "'id:'+#result"), - @CacheEvict(key = "'id-or-md5:'+#result"), - @CacheEvict(key = "'id-or-md5:'+#result") - }) - public String insert(FileInfoEntity entity) { - return super.insert(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'md5:'+#entity.md5"), - @CacheEvict(key = "'id:'+#entity.id"), - @CacheEvict(key = "'id-or-md5:'+#entity.id"), - @CacheEvict(key = "'id-or-md5:'+#entity.id") - }) - protected int updateByPk(FileInfoEntity entity) { - return super.updateByPk(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'md5:'+#result.md5", condition = "#result!=null"), - @CacheEvict(key = "'id:'+#id"), - @CacheEvict(key = "'id-or-md5:'+#id"), - @CacheEvict(key = "'id-or-md5:'+#id") - }) - public FileInfoEntity deleteByPk(String id) { - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @Cacheable(key = "'id:'+#id", condition = "#id!=null") - public FileInfoEntity selectByPk(String id) { - return super.selectByPk(id); - } - - @Override - @Cacheable(key = "'md5:'+#md5", condition = "#md5!=null") - public FileInfoEntity selectByMd5(String md5) { - if (null == md5) { - return null; - } - return createQuery().where(FileInfoEntity.md5, md5).single(); - } - - @Override - @Cacheable(key = "'id-or-md5:'+#idOrMd5", condition = "#idOrMd5!=null") - public FileInfoEntity selectByIdOrMd5(String idOrMd5) { - if (null == idOrMd5) { - return null; - } - return createQuery().where(FileInfoEntity.md5, idOrMd5).or(FileInfoEntity.id, idOrMd5).single(); - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/file/FileInfoMapper.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/file/FileInfoMapper.xml deleted file mode 100644 index 3d519760f..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/file/FileInfoMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/pom.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/pom.xml deleted file mode 100644 index b0ef72e3d..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - hsweb-system-file - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-file-oauth2 - - 基于hsweb oauth2的文件服务,通过oauth2调用远程文件服务. - - - - org.hswebframework.web - hsweb-system-file-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-service-oauth2 - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileAutoConfiguration.java b/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileAutoConfiguration.java deleted file mode 100644 index 4586518e2..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileAutoConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.service.file.oauth2; - -import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestService; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -@ConditionalOnBean(OAuth2RequestService.class) -public class OAuth2FileAutoConfiguration { - - @ConfigurationProperties(prefix = "hsweb.oauth2.file-server") - @Bean - public OAuth2FileInfoService oAuth2FileInfoService() { - return new OAuth2FileInfoService(); - } - - @ConfigurationProperties(prefix = "hsweb.oauth2.file-server") - @Bean - public OAuth2FileService oAuth2FileService() { - return new OAuth2FileService(); - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileInfoService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileInfoService.java deleted file mode 100644 index d58cb8345..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileInfoService.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.hswebframework.web.service.file.oauth2; - -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.oauth2.AbstractOAuth2CrudService; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author zhouhao - * @since - */ - -public class OAuth2FileInfoService extends AbstractOAuth2CrudService implements FileInfoService { - - private String serviceId = "file-server"; - - private String uriPrefix = "file-info"; - - @Override - public FileInfoEntity selectByMd5(String md5) { - return selectSingle(QueryParamEntity - .single(FileInfoEntity.md5, md5)); - } - - @Override - public FileInfoEntity selectByIdOrMd5(String idOrMd5) { - return selectSingle(QueryParamEntity - .single(FileInfoEntity.id, idOrMd5) - .or(FileInfoEntity.md5, idOrMd5)); - } - - @Override - public String getServiceId() { - return serviceId; - } - - @Override - public String getUriPrefix() { - return uriPrefix; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public void setUriPrefix(String uriPrefix) { - this.uriPrefix = uriPrefix; - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileService.java deleted file mode 100644 index 3775287fc..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/java/org/hswebframework/web/service/file/oauth2/OAuth2FileService.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.hswebframework.web.service.file.oauth2; - -import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestService; -import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.entity.file.SimpleFileInfoEntity; -import org.hswebframework.web.service.file.FileService; -import org.hswebframework.web.service.oauth2.OAuth2ServiceSupport; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.util.StreamUtils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author zhouhao - * @since 3.0 - */ -@ConfigurationProperties(prefix = "hsweb.oauth2.file-server") -public class OAuth2FileService implements FileService, OAuth2ServiceSupport { - private String serviceId = "file-server"; - - private String uriPrefix = "file"; - - @Autowired - private OAuth2RequestService requestService; - - @Override - public InputStream readFile(String fileIdOrMd5) { - return createRequest("/md5/download/" + fileIdOrMd5) - .get() - .as(OAuth2Response::asStream); - } - - @Override - public FileInfoEntity saveFile(InputStream fileStream, String fileName, String type, String creatorId) throws IOException { - return createRequest("/upload") - .upload("file", fileStream, fileName) - .as(getEntityType()); - } - - @Override - public String saveStaticFile(InputStream fileStream, String fileName) throws IOException { - return createRequest("/upload-static") - .upload("file", fileStream, fileName) - .as(String.class); - } - - @Override - public void writeFile(String fileId, OutputStream out, long skip) throws IOException { - try (InputStream stream = createRequest("/download/" + fileId) - .header("Range", "bytes=" + skip) - .get().asStream()) { - StreamUtils.copy(stream, out); - } - } - - @Override - public OAuth2RequestService getRequestService() { - return requestService; - } - - @Override - public String getServiceId() { - return serviceId; - } - - @Override - public String getUriPrefix() { - return uriPrefix; - } - - @Override - @SuppressWarnings("unchecked") - public Class getEntityType() { - return SimpleFileInfoEntity.class; - } - - @Override - @SuppressWarnings("unchecked") - public Class getPrimaryKeyType() { - return String.class; - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 5c3ced887..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-oauth2/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.service.file.oauth2.OAuth2FileAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/pom.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/pom.xml deleted file mode 100644 index 46a441cc6..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - hsweb-system-file - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-file-starter - - - - - - src/main/resources - true - - - - - - - com.luhuiguo - fastdfs-spring-boot-starter - 0.2.0 - true - - - - org.hswebframework.web - hsweb-system-file-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-file-web - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FastdfsServiceAutoConfiguration.java b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FastdfsServiceAutoConfiguration.java deleted file mode 100644 index 6bc281f0f..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FastdfsServiceAutoConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.file.starter; - -import org.hswebframework.web.service.file.fastdfs.FdfsFileService; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since - */ -@Configuration -@ConditionalOnProperty(prefix = "hsweb.web.upload.fdfs", name = "enable", havingValue = "true") -public class FastdfsServiceAutoConfiguration { - - @Bean - @ConfigurationProperties(prefix = "hsweb.web.upload") - public FdfsFileService fdfsFileService() { - return new FdfsFileService(); - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FileAutoConfiguration.java b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FileAutoConfiguration.java deleted file mode 100644 index a88edfd3f..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/java/org/hswebframework/web/file/starter/FileAutoConfiguration.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.file.starter; - -import org.hswebframework.web.service.file.FileService; -import org.hswebframework.web.service.file.simple.LocalFileService; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.file.simple" - , "org.hswebframework.web.controller.file"}) -@ImportAutoConfiguration(FastdfsServiceAutoConfiguration.class) -public class FileAutoConfiguration { - - @ConditionalOnMissingBean(FileService.class) - @Bean - public LocalFileService localFileService() { - return new LocalFileService(); - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f8e69fe64..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.file.starter.FileAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 809546a61..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,51 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "文件信息" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_file_info") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("文件名称").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("location").alias("location").comment("文件相对路径").jdbcType(java.sql.JDBCType.VARCHAR).length(1024).commit() - .addColumn().name("type").alias("type").comment("类型").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("md5").alias("md5").comment("md5校验值").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("size").alias("size").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() - .addColumn().name("classified").alias("classified").comment("分类").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("create_time").alias("create_time").comment("创建时间").jdbcType(java.sql.JDBCType.NUMERIC).length(32,0).commit() - .addColumn().name("creator_id").alias("creatorId").comment("创建人").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .index().name("idx_file_md5").column("md5").commit() - .index().name("idx_file_creator_id").column("creator_id").commit() - - .comment("文件信息").commit(); -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FileUploadTests.java b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FileUploadTests.java deleted file mode 100644 index 3db52f54a..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FileUploadTests.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.hswebframework.web.service.file; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; - -public class FileUploadTests extends SimpleWebApplicationTests { - - @Test - public void testUploadFile() throws Exception { - - //test multi file upload - String result = mvc.perform( - MockMvcRequestBuilders - .fileUpload("/file/upload-multi") - .file(new MockMultipartFile("files", "test.txt", - MediaType.TEXT_PLAIN_VALUE, "test".getBytes())) - .file(new MockMultipartFile("files", "test2.txt", - MediaType.TEXT_PLAIN_VALUE, "test2".getBytes())) - ).andReturn() - .getResponse() - .getContentAsString(); - - - Assert.assertEquals(JSON.parseObject(result).getJSONArray("result").size(), 2); - System.out.println(result); - String fileId = JSON.parseObject(result) - .getJSONArray("result") - .getJSONObject(0) - .getString("id"); - String fileMd5 = JSON.parseObject(result) - .getJSONArray("result") - .getJSONObject(0) - .getString("md5"); - - result = testGet("/file/md5/" + fileMd5).exec().resultAsString(); - System.out.println(result); - - result = mvc.perform(MockMvcRequestBuilders.get("/file/download/" + fileId)) - .andReturn() - .getResponse() - .getContentAsString(); - - System.out.println(result); - - result = mvc.perform(MockMvcRequestBuilders - .fileUpload("/file/upload-static") - .file(new MockMultipartFile("file", "test.txt", - MediaType.TEXT_PLAIN_VALUE, "test".getBytes()))) - .andReturn() - .getResponse() - .getContentAsString(); - - System.out.println(result); - Assert.assertNotNull(JSON.parseObject(result).getString("result")); - - - } - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FixBug93Test.java b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FixBug93Test.java deleted file mode 100644 index fa045a907..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/java/org/hswebframework/web/service/file/FixBug93Test.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.service.file; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; - -/** - * fix bug #93 test - * - * @author zhouhao - * @since 3.0.2 - */ -public class FixBug93Test extends SimpleWebApplicationTests { - - @Test - public void testUploadFile() throws Exception { - String result = mvc.perform( - MockMvcRequestBuilders - .fileUpload("/file/upload") - .file(new MockMultipartFile("file", "test中文.txt", MediaType.TEXT_PLAIN_VALUE, "test".getBytes())) - ).andReturn() - .getResponse() - .getContentAsString(); - - Assert.assertEquals(JSON.parseObject(result).getJSONObject("result").getString("name"), "test中文.txt"); - } - -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/resources/application.yml deleted file mode 100644 index f1c6c9fd6..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-starter/src/test/resources/application.yml +++ /dev/null @@ -1,30 +0,0 @@ - -spring: - http: - multipart: - enabled: true - aop: - auto: true - datasource: - url : jdbc:h2:mem:file_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver - -hsweb: - app: - name: 数据字典测试 - version: 3.0.0 - web: - upload: -# fdfs: -# enable: true - static-file-path: target/static - static-location: http://localhost:8080/ - file-path: target/file -fdfs: - connect-timeout: 2000 - so-timeout: 3000 - tracker-list: - - localhost:22122 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-web/pom.xml b/hsweb-system/hsweb-system-file/hsweb-system-file-web/pom.xml deleted file mode 100644 index 5a6639e91..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-web/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - hsweb-system-file - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-file-web - - 通过SpringMvc实现文件上传,秒传等功能 - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-file-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - commons-fileupload - commons-fileupload - 1.3.3 - - - org.hswebframework - hsweb-expands-compress - ${hsweb.expands.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileController.java b/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileController.java deleted file mode 100644 index c36d27a09..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileController.java +++ /dev/null @@ -1,304 +0,0 @@ -package org.hswebframework.web.controller.file; - -import com.alibaba.fastjson.JSON; -import io.swagger.annotations.*; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.fileupload.ParameterParser; -import org.hswebframework.expands.compress.Compress; -import org.hswebframework.expands.compress.zip.ZIPWriter; -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.WebUtil; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.file.FileService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.activation.MimetypesFileTypeMap; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Optional.ofNullable; - -/** - * 文件操作控制器,提供文件上传下载等操作 - * - * @author zhouhao - * @see FileService - * @since 3.0 - */ -@RestController -@RequestMapping("${hsweb.web.mappings.file:file}") -@Authorize(permission = "file", description = "文件管理") -@Api(value = "文件管理", tags = "文件管理-文件操作") -@SuppressWarnings("all") -public class FileController { - - private FileService fileService; - - private FileInfoService fileInfoService; - - private Logger logger = LoggerFactory.getLogger(this.getClass()); - - private static final Pattern fileNameKeyWordPattern = Pattern.compile("(\\\\)|(/)|(:)(|)|(\\?)|(>)|(<)|(\")"); - - @Autowired - public void setFileService(FileService fileService) { - this.fileService = fileService; - } - - @Autowired - public void setFileInfoService(FileInfoService fileInfoService) { - this.fileInfoService = fileInfoService; - } - - /** - * 构建并下载zip文件.仅支持POST请求 - * - * @param name 文件名 - * @param dataStr 数据,jsonArray. 格式:[{"name":"fileName","text":"fileText"}] - * @param response {@link HttpServletResponse} - * @throws IOException 写出zip文件错误 - * @throws RuntimeException 构建zip文件错误 - */ - @RequestMapping(value = "/download-zip/{name:.+}", method = {RequestMethod.POST}) - @ApiOperation("构建zip文件并下载") - @Authorize(action = "download", description = "下载文件") - public void downloadZip(@ApiParam("zip文件名") @PathVariable("name") String name, - @ApiParam(value = "zip文件内容", example = "[" + - "{\"name\":\"textFile.txt\",\"text\":\"fileText\"}," + - "{\"name\":\"uploadedFile.png\",\"file\":\"fileId or file md5\"}" + - "{\"name\":\"base64File.text\",\"base64\":\"aGVsbG8=\"}" + - "]") @RequestParam("data") String dataStr, - HttpServletResponse response) throws IOException { - response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); - - response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8")); - ZIPWriter writer = Compress.zip(); - List> data = (List) JSON.parseArray(dataStr, Map.class); - data.forEach(map -> { - String entryName = map.get("name"); - String text = map.get("text"); - String file = map.get("file"); - String fileBase64 = map.get("base64"); - if (text != null) { - writer.addTextFile(map.get("name"), text); - } else if (file != null) { - writer.addFile(entryName, fileService.readFile(file)); - } else if (fileBase64 != null) { - writer.addFile(entryName, new ByteArrayInputStream(Base64.decodeBase64(fileBase64))); - } - }); - writer.write(response.getOutputStream()); - } - - /** - * 构建一个文本文件,并下载.支持GET,POST请求 - * - * @param name 文件名 - * @param text 文本内容 - * @param response {@link HttpServletResponse} - * @throws IOException 写出文本内容错误 - */ - @RequestMapping(value = "/download-text/{name:.+}", method = {RequestMethod.GET, RequestMethod.POST}) - @ApiOperation("构建文本文件并下载") - @Authorize(action = "download", description = "下载文件") - public void downloadTxt(@ApiParam("文件名") @PathVariable("name") String name, - @ApiParam("文本内容") @RequestParam("text") String text, - HttpServletResponse response) throws IOException { - response.setCharacterEncoding("utf-8"); - response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=utf-8"); - response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8")); - response.getWriter().write(text); - } - - /** - * 使用restful风格,通过文件ID下载已经上传的文件,支持断点下载 - * 如: http://host:port/file/download/aSk2a/file.zip 将下载 ID为aSk2a的文件.并命名为file.zip - * - * @param id 文件ID - * @param name 文件名 - * @param response {@link HttpServletResponse} - * @param request {@link HttpServletRequest} - * @return 下载结果, 在下载失败时, 将返回错误信息 - * @throws IOException 读写文件错误 - * @throws NotFoundException 文件不存在 - */ - @RequestMapping(value = "/download/{id}/{name:.+}", method = RequestMethod.GET) - @ApiOperation("指定文件名下载文件") - @Authorize(action = "download", description = "下载文件") - public void restDownLoad(@ApiParam("文件的id或者md5") @PathVariable("id") String id, - @ApiParam("文件名") @PathVariable("name") String name, - @ApiParam(hidden = true) HttpServletResponse response, - @ApiParam(hidden = true) HttpServletRequest request) throws IOException { - - downLoad(id, name, response, request); - } - - /** - * 通过文件ID下载已经上传的文件,支持断点下载 - * 如: http://host:port/file/download/aSk2a/file.zip 将下载 ID为aSk2a的文件.并命名为file.zip - * - * @param idOrMd5 要下载资源文件的id或者md5值 - * @param name 自定义文件名,该文件名不能存在非法字符.如果此参数为空(null).将使用文件上传时的文件名 - * @param response {@link javax.servlet.http.HttpServletResponse} - * @param request {@link javax.servlet.http.HttpServletRequest} - * @return 下载结果, 在下载失败时, 将返回错误信息 - * @throws IOException 读写文件错误 - * @throws org.hswebframework.web.NotFoundException 文件不存在 - */ - @GetMapping(value = "/download/{id}") - @ApiOperation("下载文件") - @Authorize(action = "download", description = "下载文件") - public void downLoad(@ApiParam("文件的id或者md5") @PathVariable("id") String idOrMd5, - @ApiParam(value = "文件名,如果未指定,默认为上传时的文件名", required = false) @RequestParam(value = "name", required = false) String name, - @ApiParam(hidden = true) HttpServletResponse response, @ApiParam(hidden = true) HttpServletRequest request) - throws IOException { - FileInfoEntity fileInfo = fileInfoService.selectByIdOrMd5(idOrMd5); - if (fileInfo == null || !DataStatus.STATUS_ENABLED.equals(fileInfo.getStatus())) { - throw new NotFoundException("文件不存在"); - } - String fileName = fileInfo.getName(); - - String suffix = fileName.contains(".") ? - fileName.substring(fileName.lastIndexOf("."), fileName.length()) : - ""; - //获取contentType - String contentType = fileInfo.getType() == null ? - MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(fileName) : - fileInfo.getType(); - //未自定义文件名,则使用上传时的文件名 - if (StringUtils.isNullOrEmpty(name)) { - name = fileInfo.getName(); - } - //如果未指定文件拓展名,则追加默认的文件拓展名 - if (!name.contains(".")) { - name = name.concat(".").concat(suffix); - } - //关键字剔除 - name = fileNameKeyWordPattern.matcher(name).replaceAll(""); - int skip = 0; - long fSize = fileInfo.getSize(); - //尝试判断是否为断点下载 - try { - //获取要继续下载的位置 - String Range = request.getHeader("Range").replace("bytes=", "").replace("-", ""); - skip = StringUtils.toInt(Range); - } catch (Exception ignore) { - } - response.setContentLength((int) fSize);//文件大小 - response.setContentType(contentType); - response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8")); - //断点下载 - if (skip > 0) { - response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); - String contentRange = "bytes " + skip + "-" + (fSize - 1) + "/" + fSize; - response.setHeader("Content-Range", contentRange); - } - fileService.writeFile(idOrMd5, response.getOutputStream(), skip); - } - - /** - * 上传文件,支持多文件上传.获取到文件流后,调用{@link org.hswebframework.web.service.file.FileService#saveFile(InputStream, String, String, String)}进行文件保存 - * 上传成功后,将返回资源信息如:[{"id":"fileId","name":"fileName","md5":"md5"}] - * - * @param files 上传的文件 - * @return 文件上传结果. - */ - @PostMapping(value = "/upload-multi") - @ApiOperation("上传多个文件") - @Authorize(action = "upload", description = "上传文件") - public ResponseMessage> upload(@RequestPart("files") MultipartFile[] files) { - return ResponseMessage.ok(Stream.of(files) - .map(this::upload) - .map(ResponseMessage::getResult) - .collect(Collectors.toList())) - .include(FileInfoEntity.class, - FileInfoEntity.id, - FileInfoEntity.name, - FileInfoEntity.md5, - FileInfoEntity.size, - FileInfoEntity.type); - } - - /** - * 上传单个文件 - * - * @param file 上传文件 - * @return 上传结果 - */ - @PostMapping(value = "/upload") - @ApiOperation("上传单个文件") - @Authorize(action = "upload", description = "上传文件") - public ResponseMessage upload(@RequestPart("file") MultipartFile file) { - Authentication authentication = Authentication.current().orElse(null); - String creator = authentication == null ? null : authentication.getUser().getId(); - if (file.isEmpty()) { - return ResponseMessage.ok(); - } - String fileName = file.getOriginalFilename(); - //fix bug #93 -// String contentType = Optional.ofNullable(WebUtil.getHttpServletRequest()) -// .orElseThrow(UnsupportedOperationException::new) -// .getContentType(); -// ParameterParser parser = new ParameterParser(); -// Map params = parser.parse(contentType, ';'); -// if (params.get("charset") == null) { -// fileName = new String(file.getOriginalFilename().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); -// } - FileInfoEntity fileInfo; - try { - fileInfo = fileService.saveFile(file.getInputStream(), fileName, file.getContentType(), creator); - } catch (IOException e) { - throw new BusinessException("save file error", e); - } - return ResponseMessage.ok(fileInfo) - .include(FileInfoEntity.class, FileInfoEntity.id, - FileInfoEntity.name, - FileInfoEntity.md5, - FileInfoEntity.size, - FileInfoEntity.type); - } - - @PostMapping(value = "/upload-static") - @ApiOperation(value = "上传静态文件", notes = "上传后响应结果的result字段为文件的访问地址") - @Authorize(action = "static", description = "上传静态文件") - public ResponseMessage uploadStatic(@RequestPart("file") MultipartFile file) throws IOException { - if (file.isEmpty()) { - return ResponseMessage.ok(); - } - return ResponseMessage.ok(fileService.saveStaticFile(file.getInputStream(), file.getOriginalFilename())); - } - - @GetMapping(value = "/md5/{md5}") - @ApiOperation("根据MD5获取文件信息") - public ResponseMessage uploadStatic(@PathVariable String md5) throws IOException { - return ofNullable(fileInfoService.selectByMd5(md5)) - .map(ResponseMessage::ok) - .orElseThrow(() -> new NotFoundException("file not found")); - } -} diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileInfoController.java b/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileInfoController.java deleted file mode 100644 index 505a121de..000000000 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-web/src/main/java/org/hswebframework/web/controller/file/FileInfoController.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.controller.file; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.QueryController; -import org.hswebframework.web.entity.file.FileInfoEntity; -import org.hswebframework.web.service.file.FileInfoService; -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.file-info:file-info}") -@Authorize(permission = "file-info", description = "文件信息管理") -@Api(value = "文件信息管理",tags = "文件管理-文件信息管理") -public class FileInfoController implements QueryController { - - private FileInfoService fileInfoService; - - @Autowired - public void setFileInfoService(FileInfoService fileInfoService) { - this.fileInfoService = fileInfoService; - } - - @Override - @SuppressWarnings("all") - public FileInfoService getService() { - return fileInfoService; - } - -} diff --git a/hsweb-system/hsweb-system-file/pom.xml b/hsweb-system/hsweb-system-file/pom.xml deleted file mode 100644 index 691ff7c21..000000000 --- a/hsweb-system/hsweb-system-file/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-file - pom - - hsweb-system-file-starter - hsweb-system-file-api - hsweb-system-file-local - hsweb-system-file-web - hsweb-system-file-oauth2 - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/pom.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/pom.xml deleted file mode 100644 index 9b7ce28d0..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - hsweb-system-oauth2-client - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-oauth2-client-api - - - - - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - org.hswebframework.web - hsweb-authorization-oauth2-client - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2ServerConfigEntity.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2ServerConfigEntity.java deleted file mode 100644 index 6512e636a..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2ServerConfigEntity.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * OAuth2服务配置 实体 - * - * @author hsweb-generator-online - */ -public interface OAuth2ServerConfigEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 服务名称 - */ - String name = "name"; - /** - * 备注 - */ - String describe = "describe"; - /** - * api根地址 - */ - String apiBaseUrl = "apiBaseUrl"; - /** - * 认证地址 - */ - String authUrl = "authUrl"; - /** - * token获取地址 - */ - String accessTokenUrl = "accessTokenUrl"; - /** - * 客户端id - */ - String clientId = "clientId"; - /** - * 客户端密钥 - */ - String clientSecret = "clientSecret"; - /** - * 状态 - */ - String status = "status"; - - String redirectUri = "redirectUri"; - - String provider = "provider"; - - String getProvider(); - - void setProvider(String provider); - - String getRedirectUri(); - - void setRedirectUri(String redirectUri); - - /** - * @return 服务名称 - */ - String getName(); - - /** - * 设置 服务名称 - */ - void setName(String name); - - /** - * @return 备注 - */ - String getDescribe(); - - /** - * 设置 备注 - */ - void setDescribe(String describe); - - /** - * @return api根地址 - */ - String getApiBaseUrl(); - - /** - * 设置 api根地址 - */ - void setApiBaseUrl(String apiBaseUrl); - - /** - * @return 认证地址 - */ - String getAuthUrl(); - - default String getRealUrl(String url) { - String base = getApiBaseUrl(); - if (url.startsWith("http")) { - return url; - } - if (!base.endsWith("/") && !url.startsWith("/")) { - base += "/"; - } - return base + url; - } - - /** - * 设置 认证地址 - */ - void setAuthUrl(String authUrl); - - /** - * @return token获取地址 - */ - String getAccessTokenUrl(); - - /** - * @param accessTokenUrl token获取地址 - */ - void setAccessTokenUrl(String accessTokenUrl); - - /** - * @return 客户端id - */ - String getClientId(); - - /** - * 设置 客户端id - */ - void setClientId(String clientId); - - /** - * @return 客户端密钥 - */ - String getClientSecret(); - - /** - * 设置 客户端密钥 - */ - void setClientSecret(String clientSecret); - - /** - * @return 是否启用 - */ - Byte getStatus(); - - /** - * 设置 是否启用 - */ - void setStatus(Byte status); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2UserTokenEntity.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2UserTokenEntity.java deleted file mode 100644 index 03624fd75..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/OAuth2UserTokenEntity.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * OAuth2用户授权信息 实体 - * - * @author hsweb-generator-online - */ -public interface OAuth2UserTokenEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 客户端用户id - */ - String clientUserId = "clientUserId"; - /** - * 服务端用户id - */ - String serverUserId = "serverUserId"; - /** - * 服务端id - */ - String serverId = "serverId"; - /** - * 客户端id - */ - String clientId = "clientId"; - /** - * 授权码 - */ - String accessToken = "accessToken"; - /** - * 更新码 - */ - String refreshToken = "refreshToken"; - /** - * 有效期 - */ - String expireIn = "expireIn"; - /** - * 授权范围 - */ - String scope = "scope"; - /** - * 创建时间 - */ - String createTime = "createTime"; - /** - * 更新时间 - */ - String updateTime = "updateTime"; - - //授权方式 - String grantType = "grantType"; - - /** - * @return 授权方式 - */ - String getGrantType(); - - /** - * 设置 授权方式 - */ - void setGrantType(String grantType); - - /** - * @return 客户端用户id - */ - String getClientUserId(); - - /** - * 设置 客户端用户id - */ - void setClientUserId(String clientUserId); - - /** - * @return 服务端用户id - */ - String getServerUserId(); - - /** - * 设置 服务端用户id - */ - void setServerUserId(String serverUserId); - - /** - * @return 服务端id - */ - String getServerId(); - - /** - * 设置 服务端id - */ - void setServerId(String serverId); - - /** - * @return 客户端id - */ - String getClientId(); - - /** - * 设置 客户端id - */ - void setClientId(String clientId); - - /** - * @return 授权码 - */ - String getAccessToken(); - - /** - * 设置 授权码 - */ - void setAccessToken(String accessToken); - - /** - * @return 更新码 - */ - String getRefreshToken(); - - /** - * 设置 更新码 - */ - void setRefreshToken(String refreshToken); - - /** - * @return 有效期 - */ - Integer getExpiresIn(); - - /** - * 设置 有效期 - */ - void setExpiresIn(Integer expiresIn); - - /** - * @return 授权范围 - */ - String getScope(); - - /** - * 设置 授权范围 - */ - void setScope(String scope); - - /** - * @return 创建时间 - */ - Long getCreateTime(); - - /** - * 设置 创建时间 - */ - void setCreateTime(Long createTime); - - /** - * @return 更新时间 - */ - Long getUpdateTime(); - - /** - * 设置 更新时间 - */ - void setUpdateTime(Long updateTime); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2ServerConfigEntity.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2ServerConfigEntity.java deleted file mode 100644 index 3f55a98cf..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2ServerConfigEntity.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * OAuth2服务配置 - * - * @author hsweb-generator-online - */ -public class SimpleOAuth2ServerConfigEntity extends SimpleGenericEntity implements OAuth2ServerConfigEntity { - //服务名称 - private String name; - //备注 - private String describe; - //api根地址 - private String apiBaseUrl; - //认证地址 - private String authUrl; - //token获取地址 - private String accessTokenUrl; - //客户端id - private String clientId; - //客户端密钥 - private String clientSecret; - //是否启用 - private Byte status; - //重定向地址 - private String redirectUri; - - //服务提供商 - private String provider; - - @Override - public String getProvider() { - return provider; - } - - @Override - public void setProvider(String provider) { - this.provider = provider; - } - - @Override - public String getRedirectUri() { - return redirectUri; - } - - @Override - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - /** - * @return 服务名称 - */ - @Override - public String getName() { - return this.name; - } - - /** - * 设置 服务名称 - */ - @Override - public void setName(String name) { - this.name = name; - } - - /** - * @return 备注 - */ - @Override - public String getDescribe() { - return this.describe; - } - - /** - * 设置 备注 - */ - @Override - public void setDescribe(String describe) { - this.describe = describe; - } - - /** - * @return api根地址 - */ - @Override - public String getApiBaseUrl() { - return this.apiBaseUrl; - } - - /** - * 设置 api根地址 - */ - @Override - public void setApiBaseUrl(String apiBaseUrl) { - this.apiBaseUrl = apiBaseUrl; - } - - /** - * @return 认证地址 - */ - @Override - public String getAuthUrl() { - return this.authUrl; - } - - /** - * 设置 认证地址 - */ - @Override - public void setAuthUrl(String authUrl) { - this.authUrl = authUrl; - } - - /** - * @return token获取地址 - */ - @Override - public String getAccessTokenUrl() { - return this.accessTokenUrl; - } - - /** - * 设置 token获取地址 - */ - @Override - public void setAccessTokenUrl(String accessTokenUrl) { - this.accessTokenUrl = accessTokenUrl; - } - - /** - * @return 客户端id - */ - @Override - public String getClientId() { - return this.clientId; - } - - /** - * 设置 客户端id - */ - @Override - public void setClientId(String clientId) { - this.clientId = clientId; - } - - /** - * @return 客户端密钥 - */ - @Override - public String getClientSecret() { - return this.clientSecret; - } - - /** - * 设置 客户端密钥 - */ - @Override - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - /** - * @return 是否启用 - */ - @Override - public Byte getStatus() { - return this.status; - } - - /** - * 设置 是否启用 - */ - @Override - public void setStatus(Byte status) { - this.status = status; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2UserTokenEntity.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2UserTokenEntity.java deleted file mode 100644 index 2affeb229..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/entity/oauth2/client/SimpleOAuth2UserTokenEntity.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * OAuth2用户授权信息 - * - * @author hsweb-generator-online - */ -public class SimpleOAuth2UserTokenEntity extends SimpleGenericEntity implements OAuth2UserTokenEntity { - //客户端用户id - private String clientUserId; - //服务端用户id - private String serverUserId; - //服务端id - private String serverId; - //客户端id - private String clientId; - //授权码 - private String accessToken; - //更新码 - private String refreshToken; - //有效期 - private Integer expiresIn; - //授权范围 - private String scope; - //创建时间 - private Long createTime; - //更新时间 - private Long updateTime; - - private String grantType; - - @Override - public String getGrantType() { - return grantType; - } - - @Override - public void setGrantType(String grantType) { - this.grantType = grantType; - } - - /** - * @return 客户端用户id - */ - @Override - public String getClientUserId() { - return this.clientUserId; - } - - /** - * 设置 客户端用户id - */ - @Override - public void setClientUserId(String clientUserId) { - this.clientUserId = clientUserId; - } - - /** - * @return 服务端用户id - */ - @Override - public String getServerUserId() { - return this.serverUserId; - } - - /** - * 设置 服务端用户id - */ - @Override - public void setServerUserId(String serverUserId) { - this.serverUserId = serverUserId; - } - - /** - * @return 服务端id - */ - @Override - public String getServerId() { - return this.serverId; - } - - /** - * 设置 服务端id - */ - @Override - public void setServerId(String serverId) { - this.serverId = serverId; - } - - /** - * @return 客户端id - */ - @Override - public String getClientId() { - return this.clientId; - } - - /** - * 设置 客户端id - */ - @Override - public void setClientId(String clientId) { - this.clientId = clientId; - } - - /** - * @return 授权码 - */ - @Override - public String getAccessToken() { - return this.accessToken; - } - - /** - * 设置 授权码 - */ - @Override - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - /** - * @return 更新码 - */ - @Override - public String getRefreshToken() { - return this.refreshToken; - } - - /** - * 设置 更新码 - */ - @Override - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - } - - /** - * @return 有效期 - */ - @Override - public Integer getExpiresIn() { - return this.expiresIn; - } - - /** - * 设置 有效期 - */ - @Override - public void setExpiresIn(Integer expiresIn) { - this.expiresIn = expiresIn; - } - - /** - * @return 授权范围 - */ - @Override - public String getScope() { - return this.scope; - } - - /** - * 设置 授权范围 - */ - @Override - public void setScope(String scope) { - this.scope = scope; - } - - /** - * @return 创建时间 - */ - @Override - public Long getCreateTime() { - return this.createTime; - } - - /** - * 设置 创建时间 - */ - @Override - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } - - /** - * @return 更新时间 - */ - @Override - public Long getUpdateTime() { - return this.updateTime; - } - - /** - * 设置 更新时间 - */ - @Override - public void setUpdateTime(Long updateTime) { - this.updateTime = updateTime; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2ServerConfigService.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2ServerConfigService.java deleted file mode 100644 index a081460d1..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2ServerConfigService.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.entity.oauth2.client.OAuth2ServerConfigEntity; -import org.hswebframework.web.service.CrudService; - -/** - * OAuth2服务配置 服务类 - * - * @author hsweb-generator-online - */ -public interface OAuth2ServerConfigService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2UserTokenService.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2UserTokenService.java deleted file mode 100644 index 02456b570..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-api/src/main/java/org/hswebframework/web/service/oauth2/client/OAuth2UserTokenService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client; - -import org.hswebframework.web.entity.oauth2.client.OAuth2UserTokenEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * OAuth2用户授权信息 服务类 - * - * @author hsweb-generator-online - */ -public interface OAuth2UserTokenService extends CrudService { -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/pom.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/pom.xml deleted file mode 100644 index 965603caf..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - hsweb-system-oauth2-client - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-oauth2-client-local - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-oauth2-client-api - ${project.version} - - - org.hswebframework.web - hsweb-authorization-oauth2-client - ${project.version} - - - org.hswebframework - hsweb-expands-request - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2ServerConfigDao.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2ServerConfigDao.java deleted file mode 100644 index 0f88e65fb..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2ServerConfigDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.client; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.oauth2.client.OAuth2ServerConfigEntity; - -/** -* OAuth2服务配置 DAO接口 -* @author hsweb-generator-online - */ -public interface OAuth2ServerConfigDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2UserTokenDao.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2UserTokenDao.java deleted file mode 100644 index 258fe1ff9..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/dao/oauth2/server/client/OAuth2UserTokenDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.client; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.oauth2.client.OAuth2UserTokenEntity; - -/** -* OAuth2用户授权信息 DAO接口 -* @author hsweb-generator-online - */ -public interface OAuth2UserTokenDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2ServerConfigService.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2ServerConfigService.java deleted file mode 100644 index f45b1b46f..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2ServerConfigService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client.simple; - -import org.hswebframework.web.authorization.oauth2.client.OAuth2ServerConfig; -import org.hswebframework.web.authorization.oauth2.client.simple.OAuth2ServerConfigRepository; -import org.hswebframework.web.dao.oauth2.server.client.OAuth2ServerConfigDao; -import org.hswebframework.web.entity.oauth2.client.OAuth2ServerConfigEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.oauth2.client.OAuth2ServerConfigService; -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.List; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("oAuth2ServerConfigService") -@CacheConfig(cacheNames = "oauth2-server-config") -public class SimpleOAuth2ServerConfigService extends GenericEntityService - implements OAuth2ServerConfigService, OAuth2ServerConfigRepository { - @Autowired - private OAuth2ServerConfigDao oAuth2ServerConfigDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public OAuth2ServerConfigDao getDao() { - return oAuth2ServerConfigDao; - } - - @Override - @Cacheable(key = "'conf-id:'+#id") - public OAuth2ServerConfig findById(String id) { - OAuth2ServerConfigEntity entity = selectByPk(id); - if (null == entity) { - return null; - } - return entityFactory.newInstance(OAuth2ServerConfig.class, entity); - } - - @Override - @CacheEvict(key = "'conf-id:'+#id") - public int updateByPk(String id, OAuth2ServerConfigEntity entity) { - return super.updateByPk(id, entity); - } - - @Override - @CacheEvict(key = "'conf-id:'+#id") - public OAuth2ServerConfigEntity deleteByPk(String id) { - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(key = "'conf-id:'+#result") - public String saveOrUpdate(OAuth2ServerConfigEntity entity) { - return super.saveOrUpdate(entity); - } - - @Override - @CacheEvict(key = "'conf-id:'+#result.id") - public OAuth2ServerConfig save(OAuth2ServerConfig config) { - OAuth2ServerConfigEntity entity = entityFactory.newInstance(OAuth2ServerConfigEntity.class, config); - saveOrUpdate(entity); - return config; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java deleted file mode 100644 index 6926ada07..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/java/org/hswebframework/web/service/oauth2/client/simple/SimpleOAuth2UserTokenService.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client.simple; - -import org.hswebframework.web.authorization.oauth2.client.AccessTokenInfo; -import org.hswebframework.web.authorization.oauth2.client.simple.OAuth2UserTokenRepository; -import org.hswebframework.web.dao.oauth2.server.client.OAuth2UserTokenDao; -import org.hswebframework.web.entity.oauth2.client.OAuth2UserTokenEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.oauth2.client.OAuth2UserTokenService; -import org.springframework.beans.factory.annotation.Autowired; -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.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; - -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("oAuth2UserTokenService") -public class SimpleOAuth2UserTokenService extends GenericEntityService - implements OAuth2UserTokenService, OAuth2UserTokenRepository { - @Autowired - private OAuth2UserTokenDao oAuth2UserTokenDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public OAuth2UserTokenDao getDao() { - return oAuth2UserTokenDao; - } - - @Override - public AccessTokenInfo createToken() { - return entityFactory.newInstance(AccessTokenInfo.class); - } - - @Override - @Cacheable(cacheNames = "oauth2-user-token-list", key = "'s-g-t:'+#serverId+':'+#grantType") - public List findByServerIdAndGrantType(String serverId, String grantType) { - return selectByServerIdAndGrantType(serverId, grantType).stream() - .map(tokenInfoMapping()) - .collect(Collectors.toList()); - } - - @Override - @Cacheable(cacheNames = "oauth2-user-token", key = "'a-t:'+#accessToken") - public AccessTokenInfo findByAccessToken(String accessToken) { - return Optional.ofNullable(selectByAccessToken(accessToken)).map(tokenInfoMapping()).orElse(null); - } - - protected Function tokenInfoMapping() { - return entity -> { - - AccessTokenInfo info = entityFactory.newInstance(AccessTokenInfo.class, entity); - info.setExpiresIn(entity.getExpiresIn()); - info.setAccessToken(entity.getAccessToken()); - info.setCreateTime(entity.getCreateTime()); - info.setUpdateTime(entity.getUpdateTime()); - info.setRefreshToken(entity.getRefreshToken()); - info.setServerId(entity.getServerId()); - info.setGrantType(entity.getGrantType()); - info.setScope(entity.getScope()); - return info; - }; - } - - protected Function entityTokenInfoMapping() { - return info -> - { - OAuth2UserTokenEntity entity = entityFactory.newInstance(OAuth2UserTokenEntity.class, info); - entity.setExpiresIn(info.getExpiresIn()); - entity.setAccessToken(info.getAccessToken()); - entity.setCreateTime(info.getCreateTime()); - entity.setUpdateTime(info.getUpdateTime()); - entity.setRefreshToken(info.getRefreshToken()); - entity.setServerId(info.getServerId()); - entity.setGrantType(info.getGrantType()); - entity.setScope(info.getScope()); - return entity; - }; - } - - @Override - @Caching( - put = @CachePut(cacheNames = "oauth2-user-token", key = "'a-t:'+#tokenInfo.accessToken"), - evict = @CacheEvict(cacheNames = "oauth2-user-token-list", key = "'s-g-t:'+#result.serverId+':'+#result.grantType") - ) - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public AccessTokenInfo update(String id, AccessTokenInfo tokenInfo) { - OAuth2UserTokenEntity entity = entityTokenInfoMapping().apply(tokenInfo); - entity.setUpdateTime(System.currentTimeMillis()); - updateByPk(id, entity); - return tokenInfo; - } - - @Override - @Caching( - put = @CachePut(cacheNames = "oauth2-user-token", key = "'a-t:'+#tokenInfo.accessToken"), - evict = @CacheEvict(cacheNames = "oauth2-user-token-list", key = "'s-g-t:'+#result.serverId+':'+#result.grantType") - ) - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public AccessTokenInfo insert(AccessTokenInfo tokenInfo) { - if (tokenInfo.getId() == null) { - tokenInfo.setId(getIDGenerator().generate()); - } - OAuth2UserTokenEntity entity = entityTokenInfoMapping().apply(tokenInfo); - entity.setCreateTime(tokenInfo.getCreateTime()); - entity.setUpdateTime(tokenInfo.getUpdateTime()); - - insert(entity); - return tokenInfo; - } - - public List selectByServerIdAndGrantType(String serverId, String grantType) { - Assert.notNull(serverId, "serverId can not be null!"); - Assert.notNull(grantType, "grantType can not be null!"); - return createQuery() - .where(OAuth2UserTokenEntity.serverId, serverId) - .is(OAuth2UserTokenEntity.grantType, grantType) - .listNoPaging(); - } - - public OAuth2UserTokenEntity selectByAccessToken(String accessToken) { - Assert.notNull(accessToken, "token can not be null!"); - return createQuery().where(OAuth2UserTokenEntity.accessToken, accessToken) - .single(); - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2ServerConfigMapper.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2ServerConfigMapper.xml deleted file mode 100644 index d8cb41770..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2ServerConfigMapper.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2UserTokenMapper.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2UserTokenMapper.xml deleted file mode 100644 index ca8ba0a19..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/client/OAuth2UserTokenMapper.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/pom.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/pom.xml deleted file mode 100644 index 5f3647d89..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - hsweb-system-oauth2-client - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-oauth2-client-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-oauth2-client-local - ${project.version} - - - org.hswebframework.web - hsweb-system-oauth2-client-web - ${project.version} - - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/java/org/hswebframework/web/service/oauth2/client/starter/OAuth2ClientAutoConfiguration.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/java/org/hswebframework/web/service/oauth2/client/starter/OAuth2ClientAutoConfiguration.java deleted file mode 100644 index e2aadd81c..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/java/org/hswebframework/web/service/oauth2/client/starter/OAuth2ClientAutoConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2019 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.oauth2.client.starter; - -import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestBuilderFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -@ConditionalOnMissingBean(OAuth2RequestBuilderFactory.class) -@ComponentScan({"org.hswebframework.web.service.oauth2.client.simple" - , "org.hswebframework.web.authorization.oauth2.controller"}) -public class OAuth2ClientAutoConfiguration { - -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 5e38e310b..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.service.oauth2.client.starter.OAuth2ClientAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index ad55d5081..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 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. - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-oauth2-client", - author: "zh.sqy@qq.com", - comment: "OAuth2服务配置" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.0", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_oauth2_server") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().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(128).commit() - .addColumn().name("api_base_url").alias("apiBaseUrl").comment("api根地址").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("auth_url").alias("authUrl").comment("认证地址").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("redirect_uri").alias("redirectUri").comment("重定向地址").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("access_token_url").alias("accessTokenUrl").comment("token获取地址").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("client_id").alias("clientId").comment("客户端id").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("client_secret").alias("clientSecret").comment("客户端密钥").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("provider").alias("provider").comment("服务提供商").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .comment("OAuth2 服务配置").commit(); - - database.createOrAlter("s_oauth2_user_token") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("client_user_id").alias("clientUserId").comment("客户端用户id").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("server_user_id").alias("serverUserId").comment("服务端用户id").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("server_id").alias("serverId").comment("服务端id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("client_id").alias("clientId").comment("客户端id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("access_token").alias("accessToken").comment("授权码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("refresh_token").alias("refreshToken").comment("更新码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("expires_in").alias("expireIn").comment("有效期").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("scope").alias("scope").comment("授权范围").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("update_time").alias("updateTime").comment("更新时间").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("grant_type").alias("grant_type").comment("授权方式").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .index().name("idx_oauth_cli_c_user_id").column("client_user_id").commit() - .index().name("idx_oauth_cli_s_user_id").column("server_user_id").commit() - .index().name("idx_oauth_cli_access_token").column("access_token").commit() - .index().name("idx_oauth_cli_refresh_token").column("refresh_token").commit() - - .comment("OAuth2用户授权信息").commit(); -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/OAuth2ServerConfigTests.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/OAuth2ServerConfigTests.java deleted file mode 100644 index 83038e72a..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/OAuth2ServerConfigTests.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2019 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.starter.oauth2.client; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestService; -import org.hswebframework.web.entity.oauth2.client.OAuth2ServerConfigEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class OAuth2ServerConfigTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - - @Autowired - private OAuth2RequestService oAuth2RequestService; - -// @Test -// public void testOAuth2() throws Exception { -// OAuth2ServerConfigEntity entity = entityFactory.newInstance(OAuth2ServerConfigEntity.class); -// //https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=123&redirect_uri=www.baidu.com -// entity.setId("my_qq_test"); -// entity.setName("QQ OAuth2"); -// entity.setApiBaseUrl("https://graph.qq.com/oauth2.0/"); -// entity.setAuthUrl("authorize"); -// entity.setAccessTokenUrl("token"); -// entity.setClientId("911ab25b8a87684beba8f394f47d3de9"); -// entity.setClientSecret("2cce659031d5e1495e102be0de9e9cb0"); -// entity.setRedirectUri("http://demo.hsweb.me"); -// entity.setProvider("QQ"); -// entity.setEnabled(true); -// //add -// String requestBody = JSON.toJSONString(entity); -// JSONObject result = testPost("/oauth2-server-config") -// .setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON) -// .content(requestBody)).exec().resultAsJson(); -// Assert.assertEquals(200, result.get("status")); -// -// try { -// Map meInfo = oAuth2RequestService.create("my_qq_test") -// .byAuthorizationCode("D8C3B5E8B55E4AAAC8EA1FB8DC0AFCEC") -// .request("me").get().as(Map.class); -// System.out.println(meInfo); -// } catch (OAuth2RequestException e) { -// System.out.println(e.getErrorType() + ":" + e.getResponse().as(Map.class)); -// } -// } - - @Test - public void testCrud() throws Exception { - OAuth2ServerConfigEntity entity = entityFactory.newInstance(OAuth2ServerConfigEntity.class); - //todo 设置测试属性 - entity.setName("test"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/oauth2-server-config").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/oauth2-server-config/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(OAuth2ServerConfigEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(OAuth2ServerConfigEntity.class)))); - //todo 修改测试属性 - OAuth2ServerConfigEntity newEntity = entityFactory.newInstance(OAuth2ServerConfigEntity.class); - newEntity.setName("test2"); - - result = testPut("/oauth2-server-config/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/oauth2-server-config/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/oauth2-server-config/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/oauth2-server-config/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseConvertSupport.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseConvertSupport.java deleted file mode 100644 index ce1d5bfcb..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseConvertSupport.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 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.starter.oauth2.client; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.authorization.oauth2.client.request.definition.ResponseConvertForProviderDefinition; -import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@Component -public class QQResponseConvertSupport implements ResponseConvertForProviderDefinition { - @Override - public T convert(OAuth2Response response, Class type) { - String json = response.asString(); - if (json.contains("callback(")) { - json = json.trim().substring("callback(".length(), json.length() - 3); - } - return JSON.parseObject(json, type); - } - - @Override - public List convertList(OAuth2Response response, Class type) { - String json = response.asString(); - if (json.contains("callback(")) { - json = json.trim().substring("callback(".length(), json.length() - 3); - } - return JSON.parseArray(json, type); - } - - @Override - public String getProvider() { - return "QQ"; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseJudgeSupport.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseJudgeSupport.java deleted file mode 100644 index b7ce24d96..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/java/org/hswebframework/web/starter/oauth2/client/QQResponseJudgeSupport.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 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.starter.oauth2.client; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.authorization.oauth2.client.request.definition.ResponseJudgeForProviderDefinition; -import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response; -import org.hswebframework.web.oauth2.core.ErrorType; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@Component -public class QQResponseJudgeSupport implements ResponseJudgeForProviderDefinition { - static Map errorTypeMap = new HashMap<>(); - - static { - /* - http://wiki.connect.qq.com/%E5%85%AC%E5%85%B1%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E - */ - // success - errorTypeMap.put("0", null); - - errorTypeMap.put("100000", ErrorType.ILLEGAL_RESPONSE_TYPE); - errorTypeMap.put("100001", ErrorType.ILLEGAL_CLIENT_ID); - // missing - errorTypeMap.put("100002", ErrorType.ILLEGAL_CLIENT_SECRET); - errorTypeMap.put("100003", ErrorType.ILLEGAL_AUTHORIZATION); - errorTypeMap.put("100004", ErrorType.ILLEGAL_GRANT_TYPE); - errorTypeMap.put("100005", ErrorType.ILLEGAL_CODE); - errorTypeMap.put("100006", ErrorType.ILLEGAL_REFRESH_TOKEN); - errorTypeMap.put("100007", ErrorType.ILLEGAL_ACCESS_TOKEN); - //param error - errorTypeMap.put("100009", ErrorType.ILLEGAL_CLIENT_SECRET); - errorTypeMap.put("100010", ErrorType.ILLEGAL_REDIRECT_URI); - errorTypeMap.put("100013", ErrorType.ILLEGAL_ACCESS_TOKEN); - errorTypeMap.put("100014", ErrorType.EXPIRED_TOKEN); - errorTypeMap.put("100015", ErrorType.INVALID_TOKEN); - - errorTypeMap.put("100016", ErrorType.ILLEGAL_ACCESS_TOKEN); - - errorTypeMap.put("100019", ErrorType.ILLEGAL_CODE); - - } - - @Override - public String getProvider() { - return "QQ"; - } - - @Override - public ErrorType judge(OAuth2Response response) { - String result = response.asString(); - if (result == null) return ErrorType.OTHER; - if (result.contains("callback(")) { - result = result.substring("callback(".length(), result.length() - 3); - } - JSONObject jsonRes = JSON.parseObject(result); - String error = jsonRes.getString("error"); - if (error != null) { - return errorTypeMap.get(error); - } - return null; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/resources/application.yml deleted file mode 100644 index 47db2ebe4..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-starter/src/test/resources/application.yml +++ /dev/null @@ -1,13 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:oauth2.client_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: OAuth2服务配置测试 - version: 3.0.0 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/pom.xml b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/pom.xml deleted file mode 100644 index 21e4a48d3..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - hsweb-system-oauth2-client - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-oauth2-client-web - - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - org.hswebframework.web - hsweb-system-oauth2-client-api - ${project.version} - - - org.hswebframework.web - hsweb-authorization-oauth2-client - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientController.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientController.java deleted file mode 100644 index 579f36eaf..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientController.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.WebUtil; -import org.hswebframework.web.authorization.oauth2.client.OAuth2RequestService; -import org.hswebframework.web.authorization.oauth2.client.listener.OAuth2CodeAuthBeforeEvent; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.oauth2.client.OAuth2ServerConfigEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.oauth2.core.ErrorType; -import org.hswebframework.web.oauth2.core.OAuth2Constants; -import org.hswebframework.web.service.oauth2.client.OAuth2ServerConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.view.RedirectView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; - -/** - * @author zhouhao - */ -@Controller -@RequestMapping("${hsweb.web.mappings.oauth2-client-callback:oauth2}") -@Api(tags = "OAuth2.0-客户端-请求服务", value = "OAuth2.0客户端请求服务") -public class OAuth2ClientController { - - private OAuth2RequestService oAuth2RequestService; - - private OAuth2ServerConfigService oAuth2ServerConfigService; - - @Autowired - public void setoAuth2ServerConfigService(OAuth2ServerConfigService oAuth2ServerConfigService) { - this.oAuth2ServerConfigService = oAuth2ServerConfigService; - } - - @Autowired - public void setoAuth2RequestService(OAuth2RequestService oAuth2RequestService) { - this.oAuth2RequestService = oAuth2RequestService; - } - - private static final String STATE_SESSION_KEY = "OAUTH2_STATE"; - - @GetMapping("/state") - @ResponseBody - @ApiOperation("申请一个state") - public ResponseMessage requestState(HttpSession session) { - String state = IDGenerator.RANDOM.generate(); - session.setAttribute(STATE_SESSION_KEY, state); - return ResponseMessage.ok(state); - } - - @GetMapping("/boot/{serverId}") - @ApiOperation("跳转至OAuth2.0服务授权页面") - public RedirectView boot(@PathVariable String serverId, - @RequestParam(defaultValue = "/") String redirect, - HttpServletRequest request, - HttpSession session) throws UnsupportedEncodingException { - OAuth2ServerConfigEntity entity = oAuth2ServerConfigService.selectByPk(serverId); - if (entity == null) { - return new RedirectView("/401.html"); - } - String callback = WebUtil.getBasePath(request) - .concat("oauth2/callback/") - .concat(serverId).concat("/?redirect=") - .concat(URLEncoder.encode(redirect, "UTF-8")); - RedirectView view = new RedirectView(entity.getRealUrl(entity.getAuthUrl())); - view.addStaticAttribute(OAuth2Constants.response_type, "code"); - view.addStaticAttribute(OAuth2Constants.state, requestState(session).getResult()); - view.addStaticAttribute(OAuth2Constants.client_id, entity.getClientId()); - view.addStaticAttribute(OAuth2Constants.redirect_uri, callback); - return view; - } - - @GetMapping("/callback/{serverId}") - @ApiOperation(value = "OAuth2.0授权完成后回调", hidden = true) - public RedirectView callback(@RequestParam(defaultValue = "/") String redirect, - @PathVariable String serverId, - @RequestParam String code, - @RequestParam String state, - HttpServletRequest request, - HttpSession session) throws UnsupportedEncodingException { - try { - String cachedState = (String) session.getAttribute(STATE_SESSION_KEY); - if (!state.equals(cachedState)) { - throw new BusinessException(ErrorType.STATE_ERROR.name()); - } - oAuth2RequestService.doEvent(serverId, new OAuth2CodeAuthBeforeEvent(code, state, request::getParameter)); - return new RedirectView(URLDecoder.decode(redirect, "UTF-8")); - } finally { - session.removeAttribute(STATE_SESSION_KEY); - } - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java deleted file mode 100644 index 55de6d346..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ServerConfigController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.Api; -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.oauth2.client.OAuth2ServerConfigEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.oauth2.client.OAuth2ServerConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * OAuth2服务配置 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.oauth2-server-config:oauth2-server-config}") -@Authorize(permission = "oauth2-server-config",description = "OAuth2.0-客户端-服务配置") -@Api(tags = "OAuth2.0-客户端-服务配置",value = "OAuth2.0-客户端-服务配置") -public class OAuth2ServerConfigController implements GenericEntityController { - - private OAuth2ServerConfigService oAuth2ServerConfigService; - - @Override - public OAuth2ServerConfigEntity modelToEntity(OAuth2ServerConfigEntity model, OAuth2ServerConfigEntity entity) { - return model; - } - - @Autowired - public void setOAuth2ServerConfigService(OAuth2ServerConfigService oAuth2ServerConfigService) { - this.oAuth2ServerConfigService = oAuth2ServerConfigService; - } - - @Override - public OAuth2ServerConfigService getService() { - return oAuth2ServerConfigService; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java b/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java deleted file mode 100644 index 02e9cd374..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/hsweb-system-oauth2-client-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserTokenController.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.Api; -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.controller.QueryController; -import org.hswebframework.web.entity.oauth2.client.OAuth2UserTokenEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.oauth2.client.OAuth2UserTokenService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * OAuth2用户授权信息 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.oauth2-user-token:oauth2-user-token}") -@Authorize(permission = "oauth2-user-token",description = "OAuth2.0-客户端-token管理") -@Api(tags = "OAuth2.0-客户端-token",value = "OAuth2.0-客户端-token") -public class OAuth2UserTokenController - implements QueryController { - - private OAuth2UserTokenService oAuth2UserTokenService; - - @Autowired - public void setOAuth2UserTokenService(OAuth2UserTokenService oAuth2UserTokenService) { - this.oAuth2UserTokenService = oAuth2UserTokenService; - } - - @Override - public OAuth2UserTokenService getService() { - return oAuth2UserTokenService; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-client/pom.xml b/hsweb-system/hsweb-system-oauth2-client/pom.xml deleted file mode 100644 index e869ff210..000000000 --- a/hsweb-system/hsweb-system-oauth2-client/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-oauth2-client - pom - - hsweb-system-oauth2-client-starter - hsweb-system-oauth2-client-api - hsweb-system-oauth2-client-local - hsweb-system-oauth2-client-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/pom.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/pom.xml deleted file mode 100644 index ab5fc3681..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - hsweb-system-oauth2-server - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-oauth2-server-local - - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - - - - - - org.springframework.boot - spring-boot-starter - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - org.hswebframework.web - hsweb-authorization-oauth2-auth-server - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/AuthorizationCodeDao.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/AuthorizationCodeDao.java deleted file mode 100644 index 038bce6fe..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/AuthorizationCodeDao.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import org.hswebframework.web.entity.oauth2.server.AuthorizationCodeEntity; -import org.hswebframework.web.dao.InsertDao; -import org.hswebframework.web.dao.dynamic.DeleteByEntityDao; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; - -/** - * @author zhouhao - */ -public interface AuthorizationCodeDao extends - InsertDao, - DeleteByEntityDao, - QueryByEntityDao { - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2AccessDao.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2AccessDao.java deleted file mode 100644 index 18a0841ce..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2AccessDao.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import org.hswebframework.web.entity.oauth2.server.OAuth2AccessEntity; -import org.hswebframework.web.dao.InsertDao; -import org.hswebframework.web.dao.dynamic.DeleteByEntityDao; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; -import org.hswebframework.web.dao.dynamic.UpdateByEntityDao; - -/** - * @author zhouhao - */ -public interface OAuth2AccessDao extends - InsertDao, - DeleteByEntityDao, - UpdateByEntityDao, - QueryByEntityDao { -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2ClientDao.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2ClientDao.java deleted file mode 100644 index 2c124ef07..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/dao/oauth2/server/OAuth2ClientDao.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - - -import org.hswebframework.web.entity.oauth2.server.OAuth2ClientEntity; -import org.hswebframework.web.dao.CrudDao; - -/** - * - * @author zhouhao - */ -public interface OAuth2ClientDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/AuthorizationCodeEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/AuthorizationCodeEntity.java deleted file mode 100644 index 1e83f3d61..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/AuthorizationCodeEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCode; -import org.hswebframework.web.commons.entity.Entity; - -/** - * 授权码 - * @author zhouhao - */ -public interface AuthorizationCodeEntity extends AuthorizationCode, Entity { -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2AccessEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2AccessEntity.java deleted file mode 100644 index ca1420d16..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2AccessEntity.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.commons.entity.Entity; - -/** - * @author zhouhao - */ -public interface OAuth2AccessEntity extends OAuth2AccessToken, Entity { -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2ClientEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2ClientEntity.java deleted file mode 100644 index ac60fe6ea..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/OAuth2ClientEntity.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2Client; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; - -import java.util.Set; - -/** - * @author zhouhao - */ -public interface OAuth2ClientEntity extends GenericEntity, OAuth2Client, RecordCreationEntity { - - // client_id - @Override - String getId(); - - @Override - String getName(); - - void setName(String name); - - // client_secret - @Override - String getSecret(); - - void setSecret(String secret); - - //redirect_uri - @Override - String getRedirectUri(); - - void setRedirectUri(String redirectUri); - - /** - * @return 客户端所有者 - * @see org.hswebframework.web.authorization.User#getId() - */ - @Override - String getOwnerId(); - - void setOwnerId(String ownerId); - - String getDescribe(); - - void setDescribe(String describe); - - String getType(); - - void setType(String type); - - @Override - Set getSupportGrantTypes(); - - @Override - Set getDefaultGrantScope(); - - void setDefaultGrantScope(Set defaultGrantScope); - - void setSupportGrantTypes(Set supportGrantType); - - void setStatus(Byte status); -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleAuthorizationCodeEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleAuthorizationCodeEntity.java deleted file mode 100644 index 6e0b4b558..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleAuthorizationCodeEntity.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - - -import java.util.Set; - -/** - * @author zhouhao - */ -public class SimpleAuthorizationCodeEntity implements AuthorizationCodeEntity { - private String clientId; - - private String userId; - - private String code; - - private Long createTime; - - private Set scope; - - private String redirectUri; - - @Override - public String getRedirectUri() { - return redirectUri; - } - - @Override - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - @Override - public Set getScope() { - return scope; - } - - @Override - public void setScope(Set scope) { - this.scope = scope; - } - - @Override - public String getClientId() { - return clientId; - } - - @Override - public void setClientId(String clientId) { - this.clientId = clientId; - } - - @Override - public String getUserId() { - return userId; - } - - @Override - public void setUserId(String userId) { - this.userId = userId; - } - - @Override - public String getCode() { - return code; - } - - @Override - public void setCode(String code) { - this.code = code; - } - - @Override - public Long getCreateTime() { - return createTime; - } - - @Override - public void setCreateTime(Long createTime) { - this.createTime = createTime; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2AccessEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2AccessEntity.java deleted file mode 100644 index 917133080..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2AccessEntity.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import lombok.Getter; -import lombok.Setter; - -import java.util.Set; - -/** - * - * @author zhouhao - */ -@Getter -@Setter -public class SimpleOAuth2AccessEntity implements OAuth2AccessEntity { - - private static final long serialVersionUID = 2090466474249489203L; - private String clientId; - - private String ownerId; - - private String accessToken; - - private String refreshToken; - - private Integer expiresIn; - - private Long createTime; - - private Long updateTime; - - private Set scope; - - private String grantType; - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2ClientEntity.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2ClientEntity.java deleted file mode 100644 index 02306f457..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/entity/oauth2/server/SimpleOAuth2ClientEntity.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server; - -import lombok.*; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import java.util.Set; - -/** - * @author zhouhao - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class SimpleOAuth2ClientEntity extends SimpleGenericEntity implements OAuth2ClientEntity { - private static final long serialVersionUID = -8370400980996896599L; - private String name; - - private String secret; - - private String redirectUri; - - private String ownerId; - - private String creatorId; - - private Long createTime; - - private String type; - - private String describe; - - private Set supportGrantTypes; - - private Set defaultGrantScope; - - private Byte status; - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/CodeGenerator.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/CodeGenerator.java deleted file mode 100644 index 93d5257e4..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/CodeGenerator.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface CodeGenerator { - String generate(); -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAccessTokenService.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAccessTokenService.java deleted file mode 100644 index 9abdb0098..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAccessTokenService.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - - -import org.hswebframework.web.entity.oauth2.server.OAuth2AccessEntity; -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.authorization.oauth2.server.token.AccessTokenService; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.dao.oauth2.server.OAuth2AccessDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.DefaultDSLUpdateService; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; - -/** - * @author zhouhao - */ -public class SimpleAccessTokenService implements AccessTokenService { - - private TokenGenerator tokenGenerator = IDGenerator.MD5::generate; - - private OAuth2AccessDao oAuth2AccessDao; - - private EntityFactory entityFactory; - - public SimpleAccessTokenService(OAuth2AccessDao oAuth2AccessDao, EntityFactory entityFactory) { - this.oAuth2AccessDao = oAuth2AccessDao; - this.entityFactory = entityFactory; - } - - public SimpleAccessTokenService setTokenGenerator(TokenGenerator tokenGenerator) { - if (tokenGenerator != null) { - this.tokenGenerator = tokenGenerator; - } - return this; - } - - @Override - @Cacheable(cacheNames = "oauth2-access-token", key = "'cgo'+#token.clientId+#token.grantType+#token.ownerId") - public OAuth2AccessToken tryGetOldToken(OAuth2AccessToken token) { - OAuth2AccessToken old = DefaultDSLQueryService - .createQuery(oAuth2AccessDao) - .where("clientId", token.getClientId()) - .and("grantType", token.getGrantType()) - .and("ownerId", token.getOwnerId()) - .single(); - return old; - } - - @Override - public OAuth2AccessToken createToken() { - OAuth2AccessEntity accessEntity = entityFactory.newInstance(OAuth2AccessEntity.class); - accessEntity.setAccessToken(tokenGenerator.generate()); - accessEntity.setRefreshToken(tokenGenerator.generate()); - accessEntity.setCreateTime(System.currentTimeMillis()); - return accessEntity; - } - - @Override - @Transactional(propagation = Propagation.NOT_SUPPORTED) - @Cacheable(cacheNames = "oauth2-access-token", key = "'refresh:'+#refreshToken") - public OAuth2AccessToken getTokenByRefreshToken(String refreshToken) { - Assert.notNull(refreshToken, "refreshToken can not be null!"); - return DefaultDSLQueryService.createQuery(oAuth2AccessDao) - .where("refreshToken", refreshToken).single(); - } - - @Override - @Transactional(propagation = Propagation.NOT_SUPPORTED) - @Cacheable(cacheNames = "oauth2-access-token", key = "'token:'+#accessToken") - public OAuth2AccessToken getTokenByAccessToken(String accessToken) { - Assert.notNull(accessToken, "accessToken can not be null!"); - return DefaultDSLQueryService.createQuery(oAuth2AccessDao) - .where("accessToken", accessToken).single(); - } - - @Override - @Transactional(propagation = Propagation.NOT_SUPPORTED) - @Caching(put = { - @CachePut(cacheNames = "oauth2-access-token", key = "'refresh:'+#result.refreshToken"), - @CachePut(cacheNames = "oauth2-access-token", key = "'token:'+#result.accessToken"), - @CachePut(cacheNames = "oauth2-access-token", key = "'cgo'+#result.clientId+#result.grantType+#result.ownerId") - }) - public OAuth2AccessToken saveOrUpdateToken(OAuth2AccessToken token) { - Assert.notNull(token, "token can not be null!"); - int total = DefaultDSLQueryService - .createQuery(oAuth2AccessDao) - .where("clientId", token.getClientId()) - .and("grantType", token.getGrantType()) - .and("ownerId", token.getOwnerId()).total(); - token.setUpdateTime(System.currentTimeMillis()); - if (total > 0) { - DefaultDSLUpdateService - .createUpdate(oAuth2AccessDao, token) - .where("clientId", token.getClientId()) - .and("grantType", token.getGrantType()) - .and("ownerId", token.getOwnerId()) - .exec(); - } else { - token.setCreateTime(System.currentTimeMillis()); - oAuth2AccessDao.insert(((OAuth2AccessEntity) token)); - } - - return token; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAuthorizationCodeService.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAuthorizationCodeService.java deleted file mode 100644 index 7b9f4b4af..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleAuthorizationCodeService.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - -import org.hswebframework.web.entity.oauth2.server.AuthorizationCodeEntity; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCode; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeRequest; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeService; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.dao.oauth2.server.AuthorizationCodeDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLDeleteService; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class SimpleAuthorizationCodeService implements AuthorizationCodeService { - private AuthorizationCodeDao authorizationCodeDao; - private EntityFactory entityFactory; - private CodeGenerator codeGenerator = IDGenerator.MD5::generate; - - public SimpleAuthorizationCodeService(AuthorizationCodeDao authorizationCodeDao, EntityFactory entityFactory) { - this.authorizationCodeDao = authorizationCodeDao; - this.entityFactory = entityFactory; - } - - public SimpleAuthorizationCodeService setCodeGenerator(CodeGenerator codeGenerator) { - if (codeGenerator != null) { - this.codeGenerator = codeGenerator; - } - return this; - } - - @Override - public String createAuthorizationCode(AuthorizationCodeRequest request) { - AuthorizationCodeEntity codeEntity = entityFactory.newInstance(AuthorizationCodeEntity.class); - codeEntity.setClientId(request.getClientId()); - codeEntity.setRedirectUri(request.getRedirectUri()); - codeEntity.setCreateTime(System.currentTimeMillis()); - codeEntity.setUserId(request.getUserId()); - codeEntity.setScope(request.getScope()); - codeEntity.setCode(codeGenerator.generate()); - authorizationCodeDao.insert(codeEntity); - return codeEntity.getCode(); - } - - @Override - @Transactional(propagation = Propagation.NOT_SUPPORTED) - public AuthorizationCode consumeAuthorizationCode(String code) { - AuthorizationCodeEntity codeEntity = DefaultDSLQueryService - .createQuery(authorizationCodeDao) - .where("code", code).single(); - //delete - DefaultDSLDeleteService.createDelete(authorizationCodeDao) - .where("code", code).exec(); - return codeEntity; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleClientConfigRepository.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleClientConfigRepository.java deleted file mode 100644 index 6391e55a1..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimpleClientConfigRepository.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2Client; -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2ClientConfigRepository; -import org.hswebframework.web.entity.oauth2.server.SimpleOAuth2ClientEntity; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.oauth2.server.OAuth2ClientDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.DefaultDSLUpdateService; -import org.springframework.cache.annotation.*; - -import java.util.List; - -/** - * @author zhouhao - */ -@CacheConfig(cacheNames = "oauth2-client-config") -public class SimpleClientConfigRepository implements OAuth2ClientConfigRepository { - private OAuth2ClientDao oAuth2ClientDao; - - public SimpleClientConfigRepository(OAuth2ClientDao oAuth2ClientDao) { - this.oAuth2ClientDao = oAuth2ClientDao; - } - - @Override - @Cacheable(key = "'id:'+#id") - public OAuth2Client getClientById(String id) { - return DefaultDSLQueryService.createQuery(oAuth2ClientDao).where("id", id).single(); - } - - @Override - @Cacheable(key = "'ownerId:'+#ownerId") - public OAuth2Client getClientByOwnerId(String ownerId) { - return DefaultDSLQueryService.createQuery(oAuth2ClientDao).where("ownerId", ownerId).single(); - } - - @Override - @Caching(put = { - @CachePut(key = "'ownerId:'+#result.ownerId"), - @CachePut(key = "'id:'+#result.id") - }) - public OAuth2Client save(OAuth2Client oAuth2Client) { - OAuth2Client old = getClientById(oAuth2Client.getId()); - if (old != null) { - DefaultDSLUpdateService - .createUpdate(oAuth2ClientDao, oAuth2Client) - .excludes("id", "createTime") - .where("id", oAuth2Client.getId()).exec(); - } else { - oAuth2ClientDao.insert(((SimpleOAuth2ClientEntity) oAuth2Client)); - } - return oAuth2Client; - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'ownerId:'+#result.ownerId", condition = "#result!=null"), - @CacheEvict(key = "'id:'+#result.id", condition = "#result!=null") - }) - public OAuth2Client remove(String id) { - OAuth2Client old = getClientById(id); - oAuth2ClientDao.deleteByPk(id); - return old; - } - - @Override - public OAuth2Client newClient() { - SimpleOAuth2ClientEntity clientEntity = SimpleOAuth2ClientEntity.builder() - .build(); - clientEntity.setId(IDGenerator.MD5.generate()); - clientEntity.setSecret(IDGenerator.MD5.generate()); - clientEntity.setStatus(DataStatus.STATUS_ENABLED); - clientEntity.setCreateTimeNow(); - return clientEntity; - } - - @Override - @SuppressWarnings("unchecked") - public List getAll() { - QueryParamEntity entity = new QueryParamEntity(); - entity.setPaging(false); - return (List) oAuth2ClientDao.query(entity); - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimplePasswordService.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimplePasswordService.java deleted file mode 100644 index 6749e5163..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/SimplePasswordService.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationManager; -import org.hswebframework.web.authorization.oauth2.server.support.password.PasswordService; -import org.hswebframework.web.authorization.simple.PlainTextUsernamePasswordAuthenticationRequest; -import org.hswebframework.web.validate.ValidationException; - -/** - * @author zhouhao - */ -public class SimplePasswordService implements PasswordService { - private AuthenticationManager authenticationManager; - - public SimplePasswordService(AuthenticationManager authenticationManager) { - this.authenticationManager = authenticationManager; - } - - @Override - public String getUserIdByUsernameAndPassword(String username, String password) { - try { - Authentication authenticate = authenticationManager.authenticate(new PlainTextUsernamePasswordAuthenticationRequest(username, password)); - if (null != authenticate) { - return authenticate.getUser().getId(); - } - } catch (ValidationException | UnsupportedOperationException | IllegalArgumentException e) { - return null; - } - return null; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/TokenGenerator.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/TokenGenerator.java deleted file mode 100644 index b255f630c..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/java/org/hswebframework/web/service/oauth2/server/simple/TokenGenerator.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019 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.oauth2.server.simple; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface TokenGenerator { - String generate(); -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2AccessMapper.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2AccessMapper.xml deleted file mode 100644 index 57cadc98c..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2AccessMapper.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2ClientMapper.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2ClientMapper.xml deleted file mode 100644 index 9dadef3c8..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2ClientMapper.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2CodeMapper.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2CodeMapper.xml deleted file mode 100644 index 669b69a33..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/oauth2/OAuth2CodeMapper.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/pom.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/pom.xml deleted file mode 100644 index 6d48e7f0b..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - hsweb-system-oauth2-server - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-oauth2-server-starter - - - - - src/main/resources - true - - - - - - org.hswebframework.web - hsweb-system-oauth2-server-local - ${project.version} - - - org.hswebframework.web - hsweb-system-oauth2-server-web - ${project.version} - - - javax.servlet - javax.servlet-api - provided - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - org.hswebframework.web - hsweb-authorization-basic - ${project.version} - true - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GrantEventListener.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GrantEventListener.java deleted file mode 100644 index 362c727cb..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GrantEventListener.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.oauth2; - -import lombok.AllArgsConstructor; -import org.hswebframework.web.authorization.oauth2.server.event.OAuth2GrantEvent; -import org.hswebframework.web.authorization.token.UserTokenManager; -import org.springframework.context.event.EventListener; - -/** - * @author zhouhao - * @since 1.0 - */ -@AllArgsConstructor -public class OAuth2GrantEventListener { - - private UserTokenManager userTokenManager; - - @EventListener - public void handleOAuth2GrantEvent(OAuth2GrantEvent event) { - userTokenManager.signIn( - event.getAccessToken().getAccessToken(), - "oauth2-access-token", - event.getAccessToken().getOwnerId(), - event.getAccessToken().getExpiresIn() * 1000L); - - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GranterAutoConfiguration.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GranterAutoConfiguration.java deleted file mode 100644 index cb3219685..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/OAuth2GranterAutoConfiguration.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2019 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.oauth2; - -import org.hswebframework.web.authorization.AuthenticationManager; -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2ClientConfigRepository; -import org.hswebframework.web.authorization.oauth2.server.support.AbstractAuthorizationService; -import org.hswebframework.web.authorization.oauth2.server.support.DefaultOAuth2Granter; -import org.hswebframework.web.authorization.oauth2.server.support.client.ClientCredentialGranter; -import org.hswebframework.web.authorization.oauth2.server.support.client.DefaultClientCredentialGranter; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeGranter; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeService; -import org.hswebframework.web.authorization.oauth2.server.support.code.DefaultAuthorizationCodeGranter; -import org.hswebframework.web.authorization.oauth2.server.support.implicit.DefaultImplicitGranter; -import org.hswebframework.web.authorization.oauth2.server.support.implicit.ImplicitGranter; -import org.hswebframework.web.authorization.oauth2.server.support.password.DefaultPasswordGranter; -import org.hswebframework.web.authorization.oauth2.server.support.password.PasswordGranter; -import org.hswebframework.web.authorization.oauth2.server.support.password.PasswordService; -import org.hswebframework.web.authorization.oauth2.server.support.refresh.DefaultRefreshTokenGranter; -import org.hswebframework.web.authorization.oauth2.server.support.refresh.RefreshTokenGranter; -import org.hswebframework.web.authorization.oauth2.server.token.AccessTokenService; -import org.hswebframework.web.authorization.token.UserTokenManager; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.dao.oauth2.server.AuthorizationCodeDao; -import org.hswebframework.web.dao.oauth2.server.OAuth2AccessDao; -import org.hswebframework.web.dao.oauth2.server.OAuth2ClientDao; -import org.hswebframework.web.service.oauth2.server.simple.*; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.oauth2.server.simple" - , "org.hswebframework.web.authorization.oauth2.controller"}) -public class OAuth2GranterAutoConfiguration { - - @Autowired(required = false) - private CodeGenerator codeGenerator; - - @Autowired(required = false) - private TokenGenerator tokenGenerator; - - @ConditionalOnMissingBean(AuthorizationCodeService.class) - @Bean - public SimpleAuthorizationCodeService simpleAuthorizationCodeService(AuthorizationCodeDao authorizationCodeDao, - EntityFactory entityFactory) { - return new SimpleAuthorizationCodeService(authorizationCodeDao, entityFactory) - .setCodeGenerator(codeGenerator); - } - - @ConditionalOnMissingBean(OAuth2ClientConfigRepository.class) - @Bean - public SimpleClientConfigRepository simpleClientService(OAuth2ClientDao oAuth2ClientDao) { - return new SimpleClientConfigRepository(oAuth2ClientDao); - } - - @ConditionalOnMissingBean(PasswordService.class) - @Bean - public SimplePasswordService simplePasswordService(AuthenticationManager userService) { - return new SimplePasswordService(userService); - } - - @ConditionalOnMissingBean(AccessTokenService.class) - @Bean - public SimpleAccessTokenService simpleAccessTokenService(OAuth2AccessDao oAuth2AccessDao, EntityFactory entityFactory) { - return new SimpleAccessTokenService(oAuth2AccessDao, entityFactory) - .setTokenGenerator(tokenGenerator); - } - - @Bean - @ConditionalOnBean(UserTokenManager.class) - public OAuth2GrantEventListener oAuth2GrantEventListener(UserTokenManager userTokenManager) { - return new OAuth2GrantEventListener(userTokenManager); - } - - @Configuration - public static class OAuth2GranterConfiguration { - @Autowired - private AuthorizationCodeService authorizationCodeService; - @Autowired - private OAuth2ClientConfigRepository oAuth2ClientConfigRepository; - @Autowired - private AccessTokenService accessTokenService; - @Autowired - private PasswordService passwordService; - - private T setProperty(T abstractAuthorizationService) { - abstractAuthorizationService.setAccessTokenService(accessTokenService); - abstractAuthorizationService.setRepository(oAuth2ClientConfigRepository); - return abstractAuthorizationService; - } - - @Bean - @ConditionalOnMissingBean(AuthorizationCodeGranter.class) - public AuthorizationCodeGranter authorizationCodeGranter() { - return setProperty(new DefaultAuthorizationCodeGranter(authorizationCodeService)); - } - - @Bean - @ConditionalOnMissingBean(ClientCredentialGranter.class) - public ClientCredentialGranter clientCredentialGranter() { - return setProperty(new DefaultClientCredentialGranter()); - } - - @Bean - @ConditionalOnMissingBean(PasswordGranter.class) - public PasswordGranter passwordGranter() { - return setProperty(new DefaultPasswordGranter(passwordService)); - } - - @Bean - @ConditionalOnMissingBean(ImplicitGranter.class) - public ImplicitGranter implicitGranter() { - return setProperty(new DefaultImplicitGranter()); - } - - @Bean - @ConditionalOnMissingBean(RefreshTokenGranter.class) - @ConfigurationProperties(prefix = "hsweb.oauth2.server") - public RefreshTokenGranter refreshTokenGranter() { - return setProperty(new DefaultRefreshTokenGranter()); - } - } - - @Bean - public AutoSettingOAuth2Granter autoSettingOAuth2Granter() { - return new AutoSettingOAuth2Granter(); - } - - class AutoSettingOAuth2Granter extends DefaultOAuth2Granter implements BeanPostProcessor { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof AuthorizationCodeGranter) { - addAuthorizationCodeSupport(((AuthorizationCodeGranter) bean)); - } - if (bean instanceof ClientCredentialGranter) { - addClientCredentialSupport(((ClientCredentialGranter) bean)); - } - if (bean instanceof PasswordGranter) { - addPasswordSupport(((PasswordGranter) bean)); - } - if (bean instanceof ImplicitGranter) { - addImplicitSupport(((ImplicitGranter) bean)); - } - if (bean instanceof RefreshTokenGranter) { - addRefreshTokenSupport(((RefreshTokenGranter) bean)); - } - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - return bean; - } - } - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/authorization/OAuth2UserTokenParser.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/authorization/OAuth2UserTokenParser.java deleted file mode 100644 index 49cd87a93..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/java/org/hswebframework/web/oauth2/authorization/OAuth2UserTokenParser.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.hswebframework.web.oauth2.authorization; - -import org.hswebframework.web.authorization.basic.web.AuthorizedToken; -import org.hswebframework.web.authorization.basic.web.ParsedToken; -import org.hswebframework.web.authorization.basic.web.UserTokenParser; -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.authorization.oauth2.server.exception.GrantTokenException; -import org.hswebframework.web.authorization.oauth2.server.token.AccessTokenService; -import org.hswebframework.web.oauth2.core.ErrorType; -import org.hswebframework.web.oauth2.core.OAuth2Constants; -import org.springframework.util.StringUtils; - -import javax.servlet.http.HttpServletRequest; - -public class OAuth2UserTokenParser implements UserTokenParser { - - public static final String token_type = "oauth2-access-token"; - - private AccessTokenService accessTokenService; - - public OAuth2UserTokenParser(AccessTokenService accessTokenService) { - this.accessTokenService = accessTokenService; - } - - public void setAccessTokenService(AccessTokenService accessTokenService) { - this.accessTokenService = accessTokenService; - } - - @Override - public ParsedToken parseToken(HttpServletRequest request) { - if (request.getRequestURI().contains("oauth2") && request.getParameter(OAuth2Constants.grant_type) != null) { - return null; - } - String accessToken = request.getHeader(OAuth2Constants.authorization); - if (StringUtils.isEmpty(accessToken)) { - accessToken = request.getParameter(OAuth2Constants.access_token); - } else { - String[] arr = accessToken.split("[ ]"); - if (arr.length > 1 && ("Bearer".equalsIgnoreCase(arr[0]) || "OAuth".equalsIgnoreCase(arr[0]))) { - accessToken = arr[1]; - } - } - if (StringUtils.isEmpty(accessToken)) { - return null; - } - OAuth2AccessToken auth2AccessToken = accessTokenService.getTokenByAccessToken(accessToken); - if (auth2AccessToken == null) { - throw new GrantTokenException(ErrorType.INVALID_TOKEN); - } - Long time = auth2AccessToken.getUpdateTime() != null ? auth2AccessToken.getUpdateTime() : auth2AccessToken.getCreateTime(); - if (System.currentTimeMillis() - time > auth2AccessToken.getExpiresIn() * 1000L) { - throw new GrantTokenException(ErrorType.EXPIRED_TOKEN); - } - - return new AuthorizedToken() { - @Override - public String getUserId() { - return auth2AccessToken.getOwnerId(); - } - - @Override - public String getToken() { - return auth2AccessToken.getAccessToken(); - } - - @Override - public String getType() { - return token_type; - } - - @Override - public long getMaxInactiveInterval() { - return auth2AccessToken.getExpiresIn() * 1000L; - } - }; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 1bb7c0434..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.oauth2.OAuth2GranterAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index bce704e12..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2019 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. - * - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "http://github.com/hs-web/hsweb-framework", - author: "zh.sqy@qq.com", - comment: "OAuth2.0 server" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.0", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; - -function install(context) { - var database = context.database; - database.createOrAlter("s_oauth2_client") - .addColumn().name("u_id").varchar(32).notNull().primaryKey().comment("client_id").commit() - .addColumn().name("secret").varchar(64).notNull().comment("client_secret").commit() - .addColumn().name("name").varchar(128).notNull().comment("客户端名称").commit() - .addColumn().name("describe").varchar(256).comment("备注").commit() - .addColumn().name("type").varchar(128).notNull().comment("客户端类型").commit() - .addColumn().name("owner_id").varchar(32).notNull().comment("绑定的用户ID").commit() - .addColumn().name("creator_id").varchar(32).comment("创建者ID").commit() - .addColumn().name("redirect_uri").varchar(1024).notNull().comment("redirect_uri").commit() - .addColumn().name("create_time").number(32).notNull().comment("创建时间").commit() - .addColumn().name("support_grant_types").varchar(2048).comment("支持的授权列表").commit() - .addColumn().name("default_expires_in").number(16).comment("默认认证过期时间").commit() - .addColumn().name("default_grant_scope").clob().comment("默认认证范围").commit() - .addColumn().name("status").number(4).comment("状态").commit() - .comment("OAuth2客户端").commit(); - - database.createOrAlter("s_oauth2_access") - .addColumn().name("client_id").varchar(32).notNull().comment("client_id").commit() - .addColumn().name("owner_id").varchar(32).notNull().comment("授权对应的用户ID").commit() - .addColumn().name("access_token").varchar(32).notNull().comment("授权码").commit() - .addColumn().name("expires_in").varchar(32).notNull().comment("有效期").commit() - .addColumn().name("refresh_token").varchar(32).notNull().comment("用于更新授权的token").commit() - .addColumn().name("create_time").number(32).notNull().comment("创建时间").commit() - .addColumn().name("update_time").number(32).comment("更新时间").commit() - .addColumn().name("scope").clob().comment("授权范围").commit() - .addColumn().name("grant_type").varchar(32).comment("授权类型").commit() - .index().name("idx_oauth_ser_client_id").column("client_id").commit() - .index().name("idx_oauth_ser_owner_id").column("owner_id").commit() - .index().name("idx_oauth_ser_access_token").column("access_token").commit() - .index().name("idx_oauth_ser_refresh_token").column("refresh_token").commit() - .comment("OAuth2授权认证信息").commit(); - - database.createOrAlter("s_oauth2_auth_code") - .addColumn().name("client_id").varchar(32).notNull().comment("client_id").commit() - .addColumn().name("user_id").varchar(32).notNull().comment("授权对应的用户ID").commit() - .addColumn().name("code").varchar(32).notNull().comment("授权码").commit() - .addColumn().name("create_time").number(32).notNull().comment("创建时间").commit() - .addColumn().name("scope").clob().notNull().comment("授权范围").commit() - .addColumn().name("redirect_uri").varchar(1024).notNull().comment("重定向URI").commit() - .comment("OAuth2授权码信息").commit(); -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/pom.xml b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/pom.xml deleted file mode 100644 index b680d8557..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - hsweb-system-oauth2-server - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-oauth2-server-web - - - - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - org.hswebframework.web - hsweb-system-oauth2-server-local - ${project.version} - - - org.hswebframework.web - hsweb-authorization-oauth2-auth-server - ${project.version} - - - javax.servlet - javax.servlet-api - true - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2AuthorizeController.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2AuthorizeController.java deleted file mode 100644 index 6baa26643..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2AuthorizeController.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.exception.UnAuthorizedException; -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.authorization.oauth2.server.event.OAuth2GrantEvent; -import org.hswebframework.web.authorization.oauth2.server.support.OAuth2Granter; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeRequest; -import org.hswebframework.web.authorization.oauth2.server.support.code.AuthorizationCodeService; -import org.hswebframework.web.authorization.oauth2.server.support.code.HttpAuthorizationCodeRequest; -import org.hswebframework.web.authorization.oauth2.server.support.implicit.HttpImplicitRequest; -import org.hswebframework.web.authorization.oauth2.server.support.implicit.ImplicitRequest; -import org.hswebframework.web.oauth2.core.GrantType; -import org.hswebframework.web.oauth2.core.OAuth2Constants; -import org.hswebframework.web.authorization.oauth2.model.AuthorizationCodeModel; -import org.hswebframework.web.authorization.oauth2.model.ImplicitAccessTokenModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -/** - * @author zhouhao - */ -@RestController -@Api(tags = "OAuth2.0-服务-授权", value = "OAuth2.0-服务-授权") -@RequestMapping("${hsweb.web.mappings.authorize-oauth2:oauth2/authorize}") -public class OAuth2AuthorizeController { - - @Resource - private AuthorizationCodeService authorizationCodeService; - - @Resource - private OAuth2Granter oAuth2Granter; - - @Autowired - private ApplicationEventPublisher publisher; - - @GetMapping(params = "response_type=code") - @ApiOperation("获取当前登录用户OAuth2.0授权码") - @Authorize - @ApiImplicitParam(paramType = "query",name = OAuth2Constants.client_id,required = true) - public AuthorizationCodeModel requestCode( - @RequestParam("redirect_uri") String redirectUri, - @RequestParam(value = "state", required = false) String state, - HttpServletRequest request) { - Authentication authentication = Authentication.current().orElseThrow(UnAuthorizedException::new); - - AuthorizationCodeRequest codeRequest = new HttpAuthorizationCodeRequest(authentication.getUser().getId(), request); - - String code = authorizationCodeService.createAuthorizationCode(codeRequest); - - AuthorizationCodeModel model = new AuthorizationCodeModel(); - model.setCode(code); - model.setRedirectUri(redirectUri); - model.setState(state); - return model; - } - - - @GetMapping(params = "response_type=token") - @ApiOperation(value = "implicit方式申请token", tags = "OAuth2.0-服务-申请token") - @ApiImplicitParam(paramType = "query",name = OAuth2Constants.client_id,required = true) - public ImplicitAccessTokenModel authorizeByImplicit( - @RequestParam(value = "redirect_uri") String redirect_uri, - @RequestParam(value = "state") String state, - HttpServletRequest request) { - - ImplicitRequest implicitRequest = new HttpImplicitRequest(request); - OAuth2AccessToken accessToken = oAuth2Granter.grant(GrantType.implicit, implicitRequest); - publisher.publishEvent(new OAuth2GrantEvent(accessToken)); - - ImplicitAccessTokenModel model = new ImplicitAccessTokenModel(); - model.setState(state); - model.setToken_type("example"); - model.setAccess_token(accessToken.getAccessToken()); - model.setExpires_in(accessToken.getExpiresIn()); - model.setRedirect_uri(redirect_uri); - return model; - } - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java deleted file mode 100644 index 3bddb714f..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2ClientConfigController.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.hswebframework.web.authorization.oauth2.controller; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2Client; -import org.hswebframework.web.authorization.oauth2.server.client.OAuth2ClientConfigRepository; -import org.hswebframework.web.entity.oauth2.server.OAuth2ClientEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping("/oauth2-client-config") -@Api(tags = "OAuth2.0-服务-客户端管理", value = "OAuth2.0-服务-客户端管理") -@Authorize(permission = "oauth2-client-config", description = "OAuth2.0-服务-客户端管理") -public class OAuth2ClientConfigController { - - @Autowired - private OAuth2ClientConfigRepository repository; - - @GetMapping - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("获取全部客户端") - public ResponseMessage> getAllClient() { - return ResponseMessage.ok(repository.getAll()); - } - - - @GetMapping("/{id}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("根据id获取客户端") - public ResponseMessage getById(@PathVariable String id) { - return ResponseMessage.ok(repository.getClientById(id)); - } - - @GetMapping("/owner/{userId}") - @Authorize(action = Permission.ACTION_GET) - @ApiOperation("根据绑定到用户到客户端") - public ResponseMessage getByOwnerId(@PathVariable String userId) { - return ResponseMessage.ok(repository.getClientByOwnerId(userId)); - } - - - @PatchMapping - @Authorize(action = Permission.ACTION_UPDATE) - @ApiOperation(value = "保存客户端", notes = "如果客户端不存在则自动新增") - public ResponseMessage saveOrUpdate(@RequestBody OAuth2ClientEntity clientEntity) { - Authentication authentication = Authentication.current().orElse(null); - - if (null != authentication) { - clientEntity.setCreatorId(authentication.getUser().getId()); - } - clientEntity.setCreateTimeNow(); - - return ResponseMessage.ok(repository.save(clientEntity)); - } - - @DeleteMapping("/{id}") - @Authorize(action = Permission.ACTION_DELETE) - @ApiOperation(value = "删除客户端") - public ResponseMessage removeById(@PathVariable String id) { - return ResponseMessage.ok(repository.remove(id)); - } - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2TokenController.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2TokenController.java deleted file mode 100644 index 59e3b9ea0..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2TokenController.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.*; -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.authorization.oauth2.server.event.OAuth2GrantEvent; -import org.hswebframework.web.authorization.oauth2.server.exception.GrantTokenException; -import org.hswebframework.web.authorization.oauth2.server.support.OAuth2Granter; -import org.hswebframework.web.authorization.oauth2.server.support.client.HttpClientCredentialRequest; -import org.hswebframework.web.authorization.oauth2.server.support.code.HttpAuthorizationCodeTokenRequest; -import org.hswebframework.web.authorization.oauth2.server.support.implicit.HttpImplicitRequest; -import org.hswebframework.web.authorization.oauth2.server.support.password.HttpPasswordRequest; -import org.hswebframework.web.authorization.oauth2.server.support.refresh.HttpRefreshTokenRequest; -import org.hswebframework.web.oauth2.core.ErrorType; -import org.hswebframework.web.oauth2.core.GrantType; -import org.hswebframework.web.oauth2.core.OAuth2Constants; -import org.hswebframework.web.authorization.oauth2.model.AccessTokenModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -/** - * @author zhouhao - */ -@RestController -@Api(tags = "OAuth2.0-服务-申请token", value = "OAuth2.0-服务-申请token") -@RequestMapping("${hsweb.web.mappings.authorize-oauth2:oauth2/token}") -public class OAuth2TokenController { - - @Resource - private OAuth2Granter oAuth2Granter; - - @Autowired - private ApplicationEventPublisher publisher; - @PostMapping - @ApiOperation(value = "申请token", notes = "具体请求方式请参照: http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html") - @ApiImplicitParams( - { - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.client_id,required = true), - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.client_secret), - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.refresh_token), - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.redirect_uri), - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.code), - @ApiImplicitParam(paramType = "query", name = OAuth2Constants.scope, example = "user-info:get,share:add"), - @ApiImplicitParam(paramType = "header", name = OAuth2Constants.authorization, example = "Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW") - } - ) - public AccessTokenModel requestToken( - @RequestParam("grant_type" - ) @ApiParam(allowableValues = GrantType.authorization_code + "," + GrantType.client_credentials + "," + GrantType.password + "," + GrantType.refresh_token + "," + GrantType.implicit) String grant_type, - HttpServletRequest request) { - OAuth2AccessToken accessToken = null; - switch (grant_type) { - case GrantType.authorization_code: - accessToken = oAuth2Granter.grant(GrantType.authorization_code, new HttpAuthorizationCodeTokenRequest(request)); - break; - case GrantType.client_credentials: - accessToken = oAuth2Granter.grant(GrantType.client_credentials, new HttpClientCredentialRequest(request)); - break; - case GrantType.implicit: - accessToken = oAuth2Granter.grant(GrantType.implicit, new HttpImplicitRequest(request)); - break; - case GrantType.password: - accessToken = oAuth2Granter.grant(GrantType.password, new HttpPasswordRequest(request)); - break; - case GrantType.refresh_token: - accessToken = oAuth2Granter.grant(GrantType.refresh_token, new HttpRefreshTokenRequest(request)); - break; - default: - ErrorType.UNSUPPORTED_GRANT_TYPE.throwThis(GrantTokenException::new); - } - publisher.publishEvent(new OAuth2GrantEvent(accessToken)); - return entityToModel(accessToken); - } - - - protected AccessTokenModel entityToModel(OAuth2AccessToken token) { - AccessTokenModel model = new AccessTokenModel(); - model.setAccess_token(token.getAccessToken()); - model.setRefresh_token(token.getRefreshToken()); - model.setExpires_in(token.getExpiresIn()); - if (token.getScope() != null) { - model.setScope(token.getScope().stream().reduce((t1, t2) -> t1.concat(",").concat(t2)).orElse("")); - } else { - model.setScope("public"); - } - model.setToken_type("bearer"); - return model; - } - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserInfoController.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserInfoController.java deleted file mode 100644 index 85256e7a6..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/controller/OAuth2UserInfoController.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationHolder; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.authorization.exception.UnAuthorizedException; -import org.hswebframework.web.authorization.oauth2.server.OAuth2AccessToken; -import org.hswebframework.web.authorization.oauth2.server.exception.GrantTokenException; -import org.hswebframework.web.authorization.oauth2.server.token.AccessTokenService; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.oauth2.core.ErrorType; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; - -/** - * @author zhouhao - */ -@RestController -@Api(tags = "OAuth2.0-服务-获取用户信息", value = "OAuth2.0-服务-获取用户信息") -@RequestMapping("${hsweb.web.mappings.oauth2-auth-info:oauth2/user-auth-info}") -public class OAuth2UserInfoController { - - - @Resource - private AccessTokenService accessTokenService; - - @GetMapping - @ApiOperation("根据accessToken获取对应用户信息") - public ResponseMessage getLoginUser(@RequestParam("access_token") String access_token) { - OAuth2AccessToken auth2AccessEntity = accessTokenService.getTokenByAccessToken(access_token); - if (null == auth2AccessEntity) { - throw new GrantTokenException(ErrorType.EXPIRED_TOKEN); - } - return ResponseMessage.ok(AuthenticationHolder.get(auth2AccessEntity.getOwnerId())); - } - - @GetMapping("/{userId}") - @ApiOperation("根据accessToken获取特定的用户信息") - public ResponseMessage getUserById( - @PathVariable("userId") String userId, - @RequestParam("access_token") String access_token) { - OAuth2AccessToken auth2AccessEntity = accessTokenService.getTokenByAccessToken(access_token); - if (null == auth2AccessEntity) { - throw new GrantTokenException(ErrorType.EXPIRED_TOKEN); - } - if (auth2AccessEntity.getScope() == null ||(!auth2AccessEntity.getScope().contains("*")&&!auth2AccessEntity.getScope().contains("user:get"))) { - throw new GrantTokenException(ErrorType.UNAUTHORIZED_CLIENT); - } - Authentication info= AuthenticationHolder.get(userId); - if(info==null){ - throw new NotFoundException("user:"+userId+" not found"); - } - return ResponseMessage.ok(info); - } - -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AccessTokenModel.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AccessTokenModel.java deleted file mode 100644 index 50cd901fb..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AccessTokenModel.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.model; - -import org.hswebframework.web.commons.model.Model; - -/** - * @author zhouhao - */ -public class AccessTokenModel implements Model { - - private String access_token; - - private String refresh_token; - - private String token_type; - - private Integer expires_in; - - private String scope; - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getAccess_token() { - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } - - public String getRefresh_token() { - return refresh_token; - } - - public void setRefresh_token(String refresh_token) { - this.refresh_token = refresh_token; - } - - public String getToken_type() { - return token_type; - } - - public void setToken_type(String token_type) { - this.token_type = token_type; - } - - public Integer getExpires_in() { - return expires_in; - } - - public void setExpires_in(Integer expires_in) { - this.expires_in = expires_in; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AuthorizationCodeModel.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AuthorizationCodeModel.java deleted file mode 100644 index 7386a4547..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/AuthorizationCodeModel.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.model; - -import org.hswebframework.web.commons.model.Model; - -/** - * - * @author zhouhao - */ -public class AuthorizationCodeModel implements Model { - private String code; - private String state; - private String redirectUri; - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/ImplicitAccessTokenModel.java b/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/ImplicitAccessTokenModel.java deleted file mode 100644 index 605b26668..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/hsweb-system-oauth2-server-web/src/main/java/org/hswebframework/web/authorization/oauth2/model/ImplicitAccessTokenModel.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2019 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.authorization.oauth2.model; - -import org.hswebframework.web.commons.model.Model; - -/** - * @author zhouhao - */ -public class ImplicitAccessTokenModel implements Model { - private static final long serialVersionUID = -8797158129087670407L; - private String access_token; - - private String token_type; - - private Integer expires_in; - - private String state; - - private String redirect_uri; - - public String getRedirect_uri() { - return redirect_uri; - } - - public void setRedirect_uri(String redirect_uri) { - this.redirect_uri = redirect_uri; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getAccess_token() { - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } - - public String getToken_type() { - return token_type; - } - - public void setToken_type(String token_type) { - this.token_type = token_type; - } - - public Integer getExpires_in() { - return expires_in; - } - - public void setExpires_in(Integer expires_in) { - this.expires_in = expires_in; - } -} diff --git a/hsweb-system/hsweb-system-oauth2-server/pom.xml b/hsweb-system/hsweb-system-oauth2-server/pom.xml deleted file mode 100644 index 75ca89dba..000000000 --- a/hsweb-system/hsweb-system-oauth2-server/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - - hsweb-system-oauth2-server-starter - hsweb-system-oauth2-server-local - hsweb-system-oauth2-server-web - - pom - hsweb-system-oauth2-server - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/README.md b/hsweb-system/hsweb-system-organizational/README.md deleted file mode 100644 index 393cda773..000000000 --- a/hsweb-system/hsweb-system-organizational/README.md +++ /dev/null @@ -1,29 +0,0 @@ -## 组织架构管理 -提供 机构-部门-职位-人员 的组织架构管理 - - -## SQL条件 -`hsweb-system-organizational-local`模块中提供了一些自定义的查询条件,用于对组织机构关联查询.可以在动态查询中 -进行使用,例如: - -```java - -//查询orgId为1234的机构以及其所有子机构的数据 -createQuery().where("orgId","org-child-in","1234").list(); - -``` - -1. dist-child`(-parent)(-not)`-in : 参数`(不)`在指定的行政区域以及子(父)节点中 -2. org-child`(-parent)(-not)`-in : 参数`(不)`在指定的机构以及子(父)节点中 -3. dept-child`(-parent)(-not)`-in: 参数`(不)`在指定的部门以及子(父)节点中 -3. pos-child`(-parent)(-not)`-in: 参数`(不)`在指定的岗位以及子(父)节点中 -4. user`(-not)`-in-position`(-child)(-parent)`: 用户ID`(不)`在岗位中`(包含子级(父级)岗位)` -5. user`(-not)`-in-department`(-child)(-parent)`: 用户ID`(不)`在部门中`(包含子级(父级)岗位)` -6. user`(-not)`-in-org`(-child)(-parent)`: 用户ID`(不)`在机构中`(包含子级(父级)岗位)` -7. user`(-not)`-in-dist`(-child)(-parent)`: 用户ID`(不)`在行政区域中`(包含子级(父级)岗位)` -8. person`(-not)`-in-position`(-child)(-parent)`: 人员ID`(不)`在岗位中`(包含子级(父级)岗位)` -9. person`(-not)`-in-department`(-child)(-parent)`: 人员ID`(不)`在部门中`(包含子级(父级)岗位)` -10. person`(-not)`-in-org`(-child)(-parent)`: 人员ID`(不)`在机构中`(包含子级(父级)岗位)` -11. person`(-not)`-in-dist`(-child)(-parent)`: 人员ID`(不)`在行政区域中`(包含子级(父级)岗位)` - -注意: 括号中的内容是可选的 diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/pom.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/pom.xml deleted file mode 100644 index 3597d002a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - hsweb-system-organizational - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational-api - - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - - org.hswebframework.web - hsweb-system-organizational-authorization - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DepartmentEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DepartmentEntity.java deleted file mode 100644 index e0c6129da..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DepartmentEntity.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.hswebframework.web.organizational.authorization.access.DepartmentAttachEntity; -import org.hswebframework.web.organizational.authorization.access.OrgAttachEntity; - -import java.util.List; - -/** - * 部门 实体 - * - * @author hsweb-generator-online - */ -public interface DepartmentEntity extends TreeSortSupportEntity, OrgAttachEntity, DepartmentAttachEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 名称 - */ - String name = "name"; - /** - * 所在组织id - */ - String orgId = "orgId"; - /** - * 部门编码 - */ - String code = "code"; - /** - * 父级id - */ - String parentId = "parentId"; - /** - * 树结构编码 - */ - String path = "path"; - /** - * 排序序号 - */ - String sortIndex = "sortIndex"; - /** - * 状态 - */ - String status = "status"; - /** - * 级别 - */ - String level = "level"; - - /** - * @return 名称 - */ - String getName(); - - /** - * 设置 名称 - */ - void setName(String name); - - /** - * @return 部门编码 - */ - String getCode(); - - /** - * 设置 部门编码 - */ - void setCode(String code); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - void setChildren(List children); - - @Override - default String getDepartmentId() { - return getId(); - } - - @Override - default void setDepartmentId(String departmentId) { - setId(departmentId); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DistrictEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DistrictEntity.java deleted file mode 100644 index c1f96bbc0..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/DistrictEntity.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; - -import java.util.List; - -/** - * 行政区域 实体 - * - * @author hsweb-generator-online - */ -public interface DistrictEntity extends TreeSortSupportEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 区域名称,如重庆市 - */ - String name = "name"; - /** - * 区域全程,如重庆市江津区 - */ - String fullName = "fullName"; - /** - * 区域级别名称,如:省 - */ - String levelName = "levelName"; - /** - * 区域级别编码,如:province - */ - String levelCode = "levelCode"; - /** - * 行政区域代码,如:500000 - */ - String code = "code"; - /** - * 树路径,如: asb3-lsat - */ - String path = "path"; - /** - * 说明 - */ - String describe = "describe"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 区域名称, 如重庆市 - */ - String getName(); - - /** - * @param name 区域名称,如重庆市 - */ - void setName(String name); - - /** - * @return 区域全称, 如重庆市江津区 - */ - String getFullName(); - - /** - * @param fullName 区域全程,如重庆市江津区 - */ - void setFullName(String fullName); - - /** - * @return 区域级别名称, 如:省 - */ - String getLevelName(); - - /** - * @param levelName 区域级别名称,如:省 - */ - void setLevelName(String levelName); - - /** - * @return 区域级别编码, 如:province - */ - String getLevelCode(); - - /** - * @param levelCode 区域级别编码,如:province - */ - void setLevelCode(String levelCode); - - /** - * @return 行政区域代码, 如:500000 - */ - String getCode(); - - /** - * @param code 行政区域代码,如:500000 - */ - void setCode(String code); - - - /** - * @return 说明 - */ - String getDescribe(); - - /** - * @param describe 说明 - */ - void setDescribe(String describe); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * @param status 状态 - */ - void setStatus(Byte status); - - void setChildren(List children); - - @Override - List getChildren(); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/OrganizationalEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/OrganizationalEntity.java deleted file mode 100644 index 649d2a9dd..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/OrganizationalEntity.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.hswebframework.web.organizational.authorization.access.DistrictAttachEntity; -import org.hswebframework.web.organizational.authorization.access.OrgAttachEntity; - -import java.util.List; - -/** - * 组织 实体 - * - * @author hsweb-generator-online - */ -public interface OrganizationalEntity extends TreeSortSupportEntity, DistrictAttachEntity, OrgAttachEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 名称 - */ - String name = "name"; - /** - * 全称 - */ - String fullName = "fullName"; - /** - * 机构编码 - */ - String code = "code"; - /** - * 可选角色 - */ - String optionalRoles = "optionalRoles"; - /** - * 上级机构id - */ - String parentId = "parentId"; - /** - * 树定位码 - */ - String path = "path"; - /** - * 树结构编码 - */ - String sortIndex = "sortIndex"; - /** - * 状态 - */ - String status = "status"; - /** - * 级别 - */ - String level = "level"; - - /** - * @return 名称 - */ - String getName(); - - /** - * 设置 名称 - */ - void setName(String name); - - /** - * @return 全称 - */ - String getFullName(); - - /** - * 设置 全称 - */ - void setFullName(String fullName); - - /** - * @return 机构编码 - */ - String getCode(); - - /** - * 设置 机构编码 - */ - void setCode(String code); - - /** - * @return 可选角色 - */ - @Deprecated - java.util.List getOptionalRoles(); - - /** - * 设置 可选角色 - */ - @Deprecated - void setOptionalRoles(java.util.List optionalRoles); - - void setChildren(List children); - - Byte getStatus(); - - void setStatus(Byte status); - - @Override - default String getOrgId() { - return getId(); - } - - @Override - default void setOrgId(String orgId) { - setId(orgId); - } - - default String getOrgIdProperty() { - return "id"; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonAuthBindEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonAuthBindEntity.java deleted file mode 100644 index 14fc51faf..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonAuthBindEntity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import java.util.Set; - -/** - * @author zhouhao - */ -public interface PersonAuthBindEntity extends PersonEntity { - PersonUserEntity getPersonUser(); - - void setPersonUser(PersonUserEntity personUser); - - Set getPositionIds(); - - void setPositionIds(Set positionIds); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonEntity.java deleted file mode 100644 index dbe703806..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonEntity.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.authorization.access.UserAttachEntity; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.organizational.authorization.access.PersonAttachEntity; - -/** - * 人员 实体 - * - * @author hsweb-generator-online - */ -public interface PersonEntity extends GenericEntity, PersonAttachEntity, UserAttachEntity { - /*------------------------------------------ - | 属性名常量 | - =========================================*/ - /** - * 姓名 - */ - String name = "name"; - /** - * 性别 - */ - String sex = "sex"; - /** - * 电子邮箱 - */ - String email = "email"; - /** - * 联系电话 - */ - String phone = "phone"; - /** - * 照片 - */ - String photo = "photo"; - /** - * 关联用户id - */ - String userId = "userId"; - /** - * 状态 - */ - String status = "status"; - /** - * 备注 - */ - String remark = "remark"; - - /** - * @return 姓名 - */ - String getName(); - - /** - * 设置 姓名 - */ - void setName(String name); - - /** - * @return 性别 - */ - Byte getSex(); - - /** - * 设置 性别 - */ - void setSex(Byte sex); - - /** - * @return 电子邮箱 - */ - String getEmail(); - - /** - * 设置 电子邮箱 - */ - void setEmail(String email); - - /** - * @return 联系电话 - */ - String getPhone(); - - /** - * 设置 联系电话 - */ - void setPhone(String phone); - - /** - * @return 照片 - */ - String getPhoto(); - - /** - * 设置 照片 - */ - void setPhoto(String photo); - - /** - * @return 关联用户id - */ - String getUserId(); - - /** - * 设置 关联用户id - */ - void setUserId(String userId); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * 设置 状态 - */ - void setStatus(Byte status); - - /** - * @return 备注 - */ - String getRemark(); - - /** - * 设置 备注 - */ - void setRemark(String remark); - - @Override - default String getPersonId() { - return getId(); - } - - @Override - default void setPersonId(String personId) { - setId(personId); - } - - @Override - default String getPersonIdProperty() { - return "id"; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonPositionEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonPositionEntity.java deleted file mode 100644 index ee59a9e9a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonPositionEntity.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 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.organizational; - - -import org.hswebframework.web.organizational.authorization.access.PersonAttachEntity; -import org.hswebframework.web.organizational.authorization.access.PositionAttachEntity; - -/** - * 人员职位关联 实体 - * 即将使用 {@link RelationInfoEntity} 进行替代 - * - * @author hsweb-generator-online - */ -public interface PersonPositionEntity extends PersonAttachEntity, PositionAttachEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 人员id - */ - String personId = "personId"; - /** - * 职位id - */ - String positionId = "positionId"; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonUserEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonUserEntity.java deleted file mode 100644 index b3aec1b63..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PersonUserEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * @author zhouhao - */ -public class PersonUserEntity implements Entity { - private static final long serialVersionUID = -2619415787107625818L; - private String username; - - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PositionEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PositionEntity.java deleted file mode 100644 index 28c2c5153..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/PositionEntity.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.commons.entity.TreeSortSupportEntity; -import org.hswebframework.web.organizational.authorization.access.DepartmentAttachEntity; -import org.hswebframework.web.organizational.authorization.access.PositionAttachEntity; - -import java.util.List; - -/** - * 职位 实体 - * - * @author hsweb-generator-online - */ -public interface PositionEntity extends TreeSortSupportEntity, DepartmentAttachEntity, PositionAttachEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 职位名称 - */ - String name = "name"; - /** - * 部门id - */ - String departmentId = "departmentId"; - /** - * 持有的角色 - */ - String roles = "roles"; - /** - * 备注 - */ - String remark = "remark"; - /** - * 父级id - */ - String parentId = "parentId"; - /** - * 树结构编码 - */ - String path = "path"; - /** - * 排序索引 - */ - String sortIndex = "sortIndex"; - /** - * 级别 - */ - String level = "level"; - - /** - * @return 职位名称 - */ - String getName(); - - /** - * 设置 职位名称 - */ - void setName(String name); - - /** - * @return 持有的角色 - */ - List getRoles(); - - /** - * 设置 持有的角色 - */ - void setRoles(List roles); - - /** - * @return 备注 - */ - String getRemark(); - - /** - * 设置 备注 - */ - void setRemark(String remark); - - void setChildren(List children); - - @Override - default String getPositionId() { - return getId(); - } - - @Override - default void setPositionId(String positionId) { - setId(positionId); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationDefineEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationDefineEntity.java deleted file mode 100644 index 9fc815f4c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationDefineEntity.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 关系定义 实体 - * - * @author hsweb-generator-online - */ -public interface RelationDefineEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 关系名称 - */ - String name = "name"; - /** - * 关系类型ID - */ - String typeId = "typeId"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 关系名称 - */ - String getName(); - - /** - * @param name 关系名称 - */ - void setName(String name); - - /** - * @return 关系类型ID - */ - String getTypeId(); - - /** - * @param typeId 关系类型ID - */ - void setTypeId(String typeId); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * @param status 状态 - */ - void setStatus(Byte status); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationInfoEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationInfoEntity.java deleted file mode 100644 index b2c4d8f30..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/RelationInfoEntity.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 关系信息 实体 - * - * @author hsweb-generator-online - */ -public interface RelationInfoEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 关系从 - */ - String relationFrom = "relationFrom"; - /** - * 关系定义id - */ - String relationId = "relationId"; - /** - * 关系至 - */ - String relationTo = "relationTo"; - /** - * 关系类型从,如:人员 - */ - String relationTypeFrom = "relationTypeFrom"; - /** - * 关系类型至,如:部门 - */ - String relationTypeTo = "relationTypeTo"; - /** - * 状态 - */ - String status = "status"; - - /** - * @return 关系从 - */ - String getRelationFrom(); - - /** - * @param relationFrom 关系从 - */ - void setRelationFrom(String relationFrom); - - /** - * @return 关系定义id - */ - String getRelationId(); - - /** - * @param relationId 关系定义id - */ - void setRelationId(String relationId); - - /** - * @return 关系至 - */ - String getRelationTo(); - - /** - * @param relationTo 关系至 - */ - void setRelationTo(String relationTo); - - /** - * @return 关系类型从, 如:人员 - */ - String getRelationTypeFrom(); - - /** - * @param relationTypeFrom 关系类型从,如:人员 - */ - void setRelationTypeFrom(String relationTypeFrom); - - /** - * @return 关系类型至, 如:部门 - */ - String getRelationTypeTo(); - - /** - * @param relationTypeTo 关系类型至,如:部门 - */ - void setRelationTypeTo(String relationTypeTo); - - /** - * @return 状态 - */ - Byte getStatus(); - - /** - * @param status 状态 - */ - void setStatus(Byte status); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDepartmentEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDepartmentEntity.java deleted file mode 100644 index 8e0f1376d..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDepartmentEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import lombok.*; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 部门 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SimpleDepartmentEntity extends SimpleTreeSortSupportEntity implements DepartmentEntity { - private static final long serialVersionUID = -2137579829759620323L; - //名称 - private String name; - //所在组织id - private String orgId; - //部门编码 - private String code; - //是否启用 - private Byte status; - - private List children; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDistrictEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDistrictEntity.java deleted file mode 100644 index f812dd82a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleDistrictEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import lombok.*; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 表单发布日志 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimpleDistrictEntity extends SimpleTreeSortSupportEntity implements DistrictEntity { - //区域名称,如重庆市 - private String name; - //区域全程,如重庆市江津区 - private String fullName; - //区域级别名称,如:省 - private String levelName; - //区域级别编码,如:province - private String levelCode; - //行政区域代码,如:500000 - private String code; - //说明 - private String describe; - //状态 - private Byte status; - private List children; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleOrganizationalEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleOrganizationalEntity.java deleted file mode 100644 index a71c0da52..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleOrganizationalEntity.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 组织 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimpleOrganizationalEntity extends SimpleTreeSortSupportEntity implements OrganizationalEntity { - private static final long serialVersionUID = -1610547249282278768L; - //名称 - private String name; - //全称 - private String fullName; - //机构编码 - private String code; - //可选角色 - private java.util.List optionalRoles; - //是否启用 - private Byte status; - //子级组织 - private List children; - - private String areaId; - - - @Override - public String getDistrictId() { - return areaId; - } - - @Override - public void setDistrictId(String districtId) { - setAreaId(districtId); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonAuthBindEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonAuthBindEntity.java deleted file mode 100644 index 9e4a034b6..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonAuthBindEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import java.util.Set; - -/** - * @author zhouhao - */ -public class SimplePersonAuthBindEntity extends SimplePersonEntity implements PersonAuthBindEntity { - private PersonUserEntity personUser; - //职务ID集合 - private Set positionIds; - - @Override - public PersonUserEntity getPersonUser() { - return personUser; - } - - @Override - public void setPersonUser(PersonUserEntity personUser) { - this.personUser = personUser; - } - - @Override - public Set getPositionIds() { - return positionIds; - } - - @Override - public void setPositionIds(Set positionIds) { - this.positionIds = positionIds; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonEntity.java deleted file mode 100644 index aa8386a44..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonEntity.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 人员 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimplePersonEntity extends SimpleGenericEntity implements PersonEntity { - private static final long serialVersionUID = -4232153898188508965L; - //姓名 - @NotBlank - private String name; - //性别 - private Byte sex; - //电子邮箱 - @Email - private String email; - //联系电话 - private String phone; - //照片 - private String photo; - //关联用户id - private String userId; - //状态 - private Byte status; - //备注 - private String remark; - - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonPositionEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonPositionEntity.java deleted file mode 100644 index eb0244f34..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePersonPositionEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 人员职位关联 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimplePersonPositionEntity extends SimpleGenericEntity implements PersonPositionEntity { - private static final long serialVersionUID = -7102840729564722732L; - //人员id - private String personId; - //职位id - private String positionId; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePositionEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePositionEntity.java deleted file mode 100644 index 8f5b43c3d..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimplePositionEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleTreeSortSupportEntity; - -import java.util.List; - -/** - * 职位 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimplePositionEntity extends SimpleTreeSortSupportEntity implements PositionEntity { - private static final long serialVersionUID = -8912215943657734192L; - //职位名称 - private String name; - //部门id - private String departmentId; - //持有的角色 - private List roles; - //备注 - private String remark; - - private List children; - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationDefineEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationDefineEntity.java deleted file mode 100644 index edc1472f7..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationDefineEntity.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 关系定义 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimpleRelationDefineEntity extends SimpleGenericEntity implements RelationDefineEntity { - private static final long serialVersionUID = -8372686525577214172L; - //关系名称 - private String name; - //关系类型ID - private String typeId; - //状态 - private Byte status; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationInfoEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationInfoEntity.java deleted file mode 100644 index f28a7fa2d..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/entity/organizational/SimpleRelationInfoEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.entity.organizational; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * 关系信息 - * - * @author hsweb-generator-online - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class SimpleRelationInfoEntity extends SimpleGenericEntity implements RelationInfoEntity { - private static final long serialVersionUID = -7285786918328019221L; - //关系从 - private String relationFrom; - //关系定义id - private String relationId; - //关系至 - private String relationTo; - //关系类型从,如:人员 - private String relationTypeFrom; - //关系类型至,如:部门 - private String relationTypeTo; - //状态 - private Byte status; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DepartmentService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DepartmentService.java deleted file mode 100644 index c4e65212c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DepartmentService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 部门 服务类 - * - * @author hsweb-generator-online - */ -public interface DepartmentService extends - TreeService - , CrudService { - - List selectByOrgId(String orgId); - - List selectByOrgIds(List orgId,boolean children,boolean parent); - - DepartmentEntity selectByCode(String code); - - List selectByName(String name); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DistrictService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DistrictService.java deleted file mode 100644 index ad01f69ac..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/DistrictService.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.service.organizational; - -import org.hswebframework.web.entity.organizational.DistrictEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 表单发布日志 服务类 - * - * @author hsweb-generator-online - */ -public interface DistrictService extends TreeService,CrudService { - void disable(String id); - - void enable(String id); - - DistrictEntity selectByCode(String code); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/OrganizationalService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/OrganizationalService.java deleted file mode 100644 index 53bc8a1da..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/OrganizationalService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -import java.util.List; - -/** - * 组织 服务类 - * - * @author hsweb-generator-online - */ -public interface OrganizationalService extends - TreeService - , CrudService { - - void disable(String id); - - void enable(String id); - - OrganizationalEntity selectByCode(String code); - - OrganizationalEntity selectByName(String name); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PersonService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PersonService.java deleted file mode 100644 index 51b31c17c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PersonService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.entity.organizational.PersonAuthBindEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.service.CrudService; - -import java.util.List; - -/** - * 人员 服务类 - * - * @author hsweb-generator-online - */ -public interface PersonService extends CrudService { - - String insert(PersonAuthBindEntity authBindEntity); - - int updateByPk(PersonAuthBindEntity authBindEntity); - - List selectByName(String name); - - PersonAuthBindEntity selectAuthBindByPk(String id); - - List selectByPositionId(String positionId); - - List selectByPositionIds(List positionId); - - List selectByDepartmentId(List departmentId); - - List selectByOrgId(List departmentId); - - PersonEntity selectByUserId(String userId); - - List selectAllDepartmentId(List personId); - - List selectAllOrgId(List personId); - - List selectByRoleId(String roleId); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PositionService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PositionService.java deleted file mode 100644 index f7b54f319..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/PositionService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.service.TreeService; - -/** - * 职位 服务类 - * - * @author hsweb-generator-online - */ -public interface PositionService extends TreeService, CrudService { - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationDefineService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationDefineService.java deleted file mode 100644 index a7489f2dc..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationDefineService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.organizational; - -import org.hswebframework.web.entity.organizational.RelationDefineEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 关系定义 服务类 - * - * @author hsweb-generator-online - */ -public interface RelationDefineService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationInfoService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationInfoService.java deleted file mode 100644 index 12be96f7b..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/RelationInfoService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.service.organizational; - -import org.hswebframework.web.entity.organizational.RelationInfoEntity; -import org.hswebframework.web.organizational.authorization.relation.Relations; -import org.hswebframework.web.service.CrudService; - - -/** - * 关系信息 服务类 - * - * @author hsweb-generator-online - */ -public interface RelationInfoService extends CrudService { - Relations getRelations(String relationTypeFrom, String relationFrom); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/event/ClearPersonCacheEvent.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/event/ClearPersonCacheEvent.java deleted file mode 100644 index 51d525012..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-api/src/main/java/org/hswebframework/web/service/organizational/event/ClearPersonCacheEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.hswebframework.web.service.organizational.event; - -/** - * @author zhouhao - * @since 3.0 - */ -public class ClearPersonCacheEvent { - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/README.md b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/README.md deleted file mode 100644 index 05ee2e879..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# 机构权限控制 -实现基于组织机构的权限信息获取,以及数据权限控制 - -### 获取当前用户对应的人员信息 - -```java - PersonnelAuthentication person= PersonnelAuthentication.current().orElse(null); - - //人员基本信息 - person.getPersonnel(); - //人员的全部职位信息 - person.getPositions(); - //人员的关系信息,用于判断人与人,人与物的关系 - person.getRelations(); - //更多方法请查看源代码 -``` - -### 数据权限控制 - -约定: -1. 通过在方法上注解: `@Authorize(dataAccess=@RequiresDataAccess)` 开启数据权限控制 -2. 分页查询: 仅支持使用通用查询条件(`@QueryParamEntity`)作为参数的方法. -3. 根据主键,修改,删除: 仅支持实现`QueryController`的类 -4. 对`行政区划`进行权限控制的实体需实现接口: `DistrictAttachEntity` -5. 对`机构`进行权限控制的实体需实现接口: `OrgAttachEntity` -6. 对`部门`进行权限控制的实体需实现接口: `DepartmentAttachEntity` -7. 对`岗位`进行权限控制的实体需实现接口: `PositionAttachEntity` -8. 对`人员`进行权限控制的实体需实现接口: `PersonAttachEntity` -注意,具体的控制规则配置是由`hsweb-system-authorization`模块实现 - -### 自定义控制 - -你可以参照包`org.hswebframework.web.organizational.authorization.simple.handler`中的实现 -进行自定义控制 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/pom.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/pom.xml deleted file mode 100644 index 4d86e504d..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - hsweb-system-organizational - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational-authorization - - - org.hswebframework.web - hsweb-authorization-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-entity - ${project.version} - - - org.hswebframework - hsweb-easy-orm-rdb - true - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - true - - - org.springframework.boot - spring-boot-starter - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/DefaultPersonnelAuthenticationSupplier.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/DefaultPersonnelAuthenticationSupplier.java deleted file mode 100644 index 51e28f712..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/DefaultPersonnelAuthenticationSupplier.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import org.hswebframework.web.ThreadLocalUtils; -import org.hswebframework.web.authorization.Authentication; - -import java.util.Objects; - -/** - * 默认人员权限提供者,通过{@link PersonnelAuthenticationManager}获取,并提供ThreadLocal缓存 - * - * @author zhouhao - * @see 3.0 - */ -public class DefaultPersonnelAuthenticationSupplier implements PersonnelAuthenticationSupplier { - private PersonnelAuthenticationManager personnelAuthenticationManager; - - private static final String threadLocalCacheKey = DefaultPersonnelAuthenticationSupplier.class.getName() + "_CACHE"; - - public DefaultPersonnelAuthenticationSupplier(PersonnelAuthenticationManager personnelAuthenticationManager) { - Objects.requireNonNull(personnelAuthenticationManager); - this.personnelAuthenticationManager = personnelAuthenticationManager; - } - - @Override - public PersonnelAuthentication getByPersonId(String personId) { - return personnelAuthenticationManager.getPersonnelAuthorizationByPersonId(personId); - } - - @Override - public PersonnelAuthentication getByUserId(String userId) { - return personnelAuthenticationManager.getPersonnelAuthorizationByUserId(userId); - } - - @Override - public PersonnelAuthentication get() { - //TreadLocal Cache - return ThreadLocalUtils.get(threadLocalCacheKey, () -> - Authentication.current().map(authentication -> getByUserId(authentication.getUser().getId())) - .orElse(null)); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Department.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Department.java deleted file mode 100644 index a8c76d690..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Department.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface Department extends Serializable { - String getId(); - - String getName(); - - String getCode(); - - Organization getOrg(); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/District.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/District.java deleted file mode 100644 index b196f59e6..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/District.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; - -/** - * 行政区域 - * - * @author zhouhao - * @since 3.0 - */ -public interface District extends Serializable { - /** - * @return 行政区域ID - */ - String getId(); - - /** - * @return 行政区域名称, 如:江津区 - */ - String getName(); - - /** - * @return 行政区域全名, 如:重庆市江津区 - */ - String getFullName(); - - /** - * @return 行政区域代码, 如: 500116 - */ - String getCode(); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Organization.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Organization.java deleted file mode 100644 index 4e2e9762c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Organization.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; - -/** - * 组织,机构,公司 - * - * @author zhouhao - * @since 3.0 - */ -public interface Organization extends Serializable { - /** - * @return 组织ID, 唯一 - */ - String getId(); - - /** - * @return 组织名称, 如: xxx公司 - */ - String getName(); - - /** - * @return 组织全称, 如: 重庆市xxxx公司 - */ - String getFullName(); - - /** - * @return 组织代码 - */ - String getCode(); - - /** - * @return 所在行政区, 如果未关联将返回null - */ - District getDistrict(); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/OrganizationalAuthorizationAutoConfiguration.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/OrganizationalAuthorizationAutoConfiguration.java deleted file mode 100644 index 9828f3134..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/OrganizationalAuthorizationAutoConfiguration.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import org.hswebframework.web.organizational.authorization.relation.RelationTargetSupplierAutoRegister; -import org.hswebframework.web.organizational.authorization.simple.*; -import org.hswebframework.web.organizational.authorization.simple.handler.*; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -public class OrganizationalAuthorizationAutoConfiguration implements BeanPostProcessor { - - @Bean - @ConditionalOnMissingBean(DistrictScopeDataAccessHandler.class) - public DistrictScopeDataAccessHandler areaScopeDataAccessHandler() { - return new DistrictScopeDataAccessHandler(); - } - - - @Bean - @ConditionalOnMissingBean(CustomScopeHandler.class) - public CustomScopeHandler customScopeHandler() { - return new CustomScopeHandler(); - } - - @Bean - @ConditionalOnMissingBean(DepartmentScopeDataAccessHandler.class) - public DepartmentScopeDataAccessHandler departmentScopeDataAccessHandler() { - return new DepartmentScopeDataAccessHandler(); - } - - @Bean - @ConditionalOnMissingBean(OrgScopeDataAccessHandler.class) - public OrgScopeDataAccessHandler orgScopeDataAccessHandler() { - return new OrgScopeDataAccessHandler(); - } - - @Bean - @ConditionalOnMissingBean(PersonScopeDataAccessHandler.class) - public PersonScopeDataAccessHandler personScopeDataAccessHandler() { - return new PersonScopeDataAccessHandler(); - } - - @Bean - @ConditionalOnMissingBean(PositionScopeDataAccessHandler.class) - public PositionScopeDataAccessHandler positionScopeDataAccessHandler() { - return new PositionScopeDataAccessHandler(); - } - - @Bean - @ConditionalOnMissingBean(ScopeDataAccessConfigConvert.class) - public ScopeDataAccessConfigConvert scopeDataAccessConfigConvert() { - return new ScopeDataAccessConfigConvert(); - } - - @Bean - @ConditionalOnMissingBean(CustomScopeDataAccessConfigConvert.class) - public CustomScopeDataAccessConfigConvert customScopeDataAccessConfigConvert() { - return new CustomScopeDataAccessConfigConvert(); - } - - @Bean - @ConditionalOnMissingBean(ScopeByUserDataAccessConfigConvert.class) - public ScopeByUserDataAccessConfigConvert scopeByUserDataAccessConfigConvert() { - return new ScopeByUserDataAccessConfigConvert(); - } - - @Bean - @ConditionalOnMissingBean(ScopeByUserHandler.class) - public ScopeByUserHandler scopeByUserHandler() { - return new ScopeByUserHandler(); - } - - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof PersonnelAuthenticationSupplier) { - PersonnelAuthenticationHolder.addSupplier(((PersonnelAuthenticationSupplier) bean)); - } - return bean; - } - - @Bean - public RelationTargetSupplierAutoRegister relationTargetSupplierAutoRegister() { - return new RelationTargetSupplierAutoRegister(); - } - - @Configuration - @ConditionalOnBean(PersonnelAuthenticationManager.class) - public static class PersonnelAuthorizationSupplierAutoConfiguration { - - @Bean - public DefaultPersonnelAuthenticationSupplier personnelAuthorizationManager(PersonnelAuthenticationManager personnelAuthenticationManager) { - return new DefaultPersonnelAuthenticationSupplier(personnelAuthenticationManager); - } - - @Bean - public PersonnelAuthenticationSettingTypeSupplier personnelAuthorizationSettingTypeSupplier() { - return new PersonnelAuthenticationSettingTypeSupplier(); - } - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Personnel.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Personnel.java deleted file mode 100644 index 8605d3c0f..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Personnel.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; - -/** - * 人员基本信息 - * - * @author zhouhao - * @since 3.0 - */ -public interface Personnel extends Serializable { - String getId(); - - String getName(); - - String getPhone(); - - String getEmail(); - - String getPhoto(); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthentication.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthentication.java deleted file mode 100644 index c2c426f47..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthentication.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.organizational.authorization.relation.Relations; - -import java.io.Serializable; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * 人员权限信息,用于获取当前登录用户对应的人员相关信息 - * - * @author zhouhao - * @see Authentication - * @since 3.0 - */ -public interface PersonnelAuthentication extends Serializable { - - /** - * 获取当前登录人员信息 - * - * @return 人员权限信息 - * @see Optional - * @see Authentication#getAttribute(String) - */ - static Optional current() { - return Optional.ofNullable(PersonnelAuthenticationHolder.get()); - } - - /** - * @return 人员的基本信息 - */ - Personnel getPersonnel(); - - /** - * 获取人员的关系信息 - *
-     *     boolean isLeader = PersonnelAuthentication
-     *     .current().get()
-     *     .getRelations()
-     *     // 和张三的人员为leader关系, 我是张三的leader
-     *     .has("leader","人员","张三");
-     *     //我是开发部的leader
-     *     //.has("leader","部门","开发部");
-     *     //反转关系: 张三是我的leader
-     *     //.has("leader","人员","张三","PRE");
-     * 
- *
-     *     List relations= PersonnelAuthentication.current()
-     *     //查找用户关系
-     *     .map(PersonnelAuthentication::getRelations)
-     *     .map(relations -> relations.findAll("leader"))
-     *     .orElse(null)
-     * 
- * - * @return 人员关系信息 - * @see Relations - * @see org.hswebframework.web.organizational.authorization.relation.Relation - */ - Relations getRelations(); - - /** - * @return 人员所在行政区域ID, 只返回根节点, 永远不会返回{@code null} - */ - Set> getDistrictIds(); - - /** - * @return 人员所在机构ID, 只返回根节点, 永远不会返回{@code null} - */ - Set> getOrgIds(); - - /** - * @return 人员职务ID, 只返回根节点, 永远不会返回{@code null} - */ - Set> getPositionIds(); - - /** - * @return 人员所在部门ID, 只返回根节点, 永远不会返回{@code null} - */ - Set> getDepartmentIds(); - - /** - * 获取人员的所有职位信息 - * - * @return 职位信息 - */ - Set getPositions(); - - default Optional getPosition(String id) { - return getPositions().stream().filter(position -> position.getId().equals(id)).findFirst(); - } - - /** - * @return 根地区ID - */ - default Set getRootDistrictId() { - return getDistrictIds().stream().map(TreeNode::getValue).collect(Collectors.toSet()); - } - - /** - * @return 根机构ID - */ - default Set getRootOrgId() { - return getOrgIds().stream().map(TreeNode::getValue).collect(Collectors.toSet()); - } - - /** - * @return 根职位ID - */ - default Set getRootPositionId() { - return getPositionIds().stream().map(TreeNode::getValue).collect(Collectors.toSet()); - } - - /** - * @return 根部门ID - */ - default Set getRootDepartmentId() { - return getDepartmentIds().stream().map(TreeNode::getValue).collect(Collectors.toSet()); - } - - /** - * @return 所有地区ID - */ - default Set getAllDistrictId() { - return getDistrictIds().stream().map(TreeNode::getAllValue).flatMap(List::stream).collect(Collectors.toSet()); - } - - /** - * @return 所有机构ID - */ - default Set getAllOrgId() { - return getOrgIds().stream().map(TreeNode::getAllValue).flatMap(List::stream).collect(Collectors.toSet()); - } - - /** - * @return 所有职位ID - */ - default Set getAllPositionId() { - return getPositionIds().stream().map(TreeNode::getAllValue).flatMap(List::stream).collect(Collectors.toSet()); - } - - /** - * @return 所有部门ID - */ - default Set getAllDepartmentId() { - return getDepartmentIds().stream().map(TreeNode::getAllValue).flatMap(List::stream).collect(Collectors.toSet()); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationHolder.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationHolder.java deleted file mode 100644 index d7f396107..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationHolder.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import org.hswebframework.web.ThreadLocalUtils; -import org.hswebframework.web.authorization.AuthenticationSupplier; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.function.Function; - -/** - * @author zhouhao - */ -public class PersonnelAuthenticationHolder { - private static final List suppliers = new ArrayList<>(); - - private static final String CURRENT_USER_ID_KEY = PersonnelAuthenticationHolder.class.getName() + "_current_id"; - - private static final ReadWriteLock lock = new ReentrantReadWriteLock(); - - private static PersonnelAuthentication get(Function function) { - lock.readLock().lock(); - try { - return suppliers.stream() - .map(function) - .filter(Objects::nonNull) - .findFirst().orElse(null); - } finally { - lock.readLock().unlock(); - } - } - - /** - * @return 当前登录的用户权限信息 - */ - public static PersonnelAuthentication get() { - String currentId = ThreadLocalUtils.get(CURRENT_USER_ID_KEY); - if (currentId != null) { - return getByPersonId(currentId); - } - return get(PersonnelAuthenticationSupplier::get); - } - - public static PersonnelAuthentication getByUserId(String userId) { - return get(supplier -> supplier.getByUserId(userId)); - } - - public static PersonnelAuthentication getByPersonId(String personId) { - return get(supplier -> supplier.getByPersonId(personId)); - } - - /** - * 初始化 {@link AuthenticationSupplier} - * - * @param supplier - */ - public static void addSupplier(PersonnelAuthenticationSupplier supplier) { - lock.writeLock().lock(); - try { - suppliers.add(supplier); - } finally { - lock.writeLock().unlock(); - } - } - - public static void setCurrentPersonId(String id) { - ThreadLocalUtils.put(PersonnelAuthenticationHolder.CURRENT_USER_ID_KEY, id); - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationManager.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationManager.java deleted file mode 100644 index f27846071..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationManager.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -/** - * 人员权限信息管理器 - * - * @author zhouhao - */ -public interface PersonnelAuthenticationManager { - PersonnelAuthentication getPersonnelAuthorizationByPersonId(String personId); - - PersonnelAuthentication getPersonnelAuthorizationByUserId(String userId); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSettingTypeSupplier.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSettingTypeSupplier.java deleted file mode 100644 index 2bbf00bf2..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSettingTypeSupplier.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -public class PersonnelAuthenticationSettingTypeSupplier implements AuthorizationSettingTypeSupplier { - public static final String SETTING_TYPE_PERSON = "person"; - - public static final String SETTING_TYPE_DEPARTMENT = "department"; - - public static final String SETTING_TYPE_ORG = "org"; - - public static final String SETTING_TYPE_DISTRICT = "district"; - - public static final String SETTING_TYPE_POSITION = "position"; - - @Autowired - private PersonnelAuthenticationManager personnelAuthenticationManager; - - @Override - public Set get(String userId) { - //支持职位和人员 设置权限 - PersonnelAuthentication authorization = personnelAuthenticationManager.getPersonnelAuthorizationByUserId(userId); - if (authorization == null) { - return new HashSet<>(); - } - Set settingInfo = new HashSet<>(); - - - //人员 - SettingInfo personSetting = new SettingInfo(SETTING_TYPE_PERSON, authorization.getPersonnel().getId()); - settingInfo.add(personSetting); - - //岗位 - settingInfo.addAll(authorization.getAllPositionId() - .stream() - .map(id -> new SettingInfo(SETTING_TYPE_POSITION, id)) - .collect(Collectors.toSet())); - - //部门 - settingInfo.addAll(authorization.getAllDepartmentId() - .stream() - .map(id -> new SettingInfo(SETTING_TYPE_DEPARTMENT, id)) - .collect(Collectors.toSet())); - - //机构 - settingInfo.addAll(authorization.getAllOrgId() - .stream() - .map(id -> new SettingInfo(SETTING_TYPE_ORG, id)) - .collect(Collectors.toSet())); - - //行政区划 - settingInfo.addAll(authorization.getAllDistrictId() - .stream() - .map(id -> new SettingInfo(SETTING_TYPE_DISTRICT, id)) - .collect(Collectors.toSet())); - - return settingInfo; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSupplier.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSupplier.java deleted file mode 100644 index ec3713136..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/PersonnelAuthenticationSupplier.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.util.function.Supplier; - -/** - * 人员权限提供者,用于根据人员或者用户id获取权限信息 - * - * @author zhouhao - * @see 3.0 - */ -public interface PersonnelAuthenticationSupplier extends Supplier { - PersonnelAuthentication getByPersonId(String personId); - - PersonnelAuthentication getByUserId(String userId); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Position.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Position.java deleted file mode 100644 index d3e35de9e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/Position.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface Position extends Serializable { - String getId(); - - String getCode(); - - String getName(); - - Department getDepartment(); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/TreeNode.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/TreeNode.java deleted file mode 100644 index 9f99614cd..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/TreeNode.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.hswebframework.web.organizational.authorization; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; - -/** - * 树形结构节点信息 - * - * @param 节点值类型 - * @author zhouhao - * @since 3.0 - */ -public class TreeNode implements Serializable { - private static final long serialVersionUID = 1_0; - -// /** -// * 父节点,根节点为{@code null} -// */ -// private TreeNode parent; - - /** - * 节点值 - */ - private V value; - - /** - * 节点层级 - */ - private int level; - - private Set> children; -// -// public TreeNode getParent() { -// return parent; -// } -// -// public void setParent(TreeNode parent) { -// this.parent = parent; -// } - - public V getValue() { - return value; - } - - public void setValue(V value) { - this.value = value; - } - - public Set> getChildren() { - return children; - } - - public void setChildren(Set> children) { - this.children = children; - children.forEach(node -> node.setLevel(getLevel() + 1)); - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } - - public List getAllValue() { - List values = new ArrayList<>(children != null ? children.size() + 1 : 1); - values.add(value); - if (null != children) { - children.stream().map(TreeNode::getAllValue).flatMap(List::stream).forEach(values::add); - } - return values; - } - - @Override - public int hashCode() { - if (value != null) { - return value.hashCode(); - } - return 0; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof TreeNode) { - return obj.hashCode() == hashCode(); - } - return false; - } - - public List getAllValue(Predicate> filter) { - List values = new ArrayList<>(getChildren().size() + 1); - if (filter.test(this)) { - values.add(value); - } - children.stream().filter(filter).map(val -> val.getAllValue(filter)).flatMap(List::stream).forEach(values::add); - return values; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DataAccessType.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DataAccessType.java deleted file mode 100644 index 185d1e3a6..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DataAccessType.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.access.ScopeDataAccessConfig; - -/** - * 控制类型 - * - * @author zhouhao - * @since 3.0 - */ -public interface DataAccessType { - /** - * 控制地区 - */ - String DISTRICT_SCOPE = "DISTRICT"; - /** - * 控制机构 - */ - String ORG_SCOPE = "ORG_SCOPE"; - /** - * 控制部门 - */ - String DEPARTMENT_SCOPE = "DEPARTMENT_SCOPE"; - /** - * 控制职位 - */ - String POSITION_SCOPE = "POSITION_SCOPE"; - /** - * 控制人员 - */ - String PERSON_SCOPE = "PERSON_SCOPE"; - /** - * 控制范围:仅限本人 - */ - String SCOPE_TYPE_ONLY_SELF = "ONLY_SELF"; - /** - * 控制范围:包含子级 - */ - String SCOPE_TYPE_CHILDREN = "CHILDREN"; - /** - * 控制范围:自定义范围 - */ - String SCOPE_TYPE_CUSTOM = "CUSTOM_SCOPE"; - - /* ===========行政区============*/ - static Permission.DataAccessPredicate districtScope(String action, String type) { - return Permission.scope(action, ORG_SCOPE, type); - } - - static Permission.DataAccessPredicate selfDistrictScope(String action) { - return districtScope(action, SCOPE_TYPE_ONLY_SELF); - } - - static Permission.DataAccessPredicate customDistrictScope(String action) { - return districtScope(action, SCOPE_TYPE_CUSTOM); - } - - static Permission.DataAccessPredicate childrenDistrictScope(String action) { - return districtScope(action, SCOPE_TYPE_CHILDREN); - } - - /* ===========机构============*/ - static Permission.DataAccessPredicate orgScope(String action, String type) { - return Permission.scope(action, ORG_SCOPE, type); - } - - static Permission.DataAccessPredicate selfOrgScope(String action) { - return orgScope(action, SCOPE_TYPE_ONLY_SELF); - } - - static Permission.DataAccessPredicate customOrgScope(String action) { - return orgScope(action, SCOPE_TYPE_CUSTOM); - } - - static Permission.DataAccessPredicate childrenOrgScope(String action) { - return orgScope(action, SCOPE_TYPE_CHILDREN); - } - - - /* ===========部门===========*/ - - static Permission.DataAccessPredicate departmentScope(String action, String type) { - return Permission.scope(action, DEPARTMENT_SCOPE, type); - } - - static Permission.DataAccessPredicate selfDepartmentScope(String action) { - return departmentScope(action, SCOPE_TYPE_ONLY_SELF); - } - - static Permission.DataAccessPredicate customDepartmentScope(String action) { - return departmentScope(action, SCOPE_TYPE_CUSTOM); - } - - static Permission.DataAccessPredicate childrenDepartmentScope(String action) { - return departmentScope(action, SCOPE_TYPE_CHILDREN); - } - - /* ===========岗位===========*/ - - static Permission.DataAccessPredicate positionScope(String action, String type) { - return Permission.scope(action, POSITION_SCOPE, type); - } - - static Permission.DataAccessPredicate selfPositionScope(String action) { - return positionScope(action, SCOPE_TYPE_ONLY_SELF); - } - - static Permission.DataAccessPredicate customPositionScope(String action) { - return positionScope(action, SCOPE_TYPE_CUSTOM); - } - - static Permission.DataAccessPredicate childrenPositionScope(String action) { - return positionScope(action, SCOPE_TYPE_CHILDREN); - } - - /* ===========人员===========*/ - - static Permission.DataAccessPredicate selfScope(String action) { - return personScope(action, SCOPE_TYPE_ONLY_SELF); - } - - static Permission.DataAccessPredicate personScope(String action, String type) { - return Permission.scope(action, PERSON_SCOPE, type); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DepartmentAttachEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DepartmentAttachEntity.java deleted file mode 100644 index 7b7dcdb29..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DepartmentAttachEntity.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * 关联部门信息的实体,实现此接口,才能对相应的操作进行部门相关的权限控制 - * - * @author zhouhao - * @since 3.0 - */ -public interface DepartmentAttachEntity extends Entity { - - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - String departmentId = "departmentId"; - - /** - * @return 部门ID - */ - String getDepartmentId(); - - void setDepartmentId(String departmentId); - - default String getDepartmentIdProperty() { - return departmentId; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DistrictAttachEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DistrictAttachEntity.java deleted file mode 100644 index 294556439..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/DistrictAttachEntity.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * @author zhouhao - */ -public interface DistrictAttachEntity extends Entity { - String districtId = "districtId"; - - String getDistrictId(); - - void setDistrictId(String districtId); - - default String getDistrictIdProperty() { - return districtId; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/OrgAttachEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/OrgAttachEntity.java deleted file mode 100644 index f0bc6b180..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/OrgAttachEntity.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * 关联机构信息实体,实现该接口,表示实体与机构进行关联,在进行权限控制时,将会使用到该接口 - * - * @author zhouhao - * @since 3.0 - */ -public interface OrgAttachEntity extends Entity { - String orgId = "orgId"; - - String getOrgId(); - - void setOrgId(String orgId); - - default String getOrgIdProperty() { - return orgId; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PersonAttachEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PersonAttachEntity.java deleted file mode 100644 index c3c13987a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PersonAttachEntity.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * 关联人员信息实体,实现该接口,表示实体与机构进行关联,在进行权限控制时,将会使用到该接口 - * @author zhouhao - */ -public interface PersonAttachEntity extends Entity { - String personId = "personId"; - - String getPersonId(); - - void setPersonId(String personId); - - default String getPersonIdProperty() { - return personId; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PositionAttachEntity.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PositionAttachEntity.java deleted file mode 100644 index 1c671e5a4..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/access/PositionAttachEntity.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.organizational.authorization.access; - -import org.hswebframework.web.commons.entity.Entity; - -/** - * @author zhouhao - */ -public interface PositionAttachEntity extends Entity { - String positionId = "positionId"; - - String getPositionId(); - - void setPositionId(String positionId); - - default String getPositionIdProperty() { - return positionId; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/DepartmentRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/DepartmentRelations.java deleted file mode 100644 index 5b8b68f79..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/DepartmentRelations.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - - -public interface DepartmentRelations extends LinkedRelations { - - /** - * 设置包含子级部门 - * - * @return 部门关系链 - */ - DepartmentRelations andChildren(); - - /** - * 设置包含父级部门 - * - * @return 部门关系链 - */ - DepartmentRelations andParents(); - - /** - * 获取部门下的人员关系链 - * - * @return 人员关系链 - */ - PersonRelations persons(); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/LinkedRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/LinkedRelations.java deleted file mode 100644 index 3090bd328..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/LinkedRelations.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - - -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public interface LinkedRelations { - - /** - * 获取指定方向以及维度的关系链,如: 我是李四的经理,张三是我的经理 - * - * @param direction 关系方向 {@link Relation.Direction} - * @param dimension 关系维度,如: position,由实现进行自定义 - * @param relation 关系定义,如: 直属领导 {@link Relation#getRelation()} - * @return 关系链 - * @see Relation#getRelation() - * @see Relation#getDirection() - */ - C relations(Relation.Direction direction, String dimension, String relation); - - /** - * 获取指定方向的所有维度的关系链. - *
-     *     正向: [我]是[张三]的[研发部(维度)][经理(关系)]
-     *     反向: [张三]是[我]的[研发部(维度)][经理(关系)]
-     *     双向: [正向]或者[反向]关系
-     * 
- * - * @param direction 方向 - * @param relation 关系定义 {@link Relation#getRelation()} - * @return 关系链 - * @see Relation#getRelation() - * @see Relation#getDirection() - * @see this#relations(Relation.Direction, String, String) - */ - default C relations(Relation.Direction direction, String relation) { - return relations(direction, null, relation); - } - - /** - * @see this#relations(Relation.Direction, String, String) - * @see Relation.Direction#REVERSE - */ - default C relationsRev(String type, String relation) { - return relations(Relation.Direction.REVERSE, type, relation); - } - - /** - * @see this#relations(Relation.Direction, String) - * @see Relation.Direction#REVERSE - */ - default C relationsRev(String relation) { - return relations(Relation.Direction.REVERSE, relation); - } - - - /** - * @see this#relations(Relation.Direction, String, String) - * @see Relation.Direction#POSITIVE - */ - default C relationsPos(String type, String relation) { - return relations(Relation.Direction.POSITIVE, type, relation); - } - - /** - * @see this#relations(Relation.Direction, String) - * @see Relation.Direction#POSITIVE - */ - default C relationsPos(String relation) { - return relations(Relation.Direction.POSITIVE, relation); - } - - /** - * @see this#relations(Relation.Direction, String, String) - * @see Relation.Direction#ALL - */ - default C relations(String type, String relation) { - return relations(Relation.Direction.ALL, type, relation); - } - - /** - * @see this#relations(Relation.Direction, String) - * @see Relation.Direction#ALL - */ - default C relations(String relation) { - return relations(Relation.Direction.ALL, relation); - } - - - /** - * 判断目标关系对象属性是否与值等于 - * - * @param property 属性名称,如: name - * @param value 属性指,如: 张三 - * @return 关系链 - */ - C is(String property, Object value); - - /** - * 判断目标关系对象属性是否不等于值 - * - * @param property 属性名称,如: name - * @param value 属性指,如: 张三 - * @return 关系链 - */ - C not(String property, Object value); - - /** - * 切换当前过滤逻辑为或则,如: - *
-     *     //获取姓名为张三或者李四的领导
-     *     me.relations("领导").is("name","张三").or().is("name","李四").all();
-     * 
- * - * @return 关系链 - */ - C or(); - - /** - * 切换当前过滤逻辑为并且 - *
-     *     //获取status为1并且email不为空的领导
-     *     me.relations("领导").is("status",1).and().not("email","").all();
-     * 
- * - * @return 关系链 - */ - C and(); - - /** - * @return 全部关系信息集合 - */ - default List all() { - return stream().collect(Collectors.toList()); - } - - /** - * 获取所有的关系目标标识,通常是人员的id - * - * @return 人员id - */ - default List allTarget() { - return stream().map(Relation::getTarget).collect(Collectors.toList()); - } - - /** - * @return 全部关系信息的stream - */ - Stream stream(); - - C deep(); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/OrgRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/OrgRelations.java deleted file mode 100644 index a8d2afec1..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/OrgRelations.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - - -public interface OrgRelations extends LinkedRelations { - - /** - * 设置包含子级机构 - * - * @return 机构关系链 - */ - OrgRelations andChildren(); - - /** - * 设置包含父级机构 - * - * @return 机构关系链 - */ - OrgRelations andParents(); - - /** - * 获取全部的部门关系链 - * - * @return 部门关系链 - */ - DepartmentRelations department(); - - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/PersonRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/PersonRelations.java deleted file mode 100644 index 2be1835da..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/PersonRelations.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -public interface PersonRelations extends LinkedRelations { - - /** - * @return 人员所在部门关系链 - */ - DepartmentRelations department(); - - /** - * @return 人员所在机构关系链 - */ - OrgRelations org(); - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relation.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relation.java deleted file mode 100644 index 6b4d177b5..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relation.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.io.Serializable; - -/** - * 关系,用于获取人员等关系信息 - * - * @author zhouhao - * @see Relations - * @since 3.0 - */ -public interface Relation extends Serializable { - - /** - * 默认类型:机构 - */ - String TYPE_ORG = "org"; - - /** - * 默认类型:部门 - */ - String TYPE_DEPARTMENT = "department"; - - /** - * 默认类型:岗位 - */ - String TYPE_POSITION = "position"; - - /** - * 默认类型:人员 - */ - String TYPE_PERSON = "person"; - - /** - * @return 关系维度,如:person,department - */ - String getDimension(); - - /** - * @return 关系,如: leader,member - */ - String getRelation(); - - /** - * @return 关系目标表识(和谁建立关系),通常为目标的id - */ - String getTarget(); - - /** - * @return 关系目标对象,用于获取建立关系对象完整信息,返回值的类型可能随着{@link this#getDimension()}的不同而变化 - * @see RelationTargetSupplier - */ - Serializable getTargetObject(); - - /** - * @return 关系名称,与{@link this#getDimension()} 对应,如: 经理,员工 - */ - String getName(); - - /** - * @return 关系的方向 - * @see Direction - */ - Direction getDirection(); - - /** - * 匹配方向,如果当前的方向为ALl,则全部返回true - *
-     *     direction=ALL;
-     *     matchDirection(POSITIVE) -> true
-     *     matchDirection(REVERSE) -> true
-     *     matchDirection(ALL) -> true
-     * 
- *

- *

-     *     direction=POSITIVE;
-     *     matchDirection(POSITIVE) -> true
-     *     matchDirection(REVERSE) -> false
-     *     matchDirection(ALL) -> false
-     * 
- * - * @param direction 要匹配的方向枚举 - * @return 匹配结果 - */ - default boolean matchDirection(Direction direction) { - return getDirection() == Direction.ALL || getDirection() == direction; - } - - /** - * 匹配方向,如果当前的方向为ALl,则全部返回true - *
-     *     direction=ALL;
-     *     matchDirection("A") -> true
-     *     matchDirection("ALL") -> true
-     *     matchDirection("R") -> true
-     *     matchDirection("P") -> true
-     *     matchDirection("O") -> false
-     * 
- *

- *

-     *     direction=POSITIVE;
-     *     matchDirection("P") -> true
-     *     matchDirection("POS") -> true
-     *     matchDirection("A") -> false
-     *     matchDirection("O") -> false
-     * 
- * - * @param direction 要匹配的方向字符 - * @return 匹配结果 - * @see Direction#fromString(String) - */ - default boolean matchDirection(String direction) { - return matchDirection(Direction.fromString(direction)); - } - - /** - * 关系方向,例如,我和张三建立关系,POSITIVE:我是张三的经理 ,REVERSE张三是我的经理 - * - * @author zhouhao - * @since 3.0 - */ - enum Direction { - /** - * 正向关系 - */ - POSITIVE, - /** - * 反向关系 - */ - REVERSE, - /** - * 双向关系 - */ - ALL; - - public static Direction fromString(String direction) { - if (direction == null) { - return null; - } - for (Direction dir : values()) { - //以名称开头则认为是同一个方向 - if (dir.name().startsWith(direction.toUpperCase())) { - return dir; - } - } - return null; - } - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetHolder.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetHolder.java deleted file mode 100644 index 903a2bc67..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetHolder.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * @author zhouhao - * @since 3.0 - */ -public final class RelationTargetHolder { - private static List suppliers = new ArrayList<>(16); - - @SuppressWarnings("unchecked") - public static Optional get(String type, String target) { - return (Optional) suppliers.stream() - .filter(supplier -> supplier.support(type, target)) - .map(supplier -> supplier.get(target)) - .findFirst(); - } - - static void addSupplier(RelationTargetSupplier supplier) { - suppliers.add(supplier); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplier.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplier.java deleted file mode 100644 index c583f622a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplier.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.io.Serializable; - -/** - * @author zhouhao - * @since 3.0 - */ -public interface RelationTargetSupplier { - - boolean support(String targetType, String target); - - Serializable get(String target); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplierAutoRegister.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplierAutoRegister.java deleted file mode 100644 index f6b7fecd9..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationTargetSupplierAutoRegister.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; - -/** - * @author zhouhao - * @since 3.0 - */ -public class RelationTargetSupplierAutoRegister implements BeanPostProcessor { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof RelationTargetSupplier) { - RelationTargetHolder.addSupplier(((RelationTargetSupplier) bean)); - } - return bean; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relations.java deleted file mode 100644 index c7c1e4f94..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/Relations.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.io.Serializable; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * 关系信息,用于获取,判断组织机构中的关系信息 - * - * @author zhouhao - * @see Relation - * @since 3.0 - */ -public interface Relations extends Serializable { - - /** - * 判断与目标是否存在某个关系 - *
-     *     //判断是否是张三的leader关系
-     *     relations.has("leader","person","张三",POSITIVE);
-     * 
- *
-     *     //判断张三是否是当前的leader关系
-     *     relations.has("leader","person","张三",REVERSE);
-     * 
- *
-     *     //判断人员:张三和本人是否相互为friend关系
-     *     relations.has("friend","person","张三",ALL);
-     * 
- * - * @param relation 关系 - * @param type 关系类型 - * @param to 目标 - * @return 是否存在关系 - */ - default boolean has(String relation, String type, String to, Relation.Direction direction) { - return getAll().stream().anyMatch(rel -> - rel.getRelation().equals(relation) - && rel.getDimension().equals(type) - && rel.getTarget().equals(to) - && rel.matchDirection(direction)); - } - - default boolean has(String relation, String type, Relation.Direction direction) { - return getAll().stream().anyMatch(rel -> - rel.getRelation().equals(relation) - && rel.getDimension().equals(type) - && rel.matchDirection(direction)); - } - - - default boolean has(String relation, Relation.Direction direction) { - return getAll().stream().anyMatch(rel -> - rel.getRelation().equals(relation) - && rel.matchDirection(direction)); - } - - /** - * @see this#has(String, String, String, Relation.Direction) - */ - default boolean has(String relation, String type, String to, String direction) { - return has(relation, type, to, Relation.Direction.fromString(direction)); - } - - /** - * use {@link Relation.Direction#POSITIVE} - * - * @see this#has(String, String, String, Relation.Direction) - */ - default boolean has(String relation) { - return !findAll(relation).isEmpty(); - } - - default boolean hasRev(String relation, String type, String to) { - return has(relation, type, to, Relation.Direction.REVERSE); - } - - default boolean hasPos(String relation, String type, String to) { - return has(relation, type, to, Relation.Direction.POSITIVE); - } - - default boolean hasRev(String relation, String type) { - return has(relation, type, Relation.Direction.REVERSE); - } - - default boolean hasPos(String relation, String type) { - return has(relation, type, Relation.Direction.POSITIVE); - } - - default boolean hasPos(String relation) { - return has(relation, Relation.Direction.POSITIVE); - } - - default boolean hasRev(String relation) { - return has(relation, Relation.Direction.REVERSE); - } - - /** - * 获取指定关系的全部关系信息 - * - * @param relation 关系标识,如: leader - * @return 关系信息集合,如果关系不存在,返回空集合 - * @see this#find(Predicate) - */ - default List findAll(String relation) { - return find(rel -> rel.getRelation().equals(relation)); - } - - /** - * 获取正向关系,如: 我是xxx的relation - * - * @param relation 关系标识,如: leader - * @return 关系信息集合,如果关系不存在,返回空集合 - */ - default List findPos(String relation) { - return find(relation, Relation.Direction.POSITIVE); - } - - /** - * 获取反向关系,如: xxx是我的relation - * - * @param relation 关系标识,如: leader - * @return 关系信息集合,如果关系不存在,返回空集合 - */ - default List findRev(String relation) { - return find(relation, Relation.Direction.REVERSE); - } - - /** - * 获取指定关系和方向的关系信息 - * - * @param relation 关系标识,例如: leader - * @param direction 关系方向 - * @return 关系信息集合,如果关系不存在,返回空集合 - */ - default List find(String relation, Relation.Direction direction) { - return find(rel -> rel.getRelation().equals(relation) && rel.matchDirection(direction)); - } - - /** - * 获取指定关系和维度的全部关系信息 - * - * @param relation 关系标识,例如: leader - * @param type 关系维度,例如:person - * @return 关系信息集合,如果关系不存在,返回空集合 - * @see this#find(Predicate) - */ - default List findAll(String relation, String type) { - return find(rel -> rel.getRelation().equals(relation) && rel.getDimension().equals(type)); - } - - /** - * 获取指定关系和类型以及方向反向关系 - * - * @param relation 关系标识,例如: leader - * @param type 关系类型,例如:person - * @return 关系信息集合,如果关系不存在,返回空集合 - * @see this#find(String, String, Relation.Direction) - */ - default List findRev(String relation, String type) { - return find(relation, type, Relation.Direction.REVERSE); - } - - /** - * 获取指定关系和类型以及方向正向关系 - * - * @param relation 关系标识,例如: leader - * @param type 关系类型,例如:person - * @return 关系信息集合,如果关系不存在,返回空集合 - * @see this#find(String, String, Relation.Direction) - */ - default List findPos(String relation, String type) { - return find(relation, type, Relation.Direction.POSITIVE); - } - - /** - * 获取指定关系和类型以及方向全部关系信息 - * - * @param relation 关系标识,例如: leader - * @param type 关系类型,例如:person - * @param direction 关系方向 - * @return 关系信息集合,如果关系不存在,返回空集合 - * @see this#find(Predicate) - */ - default List find(String relation, String type, Relation.Direction direction) { - return find(rel -> - rel.getRelation().equals(relation) - && rel.getDimension().equals(type) - && rel.matchDirection(direction)); - } - - /** - * @see this#find(String, String, Relation.Direction) - */ - default List find(String relation, String type, String direction) { - return find(relation, type, Relation.Direction.fromString(direction)); - } - - /** - * 查找关系 - *
-     *     findAll(rel->rel.getDimension().equals("person"))
-     * 
- * - * @param predicate 查找的判断逻辑 - * @return 满足条件的关系信息集合,如果全部不满足则返回空集合 - */ - default List find(Predicate predicate) { - return getAll().stream().filter(predicate).collect(Collectors.toList()); - } - - /** - * @return 全部关系信息,如果一个也没有返回空集合 - */ - List getAll(); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationsManager.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationsManager.java deleted file mode 100644 index 6714e46dd..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/RelationsManager.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.util.List; - -public interface RelationsManager { - - /** - * 根据人员id获取人员的关系链 - *
-     *     PersonRelations me = getPersonRelationsByPersonId(personId);
-     *     me.department().relations("总监").all()
-     * 
- * - * @param personId 人员id - * @return 人员关系链 - */ - PersonRelations getPersonRelationsByPersonId(String personId); - - PersonRelations getPersonRelationsByUserId(String userId); - - DepartmentRelations getDepartmentRelations(List departmentIds); - - OrgRelations getOrgRelations(List orgIds); - - LinkedRelations getRelations(List target); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelation.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelation.java deleted file mode 100644 index 0454cd6eb..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelation.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author zhouhao - */ -@Data -public class SimpleRelation implements Relation { - private static final long serialVersionUID = 1_0; - - private String dimension; - - private String relation; - - private String target; - - private Serializable targetObject; - - private String name; - - private Direction direction; - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelations.java deleted file mode 100644 index 06077c2d7..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/relation/SimpleRelations.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.organizational.authorization.relation; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @author zhouhao - */ -public class SimpleRelations implements Relations { - private static final long serialVersionUID = 1_0; - private List all; - @Override - public List getAll() { - if (null == all) { - all = new ArrayList<>(); - } - return all; - } - - public void setAll(List all) { - Objects.requireNonNull(all); - this.all = all; - } - - public SimpleRelations() { - } - - public SimpleRelations(List all) { - this.all = all; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScope.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScope.java deleted file mode 100644 index 6af24e0cf..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScope.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import java.io.Serializable; -import java.util.Set; - -/** - * 自定义范围 - * - * @author zhouhao - */ -public class CustomScope implements Serializable { - private static final long serialVersionUID = 1_0; - private String type; - - private Set ids; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Set getIds() { - return ids; - } - - public void setIds(Set ids) { - this.ids = ids; - } - - @Override - public int hashCode() { - return (type + "" + ids).hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof CustomScope && hashCode() == obj.hashCode(); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScopeDataAccessConfigConvert.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScopeDataAccessConfigConvert.java deleted file mode 100644 index 93077bc7b..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/CustomScopeDataAccessConfigConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.simple.builder.DataAccessConfigConvert; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; -import org.springframework.util.StringUtils; - -import java.util.Arrays; -import java.util.List; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.*; - -/** - * @author zhouhao - */ -public class CustomScopeDataAccessConfigConvert implements DataAccessConfigConvert { - private static final List supportTypes = Arrays.asList( - DataAccessType.SCOPE_TYPE_CUSTOM - ); - - @Override - public boolean isSupport(String type, String action, String config) { - return supportTypes.contains(type); - } - - @Override - public DataAccessConfig convert(String type, String action, String config) { - if (StringUtils.isEmpty(config)) { - config = "{}"; - } - SimpleCustomScopeDataAccessConfig accessConfig = JSON.parseObject(config, SimpleCustomScopeDataAccessConfig.class); - accessConfig.setAction(action); - - return accessConfig; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfig.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfig.java deleted file mode 100644 index 85bfcfe52..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.hswebframework.web.authorization.access.ScopeDataAccessConfig; -import org.hswebframework.web.authorization.simple.AbstractDataAccessConfig; - -import java.util.Set; - -/** - * @author zhouhao - * @since 3.0.5 - */ -@Getter -@Setter -@ToString -public class ScopeByUserDataAccessConfig extends AbstractDataAccessConfig implements ScopeDataAccessConfig { - - private static final long serialVersionUID = 6678003761927318688L; - - private String scopeType; - - private String scopeTypeName; - - private Set scope; - - private boolean children; - - @Override - public String getType() { - return "SCOPE_BY_USER"; - } - - @Override - public int hashCode() { - return (toString() + getAction()).hashCode(); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof ScopeByUserDataAccessConfig && obj.hashCode() == hashCode(); - } - - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfigConvert.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfigConvert.java deleted file mode 100644 index 24188c62a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeByUserDataAccessConfigConvert.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import com.alibaba.fastjson.JSON; -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.simple.AbstractDataAccessConfig; -import org.hswebframework.web.authorization.simple.builder.DataAccessConfigConvert; -import org.springframework.util.StringUtils; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.5 - */ -@Getter -@Setter -public class ScopeByUserDataAccessConfigConvert implements DataAccessConfigConvert { - - @Override - public boolean isSupport(String type, String action, String config) { - return "SCOPE_BY_USER".equalsIgnoreCase(type); - } - - @Override - public DataAccessConfig convert(String type, String action, String config) { - if (StringUtils.isEmpty(config)) { - config = "{}"; - } - ScopeByUserDataAccessConfig dataAccessConfig = JSON.parseObject(config, ScopeByUserDataAccessConfig.class); - dataAccessConfig.setAction(action); - return dataAccessConfig; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeDataAccessConfigConvert.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeDataAccessConfigConvert.java deleted file mode 100644 index a82d91e27..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/ScopeDataAccessConfigConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.simple.builder.DataAccessConfigConvert; -import org.springframework.util.StringUtils; - -import java.util.Arrays; -import java.util.List; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.*; - -/** - * @author zhouhao - */ -public class ScopeDataAccessConfigConvert implements DataAccessConfigConvert { - private static final List supportTypes = Arrays.asList( - DISTRICT_SCOPE, ORG_SCOPE, DEPARTMENT_SCOPE, POSITION_SCOPE, PERSON_SCOPE - ); - - @Override - public boolean isSupport(String type, String action, String config) { - return supportTypes.contains(type); - } - - @Override - public DataAccessConfig convert(String type, String action, String config) { - if (StringUtils.isEmpty(config)) { - config = "{}"; - } - SimpleScopeDataAccessConfig accessConfig = JSON.parseObject(config, SimpleScopeDataAccessConfig.class); - accessConfig.setAction(action); - accessConfig.setType(type); - return accessConfig; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleCustomScopeDataAccessConfig.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleCustomScopeDataAccessConfig.java deleted file mode 100644 index def047479..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleCustomScopeDataAccessConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import org.hswebframework.web.authorization.simple.AbstractDataAccessConfig; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; - -import java.util.Set; - -/** - * 自定义范围配置 - * - * @author zhouhao - */ -public class SimpleCustomScopeDataAccessConfig extends AbstractDataAccessConfig { - private static final long serialVersionUID = 1_0; - private Set scope; - - @Override - public String getType() { - return DataAccessType.SCOPE_TYPE_CUSTOM; - } - - public Set getScope() { - return scope; - } - - public void setScope(Set scope) { - this.scope = scope; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDepartment.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDepartment.java deleted file mode 100644 index 95d4c3ff0..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDepartment.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hswebframework.web.organizational.authorization.Department; -import org.hswebframework.web.organizational.authorization.Organization; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SimpleDepartment implements Department { - private static final long serialVersionUID = 1_0; - private String id; - private String name; - private String code; - private Organization org; -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDistrict.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDistrict.java deleted file mode 100644 index c2e233e28..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleDistrict.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hswebframework.web.organizational.authorization.District; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class SimpleDistrict implements District { - private static final long serialVersionUID = 1_0; - private String id; - private String name; - private String fullName; - private String code; -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleOrganization.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleOrganization.java deleted file mode 100644 index 631c3213f..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleOrganization.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hswebframework.web.organizational.authorization.District; -import org.hswebframework.web.organizational.authorization.Organization; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class SimpleOrganization implements Organization { - private static final long serialVersionUID = 1_0; - private String id; - private String name; - private String fullName; - private String code; - private District district; -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnel.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnel.java deleted file mode 100644 index ac66948ff..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnel.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hswebframework.web.organizational.authorization.Personnel; - -/** - * @author zhouhao - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -public class SimplePersonnel implements Personnel { - private static final long serialVersionUID = 1_0; - private String id; - private String name; - private String phone; - private String photo; - private String email; -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthentication.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthentication.java deleted file mode 100644 index aef7f70db..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthentication.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import org.hswebframework.web.organizational.authorization.*; -import org.hswebframework.web.organizational.authorization.relation.Relations; - -import java.util.Collections; -import java.util.Set; - -/** - * @author zhouhao - */ -public class SimplePersonnelAuthentication implements PersonnelAuthentication { - private static final long serialVersionUID = 1_0; - private Personnel personnel; - private Set> districtIds; - private Set> orgIds; - private Set> positionIds; - private Set> departmentIds; - private Relations relations; - private Set positions; - - public void setPositions(Set positions) { - this.positions = positions; - } - - @Override - public Set getPositions() { - return positions; - } - - @Override - public Personnel getPersonnel() { - return personnel; - } - - public void setPersonnel(Personnel personnel) { - this.personnel = personnel; - } - - @Override - public Set> getDistrictIds() { - if (districtIds == null) { - districtIds = new java.util.HashSet<>(); - } - return districtIds; - } - - public void setDistrictIds(Set> districtIds) { - this.districtIds = districtIds; - } - - @Override - public Relations getRelations() { - return relations; - } - - public void setRelations(Relations relations) { - this.relations = relations; - } - - @Override - public Set> getOrgIds() { - if (orgIds == null) { - orgIds = new java.util.HashSet<>(); - } - return orgIds; - } - - public void setOrgIds(Set> orgIds) { - this.orgIds = orgIds; - } - - @Override - public Set> getPositionIds() { - if (positionIds == null) { - positionIds = new java.util.HashSet<>(); - } - return positionIds; - } - - public void setPositionIds(Set> positionIds) { - this.positionIds = positionIds; - } - - @Override - public Set> getDepartmentIds() { - if (departmentIds == null) { - departmentIds = new java.util.HashSet<>(); - } - return departmentIds; - } - - public void setDepartmentIds(Set> departmentIds) { - this.departmentIds = departmentIds; - } - - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthorizationBuilder.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthorizationBuilder.java deleted file mode 100644 index 3d58c335c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthorizationBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import com.alibaba.fastjson.JSON; -import org.hswebframework.web.bean.BeanFactory; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.organizational.authorization.*; -import org.hswebframework.web.organizational.authorization.relation.Relation; -import org.hswebframework.web.organizational.authorization.relation.Relations; -import org.hswebframework.web.organizational.authorization.relation.SimpleRelation; -import org.hswebframework.web.organizational.authorization.relation.SimpleRelations; - -import java.util.Map; - -public class SimplePersonnelAuthorizationBuilder { - private static FastBeanCopier.DefaultConverter converter = new FastBeanCopier.DefaultConverter(); - - static { - converter.setBeanFactory(new BeanFactory() { - @Override - @SuppressWarnings("all") - public T newInstance(Class targetClass) { - if (targetClass == Position.class) { - return (T) new SimplePosition(); - } - if (targetClass == Personnel.class) { - return (T) new SimplePersonnel(); - } - if (targetClass == Department.class) { - return (T) new SimpleDepartment(); - } - if (targetClass == Organization.class) { - return (T) new SimpleOrganization(); - } - if (targetClass == District.class) { - return (T) new SimpleDistrict(); - } - if (targetClass == Relation.class) { - return (T) new SimpleRelation(); - } - if (targetClass == Relations.class) { - return (T) new SimpleRelations(); - } - return FastBeanCopier.getBeanFactory().newInstance(targetClass); - } - }); - } - - public static SimplePersonnelAuthentication fromJson(String json) { - return fromMap(JSON.parseObject(json)); - } - - public static SimplePersonnelAuthentication fromMap(Map map) { - return FastBeanCopier.copy(map, new SimplePersonnelAuthentication(), converter); - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePosition.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePosition.java deleted file mode 100644 index f8c982068..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimplePosition.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hswebframework.web.organizational.authorization.Department; -import org.hswebframework.web.organizational.authorization.Position; - -/** - * @author zhouhao - * @since 3.0 - */ -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class SimplePosition implements Position { - private static final long serialVersionUID = 1_0; - private String id; - - private String name; - - private String code; - - private Department department; -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleScopeDataAccessConfig.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleScopeDataAccessConfig.java deleted file mode 100644 index 7851816cc..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/SimpleScopeDataAccessConfig.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import org.hswebframework.web.authorization.simple.AbstractDataAccessConfig; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; -import org.hswebframework.web.authorization.access.ScopeDataAccessConfig; - -import java.util.Set; - -/** - * @author zhouhao - * @since 3.0 - */ -public class SimpleScopeDataAccessConfig extends AbstractDataAccessConfig implements ScopeDataAccessConfig { - private static final long serialVersionUID = 1_0; - private String scopeType; - private Set scope; - private String type; - - public SimpleScopeDataAccessConfig() { - } - - public SimpleScopeDataAccessConfig(String scopeType) { - this.scopeType = scopeType; - } - - public SimpleScopeDataAccessConfig(String scopeType, Set scope) { - this.scopeType = scopeType; - this.scope = scope; - } - - public SimpleScopeDataAccessConfig(String type, String scopeType, String action, Set scope) { - this.scopeType = scopeType; - this.scope = scope; - this.type = type; - setAction(action); - } - - @Override - public String getScopeType() { - return scopeType; - } - - public void setScopeType(String scopeType) { - this.scopeType = scopeType; - } - - @Override - public Set getScope() { - return scope; - } - - public void setScope(Set scope) { - this.scope = scope; - } - - @Override - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/AbstractScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/AbstractScopeDataAccessHandler.java deleted file mode 100644 index a5c118ff2..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/AbstractScopeDataAccessHandler.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.utils.ClassUtils; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.access.DataAccessHandler; -import org.hswebframework.web.authorization.access.ScopeDataAccessConfig; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.QueryController; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; -import org.hswebframework.web.service.QueryService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author zhouhao - */ -public abstract class AbstractScopeDataAccessHandler implements DataAccessHandler { - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - private boolean defaultSuccessOnError = true; - - protected abstract Class getEntityClass(); - - protected abstract String getSupportScope(); - - protected abstract String getOperationScope(E entity); - - protected abstract void applyScopeProperty(E entity, String value); - - protected abstract Term createQueryTerm(Set scope, AuthorizingContext context); - - protected abstract Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization); - - @Override - public boolean isSupport(DataAccessConfig access) { - return access instanceof ScopeDataAccessConfig && access.getType().equals(getSupportScope()); - } - - @Override - public boolean handle(DataAccessConfig access, AuthorizingContext context) { - ScopeDataAccessConfig accessConfig = ((ScopeDataAccessConfig) access); - if (!PersonnelAuthentication.current().isPresent()) { - return false; - } - switch (accessConfig.getAction()) { - case Permission.ACTION_QUERY: - return handleQuery(accessConfig, context); - case Permission.ACTION_GET: - case Permission.ACTION_DELETE: - case Permission.ACTION_UPDATE: - return handleRW(accessConfig, context); - case Permission.ACTION_ADD: - return handleAdd(accessConfig, context); - default: - return false; - } - } - - protected PersonnelAuthentication getPersonnelAuthorization() { - return PersonnelAuthentication.current() - .orElseThrow(AccessDenyException::new); - } - - protected boolean handleAdd(ScopeDataAccessConfig access, AuthorizingContext context) { - Set scopes = getTryOperationScope(access); - String scope; - if (scopes.isEmpty()) { - return true; - } else if (scopes.size() == 1) { - scope = scopes.iterator().next(); - } else { - scope = scopes.iterator().next(); - logger.warn("existing many scope :{} , try use config.", scope); - } - if (scope != null) { - context.getParamContext().getParams().values().stream() - .filter(getEntityClass()::isInstance) - .map(getEntityClass()::cast) - .forEach(entity -> applyScopeProperty(entity, scope)); - } else { - logger.warn("scope is null!"); - } - return defaultSuccessOnError; - } - - protected boolean handleRW(ScopeDataAccessConfig access, AuthorizingContext context) { - //获取注解 - Object id = context.getParamContext() - .getParameter( - context.getDefinition() - .getDataAccessDefinition() - .getIdParameterName()) - .orElse(null); - - Object controller = context.getParamContext().getTarget(); - Set ids = getTryOperationScope(access); - String errorMsg; - //通过QueryController获取QueryService - //然后调用selectByPk 查询旧的数据,进行对比 - if (controller instanceof QueryController) { - //判断是否满足条件(泛型为 getEntityClass) - Class entityType = ClassUtils.getGenericType(controller.getClass(), 0); - if (ClassUtils.instanceOf(entityType, getEntityClass())) { - @SuppressWarnings("unchecked") - QueryService queryService = ((QueryController) controller).getService(); - E oldData = queryService.selectByPk(id); - return !(oldData != null && !ids.contains(getOperationScope(oldData))); - } else { - errorMsg = "GenericType[0] not instance of " + getEntityClass(); - } - } else { - errorMsg = "target not instance of QueryController"; - } - logger.warn("do handle {} fail,because {}", access.getAction(), errorMsg); - return defaultSuccessOnError; - } - - protected Set getTryOperationScope(ScopeDataAccessConfig access) { - if (DataAccessType.SCOPE_TYPE_CUSTOM.equals(access.getScopeType())) { - return access.getScope().stream().map(String::valueOf).collect(Collectors.toSet()); - } - return getTryOperationScope(access.getScopeType(), getPersonnelAuthorization()); - } - - protected boolean handleQuery(ScopeDataAccessConfig access, AuthorizingContext context) { - Entity entity = context.getParamContext().getParams() - .values().stream() - .filter(Entity.class::isInstance) - .map(Entity.class::cast) - .findAny().orElse(null); - if (entity == null) { - logger.warn("try validate query access, but query entity is null or not instance of org.hswebframework.web.commons.entity.Entity"); - return defaultSuccessOnError; - } - Set scope = getTryOperationScope(access); - if (scope.isEmpty()) { - logger.warn("try validate query access,but config is empty!"); - return defaultSuccessOnError; - } - if (entity instanceof QueryParamEntity) { - if (logger.isDebugEnabled()) { - logger.debug("try rebuild query param ..."); - } - - //重构查询条件 - //如: 旧的条件为 where name =? or name = ? - //重构后为: where org_id in(?,?) and (name = ? or name = ?) - QueryParamEntity queryParamEntity = ((QueryParamEntity) entity); - queryParamEntity.toNestQuery(query-> query.accept(createQueryTerm(scope, context))); - -// //重构查询条件 -// //如: 旧的条件为 where name =? or name = ? -// //重构后为: where org_id in(?,?) and (name = ? or name = ?) -// List oldParam = queryParamEntity.getTerms(); -// //清空旧的查询条件 -// queryParamEntity.setTerms(new ArrayList<>()); -// //添加一个查询条件 -// queryParamEntity -// .addTerm(createQueryTerm(scope, context)) -// //客户端提交的参数 作为嵌套参数 -// .nest().setTerms(oldParam); - } else { - logger.warn("try validate query access,but entity not support, QueryParamEntity support now!"); - } - return true; - } - - protected boolean genericTypeInstanceOf(Class type, AuthorizingContext context) { - Class entity = ClassUtils.getGenericType(context.getParamContext().getTarget().getClass()); - return null != entity && ClassUtils.instanceOf(entity, type); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/CustomScopeHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/CustomScopeHandler.java deleted file mode 100644 index 34d9bf601..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/CustomScopeHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.access.DataAccessHandler; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; -import org.hswebframework.web.organizational.authorization.simple.SimpleCustomScopeDataAccessConfig; -import org.hswebframework.web.organizational.authorization.simple.SimpleScopeDataAccessConfig; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - -/** - * @author zhouhao - */ -public class CustomScopeHandler implements DataAccessHandler { - - private List handlers = Arrays.asList( - new DistrictScopeDataAccessHandler(), - new DepartmentScopeDataAccessHandler(), - new OrgScopeDataAccessHandler(), - new PersonScopeDataAccessHandler(), - new PositionScopeDataAccessHandler() - ); - - @Override - public boolean isSupport(DataAccessConfig access) { - return access instanceof SimpleCustomScopeDataAccessConfig; - } - - @Override - public boolean handle(DataAccessConfig access, AuthorizingContext context) { - return ((SimpleCustomScopeDataAccessConfig) access).getScope() - .stream() - .map(scope -> new SimpleScopeDataAccessConfig(scope.getType(), DataAccessType.SCOPE_TYPE_CUSTOM, access.getAction(), new HashSet<>(scope.getIds()))) - .allMatch(accessConfig -> handlers.stream() - .filter(handler -> handler.isSupport(accessConfig)) - .allMatch(handler -> handler.handle(accessConfig, context))); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DepartmentScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DepartmentScopeDataAccessHandler.java deleted file mode 100644 index 1ec4c5712..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DepartmentScopeDataAccessHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.DepartmentAttachEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; - -import java.util.Collections; -import java.util.Set; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_CHILDREN; -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_ONLY_SELF; - -/** - * @author zhouhao - */ -public class DepartmentScopeDataAccessHandler extends AbstractScopeDataAccessHandler { - @Override - protected Class getEntityClass() { - return DepartmentAttachEntity.class; - } - - @Override - protected void applyScopeProperty(DepartmentAttachEntity entity, String value) { - entity.setDepartmentId(value); - } - - @Override - protected String getSupportScope() { - return DataAccessType.DEPARTMENT_SCOPE; - } - - @Override - protected String getOperationScope(DepartmentAttachEntity entity) { - return entity.getDepartmentId(); - } - - @Override - protected Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization) { - switch (scopeType) { - case SCOPE_TYPE_CHILDREN: - return authorization.getAllDepartmentId(); - case SCOPE_TYPE_ONLY_SELF: - return authorization.getRootDepartmentId(); - default: - return new java.util.HashSet<>(); - } - } - - @Override - protected Term createQueryTerm(Set scope, AuthorizingContext context) { - Term term = new Term(); - term.setColumn(DepartmentAttachEntity.departmentId); - term.setTermType(TermType.in); - term.setValue(scope); - term.setType(Term.Type.and); - return term; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DistrictScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DistrictScopeDataAccessHandler.java deleted file mode 100644 index 751758402..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DistrictScopeDataAccessHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.DistrictAttachEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; - -import java.util.Collections; -import java.util.Set; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.*; - -/** - * @author zhouhao - */ -public class DistrictScopeDataAccessHandler extends AbstractScopeDataAccessHandler { - @Override - protected Class getEntityClass() { - return DistrictAttachEntity.class; - } - - @Override - protected String getSupportScope() { - return DISTRICT_SCOPE; - } - - @Override - protected String getOperationScope(DistrictAttachEntity entity) { - return entity.getDistrictId(); - } - - @Override - protected void applyScopeProperty(DistrictAttachEntity entity, String value) { - entity.setDistrictId(value); - } - - @Override - protected Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization) { - switch (scopeType) { - case SCOPE_TYPE_CHILDREN: - return authorization.getAllDistrictId(); - case SCOPE_TYPE_ONLY_SELF: - return authorization.getRootDistrictId(); - default: - return new java.util.HashSet<>(); - } - } - - @Override - protected Term createQueryTerm(Set scope, AuthorizingContext context) { - Term term = new Term(); - term.setColumn(DistrictAttachEntity.districtId); - term.setTermType(TermType.in); - term.setValue(scope); - term.setType(Term.Type.and); - return term; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/OrgScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/OrgScopeDataAccessHandler.java deleted file mode 100644 index ccc714fcb..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/OrgScopeDataAccessHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.OrgAttachEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; - -import java.util.Collections; -import java.util.Set; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_CHILDREN; -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_ONLY_SELF; - -/** - * @author zhouhao - */ -public class OrgScopeDataAccessHandler extends AbstractScopeDataAccessHandler { - @Override - protected Class getEntityClass() { - return OrgAttachEntity.class; - } - - @Override - protected String getSupportScope() { - return DataAccessType.ORG_SCOPE; - } - - @Override - protected void applyScopeProperty(OrgAttachEntity entity, String value) { - entity.setOrgId(value); - } - - @Override - protected Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization) { - switch (scopeType) { - case SCOPE_TYPE_CHILDREN: - return authorization.getAllOrgId(); - case SCOPE_TYPE_ONLY_SELF: - return authorization.getRootOrgId(); - default: - return new java.util.HashSet<>(); - } - } - - @Override - protected String getOperationScope(OrgAttachEntity entity) { - return entity.getOrgId(); - } - - @Override - protected Term createQueryTerm(Set scope, AuthorizingContext context) { - Term term = new Term(); - term.setColumn(OrgAttachEntity.orgId); - term.setTermType(TermType.in); - term.setValue(scope); - term.setType(Term.Type.and); - return term; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PersonScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PersonScopeDataAccessHandler.java deleted file mode 100644 index 8fe5c9841..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PersonScopeDataAccessHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.PersonAttachEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; - -import java.util.Collections; -import java.util.Set; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_CHILDREN; -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_ONLY_SELF; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public class PersonScopeDataAccessHandler extends AbstractScopeDataAccessHandler { - @Override - protected Class getEntityClass() { - return PersonAttachEntity.class; - } - - @Override - protected String getSupportScope() { - return DataAccessType.PERSON_SCOPE; - } - - @Override - protected Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization) { - switch (scopeType) { - case SCOPE_TYPE_CHILDREN: - logger.warn("not support person children control!"); - case SCOPE_TYPE_ONLY_SELF: - return Collections.singleton(authorization.getPersonnel().getId()); - default: - return new java.util.HashSet<>(); - } - } - - @Override - protected void applyScopeProperty(PersonAttachEntity entity, String value) { - entity.setPersonId(value); - } - - @Override - protected String getOperationScope(PersonAttachEntity entity) { - return entity.getPersonId(); - } - - @Override - protected Term createQueryTerm(Set scope, AuthorizingContext context) { - Term term = new Term(); - term.setColumn(PersonAttachEntity.personId); - term.setTermType(TermType.in); - term.setValue(scope); - term.setType(Term.Type.and); - return term; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PositionScopeDataAccessHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PositionScopeDataAccessHandler.java deleted file mode 100644 index aa42d2a20..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/PositionScopeDataAccessHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.organizational.authorization.access.PositionAttachEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.DataAccessType; - -import java.util.Collections; -import java.util.Set; - -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_CHILDREN; -import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_ONLY_SELF; - -/** - * @author zhouhao - */ -public class PositionScopeDataAccessHandler extends AbstractScopeDataAccessHandler { - @Override - protected Class getEntityClass() { - return PositionAttachEntity.class; - } - - @Override - protected String getSupportScope() { - return DataAccessType.POSITION_SCOPE; - } - - @Override - protected Set getTryOperationScope(String scopeType, PersonnelAuthentication authorization) { - switch (scopeType) { - case SCOPE_TYPE_CHILDREN: - return authorization.getAllPositionId(); - case SCOPE_TYPE_ONLY_SELF: - return authorization.getRootPositionId(); - default: - return new java.util.HashSet<>(); - } - } - - @Override - protected void applyScopeProperty(PositionAttachEntity entity, String value) { - entity.setPositionId(value); - } - - @Override - protected String getOperationScope(PositionAttachEntity entity) { - return entity.getPositionId(); - } - - @Override - protected Term createQueryTerm(Set scope, AuthorizingContext context) { - Term term = new Term(); - term.setColumn(PositionAttachEntity.positionId); - term.setTermType(TermType.in); - term.setValue(scope); - term.setType(Term.Type.and); - return term; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/ScopeByUserHandler.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/ScopeByUserHandler.java deleted file mode 100644 index 31ee0d039..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/ScopeByUserHandler.java +++ /dev/null @@ -1,476 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple.handler; - -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.authorization.access.DataAccessConfig; -import org.hswebframework.web.authorization.access.DataAccessHandler; -import org.hswebframework.web.authorization.access.UserAttachEntity; -import org.hswebframework.web.authorization.define.AuthorizingContext; -import org.hswebframework.web.authorization.define.Phased; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.RecordCreationEntity; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.QueryController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.access.*; -import org.hswebframework.web.organizational.authorization.simple.ScopeByUserDataAccessConfig; -import org.hswebframework.web.service.QueryService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.*; - -/** - * @author zhouhao - * @since 3.0.5 - */ -@Slf4j -@SuppressWarnings("all") -public class ScopeByUserHandler implements DataAccessHandler { - - @Autowired - private EntityFactory entityFactory; - - @Override - public boolean isSupport(DataAccessConfig access) { - return access instanceof ScopeByUserDataAccessConfig; - } - - @Override - public boolean handle(DataAccessConfig access, AuthorizingContext context) { - ScopeByUserDataAccessConfig scope = ((ScopeByUserDataAccessConfig) access); - switch (access.getAction()) { - case Permission.ACTION_QUERY: - case Permission.ACTION_GET: - return doQueryAccess(scope, context); - case Permission.ACTION_ADD: - case Permission.ACTION_UPDATE: - default: - return doUpdateAccess(scope, context); - } - } - - protected boolean supportChildSqlTerm() { - return Dialect.H2.isSupportTermType("user-in-org"); - } - - protected boolean doUpdateAccess(ScopeByUserDataAccessConfig config, AuthorizingContext context) { - //获取id参数 - Object id = context.getParamContext() - .getParameter(context.getDefinition().getDataAccessDefinition().getIdParameterName()) - .orElse(null); - if (id == null) { - return true; - } - PersonnelAuthentication authentication = PersonnelAuthentication - .current().orElse(null); - if (authentication == null) { - log.warn("当前用户没有关联人员信息!"); - return false; - } - ScopeInfo scopeInfo = getScope(config, authentication); - if (scopeInfo.isEmpty()) { - return false; - } - Object controller = context.getParamContext().getTarget(); - QueryService queryService = null; - - if (controller instanceof QueryController) { - queryService = ((QueryController) controller).getService(); - } else { - Method getService = ReflectionUtils.findMethod(controller.getClass(), "getService"); - if (getService != null) { - try { - Object service = ReflectionUtils.invokeMethod(getService, controller); - if (service instanceof QueryService) { - queryService = ((QueryService) service); - } - } catch (Exception ignore) { - - } - } - } - if (queryService != null) { - ControllerCache controllerCache = getControllerCache(config, context); - Object entity = queryService.selectByPk(id); - if (null != entity) { - String targetId = controllerCache.targetIdGetter.apply(entity); - if (targetId == null) { - return true; - } - log.debug("执行数据权限控制,范围:{},结果:{}", scopeInfo.scope, targetId); - return scopeInfo.allScope.contains(controllerCache.targetIdGetter.apply(entity)); - } - } else { - log.debug("Controller没有实现任何通用CURD功能,无法进行数据权限控制!"); - } - return true; - - } - - @SneakyThrows - private ScopeInfo getScope(ScopeByUserDataAccessConfig config, PersonnelAuthentication authentication) { - String termType = null, personTermType = "in"; - Set scope = null, allScope = null; - ScopeInfo scopeInfo = new ScopeInfo(); - if (authentication == null) { - return scopeInfo; - } - Consumer> consumer; - boolean supportChildTerm = supportChildSqlTerm(); - - switch (config.getScopeType()) { - case "OWN_PERSON": - termType = "in"; - scope = Collections.singleton(authentication.getPersonnel().getId()); - allScope = scope; - break; - case "OWN_USER": - termType = "in"; - scope = Collections.singleton(Authentication - .current() - .map(Authentication::getUser) - .map(User::getId) - .orElseThrow(AccessDenyException::new)); - allScope = scope; - break; - case DataAccessType.ORG_SCOPE: - termType = supportChildTerm ? "user-in-org" : "in"; - personTermType = supportChildTerm ? "person-in-org" : "in"; - scope = config.isChildren() && !supportChildTerm ? authentication.getAllOrgId() : authentication.getRootOrgId(); - allScope = config.isChildren() ? authentication.getAllOrgId() : scope; - break; - case DataAccessType.DEPARTMENT_SCOPE: - termType = supportChildTerm ? "user-in-department" : "in"; - personTermType = supportChildTerm ? "person-in-department" : "in"; - scope = config.isChildren() && !supportChildTerm ? authentication.getAllDepartmentId() : authentication.getRootDepartmentId(); - allScope = config.isChildren() ? authentication.getAllDepartmentId() : scope; - break; - case DataAccessType.POSITION_SCOPE: - termType = supportChildTerm ? "user-in-position" : "in"; - personTermType = supportChildTerm ? "person-in-position" : "in"; - scope = config.isChildren() && !supportChildTerm ? authentication.getAllPositionId() : authentication.getRootPositionId(); - allScope = config.isChildren() ? authentication.getAllPositionId() : scope; - break; - case DataAccessType.DISTRICT_SCOPE: - termType = supportChildTerm ? "user-in-dist" : "in"; - personTermType = supportChildTerm ? "person-in-dist" : "in"; - scope = config.isChildren() && !supportChildTerm ? authentication.getAllDistrictId() : authentication.getRootDistrictId(); - allScope = config.isChildren() ? authentication.getAllDistrictId() : scope; - break; - case "CUSTOM_SCOPE_ORG": - termType = supportChildSqlTerm() ? "user-in-org" : "in"; - personTermType = supportChildSqlTerm() ? "person-in-org" : "in"; - scope = config.getScope(); - allScope = scope; - break; - case "CUSTOM_SCOPE_POSITION": - termType = supportChildSqlTerm() ? "user-in-position" : "in"; - personTermType = supportChildSqlTerm() ? "person-in-position" : "in"; - scope = config.getScope(); - allScope = scope; - break; - case "CUSTOM_SCOPE_DEPT": - termType = supportChildSqlTerm() ? "user-in-department" : "in"; - personTermType = supportChildSqlTerm() ? "person-in-department" : "in"; - scope = config.getScope(); - allScope = scope; - break; - case "CUSTOM_SCOPE_DIST": - termType = supportChildSqlTerm() ? "user-in-dist" : "in"; - personTermType = supportChildSqlTerm() ? "person-in-dist" : "in"; - scope = config.getScope(); - allScope = scope; - break; - default: - log.warn("不支持的数据权限范围:{}", config.getScopeType()); - } - if (termType == null) { - return scopeInfo; - } - scopeInfo.scope = new ArrayList<>(scope); - scopeInfo.allScope = new ArrayList<>(allScope); - scopeInfo.termType = termType; - if (config.isChildren()) { - if (!termType.equals("in")) { - scopeInfo.termType = termType.concat("-child"); - } - if (!personTermType.equals("in")) { - scopeInfo.personTermType = personTermType.concat("-child"); - } - } - return scopeInfo; - - } - - class ScopeInfo { - String termType; - String personTermType; - - List scope; - List allScope; - - Consumer> notUserConsumer; - - public boolean isEmpty() { - return termType == null || scope == null || scope.isEmpty(); - } - } - - static Function defaultTargetIdGetter = entity -> { - Map userInfo = FastBeanCopier.copy(entity, new HashMap<>(), FastBeanCopier.include("creatorId", "userId")); - return userInfo.getOrDefault("userId", userInfo.get("creatorId")); - }; - - protected Function createTargetIdGetter(Class entityClass, String... properties) { - String useProperty = null; - for (String property : properties) { - Field field = ReflectionUtils.findField(entityClass, property); - if (field != null) { - useProperty = property; - } - } - if (useProperty == null) { - log.debug("类[{}]中未包含字段[{}],可能无法进行数据权限控制.", entityClass, Arrays.asList(properties)); - } - return entity -> { - Map userInfo = FastBeanCopier.copy(entity, new HashMap<>(), FastBeanCopier.include(properties)); - for (String property : properties) { - String value = userInfo.get(property); - if (value != null) { - return value; - } - } - return null; - }; - } - - static BiConsumer, ScopeInfo> defaultQueryConsumer = (query, scopeInfo) -> { - query.and("creatorId", scopeInfo.termType, scopeInfo.scope); - }; - static Function> defaultScopeGetter = context -> { - return Collections.singleton(context.getAuthentication().getUser().getId()); - }; - - private Function createGetter(Class type, Function getter) { - return entity -> { - if (type.isInstance(entity)) { - return getter.apply(((E) entity)); - } - return defaultTargetIdGetter.apply(entity); - }; - } - - // static Map cache = new ConcurrentHashMap<>(); - - protected String getControlProperty(Class type, Function function) { - return function.apply((T) entityFactory.newInstance(type)); -// return cache.computeIfAbsent(type, t -> { -// return function.apply((T) entityFactory.newInstance(type)); -// }); - } - - class ControllerCache { - Function targetIdGetter = defaultTargetIdGetter; - - BiConsumer, ScopeInfo> queryConsumer = defaultQueryConsumer; - - Function> scopeGetter = defaultScopeGetter; - } - - @EqualsAndHashCode - @Getter - @Setter - class CacheKey { - private String className; - - private String method; - - private boolean children; - - private String type; - - private boolean queryController; - } - - static Map cacheMap = new ConcurrentHashMap<>(); - - - private ControllerCache getControllerCache(ScopeByUserDataAccessConfig config, AuthorizingContext context) { - Class controller = ClassUtils.getUserClass(context.getParamContext().getTarget().getClass()); - CacheKey cacheKey = new CacheKey(); - cacheKey.children = config.isChildren(); - cacheKey.className = controller.getName(); - cacheKey.method = context.getParamContext().getMethod().toString(); - cacheKey.type = config.getScopeType(); - cacheKey.queryController = context.getParamContext().getTarget() instanceof QueryController; - Class dataAccessEntityType = context.getDefinition().getDataAccessDefinition().getEntityType(); - - return cacheMap.computeIfAbsent(cacheKey, key -> { - ControllerCache controllerCache = new ControllerCache(); - Class entityClass = dataAccessEntityType; - if (entityClass == Void.class) { - if (key.queryController) { - entityClass = org.hswebframework.utils.ClassUtils.getGenericType(controller, 0); - } - } - boolean children = key.isChildren(); - //控制机构 - if (key.getType().contains("ORG") && OrgAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, OrgAttachEntity::getOrgIdProperty); - controllerCache.targetIdGetter = createGetter(OrgAttachEntity.class, OrgAttachEntity::getOrgId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, children && supportChildSqlTerm() ? "org-child-in" : "in", scopeInfo.scope); - }; - //部门 - } else if (key.getType().contains("DEPT") && DepartmentAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, DepartmentAttachEntity::getDepartmentIdProperty); - controllerCache.targetIdGetter = createGetter(DepartmentAttachEntity.class, DepartmentAttachEntity::getDepartmentId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, children && supportChildSqlTerm() ? "dept-child-in" : "in", scopeInfo.scope); - }; - //岗位 - } else if (key.getType().contains("POS") && PositionAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, PositionAttachEntity::getPositionIdProperty); - controllerCache.targetIdGetter = createGetter(PositionAttachEntity.class, PositionAttachEntity::getPositionId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, children && supportChildSqlTerm() ? "pos-child-in" : "in", scopeInfo.scope); - }; - //行政区划 - } else if (key.getType().contains("DIST") && DistrictAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, DistrictAttachEntity::getDistrictIdProperty); - controllerCache.targetIdGetter = createGetter(DistrictAttachEntity.class, DistrictAttachEntity::getDistrictId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, children && supportChildSqlTerm() ? "dist-child-in" : "in", scopeInfo.scope); - }; - //人员 - } else if (key.getType().contains("PERSON") && PersonAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, PersonAttachEntity::getPersonIdProperty); - controllerCache.targetIdGetter = createGetter(PersonAttachEntity.class, PersonAttachEntity::getPersonId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, scopeInfo.personTermType, scopeInfo.scope); - }; - //根据用户控制 - } else { - if (UserAttachEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, UserAttachEntity::getUserIdProperty); - controllerCache.targetIdGetter = createGetter(UserAttachEntity.class, UserAttachEntity::getUserId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, scopeInfo.termType, scopeInfo.scope); - }; - } else if (RecordCreationEntity.class.isAssignableFrom(entityClass)) { - String property = getControlProperty(entityClass, RecordCreationEntity::getCreatorIdProperty); - controllerCache.targetIdGetter = createGetter(RecordCreationEntity.class, RecordCreationEntity::getCreatorId); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, scopeInfo.termType, scopeInfo.scope); - }; - } else { - String property = getUserField(entityClass); - controllerCache.targetIdGetter = createTargetIdGetter(entityClass, property); - controllerCache.queryConsumer = (query, scopeInfo) -> { - query.and(property, scopeInfo.termType, scopeInfo.scope); - }; - } - } - return controllerCache; - }); - } - - protected boolean doQueryAccess(ScopeByUserDataAccessConfig config, AuthorizingContext context) { - PersonnelAuthentication authentication = PersonnelAuthentication - .current() - .orElseThrow(AccessDenyException::new); - ScopeInfo scopeInfo = getScope(config, authentication); - if (scopeInfo.isEmpty()) { - return false; - } - ControllerCache controllerCache = getControllerCache(config, context); - - //如果是执行后 - if (context.getDefinition().getDataAccessDefinition().getPhased() == Phased.after) { - Object result = context.getParamContext().getInvokeResult(); - if (result == null) { - return true; - } - result = getRealResult(result); - Predicate predicate = (o) -> { - String value = controllerCache.targetIdGetter.apply(o); - if (value == null) { - return true; - } - log.debug("执行数据权限控制[{}],scope:{},target:{}", config.getScopeTypeName(), scopeInfo.scope, value); - return scopeInfo.allScope.contains(value); - }; - if (result instanceof Collection) { - Collection res = ((Collection) result); - if (res.isEmpty()) { - return true; - } - return res.stream().allMatch(predicate); - } else { - return predicate.test(result); - } - } - - Entity entity = context.getParamContext() - .getParams() - .values() - .stream() - .filter(Entity.class::isInstance) - .map(Entity.class::cast) - .findAny() - .orElse(null); - - if (entity instanceof QueryParamEntity) { - QueryParamEntity param = ((QueryParamEntity) entity); - param.toNestQuery(query -> { - log.debug("执行查询数据权限控制[{}],范围:{}", config.getScopeTypeName(), scopeInfo.scope); - controllerCache.queryConsumer.accept(query, scopeInfo); - }); - } else { - log.debug("方法[{}]未使用动态查询参数[QueryParamEntity],无法进行数据权限控制!", context.getParamContext().getMethod()); - } - return true; - } - - public String getUserField(Class type) { - - if (ReflectionUtils.findField(type, "userId") != null) { - return "userId"; - } - - return "creatorId"; - } - - protected Object getRealResult(Object result) { - if (result instanceof ResponseEntity) { - result = ((ResponseEntity) result).getBody(); - } - if (result instanceof ResponseMessage) { - result = ((ResponseMessage) result).getResult(); - } - if (result instanceof PagerResult) { - result = ((PagerResult) result).getData(); - } - return result; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 2173c669f..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.organizational.authorization.OrganizationalAuthorizationAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/test/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthenticationBuilderTest.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/test/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthenticationBuilderTest.java deleted file mode 100644 index cafdeb984..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/test/java/org/hswebframework/web/organizational/authorization/simple/SimplePersonnelAuthenticationBuilderTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.organizational.authorization.simple; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.serializer.SerializerFeature; -import org.hswebframework.web.Maps; -import org.hswebframework.web.bean.FastBeanCopier; -import org.junit.Test; - -import static org.hswebframework.web.organizational.authorization.simple.SimplePersonnelAuthorizationBuilder.fromJson; - -public class SimplePersonnelAuthenticationBuilderTest { - - @Test - public void test() { - JSONObject auth = new JSONObject(); - auth.put("personnel", Maps.buildMap() - .put("id", "1234") - .put("name", "234") - .get()); - - auth.put("orgIds", JSON.parseArray("[{\"value\":\"123\",\"children\":[{\"value\":\"234\"}]}]")); - - auth.put("positions", JSON.parseArray("[{\"id\":\"1234\"," + - "\"department\":{\"id\":\"1234\",\"org\":{\"id\":\"234\",\"district\":{\"id\":\"test\"}}}}]")); - - SimplePersonnelAuthentication authorization = fromJson(auth.toJSONString()); - - - Object json = JSON.toJSON(authorization); - System.out.println(JSON.toJSONString(json, SerializerFeature.PrettyFormat)); - - System.out.println(JSON.toJSONString(FastBeanCopier.copy(authorization,new JSONObject())).equals(json.toString())); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/pom.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/pom.xml deleted file mode 100644 index 893eff4a8..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - hsweb-system-organizational - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational-local - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - - org.hswebframework.web - hsweb-system-organizational-api - ${project.version} - - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - io.vavr - vavr - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DepartmentDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DepartmentDao.java deleted file mode 100644 index 425be74cc..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DepartmentDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.DepartmentEntity; - -/** -* 部门 DAO接口 -* @author hsweb-generator-online - */ -public interface DepartmentDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DistrictDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DistrictDao.java deleted file mode 100644 index 55c4d7700..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/DistrictDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.DistrictEntity; - -/** -* 表单发布日志 DAO接口 -* @author hsweb-generator-online - */ -public interface DistrictDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/OrganizationalDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/OrganizationalDao.java deleted file mode 100644 index f88d2c664..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/OrganizationalDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; - -/** -* 组织 DAO接口 -* @author hsweb-generator-online - */ -public interface OrganizationalDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonDao.java deleted file mode 100644 index 6671aa83e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonDao.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.PersonEntity; - -import java.util.List; - -/** - * 人员 DAO接口 - * - * @author hsweb-generator-online - */ -public interface PersonDao extends CrudDao { - List selectByPositionId(String positionId); - - List selectByRoleId(String positionId); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonPositionDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonPositionDao.java deleted file mode 100644 index 07492f195..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PersonPositionDao.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.dao.InsertDao; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; -import org.hswebframework.web.entity.organizational.PersonPositionEntity; - -/** - * 人员职位关联 DAO接口 - * - * @author hsweb-generator-online - */ -public interface PersonPositionDao extends InsertDao - , QueryByEntityDao { - - int deleteByPersonId(String personId); - - int deleteByPositionId(String position); -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PositionDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PositionDao.java deleted file mode 100644 index 00b2c05ac..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/PositionDao.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.PositionEntity; - -/** -* 职位 DAO接口 -* @author hsweb-generator-online - */ -public interface PositionDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationDefineDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationDefineDao.java deleted file mode 100644 index a7afbcf60..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationDefineDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.RelationDefineEntity; - -/** -* 关系定义 DAO接口 -* @author hsweb-generator-online - */ -public interface RelationDefineDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationInfoDao.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationInfoDao.java deleted file mode 100644 index 2277e93da..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/dao/organizational/RelationInfoDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.organizational; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.organizational.RelationInfoEntity; - -/** -* 关系信息 DAO接口 -* @author hsweb-generator-online - */ -public interface RelationInfoDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDepartmentService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDepartmentService.java deleted file mode 100644 index e6b51e88e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDepartmentService.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2019 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.organizational.simple; - -import org.apache.commons.collections.CollectionUtils; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.dao.organizational.DepartmentDao; -import org.hswebframework.web.dao.organizational.PositionDao; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.EnableCacheAllEvictTreeSortService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.organizational.DepartmentService; -import org.hswebframework.web.service.organizational.OrganizationalService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -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.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("departmentService") -@CacheConfig(cacheNames = "department") -public class SimpleDepartmentService - extends EnableCacheAllEvictTreeSortService - implements DepartmentService { - @Autowired - private DepartmentDao departmentDao; - - @Autowired - protected PositionDao positionDao; - - @Autowired - private ApplicationEventPublisher publisher; - - @Autowired - private OrganizationalService organizationalService; - - @Override - public DepartmentDao getDao() { - return departmentDao; - } - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - @Cacheable(key = "'org-id:'+#orgId") - public List selectByOrgId(String orgId) { - return createQuery().where(DepartmentEntity.orgId, orgId).listNoPaging(); - } - - @Override - @Cacheable(key = "'org-ids:'+#orgId==null?0:orgId.hashCode()+'_'+#children+'_'+#parent") - public List selectByOrgIds(List orgId, boolean children, boolean parent) { - if (CollectionUtils.isEmpty(orgId)) { - return new java.util.ArrayList<>(); - } - Set allOrgId = new HashSet<>(orgId); - - if (children) { - allOrgId.addAll(orgId.stream() - .map(organizationalService::selectAllChildNode) - .flatMap(Collection::stream) - .map(OrganizationalEntity::getId) - .collect(Collectors.toSet())); - - } - if (parent) { - allOrgId.addAll(orgId.stream() - .map(organizationalService::selectParentNode) - .flatMap(Collection::stream) - .map(OrganizationalEntity::getId) - .collect(Collectors.toSet())); - } - - return createQuery() - .where() - .in(DepartmentEntity.orgId, allOrgId) - .listNoPaging(); - } - - @Override - @Cacheable(key = "'name:'+#name") - public List selectByName(String name) { - return createQuery().where(DepartmentEntity.name, name).listNoPaging(); - } - - @Override - @Cacheable(key = "'code:'+#code") - public DepartmentEntity selectByCode(String code) { - return createQuery().where(DepartmentEntity.code, code).single(); - } - - @Override - public DepartmentEntity deleteByPk(String id) { - if (DefaultDSLQueryService.createQuery(positionDao) - .where(PositionEntity.departmentId, id) - .total() > 0) { - throw new BusinessException("部门下存在职位信息,无法删除!"); - } - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.deleteByPk(id); - } - - @Override - public String insert(DepartmentEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.insert(entity); - } - - @Override - public int updateByPk(String id, DepartmentEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.updateByPk(id, entity); - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDistrictService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDistrictService.java deleted file mode 100644 index 995ab38af..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleDistrictService.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.hswebframework.web.service.organizational.simple; - -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.dao.organizational.DistrictDao; -import org.hswebframework.web.dao.organizational.OrganizationalDao; -import org.hswebframework.web.entity.organizational.DistrictEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.EnableCacheAllEvictTreeSortService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.organizational.DistrictService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -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.cache.annotation.Caching; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -import static org.hswebframework.web.service.DefaultDSLQueryService.*; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("districtService") -@CacheConfig(cacheNames = "district") -public class SimpleDistrictService extends EnableCacheAllEvictTreeSortService - implements DistrictService { - @Autowired - private DistrictDao districtDao; - - @Autowired - private OrganizationalDao organizationalDao; - - @Autowired - private ApplicationEventPublisher publisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public DistrictDao getDao() { - return districtDao; - } - - @Override - @CacheEvict(allEntries = true) - public String insert(DistrictEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.insert(entity); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(String id, DistrictEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.updateByPk(id, entity); - } - - @Override - @Cacheable(key = "'ids:'+(#id==null?0:#id.hashCode())") - public List selectByPk(List id) { - return super.selectByPk(id); - } - - @Override - @Cacheable(key = "'id:'+#id") - public DistrictEntity selectByPk(String id) { - return super.selectByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public DistrictEntity deleteByPk(String id) { - if (DefaultDSLQueryService.createQuery(organizationalDao).where(OrganizationalEntity.districtId, id).total() > 0) { - throw new BusinessException("行政区域下存在机构信息,无法删除!"); - } - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.deleteByPk(id); - } - - @Override - @Cacheable(key = "'code:'+#code") - public DistrictEntity selectByCode(String code) { - return createQuery().where(DistrictEntity.code, code).single(); - } - - @Override - @CacheEvict(allEntries = true) - public int updateBatch(Collection data) { - return super.updateBatch(data); - } - - @Override - @Cacheable(key = "'all'") - public List select() { - return createQuery().where().orderByAsc(DistrictEntity.sortIndex).listNoPaging(); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(List data) { - return super.updateByPk(data); - } - - @Override - @CacheEvict(allEntries = true) - public void disable(String id) { - Objects.requireNonNull(id); - createUpdate() - .set(DistrictEntity.status, DataStatus.STATUS_DISABLED) - .where(DistrictEntity.id, id) - .exec(); - publisher.publishEvent(new ClearPersonCacheEvent()); - } - - @Override - @CacheEvict(allEntries = true) - public void enable(String id) { - Objects.requireNonNull(id); - createUpdate() - .set(DistrictEntity.status, DataStatus.STATUS_ENABLED) - .where(DistrictEntity.id, id) - .exec(); - publisher.publishEvent(new ClearPersonCacheEvent()); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleOrganizationalService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleOrganizationalService.java deleted file mode 100644 index 32ee13c05..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleOrganizationalService.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2019 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.organizational.simple; - -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.organizational.DepartmentDao; -import org.hswebframework.web.dao.organizational.OrganizationalDao; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.EnableCacheAllEvictTreeSortService; -import org.hswebframework.web.service.organizational.OrganizationalService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -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.cache.annotation.Caching; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.util.Objects; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("organizationalService") -@CacheConfig(cacheNames = "organizational") -public class SimpleOrganizationalService extends EnableCacheAllEvictTreeSortService - implements OrganizationalService { - @Autowired - private OrganizationalDao organizationalDao; - - @Autowired - private DepartmentDao departmentDao; - - @Autowired - private ApplicationEventPublisher publisher; - - @Override - public OrganizationalDao getDao() { - return organizationalDao; - } - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - @CacheEvict(allEntries = true) - public OrganizationalEntity deleteByPk(String id) { - if (DefaultDSLQueryService.createQuery(departmentDao) - .where(DepartmentEntity.orgId, id) - .total() > 0) { - throw new BusinessException("机构下存在部门信息,无法删除"); - } - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public String insert(OrganizationalEntity entity) { - entity.setStatus(DataStatus.STATUS_ENABLED); - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.insert(entity); - } - - @Override - public int updateByPk(String id, OrganizationalEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.updateByPk(id, entity); - } - - @Override - @CacheEvict(allEntries = true) - public void disable(String id) { - Objects.requireNonNull(id); - createUpdate() - .set(OrganizationalEntity.status, DataStatus.STATUS_DISABLED) - .where(OrganizationalEntity.id, id) - .exec(); - publisher.publishEvent(new ClearPersonCacheEvent()); - } - - @Override - @CacheEvict(allEntries = true) - public void enable(String id) { - Objects.requireNonNull(id); - createUpdate() - .set(OrganizationalEntity.status, DataStatus.STATUS_ENABLED) - .where(OrganizationalEntity.id, id) - .exec(); - publisher.publishEvent(new ClearPersonCacheEvent()); - } - - @Override - @Transactional(readOnly = true) - @Cacheable(key = "'code:'+#code") - public OrganizationalEntity selectByCode(String code) { - if (StringUtils.isEmpty(code)) { - return null; - } - return createQuery().where(OrganizationalEntity.code, code).single(); - } - - @Override - @Cacheable(key = "'name:'+#name") - @Transactional(readOnly = true) - public OrganizationalEntity selectByName(String name) { - if (StringUtils.isEmpty(name)) { - return null; - } - - return createQuery().where(OrganizationalEntity.name, name).single(); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePersonService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePersonService.java deleted file mode 100644 index 0704378ea..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePersonService.java +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright 2019 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.organizational.simple; - -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.commons.entity.TreeSupportEntity; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.dao.dynamic.QueryByEntityDao; -import org.hswebframework.web.dao.organizational.*; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.entity.organizational.*; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.organizational.authorization.*; -import org.hswebframework.web.organizational.authorization.relation.Relation; -import org.hswebframework.web.organizational.authorization.relation.SimpleRelation; -import org.hswebframework.web.organizational.authorization.relation.SimpleRelations; -import org.hswebframework.web.organizational.authorization.simple.*; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.EnableCacheAllEvictGenericEntityService; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.service.organizational.PersonService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -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 org.springframework.transaction.event.TransactionalEventListener; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static org.hswebframework.web.commons.entity.TreeSupportEntity.*; -import static org.hswebframework.web.commons.entity.param.QueryParamEntity.*; -import static org.hswebframework.web.service.DefaultDSLQueryService.*; -import static org.springframework.util.StringUtils.isEmpty; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("personService") -@CacheConfig(cacheNames = "person") -public class SimplePersonService extends EnableCacheAllEvictGenericEntityService - implements PersonService, PersonnelAuthenticationManager { - - - @Autowired - private PersonDao personDao; - - @Autowired - private PersonPositionDao personPositionDao; - - @Autowired - private PositionDao positionDao; - - @Autowired - private DepartmentDao departmentDao; - - @Autowired - private OrganizationalDao organizationalDao; - - @Autowired - private DistrictDao districtDao; - - @Autowired(required = false) - private UserService userService; - - @Autowired - private RelationInfoDao relationInfoDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public PersonDao getDao() { - return personDao; - } - - @Override - @CacheEvict(allEntries = true) - public String insert(PersonAuthBindEntity authBindEntity) { - authBindEntity.setStatus(DataStatus.STATUS_ENABLED); - if (authBindEntity.getPersonUser() != null) { - syncUserInfo(authBindEntity); - } - String id = this.insert(((PersonEntity) authBindEntity)); - if (authBindEntity.getPositionIds() != null) { - syncPositionInfo(id, authBindEntity.getPositionIds()); - } - return id; - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(PersonAuthBindEntity authBindEntity) { - if (authBindEntity.getPositionIds() != null) { - personPositionDao.deleteByPersonId(authBindEntity.getId()); - syncPositionInfo(authBindEntity.getId(), authBindEntity.getPositionIds()); - } - if (authBindEntity.getPersonUser() != null) { - syncUserInfo(authBindEntity); - } - return this.updateByPk(((PersonEntity) authBindEntity)); - } - - @TransactionalEventListener - @CacheEvict(allEntries = true) - public void handleClearCache(ClearPersonCacheEvent event) { - logger.debug("clear all person cache"); - } - - @Override - @Cacheable(key = "'person-name:'+#name") - public List selectByName(String name) { - if (StringUtils.isEmpty(name)) { - return new ArrayList<>(); - } - return createQuery().where(PersonEntity.name, name).listNoPaging(); - } - - @Override - @Cacheable(key = "'auth-bind:'+#id") - public PersonAuthBindEntity selectAuthBindByPk(String id) { - PersonEntity personEntity = this.selectByPk(id); - if (personEntity == null) { - return null; - } - - if (personEntity instanceof PersonAuthBindEntity) { - return ((PersonAuthBindEntity) personEntity); - } - - PersonAuthBindEntity bindEntity = entityFactory.newInstance(PersonAuthBindEntity.class, personEntity); - Set positionIds = DefaultDSLQueryService.createQuery(personPositionDao) - .where(PersonPositionEntity.personId, id) - .listNoPaging().stream() - .map(PersonPositionEntity::getPositionId) - .collect(Collectors.toSet()); - - bindEntity.setPositionIds(positionIds); - - if (null != userService && null != personEntity.getUserId()) { - UserEntity userEntity = userService.selectByPk(personEntity.getUserId()); - if (null != userEntity) { - PersonUserEntity entity = entityFactory.newInstance(PersonUserEntity.class); - entity.setUsername(userEntity.getUsername()); - bindEntity.setPersonUser(entity); - } - } - return bindEntity; - } - - @Override - @Cacheable(key = "'by-position-id:'+#positionId") - public List selectByPositionId(String positionId) { - if (StringUtils.isEmpty(positionId)) { - return new ArrayList<>(); - } - return personDao.selectByPositionId(positionId); - } - - @Override - @Cacheable(key = "'by-position-ids:'+#positionId.hashCode()") - public List selectByPositionIds(List positionId) { - if (CollectionUtils.isEmpty(positionId)) { - return new ArrayList<>(); - } - return createQuery() - .where(PersonEntity.id, "person-in-position", positionId) - .listNoPaging(); - } - - @Override - @Cacheable(key = "'by-department:'+#departmentId.hashCode()") - public List selectByDepartmentId(List departmentId) { - if (CollectionUtils.isEmpty(departmentId)) { - return new ArrayList<>(); - } - return createQuery() - .where(PersonEntity.id, "person-in-department", departmentId) - .listNoPaging(); - } - - @Override - @Cacheable(key = "'by-org-id:'+#orgId.hashCode()") - public List selectByOrgId(List orgId) { - if (CollectionUtils.isEmpty(orgId)) { - return new ArrayList<>(); - } - return createQuery() - .where(PersonEntity.id, "person-in-org", orgId) - .listNoPaging(); - } - - @Override - @Cacheable(key = "'by-user-id:'+#userId") - public PersonEntity selectByUserId(String userId) { - if (StringUtils.isEmpty(userId)) { - return null; - } - return createQuery().where(PersonEntity.userId, userId).single(); - } - - @Override - @Cacheable(key = "'all-department-id:'+#personId.hashCode()") - public List selectAllDepartmentId(List personId) { - if (CollectionUtils.isEmpty(personId)) { - return new java.util.ArrayList<>(); - } - //所有的机构 - List positionId = DefaultDSLQueryService.createQuery(personPositionDao) - .where().in(PersonPositionEntity.personId, personId) - .listNoPaging() - .stream() - .map(PersonPositionEntity::getPositionId) - .filter(Objects::nonNull) - .distinct() - .collect(Collectors.toList()); - - if (CollectionUtils.isEmpty(positionId)) { - return new java.util.ArrayList<>(); - } - return DefaultDSLQueryService.createQuery(positionDao) - .where() - .in(PositionEntity.id, positionId) - .listNoPaging() - .stream() - .map(PositionEntity::getDepartmentId) - .filter(Objects::nonNull) - .distinct() - .collect(Collectors.toList()); - } - - @Override - @Cacheable(key = "'all-org-id:'+#personId.hashCode()") - public List selectAllOrgId(List personId) { - List departmentId = this.selectAllDepartmentId(personId); - if (CollectionUtils.isEmpty(departmentId)) { - return new java.util.ArrayList<>(); - } - return DefaultDSLQueryService.createQuery(departmentDao) - .where() - .in(DepartmentEntity.id, departmentId) - .listNoPaging() - .stream() - .map(DepartmentEntity::getOrgId) - .filter(Objects::nonNull) - .distinct() - .collect(Collectors.toList()); - } - - @Override - @Cacheable(key = "'by-role-id:'+#roleId") - public List selectByRoleId(String roleId) { - if (StringUtils.isEmpty(roleId)) { - return new ArrayList<>(); - } - return personDao.selectByRoleId(roleId); - } - - protected void syncPositionInfo(String personId, Set positionIds) { - for (String positionId : positionIds) { - PersonPositionEntity positionEntity = entityFactory.newInstance(PersonPositionEntity.class); - positionEntity.setPersonId(personId); - positionEntity.setPositionId(positionId); - this.personPositionDao.insert(positionEntity); - } - } - - protected void syncUserInfo(PersonAuthBindEntity bindEntity) { - if (isEmpty(bindEntity.getPersonUser().getUsername())) { - bindEntity.setUserId(""); - return; - } - - //是否使用了权限管理的userService. - if (null == userService) { - logger.warn("userService not ready!"); - return; - } - //获取用户是否存在 - UserEntity oldUser = userService.selectByUsername(bindEntity.getPersonUser().getUsername()); - if (null != oldUser) { - //判断用户是否已经绑定了其他人员 - int userBindSize = createQuery().where() - .is(PersonEntity.userId, oldUser.getId()) - .not(PersonEntity.id, bindEntity.getId()) - .total(); - tryValidateProperty(userBindSize == 0, "personUser.username", "用户已绑定其他人员"); - } - // 初始化用户后的操作方式 - Function userOperationFunction = - oldUser == null ? userService::insert : //为空新增,不为空修改 - user -> { - userService.update(oldUser.getId(), user); - return oldUser.getId(); - }; - UserEntity userEntity = entityFactory.newInstance(UserEntity.class); - - userEntity.setUsername(bindEntity.getPersonUser().getUsername()); - userEntity.setPassword(bindEntity.getPersonUser().getPassword()); - userEntity.setName(bindEntity.getName()); - - String userId = userOperationFunction.apply(userEntity); - bindEntity.setUserId(userId); - } - - - @Override - @CacheEvict(allEntries = true) - public PersonEntity deleteByPk(String id) { - personPositionDao.deleteByPersonId(id); - return super.deleteByPk(id); - } - - @Override - @Cacheable(key = "'auth:persion-id'+#personId") - public PersonnelAuthentication getPersonnelAuthorizationByPersonId(String personId) { - PersonEntity entity = selectByPk(personId); - if (null == entity) { - return null; - } - SimplePersonnelAuthentication authorization = new SimplePersonnelAuthentication(); - - Personnel personnel = entityFactory.newInstance(Personnel.class, SimplePersonnel.class, entity); - - authorization.setPersonnel(personnel); - - // 获取用户的职位ID集合(多个职位) - Set positionIds = DefaultDSLQueryService.createQuery(personPositionDao) - .where(PersonPositionEntity.personId, personId) - .listNoPaging().stream() - .map(PersonPositionEntity::getPositionId) - .collect(Collectors.toSet()); - - Map departmentCache = new HashMap<>(); - Map positionCache = new HashMap<>(); - Map orgCache = new HashMap<>(); - Map districtCache = new HashMap<>(); - - //获取所有职位,并得到根职位(树结构) - List positionEntities = getAllChildrenAndReturnRootNode(positionDao, positionIds, PositionEntity::setChildren, rootPosList -> { - //根据职位获取部门 - Set departmentIds = rootPosList.stream() - .peek(positionEntity -> positionCache.put(positionEntity.getId(), positionEntity)) - .map(PositionEntity::getDepartmentId) - .collect(Collectors.toSet()); - if (!CollectionUtils.isEmpty(departmentIds)) { - List departmentEntities = getAllChildrenAndReturnRootNode(departmentDao, departmentIds, DepartmentEntity::setChildren, rootDepList -> { - //根据部门获取机构 - Set orgIds = rootDepList.stream() - .peek(departmentEntity -> departmentCache.put(departmentEntity.getId(), departmentEntity)) - .map(DepartmentEntity::getOrgId) - .collect(Collectors.toSet()); - if (!CollectionUtils.isEmpty(orgIds)) { - List orgEntities = getAllChildrenAndReturnRootNode(organizationalDao, orgIds, OrganizationalEntity::setChildren, rootOrgList -> { - //根据机构获取行政区域 - Set districtIds = rootOrgList.stream() - .peek(org -> orgCache.put(org.getId(), org)) - .map(OrganizationalEntity::getDistrictId) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); - if (!CollectionUtils.isEmpty(districtIds)) { - List districtEntities = - getAllChildrenAndReturnRootNode(districtDao, districtIds, DistrictEntity::setChildren, - rootDistrictList -> rootDistrictList.forEach(dist -> districtCache.put(dist.getId(), dist))); - - authorization.setDistrictIds(transformationTreeNode(null, districtEntities)); - } - }); - authorization.setOrgIds(transformationTreeNode(null, orgEntities)); - } - }); - authorization.setDepartmentIds(transformationTreeNode(null, departmentEntities)); - } - }); - authorization.setPositionIds(transformationTreeNode(null, positionEntities)); - - Set positions = positionEntities.stream() - .map(positionEntity -> { - DepartmentEntity departmentEntity = departmentCache.get(positionEntity.getDepartmentId()); - if (departmentEntity == null) { - return null; - } - OrganizationalEntity organizationalEntity = orgCache.get(departmentEntity.getOrgId()); - if (organizationalEntity == null) { - return null; - } - DistrictEntity districtEntity = districtCache.get(organizationalEntity.getDistrictId()); - District district = districtEntity == null ? null : SimpleDistrict.builder() - .code(districtEntity.getCode()) - .id(districtEntity.getId()) - .name(districtEntity.getName()) - .fullName(districtEntity.getFullName()) - .build(); - - Organization organization = SimpleOrganization.builder() - .id(organizationalEntity.getId()) - .name(organizationalEntity.getName()) - .fullName(organizationalEntity.getFullName()) - .code(organizationalEntity.getCode()) - .district(district) - .build(); - Department department = SimpleDepartment - .builder() - .id(departmentEntity.getId()) - .name(departmentEntity.getName()) - .code(departmentEntity.getCode()) - .org(organization) - .build(); - - return SimplePosition - .builder() - .id(positionEntity.getId()) - .name(positionEntity.getName()) - .department(department) - .code("") - .build(); - }) - .filter(Objects::nonNull) - .collect(Collectors.toSet()); - authorization.setPositions(positions); - //获取关系 - List relationInfoList = DefaultDSLQueryService.createQuery(relationInfoDao) - .where(RelationInfoEntity.relationFrom, personId) - .or(RelationInfoEntity.relationTo, personId) - .listNoPaging(); - List relations = relationInfoList.stream() - .map(info -> { - SimpleRelation relation = new SimpleRelation(); - relation.setDimension(info.getRelationTypeFrom()); - relation.setTarget(info.getRelationTo()); - relation.setRelation(info.getRelationId()); - if (personId.equals(info.getRelationFrom())) { - relation.setDirection(Relation.Direction.POSITIVE); - } else { - relation.setDirection(Relation.Direction.REVERSE); - } - return relation; - }).collect(Collectors.toList()); - authorization.setRelations(new SimpleRelations(relations)); - return authorization; - } - - /** - * 获取一个树形结构的数据,并返回根节点集合 - * - * @param dao 查询dao接口 - * @param rootIds 根节点ID集合 - * @param childAccepter 子节点接收方法 - * @param rootConsumer 根节点消费回调 - * @param 节点类型 - * @return 根节点集合 - */ - protected > List getAllChildrenAndReturnRootNode(QueryByEntityDao dao, - Set rootIds, - BiConsumer> childAccepter, - Consumer> rootConsumer) { - if (CollectionUtils.isEmpty(rootIds)) { - return new java.util.ArrayList<>(); - } - //获取根节点 - List rootNodeList = newQuery() - .where() - .in(id, rootIds) - .execute(dao::query); - - if (!rootNodeList.isEmpty()) { - //所有子节点,使用节点的path属性进行快速查询,查询结果包含了根节点 - List allNode = newQuery() - //遍历生成查询条件: like path like ?||'%' or path like ?||'%' .... - .each(rootNodeList, (query, rootNode) -> query.or().like$(rootNode::getPath)) - .noPaging() - .execute(dao::query); - - //转为树形结构 - List tree = list2tree(allNode, childAccepter, (Predicate) node -> rootIds.contains(node.getId())); // 根节点判定 - rootConsumer.accept(rootNodeList); - return tree; - } - return new java.util.ArrayList<>(); - } - - public static > Set> transformationTreeNode(V parent, List data) { - Set> treeNodes = new HashSet<>(); - for (V node : data) { - TreeNode treeNode = new TreeNode<>(); - if (parent != null) { - TreeNode parentNode = new TreeNode<>(); - parentNode.setValue(parent.getId()); - parentNode.setChildren(treeNodes); -// treeNode.setParent(parentNode); - } - treeNode.setValue(node.getId()); - if (node.getChildren() != null && !node.getChildren().isEmpty()) { - // TODO: 2019-06-13 有不用递归的方式? - treeNode.setChildren(transformationTreeNode(node, node.getChildren())); - } - treeNodes.add(treeNode); - } - return treeNodes; - } - - @Override - @Cacheable(key = "'auth:user-id:'+#userId") - public PersonnelAuthentication getPersonnelAuthorizationByUserId(String userId) { - PersonEntity entity = createQuery().where(PersonEntity.userId, userId).single(); - if (entity == null) { - return null; - } - return getPersonnelAuthorizationByPersonId(entity.getId()); - } - - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePositionService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePositionService.java deleted file mode 100644 index 5e29b63ef..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePositionService.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 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.organizational.simple; - -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.dao.organizational.PersonDao; -import org.hswebframework.web.dao.organizational.PositionDao; -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.AbstractTreeSortService; -import org.hswebframework.web.service.EnableCacheAllEvictTreeSortService; -import org.hswebframework.web.service.organizational.PositionService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("positionService") -@CacheConfig(cacheNames = "hsweb-position") -public class SimplePositionService extends EnableCacheAllEvictTreeSortService - implements PositionService { - - @Autowired - private ApplicationEventPublisher publisher; - - @Autowired - private PositionDao positionDao; - - @Autowired - private PersonDao personDao; - - @Override - public PositionDao getDao() { - return positionDao; - } - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - @CacheEvict(allEntries = true) - public PositionEntity deleteByPk(String id) { - if (!CollectionUtils.isEmpty(personDao.selectByPositionId(id))) { - throw new BusinessException("岗位中还有人员,无法删除!"); - } - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.deleteByPk(id); - } - - @Override - @CacheEvict(allEntries = true) - public int updateByPk(String id, PositionEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.updateByPk(id, entity); - } - - @Override - @CacheEvict(allEntries = true) - public String insert(PositionEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.insert(entity); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationDefineService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationDefineService.java deleted file mode 100644 index 6b22449c8..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationDefineService.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.hswebframework.web.service.organizational.simple; - -import org.hswebframework.web.dao.organizational.RelationDefineDao; -import org.hswebframework.web.entity.organizational.RelationDefineEntity; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.organizational.RelationDefineService; -import org.hswebframework.web.service.organizational.event.ClearPersonCacheEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("relationDefineService") -@CacheConfig(cacheNames = "hsweb-relation-define") -public class SimpleRelationDefineService extends EnableCacheGenericEntityService - implements RelationDefineService { - @Autowired - private RelationDefineDao relationDefineDao; - - @Autowired - private ApplicationEventPublisher publisher; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public RelationDefineDao getDao() { - return relationDefineDao; - } - - @Override - public String insert(RelationDefineEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.insert(entity); - } - - @Override - public RelationDefineEntity deleteByPk(String pk) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.deleteByPk(pk); - } - - @Override - public int updateByPk(String pk, RelationDefineEntity entity) { - publisher.publishEvent(new ClearPersonCacheEvent()); - return super.updateByPk(pk, entity); - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationInfoService.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationInfoService.java deleted file mode 100644 index 4a9dab35e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/SimpleRelationInfoService.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.hswebframework.web.service.organizational.simple; - -import org.hswebframework.web.dao.organizational.RelationInfoDao; -import org.hswebframework.web.entity.organizational.RelationInfoEntity; -import org.hswebframework.web.organizational.authorization.relation.*; -import org.hswebframework.web.service.DefaultDSLQueryService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.organizational.RelationInfoService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("relationInfoService") -public class SimpleRelationInfoService extends GenericEntityService - implements RelationInfoService { - - @Autowired - private RelationInfoDao relationInfoDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public RelationInfoDao getDao() { - return relationInfoDao; - } - - @Override - public Relations getRelations(String relationTypeFrom, String target) { - Objects.requireNonNull(relationTypeFrom); - Objects.requireNonNull(target); - //获取关系 - List relationInfoList = DefaultDSLQueryService.createQuery(relationInfoDao) - //where type_from='person' and(relation_from='personId' or relation_to='personId') - .where(RelationInfoEntity.relationTypeFrom, relationTypeFrom) - .nest() - .is(RelationInfoEntity.relationFrom, target) - .or(RelationInfoEntity.relationTo, target) - .end() - .listNoPaging(); - - List relations = relationInfoList.stream() - .map(info -> { - SimpleRelation relation = new SimpleRelation(); - relation.setDimension(info.getRelationTypeFrom()); - relation.setTarget(info.getRelationTo()); - relation.setTargetObject(RelationTargetHolder - .get(info.getRelationTypeTo(), info.getRelationTo()).orElse(null)); - relation.setRelation(info.getRelationId()); - if (target.equals(info.getRelationFrom())) { - relation.setDirection(Relation.Direction.POSITIVE); - } else { - relation.setDirection(Relation.Direction.REVERSE); - } - return relation; - }).collect(Collectors.toList()); - - return new SimpleRelations(relations); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultDepartmentRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultDepartmentRelations.java deleted file mode 100644 index aa41349e1..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultDepartmentRelations.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import io.vavr.Lazy; -import org.hswebframework.ezorm.core.NestConditional; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.organizational.authorization.relation.DepartmentRelations; -import org.hswebframework.web.organizational.authorization.relation.PersonRelations; -import org.hswebframework.web.organizational.authorization.relation.Relation; -import org.hswebframework.web.organizational.authorization.relation.SimpleRelation; -import org.springframework.util.CollectionUtils; - -import java.util.*; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class DefaultDepartmentRelations extends DefaultLinkedRelations implements DepartmentRelations { - - private boolean includeChildren; - - private boolean includeParent; - - private NestConditional> departmentQuery = - Query.empty(new QueryParamEntity()).noPaging().nest(); - - private NestConditional> positionQuery = - Query.empty(new QueryParamEntity()).noPaging().nest(); - - - public DefaultDepartmentRelations(ServiceContext serviceContext, Supplier> targetIdSupplier) { - super(serviceContext, targetIdSupplier); - } - - @Override - public DepartmentRelations andChildren() { - includeChildren = true; - return this; - } - - @Override - public DepartmentRelations andParents() { - includeParent = true; - return this; - } - - @Override - public DepartmentRelations relations(Relation.Direction direction, String dimension, String relation) { - - if ((dimension == null || Relation.TYPE_POSITION.equals(dimension)) && direction != Relation.Direction.REVERSE) { - //没指定维度,尝试获取岗位关系 - positionQuery.is(PositionEntity.name, relation); - } - - return super.relations(direction, dimension, relation); - } - - @Override - public DepartmentRelations or() { - positionQuery.or(); - departmentQuery.or(); - return super.or(); - } - - @Override - public DepartmentRelations and() { - positionQuery.and(); - departmentQuery.and(); - return super.and(); - } - - @Override - public DepartmentRelations not(String property, Object value) { - departmentQuery.not(property, value); - - return super.not(property, value); - } - - @Override - public DepartmentRelations is(String property, Object value) { - departmentQuery.is(property, value); - return super.is(property, value); - } - - @Override - public Stream stream() { - - Map> cache = new HashMap<>(); - - List positions = positionSupplier.get(); - - List positionIdList = getAllPerson() - .stream() - .map(person -> serviceContext.getPersonService().selectAuthBindByPk(person.getId())) - .filter(bin -> !CollectionUtils.isEmpty(bin.getPositionIds())) - .flatMap(bind -> bind.getPositionIds().stream().peek(positionId -> cache.computeIfAbsent(positionId, i -> new ArrayList<>()).add(bind))) - .collect(Collectors.toList()); - - if (CollectionUtils.isEmpty(positionIdList)) { - return super.relationStream(allDepartmentId); - } - //将岗位里的人员转为关系信息 - Stream relationStream = positions.stream() - .flatMap(position -> { - List personEntities = cache.get(position.getId()); - if (CollectionUtils.isEmpty(personEntities)) { - return Stream.empty(); - } - return personEntities - .stream() - .map(person -> { - SimpleRelation relation = new SimpleRelation(); - relation.setName(position.getName()); - relation.setTarget(person.getId()); - relation.setTargetObject(person); - //固定方向,因为从逻辑都是某人是某部门的某岗位 - relation.setDirection(Relation.Direction.REVERSE); - //维度默认为岗位 - relation.setDimension(Relation.TYPE_POSITION); - //关系标识为岗位id - relation.setRelation(position.getId()); - return (Relation) relation; - }); - - }); - - return Stream.concat(relationStream, super.relationStream(allDepartmentId)); - } - - public List getAllDepartmentId() { - return allDepartmentId.get(); - } - - @SuppressWarnings("all") - //获取所有的岗位 - private Supplier> positionSupplier = Lazy.val(() -> { - List departmentId = getAllDepartmentId(); - if (CollectionUtils.isEmpty(departmentId)) { - return (Supplier) () -> new java.util.ArrayList<>(); - } - QueryParamEntity positionQueryParam = positionQuery.end() - .in(PositionEntity.departmentId, departmentId) - .getParam(); - - List positions = serviceContext - .getPositionService() - .select(positionQueryParam).stream() - .collect(Collectors.toList()); - - return (Supplier) () -> positions; - }, Supplier.class); - - //获取所有的部门 - private Supplier> allDepartmentId = createLazyIdSupplier(() -> { - Set departmentId = new HashSet<>(targetIdSupplier.get()); - if (CollectionUtils.isEmpty(departmentId)) { - return new java.util.ArrayList<>(); - } - Set allParent = null, allChildren = null; - //包含父级 - if (includeParent) { - allParent = departmentId.stream() - .map(serviceContext.getDepartmentService()::selectParentNode) - .flatMap(Collection::stream) - .map(DepartmentEntity::getId) - .collect(Collectors.toSet()); - } - //包含子级 - if (includeChildren) { - allChildren = departmentId.stream() - .map(serviceContext.getDepartmentService()::selectAllChildNode) - .flatMap(Collection::stream) - .map(DepartmentEntity::getId) - .collect(Collectors.toSet()); - } - if (!CollectionUtils.isEmpty(allChildren)) { - departmentId.addAll(allChildren); - } - if (!CollectionUtils.isEmpty(allParent)) { - departmentId.addAll(allParent); - } - - QueryParamEntity paramEntity = departmentQuery.end().getParam(); - if (paramEntity.getTerms().isEmpty()) { - return new ArrayList<>(departmentId); - } - paramEntity = departmentQuery.end() - .select(DepartmentEntity.id) - .in(DepartmentEntity.id, departmentId).getParam(); - - return serviceContext.getDepartmentService() - .select(paramEntity) - .stream() - .map(DepartmentEntity::getId) - .collect(Collectors.toList()); - }); - - - public List getAllPerson() { - - List positionEntities = positionSupplier.get(); - - if (CollectionUtils.isEmpty(positionEntities)) { - return new java.util.ArrayList<>(); - } - - return serviceContext - .getPersonService() - .selectByPositionIds( - positionEntities.stream() - .map(PositionEntity::getId) - .collect(Collectors.toList())); - } - - public List getAllUserId() { - return getAllPerson().stream() - .map(PersonEntity::getUserId) - .collect(Collectors.toList()); - } - - public List getAllPersonId() { - return getAllPerson() - .stream() - .map(PersonEntity::getId) - .collect(Collectors.toList()); - } - - @Override - public DepartmentRelations deep() { - return new DefaultDepartmentRelations(serviceContext, allDepartmentId); - } - - @Override - @SuppressWarnings("unchecked") - public PersonRelations persons() { - return new DefaultPersonRelations(serviceContext, createLazyIdSupplier(this::getAllPersonId)); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultLinkedRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultLinkedRelations.java deleted file mode 100644 index 52e387d92..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultLinkedRelations.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import io.vavr.Lazy; -import org.hswebframework.ezorm.core.NestConditional; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.organizational.authorization.relation.*; - -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@SuppressWarnings("all") -public class DefaultLinkedRelations implements LinkedRelations { - - protected Supplier> targetIdSupplier; - - protected transient NestConditional> query; - - protected transient ServiceContext serviceContext; - - public DefaultLinkedRelations(ServiceContext serviceContext, Supplier> targetIdSupplier) { - this.serviceContext = serviceContext; - this.targetIdSupplier = targetIdSupplier; - query = Query.empty(new QueryParamEntity()).nest(); - } - - @Override - public C relations(Relation.Direction direction, String dimension, String relation) { - switch (direction) { - case REVERSE: - query.nest().is("relationTypeTo", dimension).is("relationId", relation).end(); - break; - case POSITIVE: - query.nest().is("relationTypeFrom", dimension).is("relationId", relation).end(); - break; - case ALL: - query - .nest() - .nest() - .is("relationTypeFrom", dimension).is("relationId", relation) - .end() - .or() - .nest() - .is("relationTypeTo", dimension).is("relationId", relation) - .end() - .end(); - break; - - } - - return (C) this; - } - - @Override - public C is(String property, Object value) { - query.is(property, value); - return (C) this; - } - - @Override - public C not(String property, Object value) { - query.not(property, value); - return (C) this; - } - - @Override - public C or() { - query.or(); - return (C) this; - } - - @Override - public C and() { - query.and(); - return (C) this; - } - - public Supplier> createLazyIdSupplier(Supplier> idSupplier) { - return Lazy.val(() -> { - - List ids = idSupplier.get(); - - return (Supplier) () -> ids; - }, Supplier.class); - } - - public Stream relationStream(Supplier> supplier) { - - List personIdList = supplier.get(); - - QueryParamEntity queryParamEntity = query.end() - .and() - .nest() - .in("relationFrom", personIdList) - .or() - .in("relationTo", personIdList) - .end() - .getParam(); - - - return serviceContext.getRelationInfoService().select(queryParamEntity).stream() - .map(info -> { - SimpleRelation relation = new SimpleRelation(); - - relation.setTarget(info.getRelationTo()); - relation.setTargetObject(RelationTargetHolder.get(info.getRelationTypeTo(), info.getRelationTo()).orElse(null)); - relation.setRelation(info.getRelationId()); - - if (personIdList.contains(info.getRelationFrom())) { - relation.setDimension(info.getRelationTypeFrom()); - relation.setDirection(Relation.Direction.POSITIVE); - } else { - relation.setDimension(info.getRelationTypeTo()); - relation.setDirection(Relation.Direction.REVERSE); - } - return relation; - }); - } - - @Override - public C deep() { - if (this.getClass() != DefaultLinkedRelations.class) { - throw new UnsupportedOperationException("子类未实现deep方法"); - } - return (C) new DefaultLinkedRelations(serviceContext, () -> all() - .stream() - .map(Relation::getTarget) - .collect(Collectors.toList())); - } - - @Override - public Stream stream() { - return relationStream(targetIdSupplier); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultOrgRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultOrgRelations.java deleted file mode 100644 index a4ed8f65e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultOrgRelations.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.organizational.authorization.relation.DepartmentRelations; -import org.hswebframework.web.organizational.authorization.relation.OrgRelations; -import org.hswebframework.web.organizational.authorization.relation.Relation; - -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class DefaultOrgRelations extends DefaultLinkedRelations implements OrgRelations { - - private boolean includeChildren; - - private boolean includeParents; - - public DefaultOrgRelations(ServiceContext serviceContext, Supplier> targetIdSupplier) { - super(serviceContext, targetIdSupplier); - } - - @Override - public OrgRelations andChildren() { - includeChildren = true; - return this; - } - - @Override - public OrgRelations andParents() { - includeParents = true; - return this; - } - - @Override - public DepartmentRelations department() { - return new DefaultDepartmentRelations(serviceContext, () -> serviceContext - .getDepartmentService() - .selectByOrgIds(targetIdSupplier.get(), includeChildren, includeParents) - .stream() - .map(DepartmentEntity::getId) - .collect(Collectors.toList())); - } - - @Override - public OrgRelations deep() { - return new DefaultOrgRelations(serviceContext, () -> stream().map(Relation::getTarget).collect(Collectors.toList())); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultPersonRelations.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultPersonRelations.java deleted file mode 100644 index 140709cf2..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultPersonRelations.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import org.hswebframework.web.organizational.authorization.relation.*; - -import java.util.List; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -public class DefaultPersonRelations extends DefaultLinkedRelations implements PersonRelations { - - - public DefaultPersonRelations(ServiceContext serviceContext, Supplier> personIdListSupplier) { - super(serviceContext, personIdListSupplier); - } - - protected List getAllOrg() { - return serviceContext - .getPersonService() - .selectAllOrgId(targetIdSupplier.get()); - } - - protected List getAllDepartment() { - return serviceContext - .getPersonService() - .selectAllDepartmentId(targetIdSupplier.get()); - } - - @Override - public PersonRelations deep() { - return new DefaultPersonRelations(serviceContext, () -> all() - .stream() - .map(Relation::getTarget) - .collect(Collectors.toList())); - } - - @Override - public DepartmentRelations department() { - return new DefaultDepartmentRelations(serviceContext, createLazyIdSupplier(this::getAllDepartment)); - } - - @Override - public OrgRelations org() { - return new DefaultOrgRelations(serviceContext, createLazyIdSupplier(this::getAllOrg)); - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultRelationsManager.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultRelationsManager.java deleted file mode 100644 index 7cb033730..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/DefaultRelationsManager.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.organizational.authorization.relation.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -@Component -public class DefaultRelationsManager implements RelationsManager { - - @Autowired - private ServiceContext context; - - @Override - public PersonRelations getPersonRelationsByPersonId(String personId) { - return new DefaultPersonRelations(context, () -> Collections.singletonList(personId)); - } - - @Override - public PersonRelations getPersonRelationsByUserId(String userId) { - - return new DefaultPersonRelations(context, () -> Optional - .ofNullable(context.getPersonService().selectByUserId(userId)) - .map(PersonEntity::getId) - .map(Collections::singletonList) - .orElseGet(Collections::emptyList)); - } - - @Override - public DepartmentRelations getDepartmentRelations(List departmentIds) { - return new DefaultDepartmentRelations(context, () -> departmentIds); - } - - @Override - public OrgRelations getOrgRelations(List orgIds) { - return new DefaultOrgRelations(context, () -> orgIds); - } - - @Override - public LinkedRelations getRelations(List target) { - - return new DefaultLinkedRelations(context, () -> target); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/ServiceContext.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/ServiceContext.java deleted file mode 100644 index b482409e0..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/relations/ServiceContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.relations; - -import lombok.Getter; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.service.organizational.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Getter -@Component -public class ServiceContext { - - @Autowired - private PersonService personService; - - @Autowired - private PositionService positionService; - - @Autowired - private DepartmentService departmentService; - - @Autowired - private OrganizationalService organizationalService; - - @Autowired - private RelationInfoService relationInfoService; - - @Autowired - private RelationDefineService relationDefineService; - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/CustomSqlTermConfiguration.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/CustomSqlTermConfiguration.java deleted file mode 100644 index 97e5ba90e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/CustomSqlTermConfiguration.java +++ /dev/null @@ -1,386 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.web.service.organizational.DepartmentService; -import org.hswebframework.web.service.organizational.DistrictService; -import org.hswebframework.web.service.organizational.OrganizationalService; -import org.hswebframework.web.service.organizational.PositionService; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Configuration -public class CustomSqlTermConfiguration { - - //======================================================================= - @Bean - public InServiceTreeInSqlTerm distInSqlTerm(DistrictService districtService) { - return new InServiceTreeInSqlTerm<>(districtService, "dist", "s_district", false, false); - } - - @Bean - public InServiceTreeInSqlTerm distInSqlTermParent(DistrictService districtService) { - return new InServiceTreeInSqlTerm<>(districtService, "dist", "s_district", false, true); - } - - @Bean - public InServiceTreeInSqlTerm distNotInSqlTerm(DistrictService districtService) { - return new InServiceTreeInSqlTerm<>(districtService, "dist", "s_district", true, false); - } - - @Bean - public InServiceTreeInSqlTerm distNotInSqlTermParent(DistrictService districtService) { - return new InServiceTreeInSqlTerm<>(districtService, "dist", "s_district", true, true); - } - - //======================================================================= - @Bean - public InServiceTreeInSqlTerm orgInSqlTerm(OrganizationalService organizationalService) { - return new InServiceTreeInSqlTerm<>(organizationalService, "org", "s_organization", false, false); - } - - @Bean - public InServiceTreeInSqlTerm orgNotInSqlTerm(OrganizationalService organizationalService) { - return new InServiceTreeInSqlTerm<>(organizationalService, "org", "s_organization", true, false); - } - - @Bean - public InServiceTreeInSqlTerm orgInSqlTermParent(OrganizationalService organizationalService) { - return new InServiceTreeInSqlTerm<>(organizationalService, "org", "s_organization", false, true); - } - - @Bean - public InServiceTreeInSqlTerm orgNotInSqlTermParent(OrganizationalService organizationalService) { - return new InServiceTreeInSqlTerm<>(organizationalService, "org", "s_organization", true, true); - } - - //======================================================================= - @Bean - public InServiceTreeInSqlTerm departmentInSqlTerm(DepartmentService departmentService) { - return new InServiceTreeInSqlTerm<>(departmentService, "dept", "s_department", false, false); - } - - @Bean - public InServiceTreeInSqlTerm departmentNotInSqlTerm(DepartmentService departmentService) { - return new InServiceTreeInSqlTerm<>(departmentService, "dept", "s_department", true, false); - } - - @Bean - public InServiceTreeInSqlTerm departmentInSqlTermParent(DepartmentService departmentService) { - return new InServiceTreeInSqlTerm<>(departmentService, "dept", "s_department", false, true); - } - - @Bean - public InServiceTreeInSqlTerm departmentNotInSqlTermParent(DepartmentService departmentService) { - return new InServiceTreeInSqlTerm<>(departmentService, "dept", "s_department", true, true); - } - - - /*====================================================================================*/ - - @Bean - public UserInSqlTerm userInPositionSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, false, "user-in-position", positionService); - } - - @Bean - public UserInSqlTerm userNotInPositionSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(true, false, "user-not-in-position", positionService); - } - - @Bean - public UserInSqlTerm userInPositionChildSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, true, "user-in-position-child", positionService).forChild(); - } - - @Bean - public UserInSqlTerm userNotInPositionChildSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(true, true, "user-not-in-position-child", positionService).forChild(); - } - - @Bean - public UserInSqlTerm userInPositionParentSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, true, "user-in-position-parent", positionService).forParent(); - } - - @Bean - public UserInSqlTerm userNotInPositionParentSqlTerm(PositionService positionService) { - return new UserInPositionSqlTerm(true, true, "user-not-in-position-parent", positionService).forParent(); - } - /*====================================================================================*/ - - @Bean - public UserInSqlTerm personInPositionSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, false, "person-in-position", positionService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInPositionSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(true, false, "person-not-in-position", positionService).forPerson(); - } - - @Bean - public UserInSqlTerm personInPositionChildSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, true, "person-in-position-child", positionService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInPositionChildSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(true, true, "person-not-in-position-child", positionService).forPerson(); - } - - @Bean - public UserInSqlTerm personInPositionParentSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(false, true, "person-in-position-parent", positionService).forPerson().forParent(); - } - - @Bean - public UserInSqlTerm personNotInPositionParentSqlTerm(PositionService positionService) { - - return new UserInPositionSqlTerm(true, true, "person-not-in-position-parent", positionService).forPerson().forParent(); - } - - /*====================================================================================*/ - @Bean - public UserInSqlTerm userInDepartmentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, false, "user-in-department", departmentService); - } - - @Bean - public UserInSqlTerm userNotInDepartmentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, false, "user-not-in-department", departmentService); - } - - @Bean - public UserInSqlTerm userInDepartmentChildSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, true, "user-in-department-child", departmentService).forChild(); - } - - @Bean - public UserInSqlTerm userNotInDepartmentChildSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, true, "user-not-in-department-child", departmentService).forChild(); - } - - - @Bean - public UserInSqlTerm userInDepartmentParentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, true, "user-in-department-parent", departmentService).forParent(); - } - - @Bean - public UserInSqlTerm userNotInDepartmentParentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, true, "user-not-in-department-parent", departmentService).forParent(); - } - - /*====================================================================================*/ - @Bean - public UserInSqlTerm personInDepartmentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, false, "person-in-department", departmentService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInDepartmentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, false, "person-not-in-department", departmentService).forPerson(); - } - - @Bean - public UserInSqlTerm personInDepartmentChildSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, true, "person-in-department-child", departmentService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInDepartmentChildSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, true, "person-not-in-department-child", departmentService).forPerson(); - } - - @Bean - public UserInSqlTerm personInDepartmentParentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(false, true, "person-in-department-parent", departmentService) - .forPerson() - .forParent(); - } - - @Bean - public UserInSqlTerm personNotInDepartmentParentSqlTerm(DepartmentService departmentService) { - - return new UserInDepartmentSqlTerm(true, true, "person-not-in-department-parent", departmentService) - .forPerson() - .forParent(); - } - - - /*====================================================================================*/ - @Bean - public UserInSqlTerm userInOrgSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, false, "user-in-org", organizationalService); - } - - @Bean - public UserInSqlTerm userNotInOrgSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, false, "user-not-in-org", organizationalService); - } - - @Bean - public UserInSqlTerm userInOrgChildSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, true, "user-in-org-child", organizationalService); - } - - @Bean - public UserInSqlTerm userNotInOrgChildSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, true, "user-not-in-org-child", organizationalService); - } - - - @Bean - public UserInSqlTerm userInOrgParentSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, true, "user-in-org-parent", organizationalService).forParent(); - } - - @Bean - public UserInSqlTerm userNotInOrgParentSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, true, "user-not-in-org-parent", organizationalService).forParent(); - } - - - /*====================================================================================*/ - @Bean - public UserInSqlTerm personInOrgSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, false, "person-in-org", organizationalService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInOrgSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, false, "person-not-in-org", organizationalService).forPerson(); - } - - @Bean - public UserInSqlTerm personInOrgChildSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, true, "person-in-org-child", organizationalService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInOrgChildSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, true, "person-not-in-org-child", organizationalService).forPerson(); - } - - @Bean - public UserInSqlTerm personInOrgParentSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(false, true, "person-in-org-parent", organizationalService).forPerson().forParent(); - } - - @Bean - public UserInSqlTerm personNotInOrgParentSqlTerm(OrganizationalService organizationalService) { - - return new UserInOrgSqlTerm(true, true, "person-not-in-org-parent", organizationalService).forPerson().forParent(); - } - - /*====================================================================================*/ - @Bean - public UserInSqlTerm userInDistSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, false, "user-in-dist", districtService); - } - - @Bean - public UserInSqlTerm userNotInDistSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, false, "user-not-in-dist", districtService); - } - - @Bean - public UserInSqlTerm userInDistChildSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, true, "user-in-dist-child", districtService); - } - - @Bean - public UserInSqlTerm userNotInDistChildSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, true, "user-not-in-dist-child", districtService); - } - - @Bean - public UserInSqlTerm userInDistParentSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, true, "user-in-dist-parent", districtService).forParent(); - } - - @Bean - public UserInSqlTerm userNotInDistParentSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, true, "user-not-in-dist-parent", districtService).forParent(); - } - - /*====================================================================================*/ - @Bean - public UserInSqlTerm personInDistSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, false, "person-in-dist", districtService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInDistSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, false, "person-not-in-dist", districtService).forPerson(); - } - - @Bean - public UserInSqlTerm personInDistChildSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, true, "person-in-dist-child", districtService).forPerson(); - } - - @Bean - public UserInSqlTerm personNotInDistChildSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, true, "person-not-in-dist-child", districtService).forPerson(); - } - - @Bean - public UserInSqlTerm personInDistParentSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(false, true, "person-in-dist-parent", districtService).forPerson().forParent(); - } - - @Bean - public UserInSqlTerm personNotInDistParentSqlTerm(DistrictService districtService) { - - return new UserInDistSqlTerm(true, true, "person-not-in-dist-parent", districtService).forPerson().forParent(); - } - - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/InServiceTreeInSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/InServiceTreeInSqlTerm.java deleted file mode 100644 index 9f2205ab0..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/InServiceTreeInSqlTerm.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.web.commons.entity.TreeSupportEntity; -import org.hswebframework.web.dao.mybatis.mapper.TreeStructureSqlTermCustomizer; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.service.QueryService; - -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public class InServiceTreeInSqlTerm extends TreeStructureSqlTermCustomizer { - - private QueryService, PK> treeService; - - private String tableName; - - public InServiceTreeInSqlTerm(QueryService, PK> service, - String prefix, - String tableName, - boolean not, boolean parent) { - super(prefix + "-" + (parent ? "parent" : "child") + "-" + (not ? "not-" : "") + "in", not, parent); - this.treeService = service; - this.tableName = tableName; - } - - @Override - protected String getTableName() { - String db = DataSourceHolder.databaseSwitcher().currentDatabase(); - if (db != null) { - return db.concat(".").concat(tableName); - } - return tableName; - } - - @Override - protected List getTreePathByTerm(List termValue) { - - List idList = ((List) termValue); - - return treeService.selectByPk(idList) - .stream() - .map(TreeSupportEntity::getPath) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDepartmentSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDepartmentSqlTerm.java deleted file mode 100644 index 3fd26cf79..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDepartmentSqlTerm.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; -import org.hswebframework.web.service.organizational.DepartmentService; - -import java.util.List; - - -/** - * 查询岗位中的用户 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class UserInDepartmentSqlTerm extends UserInSqlTerm { - - private boolean not; - - public UserInDepartmentSqlTerm(boolean not, boolean child, String term, DepartmentService departmentService) { - super(term, departmentService); - setChild(child); - this.not = not; - } - - @Override - public String getTableName() { - return "_dept"; - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - - Dialect dialect = column.getTableMetaData().getDatabaseMetaData().getDialect(); - - SqlAppender appender = new SqlAppender(); - appender.addSpc(not ? "not" : "", "exists(select 1 from ", - getTableFullName("s_person_position")," _tmp,", - getTableFullName("s_position")," _pos,", - getTableFullName("s_person")," _person"); - if (isChild() || isParent()) { - appender.addSpc(",",getTableFullName("s_department")," _dept"); - } - appender.addSpc("where _person.u_id=_tmp.person_id and _tmp.position_id = _pos.u_id and _person.u_id=_tmp.person_id" - , "and", createColumnName(column, tableAlias), "=", isForPerson() ? "_tmp.person_id" : "_person.user_id"); - if (isChild() || isParent()) { - appender.addSpc("and _dept.u_id=_pos.department_id"); - } - - List positionIdList = BoostTermTypeMapper.convertList(column, termValue.getOld()); - if (!positionIdList.isEmpty()) { - appender.addSpc("and"); - termValue.setValue(appendCondition(positionIdList, wherePrefix, appender, "_pos.department_id", dialect)); - } - - appender.add(")"); - return appender; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDistSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDistSqlTerm.java deleted file mode 100644 index 9e2ed1557..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInDistSqlTerm.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; -import org.hswebframework.web.service.organizational.DistrictService; - -import java.util.List; - - -/** - * 查询岗位中的用户 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class UserInDistSqlTerm extends UserInSqlTerm { - - private boolean not; - - public UserInDistSqlTerm(boolean not, boolean child, String term, DistrictService service) { - super(term, service); - setChild(child); - this.not = not; - } - - @Override - public String getTableName() { - return "_dist"; - } - - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - Dialect dialect = column.getTableMetaData().getDatabaseMetaData().getDialect(); - - SqlAppender appender = new SqlAppender(); - appender.addSpc(not ? "not" : "", "exists(select 1 from ", - getTableFullName("s_person_position"), " _tmp,", - getTableFullName("s_position"), " _pos,", - getTableFullName("s_person"), " _person,", - getTableFullName("s_department"), " _dept,", - getTableFullName("s_organization"), " _org"); - if (isChild() || isParent()) { - appender.addSpc(",",getTableFullName("s_district")," _dist"); - } - appender.addSpc("where _person.u_id=_tmp.person_id and _tmp.position_id = _pos.u_id and _person.u_id=_tmp.person_id and _dept.u_id=_pos.department_id and _org.u_id=_dept.org_id" - , "and", createColumnName(column, tableAlias), "=", isForPerson() ? "_tmp.person_id" : "_person.user_id"); - if (isChild() || isParent()) { - appender.addSpc("and _org.district_id=_dist.u_id"); - } - List positionIdList = BoostTermTypeMapper.convertList(column, termValue.getOld()); - if (!positionIdList.isEmpty()) { - appender.addSpc("and"); - termValue.setValue(appendCondition(positionIdList, wherePrefix, appender, "_org.district_id", dialect)); - } - - appender.add(")"); - return appender; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInOrgSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInOrgSqlTerm.java deleted file mode 100644 index 8f5efc751..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInOrgSqlTerm.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; -import org.hswebframework.web.service.organizational.OrganizationalService; - -import java.util.List; - - -/** - * 查询岗位中的用户 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class UserInOrgSqlTerm extends UserInSqlTerm { - - private boolean not; - - public UserInOrgSqlTerm(boolean not, boolean child, String term, OrganizationalService service) { - super(term, service); - setChild(child); - this.not = not; - } - - @Override - public String getTableName() { - return "_org"; - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - Dialect dialect = column.getTableMetaData().getDatabaseMetaData().getDialect(); - - SqlAppender appender = new SqlAppender(); - appender.addSpc(not ? "not" : "", "exists(select 1 from ", - getTableFullName("s_person_position")," _tmp,", - getTableFullName("s_position")," _pos,", - getTableFullName("s_department")," _dept,", - getTableFullName("s_person")," _person"); - if (isChild()||isParent()) { - appender.addSpc(",",getTableFullName("s_organization")," _org"); - } - appender.addSpc("where _person.u_id=_tmp.person_id and _tmp.position_id = _pos.u_id and _person.u_id=_tmp.person_id and _dept.u_id=_pos.department_id" - , "and", createColumnName(column, tableAlias), "=", isForPerson() ? "_tmp.person_id" : "_person.user_id"); - if (isChild()||isParent()) { - appender.addSpc("and _org.u_id=_dept.org_id"); - } - List positionIdList = BoostTermTypeMapper.convertList(column, termValue.getOld()); - if (!positionIdList.isEmpty()) { - appender.addSpc("and"); - termValue.setValue(appendCondition(positionIdList, wherePrefix, appender, "_dept.org_id", dialect)); - } - - appender.add(")"); - return appender; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInPositionSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInPositionSqlTerm.java deleted file mode 100644 index df52d17a6..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInPositionSqlTerm.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; -import org.hswebframework.web.service.organizational.PositionService; - -import java.util.List; - - -/** - * 查询岗位中的用户 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class UserInPositionSqlTerm extends UserInSqlTerm { - - private boolean not; - - public UserInPositionSqlTerm(boolean not, boolean child, String term, PositionService positionService) { - super(term, positionService); - setChild(child); - this.not = not; - } - - @Override - public String getTableName() { - return "_pos"; - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - Dialect dialect=column.getTableMetaData().getDatabaseMetaData().getDialect(); - - SqlAppender appender = new SqlAppender(); - appender.addSpc(not ? "not" : "", "exists(select 1 from ",getTableFullName("s_person_position")," _tmp"); - if (isChild()||isParent()) { - appender.addSpc(",",getTableFullName("s_position")," _pos"); - } - if (!isForPerson()) { - appender.addSpc(",",getTableFullName("s_person")," _person"); - } - - appender.addSpc("where ", - createColumnName(column, tableAlias), "=", - isForPerson() ? " _tmp.person_id" : "_person.user_id and _person.u_id=_tmp.person_id"); - - if (isChild()||isParent()) { - appender.addSpc("and _pos.u_id=_tmp.position_id"); - } - - List positionIdList = BoostTermTypeMapper.convertList(column, termValue.getOld()); - if (!positionIdList.isEmpty()) { - appender.addSpc("and"); - termValue.setValue(appendCondition(positionIdList, wherePrefix, appender, "_tmp.position_id",dialect)); - } - - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInSqlTerm.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInSqlTerm.java deleted file mode 100644 index bda1c85cf..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/java/org/hswebframework/web/service/organizational/simple/terms/UserInSqlTerm.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.hswebframework.web.service.organizational.simple.terms; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.ezorm.rdb.render.dialect.RenderPhase; -import org.hswebframework.ezorm.rdb.render.dialect.function.SqlFunction; -import org.hswebframework.web.commons.entity.TreeSupportEntity; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.service.QueryService; - -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - - -/** - * 查询岗位中的用户 - * - * @author zhouhao - * @since 3.0.0-RC - */ -@Slf4j -public abstract class UserInSqlTerm extends AbstractSqlTermCustomizer { - - - @Setter - @Getter - private boolean child; - - @Getter - @Setter - private boolean parent; - - @Getter - @Setter - private boolean forPerson; - - QueryService, PK> treeService; - - - public UserInSqlTerm forChild() { - setChild(true); - return this; - } - - public UserInSqlTerm forParent() { - setParent(true); - return this; - } - - public UserInSqlTerm forPerson() { - this.forPerson = true; - return this; - } - - public UserInSqlTerm(String term, QueryService, PK> treeService) { - super(term); - this.treeService = treeService; - } - - public abstract String getTableName(); - - protected String getTableFullName(String tableName){ - String db = DataSourceHolder.databaseSwitcher().currentDatabase(); - if (db != null) { - return db.concat(".").concat(tableName); - } - return tableName; - } - - protected Object appendCondition(List values, String wherePrefix, SqlAppender appender, String column, Dialect dialect) { - if (!child&&!parent) { - appender.addSpc(column); - return super.appendCondition(values, wherePrefix, appender); - } else { - List paths = getTreePathByTerm(values) - .stream() - .map(path -> parent ? path : path.concat("%")) - .collect(Collectors.toList()); - int len = paths.size(); - if (len == 0) { - appender.add("1=2"); - } else { - appender.add("("); - for (int i = 0; i < len; i++) { - if (i > 0) { - appender.addSpc("or"); - } - if (parent) { - SqlFunction function = dialect.getFunction(SqlFunction.concat); - String concat; - if (function == null) { - concat = getTableName() + ".path"; - log.warn("数据库方言未支持concat函数,你可以调用Dialect.installFunction进行设置!"); - } else { - concat = function.apply(SqlFunction.Param.of(RenderPhase.where, Arrays.asList(getTableName() + ".path", "'%'"))); - } - // aaa-vvv-ccc like aaa% - appender.add("#{", wherePrefix, ".value.value[", i, "]}", " like ", concat); - } else { - appender.add(getTableName(), ".path like #{", wherePrefix, ".value.value[", i, "]}"); - } - - } - appender.add(")"); - } - return paths; - } - } - - - protected List getTreePathByTerm(List termValue) { - - List idList = ((List) termValue); - - return treeService.selectByPk(idList) - .stream() - .map(TreeSupportEntity::getPath) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DepartmentMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DepartmentMapper.xml deleted file mode 100644 index 032d874c2..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DepartmentMapper.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DistrictMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DistrictMapper.xml deleted file mode 100644 index 050478f23..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/DistrictMapper.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/OrganizationalMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/OrganizationalMapper.xml deleted file mode 100644 index ca937a9e4..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/OrganizationalMapper.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonMapper.xml deleted file mode 100644 index db7674502..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonMapper.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonPositionMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonPositionMapper.xml deleted file mode 100644 index dc4fdfd36..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PersonPositionMapper.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where person_id=#{personId} - - - - - delete from ${_fullTableName} where position_id=#{positionId} - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PositionMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PositionMapper.xml deleted file mode 100644 index 4757e2a8f..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/PositionMapper.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationDefineMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationDefineMapper.xml deleted file mode 100644 index c624f8542..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationDefineMapper.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationInfoMapper.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationInfoMapper.xml deleted file mode 100644 index e1fa6d30c..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/organizational/RelationInfoMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/pom.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/pom.xml deleted file mode 100644 index 505c7ef6a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - hsweb-system-organizational - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-organizational-local - ${project.version} - - - org.hswebframework.web - hsweb-system-organizational-web - ${project.version} - - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/java/org/hswebframework/web/organizational/starter/AuthorizationAutoConfigration.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/java/org/hswebframework/web/organizational/starter/AuthorizationAutoConfigration.java deleted file mode 100644 index 45d956ac3..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/java/org/hswebframework/web/organizational/starter/AuthorizationAutoConfigration.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2019 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.organizational.starter; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.organizational.simple" - , "org.hswebframework.web.controller.organizational"}) -public class AuthorizationAutoConfigration { -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index ccaa9acb2..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.organizational.starter.AuthorizationAutoConfigration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index b3d38d80e..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2019 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. - * - */ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-organizational", - author: "admin@hsweb.me", - comment: "组织架构" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.0", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_district") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("区域名称,如重庆市").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("full_name").alias("fullName").comment("区域全程,如重庆市江津区").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("level_name").alias("levelName").comment("区域级别名称,如:省").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("level_code").alias("levelCode").comment("区域级别编码,如:province").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("code").alias("code").comment("行政区域代码,如:500000").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("parent_id").alias("parentId").comment("父级行政区域").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("path").alias("path").comment("树路径,如: asb3-lsat").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("describe").alias("describe").comment("说明").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("sort_index").alias("sortIndex").comment("排序索引").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .index().name("idx_district_parent_id").column("parent_id").commit() - .index().name("idx_district_path").column("path").commit() - - .comment("行政区域").commit(); - - database.createOrAlter("s_organization") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("名称").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("full_name").alias("fullName").comment("全称").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("code").alias("code").comment("机构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("district_id").alias("districtId").comment("所在行政区域ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("optional_roles").alias("optionalRoles").comment("可选角色").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("parent_id").alias("parentId").comment("上级机构id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("path").alias("path").comment("树定位码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).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() - .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .index().name("idx_org_parent_id").column("parent_id").commit() - .index().name("idx_org_path").column("path").commit() - .index().name("idx_org_district_id").column("district_id").commit() - - .comment("组织,公司").commit(); - - database.createOrAlter("s_department") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("名称").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("org_id").alias("orgId").comment("所在组织id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("code").alias("code").comment("部门编码").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("path").alias("path").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).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() - .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .index().name("idx_dept_parent_id").column("parent_id").commit() - .index().name("idx_dept_path").column("path").commit() - .index().name("idx_dept_org_id").column("org_id").commit() - - .comment("部门").commit(); - - database.createOrAlter("s_position") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("职位名称").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("department_id").alias("departmentId").comment("部门id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("roles").alias("roles").comment("持有的角色").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("parent_id").alias("parentId").comment("父级id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("path").alias("path").comment("树结构编码").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("sort_index").alias("sortIndex").comment("排序索引").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("level").alias("level").comment("级别").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .index().name("idx_position_parent_id").column("parent_id").commit() - .index().name("idx_position_path").column("path").commit() - .index().name("idx_position_dept_id").column("department_id").commit() - - .comment("职位").commit(); - - database.createOrAlter("s_person") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("姓名").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("sex").alias("sex").comment("性别").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("email").alias("email").comment("电子邮箱").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("phone").alias("phone").comment("联系电话").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("photo").alias("photo").comment("照片").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("user_id").alias("userId").comment("关联用户id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .index().name("idx_person_user_id").column("user_id").commit() - - .comment("人员").commit(); - - database.createOrAlter("s_person_position") - .addColumn().name("person_id").alias("personId").comment("人员id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("position_id").alias("positionId").comment("职位id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .index().name("idx_person_pos_person_id").column("person_id").commit() - .index().name("idx_person_pos_position_id").column("position_id").commit() - - .comment("人员职位关联").commit(); - - database.createOrAlter("s_relation_def") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("关系名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("type_id").alias("typeId").comment("关系类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4,0).commit() - .index().name("idx_relation_def_type").column("type_id").commit() - - .comment("关系定义").commit(); - - database.createOrAlter("s_relation_info") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("relation_id").alias("relationId").comment("关系定义id").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("relation_from").alias("relationFrom").comment("关系从").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("relation_to").alias("relationTo").comment("关系至").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("relation_type_from").alias("relationTypeFrom").comment("关系类型从,如:人员").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("relation_type_to").alias("relationTypeTo").comment("关系类型至,如:部门").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.NUMERIC).length(4,0).commit() - .index().name("idx_relation_r_id").column("relation_id").commit() - .index().name("idx_relation_rt_from").column("relation_type_from").commit() - .index().name("idx_relation_rt_to").column("relation_type_to").commit() - .index().name("idx_relation_r_to").column("relation_to").commit() - .index().name("idx_relation_r_from").column("relation_from").commit() - - .comment("关系信息").commit(); - -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/DepartmentTests.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/DepartmentTests.java deleted file mode 100644 index 4ccdac06b..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/DepartmentTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 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.starter.organizational; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class DepartmentTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - DepartmentEntity entity = entityFactory.newInstance(DepartmentEntity.class); - //todo 设置测试属性 - entity.setName("test"); - entity.setCode("2"); - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/department").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/department/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(DepartmentEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(DepartmentEntity.class)))); - //todo 修改测试属性 - DepartmentEntity newEntity = entityFactory.newInstance(DepartmentEntity.class); - newEntity.setName("test"); - - result = testPut("/department/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/department/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/department/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/department/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/OrganizationalTests.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/OrganizationalTests.java deleted file mode 100644 index 90bf26d36..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/OrganizationalTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 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.starter.organizational; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class OrganizationalTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - OrganizationalEntity entity = entityFactory.newInstance(OrganizationalEntity.class); - //todo 设置测试属性 - entity.setName("test"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/department").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/department/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(OrganizationalEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(OrganizationalEntity.class)))); - //todo 修改测试属性 - OrganizationalEntity newEntity = entityFactory.newInstance(OrganizationalEntity.class); - newEntity.setName("test"); - - result = testPut("/department/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/department/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/department/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/department/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PersonTests.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PersonTests.java deleted file mode 100644 index 389ba0c4d..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PersonTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 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.starter.organizational; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class PersonTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - PersonEntity entity = entityFactory.newInstance(PersonEntity.class); - //todo 设置测试属性 - entity.setName("test"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/person").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/person/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(PersonEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(PersonEntity.class)))); - //todo 修改测试属性 - PersonEntity newEntity = entityFactory.newInstance(PersonEntity.class); - newEntity.setName("test2"); - - result = testPut("/person/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/person/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/person/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/person/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PositionTests.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PositionTests.java deleted file mode 100644 index 953de8e92..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/PositionTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 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.starter.organizational; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; - -/** - * TODO 完善单元测试 - * - * @author hsweb-generator-online - */ -public class PositionTests extends SimpleWebApplicationTests { - - @Autowired - private FastJsonGenericHttpMessageConverter fastJsonHttpMessageConverter; - - @Test - public void testCrud() throws Exception { - PositionEntity entity = entityFactory.newInstance(PositionEntity.class); - //todo 设置测试属性 - entity.setName("test"); - - // test add data - String requestBody = JSON.toJSONString(entity); - JSONObject result = testPost("/position").setUp(setup -> setup.contentType(MediaType.APPLICATION_JSON).content(requestBody)).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - String id = result.getString("result"); - Assert.assertNotNull(id); - entity.setId(id); - // test get data - result = testGet("/position/" + id).exec().resultAsJson(); - entity = result.getObject("result", entityFactory.getInstanceType(PositionEntity.class)); - - Assert.assertEquals(200, result.get("status")); - Assert.assertNotNull(result.getJSONObject("result")); - - Assert.assertEquals(fastJsonHttpMessageConverter.converter(entity), - fastJsonHttpMessageConverter.converter(result.getObject("result", entityFactory.getInstanceType(PositionEntity.class)))); - //todo 修改测试属性 - PositionEntity newEntity = entityFactory.newInstance(PositionEntity.class); - newEntity.setName("test"); - - result = testPut("/position/" + id) - .setUp(setup -> - setup.contentType(MediaType.APPLICATION_JSON) - .content(JSON.toJSONString(newEntity))) - .exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/position/" + id).exec().resultAsJson(); - result = result.getJSONObject("result"); - Assert.assertNotNull(result); - - result = testDelete("/position/" + id).exec().resultAsJson(); - Assert.assertEquals(200, result.get("status")); - - result = testGet("/position/" + id).exec().resultAsJson(); - Assert.assertEquals(404, result.get("status")); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/RelationsManagerTests.groovy b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/RelationsManagerTests.groovy deleted file mode 100644 index 618fd9574..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/RelationsManagerTests.groovy +++ /dev/null @@ -1,193 +0,0 @@ -package org.hswebframework.web.starter.organizational - -import org.hswebframework.web.bean.FastBeanCopier -import org.hswebframework.web.entity.organizational.SimpleDepartmentEntity -import org.hswebframework.web.entity.organizational.SimpleOrganizationalEntity -import org.hswebframework.web.entity.organizational.SimplePersonAuthBindEntity -import org.hswebframework.web.entity.organizational.SimplePositionEntity -import org.hswebframework.web.organizational.authorization.relation.PersonRelations -import org.hswebframework.web.organizational.authorization.relation.Relation -import org.hswebframework.web.organizational.authorization.relation.RelationsManager -import org.hswebframework.web.service.organizational.simple.relations.ServiceContext -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import spock.lang.Specification - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -class RelationsManagerTests extends Specification { - - @Autowired - RelationsManager relationsManager; - - @Autowired - ServiceContext serviceContext; - - def createData() { - def orgData = [ - id : "10001", - name : "总公司", - code : "000001", - children: [ - [id: "10002", name: "重庆分公司", code: "0000011"], - [id: "10003", name: "北京分公司", code: "0000012"] - ] - ] - def departmentData = [ - [ - id : "100010001", - name : "人事部", - code : "100010001", - orgId : "10001", - position: [ - - [ - id : "1", - name : "总监", - children: - [[ - id : "10001", - name : "助理", - departmentId: "100010001" - ]] - ], [ - id : "2", - name: "人事专员" - ] - - ] - ], - [ - id : "100020001", - name : "研发部", - code : "100020001", - orgId : "10002", - position: [ - [ - id : "3", - name : "经理", - children: - [[ - id : "3001", - name : "助理", - departmentId: "100020001" - ]] - ], [ - id : "4", - name: "技术人员" - ] - - ] - ], - [ - id : "100030001", - name : "研发部", - code : "100030001", - orgId : "10003", - position: [ - [ - id : "5", - name : "经理", - children: - [[ - id : "5001", - name : "助理", - departmentId: "100030001" - ]] - ], [ - id : "6", - name: "技术人员" - ] - - ] - ] - ] - - def personData = [ - [ - id : "1", - name : "张三", - positionIds: ["1"] - ], - [ - id : "2", - name : "李四", - positionIds: ["10001"] - ], - [ - id : "3", - name : "王五", - positionIds: ["3"] - ], - [ - id : "4", - name : "赵六", - positionIds: ["4"] - ], - [ - id : "5", - name : "周七", - positionIds: ["2"] - ], - [ - id : "6", - name : "宋九", - positionIds: ["2"] - ] - ] - serviceContext.getOrganizationalService() - .insert(FastBeanCopier.copy(orgData, new SimpleOrganizationalEntity())); - departmentData.forEach({ department -> - serviceContext.getDepartmentService().insert(FastBeanCopier.copy(department, new SimpleDepartmentEntity())); - department.position.forEach({ position -> - position.departmentId = department.id; - serviceContext.getPositionService().insert(FastBeanCopier.copy(position, new SimplePositionEntity())); - }) - }) - personData.forEach({ person -> - serviceContext.getPersonService().insert(FastBeanCopier.copy(person, new SimplePersonAuthBindEntity())) - }) - } - - def setup() { - expect: - relationsManager != null - - } - - def "Test"() { - setup: - createData() - and: - def me = relationsManager.getPersonRelationsByPersonId("2") - def pre = relationsManager.getPersonRelationsByPersonId("4") - - def relationList = me - .department() - .relations("总监") - .all() - - def orgRelationList = pre - .org() - .andParents() - .department() - .relations("人事专员") - .all() - - expect: - relationList != null - !relationList.isEmpty() - orgRelationList != null - !orgRelationList.isEmpty() - println relationList - println orgRelationList - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/TestApplication.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/TestApplication.java deleted file mode 100644 index dcbe97e40..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/java/org/hswebframework/web/starter/organizational/TestApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.starter.organizational; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.web.WebAppConfiguration; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@SpringBootApplication -@WebAppConfiguration -public class TestApplication { - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/resources/application.yml deleted file mode 100644 index ed04332b6..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-starter/src/test/resources/application.yml +++ /dev/null @@ -1,16 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:org_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 组织架构测试 - version: 3.0.0 -logging: - level: - org.hswebframework: debug \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/pom.xml b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/pom.xml deleted file mode 100644 index e9df3062a..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - hsweb-system-organizational - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational-web - - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-organizational-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DepartmentController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DepartmentController.java deleted file mode 100644 index df50756b8..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DepartmentController.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.RequiresDataAccess; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.organizational.DepartmentService; -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.department:department}") -@Authorize(permission = "department", description = "部门管理", dataAccess = @RequiresDataAccess) -@Api(value = "部门管理",tags = "组织架构-部门管理") -public class DepartmentController implements SimpleGenericEntityController { - - private DepartmentService departmentService; - - @Autowired - public void setDepartmentService(DepartmentService departmentService) { - this.departmentService = departmentService; - } - - @Override - public DepartmentService getService() { - return departmentService; - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DistrictController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DistrictController.java deleted file mode 100644 index a4a1c0cba..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/DistrictController.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.hswebframework.web.controller.organizational; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.organizational.DistrictEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.organizational.DistrictService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 行政区划管理 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.district:district}") -@Authorize(permission = "district", description = "行政区划管理") -@Api(value = "行政区划管理", tags = "组织架构-行政区划管理") -public class DistrictController implements SimpleGenericEntityController { - - private DistrictService districtService; - - @Autowired - public void setDistrictService(DistrictService districtService) { - this.districtService = districtService; - } - - @Override - public DistrictService getService() { - return districtService; - } - - @GetMapping("/code/{code}") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("根据行政区划代码获取") - public ResponseMessage getByCode(@PathVariable String code) { - return ResponseMessage.ok(districtService.selectByCode(code)); - } - - @GetMapping("/children/{parentId}") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("获取子级行政区划") - public ResponseMessage> getByParentId(@PathVariable String parentId) { - return ResponseMessage.ok(districtService.selectChildNode(parentId)); - } - - @GetMapping("/children/{parentId}/all") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("获取所有子级行政区划") - public ResponseMessage> getAllByParentId(@PathVariable String parentId) { - return ResponseMessage.ok(districtService.selectAllChildNode(parentId)); - } - - @GetMapping("/all") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("获取全部行政区划") - public ResponseMessage> all() { - return ResponseMessage.ok(districtService.select()); - } - - @PatchMapping("/batch") - @Authorize(action = Permission.ACTION_UPDATE) - @ApiOperation("批量修改数据") - public ResponseMessage updateBatch(@RequestBody List batch) { - districtService.updateBatch(batch); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/disable") - @Authorize(action = Permission.ACTION_DISABLE) - @ApiOperation("禁用行政区划") - public ResponseMessage disable(@PathVariable String id) { - districtService.disable(id); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/enable") - @Authorize(action = Permission.ACTION_ENABLE) - @ApiOperation("启用行政区划") - public ResponseMessage enable(@PathVariable String id) { - districtService.enable(id); - return ResponseMessage.ok(); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/OrganizationalController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/OrganizationalController.java deleted file mode 100644 index eed9bb0b4..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/OrganizationalController.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.RequiresDataAccess; -import org.hswebframework.web.commons.entity.PagerResult; -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.message.ResponseMessage; -import org.hswebframework.web.entity.organizational.DepartmentEntity; -import org.hswebframework.web.entity.organizational.OrganizationalEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.organizational.OrganizationalService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 组织 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.organizational:organizational}") -@Authorize(permission = "organizational",description = "机构管理",dataAccess = @RequiresDataAccess) -@Api(value = "机构管理",tags = "组织架构-机构管理") -public class OrganizationalController implements SimpleGenericEntityController { - - private OrganizationalService organizationalService; - - @Autowired - public void setOrganizationalService(OrganizationalService organizationalService) { - this.organizationalService = organizationalService; - } - - @Override - public OrganizationalService getService() { - return organizationalService; - } - - @PatchMapping("/batch") - @Authorize(action = Permission.ACTION_UPDATE) - @ApiOperation("批量修改数据") - public ResponseMessage updateBatch(@RequestBody List batch) { - organizationalService.updateBatch(batch); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/disable") - @Authorize(action = Permission.ACTION_DISABLE) - @ApiOperation("禁用机构") - public ResponseMessage disable(@PathVariable String id) { - organizationalService.disable(id); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/enable") - @Authorize(action = Permission.ACTION_ENABLE) - @ApiOperation("启用机构") - public ResponseMessage enable(@PathVariable String id) { - organizationalService.enable(id); - return ResponseMessage.ok(); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PersonController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PersonController.java deleted file mode 100644 index 5825ebf57..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PersonController.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.RequiresDataAccess; -import org.hswebframework.web.authorization.define.Phased; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.organizational.PersonAuthBindEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.PersonnelAuthenticationHolder; -import org.hswebframework.web.service.organizational.PersonService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 人员 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.person:person}") -@Authorize(permission = "person", description = "人员管理", dataAccess = @RequiresDataAccess) -@Api(value = "人员管理", tags = "组织架构-人员管理") -public class PersonController implements SimpleGenericEntityController { - - private PersonService personService; - - @Autowired - public void setPersonService(PersonService personService) { - this.personService = personService; - } - - @Override - public PersonService getService() { - return personService; - } - - @Override - public ResponseMessage> list(QueryParamEntity param) { - return SimpleGenericEntityController.super.list(param); - } - - @GetMapping("/me") - @ApiOperation("查看当前登录用户的人员信息") - @Authorize(merge = false) - public ResponseMessage getLoginUserPerson() { - PersonnelAuthentication authorization = PersonnelAuthentication - .current() - .orElseThrow(NotFoundException::new); - return getDetail(authorization.getPersonnel().getId()); - } - - @PutMapping("/me") - @ApiOperation("修改个人信息") - @Authorize(merge = false) - public ResponseMessage updateMePersonInfo(@RequestBody PersonAuthBindEntity bindEntity) { - PersonnelAuthentication authorization = PersonnelAuthentication - .current() - .orElseThrow(NotFoundException::new); - PersonAuthBindEntity old = personService - .selectAuthBindByPk(authorization.getPersonnel().getId()); - - bindEntity.setUserId(old.getUserId()); - bindEntity.setId(old.getId()); - bindEntity.setPositionIds(null); - - if (bindEntity.getPersonUser() != null) { - bindEntity.getPersonUser().setUsername(old.getPersonUser().getUsername()); - } - - personService.updateByPk(bindEntity); - return ResponseMessage.ok(); - } - - @GetMapping("/me/authorization") - @ApiOperation("查看当前登录用户的人员权限信息") - @Authorize(merge = false) - public ResponseMessage getLoginUserPersonDetail() { - PersonnelAuthentication authorization = PersonnelAuthentication - .current() - .orElseThrow(NotFoundException::new); - return ResponseMessage.ok(authorization); - } - - @GetMapping("/{personId}/authorization") - @ApiOperation("查看人员权限信息") - @Authorize(action = Permission.ACTION_GET, dataAccess = @RequiresDataAccess(ignore = true)) - public ResponseMessage getPersonDetail(@PathVariable String personId) { - return ResponseMessage.ok(PersonnelAuthenticationHolder.getByPersonId(personId)); - } - - @GetMapping("/{id}/detail") - @ApiOperation("查看人员详情") - @Authorize(action = Permission.ACTION_GET, dataAccess = @RequiresDataAccess(phased = Phased.after)) - public ResponseMessage getDetail(@PathVariable String id) { - return ResponseMessage.ok(personService.selectAuthBindByPk(id)); - } - - @PostMapping("/detail") - @ApiOperation("新增人员信息,并关联用户信息") - @Authorize(action = Permission.ACTION_ADD, dataAccess = @RequiresDataAccess(ignore = true)) - @ResponseStatus(HttpStatus.CREATED) - public ResponseMessage createPersonDetail(@RequestBody PersonAuthBindEntity bindEntity) { - return ResponseMessage.ok(personService.insert(bindEntity)); - } - - @PutMapping("/{id}/detail") - @ApiOperation("修改人员信息,并关联用户信息") - @Authorize(action = Permission.ACTION_UPDATE, dataAccess = @RequiresDataAccess(ignore = true)) - public ResponseMessage getDetail(@PathVariable String id, @RequestBody PersonAuthBindEntity bindEntity) { - bindEntity.setId(id); - personService.updateByPk(bindEntity); - return ResponseMessage.ok(); - } - - @GetMapping("/in-position/{positionId}") - @ApiOperation("获取指定岗位的人员") - @Authorize(action = Permission.ACTION_GET, dataAccess = @RequiresDataAccess(phased = Phased.after)) - public ResponseMessage> getByPositionId(@PathVariable String positionId) { - return ResponseMessage.ok(personService.selectByPositionId(positionId)); - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PositionController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PositionController.java deleted file mode 100644 index 0256af113..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/PositionController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 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.organizational; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.authorization.annotation.RequiresDataAccess; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.organizational.PositionEntity; -import org.hswebframework.web.service.organizational.PositionService; -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.position:position}") -@Authorize(permission = "position",description = "职位管理",dataAccess = @RequiresDataAccess) -@Api(value = "职位管理",tags = "组织架构-职位管理") -public class PositionController implements SimpleGenericEntityController { - - private PositionService positionService; - - @Autowired - public void setPositionService(PositionService positionService) { - this.positionService = positionService; - } - - @Override - public PositionService getService() { - return positionService; - } - -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationDefineController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationDefineController.java deleted file mode 100644 index 33e8f8b4f..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationDefineController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.controller.organizational; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.organizational.RelationDefineEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.organizational.RelationDefineService; -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.relationDefine:relation/define}") -@Authorize(permission = "relation-define",description = "关系定义管理") -@Api(value = "关系定义管理",tags = "组织架构-关系定义管理") -public class RelationDefineController implements SimpleGenericEntityController { - - private RelationDefineService relationDefineService; - - @Autowired - public void setRelationDefineService(RelationDefineService relationDefineService) { - this.relationDefineService = relationDefineService; - } - - @Override - public RelationDefineService getService() { - return relationDefineService; - } -} diff --git a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationInfoController.java b/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationInfoController.java deleted file mode 100644 index 493470bd3..000000000 --- a/hsweb-system/hsweb-system-organizational/hsweb-system-organizational-web/src/main/java/org/hswebframework/web/controller/organizational/RelationInfoController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.controller.organizational; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.organizational.RelationInfoEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.organizational.RelationInfoService; -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.relationInfo:relation/info}") -@Authorize(permission = "relation-info", description = "关系管理") -@Api(value = "关系管理",tags = "组织架构-关系管理") -public class RelationInfoController implements SimpleGenericEntityController { - - private RelationInfoService relationInfoService; - - @Autowired - public void setRelationInfoService(RelationInfoService relationInfoService) { - this.relationInfoService = relationInfoService; - } - - @Override - public RelationInfoService getService() { - return relationInfoService; - } -} diff --git a/hsweb-system/hsweb-system-organizational/pom.xml b/hsweb-system/hsweb-system-organizational/pom.xml deleted file mode 100644 index 6572b7e1c..000000000 --- a/hsweb-system/hsweb-system-organizational/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-organizational - pom - - hsweb-system-organizational-starter - hsweb-system-organizational-authorization - hsweb-system-organizational-api - hsweb-system-organizational-local - hsweb-system-organizational-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/README.md b/hsweb-system/hsweb-system-schedule/README.md deleted file mode 100644 index 0d1c89baf..000000000 --- a/hsweb-system/hsweb-system-schedule/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## 任务调度管理 -在线维护定时任务 -## API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/pom.xml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/pom.xml deleted file mode 100644 index 65f219cf9..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - hsweb-system-schedule - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-schedule-api - - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - org.quartz-scheduler - quartz - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/ScheduleJobEntity.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/ScheduleJobEntity.java deleted file mode 100644 index c21baaa32..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/ScheduleJobEntity.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.hswebframework.web.entity.schedule; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 调度任务 实体 - * - * @author hsweb-generator-online - */ -public interface ScheduleJobEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 任务名称 - */ - String name = "name"; - /** - * 备注 - */ - String remark = "remark"; - /** - * 定时调度配置 - */ - String quartzConfig = "quartzConfig"; - /** - * 执行脚本 - */ - String script = "script"; - /** - * 脚本语言 - */ - String language = "language"; - /** - * 是否启用 - */ - String status = "status"; - /** - * 启动参数 - */ - String parameters = "parameters"; - /** - * 任务类型 - */ - String type = "type"; - /** - * 标签 - */ - String tags = "tags"; - - /** - * @return 任务名称 - */ - String getName(); - - /** - * @param name 任务名称 - */ - void setName(String name); - - /** - * @return 备注 - */ - String getRemark(); - - /** - * @param remark 备注 - */ - void setRemark(String remark); - - /** - * @return 定时调度配置 - */ - String getQuartzConfig(); - - /** - * @param quartzConfig 定时调度配置 - */ - void setQuartzConfig(String quartzConfig); - - /** - * @return 执行脚本 - */ - String getScript(); - - /** - * @param script 执行脚本 - */ - void setScript(String script); - - /** - * @return 脚本语言 - */ - String getLanguage(); - - /** - * @param language 脚本语言 - */ - void setLanguage(String language); - - /** - * @return 是否启用 - */ - Byte getStatus(); - - /** - * @param status 是否启用 - */ - void setStatus(Byte status); - - /** - * @return 启动参数 - */ - String getParameters(); - - /** - * @param parameters 启动参数 - */ - void setParameters(String parameters); - - /** - * @return 任务类型 - */ - String getType(); - - /** - * @param type 任务类型 - */ - void setType(String type); - - /** - * @return 标签 - */ - String getTags(); - - /** - * @param tags 标签 - */ - void setTags(String tags); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/SimpleScheduleJobEntity.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/SimpleScheduleJobEntity.java deleted file mode 100644 index 861001331..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/entity/schedule/SimpleScheduleJobEntity.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.hswebframework.web.entity.schedule; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** -* 调度任务 -* @author hsweb-generator-online -*/ -public class SimpleScheduleJobEntity extends SimpleGenericEntity implements ScheduleJobEntity{ - //任务名称 - private String name; - //备注 - private String remark; - //定时调度配置 - private String quartzConfig; - //执行脚本 - private String script; - //脚本语言 - private String language; - //是否启用 - private Byte status; - //启动参数 - private String parameters; - //任务类型 - private String type; - //标签 - private String tags; - - /** - * @return 任务名称 - */ - @Override - public String getName(){ - return this.name; - } - - /** - * @param name 任务名称 - */ - @Override - public void setName(String name){ - this.name=name; - } - /** - * @return 备注 - */ - @Override - public String getRemark(){ - return this.remark; - } - - /** - * @param remark 备注 - */ - @Override - public void setRemark(String remark){ - this.remark=remark; - } - /** - * @return 定时调度配置 - */ - @Override - public String getQuartzConfig(){ - return this.quartzConfig; - } - - /** - * @param quartzConfig 定时调度配置 - */ - @Override - public void setQuartzConfig(String quartzConfig){ - this.quartzConfig = quartzConfig; - } - /** - * @return 执行脚本 - */ - @Override - public String getScript(){ - return this.script; - } - - /** - * @param script 执行脚本 - */ - @Override - public void setScript(String script){ - this.script=script; - } - /** - * @return 脚本语言 - */ - @Override - public String getLanguage(){ - return this.language; - } - - /** - * @param language 脚本语言 - */ - @Override - public void setLanguage(String language){ - this.language=language; - } - /** - * @return 是否启用 - */ - @Override - public Byte getStatus(){ - return this.status; - } - - /** - * @param status 是否启用 - */ - @Override - public void setStatus(Byte status){ - this.status = status; - } - /** - * @return 启动参数 - */ - @Override - public String getParameters(){ - return this.parameters; - } - - /** - * @param parameters 启动参数 - */ - @Override - public void setParameters(String parameters){ - this.parameters=parameters; - } - /** - * @return 任务类型 - */ - @Override - public String getType(){ - return this.type; - } - - /** - * @param type 任务类型 - */ - @Override - public void setType(String type){ - this.type=type; - } - /** - * @return 标签 - */ - @Override - public String getTags(){ - return this.tags; - } - - /** - * @param tags 标签 - */ - @Override - public void setTags(String tags){ - this.tags=tags; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobExecutor.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobExecutor.java deleted file mode 100644 index d01cc8112..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobExecutor.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.service.schedule; - -import java.util.Map; - -/** - * @author zhouhao - */ -public interface ScheduleJobExecutor { - Object doExecuteJob(String jobId, Map parameter); -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobService.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobService.java deleted file mode 100644 index bfcbf7b69..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleJobService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.service.schedule; - -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 调度任务 服务类 - * - * @author hsweb-generator-online - */ -public interface ScheduleJobService extends CrudService { - - void enable(String id); - - void disable(String id); -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleTriggerBuilder.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleTriggerBuilder.java deleted file mode 100644 index f68c3f0ef..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-api/src/main/java/org/hswebframework/web/service/schedule/ScheduleTriggerBuilder.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.service.schedule; - -import org.quartz.spi.MutableTrigger; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -public interface ScheduleTriggerBuilder { - MutableTrigger buildTrigger(String config); -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/pom.xml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/pom.xml deleted file mode 100644 index cf2fe5bde..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - hsweb-system-schedule - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-schedule-local - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-schedule-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/dao/schedule/ScheduleJobDao.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/dao/schedule/ScheduleJobDao.java deleted file mode 100644 index 28dd15c29..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/dao/schedule/ScheduleJobDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.schedule; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; - -/** -* 调度任务 DAO接口 -* @author hsweb-generator-online - */ -public interface ScheduleJobDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DefaultScriptScheduleJobExecutor.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DefaultScriptScheduleJobExecutor.java deleted file mode 100644 index e7e1e21ab..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DefaultScriptScheduleJobExecutor.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.hswebframework.web.service.schedule.simple; - -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; -import org.hswebframework.web.service.schedule.ScheduleJobExecutor; -import org.hswebframework.web.service.schedule.ScheduleJobService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Map; - -/** - * @author zhouhao - */ -public class DefaultScriptScheduleJobExecutor implements ScheduleJobExecutor { - - private ScheduleJobService scheduleJobService; - - public DefaultScriptScheduleJobExecutor() { - } - - public DefaultScriptScheduleJobExecutor(ScheduleJobService scheduleJobService) { - this.scheduleJobService = scheduleJobService; - } - - @Autowired - public void setScheduleJobService(ScheduleJobService scheduleJobService) { - this.scheduleJobService = scheduleJobService; - } - - @Override - @Transactional(rollbackFor = Throwable.class) - public Object doExecuteJob(String jobId, Map parameter) { - try { - ScheduleJobEntity jobEntity = scheduleJobService.selectByPk(jobId); - if (null == jobEntity) { - return null; - } - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(jobEntity.getLanguage()); - - String jobMd5 = DigestUtils.md5Hex(jobEntity.getScript()); - //脚本发生变化,重新编译执行 - if (engine.getContext(jobId) == null || !jobMd5.equals(engine.getContext(jobId).getMd5())) { - engine.compile(jobId, jobEntity.getScript()); - } - return engine.execute(jobId, parameter).getIfSuccess(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJob.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJob.java deleted file mode 100644 index 850b1fdae..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJob.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.hswebframework.web.service.schedule.simple; - -import org.quartz.DisallowConcurrentExecution; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@DisallowConcurrentExecution -public class DynamicJob implements Job { - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJobFactory.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJobFactory.java deleted file mode 100644 index 0dbe5077b..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/DynamicJobFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.service.schedule.simple; - -import org.hswebframework.web.service.schedule.ScheduleJobExecutor; -import org.quartz.Job; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.spi.JobFactory; -import org.quartz.spi.TriggerFiredBundle; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Map; - -/** - * @author zhouhao - */ -public class DynamicJobFactory implements JobFactory { - - public static final String JOB_ID_KEY = "dynamic-job-id:"; - - private JobFactory defaultFactory; - - private ScheduleJobExecutor scheduleJobExecutor; - - public DynamicJobFactory(JobFactory defaultFactory) { - this.defaultFactory = defaultFactory; - } - - @Autowired - public void setScheduleJobExecutor(ScheduleJobExecutor scheduleJobExecutor) { - this.scheduleJobExecutor = scheduleJobExecutor; - } - - @Override - public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { - Map data = bundle.getJobDetail().getJobDataMap(); - String jobId = (String) data.get(JOB_ID_KEY); - if (null == jobId || bundle.getJobDetail().getJobClass() != DynamicJob.class) { - return defaultFactory.newJob(bundle, scheduler); - } - return context -> scheduleJobExecutor.doExecuteJob(jobId, data); - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SimpleScheduleJobService.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SimpleScheduleJobService.java deleted file mode 100644 index 5d0d1a5b1..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SimpleScheduleJobService.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.hswebframework.web.service.schedule.simple; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.schedule.ScheduleJobDao; -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.service.schedule.ScheduleJobService; -import org.hswebframework.web.service.schedule.ScheduleTriggerBuilder; -import org.quartz.*; -import org.quartz.spi.MutableTrigger; -import org.quartz.spi.OperableTrigger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("scheduleJobService") -//@CacheConfig(cacheNames = "schedule-job") -public class SimpleScheduleJobService extends GenericEntityService - implements ScheduleJobService { - @Autowired - private ScheduleJobDao scheduleJobDao; - - @Autowired - protected Scheduler scheduler; - - @Autowired - private ScheduleTriggerBuilder scheduleTriggerBuilder; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public ScheduleJobDao getDao() { - return scheduleJobDao; - } - - public static List computeFireTimesBetween(OperableTrigger trigger, - org.quartz.Calendar cal, Date from, Date to, int num) { - List lst = new LinkedList<>(); - OperableTrigger t = (OperableTrigger) trigger.clone(); - if (t.getNextFireTime() == null) { - t.setStartTime(from); - t.setEndTime(to); - t.computeFirstFireTime(cal); - } - for (int i = 0; i < num; i++) { - Date d = t.getNextFireTime(); - if (d != null) { - if (d.before(from)) { - t.triggered(cal); - continue; - } - if (d.after(to)) { - break; - } - lst.add(d); - t.triggered(cal); - } else { - break; - } - } - return lst; - } - - protected void startJob(ScheduleJobEntity jobEntity) { - try { - if (scheduler.checkExists(createJobKey(jobEntity))) { - return; - } - JobDetail jobDetail = JobBuilder - .newJob(DynamicJob.class) - .withIdentity(createJobKey(jobEntity)) - .setJobData(createJobDataMap(jobEntity.getParameters())) - .usingJobData(DynamicJobFactory.JOB_ID_KEY, jobEntity.getId()) - .withDescription(jobEntity.getName() + (jobEntity.getRemark() == null ? "" : jobEntity.getRemark())) - .build(); - MutableTrigger trigger = scheduleTriggerBuilder.buildTrigger(jobEntity.getQuartzConfig()); - trigger.setKey(createTriggerKey(jobEntity)); - - scheduler.scheduleJob(jobDetail, trigger); - } catch (SchedulerException e) { - throw new BusinessException("启动定时调度失败", e); - } - } - - protected JobDataMap createJobDataMap(String parameters) { - JobDataMap map = new JobDataMap(); - if (!StringUtils.isEmpty(parameters)) { - JSONArray jsonArray = JSON.parseArray(parameters); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject o = jsonArray.getJSONObject(i); - map.put(o.getString("key"), o.get("value")); - } - } - return map; - } - - protected JobKey createJobKey(ScheduleJobEntity jobEntity) { - String group = jobEntity.getType() == null ? "hsweb.scheduler" : jobEntity.getType(); - - return new JobKey(jobEntity.getId(), group); - } - - protected TriggerKey createTriggerKey(ScheduleJobEntity jobEntity) { - String group = jobEntity.getType() == null ? "hsweb.scheduler" : jobEntity.getType(); - - return new TriggerKey(jobEntity.getId(), group); - } - - @Override - public void enable(String id) { - Objects.requireNonNull(id); - int size = createUpdate().set(ScheduleJobEntity.status, DataStatus.STATUS_ENABLED) - .where(ScheduleJobEntity.id, id).exec(); - if (size > 0) { - startJob(selectByPk(id)); - } - } - - private void deleteJob(ScheduleJobEntity jobEntity) { - JobKey jobKey = createJobKey(jobEntity); - try { - if (scheduler.checkExists(jobKey)) { - scheduler.deleteJob(jobKey); - } - } catch (SchedulerException e) { - throw new BusinessException("更新任务失败", e, 500); - } - } - - @Override - public void disable(String id) { - Objects.requireNonNull(id); - int size = createUpdate().set(ScheduleJobEntity.status, DataStatus.STATUS_DISABLED) - .where(ScheduleJobEntity.id, id).exec(); - if (size > 0) { - deleteJob(selectByPk(id)); - } - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SmartScheduleTriggerBuilder.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SmartScheduleTriggerBuilder.java deleted file mode 100644 index dc5a579f0..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/java/org/hswebframework/web/service/schedule/simple/SmartScheduleTriggerBuilder.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.service.schedule.simple; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.service.schedule.ScheduleTriggerBuilder; -import org.quartz.CronScheduleBuilder; -import org.quartz.spi.MutableTrigger; -import org.springframework.stereotype.Service; - -/** - * @author zhouhao - */ -@Service -public class SmartScheduleTriggerBuilder implements ScheduleTriggerBuilder { - @Override - public MutableTrigger buildTrigger(String config) { - JSONObject configObj = JSON.parseObject(config); - switch (configObj.getString("type")) { - case "cron": - String cron = configObj.getString("config"); - return CronScheduleBuilder.cronSchedule(cron) - .build(); - default: - throw new UnsupportedOperationException(config); - } - - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/schedule/ScheduleJobMapper.xml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/schedule/ScheduleJobMapper.xml deleted file mode 100644 index bbd290109..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/schedule/ScheduleJobMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/pom.xml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/pom.xml deleted file mode 100644 index d5a38a796..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - hsweb-system-schedule - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-schedule-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-schedule-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-schedule-web - ${project.version} - - - org.springframework - spring-context-support - - - org.hswebframework.web - hsweb-datasource-api - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/AutoCreateTable.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/AutoCreateTable.java deleted file mode 100644 index 0e28d5027..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/AutoCreateTable.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.hswebframework.web.schedule.configuration; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.utils.file.FileUtils; -import org.hswebframework.web.Sqls; -import org.hswebframework.web.datasource.DataSourceHolder; -import org.hswebframework.web.datasource.DatabaseType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.util.StringUtils; - -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.List; - -/** - * @author zhouhao - */ -@Order(Ordered.HIGHEST_PRECEDENCE) -public class AutoCreateTable implements CommandLineRunner { - - @Autowired - private SqlExecutor sqlExecutor; - - @Override - public void run(String... args) throws Exception { - if (sqlExecutor.tableExists("QRTZ_LOCKS")) { - return; - } - DatabaseType databaseType = DataSourceHolder.currentDatabaseType(); - String databaseTypeName = databaseType.name(); - if (databaseType == DatabaseType.jtds_sqlserver) { - databaseTypeName = DatabaseType.sqlserver.name(); - } - String file = "classpath*:/quartz/sql/quartz-" + databaseTypeName + "-create.sql"; - Resource[] resources = new PathMatchingResourcePatternResolver().getResources(file); - - for (Resource resource : resources) { - try (Reader reader = new InputStreamReader(resource.getInputStream())) { - String str = FileUtils.reader2String(reader); - List sqlList = Sqls.parse(str); - for (String sql : sqlList) { - if (StringUtils.isEmpty(sql)) return; - sqlExecutor.exec(sql); - } - } - } - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/ScheduleAutoConfiguration.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/ScheduleAutoConfiguration.java deleted file mode 100644 index 2ba509c05..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/ScheduleAutoConfiguration.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.hswebframework.web.schedule.configuration; - -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.web.service.schedule.ScheduleJobExecutor; -import org.hswebframework.web.service.schedule.ScheduleJobService; -import org.hswebframework.web.service.schedule.simple.DefaultScriptScheduleJobExecutor; -import org.hswebframework.web.service.schedule.simple.DynamicJobFactory; -import org.quartz.Calendar; -import org.quartz.Scheduler; -import org.quartz.SchedulerListener; -import org.quartz.impl.StdSchedulerFactory; -import org.quartz.spi.JobFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.AdaptableJobFactory; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; - -import javax.sql.DataSource; -import java.util.Map; - -/** - * @author zhouhao - */ -@Configuration -@EnableConfigurationProperties(SchedulerProperties.class) -@ConditionalOnMissingBean({Scheduler.class, SchedulerFactoryBean.class}) -@ComponentScan({"org.hswebframework.web.service.schedule.simple" - , "org.hswebframework.web.controller.schedule"}) -@Slf4j -public class ScheduleAutoConfiguration { - @Autowired - private SchedulerProperties schedulerProperties; - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private DataSource dataSource; - - @Autowired - private PlatformTransactionManager platformTransactionManager; - - @Autowired(required = false) - private Map calendarMap; - - @Autowired(required = false) - private SchedulerListener[] schedulerListeners; - - @Bean - public JobFactory jobFactory() { - return new DynamicJobFactory(new AdaptableJobFactory()); - } - - @Bean - public AutoCreateTable autoCreateTable() { - return new AutoCreateTable(); - } - - @Bean - public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) { - SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); - schedulerFactoryBean.setApplicationContext(applicationContext); - schedulerFactoryBean.setAutoStartup(schedulerProperties.isAutoStartup()); - schedulerFactoryBean.setDataSource(dataSource); - schedulerFactoryBean.setTransactionManager(platformTransactionManager); - schedulerFactoryBean.setOverwriteExistingJobs(schedulerProperties.isOverwriteExistingJobs()); - schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class); - schedulerFactoryBean.setBeanName(schedulerProperties.getBeanName()); - schedulerFactoryBean.setJobFactory(jobFactory); - schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown()); - schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties()); - schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay()); - schedulerFactoryBean.setCalendars(calendarMap); - schedulerFactoryBean.setSchedulerListeners(schedulerListeners); - return schedulerFactoryBean; - } - - @Bean - @ConditionalOnMissingBean(ScheduleJobExecutor.class) - public ScheduleJobExecutor scheduleJobExecutor(ScheduleJobService scheduleJobService) { - ScheduleJobExecutor defaultExecutor = new DefaultScriptScheduleJobExecutor(scheduleJobService); - - - return defaultExecutor; - } - -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/SchedulerProperties.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/SchedulerProperties.java deleted file mode 100644 index 6c642bdca..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/java/org/hswebframework/web/schedule/configuration/SchedulerProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2015-2016 http://hsweb.me - * - * 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.schedule.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.util.List; -import java.util.Properties; - -@ConfigurationProperties(prefix = "scheduler") -@Data -public class SchedulerProperties { - private boolean autoStartup = true; - - private boolean overwriteExistingJobs = true; - - private String beanName = "scheduler"; - - private boolean waitOnShutdown = true; - - private int startupDelay = 10; - - private Properties properties = new Properties(); - - private boolean enableCluster = false; - - private List executeTags; -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f4d2307a1..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.schedule.configuration.ScheduleAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index d037f95b7..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,50 +0,0 @@ - -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "调度任务" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_schedule_job") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("任务名称").jdbcType(java.sql.JDBCType.VARCHAR).length(128).commit() - .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("quartz_config").alias("quartzConfig").comment("定时调度配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("script").alias("script").comment("执行脚本").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("language").alias("language").comment("脚本语言").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("status").alias("status").comment("是否启用").jdbcType(java.sql.JDBCType.DECIMAL).length(4,0).commit() - .addColumn().name("parameters").alias("parameters").comment("启动参数").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("type").alias("type").comment("任务类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("tags").alias("tags").comment("标签").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .comment("调度任务").commit(); - -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-h2-create.sql b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-h2-create.sql deleted file mode 100644 index dcb0638cd..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-h2-create.sql +++ /dev/null @@ -1,247 +0,0 @@ --- Thanks to Amir Kibbar and Peter Rietzler for contributing the schema for H2 database, --- and verifying that it works with Quartz's StdJDBCDelegate --- --- Note, Quartz depends on row-level locking which means you must use the MVCC=TRUE --- setting on your H2 database, or you will experience dead-locks --- --- --- In your Quartz properties file, you'll need to set --- org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate - -CREATE TABLE QRTZ_CALENDARS ( - SCHED_NAME VARCHAR(120) NOT NULL, - CALENDAR_NAME VARCHAR (200) NOT NULL , - CALENDAR IMAGE NOT NULL -); - -CREATE TABLE QRTZ_CRON_TRIGGERS ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR (200) NOT NULL , - TRIGGER_GROUP VARCHAR (200) NOT NULL , - CRON_EXPRESSION VARCHAR (120) NOT NULL , - TIME_ZONE_ID VARCHAR (80) -); - -CREATE TABLE QRTZ_FIRED_TRIGGERS ( - SCHED_NAME VARCHAR(120) NOT NULL, - ENTRY_ID VARCHAR (95) NOT NULL , - TRIGGER_NAME VARCHAR (200) NOT NULL , - TRIGGER_GROUP VARCHAR (200) NOT NULL , - INSTANCE_NAME VARCHAR (200) NOT NULL , - FIRED_TIME BIGINT NOT NULL , - SCHED_TIME BIGINT NOT NULL , - PRIORITY INTEGER NOT NULL , - STATE VARCHAR (16) NOT NULL, - JOB_NAME VARCHAR (200) NULL , - JOB_GROUP VARCHAR (200) NULL , - IS_NONCONCURRENT BOOLEAN NULL , - REQUESTS_RECOVERY BOOLEAN NULL -); - -CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_GROUP VARCHAR (200) NOT NULL -); - -CREATE TABLE QRTZ_SCHEDULER_STATE ( - SCHED_NAME VARCHAR(120) NOT NULL, - INSTANCE_NAME VARCHAR (200) NOT NULL , - LAST_CHECKIN_TIME BIGINT NOT NULL , - CHECKIN_INTERVAL BIGINT NOT NULL -); - -CREATE TABLE QRTZ_LOCKS ( - SCHED_NAME VARCHAR(120) NOT NULL, - LOCK_NAME VARCHAR (40) NOT NULL -); - -CREATE TABLE QRTZ_JOB_DETAILS ( - SCHED_NAME VARCHAR(120) NOT NULL, - JOB_NAME VARCHAR (200) NOT NULL , - JOB_GROUP VARCHAR (200) NOT NULL , - DESCRIPTION VARCHAR (250) NULL , - JOB_CLASS_NAME VARCHAR (250) NOT NULL , - IS_DURABLE BOOLEAN NOT NULL , - IS_NONCONCURRENT BOOLEAN NOT NULL , - IS_UPDATE_DATA BOOLEAN NOT NULL , - REQUESTS_RECOVERY BOOLEAN NOT NULL , - JOB_DATA IMAGE NULL -); - -CREATE TABLE QRTZ_SIMPLE_TRIGGERS ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR (200) NOT NULL , - TRIGGER_GROUP VARCHAR (200) NOT NULL , - REPEAT_COUNT BIGINT NOT NULL , - REPEAT_INTERVAL BIGINT NOT NULL , - TIMES_TRIGGERED BIGINT NOT NULL -); - -CREATE TABLE qrtz_simprop_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - STR_PROP_1 VARCHAR(512) NULL, - STR_PROP_2 VARCHAR(512) NULL, - STR_PROP_3 VARCHAR(512) NULL, - INT_PROP_1 INTEGER NULL, - INT_PROP_2 INTEGER NULL, - LONG_PROP_1 BIGINT NULL, - LONG_PROP_2 BIGINT NULL, - DEC_PROP_1 NUMERIC(13,4) NULL, - DEC_PROP_2 NUMERIC(13,4) NULL, - BOOL_PROP_1 BOOLEAN NULL, - BOOL_PROP_2 BOOLEAN NULL, -); - -CREATE TABLE QRTZ_BLOB_TRIGGERS ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR (200) NOT NULL , - TRIGGER_GROUP VARCHAR (200) NOT NULL , - BLOB_DATA IMAGE NULL -); - -CREATE TABLE QRTZ_TRIGGERS ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR (200) NOT NULL , - TRIGGER_GROUP VARCHAR (200) NOT NULL , - JOB_NAME VARCHAR (200) NOT NULL , - JOB_GROUP VARCHAR (200) NOT NULL , - DESCRIPTION VARCHAR (250) NULL , - NEXT_FIRE_TIME BIGINT NULL , - PREV_FIRE_TIME BIGINT NULL , - PRIORITY INTEGER NULL , - TRIGGER_STATE VARCHAR (16) NOT NULL , - TRIGGER_TYPE VARCHAR (8) NOT NULL , - START_TIME BIGINT NOT NULL , - END_TIME BIGINT NULL , - CALENDAR_NAME VARCHAR (200) NULL , - MISFIRE_INSTR SMALLINT NULL , - JOB_DATA IMAGE NULL -); - -ALTER TABLE QRTZ_CALENDARS ADD - CONSTRAINT PK_QRTZ_CALENDARS PRIMARY KEY - ( - SCHED_NAME, - CALENDAR_NAME - ); - -ALTER TABLE QRTZ_CRON_TRIGGERS ADD - CONSTRAINT PK_QRTZ_CRON_TRIGGERS PRIMARY KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ); - -ALTER TABLE QRTZ_FIRED_TRIGGERS ADD - CONSTRAINT PK_QRTZ_FIRED_TRIGGERS PRIMARY KEY - ( - SCHED_NAME, - ENTRY_ID - ); - -ALTER TABLE QRTZ_PAUSED_TRIGGER_GRPS ADD - CONSTRAINT PK_QRTZ_PAUSED_TRIGGER_GRPS PRIMARY KEY - ( - SCHED_NAME, - TRIGGER_GROUP - ); - -ALTER TABLE QRTZ_SCHEDULER_STATE ADD - CONSTRAINT PK_QRTZ_SCHEDULER_STATE PRIMARY KEY - ( - SCHED_NAME, - INSTANCE_NAME - ); - -ALTER TABLE QRTZ_LOCKS ADD - CONSTRAINT PK_QRTZ_LOCKS PRIMARY KEY - ( - SCHED_NAME, - LOCK_NAME - ); - -ALTER TABLE QRTZ_JOB_DETAILS ADD - CONSTRAINT PK_QRTZ_JOB_DETAILS PRIMARY KEY - ( - SCHED_NAME, - JOB_NAME, - JOB_GROUP - ); - -ALTER TABLE QRTZ_SIMPLE_TRIGGERS ADD - CONSTRAINT PK_QRTZ_SIMPLE_TRIGGERS PRIMARY KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ); - -ALTER TABLE QRTZ_SIMPROP_TRIGGERS ADD - CONSTRAINT PK_QRTZ_SIMPROP_TRIGGERS PRIMARY KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ); - -ALTER TABLE QRTZ_TRIGGERS ADD - CONSTRAINT PK_QRTZ_TRIGGERS PRIMARY KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ); - -ALTER TABLE QRTZ_CRON_TRIGGERS ADD - CONSTRAINT FK_QRTZ_CRON_TRIGGERS_QRTZ_TRIGGERS FOREIGN KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) REFERENCES QRTZ_TRIGGERS ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) ON DELETE CASCADE; - - -ALTER TABLE QRTZ_SIMPLE_TRIGGERS ADD - CONSTRAINT FK_QRTZ_SIMPLE_TRIGGERS_QRTZ_TRIGGERS FOREIGN KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) REFERENCES QRTZ_TRIGGERS ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) ON DELETE CASCADE; - -ALTER TABLE QRTZ_SIMPROP_TRIGGERS ADD - CONSTRAINT FK_QRTZ_SIMPROP_TRIGGERS_QRTZ_TRIGGERS FOREIGN KEY - ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) REFERENCES QRTZ_TRIGGERS ( - SCHED_NAME, - TRIGGER_NAME, - TRIGGER_GROUP - ) ON DELETE CASCADE; - - -ALTER TABLE QRTZ_TRIGGERS ADD - CONSTRAINT FK_QRTZ_TRIGGERS_QRTZ_JOB_DETAILS FOREIGN KEY - ( - SCHED_NAME, - JOB_NAME, - JOB_GROUP - ) REFERENCES QRTZ_JOB_DETAILS ( - SCHED_NAME, - JOB_NAME, - JOB_GROUP - ); diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-mysql-create.sql b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-mysql-create.sql deleted file mode 100644 index 41fe6b946..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-mysql-create.sql +++ /dev/null @@ -1,143 +0,0 @@ -CREATE TABLE QRTZ_JOB_DETAILS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - JOB_CLASS_NAME VARCHAR(250) NOT NULL, - IS_DURABLE VARCHAR(1) NOT NULL, - IS_NONCONCURRENT VARCHAR(1) NOT NULL, - IS_UPDATE_DATA VARCHAR(1) NOT NULL, - REQUESTS_RECOVERY VARCHAR(1) NOT NULL, - JOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) -); - -CREATE TABLE QRTZ_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - NEXT_FIRE_TIME BIGINT(13) NULL, - PREV_FIRE_TIME BIGINT(13) NULL, - PRIORITY INTEGER NULL, - TRIGGER_STATE VARCHAR(16) NOT NULL, - TRIGGER_TYPE VARCHAR(8) NOT NULL, - START_TIME BIGINT(13) NOT NULL, - END_TIME BIGINT(13) NULL, - CALENDAR_NAME VARCHAR(200) NULL, - MISFIRE_INSTR SMALLINT(2) NULL, - JOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) - REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP) -); - -CREATE TABLE QRTZ_SIMPLE_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - REPEAT_COUNT BIGINT(7) NOT NULL, - REPEAT_INTERVAL BIGINT(12) NOT NULL, - TIMES_TRIGGERED BIGINT(10) NOT NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE QRTZ_CRON_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - CRON_EXPRESSION VARCHAR(200) NOT NULL, - TIME_ZONE_ID VARCHAR(80), - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE QRTZ_SIMPROP_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - STR_PROP_1 VARCHAR(512) NULL, - STR_PROP_2 VARCHAR(512) NULL, - STR_PROP_3 VARCHAR(512) NULL, - INT_PROP_1 INT NULL, - INT_PROP_2 INT NULL, - LONG_PROP_1 BIGINT NULL, - LONG_PROP_2 BIGINT NULL, - DEC_PROP_1 NUMERIC(13,4) NULL, - DEC_PROP_2 NUMERIC(13,4) NULL, - BOOL_PROP_1 VARCHAR(1) NULL, - BOOL_PROP_2 VARCHAR(1) NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE QRTZ_BLOB_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - BLOB_DATA BLOB NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE QRTZ_CALENDARS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - CALENDAR_NAME VARCHAR(200) NOT NULL, - CALENDAR BLOB NOT NULL, - PRIMARY KEY (SCHED_NAME,CALENDAR_NAME) -); - -CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP) -); - -CREATE TABLE QRTZ_FIRED_TRIGGERS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - ENTRY_ID VARCHAR(95) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - FIRED_TIME BIGINT(13) NOT NULL, - SCHED_TIME BIGINT(13) NOT NULL, - PRIORITY INTEGER NOT NULL, - STATE VARCHAR(16) NOT NULL, - JOB_NAME VARCHAR(200) NULL, - JOB_GROUP VARCHAR(200) NULL, - IS_NONCONCURRENT VARCHAR(1) NULL, - REQUESTS_RECOVERY VARCHAR(1) NULL, - PRIMARY KEY (SCHED_NAME,ENTRY_ID) -); - -CREATE TABLE QRTZ_SCHEDULER_STATE - ( - SCHED_NAME VARCHAR(120) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - LAST_CHECKIN_TIME BIGINT(13) NOT NULL, - CHECKIN_INTERVAL BIGINT(13) NOT NULL, - PRIMARY KEY (SCHED_NAME,INSTANCE_NAME) -); - -CREATE TABLE QRTZ_LOCKS - ( - SCHED_NAME VARCHAR(120) NOT NULL, - LOCK_NAME VARCHAR(40) NOT NULL, - PRIMARY KEY (SCHED_NAME,LOCK_NAME) -); diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-oracle-create.sql b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-oracle-create.sql deleted file mode 100644 index c381d9d4e..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-oracle-create.sql +++ /dev/null @@ -1,157 +0,0 @@ -CREATE TABLE qrtz_job_details - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - JOB_NAME VARCHAR2(200) NOT NULL, - JOB_GROUP VARCHAR2(200) NOT NULL, - DESCRIPTION VARCHAR2(250) NULL, - JOB_CLASS_NAME VARCHAR2(250) NOT NULL, - IS_DURABLE VARCHAR2(1) NOT NULL, - IS_NONCONCURRENT VARCHAR2(1) NOT NULL, - IS_UPDATE_DATA VARCHAR2(1) NOT NULL, - REQUESTS_RECOVERY VARCHAR2(1) NOT NULL, - JOB_DATA BLOB NULL, - CONSTRAINT QRTZ_JOB_DETAILS_PK PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) -); -CREATE TABLE qrtz_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - JOB_NAME VARCHAR2(200) NOT NULL, - JOB_GROUP VARCHAR2(200) NOT NULL, - DESCRIPTION VARCHAR2(250) NULL, - NEXT_FIRE_TIME NUMBER(13) NULL, - PREV_FIRE_TIME NUMBER(13) NULL, - PRIORITY NUMBER(13) NULL, - TRIGGER_STATE VARCHAR2(16) NOT NULL, - TRIGGER_TYPE VARCHAR2(8) NOT NULL, - START_TIME NUMBER(13) NOT NULL, - END_TIME NUMBER(13) NULL, - CALENDAR_NAME VARCHAR2(200) NULL, - MISFIRE_INSTR NUMBER(2) NULL, - JOB_DATA BLOB NULL, - CONSTRAINT QRTZ_TRIGGERS_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - CONSTRAINT QRTZ_TRIGGER_TO_JOBS_FK FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) - REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP) -); -CREATE TABLE qrtz_simple_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - REPEAT_COUNT NUMBER(7) NOT NULL, - REPEAT_INTERVAL NUMBER(12) NOT NULL, - TIMES_TRIGGERED NUMBER(10) NOT NULL, - CONSTRAINT QRTZ_SIMPLE_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - CONSTRAINT QRTZ_SIMPLE_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); -CREATE TABLE qrtz_cron_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - CRON_EXPRESSION VARCHAR2(120) NOT NULL, - TIME_ZONE_ID VARCHAR2(80), - CONSTRAINT QRTZ_CRON_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - CONSTRAINT QRTZ_CRON_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); -CREATE TABLE qrtz_simprop_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - STR_PROP_1 VARCHAR2(512) NULL, - STR_PROP_2 VARCHAR2(512) NULL, - STR_PROP_3 VARCHAR2(512) NULL, - INT_PROP_1 NUMBER(10) NULL, - INT_PROP_2 NUMBER(10) NULL, - LONG_PROP_1 NUMBER(13) NULL, - LONG_PROP_2 NUMBER(13) NULL, - DEC_PROP_1 NUMERIC(13,4) NULL, - DEC_PROP_2 NUMERIC(13,4) NULL, - BOOL_PROP_1 VARCHAR2(1) NULL, - BOOL_PROP_2 VARCHAR2(1) NULL, - CONSTRAINT QRTZ_SIMPROP_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - CONSTRAINT QRTZ_SIMPROP_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); -CREATE TABLE qrtz_blob_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - BLOB_DATA BLOB NULL, - CONSTRAINT QRTZ_BLOB_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - CONSTRAINT QRTZ_BLOB_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); -CREATE TABLE qrtz_calendars - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - CALENDAR_NAME VARCHAR2(200) NOT NULL, - CALENDAR BLOB NOT NULL, - CONSTRAINT QRTZ_CALENDARS_PK PRIMARY KEY (SCHED_NAME,CALENDAR_NAME) -); -CREATE TABLE qrtz_paused_trigger_grps - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - CONSTRAINT QRTZ_PAUSED_TRIG_GRPS_PK PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP) -); -CREATE TABLE qrtz_fired_triggers - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - ENTRY_ID VARCHAR2(95) NOT NULL, - TRIGGER_NAME VARCHAR2(200) NOT NULL, - TRIGGER_GROUP VARCHAR2(200) NOT NULL, - INSTANCE_NAME VARCHAR2(200) NOT NULL, - FIRED_TIME NUMBER(13) NOT NULL, - SCHED_TIME NUMBER(13) NOT NULL, - PRIORITY NUMBER(13) NOT NULL, - STATE VARCHAR2(16) NOT NULL, - JOB_NAME VARCHAR2(200) NULL, - JOB_GROUP VARCHAR2(200) NULL, - IS_NONCONCURRENT VARCHAR2(1) NULL, - REQUESTS_RECOVERY VARCHAR2(1) NULL, - CONSTRAINT QRTZ_FIRED_TRIGGER_PK PRIMARY KEY (SCHED_NAME,ENTRY_ID) -); -CREATE TABLE qrtz_scheduler_state - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - INSTANCE_NAME VARCHAR2(200) NOT NULL, - LAST_CHECKIN_TIME NUMBER(13) NOT NULL, - CHECKIN_INTERVAL NUMBER(13) NOT NULL, - CONSTRAINT QRTZ_SCHEDULER_STATE_PK PRIMARY KEY (SCHED_NAME,INSTANCE_NAME) -); -CREATE TABLE qrtz_locks - ( - SCHED_NAME VARCHAR2(120) NOT NULL, - LOCK_NAME VARCHAR2(40) NOT NULL, - CONSTRAINT QRTZ_LOCKS_PK PRIMARY KEY (SCHED_NAME,LOCK_NAME) -); - -create index idx_qrtz_j_req_recovery on qrtz_job_details(SCHED_NAME,REQUESTS_RECOVERY); -create index idx_qrtz_j_grp on qrtz_job_details(SCHED_NAME,JOB_GROUP); - -create index idx_qrtz_t_j on qrtz_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP); -create index idx_qrtz_t_jg on qrtz_triggers(SCHED_NAME,JOB_GROUP); -create index idx_qrtz_t_c on qrtz_triggers(SCHED_NAME,CALENDAR_NAME); -create index idx_qrtz_t_g on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP); -create index idx_qrtz_t_state on qrtz_triggers(SCHED_NAME,TRIGGER_STATE); -create index idx_qrtz_t_n_state on qrtz_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE); -create index idx_qrtz_t_n_g_state on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE); -create index idx_qrtz_t_next_fire_time on qrtz_triggers(SCHED_NAME,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_st on qrtz_triggers(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_st_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE); -create index idx_qrtz_t_nft_st_misfire_grp on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE); - -create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME); -create index idx_qrtz_ft_inst_job_req_rcvry on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY); -create index idx_qrtz_ft_j_g on qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP); -create index idx_qrtz_ft_jg on qrtz_fired_triggers(SCHED_NAME,JOB_GROUP); -create index idx_qrtz_ft_t_g on qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); -create index idx_qrtz_ft_tg on qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP); - diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-postgresql-create.sql b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-postgresql-create.sql deleted file mode 100644 index 440bc72ec..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/main/resources/quartz/sql/quartz-postgresql-create.sql +++ /dev/null @@ -1,171 +0,0 @@ --- Thanks to Patrick Lightbody for submitting this... --- --- In your Quartz properties file, you'll need to set --- org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate -CREATE TABLE qrtz_job_details - ( - SCHED_NAME VARCHAR(120) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - JOB_CLASS_NAME VARCHAR(250) NOT NULL, - IS_DURABLE BOOL NOT NULL, - IS_NONCONCURRENT BOOL NOT NULL, - IS_UPDATE_DATA BOOL NOT NULL, - REQUESTS_RECOVERY BOOL NOT NULL, - JOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) -); - -CREATE TABLE qrtz_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - JOB_NAME VARCHAR(200) NOT NULL, - JOB_GROUP VARCHAR(200) NOT NULL, - DESCRIPTION VARCHAR(250) NULL, - NEXT_FIRE_TIME BIGINT NULL, - PREV_FIRE_TIME BIGINT NULL, - PRIORITY INTEGER NULL, - TRIGGER_STATE VARCHAR(16) NOT NULL, - TRIGGER_TYPE VARCHAR(8) NOT NULL, - START_TIME BIGINT NOT NULL, - END_TIME BIGINT NULL, - CALENDAR_NAME VARCHAR(200) NULL, - MISFIRE_INSTR SMALLINT NULL, - JOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP) - REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP) -); - -CREATE TABLE qrtz_simple_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - REPEAT_COUNT BIGINT NOT NULL, - REPEAT_INTERVAL BIGINT NOT NULL, - TIMES_TRIGGERED BIGINT NOT NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE qrtz_cron_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - CRON_EXPRESSION VARCHAR(120) NOT NULL, - TIME_ZONE_ID VARCHAR(80), - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE qrtz_simprop_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - STR_PROP_1 VARCHAR(512) NULL, - STR_PROP_2 VARCHAR(512) NULL, - STR_PROP_3 VARCHAR(512) NULL, - INT_PROP_1 INT NULL, - INT_PROP_2 INT NULL, - LONG_PROP_1 BIGINT NULL, - LONG_PROP_2 BIGINT NULL, - DEC_PROP_1 NUMERIC(13,4) NULL, - DEC_PROP_2 NUMERIC(13,4) NULL, - BOOL_PROP_1 BOOL NULL, - BOOL_PROP_2 BOOL NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE qrtz_blob_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - BLOB_DATA BYTEA NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP), - FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) - REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP) -); - -CREATE TABLE qrtz_calendars - ( - SCHED_NAME VARCHAR(120) NOT NULL, - CALENDAR_NAME VARCHAR(200) NOT NULL, - CALENDAR BYTEA NOT NULL, - PRIMARY KEY (SCHED_NAME,CALENDAR_NAME) -); - - -CREATE TABLE qrtz_paused_trigger_grps - ( - SCHED_NAME VARCHAR(120) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP) -); - -CREATE TABLE qrtz_fired_triggers - ( - SCHED_NAME VARCHAR(120) NOT NULL, - ENTRY_ID VARCHAR(95) NOT NULL, - TRIGGER_NAME VARCHAR(200) NOT NULL, - TRIGGER_GROUP VARCHAR(200) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - FIRED_TIME BIGINT NOT NULL, - SCHED_TIME BIGINT NOT NULL, - PRIORITY INTEGER NOT NULL, - STATE VARCHAR(16) NOT NULL, - JOB_NAME VARCHAR(200) NULL, - JOB_GROUP VARCHAR(200) NULL, - IS_NONCONCURRENT BOOL NULL, - REQUESTS_RECOVERY BOOL NULL, - PRIMARY KEY (SCHED_NAME,ENTRY_ID) -); - -CREATE TABLE qrtz_scheduler_state - ( - SCHED_NAME VARCHAR(120) NOT NULL, - INSTANCE_NAME VARCHAR(200) NOT NULL, - LAST_CHECKIN_TIME BIGINT NOT NULL, - CHECKIN_INTERVAL BIGINT NOT NULL, - PRIMARY KEY (SCHED_NAME,INSTANCE_NAME) -); - -CREATE TABLE qrtz_locks - ( - SCHED_NAME VARCHAR(120) NOT NULL, - LOCK_NAME VARCHAR(40) NOT NULL, - PRIMARY KEY (SCHED_NAME,LOCK_NAME) -); - -create index idx_qrtz_j_req_recovery on qrtz_job_details(SCHED_NAME,REQUESTS_RECOVERY); -create index idx_qrtz_j_grp on qrtz_job_details(SCHED_NAME,JOB_GROUP); - -create index idx_qrtz_t_j on qrtz_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP); -create index idx_qrtz_t_jg on qrtz_triggers(SCHED_NAME,JOB_GROUP); -create index idx_qrtz_t_c on qrtz_triggers(SCHED_NAME,CALENDAR_NAME); -create index idx_qrtz_t_g on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP); -create index idx_qrtz_t_state on qrtz_triggers(SCHED_NAME,TRIGGER_STATE); -create index idx_qrtz_t_n_state on qrtz_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE); -create index idx_qrtz_t_n_g_state on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE); -create index idx_qrtz_t_next_fire_time on qrtz_triggers(SCHED_NAME,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_st on qrtz_triggers(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME); -create index idx_qrtz_t_nft_st_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE); -create index idx_qrtz_t_nft_st_misfire_grp on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE); - -create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME); -create index idx_qrtz_ft_inst_job_req_rcvry on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY); -create index idx_qrtz_ft_j_g on qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP); -create index idx_qrtz_ft_jg on qrtz_fired_triggers(SCHED_NAME,JOB_GROUP); -create index idx_qrtz_ft_t_g on qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); -create index idx_qrtz_ft_tg on qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP); diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java deleted file mode 100644 index 31647df6b..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.hswebframework.web.schedule.test; - -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; -import org.hswebframework.web.service.schedule.ScheduleJobService; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - -/** - * @author zhouhao - */ -@Transactional(propagation = Propagation.NOT_SUPPORTED) -public class DynamicScheduleTests extends SimpleWebApplicationTests { - - @Autowired - private ScheduleJobService scheduleJobService; - - - public static final CountDownLatch counter=new CountDownLatch(1); - public static final AtomicLong value=new AtomicLong(); - private String id; - - @Before - public void initJob() throws InterruptedException { - id = scheduleJobService.insert(createJob()); - scheduleJobService.enable(id); - } - - public ScheduleJobEntity createJob() { - ScheduleJobEntity entity = scheduleJobService.createEntity(); - entity.setStatus(DataStatus.STATUS_ENABLED); - entity.setType("test"); - entity.setLanguage("javascript"); - entity.setTags("core2"); - entity.setScript("" + - "org.hswebframework.web.schedule.test.DynamicScheduleTests.value.incrementAndGet();\n" + - "org.hswebframework.web.schedule.test.DynamicScheduleTests.counter.countDown();\n" + - "java.lang.System.out.println('script job running...')"); - entity.setQuartzConfig("{\"type\":\"cron\",\"config\":\"0/1 * * * * ?\"}"); - return entity; - } - - @Test - public void testCreateJob() throws InterruptedException { - counter.await(100, TimeUnit.SECONDS); - Assert.assertTrue(value.get()>0); - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java deleted file mode 100644 index 2e77a8569..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.schedule.test; - -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * TODO 完成注释 - * - * @author zhouhao - */ -@EnableScheduling -@Configuration -public class ScheduleTests extends SimpleWebApplicationTests { - - AtomicInteger counter = new AtomicInteger(); - - CountDownLatch countDownLatch = new CountDownLatch(1); - - @Scheduled(cron = "0/1 * * * * ?") - public void quartzTest() { - counter.incrementAndGet(); - countDownLatch.countDown(); - } - - @Test - public void test() throws InterruptedException { - countDownLatch.await(100, TimeUnit.SECONDS); - Assert.assertTrue(counter.get() > 0); - } -} diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/resources/application.yml deleted file mode 100644 index 04aae0347..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/resources/application.yml +++ /dev/null @@ -1,24 +0,0 @@ -spring: - aop: - auto: true - proxy-target-class: true - datasource: - url : jdbc:h2:file:./target/workflow-test;DB_CLOSE_ON_EXIT=FALSE - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver - cache: - type: simple - -logging: - level: - org.quartz: debug -# org.activiti: debug -mybatis: - dynamic-datasource: false -server: - port: 8080 -scheduler: - enable-cluster: false - execute-tags: core \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/pom.xml b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/pom.xml deleted file mode 100644 index 75d1c079d..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - hsweb-system-schedule - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-schedule-web - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-schedule-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/src/main/java/org/hswebframework/web/controller/schedule/ScheduleJobController.java b/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/src/main/java/org/hswebframework/web/controller/schedule/ScheduleJobController.java deleted file mode 100644 index 063fc0556..000000000 --- a/hsweb-system/hsweb-system-schedule/hsweb-system-schedule-web/src/main/java/org/hswebframework/web/controller/schedule/ScheduleJobController.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.hswebframework.web.controller.schedule; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.schedule.ScheduleJobEntity; -import org.hswebframework.web.service.schedule.ScheduleJobExecutor; -import org.hswebframework.web.service.schedule.ScheduleJobService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Map; - -/** - * 调度任务 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.scheduleJob:schedule/job}") -@Authorize(permission = "schedule-job", description = "定时调度管理") -@Api(value = "定时调度管理",tags = "定时调度管理") -public class ScheduleJobController implements SimpleGenericEntityController { - - private ScheduleJobService scheduleJobService; - - private ScheduleJobExecutor scheduleJobExecutor; - - @Autowired - @Authorize(ignore = true) - public void setScheduleJobExecutor(ScheduleJobExecutor scheduleJobExecutor) { - this.scheduleJobExecutor = scheduleJobExecutor; - } - - @Autowired - @Authorize(ignore = true) - public void setScheduleJobService(ScheduleJobService scheduleJobService) { - this.scheduleJobService = scheduleJobService; - } - - @Override - public ScheduleJobService getService() { - return scheduleJobService; - } - - @PutMapping("/{id}/enable") - @Authorize(action = Permission.ACTION_ENABLE) - @ApiOperation("启用任务") - public ResponseMessage enable(@PathVariable String id) { - scheduleJobService.enable(id); - return ResponseMessage.ok(); - } - - @PutMapping("/{id}/disable") - @Authorize(action = Permission.ACTION_DISABLE) - @ApiOperation("禁用任务") - public ResponseMessage disable(@PathVariable String id) { - scheduleJobService.disable(id); - return ResponseMessage.ok(); - } - - @PostMapping("/{id}/execute") - @Authorize(action = "execute", description = "执行任务") - @ApiOperation("执行任务") - public ResponseMessage execute(@PathVariable String id, @RequestBody Map args) { - return ResponseMessage.ok(scheduleJobExecutor.doExecuteJob(id, args)); - } -} diff --git a/hsweb-system/hsweb-system-schedule/pom.xml b/hsweb-system/hsweb-system-schedule/pom.xml deleted file mode 100644 index 72abaa205..000000000 --- a/hsweb-system/hsweb-system-schedule/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - pom - hsweb-system-schedule - - hsweb-system-schedule-starter - hsweb-system-schedule-api - hsweb-system-schedule-local - hsweb-system-schedule-web - - - - - - org.quartz-scheduler - quartz - 2.2.3 - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/README.md b/hsweb-system/hsweb-system-script/README.md deleted file mode 100644 index bd4daebe8..000000000 --- a/hsweb-system/hsweb-system-script/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## 动态脚本管理 -通过脚本(js,groovy...)在线编写代码,后端执行 - -## API \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-api/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-api/pom.xml deleted file mode 100644 index a9d909bc0..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-api/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - hsweb-system-script - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-script-api - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java b/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java deleted file mode 100644 index 1884d3bb2..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/ScriptEntity.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.hswebframework.web.entity.script; - -import org.hswebframework.web.commons.entity.GenericEntity; - -/** - * 动态脚本 实体 - * - * @author hsweb-generator-online - */ -public interface ScriptEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 脚本名称 - */ - String name = "name"; - /** - * 类型 - */ - String type = "type"; - /** - * 脚本内容 - */ - String script = "script"; - /** - * 脚本语言 - */ - String language = "language"; - /** - * 备注 - */ - String remark = "remark"; - /** - * 状态 - */ - String status = "status"; - /** - * 脚本标签 - */ - String tag = "tag"; - - /** - * @return 脚本名称 - */ - String getName(); - - /** - * @param name 脚本名称 - */ - void setName(String name); - - /** - * @return 类型 - */ - String getType(); - - /** - * @param type 类型 - */ - void setType(String type); - - /** - * @return 脚本内容 - */ - String getScript(); - - /** - * @param script 脚本内容 - */ - void setScript(String script); - - /** - * @return 脚本语言 - */ - String getLanguage(); - - /** - * @param language 脚本语言 - */ - void setLanguage(String language); - - /** - * @return 备注 - */ - String getRemark(); - - /** - * @param remark 备注 - */ - void setRemark(String remark); - - /** - * @return 状态 - */ - Long getStatus(); - - /** - * @param status 状态 - */ - void setStatus(Long status); - - /** - * @return 脚本标签 - */ - String getTag(); - - /** - * @param tag 脚本标签 - */ - void setTag(String tag); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java b/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java deleted file mode 100644 index e4c675599..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/entity/script/SimpleScriptEntity.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.hswebframework.web.entity.script; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** -* 动态脚本 -* @author hsweb-generator-online -*/ -public class SimpleScriptEntity extends SimpleGenericEntity implements ScriptEntity{ - //脚本名称 - private String name; - //类型 - private String type; - //脚本内容 - private String script; - //脚本语言 - private String language; - //备注 - private String remark; - //状态 - private Long status; - //脚本标签 - private String tag; - - /** - * @return 脚本名称 - */ - @Override - public String getName(){ - return this.name; - } - - /** - * @param name 脚本名称 - */ - @Override - public void setName(String name){ - this.name=name; - } - /** - * @return 类型 - */ - @Override - public String getType(){ - return this.type; - } - - /** - * @param type 类型 - */ - @Override - public void setType(String type){ - this.type=type; - } - /** - * @return 脚本内容 - */ - @Override - public String getScript(){ - return this.script; - } - - /** - * @param script 脚本内容 - */ - @Override - public void setScript(String script){ - this.script=script; - } - /** - * @return 脚本语言 - */ - @Override - public String getLanguage(){ - return this.language; - } - - /** - * @param language 脚本语言 - */ - @Override - public void setLanguage(String language){ - this.language=language; - } - /** - * @return 备注 - */ - @Override - public String getRemark(){ - return this.remark; - } - - /** - * @param remark 备注 - */ - @Override - public void setRemark(String remark){ - this.remark=remark; - } - /** - * @return 状态 - */ - @Override - public Long getStatus(){ - return this.status; - } - - /** - * @param status 状态 - */ - @Override - public void setStatus(Long status){ - this.status=status; - } - /** - * @return 脚本标签 - */ - @Override - public String getTag(){ - return this.tag; - } - - /** - * @param tag 脚本标签 - */ - @Override - public void setTag(String tag){ - this.tag=tag; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptExecutorService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptExecutorService.java deleted file mode 100644 index f8fb75cee..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptExecutorService.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.service.script; - -import java.util.Map; - -/** - * - * @author zhouhao - */ -public interface ScriptExecutorService { - Object execute(String id, Map parameters) throws Exception; -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java deleted file mode 100644 index edd6af712..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-api/src/main/java/org/hswebframework/web/service/script/ScriptService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.script; - -import org.hswebframework.web.entity.script.ScriptEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 动态脚本 服务类 - * - * @author hsweb-generator-online - */ -public interface ScriptService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-local/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-local/pom.xml deleted file mode 100644 index 86361afe7..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-local/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - hsweb-system-script - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-script-local - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-script-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java b/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java deleted file mode 100644 index a3084266d..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/dao/script/ScriptDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.script; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.script.ScriptEntity; - -/** -* 动态脚本 DAO接口 -* @author hsweb-generator-online - */ -public interface ScriptDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/DefaultScriptExecutorService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/DefaultScriptExecutorService.java deleted file mode 100644 index 37631c343..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/DefaultScriptExecutorService.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.hswebframework.web.service.script.simple; - -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.expands.script.engine.ScriptContext; -import org.hswebframework.web.entity.script.ScriptEntity; -import org.hswebframework.web.service.script.ScriptExecutorService; -import org.hswebframework.web.service.script.ScriptService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Map; - -/** - * @author zhouhao - */ -public class DefaultScriptExecutorService implements ScriptExecutorService { - - @Autowired - private ScriptService scriptService; - - public void setScriptService(ScriptService scriptService) { - this.scriptService = scriptService; - } - - @Override - @Transactional(rollbackFor = Throwable.class) - public Object execute(String id, Map parameters) throws Exception { - ScriptEntity scriptEntity = scriptService.selectByPk(id); - if (scriptEntity==null){ - return null; - } - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(scriptEntity.getLanguage()); - - String scriptId = "dynamicScript-" + id; - String scriptMd5 = DigestUtils.md5Hex(scriptEntity.getScript()); - - ScriptContext context = engine.getContext(scriptId); - - if (context == null || !context.getMd5().equals(scriptMd5)) { - engine.compile(scriptId, scriptEntity.getScript()); - } - - return engine.execute(scriptId, parameters).getIfSuccess(); - } -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java b/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java deleted file mode 100644 index 01de81aba..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/java/org/hswebframework/web/service/script/simple/SimpleScriptService.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.hswebframework.web.service.script.simple; - -import org.hswebframework.web.dao.script.ScriptDao; -import org.hswebframework.web.entity.script.ScriptEntity; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.script.ScriptService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.stereotype.Service; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("scriptService") -@CacheConfig(cacheNames = "dynamic-script") -public class SimpleScriptService extends EnableCacheGenericEntityService - implements ScriptService { - @Autowired - private ScriptDao scriptDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public ScriptDao getDao() { - return scriptDao; - } - -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml deleted file mode 100644 index c6bd97d82..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/script/ScriptMapper.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml deleted file mode 100644 index 8128c7639..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - hsweb-system-script - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-script-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-script-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-script-web - ${project.version} - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/java/org/hswebframework/web/service/dynamic/script/DynamicScriptAutoConfiguration.java b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/java/org/hswebframework/web/service/dynamic/script/DynamicScriptAutoConfiguration.java deleted file mode 100644 index f5787c989..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/java/org/hswebframework/web/service/dynamic/script/DynamicScriptAutoConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.service.dynamic.script; - -import org.hswebframework.web.service.script.simple.DefaultScriptExecutorService; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -@ComponentScan({ - "org.hswebframework.web.service.script", - "org.hswebframework.web.controller.script" -}) -public class DynamicScriptAutoConfiguration { - - @Bean - public DefaultScriptExecutorService defaultScriptExecutorService() { - return new DefaultScriptExecutorService(); - } -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index ac1acd0fd..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.service.dynamic.script.DynamicScriptAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 18fdc0705..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,47 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "动态脚本" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_script") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("脚本名称").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("type").alias("type").comment("类型").jdbcType(java.sql.JDBCType.VARCHAR).length(256).commit() - .addColumn().name("script").alias("script").comment("脚本内容").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("language").alias("language").comment("脚本语言").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("remark").alias("remark").comment("备注").jdbcType(java.sql.JDBCType.VARCHAR).length(512).commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.DECIMAL).length(4, 0).commit() - .addColumn().name("tag").alias("tag").comment("脚本标签").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .comment("动态脚本").commit(); - -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/java/org/hswebframework/web/workflow/flowable/ControllerTest.java b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/java/org/hswebframework/web/workflow/flowable/ControllerTest.java deleted file mode 100644 index 9e612020e..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/java/org/hswebframework/web/workflow/flowable/ControllerTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.hswebframework.web.workflow.flowable; - - -import com.alibaba.fastjson.JSONObject; -import org.hswebframework.web.tests.SimpleWebApplicationTests; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.http.MediaType; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * TODO 完善rest测试 - * - * @Author wangwei - * @Date 2017/8/1. - */ -public class ControllerTest extends SimpleWebApplicationTests { - - @Test - public void testRest() throws Exception { - JSONObject res = testPost("/script").setUp(setup -> { - setup.contentType(MediaType.APPLICATION_JSON); - setup.content("{\"id\":\"test\",\"name\":\"test\",\"language\":\"js\",\"script\":\"return 'success';\"}"); - }).exec().resultAsJson(); - - JSONObject jsonObject = testGet("/script/test/execute") - .exec().resultAsJson(); - System.out.println(jsonObject); - Assert.assertEquals(jsonObject.get("result"), "success"); - } - - -} diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/resources/application.yml b/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/resources/application.yml deleted file mode 100644 index 5dc05e8fc..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-starter/src/test/resources/application.yml +++ /dev/null @@ -1,21 +0,0 @@ -spring: - aop: - auto: true - proxy-target-class: true - datasource: - url : jdbc:h2:file:./target/script-test - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - cache: - type: simple - -logging: - level: - org.flowable: debug - org.hswebframework.web: debug -# org.activiti: debug -mybatis: - dynamic-datasource: false -server: - port: 8088 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-web/pom.xml b/hsweb-system/hsweb-system-script/hsweb-system-script-web/pom.xml deleted file mode 100644 index f4e78b0f1..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-web/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - hsweb-system-script - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-script-web - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-script-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-script/hsweb-system-script-web/src/main/java/org/hswebframework/web/controller/script/ScriptController.java b/hsweb-system/hsweb-system-script/hsweb-system-script-web/src/main/java/org/hswebframework/web/controller/script/ScriptController.java deleted file mode 100644 index 73c7de9b0..000000000 --- a/hsweb-system/hsweb-system-script/hsweb-system-script-web/src/main/java/org/hswebframework/web/controller/script/ScriptController.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.hswebframework.web.controller.script; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.entity.script.ScriptEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.script.ScriptExecutorService; -import org.hswebframework.web.service.script.ScriptService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; -import java.util.Map; - -/** - * 动态脚本 - * - * @author hsweb-generator-online - */ -@RestController -@RequestMapping("${hsweb.web.mappings.script:script}") -@Authorize(permission = "script", description = "动态脚本管理") -@Api(value = "动态脚本",tags = "动态脚本管理") -public class ScriptController implements SimpleGenericEntityController { - - private ScriptService scriptService; - - private ScriptExecutorService scriptExecutorService; - - @Autowired - public void setScriptService(ScriptService scriptService) { - this.scriptService = scriptService; - } - - @Autowired - public void setScriptExecutorService(ScriptExecutorService scriptExecutorService) { - this.scriptExecutorService = scriptExecutorService; - } - - @Override - public ScriptService getService() { - return scriptService; - } - - - @GetMapping("/{id}/execute") - @ApiOperation("执行脚本") - @Authorize(action = "execute", description = "执行脚本") - public ResponseMessage executeForGet(@PathVariable String id, @RequestParam(required = false) Map parameters) throws Exception { - if (parameters == null) { - parameters = new HashMap<>(); - } - Object result = scriptExecutorService.execute(id, parameters); - return ResponseMessage.ok(result); - } - - - @RequestMapping(value = "/{id}/execute", method = {RequestMethod.POST, RequestMethod.PUT}) - @Authorize(action = "execute", description = "执行脚本") - @ApiOperation("执行脚本") - public ResponseMessage executeFotPostAndPut(@PathVariable String id, - @RequestBody(required = false) Map parameters) throws Exception { - return ResponseMessage.ok(executeForGet(id, parameters)); - } -} diff --git a/hsweb-system/hsweb-system-script/pom.xml b/hsweb-system/hsweb-system-script/pom.xml deleted file mode 100644 index 739a16c34..000000000 --- a/hsweb-system/hsweb-system-script/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-script - pom - - hsweb-system-script-starter - hsweb-system-script-api - hsweb-system-script-local - hsweb-system-script-web - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/README.md b/hsweb-system/hsweb-system-template/README.md deleted file mode 100644 index d7f9a3c9b..000000000 --- a/hsweb-system/hsweb-system-template/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## 模板管理 -在线编辑模板,指定模板语言,传入数据,渲染模板 -##API -//todo \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-api/pom.xml deleted file mode 100644 index c2e9a6b35..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - hsweb-system-template - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-template-api - - - - - org.hswebframework.web - hsweb-commons-service-api - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/SimpleTemplateEntity.java b/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/SimpleTemplateEntity.java deleted file mode 100644 index 07362f5f8..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/SimpleTemplateEntity.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.hswebframework.web.entity.template; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** -* 模板 -* @author hsweb-generator-online -*/ -public class SimpleTemplateEntity extends SimpleGenericEntity implements TemplateEntity { - //模板名称 - private String name; - //模板类型 - private String type; - //模板内容 - private String template; - //模板配置 - private String config; - //版本号 - private Long version; - //模板分类 - private String classified; - - /** - * @return 模板名称 - */ - @Override - public String getName(){ - return this.name; - } - - /** - * @param name 模板名称 - */ - @Override - public void setName(String name){ - this.name=name; - } - /** - * @return 模板类型 - */ - @Override - public String getType(){ - return this.type; - } - - /** - * @param type 模板类型 - */ - @Override - public void setType(String type){ - this.type=type; - } - /** - * @return 模板内容 - */ - @Override - public String getTemplate(){ - return this.template; - } - - /** - * @param template 模板内容 - */ - @Override - public void setTemplate(String template){ - this.template=template; - } - /** - * @return 模板配置 - */ - @Override - public String getConfig(){ - return this.config; - } - - /** - * @param config 模板配置 - */ - @Override - public void setConfig(String config){ - this.config=config; - } - /** - * @return 版本号 - */ - @Override - public Long getVersion(){ - return this.version; - } - - /** - * @param version 版本号 - */ - @Override - public void setVersion(Long version){ - this.version=version; - } - /** - * @return 模板分类 - */ - @Override - public String getClassified(){ - return this.classified; - } - - /** - * @param classified 模板分类 - */ - @Override - public void setClassified(String classified){ - this.classified=classified; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/TemplateEntity.java b/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/TemplateEntity.java deleted file mode 100644 index abac7de84..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/entity/template/TemplateEntity.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.hswebframework.web.entity.template; - -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.GenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import javax.validation.constraints.NotNull; - -/** - * 模板 实体 - * - * @author hsweb-generator-online - */ -public interface TemplateEntity extends GenericEntity { - /*------------------------------------------- - | 属性名常量 | - ===========================================*/ - /** - * 模板名称 - */ - String name = "name"; - /** - * 模板类型 - */ - String type = "type"; - /** - * 模板内容 - */ - String template = "template"; - /** - * 模板配置 - */ - String config = "config"; - /** - * 版本号 - */ - String version = "version"; - /** - * 模板分类 - */ - String classified = "classified"; - - /** - * @return 模板名称 - */ - @NotBlank(groups = CreateGroup.class) - String getName(); - - /** - * @param name 模板名称 - */ - void setName(String name); - - /** - * @return 模板类型 - */ - @NotBlank(groups = CreateGroup.class) - String getType(); - - /** - * @param type 模板类型 - */ - void setType(String type); - - /** - * @return 模板内容 - */ - String getTemplate(); - - /** - * @param template 模板内容 - */ - void setTemplate(String template); - - /** - * @return 模板配置 - */ - String getConfig(); - - /** - * @param config 模板配置 - */ - void setConfig(String config); - - /** - * @return 版本号 - */ - @NotNull(groups = CreateGroup.class) - Long getVersion(); - - /** - * @param version 版本号 - */ - void setVersion(Long version); - - /** - * @return 模板分类 - */ - String getClassified(); - - /** - * @param classified 模板分类 - */ - void setClassified(String classified); - -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRendeFacotry.java b/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRendeFacotry.java deleted file mode 100644 index 7c8ae91f9..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRendeFacotry.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.service.template; - -import org.hswebframework.web.entity.template.TemplateEntity; - -/** - * 模板渲染器工厂 - * - * @author zhouhao - * @since 3.0 - */ -public interface TemplateRendeFacotry { - boolean isSupport(String type); - - TemplateRender create(TemplateEntity templateEntity); -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRender.java b/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRender.java deleted file mode 100644 index ef9a7b0f7..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateRender.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.service.template; - -/** - * 模板渲染器 - * - * @author zhouhao - * @since 3.0 - */ -public interface TemplateRender { - String render(Object context); -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateService.java b/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateService.java deleted file mode 100644 index 4947d9d8d..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-api/src/main/java/org/hswebframework/web/service/template/TemplateService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.service.template; - -import org.hswebframework.web.entity.template.TemplateEntity; -import org.hswebframework.web.service.CrudService; - -/** - * 模板 服务类 - * - * @author hsweb-generator-online - */ -public interface TemplateService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-local/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-local/pom.xml deleted file mode 100644 index a5fa48d9a..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-local/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - hsweb-system-template - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-template-local - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - org.hswebframework.web - hsweb-system-template-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/dao/template/TemplateDao.java b/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/dao/template/TemplateDao.java deleted file mode 100644 index cf553fc5b..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/dao/template/TemplateDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.dao.template; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.entity.template.TemplateEntity; - -/** -* 模板 DAO接口 -* @author hsweb-generator-online - */ -public interface TemplateDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/service/template/simple/SimpleTemplateService.java b/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/service/template/simple/SimpleTemplateService.java deleted file mode 100644 index 5258949fb..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/java/org/hswebframework/web/service/template/simple/SimpleTemplateService.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.hswebframework.web.service.template.simple; - -import org.hswebframework.web.dao.template.TemplateDao; -import org.hswebframework.web.entity.template.TemplateEntity; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.template.TemplateService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.stereotype.Service; -import org.springframework.util.AntPathMatcher; - -import java.util.regex.Pattern; - -/** - * 默认的服务实现 - * - * @author hsweb-generator-online - */ -@Service("templateService") -@CacheConfig(cacheNames = "template") -public class SimpleTemplateService extends EnableCacheGenericEntityService - implements TemplateService { - @Autowired - private TemplateDao templateDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public TemplateDao getDao() { - return templateDao; - } - - @Override - public int updateByPk(String id, TemplateEntity entity) { - TemplateEntity old = selectByPk(id); - assertNotNull(old); - entity.setVersion(old.getVersion() + 1); - return super.updateByPk(id, entity); - } - - @Override - public String insert(TemplateEntity entity) { - entity.setVersion(1L); - return super.insert(entity); - } -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/template/TemplateMapper.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/template/TemplateMapper.xml deleted file mode 100644 index 5da1f81ec..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/template/TemplateMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml deleted file mode 100644 index f00829279..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - hsweb-system-template - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-template-starter - - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-system-template-local - ${project.version} - - - - org.hswebframework.web - hsweb-system-template-web - ${project.version} - - - - com.h2database - h2 - test - - - - com.alibaba - druid - 1.0.26 - test - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - javax.servlet - javax.servlet-api - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/java/org/hswebframework/web/template/starter/TemplateAutoConfiguration.java b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/java/org/hswebframework/web/template/starter/TemplateAutoConfiguration.java deleted file mode 100644 index 49cee807d..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/java/org/hswebframework/web/template/starter/TemplateAutoConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.template.starter; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0 - */ -@Configuration -@ComponentScan({"org.hswebframework.web.service.template.simple" - , "org.hswebframework.web.controller.template"}) -public class TemplateAutoConfiguration { -} diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 6f04b0c24..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.template.starter.TemplateAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js deleted file mode 100644 index 653fdaa3a..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-starter/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,45 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "模板" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; -function install(context) { - var database = context.database; - database.createOrAlter("s_template") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("name").alias("name").comment("模板名称").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("type").alias("type").comment("模板类型").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("template").alias("template").comment("模板内容").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("config").alias("config").comment("模板配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("version").alias("version").comment("版本号").jdbcType(java.sql.JDBCType.DECIMAL).length(32, 0).commit() - .addColumn().name("classified").alias("classified").comment("模板分类").jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .comment("模板").commit(); -} -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-web/pom.xml b/hsweb-system/hsweb-system-template/hsweb-system-template-web/pom.xml deleted file mode 100644 index 1147f6aa6..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-web/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - hsweb-system-template - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-template-web - - - - javax.servlet - javax.servlet-api - true - - - org.hswebframework.web - hsweb-system-template-api - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-template/hsweb-system-template-web/src/main/java/org/hswebframework/web/controller/template/TemplateController.java b/hsweb-system/hsweb-system-template/hsweb-system-template-web/src/main/java/org/hswebframework/web/controller/template/TemplateController.java deleted file mode 100644 index ddd2f2496..000000000 --- a/hsweb-system/hsweb-system-template/hsweb-system-template-web/src/main/java/org/hswebframework/web/controller/template/TemplateController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.controller.template; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.entity.template.TemplateEntity; -import org.hswebframework.web.logging.AccessLogger; -import org.hswebframework.web.service.template.TemplateService; -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.template:template}") -@Authorize(permission = "template", description = "模版管理") -@Api(tags = "模版管理", value = "模版管理") -public class TemplateController implements SimpleGenericEntityController { - - private TemplateService templateService; - - @Autowired - public void setTemplateService(TemplateService templateService) { - this.templateService = templateService; - } - - @Override - public TemplateService getService() { - return templateService; - } -} diff --git a/hsweb-system/hsweb-system-template/pom.xml b/hsweb-system/hsweb-system-template/pom.xml deleted file mode 100644 index f51c96c9d..000000000 --- a/hsweb-system/hsweb-system-template/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-system-template - pom - - - hsweb-system-template-starter - hsweb-system-template-api - hsweb-system-template-web - hsweb-system-template-local - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/README.md b/hsweb-system/hsweb-system-workflow/README.md deleted file mode 100644 index 9ca989317..000000000 --- a/hsweb-system/hsweb-system-workflow/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## 工作流模板 -使用flowable(前activiti) 整合组织架构和动态表单。实现灵活的工作流配置和运行。 - -## SQL条件 -`hsweb-system-workflow-local`模块中提供了一些自定义的查询条件,用于对流程的关联查询.可以在动态查询中 -进行使用,例如: - -```java - -//查询id为userId用户的待办任务 -createQuery().where("processInstanceId","user-wf-todo",userId).list(); - -``` -注意: 表中需要存在与属性`processInstanceId`关联的字段 - -1. user-wf-claim : 用户待签收(领取)的流程数据 -2. user-wf-todo : 用户待处理的流程数据 -3. user-wf-completed : 用户已处理的流程数据 -4. user-wf-part : 用户参与的流程数据,通过options来参与的类型: `where("processInstanceId$user-wf-part$starter","admin")`.(参与类型为`starter`) diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/pom.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/pom.xml deleted file mode 100644 index f7be57d00..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/pom.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - - hsweb-system-workflow - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-workflow-local - - - - - src/main/resources - true - - - - - - - org.hswebframework.web - hsweb-commons-dao-mybatis - ${project.version} - - - - org.hswebframework.web - hsweb-commons-service-simple - ${project.version} - - - - org.flowable - flowable-spring-boot-starter-basic - ${flowable.version} - - - - org.flowable - flowable-json-converter - ${flowable.version} - - - - org.apache.xmlgraphics - batik-parser - ${batik.version} - - - - org.apache.xmlgraphics - batik-transcoder - ${batik.version} - - - commons-logging - commons-logging - - - - - - org.apache.xmlgraphics - batik-bridge - ${batik.version} - - - org.apache.xmlgraphics - batik-codec - ${batik.version} - - - org.apache.xmlgraphics - batik-css - ${batik.version} - - - org.apache.xmlgraphics - batik-svg-dom - ${batik.version} - - - org.apache.xmlgraphics - batik-svggen - ${batik.version} - - - org.imgscalr - imgscalr-lib - 4.2 - - - math.geom2d - javaGeom - 0.11.1 - - - org.springframework.boot - spring-boot-starter-web - - - org.hswebframework.web - hsweb-commons-entity - ${project.version} - - - org.hswebframework.web - hsweb-commons-controller - ${project.version} - - - org.hswebframework.web - hsweb-system-authorization-api - ${project.version} - - - org.hswebframework.web - hsweb-datasource-api - ${project.version} - - - - org.hswebframework.web - hsweb-system-organizational-api - ${project.version} - - - - org.hswebframework.web - hsweb-system-organizational-authorization - ${project.version} - - - - org.hswebframework.web - hsweb-system-dynamic-form-api - ${project.version} - - - - io.vavr - vavr - - - - org.hswebframework.web - hsweb-system-dynamic-form-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-system-authorization-starter - ${project.version} - test - - - org.hswebframework.web - hsweb-system-organizational-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ActivityConfigDao.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ActivityConfigDao.java deleted file mode 100644 index 5d48b94b3..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ActivityConfigDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.workflow.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ActivityConfigDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessDefineConfigDao.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessDefineConfigDao.java deleted file mode 100644 index 2e1cdedae..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessDefineConfigDao.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.workflow.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessDefineConfigDao extends CrudDao { - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessHistoryDao.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessHistoryDao.java deleted file mode 100644 index c37155065..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/ProcessHistoryDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.workflow.dao; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.workflow.dao.entity.ProcessHistoryEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessHistoryDao extends CrudDao { -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ActivityConfigEntity.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ActivityConfigEntity.java deleted file mode 100644 index 483f11321..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ActivityConfigEntity.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.hswebframework.web.workflow.dao.entity; - -import lombok.Getter; -import lombok.Setter; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.List; -import java.util.Map; - -@Getter -@Setter -public class ActivityConfigEntity extends SimpleGenericEntity { - - private static final long serialVersionUID = 2909584456889604626L; - - /** - * 节点ID - */ - @NotBlank(groups = CreateGroup.class) - private String activityId; - - /** - * 流程定义key - */ - @NotBlank(groups = CreateGroup.class) - private String processDefineKey; - - /** - * 流程定义ID - */ - @NotBlank(groups = CreateGroup.class) - private String processDefineId; - - /** - * 后台表单ID - */ - private String formId; - - /** - * 节点办理候选人维度,用于设置该环节的办理人,json格式,由CandidateDimensionParser解析 - */ - private String candidateDimension; - - @NotNull(groups = CreateGroup.class) - private Date createTime; - - private Date updateTime; - - @NotNull(groups = CreateGroup.class) - private Byte status; - - private List listeners; - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ListenerConfig.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ListenerConfig.java deleted file mode 100644 index 941753605..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ListenerConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.hswebframework.web.workflow.dao.entity; - -import lombok.Getter; -import lombok.Setter; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -public class ListenerConfig { - private String eventType; - - private String language; - - private String script; - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessDefineConfigEntity.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessDefineConfigEntity.java deleted file mode 100644 index 9e5674d78..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessDefineConfigEntity.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.hswebframework.web.workflow.dao.entity; - -import lombok.Getter; -import lombok.Setter; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; -import org.hswebframework.web.validator.group.CreateGroup; - -import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.List; -import java.util.Map; - -@Getter -@Setter -public class ProcessDefineConfigEntity extends SimpleGenericEntity { - - private static final long serialVersionUID = -140312693789656665L; - /** - * 流程定义Key - */ - @NotBlank(groups = CreateGroup.class) - private String processDefineKey; - - /** - * 流程定义ID - */ - @NotBlank(groups = CreateGroup.class) - private String processDefineId; - - /** - * 后台表单ID - */ - @NotBlank(groups = CreateGroup.class) - private String formId; - - /** - * 权限维度,用于控制不同人,可发起不同的流程 - */ - private String permissionDimension; - - private Date createTime; - - private Date updateTime; - - /** - * 状态 - */ - @NotNull(groups = CreateGroup.class) - private Byte status; - - private List listeners; - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessHistoryEntity.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessHistoryEntity.java deleted file mode 100644 index a20f87aaa..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dao/entity/ProcessHistoryEntity.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.hswebframework.web.workflow.dao.entity; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ProcessHistoryEntity extends SimpleGenericEntity { - - private static final long serialVersionUID = 1413072102870937450L; - - @NotBlank(message = "[type]不能为空") - private String type; - - @NotBlank(message = "[typeText]不能为空") - private String typeText; - - @NotBlank(message = "[processDefineId]不能为空") - private String processDefineId; - - @NotBlank(message = "[processInstanceId]不能为空") - private String processInstanceId; - - @NotBlank(message = "[businessKey]不能为空") - private String businessKey; - - @NotNull(message = "[createTime]不能为空") - private Date createTime; - - @NotBlank(message = "[creatorId]不能为空") - private String creatorId; - - @NotBlank(message = "[creatorName]不能为空") - private String creatorName; - - private Map data = new HashMap<>(); - - private String taskId; - - private String taskDefineKey; - - private String taskName; -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimension.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimension.java deleted file mode 100644 index acc0d8d15..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimension.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - -import java.util.Collections; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface CandidateDimension { - - List getCandidateUserIdList(); - - CandidateDimension empty = Collections::emptyList; - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimensionParser.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimensionParser.java deleted file mode 100644 index cca5acff7..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/CandidateDimensionParser.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - -/** - * @author zhouhao - * @see CandidateDimension - * @since 3.0.0-RC - */ -public interface CandidateDimensionParser { - CandidateDimension parse(DimensionContext context, String jsonConfig); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParser.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParser.java deleted file mode 100644 index 0c9ca891e..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParser.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import io.vavr.Lazy; -import org.apache.commons.collections.CollectionUtils; -import org.hswebframework.web.workflow.dimension.parser.CandidateDimensionParserStrategy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -@Component -public class DefaultCandidateDimensionParser implements CandidateDimensionParser { - - @Autowired(required = false) - private List strategies; - - private CandidateDimension parse(DimensionContext context, JSONArray jsonConfig) { - List configList = jsonConfig.stream() - .filter(json -> json instanceof JSONObject) - .map(JSONObject.class::cast) - .filter(json -> json.get("dimension") != null && CollectionUtils.isNotEmpty(json.getJSONArray("idList"))) - .map(json -> { - CandidateDimensionParserStrategy.StrategyConfig config = json.toJavaObject(CandidateDimensionParserStrategy.StrategyConfig.class); - if (config.getConfig() == null) { - config.setConfig(json); - } - return config; - }).collect(Collectors.toList()); - - if (configList.isEmpty()) { - return CandidateDimension.empty; - } - return Lazy.val(() -> { - List list = configList.stream() - .flatMap(config -> - strategies - .stream() - .filter(strategy -> strategy.support(config.getDimension())) - .map(strategy -> strategy.parse(context, config)) - .filter(CollectionUtils::isNotEmpty) - .flatMap(Collection::stream) - .filter(StringUtils::hasText) - ).collect(Collectors.toList()); - - return (CandidateDimension) () -> list; - }, CandidateDimension.class); - - } - - @Override - public CandidateDimension parse(DimensionContext context, String jsonConfig) { - JSONArray jsonArray; - if (jsonConfig.startsWith("[")) { - jsonArray = JSON.parseArray(jsonConfig); - } else { - JSONObject jsonObject = JSON.parseObject(jsonConfig); - jsonArray = new JSONArray(); - jsonArray.add(jsonObject); - } - return parse(context, jsonArray); - - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultPermissionDimensionParser.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultPermissionDimensionParser.java deleted file mode 100644 index e8e1949c3..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultPermissionDimensionParser.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - -import org.hswebframework.web.authorization.AuthenticationPredicate; -import org.hswebframework.web.authorization.AuthenticationUtils; -import org.springframework.stereotype.Component; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -public class DefaultPermissionDimensionParser implements PermissionDimensionParser { - @Override - public AuthenticationPredicate parse(String jsonConfig) { - - return AuthenticationUtils.createPredicate(jsonConfig); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DimensionContext.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DimensionContext.java deleted file mode 100644 index ff6e59719..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DimensionContext.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - - -import lombok.*; -import org.activiti.engine.task.TaskInfo; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DimensionContext { - - /** - * 流程发起人ID - */ - private String creatorId; - - private String processDefineId; - - private String activityId; - - /** - * 当前环节 - */ - private TaskInfo task; - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/PermissionDimensionParser.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/PermissionDimensionParser.java deleted file mode 100644 index 8a9f9dfeb..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/PermissionDimensionParser.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.workflow.dimension; - -import org.hswebframework.web.authorization.AuthenticationPredicate; - -/** - * @author zhouhao - * @see AuthenticationPredicate - * @since 3.0.0-RC - */ -public interface PermissionDimensionParser { - AuthenticationPredicate parse(String jsonConfig); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/CandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/CandidateDimensionParserStrategy.java deleted file mode 100644 index 3f1dd183c..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/CandidateDimensionParserStrategy.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.workflow.dimension.DimensionContext; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -public interface CandidateDimensionParserStrategy { - String DIMENSION_USER = "user"; - String DIMENSION_ROLE = "role"; - String DIMENSION_POSITION = "position"; - String DIMENSION_DEPARTMENT = "department"; - String DIMENSION_ORG = "org"; - String DIMENSION_RELATION = "relation"; - - boolean support(String dimension); - - List parse(DimensionContext context, StrategyConfig config); - - @Getter - @Setter - class StrategyConfig { - private String dimension; - - private List idList; - - private Map config; - - public Optional getConfig(String name) { - return config == null ? Optional.empty() : Optional.ofNullable(config.get(name)); - } - - public Optional getStringConfig(String name) { - return config == null ? - Optional.empty() : - Optional.ofNullable(config.get(name)) - .map(String::valueOf); - } - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/DepartmentCandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/DepartmentCandidateDimensionParserStrategy.java deleted file mode 100644 index f0e52b788..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/DepartmentCandidateDimensionParserStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.hswebframework.web.commons.entity.param.QueryParamEntity.empty; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@ConditionalOnBean(UserService.class) -public class DepartmentCandidateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - @Autowired(required = false) - private UserService userService; - - @Override - public boolean support(String dimension) { - return DIMENSION_DEPARTMENT.equals(dimension) && userService != null; - } - - @Override - public List parse(DimensionContext context,StrategyConfig config) { - - String type = config.getConfig("tree") - .map(String::valueOf) - .map("-"::concat) - .orElse(""); - - return userService.select( - empty().noPaging() - //https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-organizational#sql条件 - .where("id", "user-in-department" + type, config.getIdList())) - .stream() - .map(UserEntity::getId) - .collect(Collectors.toList()); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/OrgCandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/OrgCandidateDimensionParserStrategy.java deleted file mode 100644 index 8b13506f0..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/OrgCandidateDimensionParserStrategy.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.hswebframework.web.commons.entity.param.QueryParamEntity.empty; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@ConditionalOnBean(UserService.class) -public class OrgCandidateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - @Autowired(required = false) - private UserService userService; - - @Override - public boolean support(String dimension) { - return DIMENSION_ORG.equals(dimension) && userService != null; - } - - @Override - public List parse(DimensionContext context, StrategyConfig config) { - String type = config.getConfig("tree") - .map(String::valueOf) - .map("-"::concat) - .orElse(""); - return userService.select( - empty().noPaging() - //https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-organizational#sql条件 - .where("id", "user-in-org" + type, config.getIdList())) - .stream() - .map(UserEntity::getId) - .collect(Collectors.toList()); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/PositionCandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/PositionCandidateDimensionParserStrategy.java deleted file mode 100644 index a14d5d3ef..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/PositionCandidateDimensionParserStrategy.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.stream.Collectors; - -import static org.hswebframework.web.commons.entity.param.QueryParamEntity.*; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@ConditionalOnBean(UserService.class) -public class PositionCandidateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - @Autowired(required = false) - private UserService userService; - - @Override - public boolean support(String dimension) { - return DIMENSION_POSITION.equals(dimension) && userService != null; - } - - @Override - public List parse(DimensionContext context, StrategyConfig config) { - String type = config.getConfig("tree") - .map(String::valueOf) - .map("-"::concat) - .orElse(""); - return userService.select( - empty().noPaging() - //https://github.com/hs-web/hsweb-framework/tree/master/hsweb-system/hsweb-system-organizational#sql条件 - .where("id", "user-in-position"+type, config.getIdList())) - .stream() - .map(UserEntity::getId) - .collect(Collectors.toList()); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/RoleCandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/RoleCandidateDimensionParserStrategy.java deleted file mode 100644 index 434dec4f8..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/RoleCandidateDimensionParserStrategy.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -@ConditionalOnBean(UserService.class) -public class RoleCandidateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - - @Autowired(required = false) - private UserService userService; - - - @Override - public boolean support(String dimension) { - return DIMENSION_ROLE.equals(dimension) && userService != null; - } - - @Override - public List parse(DimensionContext context, StrategyConfig config) { - return userService.selectByUserByRole(config.getIdList()) - .stream() - .map(UserEntity::getId) - .collect(Collectors.toList()); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/ScriptCandiateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/ScriptCandiateDimensionParserStrategy.java deleted file mode 100644 index c6371f7eb..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/ScriptCandiateDimensionParserStrategy.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.web.Lists; -import org.hswebframework.web.Maps; -import org.hswebframework.web.entity.authorization.UserEntity; -import org.hswebframework.web.entity.organizational.PersonEntity; -import org.hswebframework.web.organizational.authorization.relation.PersonRelations; -import org.hswebframework.web.organizational.authorization.relation.Relation; -import org.hswebframework.web.organizational.authorization.relation.RelationsManager; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.util.DigestUtils; -import org.springframework.util.StringUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Slf4j -@ConditionalOnBean(RelationsManager.class) -public class ScriptCandiateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - @Autowired - private RelationsManager relationsManager; - - @Override - public boolean support(String dimension) { - return DIMENSION_RELATION.equals(dimension); - } - - @Override - @SneakyThrows - @SuppressWarnings("all") - public List parse(DimensionContext context, StrategyConfig config) { - String expression = config.getStringConfig("expression").orElse(null); - String expressionLanguage = config.getStringConfig("expressionLanguage").orElse(null); - - if (StringUtils.isEmpty(expression)) { - return new java.util.ArrayList<>(); - } - - String creatorId = context.getCreatorId(); - - Supplier creator = () -> relationsManager.getPersonRelationsByUserId(creatorId); - - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(expressionLanguage); - - if (engine == null) { - throw new UnsupportedOperationException("不支持的脚本:" + expressionLanguage); - } - - String id = DigestUtils.md5DigestAsHex(expression.getBytes()); - if (!engine.compiled(id)) { - engine.compile(id, expression); - } - - Object obj = engine.execute(id, Maps.buildMap() - .put("user", creator) - .put("creator", creator) - .put("creatorId", creatorId) - .put("context", context) - .get()) - .getIfSuccess(); - - Function userIdConverter = o -> { - if (o instanceof String) { - return (String) o; - } else if (o instanceof Relation) { - Object target = ((Relation) o).getTargetObject(); - if (target instanceof PersonEntity) { - return ((PersonEntity) target).getUserId(); - } else if (target instanceof UserEntity) { - return ((UserEntity) target).getId(); - } else { - return ((Relation) o).getTarget(); - } - } else { - log.warn("不支持的关系:{}", o); - return null; - } - }; - - if (obj instanceof List) { - List list = ((List) obj); - return list.stream() - .map(userIdConverter) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } else { - String result = userIdConverter.apply(obj); - if (result == null) { - return new java.util.ArrayList<>(); - } - return Lists.buildList(result).get(); - } - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/UserCandidateDimensionParserStrategy.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/UserCandidateDimensionParserStrategy.java deleted file mode 100644 index a34c26eea..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/UserCandidateDimensionParserStrategy.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.workflow.dimension.parser; - -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -public class UserCandidateDimensionParserStrategy implements CandidateDimensionParserStrategy { - - @Override - public boolean support(String dimension) { - return DIMENSION_USER.equals(dimension); - } - - @Override - public List parse(DimensionContext context, StrategyConfig config) { - return config.getIdList(); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/enums/ModelType.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/enums/ModelType.java deleted file mode 100644 index 355465e7d..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/enums/ModelType.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.hswebframework.web.workflow.enums; - -/** - * @author zhouhao - * @since 3.0.5 - */ -public enum ModelType { - bpmn, json -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/FlowableAutoConfiguration.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/FlowableAutoConfiguration.java deleted file mode 100644 index ecf095964..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/FlowableAutoConfiguration.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.hswebframework.web.workflow.flowable; - -import org.activiti.engine.delegate.event.ActivitiEventListener; -import org.activiti.engine.impl.interceptor.SessionFactory; -import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; -import org.hswebframework.web.dao.Dao; -import org.hswebframework.web.service.authorization.UserService; -import org.hswebframework.web.workflow.flowable.utils.CustomGroupEntityManager; -import org.hswebframework.web.workflow.flowable.utils.CustomGroupEntityManagerFactory; -import org.hswebframework.web.workflow.flowable.utils.CustomUserEntityManager; -import org.hswebframework.web.workflow.flowable.utils.CustomUserEntityManagerFactory; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -@Configuration -@AutoConfigureAfter(FlowableAutoConfiguration.CustomEntityManagerAutoConfiguration.class) -@MapperScan(value = "org.hswebframework.web.workflow.dao", markerInterface = Dao.class - , sqlSessionFactoryRef = "sqlSessionFactory") -public class FlowableAutoConfiguration { - - @Autowired(required = false) - private List sessionFactories; - - @Autowired(required = false) - private List activitiEventListeners; - - @Bean - public ProcessEngineConfigurationConfigurer processEngineConfigurationConfigurer() { - return configuration -> { - configuration - .setAsyncExecutorActivate(false) -// .setDatabaseSchemaUpdate("false") - .setJobExecutorActivate(false) - .setActivityFontName("宋体") - .setLabelFontName("宋体") - .setAnnotationFontName("宋体"); - - if (activitiEventListeners != null) { - configuration.setEventListeners(activitiEventListeners); - } - if (sessionFactories != null) { - configuration.setCustomSessionFactories(sessionFactories); - } - }; - } - - @ConditionalOnBean(UserService.class) - @Configuration - public static class CustomEntityManagerAutoConfiguration { - - @Autowired - private UserService userService; - - @Bean - public CustomGroupEntityManagerFactory customGroupEntityManagerFactory() { - return new CustomGroupEntityManagerFactory(new CustomGroupEntityManager(userService)); - } - - @Bean - public CustomUserEntityManagerFactory customUserEntityManagerFactory() { - return new CustomUserEntityManagerFactory(new CustomUserEntityManager(userService)); - } - - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/ActivitiUserUtil.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/ActivitiUserUtil.java deleted file mode 100644 index a1779ab9c..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/ActivitiUserUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.identity.Group; -import org.activiti.engine.impl.persistence.entity.GroupEntity; -import org.activiti.engine.impl.persistence.entity.UserEntity; -import org.hswebframework.web.entity.authorization.RoleEntity; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Author wangwei - * @Date 2017/8/3. - */ -public class ActivitiUserUtil { - public static UserEntity toActivitiUser(org.hswebframework.web.entity.authorization.UserEntity bUser) { - UserEntity userEntity = new UserEntity(); - userEntity.setId(bUser.getId()); - userEntity.setFirstName(bUser.getUsername()); - userEntity.setLastName(bUser.getName()); - userEntity.setPassword(bUser.getPassword()); -// userEntity.setEmail(bUser.getEmail()); - userEntity.setRevision(1); - return userEntity; - } - - public static GroupEntity toActivitiGroup(RoleEntity sysRole) { - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setId(sysRole.getId()); - groupEntity.setRevision(1); - groupEntity.setType("assignment"); - groupEntity.setName(sysRole.getName()); - return groupEntity; - } - - public static List toActivitiGroups(List roleEntities) { - List groups = new ArrayList(); - for (RoleEntity roleEntity : roleEntities) { - GroupEntity groupEntity = toActivitiGroup(roleEntity); - groups.add(groupEntity); - } - return groups; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManager.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManager.java deleted file mode 100644 index 5e97b8ff9..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManager.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.identity.Group; -import org.activiti.engine.impl.GroupQueryImpl; -import org.activiti.engine.impl.Page; -import org.activiti.engine.impl.persistence.entity.GroupEntity; -import org.activiti.engine.impl.persistence.entity.GroupEntityManager; -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.springframework.dao.EmptyResultDataAccessException; - -import java.util.ArrayList; -import java.util.List; - -public class CustomGroupEntityManager extends GroupEntityManager { - - private UserService userService; - - public CustomGroupEntityManager(UserService userService) { - this.userService = userService; - } - - public GroupEntity findGroupById(final String id) { - if (id == null) { - return null; - } - try { - List sysRoles = userService.getUserRole(id); - return ActivitiUserUtil.toActivitiGroup(sysRoles.get(0)); - } catch (EmptyResultDataAccessException e) { - return null; - } - } - - @Override - public List findGroupsByUser(final String id) { - if (id == null) { - return null; - } - try { - List sysRoles = userService.getUserRole(id); - return ActivitiUserUtil.toActivitiGroups(sysRoles); - } catch (EmptyResultDataAccessException e) { - return new ArrayList<>(); - } - } - - @Override - public List findGroupByQueryCriteria(GroupQueryImpl query, Page page) { - throw new RuntimeException("not implement method."); - } - - @Override - public long findGroupCountByQueryCriteria(GroupQueryImpl query) { - throw new RuntimeException("not implement method."); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManagerFactory.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManagerFactory.java deleted file mode 100644 index d4f4758e9..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomGroupEntityManagerFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.impl.interceptor.Session; -import org.activiti.engine.impl.interceptor.SessionFactory; -import org.activiti.engine.impl.persistence.entity.GroupEntityManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Created by Administrator on 2016/3/19 0019. - */ -public class CustomGroupEntityManagerFactory implements SessionFactory { - - private CustomGroupEntityManager customGroupEntityManager; - - - public CustomGroupEntityManagerFactory(CustomGroupEntityManager customGroupEntityManager) { - this.customGroupEntityManager = customGroupEntityManager; - } - - @Override - public Class getSessionType() { - // 返回原始的GroupEntityManager类型 - return GroupEntityManager.class; - } - - @Override - public Session openSession() { - // 返回自定义的GroupEntityManager实例 - return customGroupEntityManager; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManager.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManager.java deleted file mode 100644 index c8b62ac7c..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.identity.Group; -import org.activiti.engine.impl.Page; -import org.activiti.engine.impl.UserQueryImpl; -import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity; -import org.activiti.engine.impl.persistence.entity.UserEntity; -import org.activiti.engine.impl.persistence.entity.UserEntityManager; -import org.hswebframework.web.entity.authorization.RoleEntity; -import org.hswebframework.web.service.authorization.UserService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.dao.EmptyResultDataAccessException; - -import java.util.Collections; -import java.util.List; - -public class CustomUserEntityManager extends UserEntityManager { - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - private UserService userService; - - public CustomUserEntityManager(UserService userService) { - this.userService = userService; - } - - @Override - public UserEntity findUserById(final String userId) { - if (userId == null) { - return null; - } - org.hswebframework.web.entity.authorization.UserEntity user = userService.selectByPk(userId); - return ActivitiUserUtil.toActivitiUser(user); - } - - @Override - public List findGroupsByUser(final String userId) { - if (userId == null) { - return new java.util.ArrayList<>(); - } - - List sysRoles = userService.getUserRole(userId); - return ActivitiUserUtil.toActivitiGroups(sysRoles); - - } - - @Override - public List findUserByQueryCriteria(UserQueryImpl query, Page page) { - throw new UnsupportedOperationException("not implement method.."); - } - - @Override - public IdentityInfoEntity findUserInfoByUserIdAndKey(String userId, - String key) { - throw new UnsupportedOperationException("not implement method."); - } - - @Override - public List findUserInfoKeysByUserIdAndType(String userId, - String type) { - throw new UnsupportedOperationException("not implement method."); - } - - @Override - public long findUserCountByQueryCriteria(UserQueryImpl query) { - throw new UnsupportedOperationException("not implement method."); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManagerFactory.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManagerFactory.java deleted file mode 100644 index 9d5462d56..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/CustomUserEntityManagerFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.impl.interceptor.Session; -import org.activiti.engine.impl.interceptor.SessionFactory; -import org.activiti.engine.impl.persistence.entity.UserIdentityManager; - -public class CustomUserEntityManagerFactory implements SessionFactory { - private CustomUserEntityManager customUserEntityManager; - - - public CustomUserEntityManagerFactory(CustomUserEntityManager customUserEntityManager) { - this.customUserEntityManager = customUserEntityManager; - } - - @Override - public Class getSessionType() { // 返回引擎的实体管理器接口 - return UserIdentityManager.class; - } - - @Override - public Session openSession() { - return customUserEntityManager; - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/JumpTaskCmd.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/JumpTaskCmd.java deleted file mode 100644 index 3cbde105a..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/utils/JumpTaskCmd.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.hswebframework.web.workflow.flowable.utils; - -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.impl.context.Context; -import org.activiti.engine.impl.interceptor.Command; -import org.activiti.engine.impl.interceptor.CommandContext; -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl; -import org.activiti.engine.task.Comment; - -import java.util.List; - -/** - * Created by Administrator on 2016/4/20 0020. - */ -public class JumpTaskCmd implements Command { - protected String executionId; - protected String activityId; - - - public JumpTaskCmd(String executionId, String activityId) { - this.executionId = executionId; - this.activityId = activityId; - } - - @Override - public Comment execute(CommandContext commandContext) { - - for (TaskEntity taskEntity : commandContext.getTaskEntityManager().findTasksByExecutionId(executionId)) { - commandContext.getTaskEntityManager().deleteTask(taskEntity, "jump", false); - } - ExecutionEntity executionEntity = Context.getCommandContext().getExecutionEntityManager().findExecutionById(executionId); - ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition(); - ActivityImpl activity = processDefinition.findActivity(activityId); - executionEntity.executeActivity(activity); - - return null; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/GlobalEventListenerDispatcher.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/GlobalEventListenerDispatcher.java deleted file mode 100644 index 9c64ab3e8..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/GlobalEventListenerDispatcher.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.hswebframework.web.workflow.listener; - -import org.activiti.engine.RuntimeService; -import org.activiti.engine.delegate.event.ActivitiEntityEvent; -import org.activiti.engine.delegate.event.ActivitiEvent; -import org.activiti.engine.delegate.event.ActivitiEventListener; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -import org.hswebframework.web.workflow.service.config.ActivityConfiguration; -import org.hswebframework.web.workflow.service.config.ProcessConfiguration; -import org.hswebframework.web.workflow.service.config.ProcessConfigurationService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -public class GlobalEventListenerDispatcher implements ActivitiEventListener { - - @Autowired - private ProcessConfigurationService processConfigurationService; - - @Autowired - @Lazy - private RuntimeService runtimeService; - - @Override - public void onEvent(ActivitiEvent event) { - String eventType = event.getType().name().toLowerCase(); - if (event instanceof ActivitiEntityEvent) { - ActivitiEntityEvent entityEvent = ((ActivitiEntityEvent) event); - - Object entity = entityEvent.getEntity(); - if (entity instanceof TaskEntity) { - //task事件 - TaskEntity task = ((TaskEntity) entity); - ActivityConfiguration activityConfiguration = processConfigurationService.getActivityConfiguration( - Authentication.current().map(Authentication::getUser) - .map(User::getId).orElse(null) - , event.getProcessDefinitionId() - , task.getTaskDefinitionKey() - ); - TaskEventListener listener = activityConfiguration.getTaskListener(eventType); - if (null != listener) { - listener.doEvent(new TaskEvent() { - @Override - public Task getTask() { - return task; - } - - @Override - public ProcessInstance getProcessInstance() { - return runtimeService - .createProcessInstanceQuery() - .processInstanceId(event.getProcessInstanceId()) - .singleResult(); - } - }); - } - } - } - if (eventType.startsWith("process")) { - ProcessConfiguration configuration = processConfigurationService.getProcessConfiguration(event.getProcessDefinitionId()); - ProcessEventListener listener = configuration.getProcessListener(eventType); - if (null != listener) { - listener.doEvent(() -> runtimeService - .createProcessInstanceQuery() - .processInstanceId(event.getProcessInstanceId()) - .singleResult()); - } - } - - - } - - @Override - public boolean isFailOnException() { - return false; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEvent.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEvent.java deleted file mode 100644 index 9cf26d7b3..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.workflow.listener; - -import org.activiti.engine.runtime.ProcessInstance; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessEvent { - - ProcessInstance getProcessInstance(); - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEventListener.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEventListener.java deleted file mode 100644 index 3d16c7489..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/ProcessEventListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.hswebframework.web.workflow.listener; - -/** - * - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessEventListener { - - void doEvent(ProcessEvent event); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEvent.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEvent.java deleted file mode 100644 index 8f3eebe43..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.hswebframework.web.workflow.listener; - -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface TaskEvent { - Task getTask(); - - ProcessInstance getProcessInstance(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEventListener.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEventListener.java deleted file mode 100644 index 5dea42128..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/listener/TaskEventListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.hswebframework.web.workflow.listener; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface TaskEventListener { - void doEvent(TaskEvent event); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ActivityConfigService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ActivityConfigService.java deleted file mode 100644 index bb04d2f94..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ActivityConfigService.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ActivityConfigService extends CrudService { - - ActivityConfigEntity selectByProcessDefineIdAndActivityId(String processDefineId, String activityId); - - ActivityConfigEntity selectByProcessDefineKeyAndActivityId(String processDefineKey, String activityId); - - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmActivityService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmActivityService.java deleted file mode 100644 index e50ff6662..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmActivityService.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.task.TaskDefinition; - -import java.util.List; -import java.util.Map; - -/** - * 流程节点操作的接口 - * - * @Author wangwei - * @Date 2017/8/4. - */ -public interface BpmActivityService { - /** - * 获取指定节点 - * - * @param procDefId 流程定义ID - * @return ActivityImpl 指定的节点资源,未指定返回第一节点 - */ - ActivityImpl getActivityById(String procDefId, String activityId); - - /** - * 获取所有节点 - * - * @param procDefKey 流程定义Key - * @param activityId 图元ID - * @return ActivityImpl 指定的节点,未指定返回所有 - */ - List getActivitiesByKey(String procDefKey, String activityId); - - /** - * 获取所有节点 - * - * @param procDefId 流程定义ID - * @param activityId 图元ID - * @return List 当前流程的所有节点资源 - */ - List getActivitiesById(String procDefId, String activityId); - - /** - * 获取所有userTask - * - * @param procDefId 流程定义ID - * @return List 当前流程的所有userTask资源 - */ - List getUserTasksByProcDefId(String procDefId); - - /** - * 获取所有userTask - * - * @param procDefKey 流程定义ID - * @return List 当前流程的所有userTask资源 - */ - List getUserTasksByProcDefKey(String procDefKey); - - /** - * 获取下一环节 - * - * @param procDefId 流程定义ID - * @param activityId 图元ID - * @return List 当前流程的所有下一环节资源 - */ - List getNextActivities(String procDefId, String activityId,DelegateExecution execution); - - - /** - * 根据图元获取办理环节数据 - * - * @param activityImpl - * @param execution 根据连线条件conditionText获取输出节点,主要用于网关分支(预留) - * @return - */ - List getTaskDefinition(ActivityImpl activityImpl,DelegateExecution execution); - - /** - * 获取开始节点 - * - * @param procDefId 流程定义ID - * @return ActivityImpl 当前流程的结束资源 - */ - ActivityImpl getStartEvent(String procDefId); - - /** - * 获取结束节点 - * - * @param procDefId 流程定义ID - * @return ActivityImpl 当前流程的结束资源 - */ - ActivityImpl getEndEvent(String procDefId); - - /*** - * 获取当前执行节点 - * @param procDefId 流程定义ID - * @param procInstId 流程实例ID - * @return - */ - ActivityImpl getActivityByProcInstId(String procDefId, String procInstId); - - /** - * 根据节点获取下一步执行节点集合 - * - * @param activity - * @return - */ - List getNextEvent(ActivityImpl activity); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmProcessService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmProcessService.java deleted file mode 100644 index ded1360f9..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmProcessService.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Job; -import org.activiti.engine.runtime.ProcessInstance; -import org.hswebframework.web.workflow.service.request.StartProcessRequest; - -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -/** - * 流程实例操作相关接口 - * @Author wangwei - * @Date 2017/8/4. - */ -public interface BpmProcessService{ - - /** - * 获取所有可以启动的流程 - * @return - */ - List getAllProcessDefinition(); - - /** - * 启动一个流程,并初始化自定义主表单数据 - * - * @return 启动后的流程实例 - */ - ProcessInstance startProcessInstance(StartProcessRequest request); - - /** - * 流程实例挂起 - * @param procInstId 流程实例ID - */ - void closeProcessInstance(String procInstId); - - /** - * 流程实例激活 - * @param procInstId 流程实例ID - */ - void openProcessInstance(String procInstId); - - /** - * 根据流程定义id获取流程定义实例
- * 此方法使用了缓存,返回的{@link org.activiti.engine.repository.ProcessDefinition}实例不为activity默认的实例,而是{@link ProcessDefinitionCache},以保证缓存时正常序列化 - * - * @param procDefId 流程定义id - * @return 流程定义实例 - * @throws Exception 异常信息 - */ - ProcessDefinition getProcessDefinitionById(String procDefId); - - /** - * 根据流程定义id获取流程定义实例
- * 此方法使用了缓存,返回的{@link org.activiti.engine.repository.ProcessDefinition}实例不为activity默认的实例,而是{@link ProcessDefinitionCache},以保证缓存时正常序列化 - * - * @param procDefKey 流程定义id - * @return 流程定义实例 - * @throws Exception 异常信息 - */ - ProcessDefinition getProcessDefinitionByKey(String procDefKey); - - /*** - * 获取job事件 - * @param procInstId 执行ID - */ - Job getJob(String procInstId); - - /*** - * 强制删除job任务,该方法无 api 接口 - * @param jobId - */ - int deleteJob(String jobId); - - /*** - * 查看流程图 - * @param procDefId 流程定义id - * @return - */ - InputStream findProcessPic(String procDefId); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmTaskService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmTaskService.java deleted file mode 100644 index cb71de93b..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/BpmTaskService.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.task.Task; -import org.hswebframework.web.workflow.service.request.CompleteTaskRequest; -import org.hswebframework.web.workflow.service.request.JumpTaskRequest; -import org.hswebframework.web.workflow.service.request.RejectTaskRequest; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 流程任务操作相关接口 - * - * @Author wangwei - * @Date 2017/8/4. - */ -public interface BpmTaskService { - - List selectNowTask(String procInstId); - - List selectTaskByProcessId(String procInstId); - - Task selectTaskByTaskId(String taskId); - - HistoricProcessInstance selectHisProInst(String procInstId); - - /** - * 设置任务办理的候选人 - * - * @param doingUserId 当前操作人 - * @param task 任务 - */ - void setCandidate(String doingUserId, Task task); - - /** - * 获取环节变量 - * - * @param taskId - * @return - */ - Map selectVariableLocalByTaskId(String taskId); - - /** - * 获取环节变量 - * - * @param taskId - * @param variableName - * @return - */ - Object selectVariableLocalByTaskId(String taskId, String variableName); - - /** - * 根据taskId获取流程图对应的图元 - * - * @param taskId - * @return - */ - ActivityImpl selectActivityImplByTask(String taskId); - - /** - * 领取(签收)任务 - * - * @param taskId 任务id - * @param userId 用户id - * @throws Exception 异常信息 - */ - void claim(String taskId, String userId); - - - /** - * 完成任务 - * - * @param request 完成任务请求 - */ - void complete(CompleteTaskRequest request); - - /** - * 流程任意跳转 - */ - void jumpTask(JumpTaskRequest request); - - /** - * 驳回任务 - */ - void reject(RejectTaskRequest request); - - /** - * 结束流程 - * - * @param procInstId 流程实例ID - */ - void endProcess(String procInstId); - - /** - * 删除历史环节信息 - * - * @param taskId 环节ID - */ - void removeHiTask(String taskId); - - /** - * 获取所有任务节点 - * - * @param procDefKey 流程定义Key,该参数获取最新流程 - */ - Map getUserTasksByProcDefKey(String procDefKey); - - /** - * 获取所有任务节点 - * - * @param procInstId 流程实例ID,该参数获取当前流程实例对应流程 - */ - Map getUserTasksByProcInstId(String procInstId); - - /** - * 设置流程变量 - * - * @param taskId 当前环节ID - * @param map key-value - */ - void setVariables(String taskId, Map map); - - /** - * 删除流程变量 - * - * @param taskId 当前环节ID - * @param var2 需要删除的 key - */ - void removeVariables(String taskId, Collection var2); - - /** - * 设置任务变量 - * - * @param taskId 当前环节ID - */ - void setVariablesLocal(String taskId, Map map); - - /*** - * 获取流程变量 - * @param procInstId 流程实例ID - */ - Map getVariablesByProcInstId(String procInstId); - - /** - * 获取流程变量 - * - * @param taskId - * @return - */ - Map getVariablesByTaskId(String taskId); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessDefineConfigService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessDefineConfigService.java deleted file mode 100644 index c994ef9b8..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessDefineConfigService.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessDefineConfigService extends CrudService { - - ProcessDefineConfigEntity selectByProcessDefineId(String processDefineId); - - ProcessDefineConfigEntity selectByLatestProcessDefineKey(String processDefineKey); - - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessHistoryService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessHistoryService.java deleted file mode 100644 index f58890153..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/ProcessHistoryService.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.workflow.dao.entity.ProcessHistoryEntity; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessHistoryService extends CrudService { - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/WorkFlowFormService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/WorkFlowFormService.java deleted file mode 100644 index c077d6fed..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/WorkFlowFormService.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.hswebframework.web.workflow.service; - -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.workflow.service.request.SaveFormRequest; - -import java.util.List; - - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface WorkFlowFormService { - void saveProcessForm(ProcessInstance instance, SaveFormRequest request); - - void saveTaskForm(ProcessInstance instance,Task task, SaveFormRequest request); - - PagerResult selectProcessForm(String processDefineId, QueryParamEntity queryParam); - - PagerResult selectTaskForm(String processDefineId, String activityId, QueryParamEntity queryParam); - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ActivityConfiguration.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ActivityConfiguration.java deleted file mode 100644 index b6d22128f..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ActivityConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.workflow.service.config; - -import org.activiti.engine.task.Task; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.workflow.listener.TaskEventListener; - -import java.util.List; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ActivityConfiguration { - /** - * 此任务需要提交的表单,如果返回值不为空,则说明此任务在完成的时候,需要一起提交表单数据 - * - * @return 表单ID, 如果未设置返回null - * @see org.hswebframework.web.service.form.DynamicFormOperationService - * @see org.hswebframework.web.service.form.DynamicFormService - */ - String getFormId(); - - /** - * 判断用户是否可以签收此任务 - * - * @param userId 用户ID {@link User#getId()} - * @return 是否可以签收 - * @see User - * @see org.hswebframework.web.authorization.Authentication - */ - boolean canClaim(Task task, String userId); - - /** - * 获取此任务的所有候选人信息 - * - * @return 此任务的所有候选人信息 {@link CandidateInfo} - */ - List getCandidateInfo(Task task); - - TaskEventListener getTaskListener(String eventType); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/CandidateInfo.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/CandidateInfo.java deleted file mode 100644 index ac1f111d0..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/CandidateInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.hswebframework.web.workflow.service.config; - -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; - -/** - * 候选人信息 - */ -public interface CandidateInfo { - /** - * 候选人的用户授权信息 - * - * @see Authentication - */ - Authentication user(); - - /** - * 候选人的组织架构人员信息 - * - * @see PersonnelAuthentication - */ - PersonnelAuthentication person(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfiguration.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfiguration.java deleted file mode 100644 index e86e66b0e..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfiguration.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.workflow.service.config; - - -import org.activiti.engine.repository.ProcessDefinition; -import org.hswebframework.web.workflow.listener.ProcessEventListener; - -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -public interface ProcessConfiguration { - String getFormId(); - - void assertCanStartProcess(String userId, ProcessDefinition definition); - - boolean canStartProcess(String userId, ProcessDefinition definition); - - ProcessEventListener getProcessListener(String eventType); - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfigurationService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfigurationService.java deleted file mode 100644 index f8ecf0924..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/config/ProcessConfigurationService.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.workflow.service.config; - - -public interface ProcessConfigurationService { - - ActivityConfiguration getActivityConfiguration(String doingUser, String processDefineId, String activityId); - - ProcessConfiguration getProcessConfiguration(String processDefineId); - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/AbstractFlowableService.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/AbstractFlowableService.java deleted file mode 100644 index 258611509..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/AbstractFlowableService.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.activiti.engine.*; - -import javax.annotation.Resource; - -/** - * @author wangwei - * @author zhouhao - */ -public abstract class AbstractFlowableService { - @Resource - protected ProcessEngine processEngine; - @Resource - protected RepositoryService repositoryService; - @Resource - protected RuntimeService runtimeService; - @Resource - protected TaskService taskService; - @Resource - protected HistoryService historyService; - @Resource - protected IdentityService identityService; - @Resource - protected ManagementService managementService; - @Resource - protected FormService bpmFormService; -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ActivityConfigServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ActivityConfigServiceImpl.java deleted file mode 100644 index b93c04407..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ActivityConfigServiceImpl.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.workflow.dao.ActivityConfigDao; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; -import org.hswebframework.web.workflow.service.ActivityConfigService; -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.cache.annotation.Caching; -import org.springframework.stereotype.Service; - -import java.util.Date; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Service -@CacheConfig(cacheNames = "process-activity-config") -public class ActivityConfigServiceImpl extends GenericEntityService - implements ActivityConfigService { - - @Autowired - private ActivityConfigDao activityConfigDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return activityConfigDao; - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId+'-'+#entity.activityId"), - @CacheEvict(key = "'define-key:'+#entity.processDefineKey+'-'+#entity.activityId") - }) - public String insert(ActivityConfigEntity entity) { - entity.setCreateTime(new Date()); - entity.setUpdateTime(new Date()); - entity.setStatus(DataStatus.STATUS_ENABLED); - return super.insert(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId+'-'+#entity.activityId"), - @CacheEvict(key = "'define-key:'+#entity.processDefineKey+'-'+#entity.activityId") - }) - public int updateByPk(String pk, ActivityConfigEntity entity) { - entity.setUpdateTime(new Date()); - return super.updateByPk(pk, entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId+'-'+#entity.activityId"), - @CacheEvict(key = "'define-key:'+#entity.processDefineKey+'-'+#entity.activityId") - }) - protected int updateByPk(ActivityConfigEntity entity) { - return super.updateByPk(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId+'-'+#entity.activityId"), - @CacheEvict(key = "'define-key:'+#entity.processDefineKey+'-'+#entity.activityId") - }) - public String saveOrUpdate(ActivityConfigEntity entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#result.processDefineId+'-'+#result.activityId", condition = "#result!=null"), - @CacheEvict(key = "'define-key:'+#result.processDefineKey+'-'+#result.activityId", condition = "#result!=null") - }) - public ActivityConfigEntity deleteByPk(String id) { - return super.deleteByPk(id); - } - - @Override - @Cacheable(key = "'define-id:'+#processDefineId+'-'+#activityId") - public ActivityConfigEntity selectByProcessDefineIdAndActivityId(String processDefineId, String activityId) { - return createQuery() - .where("processDefineId", processDefineId) - .and("activityId", activityId) - .single(); - } - - @Override - @Cacheable(key = "'define-key:'+#processDefineKey+'-'+#activityId") - public ActivityConfigEntity selectByProcessDefineKeyAndActivityId(String processDefineKey, String activityId) { - return createQuery() - .where("processDefineKey", processDefineKey) - .and("activityId", activityId) - .single(); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmActivityServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmActivityServiceImpl.java deleted file mode 100644 index 76ac16b10..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmActivityServiceImpl.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.activiti.engine.ProcessEngine; -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.Expression; -import org.activiti.engine.delegate.VariableScope; -import org.activiti.engine.impl.Condition; -import org.activiti.engine.impl.RepositoryServiceImpl; -import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.activiti.engine.impl.bpmn.parser.BpmnParse; -import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.activiti.engine.impl.context.Context; -import org.activiti.engine.impl.delegate.ExpressionGetInvocation; -import org.activiti.engine.impl.el.ExpressionManager; -import org.activiti.engine.impl.javax.el.ELContext; -import org.activiti.engine.impl.juel.ExpressionFactoryImpl; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmActivity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.pvm.process.ProcessElementImpl; -import org.activiti.engine.impl.task.TaskDefinition; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Execution; -import org.activiti.engine.runtime.ProcessInstance; -import org.hswebframework.web.workflow.service.BpmActivityService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * @Author wangwei - * @Date 2017/8/7. - */ -@Service -public class BpmActivityServiceImpl extends AbstractFlowableService implements BpmActivityService { - - @Autowired - private ProcessEngine processEngine; - - /** - * 获取指定节点 - * - * @param procDefId 流程定义ID - * @return ActivityImpl 指定的节点资源 - */ - @Override - public ActivityImpl getActivityById(String procDefId, String activityId) { - return getProcessDefinition(procDefId).findActivity(activityId); - } - - @Override - public List getActivitiesByKey(String procDefKey, String activityId) { - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .processDefinitionKey(procDefKey) - .orderByProcessDefinitionVersion() - .desc() - .singleResult(); - - return getActivitiesById(definition.getId(), activityId); - } - - @Override - public List getActivitiesById(String processDefId, String activityId) { - ProcessDefinitionEntity pde = getProcessDefinition(processDefId); - if (activityId == null) { - return pde.getActivities(); - } else { - ActivityImpl activity = pde.findActivity(activityId); - if (null == activity) { - return new java.util.ArrayList<>(); - } - return Collections.singletonList(activity); - } - } - - /** - * 获取所有userTask - * - * @param procDefId 流程定义ID - * @return List 当前流程的所有userTask资源 - */ - @Override - public List getUserTasksByProcDefId(String procDefId) { - - return findActivities(procDefId, activity -> "userTask".equals(activity.getProperty("type"))); - - } - - @Override - public List getUserTasksByProcDefKey(String procDefKey) { - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(procDefKey).orderByProcessDefinitionVersion().desc().list().get(0); - String procDefId = definition.getId(); - List activities = findActivities(procDefId, activity -> "userTask".equals(activity.getProperty("type"))); -// - if (null != activities) { - activities.sort(Comparator.comparing(ProcessElementImpl::getId)); - } - return activities; - } - - @Override - public List getNextActivities(String procDefId, String activityId, DelegateExecution execution) { - ActivityImpl activity; - if (activityId != null) { - activity = getActivityById(procDefId, activityId); - } else { - activity = getStartEvent(procDefId); - } - - List pvmTransitions = activity.getOutgoingTransitions(); - - return pvmTransitions.stream() - .map(PvmTransition::getDestination) - .map(ActivityImpl.class::cast) //强转为ActivityImpl - .filter(Objects::nonNull) - .map(act -> getTaskDefinition(act, execution)) //获取TaskDefinition集合 - .flatMap(Collection::stream) //合并集合 - .collect(Collectors.toList()); - - } - - @Override - public List getTaskDefinition(ActivityImpl activityImpl, DelegateExecution execution) { - Set taskDefinitionList = new HashSet<>(); - List nextTaskDefinition; - if ("userTask".equals(activityImpl.getProperty("type"))) { - TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activityImpl.getActivityBehavior()).getTaskDefinition(); - taskDefinitionList.add(taskDefinition); - } else { - List pvmTransitions = activityImpl.getOutgoingTransitions(); - List outTransitionsTemp; - for (PvmTransition tr : pvmTransitions) { - PvmActivity pvmActivity = tr.getSource(); //获取线路的终点节点 - - boolean exclusiveGateway = "exclusiveGateway".equals(pvmActivity.getProperty("type")); - boolean parallelGateway = "parallelGateway".equals(pvmActivity.getProperty("type")); - - if (exclusiveGateway || parallelGateway) { - outTransitionsTemp = pvmActivity.getOutgoingTransitions(); - if (outTransitionsTemp.size() == 1) { - nextTaskDefinition = getTaskDefinition((ActivityImpl) outTransitionsTemp.get(0).getDestination(), execution); - taskDefinitionList.addAll(nextTaskDefinition); - } else if (outTransitionsTemp.size() > 1) { - for (PvmTransition transition : outTransitionsTemp) { - String condition = (String) transition.getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT); - if (StringUtils.isEmpty(condition)) { - nextTaskDefinition = getTaskDefinition((ActivityImpl) transition.getDestination(), execution); - if (exclusiveGateway) { - if (!CollectionUtils.isEmpty(nextTaskDefinition)) { - taskDefinitionList.add(nextTaskDefinition.get(0)); - } - } else { - taskDefinitionList.addAll(nextTaskDefinition); - } - continue; - } - ExpressionManager expressionManager = ((ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration()).getExpressionManager(); - - ELContext elContext = expressionManager.getElContext(execution); - - ExpressionFactoryImpl factory = new ExpressionFactoryImpl(); - - Object e = factory.createValueExpression(elContext, condition, Object.class).getValue(elContext); - - if (Boolean.TRUE.equals(e)) { - nextTaskDefinition = getTaskDefinition((ActivityImpl) transition.getDestination(), execution); - taskDefinitionList.addAll(nextTaskDefinition); - } - } - } - } else if ("userTask".equals(pvmActivity.getProperty("type"))) { - taskDefinitionList.add(((UserTaskActivityBehavior) ((ActivityImpl) pvmActivity).getActivityBehavior()).getTaskDefinition()); - } - } - } - return new ArrayList<>(taskDefinitionList); - } - - @Override - public ActivityImpl getStartEvent(String procDefId) { - return findActivity(procDefId, activity -> "startEvent".equals(activity.getProperty("type"))); - } - - private List findActivities(String procDefId, Predicate predicate) { - ProcessDefinitionEntity pde = getProcessDefinition(procDefId); - if (pde == null) { - return new ArrayList<>(); - } - return pde.getActivities() - .stream() - .filter(predicate) - .collect(Collectors.toList()); - } - - private ActivityImpl findActivity(String procDefId, Predicate predicate) { - ProcessDefinitionEntity pde = getProcessDefinition(procDefId); - if (pde == null) { - return null; - } - return pde.getActivities() - .stream() - .filter(predicate) - .findFirst() - .orElse(null); - } - - @Override - public ActivityImpl getEndEvent(String procDefId) { - return findActivity(procDefId, activity -> "endEvent".equals(activity.getProperty("type"))); - } - - /** - * 获取流程定义 - * - * @param procDefId 流程定义ID - * @return 流程定义资源 - */ - public ProcessDefinitionEntity getProcessDefinition(String procDefId) { - return (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId); - } - - @Override - public ActivityImpl getActivityByProcInstId(String procDefId, String procInstId) { - ProcessInstance processInstance = runtimeService - .createProcessInstanceQuery() - .processInstanceId(procInstId) - .active() - .singleResult(); - String activityId = processInstance.getActivityId(); - - return getProcessDefinition(procDefId).findActivity(activityId); - } - - @Override - public List getNextEvent(ActivityImpl activity) { - - return activity.getOutgoingTransitions() - .stream() - .map(PvmTransition::getDestination) - .map(ActivityImpl.class::cast) - .collect(Collectors.toList()); - -// List activities = new ArrayList<>(); -// List pvmTransitions = activity.getOutgoingTransitions(); -// for (PvmTransition pvmTransition : pvmTransitions) { -// activities.add((ActivityImpl) pvmTransition.getDestination()); -// } -// return activities; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmProcessServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmProcessServiceImpl.java deleted file mode 100644 index 05b0e9c6f..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmProcessServiceImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Job; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.workflow.dao.entity.ProcessHistoryEntity; -import org.hswebframework.web.workflow.service.BpmProcessService; -import org.hswebframework.web.workflow.service.BpmTaskService; -import org.hswebframework.web.workflow.service.ProcessHistoryService; -import org.hswebframework.web.workflow.service.WorkFlowFormService; -import org.hswebframework.web.workflow.service.request.SaveFormRequest; -import org.hswebframework.web.workflow.service.request.StartProcessRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.io.InputStream; -import java.util.List; -import java.util.function.Consumer; - -/** - * @Author wangwei - * @Date 2017/8/7. - */ -@Service -@Transactional(rollbackFor = Throwable.class) -public class BpmProcessServiceImpl extends AbstractFlowableService implements BpmProcessService { - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private BpmTaskService bpmTaskService; - - @Autowired - private WorkFlowFormService workFlowFormService; - - @Autowired - private ProcessHistoryService processHistoryService; - - @Override - public List getAllProcessDefinition() { - return repositoryService.createProcessDefinitionQuery().latestVersion().active().list(); - } - - @Override - public ProcessInstance startProcessInstance(StartProcessRequest request) { - request.tryValidate(); - ProcessInstance processInstance; - logger.debug("start workflow :{}", request); - try { - identityService.setAuthenticatedUserId(request.getCreatorId()); - - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(request.getProcessDefineId()) - .singleResult(); - if (definition == null) { - throw new NotFoundException("流程[" + request.getProcessDefineId() + "]不存在"); - } - - //创建业务ID - String businessKey = IDGenerator.MD5.generate(); - - //启动流程 - processInstance = runtimeService.startProcessInstanceById( - request.getProcessDefineId() - , businessKey - , request.getVariables()); - - //候选人设置 - Consumer candidateUserSetter = (task) -> { - if (task == null) { - return; - } - //指定了下一环节的办理人 - if (!StringUtils.isNullOrEmpty(request.getNextClaimUserId())) { - taskService.addCandidateUser(task.getId(), request.getNextClaimUserId()); - } else { - bpmTaskService.setCandidate(request.getCreatorId(), task); - } - }; - - List tasks = bpmTaskService.selectTaskByProcessId(processInstance.getProcessDefinitionId()); - - //当前节点 - String activityId = processInstance.getActivityId(); - if (activityId == null) { - //所有task设置候选人 - tasks.forEach(candidateUserSetter); - } else { - candidateUserSetter.accept(taskService - .createTaskQuery() - .processInstanceId(processInstance.getProcessInstanceId()) - .taskDefinitionKey(activityId) - .active() - .singleResult()); - } - - workFlowFormService.saveProcessForm(processInstance, SaveFormRequest - .builder() - .userId(request.getCreatorId()) - .userName(request.getCreatorName()) - .formData(request.getFormData()) - .build()); - - ProcessHistoryEntity history = ProcessHistoryEntity.builder() - .type("start") - .typeText("启动流程") - .businessKey(businessKey) - .creatorId(request.getCreatorId()) - .creatorName(request.getCreatorName()) - .processInstanceId(processInstance.getProcessInstanceId()) - .processDefineId(processInstance.getProcessDefinitionId()) - .build(); - - processHistoryService.insert(history); - - - } finally { - identityService.setAuthenticatedUserId(null); - } - return processInstance; - } - - @Override - public void closeProcessInstance(String processInstanceId) { - runtimeService.suspendProcessInstanceById(processInstanceId); - } - - @Override - public void openProcessInstance(String processInstanceId) { - runtimeService.activateProcessInstanceById(processInstanceId); - } - - @Override - public ProcessDefinition getProcessDefinitionById(String processDefinitionId) { - return repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult(); - } - - @Override - public ProcessDefinition getProcessDefinitionByKey(String procDefKey) { - return repositoryService.createProcessDefinitionQuery().processDefinitionKey(procDefKey).orderByProcessDefinitionVersion().desc().list().get(0); - } - - @Override - public InputStream findProcessPic(String procDefId) { - ProcessDefinition definition = getProcessDefinitionById(procDefId); - String source = definition.getDiagramResourceName(); - return repositoryService.getResourceAsStream(definition.getDeploymentId(), source); - } - - @Override - public Job getJob(String processInstanceId) { - return managementService.createJobQuery().processInstanceId(processInstanceId).singleResult(); - } - - @Override - public int deleteJob(String jobId) { - return 0; - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmTaskServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmTaskServiceImpl.java deleted file mode 100644 index 1dfeaf8c6..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/BpmTaskServiceImpl.java +++ /dev/null @@ -1,533 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import lombok.SneakyThrows; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.history.HistoricTaskInstance; -import org.activiti.engine.history.HistoricVariableInstance; -import org.activiti.engine.impl.RepositoryServiceImpl; -import org.activiti.engine.impl.TaskServiceImpl; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmActivity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.delegate.ActivityExecution; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.pvm.process.TransitionImpl; -import org.activiti.engine.runtime.Execution; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.Maps; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.workflow.dao.entity.ProcessHistoryEntity; -import org.hswebframework.web.workflow.service.ProcessHistoryService; -import org.hswebframework.web.workflow.service.config.ProcessConfigurationService; -import org.hswebframework.web.workflow.service.BpmActivityService; -import org.hswebframework.web.workflow.service.BpmTaskService; -import org.hswebframework.web.workflow.flowable.utils.JumpTaskCmd; -import org.hswebframework.web.workflow.service.WorkFlowFormService; -import org.hswebframework.web.workflow.service.config.CandidateInfo; -import org.hswebframework.web.workflow.service.request.CompleteTaskRequest; -import org.hswebframework.web.workflow.service.request.JumpTaskRequest; -import org.hswebframework.web.workflow.service.request.RejectTaskRequest; -import org.hswebframework.web.workflow.service.request.SaveFormRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; - -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.stream.Collectors; - - -/** - * @author wangwei - * @author zhouhao - */ -@Service -@Transactional(rollbackFor = Throwable.class) -public class BpmTaskServiceImpl extends AbstractFlowableService implements BpmTaskService { - - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private BpmActivityService bpmActivityService; - - @Autowired - private ProcessConfigurationService processConfigurationService; - - @Autowired - private WorkFlowFormService workFlowFormService; - - @Autowired - private ProcessHistoryService processHistoryService; - - @Autowired - private SqlExecutor sqlExecutor; - - @Override - public List selectNowTask(String procInstId) { - return taskService.createTaskQuery() - .processInstanceId(procInstId) - .active() - .list(); - } - - @Override - public List selectTaskByProcessId(String procInstId) { - return taskService - .createTaskQuery() - .processInstanceId(procInstId) - .active() - .list(); - } - - @Override - public Task selectTaskByTaskId(String taskId) { - return taskService - .createTaskQuery() - .taskId(taskId) - .active() - .singleResult(); - } - - @Override - public void claim(String taskId, String userId) { - Task task = taskService.createTaskQuery(). - taskId(taskId) - .taskCandidateUser(userId) - .active() - .singleResult(); - if (task == null) { - throw new NotFoundException("无法签收此任务"); - } - if (!StringUtils.isNullOrEmpty(task.getAssignee())) { - throw new BusinessException("任务已签售"); - } else { - taskService.claim(taskId, userId); - } - } - - @Override - public void complete(CompleteTaskRequest request) { - request.tryValidate(); - - Task task = taskService.createTaskQuery() - .taskId(request.getTaskId()) - .includeProcessVariables() - .active() - .singleResult(); - - Objects.requireNonNull(task, "任务不存在"); - String assignee = task.getAssignee(); - Objects.requireNonNull(assignee, "任务未签收"); - if (!assignee.equals(request.getCompleteUserId())) { - throw new BusinessException("只能完成自己的任务"); - } - Map variable = new HashMap<>(); - variable.put("preTaskId", task.getId()); - Map transientVariables = new HashMap<>(); - - if (null != request.getVariables()) { - variable.putAll(request.getVariables()); - transientVariables.putAll(request.getVariables()); - } - - ProcessInstance instance = runtimeService.createProcessInstanceQuery() - .processInstanceId(task.getProcessInstanceId()) - .singleResult(); - - //查询主表的数据作为变量 - Optional.of(workFlowFormService.>selectProcessForm(instance.getProcessDefinitionId(), - QueryParamEntity.of("processInstanceId", instance.getProcessInstanceId()).doPaging(0, 2))) - .map(PagerResult::getData) - .map(list -> { - if (list.size() == 1) { - return list.get(0); - } - if (list.size() > 1) { - logger.warn("主表数据存在多条数据:processInstanceId={}", instance.getProcessInstanceId()); - } - return null; - }) - .ifPresent(transientVariables::putAll); - - - //保存表单数据 - workFlowFormService.saveTaskForm(instance, task, SaveFormRequest.builder() - .userName(request.getCompleteUserName()) - .userId(request.getCompleteUserId()) - .formData(request.getFormData()) - .build()); - - if (null != request.getFormData()) { - transientVariables.putAll(request.getFormData()); - } - - taskService.complete(task.getId(), null, transientVariables); - - //跳转 - if (!StringUtils.isNullOrEmpty(request.getNextActivityId())) { - doJumpTask(task, request.getNextActivityId(), (t) -> { - }); - } - - //下一步候选人 - List tasks = selectNowTask(task.getProcessInstanceId()); - for (Task next : tasks) { - setVariablesLocal(next.getId(), variable); - if (!StringUtils.isNullOrEmpty(request.getNextClaimUserId())) { - taskService.addCandidateUser(next.getId(), request.getNextClaimUserId()); - } else { - setCandidate(request.getCompleteUserId(), next); - } - } - - ProcessHistoryEntity history = ProcessHistoryEntity.builder() - .businessKey(instance.getBusinessKey()) - .type("complete") - .typeText("完成任务") - .creatorId(request.getCompleteUserId()) - .creatorName(request.getCompleteUserName()) - .processDefineId(instance.getProcessDefinitionId()) - .processInstanceId(instance.getProcessInstanceId()) - .taskId(task.getId()) - .taskDefineKey(task.getTaskDefinitionKey()) - .taskName(task.getName()) - .build(); - - processHistoryService.insert(history); - } - - @Override - @SneakyThrows - public void reject(RejectTaskRequest request) { - request.tryValidate(); - String taskId = request.getTaskId(); - Task curTask = selectTaskByTaskId(taskId); - if (curTask == null) { - throw new NotFoundException("任务不存在或未激活"); - } - ProcessInstance processInstance = runtimeService - .createProcessInstanceQuery() - .processInstanceId(curTask.getProcessInstanceId()) - .singleResult(); - - ProcessDefinitionEntity entity = (ProcessDefinitionEntity) - ((RepositoryServiceImpl) repositoryService) - .getDeployedProcessDefinition(curTask.getProcessDefinitionId()); - - ActivityImpl currActivity = entity.findActivity(curTask.getTaskDefinitionKey()); - - List transitions = new ArrayList<>(); - //查找上一个环节 - findActivity(currActivity, - activity -> - activity.getIncomingTransitions() - .stream() - .map(PvmTransition::getSource) - .collect(Collectors.toList()), - activity -> transitions.isEmpty() && "userTask".equals(activity.getProperty("type")), - transitions::add); - - if (!transitions.isEmpty()) { - //跳转到上一环节 - PvmActivity transition = transitions.get(transitions.size() - 1); - doJumpTask(curTask, transition.getId(), newTask -> { - }); - } else { - throw new BusinessException("无法获取上一步任务"); - } - - //记录日志 - ProcessHistoryEntity history = ProcessHistoryEntity.builder() - .businessKey(processInstance.getBusinessKey()) - .type("reject") - .typeText("驳回") - .creatorId(request.getRejectUserId()) - .creatorName(request.getRejectUserName()) - .processDefineId(processInstance.getProcessDefinitionId()) - .processInstanceId(processInstance.getProcessInstanceId()) - .taskId(taskId) - .taskDefineKey(curTask.getTaskDefinitionKey()) - .taskName(curTask.getName()) - .data(request.getData()) - .build(); - - processHistoryService.insert(history); - } - - protected void findActivity( - PvmActivity activity, - Function> function, - Predicate predicate, - Consumer consumer) { - - List activities = function.apply(activity); - for (PvmActivity pvmActivity : activities) { - consumer.accept(pvmActivity); - if (predicate.test(pvmActivity)) { - return; - } - //往下查找 - findActivity(pvmActivity, function, predicate, consumer); - } - } - - @SneakyThrows - public void doJumpTask(Task task, String activityId, Consumer newTaskConsumer) { - - ProcessDefinitionEntity entity = (ProcessDefinitionEntity) - ((RepositoryServiceImpl) repositoryService) - .getDeployedProcessDefinition(task.getProcessDefinitionId()); - - String sourceId = task.getTaskDefinitionKey(); - - ActivityImpl targetActivity = entity.findActivity(activityId); - ActivityImpl sourceActivity = entity.findActivity(sourceId); - - if (logger.isDebugEnabled()) { - logger.debug("流程[{}({})]跳转[{}]->[{}]", - entity.getName(), - entity.getId(), - sourceActivity.getId(), - targetActivity.getId()); - } - - //回退的节点 - List backActivities = new ArrayList<>(); - //如果目标节点的Outgoing中有源节点,说明是回退需要删除对应的连线 - findActivity(targetActivity, - activity -> activity - .getOutgoingTransitions() - .stream() - .map(PvmTransition::getDestination) - .collect(Collectors.toList()), - activity -> sourceActivity.getId().equals(activity.getId()), - backActivities::add); - - //回退 - if (!backActivities.isEmpty()) { - for (PvmActivity pvmTransition : backActivities) { - if (logger.isDebugEnabled()) { - logger.debug("流程[{}({})]回退[{}]->[{}],删除链接线:{}", - entity.getName(), - entity.getId(), - sourceActivity.getId(), - targetActivity.getId(), - pvmTransition.getId()); - } - //删除连线 - List instance = historyService - .createHistoricActivityInstanceQuery() - .processInstanceId(task.getProcessInstanceId()) - .activityId(pvmTransition.getId()) - .list(); - for (HistoricActivityInstance historicActivityInstance : instance) { - sqlExecutor.delete("delete from act_hi_actinst where id_= #{id}", historicActivityInstance); - } - } - } - //执行回退命令 - TaskServiceImpl taskServiceImpl = (TaskServiceImpl) taskService; - taskServiceImpl.getCommandExecutor().execute(new JumpTaskCmd(task.getExecutionId(), activityId)); - //设置候选人并回调 - selectNowTask(task.getProcessInstanceId()) - .forEach(t -> { - //设置候选人 - setCandidate(task.getAssignee(), t); - newTaskConsumer.accept(t); - }); - - } - - @Override - public void jumpTask(JumpTaskRequest request) { - request.tryValidate(); - - Task task = taskService.createTaskQuery() - .taskId(request.getTaskId()) - .singleResult(); - - //记录跳转后的节点到日志 - List> targetTask = new ArrayList<>(); - - doJumpTask(task, request.getTargetActivityId(), t -> { - Map target = new HashMap<>(); - target.put("taskId", t.getId()); - target.put("taskName", t.getName()); - target.put("activityId", t.getTaskDefinitionKey()); - targetTask.add(target); - }); - - if (request.isRecordLog()) { - - ProcessInstance processInstance = runtimeService - .createProcessInstanceQuery() - .processInstanceId(task.getProcessInstanceId()) - .singleResult(); - - Map data = new HashMap<>(); - data.put("targetTask", targetTask); - if (request.getData() != null) { - data.putAll(request.getData()); - } - - ProcessHistoryEntity history = ProcessHistoryEntity.builder() - .businessKey(processInstance.getBusinessKey()) - .type("jump") - .typeText("流程跳转") - .creatorId(request.getJumpUserId()) - .creatorName(request.getJumpUserName()) - .processDefineId(processInstance.getProcessDefinitionId()) - .processInstanceId(processInstance.getProcessInstanceId()) - .taskId(task.getId()) - .taskDefineKey(task.getTaskDefinitionKey()) - .taskName(task.getName()) - .data(data) - .build(); - - processHistoryService.insert(history); - } - } - - @Override - public void endProcess(String procInstId) { -// ProcessInstance processInstance = runtimeService -// .createProcessInstanceQuery() -// .processInstanceId(procInstId) -// .singleResult(); -// ActivityImpl activity = bpmActivityService.getEndEvent(processInstance.getProcessDefinitionId()); -// List tasks = selectNowTask(procInstId); -// -// if (!tasks.isEmpty()) { -// doJumpTask(tasks.get(0).getId(), activity.getId()); -// } - - } - - @Override - public void removeHiTask(String taskId) { - historyService.deleteHistoricTaskInstance(taskId); - } - - @Override - public Map selectVariableLocalByTaskId(String taskId) { - return taskService.getVariablesLocal(taskId); - } - - @Override - public String selectVariableLocalByTaskId(String taskId, String variableName) { - return (String) taskService.getVariableLocal(taskId, variableName); - } - - @Override - public HistoricProcessInstance selectHisProInst(String procInstId) { - return historyService.createHistoricProcessInstanceQuery().processInstanceId(procInstId).singleResult(); - } - - @Override - public void setCandidate(String doingUserId, Task task) { - if (task == null) { - return; - } - if (task.getTaskDefinitionKey() != null) { - //从配置中获取候选人 - List candidateInfoList = processConfigurationService - .getActivityConfiguration(doingUserId, task.getProcessDefinitionId(), task.getTaskDefinitionKey()) - .getCandidateInfo(task); - if (CollectionUtils.isEmpty(candidateInfoList)) { - logger.warn("任务:{}未能设置候选人,此任务可能无法办理!", task); - } else { - for (CandidateInfo candidateInfo : candidateInfoList) { - Authentication user = candidateInfo.user(); - if (user != null) { - taskService.addCandidateUser(task.getId(), user.getUser().getId()); - } - } - } - } else { - logger.warn("未能成功设置环节候选人,task:{}", task); - } - } - - @Override - public ActivityImpl selectActivityImplByTask(String taskId) { - if (StringUtils.isNullOrEmpty(taskId)) { - return new ActivityImpl(null, null); - } - Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); - ProcessDefinitionEntity entity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId()); - List activities = entity.getActivities(); - return activities - .stream() - .filter(activity -> "userTask".equals(activity.getProperty("type")) && activity.getProperty("name").equals(task.getName())) - .findFirst() - .orElseThrow(() -> new NotFoundException("获取节点信息失败")); - } - - @Override - public Map getUserTasksByProcDefKey(String procDefKey) { - String definitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(procDefKey).orderByProcessDefinitionVersion().desc().list().get(0).getId(); - List activities = bpmActivityService.getUserTasksByProcDefId(definitionId); - Map map = new HashMap<>(); - for (ActivityImpl activity : activities) { - map.put(activity.getId(), activity.getProperty("name")); - } - return map; - } - - @Override - public Map getUserTasksByProcInstId(String procInstId) { - String definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(procInstId).singleResult().getProcessDefinitionId(); - List activities = bpmActivityService.getUserTasksByProcDefId(definitionId); - Map map = new HashMap<>(); - for (ActivityImpl activity : activities) { - map.put(activity.getId(), activity.getProperty("name")); - } - return map; - } - - @Override - public void setVariables(String taskId, Map map) { - taskService.setVariables(taskId, map); - } - - @Override - public void removeVariables(String taskId, Collection var2) { - taskService.removeVariables(taskId, var2); - } - - @Override - public void setVariablesLocal(String taskId, Map map) { - taskService.setVariablesLocal(taskId, map); - } - - @Override - public Map getVariablesByProcInstId(String procInstId) { - List executions = runtimeService.createExecutionQuery().processInstanceId(procInstId).list(); - String executionId = ""; - for (Execution execution : executions) { - if (StringUtils.isNullOrEmpty(execution.getParentId())) { - executionId = execution.getId(); - } - } - return runtimeService.getVariables(executionId); - } - - @Override - public Map getVariablesByTaskId(String taskId) { - return taskService.getVariables(taskId); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessConfigurationServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessConfigurationServiceImpl.java deleted file mode 100644 index e14d92137..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessConfigurationServiceImpl.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import io.vavr.Lazy; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.task.Task; -import org.apache.commons.codec.digest.DigestUtils; -import org.hswebframework.expands.script.engine.DynamicScriptEngine; -import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory; -import org.hswebframework.expands.script.engine.ExecuteResult; -import org.hswebframework.web.BusinessException; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.AuthenticationHolder; -import org.hswebframework.web.authorization.AuthenticationPredicate; -import org.hswebframework.web.authorization.exception.AccessDenyException; -import org.hswebframework.web.organizational.authorization.PersonnelAuthentication; -import org.hswebframework.web.organizational.authorization.PersonnelAuthenticationHolder; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; -import org.hswebframework.web.workflow.dao.entity.ListenerConfig; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; -import org.hswebframework.web.workflow.dimension.CandidateDimension; -import org.hswebframework.web.workflow.dimension.CandidateDimensionParser; -import org.hswebframework.web.workflow.dimension.DimensionContext; -import org.hswebframework.web.workflow.dimension.PermissionDimensionParser; -import org.hswebframework.web.workflow.listener.ProcessEvent; -import org.hswebframework.web.workflow.listener.ProcessEventListener; -import org.hswebframework.web.workflow.listener.TaskEvent; -import org.hswebframework.web.workflow.listener.TaskEventListener; -import org.hswebframework.web.workflow.service.ActivityConfigService; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -import org.hswebframework.web.workflow.service.config.ProcessConfigurationService; -import org.hswebframework.web.workflow.service.config.CandidateInfo; -import org.hswebframework.web.workflow.service.config.ActivityConfiguration; -import org.hswebframework.web.workflow.service.config.ProcessConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.stream.Collectors; - - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Service -@Slf4j -public class ProcessConfigurationServiceImpl implements ProcessConfigurationService { - - @Autowired - private ProcessDefineConfigService defineConfigService; - - @Autowired - private ActivityConfigService activityConfigService; - - @Autowired - private PermissionDimensionParser permissionDimensionParser; - - @Autowired - private CandidateDimensionParser candidateDimensionParser; - - - private static final EmptyActivityConfiguration emptyConfiguration = new EmptyActivityConfiguration(); - - @Override - public ActivityConfiguration getActivityConfiguration(String doingUser, String processDefineId, String activityId) { - ActivityConfigEntity configEntity = activityConfigService.selectByProcessDefineIdAndActivityId(processDefineId, activityId); - if (configEntity == null) { - return emptyConfiguration; - } - - return new ActivityConfiguration() { - @Override - public String getFormId() { - return configEntity.getFormId(); - } - - @Override - public boolean canClaim(Task task, String userId) { - return getCandidateInfo(task) - .stream() - .map(CandidateInfo::user) - .anyMatch(user -> user.getUser().getId().equals(userId)); - } - - @Override - @SuppressWarnings("all") - public List getCandidateInfo(Task task) { - return Lazy.val(() -> { - - DimensionContext context = new DimensionContext(); - context.setCreatorId(doingUser); - context.setActivityId(activityId); - context.setProcessDefineId(processDefineId); - context.setTask(task); - CandidateDimension dimension = candidateDimensionParser - .parse(context, configEntity.getCandidateDimension()); - - return dimension.getCandidateUserIdList() - .stream() - .distinct() - .map(userId -> - Lazy.val(() -> new CandidateInfo() { - @Override - public Authentication user() { - return AuthenticationHolder.get(userId); - } - - @Override - public PersonnelAuthentication person() { - return PersonnelAuthenticationHolder.getByUserId(userId); - } - }, CandidateInfo.class)) - .collect(Collectors.toList()); - - }, List.class); - } - - @Override - public TaskEventListener getTaskListener(String eventType) { - if (CollectionUtils.isEmpty(configEntity.getListeners())) { - return null; - } - return configEntity - .getListeners() - .stream() - .filter(config -> eventType.equals(config.getEventType())) - .map(ProcessConfigurationServiceImpl.this::createTaskEventListener) - .collect(Collectors.collectingAndThen(Collectors.toList(), - list -> event -> list.forEach(listener -> listener.accept(event)))); - } - }; - } - - - @SneakyThrows - protected Consumer createTaskEventListener(ListenerConfig listenerConfig) { - DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(listenerConfig.getLanguage()); - if (null != engine) { - String scriptId = DigestUtils.md5Hex(listenerConfig.getScript()); - if (!engine.compiled(scriptId)) { - engine.compile(scriptId, listenerConfig.getScript()); - } - return event -> { - Map context = new HashMap<>(); - context.put("event", event); - ExecuteResult result = engine.execute(scriptId, context); - if (!result.isSuccess()) { - throw new BusinessException("执行监听器失败:" + result.getMessage(), result.getException()); - } - }; - } else { - log.warn("不支持的脚本语言:{}", listenerConfig.getLanguage()); - } - return null; - } - - @Override - public ProcessConfiguration getProcessConfiguration(String processDefineId) { - ProcessDefineConfigEntity entity = defineConfigService.selectByProcessDefineId(processDefineId); - if (entity == null) { - return emptyConfiguration; - } - return new ProcessConfiguration() { - @Override - public String getFormId() { - return entity.getFormId(); - } - - @Override - public void assertCanStartProcess(String userId, ProcessDefinition definition) { - if (!canStartProcess(userId, definition)) { - throw new AccessDenyException("没有权限启动此流程"); - } - } - - @Override - public boolean canStartProcess(String userId, ProcessDefinition definition) { - if (StringUtils.isEmpty(entity.getPermissionDimension()) || "*".equals(entity.getPermissionDimension())) { - return true; - } - AuthenticationPredicate predicate = permissionDimensionParser.parse(entity.getPermissionDimension()); - if (null != predicate) { - return predicate.test(AuthenticationHolder.get(userId)); - } - return true; - } - - @Override - public ProcessEventListener getProcessListener(String eventType) { - if (CollectionUtils.isEmpty(entity.getListeners())) { - return null; - } - return entity - .getListeners() - .stream() - .filter(config -> eventType.equals(config.getEventType())) - .map(ProcessConfigurationServiceImpl.this::createTaskEventListener) - .collect(Collectors.collectingAndThen(Collectors.toList(), - list -> event -> list.forEach(listener -> listener.accept(event)))); - } - }; - } - - private final static class EmptyActivityConfiguration implements ActivityConfiguration, ProcessConfiguration { - - @Override - public String getFormId() { - return null; - } - - @Override - public boolean canClaim(Task task, String userId) { - return false; - } - - @Override - public List getCandidateInfo(Task task) { - return new java.util.ArrayList<>(); - } - - @Override - public void assertCanStartProcess(String userId, ProcessDefinition definition) { - } - - @Override - public boolean canStartProcess(String userId, ProcessDefinition definition) { - return true; - } - - @Override - public ProcessEventListener getProcessListener(String eventType) { - return null; - } - - @Override - public TaskEventListener getTaskListener(String eventType) { - return null; - } - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessDefineConfigServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessDefineConfigServiceImpl.java deleted file mode 100644 index af8a9e425..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessDefineConfigServiceImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.hswebframework.web.commons.entity.DataStatus; -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.EnableCacheGenericEntityService; -import org.hswebframework.web.workflow.dao.ProcessDefineConfigDao; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -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.cache.annotation.Caching; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.Objects; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Service -@CacheConfig(cacheNames = "process-config") -public class ProcessDefineConfigServiceImpl extends EnableCacheGenericEntityService - implements ProcessDefineConfigService { - - @Autowired - private ProcessDefineConfigDao processDefineConfigDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return processDefineConfigDao; - } - - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId"), - @CacheEvict(key = "'define-key-latest:'+#entity.processDefineKey") - }) - public String insert(ProcessDefineConfigEntity entity) { - entity.setCreateTime(new Date()); - entity.setUpdateTime(new Date()); - entity.setStatus(DataStatus.STATUS_ENABLED); - return super.insert(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId"), - @CacheEvict(key = "'define-key-latest:'+#entity.processDefineKey") - }) - public int updateByPk(String id, ProcessDefineConfigEntity entity) { - entity.setUpdateTime(new Date()); - return super.updateByPk(id, entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId"), - @CacheEvict(key = "'define-key-latest:'+#entity.processDefineKey") - }) - protected int updateByPk(ProcessDefineConfigEntity entity) { - return super.updateByPk(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#entity.processDefineId"), - @CacheEvict(key = "'define-key-latest:'+#entity.processDefineKey") - }) - public String saveOrUpdate(ProcessDefineConfigEntity entity) { - return super.saveOrUpdate(entity); - } - - @Override - @Caching(evict = { - @CacheEvict(key = "'define-id:'+#result.processDefineId"), - @CacheEvict(key = "'define-key-latest:'+#result.processDefineKey") - }) - public ProcessDefineConfigEntity deleteByPk(String id) { - - return super.deleteByPk(id); - } - - @Override - @Cacheable(key = "'define-id:'+#processDefineId") - public ProcessDefineConfigEntity selectByProcessDefineId(String processDefineId) { - return createQuery() - .where("processDefineId", Objects.requireNonNull(processDefineId, "参数[processDefineId]不能为空")) - .single(); - } - - @Override - @Cacheable(key = "'define-key-latest:'+#processDefineKey") - public ProcessDefineConfigEntity selectByLatestProcessDefineKey(String processDefineKey) { - return createQuery() - .where("processDefineKey", Objects.requireNonNull(processDefineKey, "参数[processDefineKey]不能为空")) - .and("status", DataStatus.STATUS_ENABLED) - .orderByDesc("updateTime") - .single(); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessHistoryServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessHistoryServiceImpl.java deleted file mode 100644 index 617bbea73..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/ProcessHistoryServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.hswebframework.web.dao.CrudDao; -import org.hswebframework.web.id.IDGenerator; -import org.hswebframework.web.service.GenericEntityService; -import org.hswebframework.web.workflow.dao.ProcessHistoryDao; -import org.hswebframework.web.workflow.dao.entity.ProcessHistoryEntity; -import org.hswebframework.web.workflow.service.ProcessHistoryService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Date; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Component -public class ProcessHistoryServiceImpl extends GenericEntityService implements ProcessHistoryService { - - @Autowired - private ProcessHistoryDao processHistoryDao; - - @Override - protected IDGenerator getIDGenerator() { - return IDGenerator.MD5; - } - - @Override - public CrudDao getDao() { - return processHistoryDao; - } - - @Override - public String insert(ProcessHistoryEntity entity) { - entity.setCreateTime(new Date()); - - return super.insert(entity); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/WorkFlowFormServiceImpl.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/WorkFlowFormServiceImpl.java deleted file mode 100644 index ca0b42b1b..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/imp/WorkFlowFormServiceImpl.java +++ /dev/null @@ -1,296 +0,0 @@ -package org.hswebframework.web.workflow.service.imp; - -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.meta.RDBTableMetaData; -import org.hswebframework.ezorm.rdb.meta.converter.DateTimeConverter; -import org.hswebframework.ezorm.rdb.render.dialect.Dialect; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.service.form.DynamicFormOperationService; -import org.hswebframework.web.service.form.initialize.ColumnInitializeContext; -import org.hswebframework.web.service.form.initialize.DynamicFormInitializeCustomizer; -import org.hswebframework.web.service.form.initialize.TableInitializeContext; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; -import org.hswebframework.web.workflow.service.ActivityConfigService; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -import org.hswebframework.web.workflow.service.WorkFlowFormService; -import org.hswebframework.web.workflow.service.request.SaveFormRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - -import java.sql.JDBCType; -import java.util.*; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Service -@Transactional(rollbackFor = Exception.class) -public class WorkFlowFormServiceImpl extends AbstractFlowableService implements WorkFlowFormService, DynamicFormInitializeCustomizer { - - @Autowired - private DynamicFormOperationService dynamicFormOperationService; - - @Autowired - private ActivityConfigService activityConfigService; - - @Autowired - private ProcessDefineConfigService processDefineConfigService; - - @Override - public void saveProcessForm(ProcessInstance instance, SaveFormRequest request) { - request.tryValidate(); - - ProcessDefineConfigEntity entity = processDefineConfigService.selectByProcessDefineId(instance.getProcessDefinitionId()); - - if (entity == null || StringUtils.isEmpty(entity.getFormId())) { - return; - } - Map formData = request.getFormData(); - - acceptStartProcessFormData(instance, formData); - - dynamicFormOperationService.saveOrUpdate(entity.getFormId(), formData); - - } - - @Override - @Transactional(readOnly = true) - public PagerResult selectProcessForm(String processDefineId, QueryParamEntity queryParam) { - ProcessDefineConfigEntity entity = processDefineConfigService.selectByProcessDefineId(processDefineId); - - if (entity == null || StringUtils.isEmpty(entity.getFormId())) { - return PagerResult.empty(); - } - - return dynamicFormOperationService.selectPager(entity.getFormId(), queryParam); - } - - @Override - @Transactional(readOnly = true) - public PagerResult selectTaskForm(String processDefineId, String activityId, QueryParamEntity queryParam) { - Objects.requireNonNull(processDefineId, "processDefineId can not be null"); - Objects.requireNonNull(activityId, "activityId can not be null"); - - ActivityConfigEntity entity = activityConfigService.selectByProcessDefineIdAndActivityId(processDefineId, activityId); - - if (entity == null || StringUtils.isEmpty(entity.getFormId())) { - return PagerResult.empty(); - } - return dynamicFormOperationService.selectPager(entity.getFormId(), queryParam); - } - - @Override - public void saveTaskForm(ProcessInstance instance, Task task, SaveFormRequest request) { - request.tryValidate(); - - ActivityConfigEntity entity = activityConfigService.selectByProcessDefineIdAndActivityId(task.getProcessDefinitionId(), task.getTaskDefinitionKey()); - - if (entity == null || StringUtils.isEmpty(entity.getFormId())) { - return; - } - - Map formData = request.getFormData(); - - acceptStartProcessFormData(instance, formData); - acceptTaskFormData(task, formData); - - dynamicFormOperationService.saveOrUpdate(entity.getFormId(), formData); - - } - - protected void acceptTaskFormData(Task task, - Map formData) { - - - formData.put("processTaskId", task.getId()); - formData.put("processTaskDefineKey", task.getTaskDefinitionKey()); - formData.put("processTaskName", task.getName()); - - } - - protected void acceptStartProcessFormData(ProcessInstance instance, - - Map formData) { - String processDefinitionName; - try { - processDefinitionName = ((ExecutionEntity) instance).getProcessDefinition().getName(); - } catch (NullPointerException e) { - processDefinitionName = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(instance.getProcessDefinitionId()) - .singleResult().getName(); - } - formData.put("id", instance.getBusinessKey()); - formData.put("processDefineId", instance.getProcessDefinitionId()); - formData.put("processDefineKey", instance.getProcessDefinitionKey()); - formData.put("processDefineName", processDefinitionName); - formData.put("processInstanceId", instance.getProcessInstanceId()); - - } - - @Override - public void customTableSetting(TableInitializeContext context) { - RDBTableMetaData table = context.getTable(); - Dialect dialect = context.getDatabase().getMeta().getDialect(); - - if (!table.getProperty("enable-workflow", true).isTrue()) { - return; - } - //----------taskId-------------- - { - RDBColumnMetaData processTaskId = new RDBColumnMetaData(); - processTaskId.setJavaType(String.class); - processTaskId.setJdbcType(JDBCType.VARCHAR); - processTaskId.setLength(32); - processTaskId.setName("proc_task_id"); - processTaskId.setAlias("processTaskId"); - processTaskId.setDataType(dialect.buildDataType(processTaskId)); - processTaskId.setComment("流程任务ID"); - table.addColumn(processTaskId); - } - - //----------taskDefineKey-------------- - { - RDBColumnMetaData taskDefineKey = new RDBColumnMetaData(); - taskDefineKey.setJavaType(String.class); - taskDefineKey.setJdbcType(JDBCType.VARCHAR); - taskDefineKey.setLength(128); - taskDefineKey.setName("proc_task_key"); - taskDefineKey.setAlias("processTaskDefineKey"); - taskDefineKey.setDataType(dialect.buildDataType(taskDefineKey)); - taskDefineKey.setComment("流程任务定义KEY"); - table.addColumn(taskDefineKey); - } - - //----------taskName-------------- - { - RDBColumnMetaData processTaskName = new RDBColumnMetaData(); - processTaskName.setJavaType(String.class); - processTaskName.setJdbcType(JDBCType.VARCHAR); - processTaskName.setLength(128); - processTaskName.setName("proc_task_name"); - processTaskName.setAlias("processTaskName"); - processTaskName.setDataType(dialect.buildDataType(processTaskName)); - processTaskName.setComment("流程任务定义名称"); - table.addColumn(processTaskName); - } - - //----------processDefineId-------------- - { - RDBColumnMetaData processDefineId = new RDBColumnMetaData(); - processDefineId.setJavaType(String.class); - processDefineId.setJdbcType(JDBCType.VARCHAR); - processDefineId.setLength(32); - processDefineId.setName("proc_def_id"); - processDefineId.setAlias("processDefineId"); - processDefineId.setDataType(dialect.buildDataType(processDefineId)); - processDefineId.setProperty("read-only", true); - processDefineId.setComment("流程定义ID"); - table.addColumn(processDefineId); - } - //----------processDefineKey-------------- - { - RDBColumnMetaData processDefineKey = new RDBColumnMetaData(); - processDefineKey.setJavaType(String.class); - processDefineKey.setJdbcType(JDBCType.VARCHAR); - processDefineKey.setLength(32); - processDefineKey.setName("proc_def_key"); - processDefineKey.setAlias("processDefineKey"); - processDefineKey.setDataType(dialect.buildDataType(processDefineKey)); - processDefineKey.setProperty("read-only", true); - processDefineKey.setComment("流程定义KEY"); - table.addColumn(processDefineKey); - } //----------processDefineName-------------- - { - RDBColumnMetaData processDefineName = new RDBColumnMetaData(); - processDefineName.setJavaType(String.class); - processDefineName.setJdbcType(JDBCType.VARCHAR); - processDefineName.setLength(128); - processDefineName.setName("proc_def_name"); - processDefineName.setAlias("processDefineName"); - processDefineName.setDataType(dialect.buildDataType(processDefineName)); - processDefineName.setProperty("read-only", true); - processDefineName.setComment("流程定义Name"); - table.addColumn(processDefineName); - } - //----------processDefineVersion-------------- - { - RDBColumnMetaData processInstanceId = new RDBColumnMetaData(); - processInstanceId.setJavaType(String.class); - processInstanceId.setJdbcType(JDBCType.VARCHAR); - processInstanceId.setLength(32); - processInstanceId.setName("proc_ins_id"); - processInstanceId.setAlias("processInstanceId"); - processInstanceId.setDataType(dialect.buildDataType(processInstanceId)); - processInstanceId.setProperty("read-only", true); - processInstanceId.setComment("流程实例ID"); - table.addColumn(processInstanceId); - }//----------creatorUserId-------------- - { - RDBColumnMetaData creatorUserId = new RDBColumnMetaData(); - creatorUserId.setJavaType(String.class); - creatorUserId.setJdbcType(JDBCType.VARCHAR); - creatorUserId.setLength(32); - creatorUserId.setName("creator_id"); - creatorUserId.setAlias("creatorId"); - creatorUserId.setDataType(dialect.buildDataType(creatorUserId)); - creatorUserId.setProperty("read-only", true); - creatorUserId.setComment("创建人ID"); - creatorUserId.setDefaultValue(() -> Authentication.current().map(autz -> autz.getUser().getId()).orElse(null)); - table.addColumn(creatorUserId); - } - {//-----------creatorName--------- - RDBColumnMetaData creatorName = new RDBColumnMetaData(); - creatorName.setJavaType(String.class); - creatorName.setJdbcType(JDBCType.VARCHAR); - creatorName.setLength(32); - creatorName.setName("creator_name"); - creatorName.setAlias("creatorName"); - creatorName.setDataType(dialect.buildDataType(creatorName)); - creatorName.setProperty("read-only", true); - creatorName.setComment("创建人姓名"); - creatorName.setDefaultValue(() -> Authentication.current().map(autz -> autz.getUser().getName()).orElse(null)); - table.addColumn(creatorName); - } - {//-----------creatorName--------- - RDBColumnMetaData createTime = new RDBColumnMetaData(); - createTime.setJavaType(Date.class); - createTime.setJdbcType(JDBCType.TIMESTAMP); - createTime.setName("create_time"); - createTime.setAlias("createTime"); - createTime.setDataType(dialect.buildDataType(createTime)); - createTime.setProperty("read-only", true); - createTime.setComment("创建时间"); - createTime.setNotNull(true); - createTime.setValueConverter(new DateTimeConverter("yyyy-MM-dd HH:mm:ss", Date.class)); - createTime.setDefaultValue(Date::new); - table.addColumn(createTime); - } - {//-----------lastUpdateTime--------- - RDBColumnMetaData lastUpdateTime = new RDBColumnMetaData(); - lastUpdateTime.setJavaType(Date.class); - lastUpdateTime.setJdbcType(JDBCType.TIMESTAMP); - lastUpdateTime.setName("last_update_time"); - lastUpdateTime.setAlias("lastUpdateTime"); - lastUpdateTime.setDataType(dialect.buildDataType(lastUpdateTime)); - lastUpdateTime.setComment("最后一次修改时间"); - lastUpdateTime.setNotNull(true); - lastUpdateTime.setValueConverter(new DateTimeConverter("yyyy-MM-dd HH:mm:ss", Date.class)); - lastUpdateTime.setDefaultValue(Date::new); - table.addColumn(lastUpdateTime); - } - } - - @Override - public void customTableColumnSetting(ColumnInitializeContext context) { - - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/CompleteTaskRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/CompleteTaskRequest.java deleted file mode 100644 index 3615caa2e..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/CompleteTaskRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.hswebframework.web.workflow.service.request; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CompleteTaskRequest implements ValidateBean { - private static final long serialVersionUID = -2548459805655649449L; - /** - * 任务ID - */ - @NotBlank - private String taskId; - - /** - * 完成此任务的用户ID - */ - @NotBlank - private String completeUserId; - - /** - * 完成此任务的用户姓名 - */ - @NotBlank - private String completeUserName; - - /** - * 下一环节的ID - */ - private String nextActivityId; - - /** - * 下一环节办理的用户ID - */ - private String nextClaimUserId; - - /** - * 变量 - */ - private Map variables = new HashMap<>(); - - /** - * 表单数据 - */ - private Map formData = new HashMap<>(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/JumpTaskRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/JumpTaskRequest.java deleted file mode 100644 index dcd04be13..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/JumpTaskRequest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hswebframework.web.workflow.service.request; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class JumpTaskRequest implements ValidateBean { - private static final long serialVersionUID = 7625759475416169067L; - - @NotBlank(message = "[jumpUserId]不能为空") - private String jumpUserId; - - @NotBlank(message = "[jumpUserName]不能为空") - private String jumpUserName; - - @NotBlank(message = "[taskId]不能为空") - private String taskId; - - @NotBlank(message = "[targetActivityId]不能为空") - private String targetActivityId; - - //是否记录到流程日志 - private boolean recordLog = true; - - //自定义数据,将会记录到流程历史记录里,比如回退原因等 - private Map data = new HashMap<>(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/RejectTaskRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/RejectTaskRequest.java deleted file mode 100644 index dcf01967b..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/RejectTaskRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.workflow.service.request; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.bean.Bean; -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class RejectTaskRequest implements ValidateBean { - private static final long serialVersionUID = 7625759475416169067L; - - @NotBlank(message = "[rejectUserId]不能为空") - private String rejectUserId; - - @NotBlank(message = "[rejectUserName]不能为空") - private String rejectUserName; - - @NotBlank(message = "[taskId]不能为空") - private String taskId; - - //自定义数据,将会记录到流程历史记录里,比如回退原因等 - private Map data = new HashMap<>(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/SaveFormRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/SaveFormRequest.java deleted file mode 100644 index 7982b5b47..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/SaveFormRequest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.hswebframework.web.workflow.service.request; - -import lombok.*; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.commons.bean.ValidateBean; - -import javax.validation.constraints.NotNull; -import java.util.HashMap; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SaveFormRequest implements ValidateBean { - private static final long serialVersionUID = 7575220908978610735L; - - @NotBlank - private String userId; - - @NotBlank - private String userName; - - private Map formData = new HashMap<>(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/StartProcessRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/StartProcessRequest.java deleted file mode 100644 index d8c6016de..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/service/request/StartProcessRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.hswebframework.web.workflow.service.request; - -import lombok.*; -import org.activiti.engine.repository.ProcessDefinition; -import org.hibernate.validator.constraints.NotBlank; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.User; -import org.hswebframework.web.commons.bean.ValidateBean; - -import java.util.HashMap; -import java.util.Map; - -/** - * 启动流程请求 - * - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@ToString -public class StartProcessRequest implements ValidateBean { - private static final long serialVersionUID = -344629653235864995L; - /** - * 流程定义ID - * - * @see ProcessDefinition#getId() - */ - @NotBlank - private String processDefineId; - - /** - * 流程发起人ID - * - * @see Authentication#current() - * @see Authentication#getUser() - * @see User#getId() - */ - @NotBlank - private String creatorId; - - /** - * 流程发起人姓名 - * - * @see User#getName() - */ - @NotBlank - private String creatorName; - - /** - * 下一环节的办理人ID - */ - private String nextClaimUserId; - - /** - * 流程变量 - */ - private Map variables = new HashMap<>(); - - /** - * 表单数据 - */ - private Map formData = new HashMap<>(); -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ClaimSqlTerm.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ClaimSqlTerm.java deleted file mode 100644 index 7f5a03dac..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ClaimSqlTerm.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.workflow.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; - -import java.util.List; - -/** - * 用户待签收的流程条件 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class ClaimSqlTerm extends AbstractSqlTermCustomizer { - public ClaimSqlTerm(String termType) { - super(termType); - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - RDBColumnMetaData processInstanceId = column.getTableMetaData().findColumn("processInstanceId"); - if (processInstanceId == null) { - throw new UnsupportedOperationException("未获取到属性:[processInstanceId]对应的列"); - } - List val = BoostTermTypeMapper.convertList(column, termValue.getOld()); - - termValue.setValue(val); - SqlAppender appender = new SqlAppender(); - appender.add("exists(select 1 from ACT_RU_TASK RES inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_ WHERE ", - createColumnName(processInstanceId, tableAlias), - "=RES.PROC_INST_ID_ and RES.ASSIGNEE_ is null and I.TYPE_ = 'candidate' and I.USER_ID_ "); - appendCondition(val, wherePrefix, appender); - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/CompletedSqlTerm.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/CompletedSqlTerm.java deleted file mode 100644 index 093ab9264..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/CompletedSqlTerm.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.workflow.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; - -import java.util.List; - -/** - * 已完成的任务查询条件 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class CompletedSqlTerm extends AbstractSqlTermCustomizer { - public CompletedSqlTerm(String termType) { - super(termType); - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - RDBColumnMetaData processInstanceId = column.getTableMetaData().findColumn("processInstanceId"); - if (processInstanceId == null) { - throw new UnsupportedOperationException("未获取到属性:[processInstanceId]对应的列"); - } - List val = BoostTermTypeMapper.convertList(column, termValue.getOld()); - - termValue.setValue(val); - SqlAppender appender = new SqlAppender(); - appender.add("exists(select 1 from ACT_HI_TASKINST RES WHERE ", - createColumnName(processInstanceId, tableAlias), - "= RES.PROC_INST_ID_ and RES.ASSIGNEE_ "); - appendCondition(val, wherePrefix, appender); - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ProcessParticipateSqlTerm.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ProcessParticipateSqlTerm.java deleted file mode 100644 index 0bbf6d868..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/ProcessParticipateSqlTerm.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.workflow.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; - -import java.util.List; - -/** - * 参与的任务查询条件 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class ProcessParticipateSqlTerm extends AbstractSqlTermCustomizer { - public ProcessParticipateSqlTerm(String termType) { - super(termType); - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - RDBColumnMetaData processInstanceId = column.getTableMetaData().findColumn("processInstanceId"); - if (processInstanceId == null) { - throw new UnsupportedOperationException("未获取到属性:[processInstanceId]对应的列"); - } - List val = BoostTermTypeMapper.convertList(column, termValue.getOld()); - - termValue.setValue(val); - SqlAppender appender = new SqlAppender(); - - appender.add("exists(select 1 from ACT_HI_IDENTITYLINK I WHERE ", - createColumnName(processInstanceId, tableAlias), - "=I.PROC_INST_ID_" - , (!term.getOptions().isEmpty() ? " and I.TYPE_ =" + wherePrefix + ".options[0]" : "") - , " and I.USER_ID_ "); - appendCondition(val, wherePrefix, appender); - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/TodoSqlTerm.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/TodoSqlTerm.java deleted file mode 100644 index ccb1afff8..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/TodoSqlTerm.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.hswebframework.web.workflow.terms; - -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData; -import org.hswebframework.ezorm.rdb.render.SqlAppender; -import org.hswebframework.ezorm.rdb.render.dialect.term.BoostTermTypeMapper; -import org.hswebframework.web.dao.mybatis.mapper.AbstractSqlTermCustomizer; -import org.hswebframework.web.dao.mybatis.mapper.ChangedTermValue; - -import java.util.List; - -/** - * 代办的任务查询条件 - * - * @author zhouhao - * @since 3.0.0-RC - */ -public class TodoSqlTerm extends AbstractSqlTermCustomizer { - public TodoSqlTerm(String termType) { - super(termType); - } - - @Override - public SqlAppender accept(String wherePrefix, Term term, RDBColumnMetaData column, String tableAlias) { - ChangedTermValue termValue = createChangedTermValue(term); - RDBColumnMetaData processInstanceId = column.getTableMetaData().findColumn("processInstanceId"); - if (processInstanceId == null) { - throw new UnsupportedOperationException("未获取到属性:[processInstanceId]对应的列"); - } - List val = BoostTermTypeMapper.convertList(column, termValue.getOld()); - - termValue.setValue(val); - SqlAppender appender = new SqlAppender(); - appender.add("exists(select 1 from ACT_RU_TASK RES WHERE ", - createColumnName(processInstanceId, tableAlias), - "= RES.PROC_INST_ID_ and RES.ASSIGNEE_ "); - appendCondition(val, wherePrefix, appender); - appender.add(")"); - - return appender; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/WorkflowTermsAutoConfiguration.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/WorkflowTermsAutoConfiguration.java deleted file mode 100644 index 4e2bfde83..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/terms/WorkflowTermsAutoConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.hswebframework.web.workflow.terms; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Configuration -public class WorkflowTermsAutoConfiguration { - - @Bean - public ClaimSqlTerm claimSqlTerm() { - return new ClaimSqlTerm("user-wf-claim"); - } - - @Bean - public CompletedSqlTerm completedSqlTerm() { - return new CompletedSqlTerm("user-wf-completed"); - } - - @Bean - public ProcessParticipateSqlTerm participateSqlTerm() { - return new ProcessParticipateSqlTerm("user-wf-part"); - } - - @Bean - public TodoSqlTerm todoSqlTerm() { - return new TodoSqlTerm("user-wf-todo"); - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/util/QueryUtils.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/util/QueryUtils.java deleted file mode 100644 index 985b2f6c4..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/util/QueryUtils.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.hswebframework.web.workflow.util; - -import lombok.extern.slf4j.Slf4j; -import org.activiti.engine.query.Query; -import org.hswebframework.ezorm.core.param.Sort; -import org.hswebframework.ezorm.core.param.Term; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.utils.StringUtils; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.springframework.util.ReflectionUtils; - -import java.lang.reflect.Method; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.BiConsumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Slf4j -public class QueryUtils { - - public static > PagerResult doQuery(T query, QueryParamEntity entity) { - return doQuery(query, - entity, - Function.identity()); - } - - public static > PagerResult doQuery(T query, QueryParamEntity entity, Function mapping) { - return doQuery(query, - entity, - mapping, - (term, tuQuery) -> log.warn("不支持的查询条件:{} {}", term.getTermType(), term.getColumn())); - } - - public static > PagerResult doQuery(T query, - QueryParamEntity entity, - Function mapping, - BiConsumer notFound) { - applyQueryParam(query, entity, notFound); - int total = (int) query.count(); - if (total == 0) { - return PagerResult.empty(); - } - entity.rePaging(total); - List list = query.listPage(entity.getPageIndex(), entity.getPageSize() * (entity.getPageIndex() + 1)) - .stream() - .map(mapping) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - return PagerResult.of(total, list, entity); - } - - public static > void applyQueryParam(T query, QueryParamEntity entity, BiConsumer notFound) { - Class type = query.getClass(); - for (Term term : entity.getTerms()) { - String name = term.getColumn(); - if (TermType.like.equals(term.getTermType())) { - name = name.concat("Like"); - } else if (TermType.in.equals(term.getTermType())) { - name = name.concat("s"); - } - String finalName = name; - AtomicBoolean found = new AtomicBoolean(false); - ReflectionUtils.doWithMethods(type, method -> { - if (method.getParameterCount() == 1 && (method.getName().equals(finalName) || method.getName().equals(term.getColumn()))) { - Object value = FastBeanCopier.DEFAULT_CONVERT.convert(term.getValue(), method.getParameterTypes()[0], FastBeanCopier.EMPTY_CLASS_ARRAY); - ReflectionUtils.invokeMethod(method, query, value); - found.set(true); - } - }); - if (!found.get()) { - notFound.accept(term, query); - } - } - for (Sort sort : entity.getSorts()) { - String name = sort.getName(); - Method method = ReflectionUtils.findMethod(type, "orderBy" + StringUtils.toUpperCaseFirstOne(name)); - if (method != null && method.getParameterCount() == 0) { - ReflectionUtils.invokeMethod(method, query); - if ("asc".equals(sort.getOrder())) { - query.asc(); - } else { - query.desc(); - } - } - - } - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableDeploymentController.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableDeploymentController.java deleted file mode 100644 index 9509cbf51..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableDeploymentController.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.hswebframework.web.workflow.web; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.SneakyThrows; -import org.activiti.bpmn.converter.BpmnXMLConverter; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.editor.constants.ModelDataJsonConstants; -import org.activiti.editor.language.json.converter.BpmnJsonConverter; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.DeploymentBuilder; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.repository.ProcessDefinitionQuery; -import org.apache.commons.io.FilenameUtils; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.workflow.service.BpmActivityService; -import org.hswebframework.web.workflow.service.BpmProcessService; -import org.hswebframework.web.workflow.service.BpmTaskService; -import org.hswebframework.web.workflow.service.imp.AbstractFlowableService; -import org.hswebframework.web.workflow.util.QueryUtils; -import org.hswebframework.web.workflow.web.response.ActivityInfo; -import org.hswebframework.web.workflow.web.response.ProcessDefinitionInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.util.StreamUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.imageio.ImageIO; -import javax.servlet.http.HttpServletResponse; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.util.zip.ZipInputStream; - -/** - * @Author wangwei - * @Date 2017/8/10. - */ -@RestController -@RequestMapping("/workflow/process/definition") -@Api(tags = "工作流-流程定义管理", description = "工作流流程定义管理") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -public class FlowableDeploymentController extends AbstractFlowableService { - - private final static String MODEL_ID = "modelId"; - - @Autowired - BpmTaskService bpmTaskService; - @Autowired - BpmProcessService bpmProcessService; - @Autowired - BpmActivityService bpmActivityService; - - /** - * 流程定义列表 - */ - @GetMapping - @ApiOperation("查询流程定义列表") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage> queryProcessList(QueryParamEntity param) { - ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); - - return ResponseMessage.ok(QueryUtils.doQuery(processDefinitionQuery, param, ProcessDefinitionInfo::of)); - } - - /** - * 部署流程资源 - * 加载ZIP文件中的流程 - */ - @PostMapping(value = "/deploy") - @ApiOperation("上传流程定义文件并部署流程") - @Authorize(action = "deploy") - public ResponseMessage deploy(@RequestPart(value = "file") MultipartFile file) throws IOException { - // 获取上传的文件名 - String fileName = file.getOriginalFilename(); - - // 得到输入流(字节流)对象 - InputStream fileInputStream = file.getInputStream(); - - // 文件的扩展名 - String extension = FilenameUtils.getExtension(fileName); - - // zip或者bar类型的文件用ZipInputStream方式部署 - DeploymentBuilder deployment = repositoryService.createDeployment(); - if ("zip".equals(extension) || "bar".equals(extension)) { - ZipInputStream zip = new ZipInputStream(fileInputStream); - deployment.addZipInputStream(zip); - } else { - // 其他类型的文件直接部署 - deployment.addInputStream(fileName, fileInputStream); - } - Deployment result = deployment.deploy(); - - return ResponseMessage.ok(result); - } - - /** - * 读取流程资源 - * - * @param processDefinitionId 流程定义ID - * @param resourceName 资源名称 - */ - @GetMapping(value = "/{processDefinitionId}/resource/{resourceName}") - @ApiOperation("读取流程资源") - @Authorize(action = Permission.ACTION_QUERY) - @SneakyThrows - public void readResource(@PathVariable String processDefinitionId - , @PathVariable String resourceName, HttpServletResponse response) { - ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery(); - ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult(); - - // 通过接口读取 - try (InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName)) { - StreamUtils.copy(resourceAsStream, response.getOutputStream()); - } - - } - - /*** - * 流程定义转换Model - */ - @PutMapping(value = "/convert-to-model/{processDefinitionId}") - @ApiOperation("流程定义转换模型") - @Authorize(action = Permission.ACTION_UPDATE) - public ResponseMessage convertToModel(@PathVariable("processDefinitionId") String processDefinitionId) - throws UnsupportedEncodingException, XMLStreamException { - ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(processDefinitionId).singleResult(); - if (null == processDefinition) { - throw new NotFoundException(); - } - InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), - processDefinition.getResourceName()); - - XMLInputFactory xif = XMLInputFactory.newInstance(); - InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8"); - XMLStreamReader xtr = xif.createXMLStreamReader(in); - BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); - - - BpmnJsonConverter converter = new BpmnJsonConverter(); - com.fasterxml.jackson.databind.node.ObjectNode modelNode = converter.convertToJson(bpmnModel); - org.activiti.engine.repository.Model modelData = repositoryService.newModel(); - modelData.setKey(processDefinition.getKey()); - modelData.setName(processDefinition.getResourceName().substring(0, processDefinition.getResourceName().indexOf("."))); - modelData.setCategory(processDefinition.getDeploymentId()); - - ObjectNode modelObjectNode = new ObjectMapper().createObjectNode(); - modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processDefinition.getName()); - modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); - modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, processDefinition.getDescription()); - modelData.setMetaInfo(modelObjectNode.toString()); - - repositoryService.saveModel(modelData); - - repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8")); - return ResponseMessage.ok(modelData.getId()); - } - - /** - * 删除部署的流程,如果流程下有正在运行的流程实例则报错 - * - * @param deploymentId 流程部署ID - */ - @DeleteMapping(value = "/deployment/{deploymentId}") - @ApiOperation("删除部署的流程") - @Authorize(action = Permission.ACTION_DELETE) - public ResponseMessage deleteProcessDefinition( - @PathVariable("deploymentId") String deploymentId - , @RequestParam(defaultValue = "false") boolean cascade) { - repositoryService.deleteDeployment(deploymentId, cascade); - - return ResponseMessage.ok(); - } - - - /** - * 查看当前节点流程图 - */ - @GetMapping("/{processInstanceId}/activity") - @ApiOperation("查看当前流程活动节点流程图") - @Authorize(action = Permission.ACTION_QUERY) - public ResponseMessage getProcessInstanceActivity(@PathVariable String processInstanceId) { - HistoricProcessInstance processInstance = bpmTaskService.selectHisProInst(processInstanceId); - if (processInstance != null) { - ActivityImpl activity = bpmActivityService.getActivityByProcInstId(processInstance.getProcessDefinitionId(), processInstance.getId()); - return ResponseMessage.ok(ActivityInfo.of(activity)); - } else { - throw new NotFoundException("流程不存在"); - } - } - - @GetMapping("/{processInstanceId}/image") - @ApiOperation("查看当前流程活动节点流程图") - @Authorize(action = Permission.ACTION_QUERY) - public void getProcessImage(@PathVariable String processInstanceId, HttpServletResponse response) throws IOException { - try (InputStream inputStream = bpmProcessService.findProcessPic(processInstanceId)) { - response.setContentType(MediaType.IMAGE_PNG_VALUE); - ImageIO.write(ImageIO.read(inputStream), "png", response.getOutputStream()); - } - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableModelManagerController.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableModelManagerController.java deleted file mode 100644 index 319c637c0..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableModelManagerController.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.hswebframework.web.workflow.web; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.activiti.bpmn.converter.BpmnXMLConverter; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.editor.language.json.converter.BpmnJsonConverter; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.impl.persistence.entity.ModelEntity; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.Model; -import org.activiti.engine.repository.ModelQuery; -import org.apache.batik.transcoder.TranscoderException; -import org.apache.batik.transcoder.TranscoderInput; -import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.batik.transcoder.image.PNGTranscoder; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.hswebframework.ezorm.core.PropertyWrapper; -import org.hswebframework.ezorm.core.SimplePropertyWrapper; -import org.hswebframework.ezorm.core.param.TermType; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.bean.FastBeanCopier; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.workflow.enums.ModelType; -import org.hswebframework.web.workflow.util.QueryUtils; -import org.hswebframework.web.workflow.web.request.ModelCreateRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URLEncoder; -import java.util.List; -import java.util.Map; - -@RestController -@RequestMapping("/workflow/model") -@Api(tags = "工作流-模型管理", description = "工作流模型管理") -@Authorize(permission = "workflow-model", description = "工作流模型管理") -@Slf4j -public class FlowableModelManagerController { - - @Autowired - private RepositoryService repositoryService; - - private final static String MODEL_ID = "modelId"; - private final static String MODEL_NAME = "name"; - private final static String MODEL_REVISION = "revision"; - private final static String MODEL_DESCRIPTION = "description"; - private final static String MODEL_KEY = "key"; - - @GetMapping - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("获取模型列表") - public ResponseMessage> getModelList(QueryParamEntity param) { - ModelQuery modelQuery = repositoryService.createModelQuery(); - return ResponseMessage.ok( - QueryUtils.doQuery(modelQuery, param, - model -> FastBeanCopier.copy(model, new ModelEntity()), - (term, modelQuery1) -> { - if ("latestVersion".equals(term.getColumn())) { - modelQuery1.latestVersion(); - } - })); - } - - @PostMapping - @ResponseStatus(value = HttpStatus.CREATED) - @ApiOperation("创建模型") - public ResponseMessage createModel(@RequestBody ModelCreateRequest model) throws Exception { - JSONObject stencilset = new JSONObject(); - stencilset.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); - JSONObject editorNode = new JSONObject(); - editorNode.put("id", "canvas"); - editorNode.put("resourceId", "canvas"); - editorNode.put("stencilset", stencilset); - JSONObject modelObjectNode = new JSONObject(); - modelObjectNode.put(MODEL_REVISION, 1); - modelObjectNode.put(MODEL_DESCRIPTION, model.getDescription()); - modelObjectNode.put(MODEL_KEY, model.getKey()); - modelObjectNode.put(MODEL_NAME, model.getName()); - - Model modelData = repositoryService.newModel(); - modelData.setMetaInfo(modelObjectNode.toJSONString()); - modelData.setName(model.getName()); - modelData.setKey(model.getKey()); - repositoryService.saveModel(modelData); - repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8")); - return ResponseMessage.ok(modelData).status(201); - } - - @PostMapping("/{modelId}/deploy") - @ApiOperation("发布模型") - @Authorize(action = "deploy") - public ResponseMessage deployModel(@PathVariable String modelId) throws Exception { - Model modelData = repositoryService.getModel(modelId); - if (modelData == null) { - throw new NotFoundException("模型不存在!"); - } - ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId())); - BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); - byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model); - String processName = modelData.getName() + ".bpmn20.xml"; - Deployment deployment = repositoryService.createDeployment() - .name(modelData.getName()) - .addString(processName, new String(bpmnBytes, "utf8")) - .deploy(); - return ResponseMessage.ok(deployment).include(Deployment.class, "id", "name", "new"); - } - - /** - * 导出model对象为指定类型 - * - * @param modelId 模型ID - * @param type 导出文件类型(bpmn\json) - */ - @GetMapping(value = "export/{modelId}/{type}") - @ApiOperation("导出模型") - @Authorize(action = "export") - @SneakyThrows - public void export(@PathVariable("modelId") @ApiParam("模型ID") String modelId, - @PathVariable("type") @ApiParam(value = "类型", allowableValues = "bpmn,json", example = "json") - ModelType type, - @ApiParam(hidden = true) HttpServletResponse response) { - Model modelData = repositoryService.getModel(modelId); - if (modelData == null) { - throw new NotFoundException("模型不存在"); - } - BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); - byte[] modelEditorSource = repositoryService.getModelEditorSource(modelData.getId()); - - JsonNode editorNode = new ObjectMapper().readTree(modelEditorSource); - BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); - - // 处理异常 - if (bpmnModel.getMainProcess() == null) { - throw new UnsupportedOperationException("无法导出模型文件:" + type); - } - - String filename = ""; - byte[] exportBytes = null; - - String mainProcessId = bpmnModel.getMainProcess().getId(); - - if (type == ModelType.bpmn) { - BpmnXMLConverter xmlConverter = new BpmnXMLConverter(); - exportBytes = xmlConverter.convertToXML(bpmnModel); - filename = mainProcessId + ".bpmn20.xml"; - } else if (type == ModelType.json) { - exportBytes = modelEditorSource; - filename = mainProcessId + ".json"; - - } else { - throw new UnsupportedOperationException("不支持的格式:" + type); - } - - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8")); - - /*创建输入流*/ - try (ByteArrayInputStream in = new ByteArrayInputStream(exportBytes)) { - IOUtils.copy(in, response.getOutputStream()); - response.flushBuffer(); - } - } - - @GetMapping(value = "/{modelId}/json") - @Authorize(action = Permission.ACTION_GET) - public Object getEditorJson(@PathVariable String modelId) { - JSONObject modelNode; - Model model = repositoryService.getModel(modelId); - if (model == null) throw new NullPointerException("模型不存在"); - if (StringUtils.isNotEmpty(model.getMetaInfo())) { - modelNode = JSON.parseObject(model.getMetaInfo()); - } else { - modelNode = new JSONObject(); - modelNode.put(MODEL_NAME, model.getName()); - } - modelNode.put(MODEL_ID, model.getId()); - modelNode.put("model", JSON.parse(new String(repositoryService.getModelEditorSource(model.getId())))); - return modelNode; - } - - @PutMapping(value = "/{modelId}") - @ResponseStatus(value = HttpStatus.OK) - @Authorize(action = Permission.ACTION_UPDATE) - public void saveModel(@PathVariable String modelId, - @RequestParam Map values) throws TranscoderException, IOException { - Model model = repositoryService.getModel(modelId); - JSONObject modelJson = JSON.parseObject(model.getMetaInfo()); - - modelJson.put(MODEL_NAME, values.get("name")); - modelJson.put(MODEL_DESCRIPTION, values.get("description")); - - model.setMetaInfo(modelJson.toString()); - model.setName(values.get("name")); - - repositoryService.saveModel(model); - - repositoryService.addModelEditorSource(model.getId(), values.get("json_xml").getBytes("utf-8")); - - InputStream svgStream = new ByteArrayInputStream(values.get("svg_xml").getBytes("utf-8")); - TranscoderInput input = new TranscoderInput(svgStream); - - PNGTranscoder transcoder = new PNGTranscoder(); - // Setup output - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - TranscoderOutput output = new TranscoderOutput(outStream); - - // Do the transformation - transcoder.transcode(input, output); - final byte[] result = outStream.toByteArray(); - repositoryService.addModelEditorSourceExtra(model.getId(), result); - outStream.close(); - } - - @DeleteMapping("/{modelId}") - @Authorize(action = Permission.ACTION_DELETE) - public ResponseMessage delete(@PathVariable String modelId) { - repositoryService.deleteModel(modelId); - return ResponseMessage.ok(); - } -} \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableProcessController.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableProcessController.java deleted file mode 100644 index b6d10f31f..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/FlowableProcessController.java +++ /dev/null @@ -1,388 +0,0 @@ -package org.hswebframework.web.workflow.web; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.TaskService; -import org.activiti.engine.history.HistoricTaskInstanceQuery; -import org.activiti.engine.impl.RepositoryServiceImpl; -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.impl.task.TaskDefinition; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Execution; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.runtime.ProcessInstanceQuery; -import org.activiti.engine.task.Task; -import org.activiti.engine.task.TaskQuery; -import org.hswebframework.ezorm.core.Conditional; -import org.hswebframework.ezorm.core.NestConditional; -import org.hswebframework.ezorm.core.dsl.Query; -import org.hswebframework.web.NotFoundException; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.Permission; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.workflow.service.BpmActivityService; -import org.hswebframework.web.workflow.service.WorkFlowFormService; -import org.hswebframework.web.workflow.service.config.CandidateInfo; -import org.hswebframework.web.workflow.service.config.ProcessConfigurationService; -import org.hswebframework.web.workflow.service.BpmProcessService; -import org.hswebframework.web.workflow.service.BpmTaskService; -import org.hswebframework.web.workflow.service.request.CompleteTaskRequest; -import org.hswebframework.web.workflow.service.request.JumpTaskRequest; -import org.hswebframework.web.workflow.service.request.RejectTaskRequest; -import org.hswebframework.web.workflow.service.request.StartProcessRequest; -import org.hswebframework.web.workflow.util.QueryUtils; -import org.hswebframework.web.workflow.web.response.CandidateDetail; -import org.hswebframework.web.workflow.web.response.ProcessInfo; -import org.hswebframework.web.workflow.web.response.TaskInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@RestController -@RequestMapping("/workflow/process") -@Api(tags = "工作流-流程管理", description = "工作流-流程管理") -@Authorize(permission = "workflow-process", description = "工作流-流程管理") -public class FlowableProcessController { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private BpmTaskService bpmTaskService; - - @Autowired - private BpmActivityService bpmActivityService; - - @Autowired - private BpmProcessService bpmProcessService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private ProcessConfigurationService processConfigurationService; - - @Autowired - private TaskService taskService; - - @Autowired - private HistoryService historyService; - - @Autowired - private WorkFlowFormService workFlowFormService; - - @GetMapping("/doing") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("查询进行中的流程信息") - public ResponseMessage> queryProcess(QueryParamEntity query) { - ProcessInstanceQuery instanceQuery = runtimeService.createProcessInstanceQuery(); - - PagerResult result = QueryUtils.doQuery(instanceQuery, query, ProcessInfo::of, (term, q) -> { - if ("status".equals(term.getColumn())) { - switch (String.valueOf(term.getValue())) { - case "active": - q.active(); - break; - case "suspended": - q.suspended(); - break; - default: - break; - } - } - }); - - return ResponseMessage.ok(result).exclude(query.getExcludes()).include(query.getIncludes()); - } - - @GetMapping("/tasks") - @Authorize(action = Permission.ACTION_QUERY) - @ApiOperation("查询当前用户的历史任务信息") - public ResponseMessage> getHistory(QueryParamEntity query, Authentication authentication) { - HistoricTaskInstanceQuery historyQuery = historyService.createHistoricTaskInstanceQuery(); - historyQuery.taskAssignee(authentication.getUser().getId()); - - PagerResult result = QueryUtils.doQuery(historyQuery, query, TaskInfo::of, (term, q) -> { - if ("status".equals(term.getColumn())) { - switch (String.valueOf(term.getValue())) { - case "finished": - q.finished(); - break; - case "processFinished": - q.processFinished(); - break; - default: - break; - } - } - }); - - return ResponseMessage.ok(result).exclude(query.getExcludes()).include(query.getIncludes()); - } - - @PostMapping("/start/key/{defineKey}") - @ApiOperation("提交表单数据并根据流程定义key启动流程") - @Authorize(merge = false) - public ResponseMessage startProcessByKey(@PathVariable String defineKey, - @RequestBody Map data, - Authentication authentication) { - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .processDefinitionKey(defineKey) - .active() - .latestVersion() - .singleResult(); - - if (null == definition) { - throw new NotFoundException("流程[" + defineKey + "]不存在"); - } - //判断权限 - processConfigurationService.getProcessConfiguration(definition.getId()) - .assertCanStartProcess(authentication.getUser().getId(), definition); - - String id = definition.getId(); - - ProcessInstance instance = bpmProcessService.startProcessInstance(StartProcessRequest.builder() - .creatorId(authentication.getUser().getId()) - .creatorName(authentication.getUser().getName()) - .formData(data) - .processDefineId(id) - .build()); - - - return ResponseMessage.ok(instance.getId()); - } - - @PostMapping("/start/id/{defId}") - @ApiOperation("提交表单数据并根据流程定义ID启动流程") - @Authorize(merge = false) - public ResponseMessage startProcess(@PathVariable String defId, - @RequestBody Map data, - Authentication authentication) { - ProcessDefinition definition = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(defId) - .active() - .singleResult(); - - if (null == definition) { - throw new NotFoundException("流程[" + defId + "]不存在"); - } - //判断权限 - processConfigurationService.getProcessConfiguration(definition.getId()) - .assertCanStartProcess(authentication.getUser().getId(), definition); - - - ProcessInstance instance = bpmProcessService.startProcessInstance(StartProcessRequest.builder() - .creatorId(authentication.getUser().getId()) - .creatorName(authentication.getUser().getName()) - .formData(data) - .processDefineId(defId) - .build()); - - return ResponseMessage.ok(instance.getId()); - } - - @GetMapping("/todo") - @ApiOperation("获取待办任务") - @Authorize(merge = false) - public ResponseMessage> getTodoList(QueryParamEntity query, Authentication authentication) { - TaskQuery taskQuery = taskService.createTaskQuery(); - - taskQuery.taskAssignee(authentication.getUser().getId()); - - PagerResult result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of); - - - return ResponseMessage.ok(result).exclude(query.getExcludes()).include(query.getIncludes()); - } - - @AllArgsConstructor - @Getter - public enum Type { - claim("user-wf-claim"), - todo("user-wf-todo"), - completed("user-wf-completed"), - part("user-wf-part"), - create("is") { - @Override - public void applyQueryTerm(NestConditional conditional, String userId) { - conditional.accept("creatorId", getTermType(), userId); - } - }, - claimOrTodo("is") { - @Override - public void applyQueryTerm(NestConditional conditional, String userId) { - conditional.nest() - .when(true, q -> Type.claim.applyQueryTerm(q, userId)) - .or() - .when(true, q -> Type.todo.applyQueryTerm(q, userId)) - .end(); - } - }; - - private String termType; - - public void applyQueryTerm(NestConditional conditional, String userId) { - conditional.accept("processInstanceId", termType, userId); - } - } - - @GetMapping("/{type}/form/{processDefineId}") - @ApiOperation("获取自己可查看的流程表单数据") - @Authorize(merge = false) - @SuppressWarnings("all") - public ResponseMessage> getFormData(@PathVariable Type type, - @PathVariable String processDefineId, - QueryParamEntity query, - Authentication authentication) { - Query.empty(query) - .nest() - .when(type != null, q -> type.applyQueryTerm(q, authentication.getUser().getId())) - .end(); - return ResponseMessage.ok(workFlowFormService.selectProcessForm(processDefineId, query)); - } - - @GetMapping("/task/form/{processDefineId}/{taskDefineKey}") - @ApiOperation("获取流程任务表单数据") - @Authorize(merge = false) - public ResponseMessage> getTaskFormData(@PathVariable String processDefineId, - @PathVariable String taskDefineKey, - QueryParamEntity query) { - return ResponseMessage.ok(workFlowFormService.selectTaskForm(processDefineId, taskDefineKey, query)); - } - - - @GetMapping("/claims") - @ApiOperation("获取待签收任务") - @Authorize(merge = false) - public ResponseMessage> getClaims(QueryParamEntity query, Authentication authentication) { - TaskQuery taskQuery = taskService.createTaskQuery(); - - taskQuery.taskCandidateUser(authentication.getUser().getId()); - - PagerResult result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of); - - return ResponseMessage.ok(result); - } - - @GetMapping("/claims-and-todo") - @ApiOperation("获取待签收和待处理的任务") - @Authorize(merge = false) - public ResponseMessage> getClaimsAndTodo(QueryParamEntity query, Authentication authentication) { - TaskQuery taskQuery = taskService.createTaskQuery(); - - taskQuery.taskCandidateOrAssigned(authentication.getUser().getId()); - - PagerResult result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of); - - return ResponseMessage.ok(result); - } - - @PutMapping("/claim/{taskId}") - @ApiOperation("签收任务") - @Authorize(merge = false) - public ResponseMessage claim(@PathVariable String taskId, Authentication authentication) { - bpmTaskService.claim(taskId, authentication.getUser().getId()); - return ResponseMessage.ok(); - } - - @PutMapping("/complete/{taskId}") - @Authorize(merge = false) - public ResponseMessage complete(@PathVariable String taskId, - @RequestBody(required = false) Map formData, - Authentication authentication) { - // 办理 - bpmTaskService.complete(CompleteTaskRequest.builder() - .taskId(taskId) - .completeUserId(authentication.getUser().getId()) - .completeUserName(authentication.getUser().getName()) - .formData(formData) - .build()); - return ResponseMessage.ok(); - } - - @PutMapping("/reject/{taskId}") - @Authorize(merge = false) - @ApiOperation("驳回") - public ResponseMessage reject(@PathVariable String taskId, - @RequestBody Map data, - Authentication authentication) { - // 驳回 - bpmTaskService.reject(RejectTaskRequest.builder() - .taskId(taskId) - .rejectUserId(authentication.getUser().getId()) - .rejectUserName(authentication.getUser().getName()) - .data(data) - .build()); - return ResponseMessage.ok(); - } - - @PutMapping("/jump/{taskId}/{activityId}") - @Authorize(merge = false) - @ApiOperation("流程跳转") - public ResponseMessage jump(@PathVariable String taskId, - @PathVariable String activityId, - @RequestBody Map data, - Authentication authentication) { - // 流程跳转 - bpmTaskService.jumpTask(JumpTaskRequest - .builder() - .taskId(taskId) - .targetActivityId(activityId) - .recordLog(true) - .jumpUserId(authentication.getUser().getId()) - .jumpUserName(authentication.getUser().getUsername()) - .data(data) - .build()); - return ResponseMessage.ok(); - } - - @PostMapping("/next-task-candidate/{taskId}") - @Authorize(merge = false) - public ResponseMessage> candidateList(@PathVariable String taskId, - @RequestBody Map data, - Authentication authentication) { - - Task task = taskService.createTaskQuery() - .taskId(taskId) - .singleResult(); - - ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery() - .processInstanceId(task.getProcessInstanceId()) - .activityId(task.getTaskDefinitionKey()) - .singleResult(); - - execution.setTransientVariables(data); - - List taskDefinitions = bpmActivityService - .getNextActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey(), (execution)); - - List candidates = taskDefinitions.stream().map(TaskDefinition::getKey) - .flatMap(key -> - processConfigurationService - .getActivityConfiguration(authentication.getUser().getId(), task.getProcessDefinitionId(), key) - .getCandidateInfo(task) - .stream()) - .distinct() - .map(CandidateDetail::of) - .collect(Collectors.toList()); - - - return ResponseMessage.ok(candidates); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessActivityConfigController.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessActivityConfigController.java deleted file mode 100644 index 6290db132..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessActivityConfigController.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.hswebframework.web.workflow.web; - -import io.swagger.annotations.Api; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.TaskService; -import org.activiti.engine.task.Task; -import org.hswebframework.web.authorization.Authentication; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.controller.message.ResponseMessage; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.workflow.dao.entity.ActivityConfigEntity; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; -import org.hswebframework.web.workflow.service.ActivityConfigService; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -import org.hswebframework.web.workflow.service.config.CandidateInfo; -import org.hswebframework.web.workflow.service.config.ProcessConfigurationService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@RestController -@RequestMapping("/workflow/process/configuration/activity") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -@Api(tags = "工作流-流程定义-环节配置") -public class ProcessActivityConfigController - implements SimpleGenericEntityController { - @Autowired - private ActivityConfigService service; - - @Override - public CrudService getService() { - return service; - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessDefineConfigController.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessDefineConfigController.java deleted file mode 100644 index 35d5c9a4a..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/ProcessDefineConfigController.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.hswebframework.web.workflow.web; - -import io.swagger.annotations.Api; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.service.CrudService; -import org.hswebframework.web.workflow.dao.entity.ProcessDefineConfigEntity; -import org.hswebframework.web.workflow.service.ProcessDefineConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@RestController -@RequestMapping("/workflow/process/configuration/definition") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -@Api(tags = "工作流-流程定义-流程配置") -public class ProcessDefineConfigController - implements SimpleGenericEntityController { - @Autowired - private ProcessDefineConfigService service; - - @Override - public CrudService getService() { - return service; - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/BaseProcessDefinitionDiagramLayoutResource.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/BaseProcessDefinitionDiagramLayoutResource.java deleted file mode 100644 index 39d6de241..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/BaseProcessDefinitionDiagramLayoutResource.java +++ /dev/null @@ -1,498 +0,0 @@ -/* 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.workflow.web.diagram; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.ActivitiObjectNotFoundException; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior; -import org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior; -import org.activiti.engine.impl.bpmn.parser.BpmnParse; -import org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition; -import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration; -import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl; -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.delegate.ActivityBehavior; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.pvm.process.Lane; -import org.activiti.engine.impl.pvm.process.LaneSet; -import org.activiti.engine.impl.pvm.process.ParticipantProcess; -import org.activiti.engine.impl.pvm.process.TransitionImpl; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Execution; -import org.activiti.engine.runtime.ProcessInstance; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; - -public class BaseProcessDefinitionDiagramLayoutResource { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private HistoryService historyService; - - public Map getDiagramNode(String processInstanceId, String processDefinitionId) { - - List highLightedFlows = Collections.emptyList(); - List highLightedActivities; - - Map subProcessInstanceMap = new HashMap<>(); - - ProcessInstance processInstance = null; - if (processInstanceId != null) { - processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - if (processInstance == null) { - throw new ActivitiObjectNotFoundException("Process instance could not be found"); - } - processDefinitionId = processInstance.getProcessDefinitionId(); - - List subProcessInstances = runtimeService - .createProcessInstanceQuery() - .superProcessInstanceId(processInstanceId).list(); - - for (ProcessInstance subProcessInstance : subProcessInstances) { - String subDefId = subProcessInstance.getProcessDefinitionId(); - - String superExecutionId = (subProcessInstance).getSuperExecutionId(); - ProcessDefinitionEntity subDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(subDefId); - - JSONObject processInstanceJSON = new JSONObject(); - processInstanceJSON.put("processInstanceId", subProcessInstance.getId()); - processInstanceJSON.put("superExecutionId", superExecutionId); - processInstanceJSON.put("processDefinitionId", subDef.getId()); - processInstanceJSON.put("processDefinitionKey", subDef.getKey()); - processInstanceJSON.put("processDefinitionName", subDef.getName()); - - subProcessInstanceMap.put(superExecutionId, processInstanceJSON); - } - } - - if (processDefinitionId == null) { - throw new ActivitiObjectNotFoundException("No process definition id provided"); - } - - ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId); - - if (processDefinition == null) { - throw new ActivitiException("Process definition " + processDefinitionId + " could not be found"); - } - - JSONObject responseJSON = new JSONObject(); - - // Process definition - Map pdrJSON = getProcessDefinitionResponse(processDefinition); - - if (pdrJSON != null) { - responseJSON.put("processDefinition", pdrJSON); - } - - // Highlighted activities - if (processInstance != null) { - JSONArray activityArray = new JSONArray(); - JSONArray flowsArray = new JSONArray(); - - highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - highLightedFlows = getHighLightedFlows(processInstanceId, processDefinition); - - for (String activityName : highLightedActivities) { - activityArray.add(activityName); - } - - for (String flow : highLightedFlows) - flowsArray.add(flow); - - responseJSON.put("highLightedActivities", activityArray); - responseJSON.put("highLightedFlows", flowsArray); - } - - // Pool shape, if process is participant in collaboration - if (processDefinition.getParticipantProcess() != null) { - ParticipantProcess pProc = processDefinition.getParticipantProcess(); - - JSONObject participantProcessJSON = new JSONObject(); - participantProcessJSON.put("id", pProc.getId()); - if (StringUtils.isNotEmpty(pProc.getName())) { - participantProcessJSON.put("name", pProc.getName()); - } else { - participantProcessJSON.put("name", ""); - } - participantProcessJSON.put("x", pProc.getX()); - participantProcessJSON.put("y", pProc.getY()); - participantProcessJSON.put("width", pProc.getWidth()); - participantProcessJSON.put("height", pProc.getHeight()); - - responseJSON.put("participantProcess", participantProcessJSON); - } - - // Draw lanes - - if (processDefinition.getLaneSets() != null && !processDefinition.getLaneSets().isEmpty()) { - JSONArray laneSetArray = new JSONArray(); - for (LaneSet laneSet : processDefinition.getLaneSets()) { - JSONArray laneArray = new JSONArray(); - if (laneSet.getLanes() != null && !laneSet.getLanes().isEmpty()) { - for (Lane lane : laneSet.getLanes()) { - JSONObject laneJSON = new JSONObject(); - laneJSON.put("id", lane.getId()); - if (StringUtils.isNotEmpty(lane.getName())) { - laneJSON.put("name", lane.getName()); - } else { - laneJSON.put("name", ""); - } - laneJSON.put("x", lane.getX()); - laneJSON.put("y", lane.getY()); - laneJSON.put("width", lane.getWidth()); - laneJSON.put("height", lane.getHeight()); - - List flowNodeIds = lane.getFlowNodeIds(); - JSONArray flowNodeIdsArray = new JSONArray(); - for (String flowNodeId : flowNodeIds) { - flowNodeIdsArray.add(flowNodeId); - } - laneJSON.put("flowNodeIds", flowNodeIdsArray); - - laneArray.add(laneJSON); - } - } - JSONObject laneSetJSON = new JSONObject(); - laneSetJSON.put("id", laneSet.getId()); - if (StringUtils.isNotEmpty(laneSet.getName())) { - laneSetJSON.put("name", laneSet.getName()); - } else { - laneSetJSON.put("name", ""); - } - laneSetJSON.put("lanes", laneArray); - - laneSetArray.add(laneSetJSON); - } - - if (laneSetArray.size() > 0) - responseJSON.put("laneSets", laneSetArray); - } - - JSONArray sequenceFlowArray = new JSONArray(); - JSONArray activityArray = new JSONArray(); - - // Activities and their sequence-flows - - for (ActivityImpl activity : processDefinition.getActivities()) { - getActivity(processInstanceId, activity, activityArray, sequenceFlowArray, - processInstance, highLightedFlows, subProcessInstanceMap); - } - - responseJSON.put("activities", activityArray); - responseJSON.put("sequenceFlows", sequenceFlowArray); - - return responseJSON; - } - - private List getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) { - - List highLightedFlows = new ArrayList(); - List historicActivityInstances = historyService - .createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .orderByHistoricActivityInstanceStartTime().asc().list(); - - List historicActivityInstanceList = new ArrayList(); - for (HistoricActivityInstance hai : historicActivityInstances) { - historicActivityInstanceList.add(hai.getActivityId()); - } - - // add current activities to list - List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - historicActivityInstanceList.addAll(highLightedActivities); - - // activities and their sequence-flows - for (ActivityImpl activity : processDefinition.getActivities()) { - int index = historicActivityInstanceList.indexOf(activity.getId()); - - if (index >= 0 && index + 1 < historicActivityInstanceList.size()) { - List pvmTransitionList = activity - .getOutgoingTransitions(); - for (PvmTransition pvmTransition : pvmTransitionList) { - String destinationFlowId = pvmTransition.getDestination().getId(); - if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) { - highLightedFlows.add(pvmTransition.getId()); - } - } - } - } - return highLightedFlows; - } - - private void getActivity(String processInstanceId, ActivityImpl activity, List activityArray, - List sequenceFlowArray, ProcessInstance processInstance, List highLightedFlows, - Map subProcessInstanceMap) { - - JSONObject activityJSON = new JSONObject(); - - // Gather info on the multi instance marker - String multiInstance = (String) activity.getProperty("multiInstance"); - if (multiInstance != null) { - if (!"sequential".equals(multiInstance)) { - multiInstance = "parallel"; - } - } - - ActivityBehavior activityBehavior = activity.getActivityBehavior(); - // Gather info on the collapsed marker - Boolean collapsed = (activityBehavior instanceof CallActivityBehavior); - Boolean expanded = (Boolean) activity.getProperty(BpmnParse.PROPERTYNAME_ISEXPANDED); - if (expanded != null) { - collapsed = !expanded; - } - - Boolean isInterrupting = null; - if (activityBehavior instanceof BoundaryEventActivityBehavior) { - isInterrupting = ((BoundaryEventActivityBehavior) activityBehavior).isInterrupting(); - } - - // Outgoing transitions of activity - for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) { - String flowName = (String) sequenceFlow.getProperty("name"); - boolean isHighLighted = (highLightedFlows.contains(sequenceFlow.getId())); - boolean isConditional = sequenceFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION) != null && - !((String) activity.getProperty("type")).toLowerCase().contains("gateway"); - boolean isDefault = sequenceFlow.getId().equals(activity.getProperty("default")) - && ((String) activity.getProperty("type")).toLowerCase().contains("gateway"); - - List waypoints = ((TransitionImpl) sequenceFlow).getWaypoints(); - JSONArray xPointArray = new JSONArray(); - JSONArray yPointArray = new JSONArray(); - for (int i = 0; i < waypoints.size(); i += 2) { // waypoints.size() - // minimally 4: x1, y1, - // x2, y2 - xPointArray.add(waypoints.get(i)); - yPointArray.add(waypoints.get(i + 1)); - } - - JSONObject flowJSON = new JSONObject(); - flowJSON.put("id", sequenceFlow.getId()); - flowJSON.put("name", flowName); - flowJSON.put("flow", "(" + sequenceFlow.getSource().getId() + ")--" - + sequenceFlow.getId() + "-->(" - + sequenceFlow.getDestination().getId() + ")"); - - if (isConditional) - flowJSON.put("isConditional", isConditional); - if (isDefault) - flowJSON.put("isDefault", isDefault); - if (isHighLighted) - flowJSON.put("isHighLighted", isHighLighted); - - flowJSON.put("xPointArray", xPointArray); - flowJSON.put("yPointArray", yPointArray); - - sequenceFlowArray.add(flowJSON); - } - - // Nested activities (boundary events) - JSONArray nestedActivityArray = new JSONArray(); - for (ActivityImpl nestedActivity : activity.getActivities()) { - nestedActivityArray.add(nestedActivity.getId()); - } - - Map properties = activity.getProperties(); - JSONObject propertiesJSON = new JSONObject(); - for (String key : properties.keySet()) { - Object prop = properties.get(key); - if (prop instanceof String) - propertiesJSON.put(key, properties.get(key)); - else if (prop instanceof Integer) - propertiesJSON.put(key, properties.get(key)); - else if (prop instanceof Boolean) - propertiesJSON.put(key, properties.get(key)); - else if ("initial".equals(key)) { - ActivityImpl act = (ActivityImpl) properties.get(key); - propertiesJSON.put(key, act.getId()); - } else if ("timerDeclarations".equals(key)) { - ArrayList timerDeclarations = (ArrayList) properties.get(key); - JSONArray timerDeclarationArray = new JSONArray(); - - if (timerDeclarations != null) - for (TimerDeclarationImpl timerDeclaration : timerDeclarations) { - JSONObject timerDeclarationJSON = new JSONObject(); - - timerDeclarationJSON.put("isExclusive", timerDeclaration.isExclusive()); - if (timerDeclaration.getRepeat() != null) - timerDeclarationJSON.put("repeat", timerDeclaration.getRepeat()); - - timerDeclarationJSON.put("retries", String.valueOf(timerDeclaration.getRetries())); - timerDeclarationJSON.put("type", timerDeclaration.getJobHandlerType()); - timerDeclarationJSON.put("configuration", timerDeclaration.getJobHandlerConfiguration()); - //timerDeclarationJSON.put("expression", timerDeclaration.getDescription()); - - timerDeclarationArray.add(timerDeclarationJSON); - } - if (timerDeclarationArray.size() > 0) - propertiesJSON.put(key, timerDeclarationArray); - // TODO: implement getting description - } else if ("eventDefinitions".equals(key)) { - ArrayList eventDefinitions = (ArrayList) properties.get(key); - JSONArray eventDefinitionsArray = new JSONArray(); - - if (eventDefinitions != null) { - for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) { - JSONObject eventDefinitionJSON = new JSONObject(); - - if (eventDefinition.getActivityId() != null) - eventDefinitionJSON.put("activityId", eventDefinition.getActivityId()); - - eventDefinitionJSON.put("eventName", eventDefinition.getEventName()); - eventDefinitionJSON.put("eventType", eventDefinition.getEventType()); - eventDefinitionJSON.put("isAsync", eventDefinition.isAsync()); - eventDefinitionJSON.put("isStartEvent", eventDefinition.isStartEvent()); - eventDefinitionsArray.add(eventDefinitionJSON); - } - } - - if (eventDefinitionsArray.size() > 0) - propertiesJSON.put(key, eventDefinitionsArray); - - // TODO: implement it - } else if ("errorEventDefinitions".equals(key)) { - ArrayList errorEventDefinitions = (ArrayList) properties.get(key); - JSONArray errorEventDefinitionsArray = new JSONArray(); - - if (errorEventDefinitions != null) { - for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) { - JSONObject errorEventDefinitionJSON = new JSONObject(); - - if (errorEventDefinition.getErrorCode() != null) - errorEventDefinitionJSON.put("errorCode", errorEventDefinition.getErrorCode()); - else - errorEventDefinitionJSON.put("errorCode",null); - - errorEventDefinitionJSON.put("handlerActivityId", - errorEventDefinition.getHandlerActivityId()); - - errorEventDefinitionsArray.add(errorEventDefinitionJSON); - } - } - - if (errorEventDefinitionsArray.size() > 0) - propertiesJSON.put(key, errorEventDefinitionsArray); - } - - } - - if ("callActivity".equals(properties.get("type"))) { - CallActivityBehavior callActivityBehavior = null; - - if (activityBehavior instanceof CallActivityBehavior) { - callActivityBehavior = (CallActivityBehavior) activityBehavior; - } - - if (callActivityBehavior != null) { - propertiesJSON.put("processDefinitonKey", callActivityBehavior.getProcessDefinitonKey()); - - // get processDefinitonId from execution or get last processDefinitonId - // by key - JSONArray processInstanceArray = new JSONArray(); - if (processInstance != null) { - List executionList = runtimeService.createExecutionQuery() - .processInstanceId(processInstanceId) - .activityId(activity.getId()).list(); - if (!executionList.isEmpty()) { - for (Execution execution : executionList) { - processInstanceArray.add(subProcessInstanceMap.get(execution.getId())); - } - } - } - - // If active activities nas no instance of this callActivity then add - // last definition - if (processInstanceArray.size() == 0 && StringUtils.isNotEmpty(callActivityBehavior.getProcessDefinitonKey())) { - // Get last definition by key - ProcessDefinition lastProcessDefinition = repositoryService - .createProcessDefinitionQuery() - .processDefinitionKey(callActivityBehavior.getProcessDefinitonKey()) - .latestVersion().singleResult(); - - // TODO: unuseful fields there are processDefinitionName, processDefinitionKey - if (lastProcessDefinition != null) { - JSONObject processInstanceJSON = new JSONObject(); - processInstanceJSON.put("processDefinitionId", lastProcessDefinition.getId()); - processInstanceJSON.put("processDefinitionKey", lastProcessDefinition.getKey()); - processInstanceJSON.put("processDefinitionName", lastProcessDefinition.getName()); - processInstanceArray.add(processInstanceJSON); - } - } - - if (processInstanceArray.size() > 0) { - propertiesJSON.put("processDefinitons", processInstanceArray); - } - } - } - - activityJSON.put("activityId", activity.getId()); - activityJSON.put("properties", propertiesJSON); - if (multiInstance != null) - activityJSON.put("multiInstance", multiInstance); - if (collapsed) - activityJSON.put("collapsed", collapsed); - if (nestedActivityArray.size() > 0) - activityJSON.put("nestedActivities", nestedActivityArray); - if (isInterrupting != null) - activityJSON.put("isInterrupting", isInterrupting); - - activityJSON.put("x", activity.getX()); - activityJSON.put("y", activity.getY()); - activityJSON.put("width", activity.getWidth()); - activityJSON.put("height", activity.getHeight()); - - activityArray.add(activityJSON); - - // Nested activities (boundary events) - for (ActivityImpl nestedActivity : activity.getActivities()) { - getActivity(processInstanceId, nestedActivity, activityArray, sequenceFlowArray, - processInstance, highLightedFlows, subProcessInstanceMap); - } - } - - private Map getProcessDefinitionResponse(ProcessDefinitionEntity processDefinition) { - JSONObject pdrJSON = new JSONObject(); - pdrJSON.put("id", processDefinition.getId()); - pdrJSON.put("name", processDefinition.getName()); - pdrJSON.put("key", processDefinition.getKey()); - pdrJSON.put("version", processDefinition.getVersion()); - pdrJSON.put("deploymentId", processDefinition.getDeploymentId()); - pdrJSON.put("isGraphicNotationDefined", isGraphicNotationDefined(processDefinition)); - return pdrJSON; - } - - private boolean isGraphicNotationDefined(ProcessDefinitionEntity processDefinition) { - return ((ProcessDefinitionEntity) repositoryService - .getProcessDefinition(processDefinition.getId())) - .isGraphicalNotationDefined(); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessDefinitionDiagramLayoutResource.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessDefinitionDiagramLayoutResource.java deleted file mode 100644 index 019ae2a7a..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessDefinitionDiagramLayoutResource.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.hswebframework.web.workflow.web.diagram; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@RestController -@RequestMapping("/workflow/service/") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -public class ProcessDefinitionDiagramLayoutResource - extends BaseProcessDefinitionDiagramLayoutResource { - - @GetMapping( - value = {"/process-definition/{processDefinitionId}/diagram-layout"}, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE - ) - public Object getDiagram(@PathVariable String processDefinitionId) { - return this.getDiagramNode(null, processDefinitionId); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceDiagramLayoutResource.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceDiagramLayoutResource.java deleted file mode 100644 index 004b63121..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceDiagramLayoutResource.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.hswebframework.web.workflow.web.diagram; - -import org.hswebframework.web.authorization.annotation.Authorize; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@RestController -@RequestMapping("/workflow/service/") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -public class ProcessInstanceDiagramLayoutResource - extends BaseProcessDefinitionDiagramLayoutResource -{ - - - @GetMapping( - value = {"/process-instance/{processInstanceId}/diagram-layout"}, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE - ) - public Object getDiagram(@PathVariable String processInstanceId) { - return this.getDiagramNode(processInstanceId, null); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceHighlightsResource.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceHighlightsResource.java deleted file mode 100644 index d6538e062..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/diagram/ProcessInstanceHighlightsResource.java +++ /dev/null @@ -1,259 +0,0 @@ -/* 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.workflow.web.diagram; - -import java.util.*; -import java.util.stream.Collectors; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.history.HistoricActivityInstanceQuery; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.runtime.ProcessInstance; -import org.hswebframework.web.authorization.annotation.Authorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - - -@RestController -@RequestMapping("/workflow/service") -@Authorize(permission = "workflow-definition", description = "工作流-流程定义管理") -public class ProcessInstanceHighlightsResource { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private HistoryService historyService; - - - @GetMapping(value = "/process-instance/{processInstanceId}/highlights", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Object getHighlighted(@PathVariable String processInstanceId) { - - JSONObject responseJSON = new JSONObject(); - - responseJSON.put("processInstanceId", processInstanceId); - - JSONArray activitiesArray = new JSONArray(); - JSONArray flowsArray = new JSONArray(); - - HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(processInstanceId) - .singleResult(); - ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService - .getProcessDefinition(processInstance.getProcessDefinitionId()); - - responseJSON.put("processDefinitionId", processInstance.getProcessDefinitionId()); - List highLightedActivities; - if (processInstance.getEndTime() != null) { - highLightedActivities = historyService - .createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .activityType("endEvent") - .list().stream().map(HistoricActivityInstance::getActivityId) - .collect(Collectors.toList()); - } else { - highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - } - List highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId); - - activitiesArray.addAll(highLightedActivities); - - flowsArray.addAll(highLightedFlows); - - - responseJSON.put("activities", activitiesArray); - responseJSON.put("flows", flowsArray); - - return responseJSON; - } - - - /** - * getHighLightedFlows - * - * @param processDefinition - * @param processInstanceId - * @return - */ - private List getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) { - - List highLightedFlows = new ArrayList(); - - List historicActivityInstances = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - //order by startime asc is not correct. use default order is correct. - //.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/ - .list(); - - LinkedList hisActInstList = new LinkedList(); - hisActInstList.addAll(historicActivityInstances); - - getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows); - - return highLightedFlows; - } - - /** - * getHighlightedFlows - *

- * code logic: - * 1. Loop all activities by id asc order; - * 2. Check each activity's outgoing transitions and eventBoundery outgoing transitions, if outgoing transitions's destination.id is in other executed activityIds, add this transition to highLightedFlows List; - * 3. But if activity is not a parallelGateway or inclusiveGateway, only choose the earliest flow. - * - * @param activityList - * @param hisActInstList - * @param highLightedFlows - */ - private void getHighlightedFlows(List activityList, LinkedList hisActInstList, List highLightedFlows) { - - //check out startEvents in activityList - List startEventActList = new ArrayList(); - Map activityMap = new HashMap(activityList.size()); - for (ActivityImpl activity : activityList) { - - activityMap.put(activity.getId(), activity); - - String actType = (String) activity.getProperty("type"); - if (actType != null && actType.toLowerCase().indexOf("startevent") >= 0) { - startEventActList.add(activity); - } - } - - //These codes is used to avoid a bug: - //ACT-1728 If the process instance was started by a callActivity, it will be not have the startEvent activity in ACT_HI_ACTINST table - //Code logic: - //Check the first activity if it is a startEvent, if not check out the startEvent's highlight outgoing flow. - HistoricActivityInstance firstHistActInst = hisActInstList.getFirst(); - String firstActType = (String) firstHistActInst.getActivityType(); - if (firstActType != null && firstActType.toLowerCase().indexOf("startevent") < 0) { - PvmTransition startTrans = getStartTransaction(startEventActList, firstHistActInst); - if (startTrans != null) { - highLightedFlows.add(startTrans.getId()); - } - } - - while (!hisActInstList.isEmpty()) { - HistoricActivityInstance histActInst = hisActInstList.removeFirst(); - ActivityImpl activity = activityMap.get(histActInst.getActivityId()); - if (activity != null) { - boolean isParallel = false; - String type = histActInst.getActivityType(); - if ("parallelGateway".equals(type) || "inclusiveGateway".equals(type)) { - isParallel = true; - } else if ("subProcess".equals(histActInst.getActivityType())) { - getHighlightedFlows(activity.getActivities(), hisActInstList, highLightedFlows); - } - - List allOutgoingTrans = new ArrayList(); - allOutgoingTrans.addAll(activity.getOutgoingTransitions()); - allOutgoingTrans.addAll(getBoundaryEventOutgoingTransitions(activity)); - List activityHighLightedFlowIds = getHighlightedFlows(allOutgoingTrans, hisActInstList, isParallel); - highLightedFlows.addAll(activityHighLightedFlowIds); - } - } - } - - /** - * Check out the outgoing transition connected to firstActInst from startEventActList - * - * @param startEventActList - * @param firstActInst - * @return - */ - private PvmTransition getStartTransaction(List startEventActList, HistoricActivityInstance firstActInst) { - for (ActivityImpl startEventAct : startEventActList) { - for (PvmTransition trans : startEventAct.getOutgoingTransitions()) { - if (trans.getDestination().getId().equals(firstActInst.getActivityId())) { - return trans; - } - } - } - return null; - } - - /** - * getBoundaryEventOutgoingTransitions - * - * @param activity - * @return - */ - private List getBoundaryEventOutgoingTransitions(ActivityImpl activity) { - List boundaryTrans = new ArrayList(); - for (ActivityImpl subActivity : activity.getActivities()) { - String type = (String) subActivity.getProperty("type"); - if (type != null && type.toLowerCase().indexOf("boundary") >= 0) { - boundaryTrans.addAll(subActivity.getOutgoingTransitions()); - } - } - return boundaryTrans; - } - - /** - * find out single activity's highlighted flowIds - * - * @param activity - * @param hisActInstList - * @param isExclusive if true only return one flowId(Such as exclusiveGateway, BoundaryEvent On Task) - * @return - */ - private List getHighlightedFlows(List pvmTransitionList, LinkedList hisActInstList, boolean isParallel) { - - List highLightedFlowIds = new ArrayList(); - - PvmTransition earliestTrans = null; - HistoricActivityInstance earliestHisActInst = null; - - for (PvmTransition pvmTransition : pvmTransitionList) { - - String destActId = pvmTransition.getDestination().getId(); - HistoricActivityInstance destHisActInst = findHisActInst(hisActInstList, destActId); - if (destHisActInst != null) { - if (isParallel) { - highLightedFlowIds.add(pvmTransition.getId()); - } else if (earliestHisActInst == null || (earliestHisActInst.getId().compareTo(destHisActInst.getId()) > 0)) { - earliestTrans = pvmTransition; - earliestHisActInst = destHisActInst; - } - } - } - - if ((!isParallel) && earliestTrans != null) { - highLightedFlowIds.add(earliestTrans.getId()); - } - - return highLightedFlowIds; - } - - private HistoricActivityInstance findHisActInst(LinkedList hisActInstList, String actId) { - for (HistoricActivityInstance hisActInst : hisActInstList) { - if (hisActInst.getActivityId().equals(actId)) { - return hisActInst; - } - } - return null; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/request/ModelCreateRequest.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/request/ModelCreateRequest.java deleted file mode 100644 index 00ba1685c..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/request/ModelCreateRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hswebframework.web.workflow.web.request; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.hibernate.validator.constraints.NotBlank; - -@Data -@ApiModel("工作流模型创建请求") -public class ModelCreateRequest { - - @ApiModelProperty(value = "模型标识",example = "test_model") - @NotBlank - private String key; - - @ApiModelProperty(value = "模型名称",example = "测试模型") - @NotBlank - private String name; - - @ApiModelProperty(value = "模型说明") - private String description; -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ActivityInfo.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ActivityInfo.java deleted file mode 100644 index 3729b499c..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ActivityInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.hswebframework.web.workflow.web.response; - -import lombok.Data; -import org.activiti.bpmn.model.Activity; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.hswebframework.web.commons.bean.Bean; - -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Data -public class ActivityInfo implements Bean { - private static final long serialVersionUID = -3273391092933844118L; - private String id; - - private int x = -1; - private int y = -1; - private int width = -1; - private int height = -1; - - private String processDefinitionId; - private String processDefinitionKey; - private String processDefinitionName; - - private Map properties; - - public static ActivityInfo of(ActivityImpl activity) { - ActivityInfo info = new ActivityInfo(); - info.copyFrom(activity); - info.setProcessDefinitionId(activity.getProcessDefinition().getId()); - info.setProcessDefinitionKey(activity.getProcessDefinition().getKey()); - info.setProcessDefinitionName(activity.getProcessDefinition().getName()); - return info; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/CandidateDetail.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/CandidateDetail.java deleted file mode 100644 index 691d5030b..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/CandidateDetail.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.hswebframework.web.workflow.web.response; - -import lombok.Getter; -import lombok.Setter; -import org.hswebframework.web.commons.bean.Bean; -import org.hswebframework.web.organizational.authorization.Position; -import org.hswebframework.web.workflow.service.config.CandidateInfo; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Getter -@Setter -public class CandidateDetail implements Bean { - - private static final long serialVersionUID = 7568237438666348299L; - - private String userId; - - private String personId; - - private String name; - - private List positions; - - public static CandidateDetail of(CandidateInfo candidateInfo) { - CandidateDetail detail = new CandidateDetail(); - - if (candidateInfo.user() != null) { - detail.setName(candidateInfo.user().getUser().getName()); - detail.setUserId(candidateInfo.user().getUser().getId()); - } - - if (candidateInfo.person() != null) { - detail.setPersonId(candidateInfo.person().getPersonnel().getId()); - detail.setName(candidateInfo.person().getPersonnel().getName()); - detail.setPositions(new ArrayList<>(candidateInfo.person().getPositions())); - } - - return detail; - } - - @Override - public int hashCode() { - return userId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CandidateDetail) { - return ((CandidateDetail) obj).getUserId().equals(userId); - } - return super.equals(obj); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessDefinitionInfo.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessDefinitionInfo.java deleted file mode 100644 index 8012febc3..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessDefinitionInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.hswebframework.web.workflow.web.response; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; -import org.activiti.engine.repository.ProcessDefinition; -import org.hswebframework.web.commons.bean.Bean; - -/** - * @author zhouhao - */ -@Data -public class ProcessDefinitionInfo implements Bean { - - private static final long serialVersionUID = -7246626050183062980L; - - private String id; - private String category; - private String name; - private String key; - private String description; - private int version; - private String resourceName; - private String deploymentId; - private String diagramResourceName; - private boolean suspended; - private boolean hasStartFormKey; - private boolean hasGraphicalNotation; - private String tenantId; - - public static ProcessDefinitionInfo of(ProcessDefinition definition) { - ProcessDefinitionInfo info = new ProcessDefinitionInfo(); - info.copyFrom(definition); - - info.hasGraphicalNotation = definition.hasGraphicalNotation(); - info.hasStartFormKey = definition.hasStartFormKey(); - return info; - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessInfo.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessInfo.java deleted file mode 100644 index f745db7ca..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/ProcessInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.hswebframework.web.workflow.web.response; - -import lombok.Data; -import org.activiti.engine.runtime.ProcessInstance; -import org.hswebframework.web.commons.bean.Bean; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Data -public class ProcessInfo implements Bean { - - private static final long serialVersionUID = 6903869441158752614L; - - private String id; - - private String processDefinitionId; - - private String processDefinitionKey; - - private String processDefinitionName; - - private Integer processDefinitionVersion; - - private String deploymentId; - - private String activityId; - - private String activityName; - - private String processInstanceId; - - private String businessKey; - - private String parentId; - - private boolean suspended; - - public static ProcessInfo of(ProcessInstance processInstance) { - ProcessInfo info = new ProcessInfo(); - info.copyFrom(processInstance); - info.suspended = processInstance.isSuspended(); - return info; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/TaskInfo.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/TaskInfo.java deleted file mode 100644 index 25f5863f9..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/web/response/TaskInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.hswebframework.web.workflow.web.response; - -import lombok.Data; -import org.hswebframework.web.commons.bean.Bean; - -import java.util.Date; -import java.util.Map; - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@Data -public class TaskInfo implements Bean { - - private static final long serialVersionUID = 8648745689340116922L; - private String id; - private int revision; - private String owner; - private String assignee; - private String initialAssignee; - private String parentTaskId; - private String name; - private String localizedName; - private String description; - private String localizedDescription; - private int priority; - private Date createTime; - private Date dueDate; - private int suspensionState; - private String category; - private String executionId; - private String processInstanceId; - private String processDefinitionId; - private String taskDefinitionKey; - private String formKey; - private String eventName; - - public static TaskInfo of(org.activiti.engine.task.TaskInfo task) { - TaskInfo taskInfo = new TaskInfo(); - taskInfo.copyFrom(task); - return taskInfo; - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/hsweb-starter.js b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/hsweb-starter.js deleted file mode 100644 index 8da9c114a..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/hsweb-starter.js +++ /dev/null @@ -1,92 +0,0 @@ -//组件信息 -var info = { - groupId: "${project.groupId}", - artifactId: "${project.artifactId}", - version: "${project.version}", - website: "https://github.com/hs-web/hsweb-framework", - author: "admin@hsweb.me", - comment: "" -}; - -//版本更新信息 -var versions = [ - // { - // version: "3.0.2", - // upgrade: function (context) { - // java.lang.System.out.println("更新到3.0.2了"); - // } - // } -]; -var JDBCType = java.sql.JDBCType; - -function install(context) { - var database = context.database; - database.createOrAlter("s_wf_proc_conf") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("proc_def_key").alias("processDefineKey").comment("模板定义KEY").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("proc_def_id").alias("processDefineId").comment("模板定义ID").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("form_id").alias("formId").comment("表单ID").length(32).jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("permission_dimension").alias("permissionDimension").comment("启动权限配置").jdbcType(java.sql.JDBCType.CLOB).length(32).commit() - .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").datetime().commit() - .addColumn().name("update_time").alias("updateTime").comment("修改时间").datetime().commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.TINYINT).commit() - .addColumn().name("listeners").alias("listeners").comment("监听器配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .index().name("idx_proc_def_key").column("proc_def_key").commit() - .index().name("idx_proc_def_id").column("proc_def_id").commit() - - .comment("工作流流程自定义配置") - .commit(); - - database.createOrAlter("s_wf_act_conf") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("proc_def_key").alias("processDefineKey").comment("模板定义KEY").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("proc_def_id").alias("processDefineId").comment("模板定义ID").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("act_id").alias("activityId").comment("元图ID").jdbcType(java.sql.JDBCType.VARCHAR).length(64).commit() - .addColumn().name("form_id").alias("formId").comment("表单ID").length(32).jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("candidate_dimension").alias("candidateDimension").comment("候选人维度").jdbcType(java.sql.JDBCType.CLOB).length(32).commit() - .addColumn().name("create_time").alias("createTime").comment("创建时间").datetime().commit() - .addColumn().name("update_time").alias("updateTime").comment("修改时间").datetime().commit() - .addColumn().name("status").alias("status").comment("状态").jdbcType(java.sql.JDBCType.TINYINT).commit() - .addColumn().name("properties").alias("properties").comment("其他配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("listeners").alias("listeners").comment("监听器配置").jdbcType(java.sql.JDBCType.CLOB).commit() - .index().name("idx_act_proc_def_id").column("proc_def_id").commit() - .index().name("idx_act_proc_def_key").column("proc_def_key").commit() - - .comment("工作流环节自定义配置") - .commit(); - - database.createOrAlter("s_wf_proc_his") - .addColumn().name("u_id").alias("id").comment("ID").jdbcType(java.sql.JDBCType.VARCHAR).length(32).primaryKey().commit() - .addColumn().name("proc_ins_id").alias("processInstanceId").comment("流程实例ID").notNull().jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("proc_def_id").alias("processDefineId").comment("模板定义ID").notNull().jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("type").alias("type").comment("类型").notNull().jdbcType(java.sql.JDBCType.VARCHAR).length(32).commit() - .addColumn().name("type_text").alias("typeText").comment("类型说明").notNull().length(128).jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("task_id").alias("taskId").length(32).comment("任务ID").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("task_name").alias("taskName").length(32).comment("任务名称").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("task_def_key").alias("taskDefineKey").length(64).comment("任务定义KEY").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("biz_key").alias("businessKey").length(32).comment("业务主键").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("data").alias("data").comment("相关数据").jdbcType(java.sql.JDBCType.CLOB).commit() - .addColumn().name("create_time").alias("createTime").notNull().comment("创建时间").datetime().commit() - .addColumn().name("creator_id").alias("creatorId").length(32).notNull().comment("创建人ID").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .addColumn().name("creator_name").alias("creatorName").length(32).notNull().comment("创建人姓名").jdbcType(java.sql.JDBCType.VARCHAR).commit() - .index().name("idx_proc_his_def_id").column("proc_def_id").commit() - .index().name("idx_proc_his_ins_id").column("proc_ins_id").commit() - .index().name("idx_proc_his_task_id").column("task_id").commit() - .comment("工作流流程历史") - .commit(); -} - -//设置依赖 -dependency.setup(info) - .onInstall(install) - .onUpgrade(function (context) { //更新时执行 - var upgrader = context.upgrader; - upgrader.filter(versions) - .upgrade(function (newVer) { - newVer.upgrade(context); - }); - }) - .onUninstall(function (context) { //卸载时执行 - - }); \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ActivityConfigMapper.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ActivityConfigMapper.xml deleted file mode 100644 index cc2288795..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ActivityConfigMapper.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessDefineConfigMapper.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessDefineConfigMapper.xml deleted file mode 100644 index 8fd9f45b0..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessDefineConfigMapper.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessHistoryMapper.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessHistoryMapper.xml deleted file mode 100644 index 89ed9c5da..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/org/hswebframework/web/dao/mybatis/mappers/workflow/ProcessHistoryMapper.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - delete from ${_fullTableName} where u_id =#{id} - - - - - - - - - - - - - - - - diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/processes/README.md b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/resources/processes/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParserTest.groovy b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParserTest.groovy deleted file mode 100644 index 19a4c3ba1..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParserTest.groovy +++ /dev/null @@ -1,78 +0,0 @@ -package org.hswebframework.web.workflow.dimension - -import org.hswebframework.web.workflow.flowable.TestApplication -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import spock.lang.Specification - -/** - * @author zhouhao - * @since 3.0.0-RC - */ -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -class DefaultCandidateDimensionParserTest extends Specification { - - @Autowired - private CandidateDimensionParser parser; - - def "Test Parse User"() { - setup: - def config = """ {"dimension":"user","idList":["admin"]} """ - and: - def dimension = parser.parse(null,config) - expect: - dimension != null - dimension.getCandidateUserIdList() != null - !dimension.getCandidateUserIdList().isEmpty() - dimension.getCandidateUserIdList().get(0) == "admin" - } - - def "Test Parse Role"() { - setup: - def config = """ {"dimension":"role","idList":["admin"]} """ - and: - def dimension = parser.parse(null,config) - expect: - dimension != null - dimension.getCandidateUserIdList() != null - dimension != CandidateDimension.empty - } - - - def "Test Parse Position"() { - setup: - def config = """ {"dimension":"position","idList":["test"],"tree":"parent"} """ - and: - def dimension = parser.parse(null,config) - expect: - dimension != null - dimension.getCandidateUserIdList() != null - dimension != CandidateDimension.empty - } - - def "Test Parse Department"() { - setup: - def config = """ {"dimension":"department","idList":["test"]} """ - and: - def dimension = parser.parse(null,config) - expect: - dimension != null - dimension.getCandidateUserIdList() != null - dimension != CandidateDimension.empty - } - - def "Test Parse Org"() { - setup: - def config = """ {"dimension":"org","idList":["test"]} """ - and: - def dimension = parser.parse(null,config) - expect: - dimension != null - dimension.getCandidateUserIdList() != null - dimension != CandidateDimension.empty - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/TestApplication.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/TestApplication.java deleted file mode 100644 index fd44758f8..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/TestApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.workflow.flowable; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -/** - * @author zhouhao - */ -@SpringBootApplication -@ComponentScan("org.hswebframework.web.workflow") -public class TestApplication { - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowModelTests.groovy b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowModelTests.groovy deleted file mode 100644 index 3e0045055..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowModelTests.groovy +++ /dev/null @@ -1,64 +0,0 @@ -package org.hswebframework.web.workflow.flowable - -import com.alibaba.fastjson.JSON -import org.hswebframework.web.authorization.AuthenticationInitializeService -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import spock.lang.Shared -import spock.lang.Specification - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * @author zhouhao - * @since - */ -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -class WorkFlowModelTests extends Specification { - @Autowired - private ConfigurableApplicationContext context; - - @Shared - private MockMvc mockMvc; - - @Autowired - private AuthenticationInitializeService initializeService; - - void setup() { - mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); - } - - def "Add Model"() { - setup: - //添加模型 - def json = mockMvc.perform(post("/workflow/model/") - .contentType(MediaType.APPLICATION_JSON) - .content(""" - { - "key":"testModel", - "name":"测试模型" - } - """)) - .andExpect(status().is(201)) - .andReturn().getResponse().getContentAsString(); - println(json) - - and: - def jsonObject = JSON.parseObject(json) - def id = jsonObject.getJSONObject("result").getString("id"); - - expect: - jsonObject != null - id != null - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowProcessTests.groovy b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowProcessTests.groovy deleted file mode 100644 index 22e285141..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/java/org/hswebframework/web/workflow/flowable/WorkFlowProcessTests.groovy +++ /dev/null @@ -1,86 +0,0 @@ -package org.hswebframework.web.workflow.flowable - -import com.alibaba.fastjson.JSON -import org.activiti.engine.RuntimeService -import org.activiti.engine.TaskService -import org.activiti.engine.impl.persistence.entity.ExecutionEntity -import org.activiti.engine.runtime.ProcessInstance -import org.hswebframework.web.authorization.AuthenticationInitializeService -import org.hswebframework.web.workflow.service.BpmProcessService -import org.hswebframework.web.workflow.service.BpmTaskService -import org.hswebframework.web.workflow.service.request.CompleteTaskRequest -import org.hswebframework.web.workflow.service.request.StartProcessRequest -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.http.MediaType -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import spock.lang.Shared -import spock.lang.Specification - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * @author zhouhao - * @since - */ -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [TestApplication.class], properties = ["classpath:application.yml"]) -class WorkFlowProcessTests extends Specification { - @Autowired - private ConfigurableApplicationContext context; - - @Shared - private MockMvc mockMvc; - - @Autowired - private AuthenticationInitializeService initializeService; - - @Autowired - private BpmProcessService bpmProcessService; - - @Autowired - private BpmTaskService bpmTaskService; - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private TaskService taskService; - - void setup() { - mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); - } - - def "Start Process"() { - setup: - def request = new StartProcessRequest(); - request.setCreatorId("admin"); - request.setCreatorName("admin"); - request.setProcessDefineId("testid:1:4"); - request.setNextClaimUserId("admin") - and: - def instance = (ExecutionEntity) bpmProcessService.startProcessInstance(request); - expect: - instance != null - !instance.getTasks().isEmpty() - def taskId = instance.getTasks().get(0).getId(); - - bpmTaskService.claim(taskId, "admin"); - - bpmTaskService.complete(CompleteTaskRequest.builder() - .taskId(instance.getTasks().get(0).getId()) - .completeUserId("admin") - .completeUserName("admin") - .nextClaimUserId("admin") - .build()); - - - } - -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application-dev.yml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application-dev.yml deleted file mode 100644 index 8c124cc06..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application-dev.yml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - datasource: - url : jdbc:mysql://localhost:3306/hsweb?useSSL=false&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false - username : root - password : root - type: com.alibaba.druid.pool.DruidDataSource \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application.yml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application.yml deleted file mode 100644 index 7e8cff400..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/application.yml +++ /dev/null @@ -1,21 +0,0 @@ -spring: - aop: - auto: true - proxy-target-class: true - datasource: - url : jdbc:h2:file:./target/workflow-test - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - cache: - type: simple - -logging: - level: - org.flowable: debug - org.hswebframework.web: debug -# org.activiti: debug -mybatis: - dynamic-datasource: false -server: - port: 8088 \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/README.md b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/SimpleProcess.bpmn20.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/SimpleProcess.bpmn20.xml deleted file mode 100644 index fefd718f3..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/test/resources/processes/SimpleProcess.bpmn20.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/pom.xml b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/pom.xml deleted file mode 100644 index 840e69c4a..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - hsweb-system-workflow - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-workflow-starter - - - - - org.hswebframework.web - hsweb-system-workflow-local - ${project.version} - - - org.springframework.boot - spring-boot-starter - - - - - ch.qos.logback - logback-classic - test - - - mysql - mysql-connector-java - test - - - com.h2database - h2 - test - - - com.alibaba - druid - 1.0.26 - test - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-system-authorization-starter - ${project.version} - test - - - org.hswebframework.web - hsweb-system-organizational-starter - ${project.version} - test - - - - org.hswebframework.web - hsweb-tests - ${project.version} - test - - - - org.hswebframework.web - hsweb-system-dynamic-form-starter - ${project.version} - test - - - \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/java/org/hswebframework/web/workflow/starter/WorkFlowAutoConfiguration.java b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/java/org/hswebframework/web/workflow/starter/WorkFlowAutoConfiguration.java deleted file mode 100644 index 165a1355e..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/java/org/hswebframework/web/workflow/starter/WorkFlowAutoConfiguration.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.hswebframework.web.workflow.starter; - -import com.alibaba.fastjson.parser.ParserConfig; -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan("org.hswebframework.web.workflow") -public class WorkFlowAutoConfiguration implements CommandLineRunner { - - @Override - public void run(String... args) throws Exception { - ParserConfig.getGlobalInstance() - .addAccept("org.hswebframework.web.workflow.dao.entity"); - } -} diff --git a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/resources/META-INF/spring.factories b/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 94263a215..000000000 --- a/hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.workflow.starter.WorkFlowAutoConfiguration \ No newline at end of file diff --git a/hsweb-system/hsweb-system-workflow/pom.xml b/hsweb-system/hsweb-system-workflow/pom.xml deleted file mode 100644 index 4cf36739f..000000000 --- a/hsweb-system/hsweb-system-workflow/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - hsweb-system - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-system-workflow - pom - - 1.7 - 5.23.0 - - - hsweb-system-workflow-starter - hsweb-system-workflow-local - - - - \ No newline at end of file diff --git a/hsweb-tests/pom.xml b/hsweb-tests/pom.xml deleted file mode 100644 index e9c8748a4..000000000 --- a/hsweb-tests/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - hsweb-framework - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-tests - - - - - javax.servlet - javax.servlet-api - - - - org.glassfish - javax.el - - - - com.h2database - h2 - - - - com.alibaba - druid - 1.0.26 - - - - org.spockframework - spock-core - - - - org.spockframework - spock-spring - - - - com.athaydes - spock-reports - 1.2.13 - - - - org.hswebframework.web - hsweb-spring-boot-starter - ${project.version} - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-jdbc - - - junit - junit - compile - - - org.springframework.boot - spring-boot-starter-test - - - \ No newline at end of file diff --git a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecification.groovy b/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecification.groovy deleted file mode 100644 index 9bdb9480d..000000000 --- a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecification.groovy +++ /dev/null @@ -1,121 +0,0 @@ -package org.hswebframework.web.tests - -import com.alibaba.fastjson.JSON -import org.hswebframework.ezorm.core.dsl.Query -import org.hswebframework.web.WebUtil -import org.hswebframework.web.commons.entity.param.QueryParamEntity -import org.springframework.http.MediaType -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* - - -/** - * @author zhouhao - * @since 3.0.2 - */ -abstract class HswebCrudWebApiSpecification extends HswebSpecification { - - protected abstract String getBaseApi(); - - def doAddRequest(String requestBody) { - def response = mockMvc.perform(post(getBaseApi()) - .content(requestBody) - .contentType(MediaType.APPLICATION_JSON)) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doUpdateRequest(String id, String requestBody) { - def response = mockMvc.perform(put("${getBaseApi()}/{id}", id) - .content(requestBody) - .contentType(MediaType.APPLICATION_JSON)) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doDeleteRequest(String id) { - def response = mockMvc - .perform(delete("${getBaseApi()}/{id}", id)) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doGetRequest(String id) { - def response = mockMvc - .perform(get("${getBaseApi()}/{id}", id)) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - - Query createQuery() { - return Query.empty(new QueryParamEntity()); - } - - def doQueryRequest(Query query) { - MockHttpServletRequestBuilder get = get("${getBaseApi()}") - WebUtil.objectToHttpParameters(query.param) - .forEach({ k, v -> get.param(k, v) }) - def response = mockMvc - .perform(get) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doQueryByIdsRequest(String ids) { - def response = mockMvc - .perform(get("${getBaseApi()}/ids").param("ids", ids)) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doTotalRequest(Query query) { - MockHttpServletRequestBuilder get = get("${getBaseApi()}/total") - WebUtil.objectToHttpParameters(query.param) - .forEach({ k, v -> get.param(k, v) }) - - def response = mockMvc - .perform(get) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doCountRequest(Query query) { - MockHttpServletRequestBuilder get = get("${getBaseApi()}/count") - WebUtil.objectToHttpParameters(query.param) - .forEach({ k, v -> get.param(k, v) }) - def response = mockMvc - .perform(get) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } - - def doNoPagingRequest(Query query) { - MockHttpServletRequestBuilder get = get("${getBaseApi()}/no-paging") - WebUtil.objectToHttpParameters(query.param) - .forEach({ k, v -> get.param(k, v) }) - def response = mockMvc - .perform(get) - .andReturn() - .response - .contentAsString; - return JSON.parseObject(response); - } -} diff --git a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebSpecification.groovy b/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebSpecification.groovy deleted file mode 100644 index febd1df09..000000000 --- a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebSpecification.groovy +++ /dev/null @@ -1,36 +0,0 @@ -package org.hswebframework.web.tests - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.web.WebAppConfiguration -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.setup.MockMvcBuilders -import org.springframework.web.context.WebApplicationContext -import spock.lang.Shared -import spock.lang.Specification - -/** - * @author zhouhao - * @since 3.0.2 - */ -@WebAppConfiguration -@ContextConfiguration -@SpringBootTest(classes = [HswebTestApplication.class], properties = ["classpath:application.yml"]) -class HswebSpecification extends Specification { - @Autowired - protected WebApplicationContext context; - - @Shared - protected MockMvc mockMvc; - - void setup() { - mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); - } - - MockMvc getMock() { - return mockMvc; - } - -} diff --git a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebTestApplication.groovy b/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebTestApplication.groovy deleted file mode 100644 index 90455765c..000000000 --- a/hsweb-tests/src/main/groovy/org/hswebframework/web/tests/HswebTestApplication.groovy +++ /dev/null @@ -1,15 +0,0 @@ -package org.hswebframework.web.tests; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.web.WebAppConfiguration; - -/** - * @author zhouhao - * @since 3.0.2 - */ -@SpringBootApplication -@WebAppConfiguration -@Configuration -class HswebTestApplication { -} diff --git a/hsweb-tests/src/main/java/org/hswebframework/web/tests/SimpleWebApplicationTests.java b/hsweb-tests/src/main/java/org/hswebframework/web/tests/SimpleWebApplicationTests.java deleted file mode 100644 index 744af3caa..000000000 --- a/hsweb-tests/src/main/java/org/hswebframework/web/tests/SimpleWebApplicationTests.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * * Copyright 2019 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.tests; - -import org.hswebframework.ezorm.rdb.executor.SqlExecutor; -import org.hswebframework.web.commons.entity.factory.EntityFactory; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpSession; -import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; -import org.springframework.web.context.WebApplicationContext; - -import javax.annotation.Resource; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; - -/** - * 已弃用,请使用 {@link HswebSpecification} {@link HswebCrudWebApiSpecification } - * - * @author zhouhao - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SimpleWebApplicationTests.Config.class) -@Deprecated -public class SimpleWebApplicationTests extends AbstractTransactionalJUnit4SpringContextTests { - - protected MockMvc mvc; - @Resource - protected WebApplicationContext wac; - - protected MockHttpSession session; - - @Autowired - protected SqlExecutor sqlExecutor; - - @Autowired - protected EntityFactory entityFactory; - - @Before - public void setup() throws Exception { - this.mvc = webAppContextSetup(this.wac).build(); - this.session = new MockHttpSession(); - } - - private TestProcess test(MockHttpServletRequestBuilder builder) { - return new TestProcess() { - @Override - public TestProcess setUp(TestProcessSetUp testProcessSetUp) { - testProcessSetUp.setUp(builder); - return this; - } - - @Override - public TestResult exec() throws Exception { - return () -> mvc.perform(builder); - } - }; - } - - protected MockHttpServletRequestBuilder initDefaultSetting(MockHttpServletRequestBuilder builder) { - return builder.session(session).characterEncoding("UTF-8").contentType(MediaType.APPLICATION_JSON); - } - - protected TestProcess testGet(String api) throws Exception { - MockHttpServletRequestBuilder msrb = initDefaultSetting(get(api)); - return test(msrb); - } - - protected TestProcess testPost(String api) throws Exception { - MockHttpServletRequestBuilder msrb = initDefaultSetting(post(api)); - return test(msrb); - } - - protected TestProcess testDelete(String api) throws Exception { - MockHttpServletRequestBuilder msrb = initDefaultSetting(delete(api)); - return test(msrb); - } - - - protected TestProcess testPut(String api) throws Exception { - MockHttpServletRequestBuilder msrb = initDefaultSetting(put(api)); - return test(msrb); - } - - @Configuration - @SpringBootApplication - @WebAppConfiguration - public static class Config { - - } -} diff --git a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcess.java b/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcess.java deleted file mode 100644 index 651935f9e..000000000 --- a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcess.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.hswebframework.web.tests; - -public interface TestProcess { - TestProcess setUp(TestProcessSetUp testProcessSetUp); - - TestResult exec() throws Exception; - -} diff --git a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcessSetUp.java b/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcessSetUp.java deleted file mode 100644 index 3e56ab6ea..000000000 --- a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestProcessSetUp.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.hswebframework.web.tests; - -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; - -public interface TestProcessSetUp { - void setUp(MockHttpServletRequestBuilder requestBuilder); -} \ No newline at end of file diff --git a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestResult.java b/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestResult.java deleted file mode 100644 index 7aa5addbb..000000000 --- a/hsweb-tests/src/main/java/org/hswebframework/web/tests/TestResult.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.hswebframework.web.tests; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import org.springframework.test.web.servlet.ResultActions; - -/** - * @author zhouhao - * @TODO - */ -public interface TestResult { - ResultActions getResultActions() throws Exception; - - default String resultAsString() { - try { - return getResultActions().andReturn().getResponse().getContentAsString(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - default JSONObject resultAsJson() { - return JSON.parseObject(resultAsString()); - } - - default JSONArray resultAsJsonArray() { - return JSON.parseArray(resultAsString()); - } -} diff --git a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecificationTest.groovy b/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecificationTest.groovy deleted file mode 100644 index 82d8c681f..000000000 --- a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/HswebCrudWebApiSpecificationTest.groovy +++ /dev/null @@ -1,88 +0,0 @@ -package org.hswebframework.web.tests - -import com.alibaba.fastjson.JSONObject -import spock.lang.Specification - -/** - * @author zhouhao - * @since 3.0.2 - */ -class HswebCrudWebApiSpecificationTest extends HswebCrudWebApiSpecification { - - @Override - protected String getBaseApi() { - return "/test" - } - - def "测试初始化"() { - expect: - mockMvc != null - context != null - } - - def "测试新增"() { - given: - def response = doAddRequest(JSONObject.toJSONString([name: "test"])); - expect: - response != null - response.status == 200 || response.status == 201 - } - - def "测试修改"() { - given: - def response = doUpdateRequest("test", JSONObject.toJSONString([name: "test"])); - expect: - response != null - response.status == 200 - } - - def "测试删除"() { - given: - def response = doDeleteRequest("test"); - expect: - response != null - response.status == 200 - } - - def "测试查询"() { - given: - def response = doQueryRequest(createQuery().where("id", "1234")); - expect: - response != null - response.status == 200 - } - - def "测试根据id查询"() { - given: - def response = doGetRequest("1"); - expect: - response != null - response.status == 200 - } - - def "测试根据id集合查询"() { - given: - def response = doQueryByIdsRequest("1,2,3,4"); - expect: - response != null - response.status == 200 - } - - def "测试查询总数"() { - given: - def response = doCountRequest(createQuery().where("id", "1234")); - expect: - response != null - response.status == 200 - } - - - def "测试不分页查询"() { - given: - def response = doNoPagingRequest(createQuery().where("id", "1234")); - expect: - response != null - response.status == 200 - } - -} diff --git a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestController.java b/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestController.java deleted file mode 100644 index 647f5de88..000000000 --- a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestController.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.hswebframework.web.tests; - -import org.hswebframework.web.commons.entity.Entity; -import org.hswebframework.web.commons.entity.PagerResult; -import org.hswebframework.web.commons.entity.param.QueryParamEntity; -import org.hswebframework.web.controller.SimpleGenericEntityController; -import org.hswebframework.web.service.CrudService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Collections; -import java.util.List; - -/** - * @author zhouhao - * @since 3.0.2 - */ -@RestController -@RequestMapping("/test") -public class TestController implements SimpleGenericEntityController { - - @Override - public CrudService getService() { - return new CrudService() { - @Override - public TestEntity createEntity() { - return new TestEntity(); - } - - @Override - public Class getEntityInstanceType() { - return TestEntity.class; - } - - @Override - public TestEntity deleteByPk(String s) { - return new TestEntity(); - } - - @Override - public String insert(TestEntity data) { - return data.getId(); - } - - @Override - public PagerResult selectPager(Entity param) { - return PagerResult.empty(); - } - - @Override - public List select(Entity param) { - return Collections.emptyList(); - } - - @Override - public int count(Entity param) { - return 0; - } - - @Override - public TestEntity selectSingle(Entity param) { - return null; - } - - @Override - public TestEntity selectByPk(String id) { - return new TestEntity(); - } - - @Override - public List selectByPk(List id) { - return Collections.emptyList(); - } - - @Override - public List select() { - return Collections.emptyList(); - } - - @Override - public int count() { - return 0; - } - - @Override - public int updateByPk(String id, TestEntity data) { - return 0; - } - - @Override - public int updateByPk(List data) { - return 0; - } - - @Override - public String saveOrUpdate(TestEntity testEntity) { - return testEntity.getId(); - } - }; - } -} diff --git a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestEntity.java b/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestEntity.java deleted file mode 100644 index 244466453..000000000 --- a/hsweb-tests/src/test/groovy/org/hswebframework/web/tests/TestEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.hswebframework.web.tests; - -import org.hswebframework.web.commons.entity.SimpleGenericEntity; - -/** - * @author zhouhao - * @since 3.0.2 - */ -public class TestEntity extends SimpleGenericEntity { -} diff --git a/hsweb-tests/src/test/resources/application.yml b/hsweb-tests/src/test/resources/application.yml deleted file mode 100644 index 027075c17..000000000 --- a/hsweb-tests/src/test/resources/application.yml +++ /dev/null @@ -1,19 +0,0 @@ -spring: - aop: - auto: true - datasource: - url : jdbc:h2:mem:permission_test_mem - username : sa - password : - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name : org.h2.Driver -hsweb: - app: - name: 测试 - version: 3.0.0 - -logging: - level: - org.springframework: WARN - org.hswebframework: WARN - org.hswebframework.web: DEBUG \ No newline at end of file diff --git a/hsweb-thirdparty/README.md b/hsweb-thirdparty/README.md deleted file mode 100644 index d52b17f42..000000000 --- a/hsweb-thirdparty/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# 对一些第三方插件的封装 - -```bash ---------hsweb-thirdparty-ueditor # 百度ueditor的封装 - -``` \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/README.md b/hsweb-thirdparty/hsweb-thirdparty-ueditor/README.md deleted file mode 100644 index bab9a33b8..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# 百度UEditor - -对[百度UEditor](http://ueditor.baidu.com/website/)后台服务的封装 - -# 使用: - -在pom.xml引入模块: - -```xml - - - org.hswebframework.web - hsweb-thirdparty-ueditor - ${hsweb.framework.version} - - -``` - -⚠️ 注意: 此模块使用`hsweb-system-file-api`模块进行文件管理. -所以在使用此模块之前需要提供`hsweb-system-file-api`的实现模块. -你可以查看[hsweb-system-file](../../hsweb-system/hsweb-system-file)的文档进行引入. - -### 后端配置 - -在`src/main/resources` 下建立`ueditor-config.json`文件,此文件为ueditor的配置文件.例如: -[ueditor-config.json](https://github.com/hs-web/hsweb3-demo/blob/master/src/main/resources/ueditor-config.json) -你也可以参照[官方的配置](http://fex.baidu.com/ueditor/#server-config) - -### 前端配置 -修改`ueditor.config.js`中的配置项: `window.UEDITOR_CONFIG.serverUrl`. 例如: - -```js - /** - * 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。 - */ - window.UEDITOR_CONFIG = { - - // 服务器统一请求接口路径 - serverUrl: "/ueditor" - //** 更多配置项 - } -``` \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/pom.xml b/hsweb-thirdparty/hsweb-thirdparty-ueditor/pom.xml deleted file mode 100644 index 26eec574d..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - hsweb-thirdparty - org.hswebframework.web - 4.0.0-SNAPSHOT - ../pom.xml - - 4.0.0 - - hsweb-thirdparty-ueditor - - 对百度UEditor后台服务的拓展和封装 - - - - - org.hswebframework.web - hsweb-system-file-api - ${project.version} - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework - spring-webmvc - - - - javax.servlet - javax.servlet-api - provided - - - - commons-fileupload - commons-fileupload - 1.3.3 - true - - - - \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ActionEnter.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ActionEnter.java deleted file mode 100644 index 580492e25..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ActionEnter.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.baidu.ueditor; - -import com.baidu.ueditor.define.ActionMap; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.State; -import com.baidu.ueditor.hunter.FileManager; -import com.baidu.ueditor.hunter.ImageHunter; -import com.baidu.ueditor.upload.Uploader; - -import javax.servlet.http.HttpServletRequest; -import java.util.Map; - -public class ActionEnter { - - private HttpServletRequest request = null; - - private String rootPath = null; - private String contextPath = null; - - private String actionType = null; - - private ConfigManager configManager = null; - - public ActionEnter(HttpServletRequest request, String rootPath) { - - this.request = request; - this.rootPath = rootPath; - this.actionType = request.getParameter("action"); - this.contextPath = request.getContextPath(); - this.configManager = ConfigManager.getInstance(this.rootPath, this.contextPath, request.getRequestURI()); - } - - public String exec() { - - String callbackName = this.request.getParameter("callback"); - - if (callbackName != null) { - - if (!validCallbackName(callbackName)) { - return new BaseState(false, AppInfo.ILLEGAL).toJSONString(); - } - - return callbackName + "(" + this.invoke() + ");"; - - } else { - return this.invoke(); - } - - } - - public String invoke() { - - if (actionType == null || !ActionMap.mapping.containsKey(actionType)) { - return new BaseState(false, AppInfo.INVALID_ACTION).toJSONString(); - } - - if (this.configManager == null || !this.configManager.valid()) { - return new BaseState(false, AppInfo.CONFIG_ERROR).toJSONString(); - } - - State state = null; - - int actionCode = ActionMap.getType(this.actionType); - - Map conf ; - - switch (actionCode) { - - case ActionMap.CONFIG: - return this.configManager.getAllConfig().toString(); - - case ActionMap.UPLOAD_IMAGE: - case ActionMap.UPLOAD_SCRAWL: - case ActionMap.UPLOAD_VIDEO: - case ActionMap.UPLOAD_FILE: - conf = this.configManager.getConfig(actionCode); - state = new Uploader(request, conf).doExec(); - break; - - case ActionMap.CATCH_IMAGE: - conf = configManager.getConfig(actionCode); - String[] list = this.request.getParameterValues((String) conf.get("fieldName")); - state = new ImageHunter(conf).capture(list); - break; - - case ActionMap.LIST_IMAGE: - case ActionMap.LIST_FILE: - conf = configManager.getConfig(actionCode); - int start = this.getStartIndex(); - state = new FileManager(conf).listFile(start); - break; - - } - - return state == null ? "{}" : state.toJSONString(); - - } - - public int getStartIndex() { - - String start = this.request.getParameter("start"); - - try { - return Integer.parseInt(start); - } catch (Exception e) { - return 0; - } - - } - - /** - * callback参数验证 - */ - public boolean validCallbackName(String name) { - - return name.matches("^[a-zA-Z_]+[\\w0-9_]*$"); - - } - -} \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ConfigManager.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ConfigManager.java deleted file mode 100644 index 325ae8b0e..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/ConfigManager.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.baidu.ueditor; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.baidu.ueditor.define.ActionMap; -import lombok.extern.slf4j.Slf4j; -import org.hswebframework.utils.file.FileUtils; - -import java.io.*; -import java.util.*; - -/** - * 配置管理器 - * - * @author hancong03@baidu.com - */ -@Slf4j -public final class ConfigManager { - - private final String rootPath; - private static final String configFileName = "ueditor-config.json"; - private JSONObject jsonConfig = null; - // 涂鸦上传filename定义 - private final static String SCRAWL_FILE_NAME = "scrawl"; - // 远程图片抓取filename定义 - private final static String REMOTE_FILE_NAME = "remote"; - - /* - * 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件 - */ - private ConfigManager(String rootPath, String contextPath, String uri) throws IOException { - - - rootPath = rootPath.replace("\\", "/"); - this.rootPath = rootPath; - this.initEnv(); - } - - /** - * 配置管理器构造工厂 - * - * @param rootPath 服务器根路径 - * @param contextPath 服务器所在项目路径 - * @param uri 当前访问的uri - * @return 配置管理器实例或者null - */ - public static ConfigManager getInstance(String rootPath, String contextPath, String uri) { - - try { - return new ConfigManager(rootPath, contextPath, uri); - } catch (Exception e) { - return null; - } - - } - - // 验证配置文件加载是否正确 - public boolean valid() { - return this.jsonConfig != null; - } - - public JSONObject getAllConfig() { - - return this.jsonConfig; - - } - - public Map getConfig(int type) { - - Map conf = new HashMap(); - String savePath = null; - - switch (type) { - - case ActionMap.UPLOAD_FILE: - conf.put("isBase64", "false"); - conf.put("maxSize", this.jsonConfig.getLong("fileMaxSize")); - conf.put("allowFiles", this.getArray("fileAllowFiles")); - conf.put("fieldName", this.jsonConfig.getString("fileFieldName")); - savePath = this.jsonConfig.getString("filePathFormat"); - break; - - case ActionMap.UPLOAD_IMAGE: - conf.put("isBase64", "false"); - conf.put("maxSize", this.jsonConfig.getLong("imageMaxSize")); - conf.put("allowFiles", this.getArray("imageAllowFiles")); - conf.put("fieldName", this.jsonConfig.getString("imageFieldName")); - savePath = this.jsonConfig.getString("imagePathFormat"); - break; - - case ActionMap.UPLOAD_VIDEO: - conf.put("maxSize", this.jsonConfig.getLong("videoMaxSize")); - conf.put("allowFiles", this.getArray("videoAllowFiles")); - conf.put("fieldName", this.jsonConfig.getString("videoFieldName")); - savePath = this.jsonConfig.getString("videoPathFormat"); - break; - - case ActionMap.UPLOAD_SCRAWL: - conf.put("filename", ConfigManager.SCRAWL_FILE_NAME); - conf.put("maxSize", this.jsonConfig.getLong("scrawlMaxSize")); - conf.put("fieldName", this.jsonConfig.getString("scrawlFieldName")); - conf.put("isBase64", "true"); - savePath = this.jsonConfig.getString("scrawlPathFormat"); - break; - - case ActionMap.CATCH_IMAGE: - conf.put("filename", ConfigManager.REMOTE_FILE_NAME); - conf.put("filter", this.getArray("catcherLocalDomain")); - conf.put("maxSize", this.jsonConfig.getLong("catcherMaxSize")); - conf.put("allowFiles", this.getArray("catcherAllowFiles")); - conf.put("fieldName", this.jsonConfig.getString("catcherFieldName") + "[]"); - savePath = this.jsonConfig.getString("catcherPathFormat"); - break; - - case ActionMap.LIST_IMAGE: - conf.put("allowFiles", this.getArray("imageManagerAllowFiles")); - conf.put("dir", this.jsonConfig.getString("imageManagerListPath")); - conf.put("count", this.jsonConfig.getIntValue("imageManagerListSize")); - break; - - case ActionMap.LIST_FILE: - conf.put("allowFiles", this.getArray("fileManagerAllowFiles")); - conf.put("dir", this.jsonConfig.getString("fileManagerListPath")); - conf.put("count", this.jsonConfig.getIntValue("fileManagerListSize")); - break; - - } - - conf.put("savePath", savePath); - conf.put("rootPath", this.rootPath); - - return conf; - - } - - private void initEnv() throws IOException { - try { - this.jsonConfig = JSON.parseObject(FileUtils.reader2String(configFileName)); - } catch (Exception e) { - log.warn("read ueditor config file error", e); - this.jsonConfig = null; - } - - } - - private String[] getArray(String key) { - - JSONArray jsonArray = this.jsonConfig.getJSONArray(key); - String[] result = new String[jsonArray.size()]; - - for (int i = 0, len = jsonArray.size(); i < len; i++) { - result[i] = jsonArray.getString(i); - } - - return result; - - } - - // 过滤输入字符串, 剔除多行注释以及替换掉反斜杠 - private String filter(String input) { - - return input.replaceAll("/\\*[\\s\\S]*?\\*/", ""); - - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Context.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Context.java deleted file mode 100644 index 34e37bbbd..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Context.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baidu.ueditor; - -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.file.FileService; - -public class Context { - public static FileService FILE_SERVICE; - public static FileInfoService RESOURCES_SERVICE; -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Encoder.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Encoder.java deleted file mode 100644 index 69941794c..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/Encoder.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baidu.ueditor; - -public class Encoder { - - public static String toUnicode ( String input ) { - - StringBuilder builder = new StringBuilder(); - char[] chars = input.toCharArray(); - - for ( char ch : chars ) { - - if ( ch < 256 ) { - builder.append( ch ); - } else { - builder.append("\\u").append(Integer.toHexString(ch & 0xffff)); - } - - } - - return builder.toString(); - - } - -} \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/PathFormat.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/PathFormat.java deleted file mode 100644 index 51341462f..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/PathFormat.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.baidu.ueditor; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class PathFormat { - - private static final String TIME = "time"; - private static final String FULL_YEAR = "yyyy"; - private static final String YEAR = "yy"; - private static final String MONTH = "mm"; - private static final String DAY = "dd"; - private static final String HOUR = "hh"; - private static final String MINUTE = "ii"; - private static final String SECOND = "ss"; - private static final String RAND = "rand"; - - private static Date currentDate = null; - - public static String parse ( String input ) { - - Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(input); - - PathFormat.currentDate = new Date(); - - StringBuffer sb = new StringBuffer(); - - while ( matcher.find() ) { - - matcher.appendReplacement(sb, PathFormat.getString(matcher.group(1)) ); - - } - - matcher.appendTail(sb); - - return sb.toString(); - } - - /** - * 格式化路径, 把windows路径替换成标准路径 - * @param input 待格式化的路径 - * @return 格式化后的路径 - */ - public static String format ( String input ) { - - return input.replace( "\\", "/" ); - - } - - public static String parse ( String input, String filename ) { - - Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(input); - String matchStr = null; - - PathFormat.currentDate = new Date(); - - StringBuffer sb = new StringBuffer(); - - while ( matcher.find() ) { - - matchStr = matcher.group( 1 ); - if (matchStr.contains("filename")) { - filename = filename.replace( "$", "\\$" ).replaceAll( "[\\/:*?\"<>|]", "" ); - matcher.appendReplacement(sb, filename ); - } else { - matcher.appendReplacement(sb, PathFormat.getString(matchStr) ); - } - - } - - matcher.appendTail(sb); - - return sb.toString(); - } - - private static String getString ( String pattern ) { - - pattern = pattern.toLowerCase(); - - // time 处理 - if (pattern.contains(PathFormat.TIME)) { - return PathFormat.getTimestamp(); - } else if (pattern.contains(PathFormat.FULL_YEAR)) { - return PathFormat.getFullYear(); - } else if (pattern.contains(PathFormat.YEAR)) { - return PathFormat.getYear(); - } else if (pattern.contains(PathFormat.MONTH)) { - return PathFormat.getMonth(); - } else if (pattern.contains(PathFormat.DAY)) { - return PathFormat.getDay(); - } else if (pattern.contains(PathFormat.HOUR)) { - return PathFormat.getHour(); - } else if (pattern.contains(PathFormat.MINUTE)) { - return PathFormat.getMinute(); - } else if (pattern.contains(PathFormat.SECOND)) { - return PathFormat.getSecond(); - } else if (pattern.contains(PathFormat.RAND)) { - return PathFormat.getRandom(pattern); - } - - return pattern; - - } - - private static String getTimestamp () { - return System.currentTimeMillis() + ""; - } - - private static String getFullYear () { - return new SimpleDateFormat( "yyyy" ).format( PathFormat.currentDate ); - } - - private static String getYear () { - return new SimpleDateFormat( "yy" ).format( PathFormat.currentDate ); - } - - private static String getMonth () { - return new SimpleDateFormat( "MM" ).format( PathFormat.currentDate ); - } - - private static String getDay () { - return new SimpleDateFormat( "dd" ).format( PathFormat.currentDate ); - } - - private static String getHour () { - return new SimpleDateFormat( "HH" ).format( PathFormat.currentDate ); - } - - private static String getMinute () { - return new SimpleDateFormat( "mm" ).format( PathFormat.currentDate ); - } - - private static String getSecond () { - return new SimpleDateFormat( "ss" ).format( PathFormat.currentDate ); - } - - private static String getRandom ( String pattern ) { - - int length = 0; - pattern = pattern.split( ":" )[ 1 ].trim(); - - length = Integer.parseInt(pattern); - - return ( Math.random() + "" ).replace( ".", "" ).substring( 0, length ); - - } -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionMap.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionMap.java deleted file mode 100644 index 364df6336..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionMap.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baidu.ueditor.define; - -import org.hswebframework.web.Maps; - -import java.util.HashMap; -import java.util.Map; - -/** - * 定义请求action类型 - * - * @author hancong03@baidu.com - */ -@SuppressWarnings("serial") -public final class ActionMap { - - public static final Map mapping; - // 获取配置请求 - public static final int CONFIG = 0; - public static final int UPLOAD_IMAGE = 1; - public static final int UPLOAD_SCRAWL = 2; - public static final int UPLOAD_VIDEO = 3; - public static final int UPLOAD_FILE = 4; - public static final int CATCH_IMAGE = 5; - public static final int LIST_FILE = 6; - public static final int LIST_IMAGE = 7; - - static { - mapping = Maps.buildMap(). - put("config", ActionMap.CONFIG). - put("uploadimage", ActionMap.UPLOAD_IMAGE). - put("uploadscrawl", ActionMap.UPLOAD_SCRAWL). - put("uploadvideo", ActionMap.UPLOAD_VIDEO). - put("uploadfile", ActionMap.UPLOAD_FILE). - put("catchimage", ActionMap.CATCH_IMAGE). - put("listfile", ActionMap.LIST_FILE). - put("listimage", ActionMap.LIST_IMAGE).get(); - } - - public static int getType(String key) { - return ActionMap.mapping.get(key); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionState.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionState.java deleted file mode 100644 index b0fad34fd..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/ActionState.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.baidu.ueditor.define; - -public enum ActionState { - UNKNOW_ERROR -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/AppInfo.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/AppInfo.java deleted file mode 100644 index 807c18b0d..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/AppInfo.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public final class AppInfo { - - public static final int SUCCESS = 0; - public static final int MAX_SIZE = 1; - public static final int PERMISSION_DENIED = 2; - public static final int FAILED_CREATE_FILE = 3; - public static final int IO_ERROR = 4; - public static final int NOT_MULTIPART_CONTENT = 5; - public static final int PARSE_REQUEST_ERROR = 6; - public static final int NOTFOUND_UPLOAD_DATA = 7; - public static final int NOT_ALLOW_FILE_TYPE = 8; - - public static final int INVALID_ACTION = 101; - public static final int CONFIG_ERROR = 102; - - public static final int PREVENT_HOST = 201; - public static final int CONNECTION_ERROR = 202; - public static final int REMOTE_FAIL = 203; - - public static final int NOT_DIRECTORY = 301; - public static final int NOT_EXIST = 302; - - public static final int ILLEGAL = 401; - - public static Map info = new HashMap() { - private static final long serialVersionUID = 7957693488024072535L; - - { - - put(AppInfo.SUCCESS, "SUCCESS"); - - // 无效的Action - put(AppInfo.INVALID_ACTION, "\u65E0\u6548\u7684Action"); - // 配置文件初始化失败 - put(AppInfo.CONFIG_ERROR, "\u914D\u7F6E\u6587\u4EF6\u521D\u59CB\u5316\u5931\u8D25"); - // 抓取远程图片失败 - put(AppInfo.REMOTE_FAIL, "\u6293\u53D6\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25"); - - // 被阻止的远程主机 - put(AppInfo.PREVENT_HOST, "\u88AB\u963B\u6B62\u7684\u8FDC\u7A0B\u4E3B\u673A"); - // 远程连接出错 - put(AppInfo.CONNECTION_ERROR, "\u8FDC\u7A0B\u8FDE\u63A5\u51FA\u9519"); - - // "文件大小超出限制" - put(AppInfo.MAX_SIZE, "\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236"); - // 权限不足, 多指写权限 - put(AppInfo.PERMISSION_DENIED, "\u6743\u9650\u4E0D\u8DB3"); - // 创建文件失败 - put(AppInfo.FAILED_CREATE_FILE, "\u521B\u5EFA\u6587\u4EF6\u5931\u8D25"); - // IO错误 - put(AppInfo.IO_ERROR, "IO\u9519\u8BEF"); - // 上传表单不是multipart/form-data类型 - put(AppInfo.NOT_MULTIPART_CONTENT, "\u4E0A\u4F20\u8868\u5355\u4E0D\u662Fmultipart/form-data\u7C7B\u578B"); - // 解析上传表单错误 - put(AppInfo.PARSE_REQUEST_ERROR, "\u89E3\u6790\u4E0A\u4F20\u8868\u5355\u9519\u8BEF"); - // 未找到上传数据 - put(AppInfo.NOTFOUND_UPLOAD_DATA, "\u672A\u627E\u5230\u4E0A\u4F20\u6570\u636E"); - // 不允许的文件类型 - put(AppInfo.NOT_ALLOW_FILE_TYPE, "\u4E0D\u5141\u8BB8\u7684\u6587\u4EF6\u7C7B\u578B"); - - // 指定路径不是目录 - put(AppInfo.NOT_DIRECTORY, "\u6307\u5B9A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55"); - // 指定路径并不存在 - put(AppInfo.NOT_EXIST, "\u6307\u5B9A\u8DEF\u5F84\u5E76\u4E0D\u5B58\u5728"); - - // callback参数名不合法 - put(AppInfo.ILLEGAL, "Callback\u53C2\u6570\u540D\u4E0D\u5408\u6CD5"); - - } - }; - - public static String getStateInfo(int key) { - return AppInfo.info.get(key); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/BaseState.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/BaseState.java deleted file mode 100644 index d6ed36647..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/BaseState.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.baidu.ueditor.define; - -import com.baidu.ueditor.Encoder; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class BaseState implements State { - - private boolean state = false; - private String info = null; - - private Map infoMap = new HashMap<>(); - - public BaseState () { - this.state = true; - } - - public BaseState ( boolean state ) { - this.setState( state ); - } - - public BaseState ( boolean state, String info ) { - this.setState( state ); - this.info = info; - } - - public BaseState ( boolean state, int infoCode ) { - this.setState( state ); - this.info = AppInfo.getStateInfo(infoCode); - } - - public boolean isSuccess () { - return this.state; - } - - public void setState ( boolean state ) { - this.state = state; - } - - public void setInfo ( String info ) { - this.info = info; - } - - public void setInfo ( int infoCode ) { - this.info = AppInfo.getStateInfo(infoCode); - } - - public String toJSONString() { - return this.toString(); - } - - public String toString () { - - String stateVal = this.isSuccess() ? AppInfo.getStateInfo(AppInfo.SUCCESS) : this.info; - - StringBuilder builder = new StringBuilder(); - - builder.append("{\"state\": \"").append(stateVal).append("\""); - - this.infoMap.forEach((key,value)-> builder.append(",\"").append(key).append("\": \"").append(value).append("\"")); - - builder.append( "}" ); - - return Encoder.toUnicode(builder.toString()); - - } - - public void putInfo(String name, String val) { - this.infoMap.put(name, val); - } - - public void putInfo(String name, long val) { - this.putInfo(name, val+""); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/FileType.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/FileType.java deleted file mode 100644 index b03b2c077..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/FileType.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public class FileType { - - public static final String JPG = "JPG"; - - private static final Map types = new HashMap(){ - - private static final long serialVersionUID = -935543810424292061L; - - { - - put( FileType.JPG, ".jpg" ); - - }}; - - public static String getSuffix ( String key ) { - return FileType.types.get( key ); - } - - /** - * 根据给定的文件名,获取其后缀信息 - * @param filename - * @return - */ - public static String getSuffixByFilename ( String filename ) { - - return filename.substring( filename.lastIndexOf( "." ) ).toLowerCase(); - - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MIMEType.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MIMEType.java deleted file mode 100644 index 69f4dd107..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MIMEType.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baidu.ueditor.define; - -import java.util.HashMap; -import java.util.Map; - -public class MIMEType { - - public static final Map types = new HashMap<>(); - - static { - types.put("image/gif", ".gif"); - types.put("image/jpeg", ".jpg"); - types.put("image/jpg", ".jpg"); - types.put("image/png", ".png"); - types.put("image/bmp", ".bmp"); - } - - public static String getSuffix(String mime) { - return MIMEType.types.get(mime); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MultiState.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MultiState.java deleted file mode 100644 index 08b4a8f88..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/MultiState.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.baidu.ueditor.define; - -import com.baidu.ueditor.Encoder; - -import java.util.*; - -/** - * 多状态集合状态 - * 其包含了多个状态的集合, 其本身自己也是一个状态 - * - * @author hancong03@baidu.com , zh.sqy@qq.com - */ -public class MultiState implements State { - - private boolean state = false; - private String info = null; - private Map intMap = new HashMap<>(); - private Map infoMap = new HashMap<>(); - private List stateList = new ArrayList<>(); - - public MultiState(boolean state) { - this.state = state; - } - - public MultiState(boolean state, String info) { - this.state = state; - this.info = info; - } - - public MultiState(boolean state, int infoKey) { - this.state = state; - this.info = AppInfo.getStateInfo(infoKey); - } - - public boolean isSuccess() { - return this.state; - } - - public void addState(State state) { - stateList.add(state.toJSONString()); - } - - /** - * 该方法调用无效果 - */ - public void putInfo(String name, String val) { - this.infoMap.put(name, val); - } - - public String toJSONString() { - - String stateVal = this.isSuccess() ? AppInfo.getStateInfo(AppInfo.SUCCESS) : this.info; - - StringBuilder builder = new StringBuilder(); - - builder.append("{\"state\": \"").append(stateVal).append("\""); - - //int - this.intMap.forEach((k, v) -> builder.append(",\"").append(k).append("\": ").append(v)); - //string - this.infoMap.forEach((k, v) -> builder.append(",\"").append(k).append("\": \"").append(v).append("\"")); - - //list - builder.append(", list: [").append(String.join(",", this.stateList.toArray(new String[this.stateList.size()]))); - - builder.append(" ]}"); - - return Encoder.toUnicode(builder.toString()); - - } - - public void putInfo(String name, long val) { - this.intMap.put(name, val); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/State.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/State.java deleted file mode 100644 index 178f697b2..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/define/State.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baidu.ueditor.define; - -/** - * 处理状态接口 - * - * @author hancong03@baidu.com - */ -public interface State { - - boolean isSuccess(); - - void putInfo(String name, String val); - - void putInfo(String name, long val); - - String toJSONString(); - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/FileManager.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/FileManager.java deleted file mode 100644 index 5494bc886..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/FileManager.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.baidu.ueditor.hunter; - -import com.baidu.ueditor.define.MultiState; -import com.baidu.ueditor.define.State; - -import java.io.File; -import java.util.Map; - -public class FileManager { - private String rootPath = null; - - public FileManager(Map conf) { - - this.rootPath = (String) conf.get("rootPath"); - - } - - public State listFile(int index) { - - State state = new MultiState(true); - - state.putInfo("start", index); - state.putInfo("total",0); - - return state; - - } - -// private State getState(List resources) { -// -// MultiState state = new MultiState(true); -// BaseState fileState = null; -// -// for (FileInfoEntity obj : resources) { -// if (obj == null) { -// break; -// } -// fileState = new BaseState(true); -// fileState.putInfo("url", rootPath + "file/download/" + obj.getId() + "/" + obj.getName()); -// state.addState(fileState); -// } -// -// return state; -// -// } - - private String getPath(File file) { - - String path = file.getAbsolutePath(); - path = path.replace("\\", "/"); - return path.replace(this.rootPath, "/"); - - } - - private String[] getAllowFiles(Object fileExt) { - - String[] exts = null; - String ext = null; - - if (fileExt == null) { - return new String[0]; - } - - exts = (String[]) fileExt; - - for (int i = 0, len = exts.length; i < len; i++) { - - ext = exts[i]; - exts[i] = ext.replace(".", ""); - - } - - return exts; - - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java deleted file mode 100644 index 24fcbf58e..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/hunter/ImageHunter.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.baidu.ueditor.hunter; - -import com.baidu.ueditor.PathFormat; -import com.baidu.ueditor.define.*; -import com.baidu.ueditor.upload.StorageManager; - -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * 图片抓取器 - * @author hancong03@baidu.com - * - */ -public class ImageHunter { - - private String filename = null; - private String savePath = null; - private String rootPath = null; - private List allowTypes = null; - private long maxSize = -1; - - private List filters = null; - - public ImageHunter ( Map conf ) { - - this.filename = (String)conf.get( "filename" ); - this.savePath = (String)conf.get( "savePath" ); - this.rootPath = (String)conf.get( "rootPath" ); - this.maxSize = (Long)conf.get( "maxSize" ); - this.allowTypes = Arrays.asList((String[]) conf.get("allowFiles")); - this.filters = Arrays.asList((String[]) conf.get("filter")); - - } - - public State capture ( String[] list ) { - - MultiState state = new MultiState( true ); - - for ( String source : list ) { - state.addState( captureRemoteData( source ) ); - } - - return state; - - } - - public State captureRemoteData ( String urlStr ) { - - HttpURLConnection connection = null; - URL url = null; - String suffix = null; - - try { - url = new URL( urlStr ); - - if ( !validHost( url.getHost() ) ) { - return new BaseState( false, AppInfo.PREVENT_HOST ); - } - - connection = (HttpURLConnection) url.openConnection(); - - connection.setInstanceFollowRedirects( true ); - connection.setUseCaches( true ); - - if ( !validContentState( connection.getResponseCode() ) ) { - return new BaseState( false, AppInfo.CONNECTION_ERROR ); - } - - suffix = MIMEType.getSuffix( connection.getContentType() ); - - if ( !validFileType( suffix ) ) { - return new BaseState( false, AppInfo.NOT_ALLOW_FILE_TYPE ); - } - - if ( !validFileSize( connection.getContentLength() ) ) { - return new BaseState( false, AppInfo.MAX_SIZE ); - } - - String savePath = this.getPath( this.savePath, this.filename, suffix ); - String physicalPath = this.rootPath + savePath; - - State state = StorageManager.saveFileByInputStream( connection.getInputStream(), physicalPath ); - - if ( state.isSuccess() ) { - state.putInfo( "url", PathFormat.format( savePath ) ); - state.putInfo( "source", urlStr ); - } - - return state; - - } catch ( Exception e ) { - return new BaseState( false, AppInfo.REMOTE_FAIL ); - } - - } - - private String getPath ( String savePath, String filename, String suffix ) { - - return PathFormat.parse( savePath + suffix, filename ); - - } - - private boolean validHost ( String hostname ) { - - return !filters.contains( hostname ); - - } - - private boolean validContentState ( int code ) { - - return HttpURLConnection.HTTP_OK == code; - - } - - private boolean validFileType ( String type ) { - - return this.allowTypes.contains( type ); - - } - - private boolean validFileSize ( int size ) { - return size < this.maxSize; - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java deleted file mode 100644 index 60c0650d7..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Base64Uploader.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.Context; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.FileType; -import com.baidu.ueditor.define.State; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.binary.Base64; -import org.hswebframework.web.service.file.FileService; - -import java.io.ByteArrayInputStream; -import java.util.Map; - -@Slf4j -public final class Base64Uploader { - - public static State save(String content, Map conf) { - - byte[] data = decode(content); - - long maxSize = (Long) conf.get("maxSize"); - - if (!validSize(data, maxSize)) { - return new BaseState(false, AppInfo.MAX_SIZE); - } - String suffix = FileType.getSuffix(FileType.JPG); - try { - FileService fileService = Context.FILE_SERVICE; - String path = fileService.saveStaticFile(new ByteArrayInputStream(data), System.currentTimeMillis() + suffix); - State state = new BaseState(true); - state.putInfo("size", data.length); - state.putInfo("title", ""); - state.putInfo("url", path); - state.putInfo("type", suffix); - return state; - } catch (Exception e) { - log.error("上传base64文件失败",e); - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - private static byte[] decode(String content) { - return Base64.decodeBase64(content); - } - - private static boolean validSize(byte[] data, long length) { - return data.length <= length; - } - -} \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java deleted file mode 100644 index 63ca238d0..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/BinaryUploader.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.Context; -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.FileType; -import com.baidu.ueditor.define.State; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.fileupload.FileItemIterator; -import org.apache.commons.fileupload.FileItemStream; -import org.apache.commons.fileupload.FileUploadException; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.hswebframework.web.service.file.FileService; - -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -@Slf4j -public class BinaryUploader { - - public static final State save(HttpServletRequest request, Map conf) { - FileItemStream fileStream = null; - boolean isAjaxUpload = request.getHeader("X_Requested_With") != null; - - if (!ServletFileUpload.isMultipartContent(request)) { - return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT); - } - - ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory()); - - if (isAjaxUpload) { - upload.setHeaderEncoding("UTF-8"); - } - try { - FileItemIterator iterator = upload.getItemIterator(request); - - while (iterator.hasNext()) { - fileStream = iterator.next(); - - if (!fileStream.isFormField()) - break; - fileStream = null; - } - if (fileStream == null) { - return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA); - } - - String savePath = (String) conf.get("savePath"); - String originFileName = fileStream.getName(); - String suffix = FileType.getSuffixByFilename(originFileName); - - originFileName = originFileName.substring(0, originFileName.length() - suffix.length()); - if (!validType(suffix, (String[]) conf.get("allowFiles"))) { - return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE); - } - InputStream is = fileStream.openStream(); - try { - FileService fileService = Context.FILE_SERVICE; - - String path = fileService.saveStaticFile(is, originFileName + suffix); - State state = new BaseState(true); - state.putInfo("size", 0); - state.putInfo("title", originFileName + suffix); - state.putInfo("url", path); - state.putInfo("type", suffix); - state.putInfo("original", originFileName + suffix); - return state; - } catch (Exception e) { - e.printStackTrace(); - } - } catch (FileUploadException e) { - return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - private static boolean validType(String type, String[] allowTypes) { - List list = Arrays.asList(allowTypes); - - return list.contains(type); - } -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/StorageManager.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/StorageManager.java deleted file mode 100644 index eee48b270..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/StorageManager.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.define.AppInfo; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.State; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FileUtils; - -import java.io.*; - -@Slf4j -public class StorageManager { - public static final int BUFFER_SIZE = 8192; - - public StorageManager() { - } - - public static State saveBinaryFile(byte[] data, String path) { - File file = new File(path); - - State state = valid(file); - - if (!state.isSuccess()) { - return state; - } - - try (BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(file))) { - bos.write(data); - bos.flush(); - bos.close(); - } catch (IOException ioe) { - return new BaseState(false, AppInfo.IO_ERROR); - } - - state = new BaseState(true, file.getAbsolutePath()); - state.putInfo("size", data.length); - state.putInfo("title", file.getName()); - return state; - } - - public static State saveFileByInputStream(InputStream is, String path, - long maxSize) { - - File tmpFile = getTmpFile(); - - byte[] dataBuf = new byte[2048]; - - try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) { - - int count = 0; - while ((count = bis.read(dataBuf)) != -1) { - bos.write(dataBuf, 0, count); - } - bos.flush(); - bos.close(); - - if (tmpFile.length() > maxSize) { - tmpFile.delete(); - return new BaseState(false, AppInfo.MAX_SIZE); - } - - State state = saveTmpFile(tmpFile, path); - - if (!state.isSuccess()) { - tmpFile.delete(); - } - - return state; - - } catch (IOException e) { - } - return new BaseState(false, AppInfo.IO_ERROR); - } - - public static State saveFileByInputStream(InputStream is, String path) { - State state; - - File tmpFile = getTmpFile(); - - byte[] dataBuf = new byte[2048]; - - try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); - BufferedOutputStream bos = new BufferedOutputStream( - new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) { - - int count = 0; - while ((count = bis.read(dataBuf)) != -1) { - bos.write(dataBuf, 0, count); - } - bos.flush(); - bos.close(); - - state = saveTmpFile(tmpFile, path); - - if (!state.isSuccess()) { - tmpFile.delete(); - } - - return state; - } catch (IOException e) { - return new BaseState(false, AppInfo.IO_ERROR); - } - } - - private static File getTmpFile() { - File tmpDir = FileUtils.getTempDirectory(); - String tmpFileName = (Math.random() * 10000 + "").replace(".", ""); - return new File(tmpDir, tmpFileName); - } - - private static State saveTmpFile(File tmpFile, String path) { - State state = null; - File targetFile = new File(path); - - if (targetFile.canWrite()) { - return new BaseState(false, AppInfo.PERMISSION_DENIED); - } - try { - FileUtils.moveFile(tmpFile, targetFile); - } catch (IOException e) { - return new BaseState(false, AppInfo.IO_ERROR); - } - - state = new BaseState(true); - state.putInfo("size", targetFile.length()); - state.putInfo("title", targetFile.getName()); - - return state; - } - - private static State valid(File file) { - File parentPath = file.getParentFile(); - - if ((!parentPath.exists()) && (!parentPath.mkdirs())) { - return new BaseState(false, AppInfo.FAILED_CREATE_FILE); - } - - if (!parentPath.canWrite()) { - return new BaseState(false, AppInfo.PERMISSION_DENIED); - } - - return new BaseState(true); - } -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Uploader.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Uploader.java deleted file mode 100644 index c61801e6b..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/com/baidu/ueditor/upload/Uploader.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baidu.ueditor.upload; - -import com.baidu.ueditor.define.State; - -import javax.servlet.http.HttpServletRequest; -import java.util.Map; - -public class Uploader { - private HttpServletRequest request = null; - private Map conf = null; - - public Uploader(HttpServletRequest request, Map conf) { - this.request = request; - this.conf = conf; - } - - public final State doExec() { - String filedName = (String) this.conf.get("fieldName"); - State state; - - if ("true".equals(this.conf.get("isBase64"))) { - state = Base64Uploader.save(this.request.getParameter(filedName), - this.conf); - } else { - state = BinaryUploader.save(this.request, this.conf); - } - - return state; - } -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorAutoConfiguration.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorAutoConfiguration.java deleted file mode 100644 index 14d26229d..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorAutoConfiguration.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hswebframework.web.thirdpart.ueditor; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class UeditorAutoConfiguration { - - @Bean - public UeditorController ueditorController(){ - return new UeditorController(); - } -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorController.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorController.java deleted file mode 100644 index 4b7a27cee..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/java/org/hswebframework/web/thirdpart/ueditor/UeditorController.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.hswebframework.web.thirdpart.ueditor; - -import com.baidu.ueditor.ActionEnter; -import com.baidu.ueditor.Context; -import com.baidu.ueditor.define.BaseState; -import com.baidu.ueditor.define.FileType; -import com.baidu.ueditor.define.State; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.fileupload.ParameterParser; -import org.hswebframework.web.WebUtil; -import org.hswebframework.web.service.file.FileInfoService; -import org.hswebframework.web.service.file.FileService; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.Map; -import java.util.Optional; - -/** - * ueditor 服务端实现 - * - * @see FileService - * @since 2.0 - */ -@RestController -@RequestMapping("/ueditor") -@Api(tags = "第三方应用-ueditor", value = "ueditor") -public class UeditorController { - - @Resource - private FileService fileService; - - @Resource - private FileInfoService resourcesService; - - @Value("${ueditor.root-path:/}") - private String rootPath = "/"; - - public void setRootPath(String rootPath) { - this.rootPath = rootPath; - } - - @PostConstruct - public void init() { - Context.FILE_SERVICE = fileService; - Context.RESOURCES_SERVICE = resourcesService; - } - - private String getDownloadPath(HttpServletRequest request) { - return rootPath; - } - - /** - * ueditor上传文件 - * - * @return 上传结果 - * @throws IOException 文件上传错误 - */ - @RequestMapping(method = RequestMethod.POST, consumes = "multipart/form-data") - @ApiOperation("上传文件") - public String upload(@RequestParam(value = "upfile", required = false) MultipartFile file) throws IOException { - String fileName = file.getOriginalFilename(); - String suffix = FileType.getSuffixByFilename(fileName); - String path = fileService.saveStaticFile(file.getInputStream(), System.currentTimeMillis() + suffix); - State state = new BaseState(true); - state.putInfo("size", file.getSize()); - state.putInfo("title",fileName); - state.putInfo("url", path); - state.putInfo("type", suffix); - state.putInfo("original",fileName); - return state.toJSONString(); - } - - @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}) - @ApiOperation("初始化配置") - public String run(HttpServletRequest request) throws Exception { - return new ActionEnter(request, getDownloadPath(request)).exec(); - } - -} diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index b5599986c..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "properties": [ - { - "name": "ueditor.rootPath", - "type": "java.lang.String", - "defaultValue": "/", - "description": "ueditor访问的根路径,例如:/ , http://file_server/." - } - ] -} \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/spring.factories b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 2299dc27f..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.hswebframework.web.thirdpart.ueditor.UeditorAutoConfiguration \ No newline at end of file diff --git a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/test/java/com/baidu/ueditor/define/MultiStateTest.java b/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/test/java/com/baidu/ueditor/define/MultiStateTest.java deleted file mode 100644 index 0531496d9..000000000 --- a/hsweb-thirdparty/hsweb-thirdparty-ueditor/src/test/java/com/baidu/ueditor/define/MultiStateTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baidu.ueditor.define; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class MultiStateTest { - - @Test - public void toJSONString(){ - MultiState state=new MultiState(true); - - state.addState(new BaseState()); - state.putInfo("test",1); - state.putInfo("test","1"); - - System.out.println(state.toJSONString()); - - } -} \ No newline at end of file diff --git a/hsweb-thirdparty/pom.xml b/hsweb-thirdparty/pom.xml deleted file mode 100644 index 7c826c64b..000000000 --- a/hsweb-thirdparty/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - hsweb-framework - org.hswebframework.web - 4.0.0-SNAPSHOT - - 4.0.0 - - hsweb-thirdparty - pom - - hsweb-thirdparty-ueditor - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 731f54d62..256783cf8 100644 --- a/pom.xml +++ b/pom.xml @@ -30,12 +30,9 @@ hsweb-core hsweb-authorization hsweb-system - hsweb-tests hsweb-datasource hsweb-commons hsweb-logging - hsweb-boost - hsweb-thirdparty pom @@ -303,10 +300,11 @@ - org.hibernate - hibernate-validator - 6.0.17.Final + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + 1.0.2.Final + io.vavr vavr