diff --git a/build-version.gradle b/build-version.gradle index 3b2ee116..dfb853de 100755 --- a/build-version.gradle +++ b/build-version.gradle @@ -146,7 +146,7 @@ subprojects { // ext['oauth2-oidc-sdk.version'] = // ext['ojdbc.version'] = // ext['okhttp3.version'] = - // ext['oracle-database.version'] = + // ext['oracle-database.version'] ='12.2.0.1' // ext['pooled-jms.version'] = // ext['postgresql.version'] = // ext['prometheus-pushgateway.version'] = diff --git a/build.gradle b/build.gradle index 46346189..ebb425e3 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,7 @@ subprojects { exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" exclude group: "org.slf4j", module: "slf4j-jdk14" exclude group: "org.slf4j", module: "slf4j-nop" + //exclude group: "com.oracle.database.jdbc", module: "ojdbc8" } dependencyManagement { diff --git a/config/application.properties b/config/application.properties new file mode 100644 index 00000000..b28b6dfc --- /dev/null +++ b/config/application.properties @@ -0,0 +1,223 @@ +########################################################################## +#(100) excluded auto configuration - io.sc.platform.core +########################################################################## +spring.autoconfigure.exclude = + +########################################################################## +#(150) application configuration - io.sc.platform.core +########################################################################## +# - io.sc.platform.core +application.audit-log-mode = none +#application.audit-log-mode = none +#application.audit-log-mode = log +#application.audit-log-mode = database +# - io.sc.platform.installer +application.installer.enabled = true +# - io.sc.platform.jdbc.liquibase +application.updater.enabled = true +# - io.sc.platform.security +application.default-password = password + +########################################################################## +#(200) spring.main configuration - io.sc.platform.core +########################################################################## +spring.main.allow-bean-definition-overriding = false +spring.main.banner-mode = console +spring.main.lazy-initialization = false +spring.main.log-startup-info = true +spring.main.register-shutdown-hook = true + +########################################################################## +#(210) jasypt encryptor configuration - io.sc.platform.core +########################################################################## +jasypt.encryptor.bean = platformJasyptStringEncryptor + +########################################################################## +#(300) web server configuration - io.sc.platform.mvc +########################################################################## +#server.address = 127.0.0.1 +server.port = 8080 +server.servlet.context-path = / +server.servlet.session.timeout = 30m +server.error.path = /error +server.error.whitelabel.enabled = true +server.error.include-exception = true +server.error.include-binding-errors = always +server.error.include-message = always +server.error.include-stacktrace = always + +########################################################################## +#(1000) dataSource configuration - io.sc.platform.jdbc +########################################################################## +spring.datasource.items[primary].driver-class-name = org.h2.Driver +spring.datasource.items[primary].url = jdbc:h2:mem:DB_PLATFORM;DB_CLOSE_DELAY=-1 +spring.datasource.items[primary].username = platform +spring.datasource.items[primary].password = platform + +########################################################################## +#(1100) jpa configuration - io.sc.platform.orm.jpa +########################################################################## +spring.jpa.open-in-view = false +spring.jpa.show-sql = false +spring.jpa.generate-ddl = false +spring.jpa.hibernate.ddl-auto = none +spring.jpa.hibernate.jdbc.batch_size = 25 +spring.jpa.properties.hibernate.enable_lazy_load_no_trans =true +spring.jpa.properties.hibernate.dialect =org.hibernate.dialect.H2Dialect + +########################################################################## +#(1500) hikari configuration - io.sc.platform.jdbc +########################################################################## +#spring.datasource.items[primary].hikari.autoCommit = true +#spring.datasource.items[primary].hikari.connectionTimeout = 10000 +#spring.datasource.items[primary].hikari.idleTimeout = 600000 +#spring.datasource.items[primary].hikari.maxLifetime = 1800000 +#spring.datasource.items[primary].hikari.minimumIdle = 10 +#spring.datasource.items[primary].hikari.maximumPoolSize = 10 +#spring.datasource.items[primary].hikari.metricRegistry = +#spring.datasource.items[primary].hikari.healthCheckRegistry = +#spring.datasource.items[primary].hikari.poolName = +#spring.datasource.items[primary].hikari.initializationFailTimeout = 1 +#spring.datasource.items[primary].hikari.isolateInternalQueries = false +#spring.datasource.items[primary].hikari.allowPoolSuspension = false +#spring.datasource.items[primary].hikari.readOnly = false +#spring.datasource.items[primary].hikari.registerMbeans = false +#spring.datasource.items[primary].hikari.catalog = +#spring.datasource.items[primary].hikari.connectionInitSql = +#spring.datasource.items[primary].hikari.driverClassName = +#spring.datasource.items[primary].hikari.transactionIsolation = +#spring.datasource.items[primary].hikari.validationTimeout = 5000 +#spring.datasource.items[primary].hikari.leakDetectionThreshold = 0 +#spring.datasource.items[primary].hikari.dataSource = +#spring.datasource.items[primary].hikari.schema = +#spring.datasource.items[primary].hikari.threadFactory = +#spring.datasource.items[primary].hikari.scheduledExecutor = + +########################################################################## +#(2100) spring.session configuration - io.sc.platform.mvc +########################################################################## +spring.session.store-type = none +#spring.session.store-type = jdbc +#spring.session.store-type = redis +spring.session.jdbc.initializer.enabled = false +spring.session.jdbc.cleanup-cron = 0 */5 * * * * +spring.session.redis.namespace = spring:session +spring.session.redis.cleanupCron = 0 */5 * * * * + +########################################################################## +#(2200) spring web configuration (WebProperties) - io.sc.platform.mvc +########################################################################## +spring.web.resources.add-mappings = true +spring.web.resources.cache.cachecontrol.cache-public = true +spring.web.resources.cache.cachecontrol.must-revalidate = true +spring.web.resources.chain.cache = true +spring.web.resources.chain.compressed = true + +########################################################################## +#(2300) management http server configuration - io.sc.platform.mvc +########################################################################## +management.endpoints.enabled-by-default = true +management.endpoints.web.exposure.include = * +management.context-path = /actuator +management.security.enabled = false + +########################################################################## +#(2400) thymeleaf configuration - io.sc.platform.mvc +########################################################################## +spring.thymeleaf.enabled = true +spring.thymeleaf.cache = false +spring.thymeleaf.encoding = UTF-8 +spring.thymeleaf.mode = HTML +spring.thymeleaf.prefix = classpath:/templates/ +spring.thymeleaf.check-template = false +spring.thymeleaf.check-template-location = false +spring.thymeleaf.servlet.content-type = text/html + +########################################################################## +#(2500) jackson configuration - io.sc.platform.mvc +########################################################################## +spring.jackson.time-zone = Asia/Shanghai +spring.jackson.date-format = yyyy-MM-dd HH:mm:ss +spring.jackson.serialization.indent_output = true +spring.jackson.serialization.fail_on_empty_beans = false +spring.jackson.deserialization.fail_on_ignored_properties = false +spring.jackson.parser.allow_comments = true +spring.jackson.parser.allow_single_quotes = true +spring.jackson.parser.allow_trailing_comma = true +spring.jackson.parser.allow_unquoted_field_names = true +spring.jackson.parser.ignore_undefined = true +spring.jackson.parser.allow_unquoted_control_chars = true + +########################################################################## +#(2600) i18n message source configuration - io.sc.platform.mvc +########################################################################## +spring.messages.alwaysUseMessageFormat = false +spring.messages.cacheDuration = -1 +spring.messages.encoding = UTF-8 +spring.messages.fallbackToSystemLocale = false +spring.messages.useCodeAsDefaultMessage = true + +########################################################################## +#(3000) platform security configuration - io.sc.platform.security.loginform +########################################################################## +spring.security.formLogin.loginPage = /login +spring.security.formLogin.loginProcessingUrl = /login +spring.security.formLogin.failureUrl = /login-error +spring.security.logout.logoutUrl = /logout +spring.security.logout.logoutSuccessUrl = / + +########################################################################## +#(4000) email configuration - io.sc.platform.communication +########################################################################## +spring.mail.host=zzz.xxx.yyy +spring.mail.port=25 +spring.mail.protocol=smtp +spring.mail.test-connection=false +spring.mail.default-encoding=UTF-8 +spring.mail.properties.mail.smtp.auth=true +spring.mail.username=xxx +spring.mail.password=yyy + +########################################################################## +#(5000) flowable bpm configuration - io.sc.platform.flowable +########################################################################## +# core +flowable.asyncExecutorActivate =false +flowable.asyncHistoryExecutorActivate = false +flowable.check-process-definitions=false +flowable.custom-mybatis-mappers= +flowable.custom-mybatis-x-m-l-mappers= +flowable.database-schema= +flowable.database-schema-update=true +flowable.db-history-used=true +flowable.deployment-name=SpringBootAutoDeployment +flowable.history-level= +flowable.process-definition-location-prefix=classpath*:/processes/ +flowable.process-definition-location-suffixes=**.bpmn20.xml,**.bpmn +# process +flowable.process.definition-cache-limit=-1 +flowable.process.enable-safe-xml=true +flowable.process.servlet.load-on-startup=-1 +flowable.process.servlet.name=Flowable BPMN Rest API +flowable.process.servlet.path=/process-api +# cmmn +flowable.cmmn.enabled=false +# content +flowable.content.enabled=false +# dmn +flowable.dmn.enabled=false +# form +flowable.form.enabled=false +# idm +flowable.idm.enabled=false + +########################################################################## +#(8000) cxf configuration - io.sc.platform.ws.cxf +########################################################################## +cxf.path = /webservices + +########################################################################## +#(9000) p6spy configuration - io.sc.platform.jdbc +########################################################################## +p6spy.enabled = true +p6spy.ignorePattern = false diff --git a/config/banner.txt b/config/banner.txt new file mode 100644 index 00000000..420b910e --- /dev/null +++ b/config/banner.txt @@ -0,0 +1,48 @@ +************************************************************************************** + Name: app.platform + Version: ${application.version} + Base on Spring Boot ${spring-boot.version} +************************************************************************************** +System.environment: +-------------------------------------------------------------------------------------- + java.specification.version = 1.8 + java.specification.vendor = Oracle Corporation + java.specification.name = Java Platform API Specification + java.vm.specification.version = 1.8 + java.vm.specification.vendor = Oracle Corporation + java.vm.specification.name = Java Virtual Machine Specification + java.home = /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre + java.version = 1.8.0_332 + java.vendor = Azul Systems, Inc. + java.vendor.url = http://www.azul.com/ + java.vm.version = 25.332-b09 + java.vm.vendor = Azul Systems, Inc. + java.vm.name = OpenJDK 64-Bit Server VM + java.class.version = 52.0 + java.class.path = ${java.class.path2} + java.library.path = /Users/wangshaoping/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. + java.io.tmpdir = /var/folders/82/6m96_g610hj1v1tcpvhtjysr0000gn/T/ + java.ext.dirs = /Users/wangshaoping/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java + os.name = Mac OS X + os.arch = aarch64 + os.version = 13.5.1 + user.name = wangshaoping + user.home = /Users/wangshaoping + user.dir = /Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform + +Application.environment +-------------------------------------------------------------------------------------- + application.name = app.platform + application.is-running-in-development = false + application.is-running-in-web-container = false + + application.home.dir = /Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform + application.installer.enabled = ${application.installer.enabled} + application.updater.enabled = ${application.updater.enabled} + application.audit-log-mode = ${application.audit-log-mode} + spring.config.location = file:/Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform/config/application.properties + spring.banner.location = file:/Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform/config/banner.txt + logging.config = file:/Users/wangshaoping/wspsc/workspace/wangshaoping/v8/platform/config/logback-spring.xml + p6spy.enabled = ${p6spy.enabled} + p6spy.ignorePattern = ${p6spy.ignorePattern} +************************************************************************************** diff --git a/config/license.txt b/config/license.txt new file mode 100644 index 00000000..d5ee1622 --- /dev/null +++ b/config/license.txt @@ -0,0 +1,216 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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 + + https://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. + +======================================================================= + +To the extent any open source subcomponents are licensed under the EPL and/or other +similar licenses that require the source code and/or modifications to +source code to be made available (as would be noted above), you may obtain a +copy of the source code corresponding to the binaries for such open source +components and modifications thereto, if any, (the "Source Files"), by +downloading the Source Files from https://www.springsource.org/download, +or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview +Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All +such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General +Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent +physical medium. This offer to obtain a copy of the Source Files is valid for three +years from the date you acquired this Software product. diff --git a/config/logback-spring.xml b/config/logback-spring.xml new file mode 100644 index 00000000..cae04191 --- /dev/null +++ b/config/logback-spring.xml @@ -0,0 +1,66 @@ + + + + + + + + + + ${pattern} + + + + + ${pattern} + ${homedir}/logs/log.log + + ${homedir}/logs/log.%d.log + 30 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties index 677f53c8..76d7a0c2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,9 +36,9 @@ application_version=1.0.0 # platform ########################################################### platform_group=io.sc -platform_version=8.1.11 +platform_version=8.1.13 platform_plugin_version=8.1.11 -platform_core_frontend_version=8.1.27 +platform_core_frontend_version=8.1.42 ########################################################### # dependencies version @@ -66,7 +66,8 @@ oshi_version=6.4.2 p6spy_version=3.9.1 poi_ooxml_version=3.17 schemacrawler_version=16.19.11 -spring_boot_version=2.7.17 +#schemacrawler_version=14.21.02 +spring_boot_version=2.7.18 spring_cloud_alibaba_version=2021.0.4.0 spring_cloud_context_version=3.1.4 spring_cloud_version=2021.0.8 diff --git a/io.sc.platform.core.frontend/package.json b/io.sc.platform.core.frontend/package.json index 646308e2..573db6bd 100644 --- a/io.sc.platform.core.frontend/package.json +++ b/io.sc.platform.core.frontend/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.1.28", + "version": "8.1.42", "description": "前端核心包,用于快速构建前端的脚手架", "//main": "库的主文件", "main": "dist/platform-core.js", diff --git a/io.sc.platform.core.frontend/src/components/index.ts b/io.sc.platform.core.frontend/src/components/index.ts index 02709946..9c1a16f6 100644 --- a/io.sc.platform.core.frontend/src/components/index.ts +++ b/io.sc.platform.core.frontend/src/components/index.ts @@ -5,11 +5,13 @@ import dialog from '@/views/Dialog.vue'; import codemirror from '@/views/Codemirror.vue'; import select from '@/views/Select.vue'; +import treeGrid from '@/views/TreeGrid.vue'; -const localComponents = { -'component.testcase.dialog': dialog, -'component.testcase.codemirror': codemirror, -'component.testcase.select': select, -} +const localComponents = { + 'component.testcase.dialog': dialog, + 'component.testcase.codemirror': codemirror, + 'component.testcase.select': select, + 'component.testcase.treeGrid': treeGrid, +}; export default localComponents; diff --git a/io.sc.platform.core.frontend/src/i18n/messages.json b/io.sc.platform.core.frontend/src/i18n/messages.json index 87385998..00d6bddd 100644 --- a/io.sc.platform.core.frontend/src/i18n/messages.json +++ b/io.sc.platform.core.frontend/src/i18n/messages.json @@ -2,5 +2,6 @@ "menu.testcase": "Test Case", "menu.testcase.codemirror": "CodeMirror", "menu.testcase.dialog": "Dialog", - "menu.testcase.select": "Select" + "menu.testcase.select": "Select", + "menu.testcase.treeGrid": "Tree Grid" } diff --git a/io.sc.platform.core.frontend/src/i18n/messages_tw_CN.json b/io.sc.platform.core.frontend/src/i18n/messages_tw_CN.json index 7d2bf8e7..00806365 100644 --- a/io.sc.platform.core.frontend/src/i18n/messages_tw_CN.json +++ b/io.sc.platform.core.frontend/src/i18n/messages_tw_CN.json @@ -2,5 +2,6 @@ "menu.testcase": "測試用例", "menu.testcase.codemirror": "CodeMirror", "menu.testcase.dialog": "Dialog", - "menu.testcase.select": "Select" + "menu.testcase.select": "Select", + "menu.testcase.treeGrid": "Tree Grid" } diff --git a/io.sc.platform.core.frontend/src/i18n/messages_zh_CN.json b/io.sc.platform.core.frontend/src/i18n/messages_zh_CN.json index f6089331..ef4c117c 100644 --- a/io.sc.platform.core.frontend/src/i18n/messages_zh_CN.json +++ b/io.sc.platform.core.frontend/src/i18n/messages_zh_CN.json @@ -2,5 +2,6 @@ "menu.testcase": "测试用例", "menu.testcase.codemirror": "CodeMirror", "menu.testcase.dialog": "Dialog", - "menu.testcase.select": "Select" + "menu.testcase.select": "Select", + "menu.testcase.treeGrid": "Tree Grid" } diff --git a/io.sc.platform.core.frontend/src/menus/menus.json b/io.sc.platform.core.frontend/src/menus/menus.json index 97dfc47f..b0672bd8 100644 --- a/io.sc.platform.core.frontend/src/menus/menus.json +++ b/io.sc.platform.core.frontend/src/menus/menus.json @@ -44,5 +44,14 @@ "titleI18nKey": "menu.testcase.select", "icon": "bi-palette", "routeName": "route.testcase.select" + }, + { + "type": "ROUTE", + "order": 400, + "parentId": "menu.testcase", + "id": "menu.testcase.treeGrid", + "titleI18nKey": "menu.testcase.treeGrid", + "icon": "bi-palette", + "routeName": "route.testcase.treeGrid" } ] diff --git a/io.sc.platform.core.frontend/src/platform/components/grid/PlatformGrid.vue b/io.sc.platform.core.frontend/src/platform/components/grid/PlatformGrid.vue index 0b45da3f..641f3100 100644 --- a/io.sc.platform.core.frontend/src/platform/components/grid/PlatformGrid.vue +++ b/io.sc.platform.core.frontend/src/platform/components/grid/PlatformGrid.vue @@ -22,6 +22,7 @@ @row-click="rowClick" @row-dblclick="rowDbClick" @fullscreen="tableFullscreenFun" + @selection="selection" > + + diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/controller/AnnouncementController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/controller/AnnouncementController.java new file mode 100644 index 00000000..7632c3f2 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/controller/AnnouncementController.java @@ -0,0 +1,14 @@ +package io.sc.platform.system.announcement.controller; + +import io.sc.platform.mvc.controller.support.RestCrudController; +import io.sc.platform.system.announcement.convertor.AnnouncementEntityVoConverter; +import io.sc.platform.system.announcement.jpa.entity.AnnouncementEntity; +import io.sc.platform.system.announcement.jpa.repository.AnnouncementRepository; +import io.sc.platform.system.announcement.service.AnnouncementService; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("api/system/announcement") +public class AnnouncementController extends RestCrudController { +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/convertor/AnnouncementEntityVoConverter.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/convertor/AnnouncementEntityVoConverter.java new file mode 100644 index 00000000..14dfccf6 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/convertor/AnnouncementEntityVoConverter.java @@ -0,0 +1,31 @@ +package io.sc.platform.system.announcement.convertor; + +import io.sc.platform.orm.EntityVoConverter; +import io.sc.platform.system.announcement.jpa.entity.AnnouncementEntity; +import io.sc.platform.system.api.announcement.AnnouncementVo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AnnouncementEntityVoConverter implements EntityVoConverter { + private static final Logger log = LoggerFactory.getLogger(AnnouncementEntityVoConverter.class); + + @Override + public AnnouncementVo toVo(AnnouncementEntity entity) { + if(entity==null){ + return null; + } + AnnouncementVo vo =new AnnouncementVo(); + vo.setId(entity.getId()); + vo.setTitle(entity.getTitle()); + vo.setContent(entity.getContent()); + return vo; + } + + @Override + public AnnouncementEntity fromVo(AnnouncementVo vo) { + if(vo==null){ + return null; + } + return null; + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/entity/AnnouncementEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/entity/AnnouncementEntity.java new file mode 100644 index 00000000..1a2a66b7 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/entity/AnnouncementEntity.java @@ -0,0 +1,52 @@ +package io.sc.platform.system.announcement.jpa.entity; + +import io.sc.platform.orm.entity.AuditorEntity; +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; +import javax.validation.constraints.Size; + +@Entity +@Table(name="SYS_ANNOUNCEMENT") +public class AnnouncementEntity extends AuditorEntity { + //主键 + @Id + @GeneratedValue(generator = "system-uuid") + @GenericGenerator(name = "system-uuid", strategy = "uuid2") + @Column(name="ID_", length=36) + @Size(max=36) + private String id; + + //标题 + @Column(name="TITLE_", length=255) + @Size(max=255) + private String title; + + //公告内容 + @Column(name="CONTENT_") + private String content; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/repository/AnnouncementRepository.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/repository/AnnouncementRepository.java new file mode 100644 index 00000000..1e44034e --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/jpa/repository/AnnouncementRepository.java @@ -0,0 +1,8 @@ +package io.sc.platform.system.announcement.jpa.repository; + +import io.sc.platform.orm.repository.DaoRepository; +import io.sc.platform.system.announcement.jpa.entity.AnnouncementEntity; + +public interface AnnouncementRepository extends DaoRepository { + +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/AnnouncementService.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/AnnouncementService.java new file mode 100644 index 00000000..6f37d053 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/AnnouncementService.java @@ -0,0 +1,8 @@ +package io.sc.platform.system.announcement.service; + +import io.sc.platform.orm.service.DaoService; +import io.sc.platform.system.announcement.jpa.entity.AnnouncementEntity; +import io.sc.platform.system.announcement.jpa.repository.AnnouncementRepository; + +public interface AnnouncementService extends DaoService { +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/impl/AnnouncementServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/impl/AnnouncementServiceImpl.java new file mode 100644 index 00000000..b7711883 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/announcement/service/impl/AnnouncementServiceImpl.java @@ -0,0 +1,12 @@ +package io.sc.platform.system.announcement.service.impl; + +import io.sc.platform.orm.service.impl.DaoServiceImpl; +import io.sc.platform.system.announcement.jpa.entity.AnnouncementEntity; +import io.sc.platform.system.announcement.jpa.repository.AnnouncementRepository; +import io.sc.platform.system.announcement.service.AnnouncementService; +import org.springframework.stereotype.Service; + +@Service +public class AnnouncementServiceImpl extends DaoServiceImpl implements AnnouncementService { + +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/controller/AuditLogController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/controller/AuditLogController.java index 6ce385c9..4199c7ac 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/controller/AuditLogController.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/controller/AuditLogController.java @@ -1,18 +1,14 @@ package io.sc.platform.system.auditlog.controller; -import io.sc.platform.core.audit.AuditLog; import io.sc.platform.mvc.controller.support.RestCrudController; import io.sc.platform.system.auditlog.jpa.entity.AuditLogEntity; import io.sc.platform.system.auditlog.jpa.repository.AuditLogRepository; import io.sc.platform.system.auditlog.service.AuditLogService; -import io.sc.platform.system.corporation.jpa.entity.CorporationEntity; -import io.sc.platform.system.corporation.jpa.repository.CorporationRepository; -import io.sc.platform.system.corporation.service.CorporationService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/auditlog") +@RequestMapping("/api/system/monitor/auditlog") public class AuditLogController extends RestCrudController { } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/jpa/entity/AuditLogEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/jpa/entity/AuditLogEntity.java index dde810d3..51dc0161 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/jpa/entity/AuditLogEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/auditlog/jpa/entity/AuditLogEntity.java @@ -1,13 +1,11 @@ package io.sc.platform.system.auditlog.jpa.entity; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.sc.platform.core.audit.AuditLog; import io.sc.platform.orm.entity.BaseEntity; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import javax.validation.constraints.Size; -import java.io.Serializable; import java.util.Date; /** @@ -24,64 +22,64 @@ public class AuditLogEntity extends BaseEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID") + @Column(name="ID_") @Size(max=36) private String id; - @Column(name="_CLASS_NAME",length=255) + @Column(name="CLASS_NAME_",length=255) @Size(max=255) private String className; //AuditLog 注解所在类的名称 - @Column(name="_METHOD_NAME",length=255) + @Column(name="METHOD_NAME_",length=255) @Size(max=255) private String methodName; //AuditLog 注解所在方法的名称 - @Column(name="_HTTP_METHOD",length=20) + @Column(name="HTTP_METHOD_",length=20) @Size(max=20) private String httpMethod; //AuditLog 注解所在方法的 http 请求方法(get,post,put,update,delete) - @Column(name="_ACTION",length=255) + @Column(name="ACTION_",length=255) @Size(max=255) private String action; //AuditLog 注解中指定的日志操作 - @Column(name="_STATUS",length=20) + @Column(name="STATUS_",length=20) @Size(max=20) private String status; //请求方法的执行状态 - @Column(name="_START_DATE") + @Column(name="START_DATE_") @Temporal(TemporalType.TIMESTAMP) private Date startDate; //方法开始执行时间 - @Column(name="_EXECUTE_TIME") + @Column(name="EXECUTE_TIME_") private Long executeTime; //方法执行的时间(单位:毫秒) - @Column(name="_URL",length=2045) + @Column(name="URL_",length=2045) @Size(max=2048) private String url; //请求的 URL - @Column(name="_IP",length=50) + @Column(name="IP_",length=50) @Size(max=50) private String ip; //调用者 IP 地址 - @Column(name="_LOGIN_NAME",length=255) + @Column(name="LOGIN_NAME_",length=255) @Size(max=255) private String loginName; //调用者登录用户名 - @Column(name="_OLD_VALUE") + @Column(name="OLD_VALUE_") private String oldValue; //调用者请求的数据原始值(json字符串) - @Column(name="_NEW_VALUE") + @Column(name="NEW_VALUE_") private String newValue; //调用者请求的数据新值(json字符串) - @Column(name="_EXCEPTION",length=255) + @Column(name="EXCEPTION_",length=255) @Size(max=255) private String exception; //方法执行抛出的违例类名称 - @Column(name="_EXCEPTION_MESSAGE",length=1024) + @Column(name="EXCEPTION_MESSAGE_",length=1024) @Size(max=1024) private String exceptionMessage;//方法执行抛出的违例消息 - @Column(name="_EXCEPTION_STACK_TRACE") + @Column(name="EXCEPTION_STACK_TRACE_") private String exceptionStackTrace;//方法执行抛出的违例栈 diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/SystemParameterServiceAutoConfiguration.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/SystemParameterServiceAutoConfiguration.java new file mode 100644 index 00000000..61fe1dab --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/SystemParameterServiceAutoConfiguration.java @@ -0,0 +1,44 @@ +package io.sc.platform.system.autoconfigure; + +import io.sc.platform.core.i18n.MessageSourceBaseName; +import io.sc.platform.core.i18n.PlatformResourceBundleMessageSource; +import io.sc.platform.core.service.RuntimeService; +import io.sc.platform.mvc.autoconfigure.support.PluginSystemParameterServiceImpl; +import io.sc.platform.mvc.service.SystemParameterService; +import io.sc.platform.system.autoconfigure.support.CompositeMessageSource; +import io.sc.platform.system.autoconfigure.support.DatabaseMessageSource; +import io.sc.platform.system.autoconfigure.support.DatabaseSystemParameterServiceImpl; +import io.sc.platform.system.i18n.jpa.repository.I18nRepository; +import io.sc.platform.system.parameter.service.ParameterService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SearchStrategy; +import org.springframework.boot.autoconfigure.context.MessageSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.MessageSource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.AbstractApplicationContext; + +import java.time.Duration; + +/** + * 资源文件(通常用于国际化的资源文件)扫描自动配置 + * @author wangshaoping + * + */ +@Configuration +@AutoConfigureBefore(io.sc.platform.mvc.autoconfigure.MvcServiceProviderAutoConfiguration.class) +@EnableConfigurationProperties +public class SystemParameterServiceAutoConfiguration { + @Autowired private ApplicationContext applicationContext; + + @Bean + @ConditionalOnMissingBean + public SystemParameterService systemParameterService(){ + return new DatabaseSystemParameterServiceImpl(applicationContext); + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/support/DatabaseSystemParameterServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/support/DatabaseSystemParameterServiceImpl.java new file mode 100644 index 00000000..7238c126 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/autoconfigure/support/DatabaseSystemParameterServiceImpl.java @@ -0,0 +1,40 @@ +package io.sc.platform.system.autoconfigure.support; + +import io.sc.platform.mvc.service.SystemParameterService; +import io.sc.platform.system.parameter.service.ParameterService; +import org.springframework.context.ApplicationContext; + +import java.util.Map; + +public class DatabaseSystemParameterServiceImpl implements SystemParameterService { + private ParameterService parameterService; + + public DatabaseSystemParameterServiceImpl(ApplicationContext applicationContext){ + this.parameterService =applicationContext.getBean(ParameterService.class); + } + + @Override + public boolean containsParameter(String code) { + return parameterService.containsParameter(code); + } + + @Override + public String getParameter(String code) { + return parameterService.getParameter(code); + } + + @Override + public String getParameter(String code, String defaultValue) { + return parameterService.getParameter(code,defaultValue); + } + + @Override + public Map getParameters(String[] codes) { + return parameterService.getParameters(codes); + } + + @Override + public Map getParameters() { + return parameterService.getParameters(); + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/controller/CorporationController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/controller/CorporationController.java index 3e2a4039..01287fc4 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/controller/CorporationController.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/controller/CorporationController.java @@ -2,14 +2,16 @@ package io.sc.platform.system.corporation.controller; import io.sc.platform.mvc.controller.support.RestCrudController; import io.sc.platform.system.api.corporation.CorporationVo; +import io.sc.platform.system.corporation.convertor.CorporationEntityVoConverter; import io.sc.platform.system.corporation.jpa.entity.CorporationEntity; import io.sc.platform.system.corporation.jpa.repository.CorporationRepository; import io.sc.platform.system.corporation.service.CorporationService; +import io.sc.platform.system.org.convertor.OrgEntityVoConverter; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/corporation") +@RequestMapping("api/system/corporation") public class CorporationController extends RestCrudController { - + private CorporationEntityVoConverter converter =new CorporationEntityVoConverter(); } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/convertor/CorporationEntityVoConverter.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/convertor/CorporationEntityVoConverter.java new file mode 100644 index 00000000..9a70ff8a --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/convertor/CorporationEntityVoConverter.java @@ -0,0 +1,35 @@ +package io.sc.platform.system.corporation.convertor; + +import io.sc.platform.orm.EntityVoConverter; +import io.sc.platform.system.api.corporation.CorporationVo; +import io.sc.platform.system.api.org.OrgVo; +import io.sc.platform.system.corporation.jpa.entity.CorporationEntity; +import io.sc.platform.system.org.jpa.entity.OrgEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CorporationEntityVoConverter implements EntityVoConverter { + private static final Logger log = LoggerFactory.getLogger(CorporationEntityVoConverter.class); + + @Override + public CorporationVo toVo(CorporationEntity entity) { + if(entity==null){ + return null; + } + CorporationVo vo =new CorporationVo(); + vo.setCode(entity.getCode()); + vo.setName(entity.getName()); + vo.setDescription(entity.getDescription()); + vo.setEnable(entity.getEnable()); + vo.setParentCode(entity.getParent()==null?null:entity.getParent().getCode()); + return vo; + } + + @Override + public CorporationEntity fromVo(CorporationVo vo) { + if(vo==null){ + return null; + } + return null; + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/entity/CorporationEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/entity/CorporationEntity.java index 209017b8..ed261a39 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/entity/CorporationEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/entity/CorporationEntity.java @@ -17,28 +17,28 @@ import javax.validation.constraints.Size; public class CorporationEntity extends AuditorEntity { //法人代码 @Id - @Column(name="_CODE",nullable=false,length=255) + @Column(name="CODE_",nullable=false,length=255) @Size(min=1,max=255) private String code; //法人名称 - @Column(name="_NAME", length=255) + @Column(name="NAME_", length=255) @Size(min=1,max=255) private String name; //描述 - @Column(name="_DESCRIPTION", length=255) + @Column(name="DESCRIPTION_", length=255) @Size(max=255) private String description; //是否可用 - @Column(name="_ENABLE") + @Column(name="ENABLE_") @Convert(converter= NumericBooleanConverter.class) private Boolean enable; // 父法人 @ManyToOne(fetch=FetchType.LAZY) - @JoinColumn(name="_PARENT_CODE") + @JoinColumn(name="PARENT_CODE_") private CorporationEntity parent; public CorporationEntity(){} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/support/CorporationEntityJsonSerializer.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/support/CorporationEntityJsonSerializer.java index 729abc7f..28de4dbe 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/support/CorporationEntityJsonSerializer.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/corporation/jpa/support/CorporationEntityJsonSerializer.java @@ -13,11 +13,12 @@ public class CorporationEntityJsonSerializer extends JsonSerializer { + @PostMapping("updateDictionariesOrder") + public void updateDictionariesOrder(@RequestBody List> orderItems) throws Exception{ + service.updateDictionariesOrder(orderItems); + } } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/jpa/entity/DictionaryEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/jpa/entity/DictionaryEntity.java index e27a2f28..01413fc8 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/jpa/entity/DictionaryEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/jpa/entity/DictionaryEntity.java @@ -18,19 +18,19 @@ public class DictionaryEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID", length=36) + @Column(name="ID_", length=36) @Size(max=36) private String id; - @Column(name="_CODE", length=255) + @Column(name="CODE_", length=255) @Size(max=255) private String code; - @Column(name="_VALUE", length=255) + @Column(name="VALUE_", length=255) @Size(max=255) private String value; - @Column(name="_ORDER") + @Column(name="ORDER_") private Integer order; public DictionaryEntity() {} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/DictionaryService.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/DictionaryService.java index a3fd8081..9b451ee1 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/DictionaryService.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/DictionaryService.java @@ -1,8 +1,13 @@ package io.sc.platform.system.dictionary.service; +import io.sc.platform.mvc.support.OrderItem; import io.sc.platform.orm.service.DaoService; import io.sc.platform.system.dictionary.jpa.entity.DictionaryEntity; import io.sc.platform.system.dictionary.jpa.repository.DictionaryRepository; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; public interface DictionaryService extends DaoService { + public void updateDictionariesOrder(List> orderItems) throws Exception; } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/impl/DictionaryServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/impl/DictionaryServiceImpl.java index 5853fc31..a65e2801 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/impl/DictionaryServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/dictionary/service/impl/DictionaryServiceImpl.java @@ -1,12 +1,33 @@ package io.sc.platform.system.dictionary.service.impl; +import io.sc.platform.jdbc.util.SqlBatcher; +import io.sc.platform.mvc.support.OrderItem; import io.sc.platform.orm.service.impl.DaoServiceImpl; import io.sc.platform.system.dictionary.jpa.entity.DictionaryEntity; import io.sc.platform.system.dictionary.jpa.repository.DictionaryRepository; import io.sc.platform.system.dictionary.service.DictionaryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import javax.transaction.Transactional; +import java.util.List; + @Service public class DictionaryServiceImpl extends DaoServiceImpl implements DictionaryService { + @Autowired private JdbcTemplate jdbcTemplate; + @Override + @Transactional + public void updateDictionariesOrder(List> orderItems) throws Exception { + if(orderItems==null || orderItems.isEmpty()){ + return; + } + SqlBatcher sqlBatcher =new SqlBatcher("update SYS_DICTIONARY set ORDER_=? where ID_=?"); + for(OrderItem orderItem : orderItems) { + System.out.println(orderItem.getId() + "/" + orderItem.getOrder()); + sqlBatcher.addArg(new Object[]{orderItem.getOrder(),orderItem.getId()}); + } + sqlBatcher.execute(jdbcTemplate); + } } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/DsEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/DsEntity.java index 50f2b515..336a110f 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/DsEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/DsEntity.java @@ -16,7 +16,7 @@ import static javax.persistence.InheritanceType.SINGLE_TABLE; @Entity @Table(name="SYS_DATASOURCE") @Inheritance(strategy = SINGLE_TABLE) -@DiscriminatorColumn(name="_TYPE",discriminatorType=DiscriminatorType.STRING,length=20) +@DiscriminatorColumn(name="TYPE_",discriminatorType=DiscriminatorType.STRING,length=20) @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",defaultImpl=JdbcDsEntity.class, visible = true) @JsonSubTypes({ @JsonSubTypes.Type(value =JndiDsEntity.class, name = "JNDI"), @@ -26,22 +26,22 @@ public abstract class DsEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID") + @Column(name="ID_") @Size(max=36) private String id; //名称 - @Column(name="_NAME") + @Column(name="NAME_") @Size(max=255) private String name; //数据源类型 - @Column(name="_TYPE", insertable=false,updatable=false) + @Column(name="TYPE_", insertable=false,updatable=false) @Size(max=20) private String type; //描述 - @Column(name="_DESCRIPTION") + @Column(name="DESCRIPTION_") @Size(max=255) private String description; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JdbcDsEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JdbcDsEntity.java index 0280d1f6..675a483f 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JdbcDsEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JdbcDsEntity.java @@ -20,27 +20,27 @@ import java.util.Map; @DiscriminatorValue("JDBC") @JsonSerialize(using= JdbcDsEntityJsonSerializer.class) public class JdbcDsEntity extends DsEntity { - @Column(name="_JDBC_DATABASE_TYPE", length=20) + @Column(name="JDBC_DATABASE_TYPE_", length=20) @Size(max=20) private String databaseType; - @Column(name="_JDBC_DRIVER") + @Column(name="JDBC_DRIVER_") @Size(max=255) private String jdbcDriver; - @Column(name="_JDBC_URL") + @Column(name="JDBC_URL_") @Size(max=255) private String jdbcUrl; - @Column(name="_JDBC_USERNAME") + @Column(name="JDBC_USERNAME_") @Size(max=255) private String username; - @Column(name="_JDBC_PASSWORD") + @Column(name="JDBC_PASSWORD_") @Size(max=255) private String password; - @Column(name="_JDBC_PROPERTIES", length=2048) + @Column(name="JDBC_PROPERTIES_", length=2048) @Convert(converter = MapStringConverter.class) private Map properties; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JndiDsEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JndiDsEntity.java index fe522219..cbb2bcef 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JndiDsEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/ds/jpa/entity/JndiDsEntity.java @@ -15,7 +15,7 @@ import javax.validation.constraints.Size; @DiscriminatorValue("JNDI") @JsonSerialize(using= JndiDsEntityJsonSerializer.class) public class JndiDsEntity extends DsEntity { - @Column(name="_JNDI_NAME") + @Column(name="JNDI_NAME_") @Size(max=255) private String jndiName; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/i18n/jpa/entity/I18nEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/i18n/jpa/entity/I18nEntity.java index c655f29a..4660faf5 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/i18n/jpa/entity/I18nEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/i18n/jpa/entity/I18nEntity.java @@ -26,22 +26,22 @@ public class I18nEntity extends AuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID") + @Column(name="ID_") @Size(max=36) private String id; //消息代码 - @Column(name="_CODE",nullable=false) + @Column(name="CODE_",nullable=false) @Size(max=255) private String code; //语言 @Enumerated(EnumType.STRING) - @Column(name="_LANG") + @Column(name="LANG_") private Language lang; //消息文本 - @Column(name="_MESSAGE") + @Column(name="MESSAGE_") @Size(max=1024) private String message; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/initializer/ParameterInitializer.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/initializer/ParameterInitializer.java new file mode 100644 index 00000000..a5a68340 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/initializer/ParameterInitializer.java @@ -0,0 +1,68 @@ +package io.sc.platform.system.initializer; + +import io.sc.platform.core.initializer.ApplicationInitializer; +import io.sc.platform.core.initializer.ApplicationInitializerExecuteException; +import io.sc.platform.jdbc.sql.builder.InsertIntoSqlBuilder; +import io.sc.platform.system.parameter.service.ParameterService; +import org.springframework.context.ApplicationContext; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.util.Date; +import java.util.UUID; + +public class ParameterInitializer implements ApplicationInitializer { + private Boolean isInitialized =null; + private JdbcTemplate jdbcTemplate; + private ParameterService parameterService; + + @Override + public void init(ApplicationContext applicationContext) { + this.jdbcTemplate =applicationContext.getBean(JdbcTemplate.class); + this.parameterService =applicationContext.getBean(ParameterService.class); + } + + @Override + public synchronized boolean isInitialized() { + if(isInitialized!=null) { + return isInitialized; + } + if(parameterService.getRepository().count()<=0){ + isInitialized =false; + }else { + isInitialized = true; + } + return isInitialized; + } + + @Override + public void execute() throws ApplicationInitializerExecuteException { + InsertIntoSqlBuilder builder =new InsertIntoSqlBuilder(); + String systemId =UUID.randomUUID().toString(); + builder.table("SYS_PARAMETER") + .field("ID_", systemId) + .field("CODE_","parameter.system") + .field("VALUE_",null) + .field("PARENT_ID_",null) + .field("DATA_COME_FROM_","INPUT") + .field("CREATOR_","admin") + .field("CREATE_DATE_",new Date()) + .field("LAST_MODIFIER_","admin") + .field("LAST_MODIFYDATE_",new Date()) + .field("CORP_CODE_","ROOT") + .insert(jdbcTemplate); + + builder =new InsertIntoSqlBuilder(); + builder.table("SYS_PARAMETER") + .field("ID_", UUID.randomUUID().toString()) + .field("CODE_","parameter.system.homePage") + .field("VALUE_","/home") + .field("PARENT_ID_",systemId) + .field("DATA_COME_FROM_","INPUT") + .field("CREATOR_","admin") + .field("CREATE_DATE_",new Date()) + .field("LAST_MODIFIER_","admin") + .field("LAST_MODIFYDATE_",new Date()) + .field("CORP_CODE_","ROOT") + .insert(jdbcTemplate); + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/controller/MenuController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/controller/MenuController.java index 6fddad7d..1d6fb3c6 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/controller/MenuController.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/controller/MenuController.java @@ -2,10 +2,13 @@ package io.sc.platform.system.menu.controller; import io.sc.platform.mvc.controller.support.RestCrudController; import io.sc.platform.mvc.support.CascadeMany2Many; +import io.sc.platform.orm.service.support.QueryParameter; +import io.sc.platform.orm.service.support.QueryResult; import io.sc.platform.system.api.menu.MenuVo; import io.sc.platform.system.menu.jpa.entity.MenuEntity; import io.sc.platform.system.menu.jpa.repository.MenuRepository; import io.sc.platform.system.menu.service.MenuService; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -13,6 +16,36 @@ import java.util.List; @RestController @RequestMapping("/api/system/menu") public class MenuController extends RestCrudController { + /** + * 列出所有菜单树,并且将角色所拥有的菜单列表作出标记 + * @param roleId 角色ID + * @param queryParameter 查询参数 + * @return 列出所有菜单树,并且将角色所拥有的菜单列表作出标记 + * @throws Exception 违例 + */ + @GetMapping("listAllMenusWithSelectedStatusByRole") + public List listAllMenusWithSelectedStatusByRole(@RequestParam(name="roleId",required=false) String roleId, QueryParameter queryParameter) throws Exception{ + if(StringUtils.hasText(roleId)){ + return service.listAllMenusWithSelectedStatusByRole(roleId,queryParameter); + } + return QueryResult.emptyList(); + } + + /** + * 列出所有菜单树,并且将机构所拥有的菜单列表作出标记 + * @param orgId 机构ID + * @param queryParameter 查询参数 + * @return 列出所有菜单树,并且将机构所拥有的菜单列表作出标记 + * @throws Exception 违例 + */ + @GetMapping("listAllMenusWithSelectedStatusByOrg") + public List listAllMenusWithSelectedStatusByOrg(@RequestParam(name="orgId",required=false) String orgId, QueryParameter queryParameter) throws Exception{ + if(StringUtils.hasText(orgId)){ + return service.listAllMenusWithSelectedStatusByOrg(orgId,queryParameter); + } + return QueryResult.emptyList(); + } + /** * 给菜单添加角色 * @param wrapper 具有级联关系的菜单和角色关系封装器, 由于菜单具有级联关系(如果某个角色拥有一个子菜单的访问权限,那么该角色同时拥有该子菜单所有父菜单分类的访问权限), diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/convertor/MenuEntityVoConvertor.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/convertor/MenuEntityVoConvertor.java index 5a704353..9fd13bab 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/convertor/MenuEntityVoConvertor.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/convertor/MenuEntityVoConvertor.java @@ -27,8 +27,8 @@ public class MenuEntityVoConvertor implements EntityVoConverter map = ObjectMapper4Json.getMapper().readValue(query, new HashMap().getClass()); @@ -62,19 +62,19 @@ public class MenuEntityVoConvertor implements EntityVoConverter roles =new ArrayList(); @@ -89,14 +93,14 @@ public abstract class MenuEntity extends AuditorEntity implements IdClearable { @ManyToMany(fetch=FetchType.LAZY) @JoinTable( name = "SYS_ORG_MENU", - joinColumns = {@JoinColumn(name = "_MENU_ID", nullable = false,referencedColumnName="_ID")}, - inverseJoinColumns = {@JoinColumn(name = "_ORG_ID",nullable = false,referencedColumnName="_ID")} + joinColumns = {@JoinColumn(name = "MENU_ID_", nullable = false,referencedColumnName="ID_")}, + inverseJoinColumns = {@JoinColumn(name = "ORG_ID_",nullable = false,referencedColumnName="ID_")} ) protected List orgs =new ArrayList(); //父 @ManyToOne(fetch=FetchType.LAZY) - @JoinColumn(name="_PARENT_ID") + @JoinColumn(name="PARENT_ID_") protected MenuGroupEntity parent; public String getId() { diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuJavascriptEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuJavascriptEntity.java index 1a517b6f..5fcaac49 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuJavascriptEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuJavascriptEntity.java @@ -12,7 +12,7 @@ import javax.validation.constraints.Size; @DiscriminatorValue("JAVASCRIPT") public class MenuJavascriptEntity extends MenuEntity { //javascript 脚本 - @Column(name="_JAVA_SCRIPT", length=1024) + @Column(name="JAVA_SCRIPT_", length=1024) @Size(max=1024) private String javaScript; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuRouteEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuRouteEntity.java index 964f125a..4c6a8f86 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuRouteEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuRouteEntity.java @@ -20,11 +20,11 @@ import java.util.Set; @DiscriminatorValue("ROUTE") public class MenuRouteEntity extends MenuEntity { //路由ID - @Column(name="_ROUTE_NAME", length=255) + @Column(name="ROUTE_NAME_", length=255) @Size(max=255) private String routeName; - @Column(name="_ROUTE_QUERY", length=1024) + @Column(name="ROUTE_QUERY_", length=1024) @Convert(converter = MapStringConverter.class) private Map routeQuery =new HashMap<>(); diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuUrlEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuUrlEntity.java index 938498bd..7060f518 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuUrlEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/entity/MenuUrlEntity.java @@ -12,12 +12,12 @@ import javax.validation.constraints.Size; @DiscriminatorValue("URL") public class MenuUrlEntity extends MenuEntity { //菜单URL - @Column(name="_URL", length=1024) + @Column(name="URL_", length=1024) @Size(max=1024) private String url; //菜单URL打开方式 - @Column(name="_URL_OPEN_TYPE", length=50) + @Column(name="URL_OPEN_TYPE_", length=50) @Enumerated(EnumType.STRING) private UrlOpenType urlOpenType; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/support/MenuEntityJsonSerializer.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/support/MenuEntityJsonSerializer.java new file mode 100644 index 00000000..53b73a98 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/jpa/support/MenuEntityJsonSerializer.java @@ -0,0 +1,26 @@ +package io.sc.platform.system.menu.jpa.support; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import io.sc.platform.orm.entity.support.AuditorEntityJsonSerializer; +import io.sc.platform.orm.entity.support.CorporationAuditorEntityJsonSerializer; +import io.sc.platform.system.menu.jpa.entity.MenuEntity; +import io.sc.platform.system.org.jpa.entity.OrgEntity; + +import java.io.IOException; + +public class MenuEntityJsonSerializer extends JsonSerializer{ + @Override + public void serialize(MenuEntity value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { + gen.writeStartObject(); + gen.writeObjectField("id", value.getId()); + gen.writeObjectField("name", value.getName()); + gen.writeObjectField("titleI18nKey", value.getTitleI18nKey()); + gen.writeObjectField("enable", value.getEnable()); + gen.writeObjectField("parentId", value.getParent()==null?null:value.getParent().getId()); + AuditorEntityJsonSerializer.serializeJson(value, gen, serializers); + gen.writeEndObject(); + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/MenuService.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/MenuService.java index 3f4e6521..86a9b423 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/MenuService.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/MenuService.java @@ -2,13 +2,52 @@ package io.sc.platform.system.menu.service; import io.sc.platform.mvc.support.CascadeMany2Many; import io.sc.platform.orm.service.DaoService; +import io.sc.platform.orm.service.support.QueryParameter; import io.sc.platform.system.api.menu.MenuVo; import io.sc.platform.system.menu.jpa.entity.MenuEntity; import io.sc.platform.system.menu.jpa.repository.MenuRepository; +import io.sc.platform.system.org.jpa.entity.OrgEntity; import java.util.List; public interface MenuService extends DaoService { + + /** + * 列出所有菜单树,并且将角色所拥有的菜单列表作出标记 + * @param roleId 角色ID + * @param queryParameter 查询参数 + * @return 列出所有菜单树,并且将角色所拥有的菜单列表作出标记 + * @throws Exception 违例 + */ + public List listAllMenusWithSelectedStatusByRole(String roleId, QueryParameter queryParameter) throws Exception; + + /** + * 列出所有菜单树,并且将机构所拥有的菜单列表作出标记 + * @param orgId 机构ID + * @param queryParameter 查询参数 + * @return 列出所有菜单树,并且将机构所拥有的菜单列表作出标记 + * @throws Exception 违例 + */ + public List listAllMenusWithSelectedStatusByOrg(String orgId, QueryParameter queryParameter) throws Exception; + + /** + * 查询角色所拥有的菜单 + * @param roleId 角色ID + * @param queryParameter 查询参数 + * @return 角色所拥有的菜单 + * @throws Exception 违例 + */ + public List listMenusByRole(String roleId, QueryParameter queryParameter) throws Exception; + + /** + * 查询机构所拥有的菜单 + * @param orgId 机构ID + * @param queryParameter 查询参数 + * @return 机构所拥有的菜单 + * @throws Exception 违例 + */ + public List listMenusByOrg(String orgId, QueryParameter queryParameter) throws Exception; + /** * 给菜单添加角色 * @param wrapper 具有级联关系的菜单和角色多对多关系 Wrapper diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/impl/MenuServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/impl/MenuServiceImpl.java index 26bd136b..59307e14 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/impl/MenuServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/menu/service/impl/MenuServiceImpl.java @@ -4,25 +4,31 @@ import io.sc.platform.core.util.TreeBuilder; import io.sc.platform.jdbc.util.SqlBatcher; import io.sc.platform.mvc.support.CascadeMany2Many; import io.sc.platform.orm.service.impl.DaoServiceImpl; +import io.sc.platform.orm.service.support.QueryParameter; +import io.sc.platform.orm.service.support.QueryResult; import io.sc.platform.system.api.menu.MenuVo; +import io.sc.platform.system.api.org.OrgVo; import io.sc.platform.system.menu.convertor.MenuEntityPluginConvertor; import io.sc.platform.system.menu.convertor.MenuEntityVoConvertor; import io.sc.platform.system.menu.jpa.entity.MenuEntity; import io.sc.platform.system.menu.jpa.repository.MenuRepository; import io.sc.platform.system.menu.service.MenuService; import io.sc.platform.system.menu.service.support.MenuEntityTreeBuilder; +import io.sc.platform.system.org.convertor.OrgEntityVoConverter; +import io.sc.platform.system.org.jpa.entity.OrgEntity; import io.sc.platform.system.plugins.PluginManager; import io.sc.platform.system.plugins.item.MenuItem; +import io.sc.platform.system.role.jpa.entity.RoleEntity; +import io.sc.platform.system.user.jpa.entity.UserEntity; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import javax.persistence.criteria.Join; import javax.transaction.Transactional; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class MenuServiceImpl extends DaoServiceImpl implements MenuService { @@ -31,15 +37,80 @@ public class MenuServiceImpl extends DaoServiceImpl treeBuilder =new MenuEntityTreeBuilder(); @Autowired private JdbcTemplate jdbcTemplate; + @Override + public List listAllMenusWithSelectedStatusByRole(String roleId, QueryParameter queryParameter) throws Exception { + MenuEntityVoConvertor converter =new MenuEntityVoConvertor(); + List allMenuEntities =repository.findAll(); + List selectedMenuEntities =listMenusByRole(roleId,queryParameter); + List allMenus =converter.toVo(allMenuEntities); + List selectedMenus =converter.toVo(selectedMenuEntities); + Set selectedMenuIds =new HashSet<>(); + for(MenuVo selectedMenu : selectedMenus){ + selectedMenuIds.add(selectedMenu.getId()); + } + for(MenuVo allMenu : allMenus){ + if(selectedMenuIds.contains(allMenu.getId())) { + allMenu.setSelected(true); + } + } + return allMenus; + } + + @Override + public List listAllMenusWithSelectedStatusByOrg(String orgId, QueryParameter queryParameter) throws Exception { + MenuEntityVoConvertor converter =new MenuEntityVoConvertor(); + List allMenuEntities =repository.findAll(); + List selectedMenuEntities =listMenusByOrg(orgId,queryParameter); + List allMenus =converter.toVo(allMenuEntities); + List selectedMenus =converter.toVo(selectedMenuEntities); + Set selectedMenuIds =new HashSet<>(); + for(MenuVo selectedMenu : selectedMenus){ + selectedMenuIds.add(selectedMenu.getId()); + } + for(MenuVo allMenu : allMenus){ + if(selectedMenuIds.contains(allMenu.getId())) { + allMenu.setSelected(true); + } + } + return allMenus; + } + + @Override + public List listMenusByRole(String roleId, QueryParameter queryParameter) throws Exception { + if(StringUtils.hasText(roleId)) { + Specification specification = (root, query, criteriaBuilder) -> { + Join join = root.join("roles"); + return criteriaBuilder.equal(join.get("id"), roleId); + }; + return this.list(specification, queryParameter); + } + return QueryResult.emptyList(); + } + + @Override + public List listMenusByOrg(String orgId, QueryParameter queryParameter) throws Exception { + if(StringUtils.hasText(orgId)) { + Specification specification = (root, query, criteriaBuilder) -> { + Join join = root.join("orgs"); + return criteriaBuilder.equal(join.get("id"), orgId); + }; + return this.list(specification, queryParameter); + } + return QueryResult.emptyList(); + } + @Override @Transactional public void addRoles(CascadeMany2Many wrapper) throws Exception { if(wrapper==null){return;} if(wrapper.getTargets()!=null && wrapper.getTargets().size()>0){ - wrapper.getSourceAndChildren().addAll(wrapper.getSourceCascadeParent()); - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(_ROLE_ID,_MENU_ID) values(?,?)"); + Set sourceIds =new HashSet<>(); + sourceIds.add(wrapper.getSource()); + sourceIds.addAll(wrapper.getSourceParents()); + sourceIds.addAll(wrapper.getSourceChildren()); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(ROLE_ID_,MENU_ID_) values(?,?)"); for(String roleId : wrapper.getTargets()){ - for(String menuId : wrapper.getSourceAndChildren()){ + for(String menuId : sourceIds){ sqlBatcher.addArg(new Object[]{roleId,menuId}); } } @@ -52,18 +123,21 @@ public class MenuServiceImpl extends DaoServiceImpl wrapper) throws Exception { if(wrapper==null){return;} - List> roles =jdbcTemplate.queryForList("select _ID from SYS_ROLE"); + List> roles =jdbcTemplate.queryForList("select ID_ from SYS_ROLE"); List roleIds =new ArrayList(); if(roles!=null && roles.size()>0){ for(Map row : roles){ - roleIds.add((String)row.get("_ID")); + roleIds.add((String)row.get("ID_")); } } if(roleIds!=null && roleIds.size()>0){ - wrapper.getSourceAndChildren().addAll(wrapper.getSourceCascadeParent()); - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(_ROLE_ID,_MENU_ID) values(?,?)"); + Set sourceIds =new HashSet<>(); + sourceIds.add(wrapper.getSource()); + sourceIds.addAll(wrapper.getSourceParents()); + sourceIds.addAll(wrapper.getSourceChildren()); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(ROLE_ID_,MENU_ID_) values(?,?)"); for(String roleId : roleIds){ - for(String menuId : wrapper.getSourceAndChildren()){ + for(String menuId : sourceIds){ sqlBatcher.addArg(new Object[]{roleId,menuId}); } } @@ -77,9 +151,12 @@ public class MenuServiceImpl extends DaoServiceImpl wrapper) throws Exception { if(wrapper==null){return;} if(wrapper.getTargets()!=null && wrapper.getTargets().size()>0){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where _MENU_ID=? and _ROLE_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where MENU_ID_=? and ROLE_ID_=?"); for(String roleId : wrapper.getTargets()){ - for(String menuId : wrapper.getSourceAndChildren()){ + Set sourceIds =new HashSet<>(); + sourceIds.add(wrapper.getSource()); + sourceIds.addAll(wrapper.getSourceChildren()); + for(String menuId : sourceIds){ if(StringUtils.hasText(menuId) && StringUtils.hasText(roleId)){ sqlBatcher.addArg(new Object[]{menuId,roleId}); } @@ -94,8 +171,11 @@ public class MenuServiceImpl extends DaoServiceImpl wrapper) throws Exception { if(wrapper==null){return;} - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where _MENU_ID=?"); - for(String menuId : wrapper.getSourceAndChildren()){ + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where MENU_ID_=?"); + Set sourceIds =new HashSet<>(); + sourceIds.add(wrapper.getSource()); + sourceIds.addAll(wrapper.getSourceChildren()); + for(String menuId : sourceIds){ if(StringUtils.hasText(menuId)){ sqlBatcher.addArg(new Object[]{menuId}); } @@ -108,11 +188,13 @@ public class MenuServiceImpl extends DaoServiceImpl wrapper) throws Exception { if(wrapper==null){return;} - - if(wrapper.getSourceAndChildren()!=null && wrapper.getSourceAndChildren().size()>0){ + Set sourceIds =new HashSet<>(); + sourceIds.add(wrapper.getSource()); + sourceIds.addAll(wrapper.getSourceChildren()); + if(sourceIds!=null && sourceIds.size()>0){ //删除当前选中菜单及其子菜单和机构的关系 - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where _MENU_ID=?"); - for(String menuId : wrapper.getSourceAndChildren()){ + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where MENU_ID_=?"); + for(String menuId : sourceIds){ if(StringUtils.hasText(menuId)){ sqlBatcher.addArg(new Object[]{menuId}); } @@ -121,10 +203,10 @@ public class MenuServiceImpl extends DaoServiceImpl0){ - wrapper.getSourceAndChildren().addAll(wrapper.getSourceCascadeParent()); - sqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(_ORG_ID,_MENU_ID) values(?,?)"); + sourceIds.addAll(wrapper.getSourceParents()); + sqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(ORG_ID_,MENU_ID_) values(?,?)"); for(String orgId : wrapper.getTargets()){ - for(String menuId : wrapper.getSourceAndChildren()){ + for(String menuId : sourceIds){ sqlBatcher.addArg(new Object[]{orgId,menuId}); } } @@ -172,7 +254,7 @@ public class MenuServiceImpl extends DaoServiceImpl getAllMenus() { - List entities =jdbcTemplate.query("select * from SYS_MENU order by _ORDER",new MenuEntityVoConvertor()); + List entities =jdbcTemplate.query("select * from SYS_MENU where ENABLE_=1 order by ORDER_",new MenuEntityVoConvertor()); return voConverter.toVo(entities); } @@ -180,33 +262,33 @@ public class MenuServiceImpl extends DaoServiceImpl'GROUP'" + + " on A.MENU_ID_=B.ID_" + + " where B.TYPE_<>'GROUP'" + " )" + " ) TMP" + ")"; jdbcTemplate.update(sql); //删除重复的关系记录 - sql =" select _ROLE_ID,_MENU_ID from SYS_ROLE_MENU" - + " group by _ROLE_ID,_MENU_ID" + sql =" select ROLE_ID_,MENU_ID_ from SYS_ROLE_MENU" + + " group by ROLE_ID_,MENU_ID_" + " having count(*)>1"; List> result =jdbcTemplate.queryForList(sql); if(result!=null && result.size()>0){ - SqlBatcher deleteSqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where _ROLE_ID=? and _MENU_ID=?"); - SqlBatcher insertSqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(_ROLE_ID,_MENU_ID) values(?,?)"); + SqlBatcher deleteSqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where ROLE_ID_=? and MENU_ID_=?"); + SqlBatcher insertSqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(ROLE_ID_,MENU_ID_) values(?,?)"); for(Map row : result){ - deleteSqlBatcher.addArg(new Object[]{row.get("_ROLE_ID"),row.get("_MENU_ID")}); - insertSqlBatcher.addArg(new Object[]{row.get("_ROLE_ID"),row.get("_MENU_ID")}); + deleteSqlBatcher.addArg(new Object[]{row.get("ROLE_ID_"),row.get("MENU_ID_")}); + insertSqlBatcher.addArg(new Object[]{row.get("ROLE_ID_"),row.get("MENU_ID_")}); } deleteSqlBatcher.execute(jdbcTemplate); insertSqlBatcher.execute(jdbcTemplate); @@ -217,33 +299,33 @@ public class MenuServiceImpl extends DaoServiceImpl'GROUP'" + + " on A.MENU_ID_=B.ID_" + + " where B.TYPE_<>'GROUP'" + " )" + " ) TMP" + ")"; jdbcTemplate.update(sql); //删除重复的关系记录 - sql =" select _ORG_ID,_MENU_ID from SYS_ORG_MENU" - + " group by _ORG_ID,_MENU_ID" + sql =" select ORG_ID_,MENU_ID_ from SYS_ORG_MENU" + + " group by ORG_ID_,MENU_ID_" + " having count(*)>1"; List> result =jdbcTemplate.queryForList(sql); if(result!=null && result.size()>0){ - SqlBatcher deleteSqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where _ORG_ID=? and _MENU_ID=?"); - SqlBatcher insertSqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(_ORG_ID,_MENU_ID) values(?,?)"); + SqlBatcher deleteSqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where ORG_ID_=? and MENU_ID_=?"); + SqlBatcher insertSqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(ORG_ID_,MENU_ID_) values(?,?)"); for(Map row : result){ - deleteSqlBatcher.addArg(new Object[]{row.get("_ORG_ID"),row.get("_MENU_ID")}); - insertSqlBatcher.addArg(new Object[]{row.get("_ORG_ID"),row.get("_MENU_ID")}); + deleteSqlBatcher.addArg(new Object[]{row.get("ORG_ID_"),row.get("MENU_ID_")}); + insertSqlBatcher.addArg(new Object[]{row.get("ORG_ID_"),row.get("MENU_ID_")}); } deleteSqlBatcher.execute(jdbcTemplate); insertSqlBatcher.execute(jdbcTemplate); diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/monitor/controller/LogViewerController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/monitor/controller/LogViewerController.java new file mode 100644 index 00000000..f3f63d7e --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/monitor/controller/LogViewerController.java @@ -0,0 +1,161 @@ +package io.sc.platform.system.monitor.controller; + +import io.sc.platform.core.DirectoryManager; +import io.sc.platform.core.support.LoggerLevelInfo; +import io.sc.platform.core.util.FileUtil; +import io.sc.platform.core.util.StringUtil; +import io.sc.platform.mvc.support.FileDownloader; +import io.sc.platform.orm.service.support.QueryResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.actuate.logging.LoggersEndpoint; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.data.domain.Page; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.*; + +@RestController +@RequestMapping("/api/monitor/logger") +public class LogViewerController { + @Autowired private LoggersEndpoint loggersEndpoint; + + @PostMapping("getLogFileContents") + public String getLogFileContents(@RequestBody Map parameter) throws IOException { + String path =DirectoryManager.getInstance().getByName("dir.log") + "/log.log"; + return FileUtil.readStringAsLastRow(path, parameter.get("rows")); + } + + @GetMapping("getLogFiles") + public Page getLogFiles() throws IOException { + File dir =new File(DirectoryManager.getInstance().getByName("dir.log")); + File[] files =dir.listFiles(); + if(files!=null && files.length>0){ + List result =new ArrayList(); + for(File file : files){ + FileWrapper wrapper =new FileWrapper(file.getName(),new Date(file.lastModified()), StringUtil.commaStyle(file.length())); + result.add(wrapper); + } + return QueryResult.page(result); + } + return QueryResult.emptyPage(); + } + + @GetMapping("getLogConfigurationLevels") + public Page getLogConfigurationLevels(LoggerLevelInfo levelInfo) throws Exception{ + return QueryResult.page(findLevelsFromActuator(levelInfo)); + } + + /** + * 下载日志文件 + * @param fileName 文件名 + * @param request HttpServletRequest 对象 + * @param response HttpServletResponse 对象 + * @throws Exception 违例 + */ + @RequestMapping(value="downloadLogFile/{fileName:.+}",method=RequestMethod.GET) + public void downloadLogFile(@PathVariable("fileName") String fileName, HttpServletRequest request, HttpServletResponse response) throws Exception{ + Resource resource =new DefaultResourceLoader().getResource("file://" + DirectoryManager.getInstance().getByName("dir.log") + "/" + fileName); + FileDownloader.download(request, response, fileName, resource); + } + + + private static class FileWrapper{ + private String name; + private Date lastModifyDate; + private String size; + + public FileWrapper(String name,Date lastModifyDate,String size){ + this.name =name; + this.lastModifyDate =lastModifyDate; + this.size =size; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getLastModifyDate() { + return lastModifyDate; + } + + public void setLastModifyDate(Date lastModifyDate) { + this.lastModifyDate = lastModifyDate; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + } + + public List findLevelsFromActuator(LoggerLevelInfo levelInfo) throws Exception { + Map configurations =loggersEndpoint.loggers(); + if(configurations==null){ + return Collections.emptyList(); + } + Object o =configurations.get("loggers"); + if(o==null){ + return Collections.emptyList(); + } + List result =new ArrayList(); + if(o instanceof Map){ + Map map =(Map)o; + for(String key : map.keySet()){ + LoggersEndpoint.LoggerLevels loggerLevels =map.get(key); + result.add(new LoggerLevelInfo(key,loggerLevels.getConfiguredLevel(),"INFO")); + } + } + + if( + !StringUtils.hasText(levelInfo.getName()) + && levelInfo.getConfiguredLevel()!=null + && levelInfo.getEffectiveLevel()!=null + ){ + return result; + } + //filter + List filter =new ArrayList(); + if(StringUtils.hasText(levelInfo.getName())){ + for(LoggerLevelInfo info : result){ + if(info.getName().toLowerCase().contains(levelInfo.getName().trim().toLowerCase())){ + filter.add(info); + } + } + result =filter; + } + + filter =new ArrayList(); + if(levelInfo.getConfiguredLevel()!=null){ + for(LoggerLevelInfo info : result){ + if(info.getConfiguredLevel()!=null && info.getConfiguredLevel().equals(levelInfo.getConfiguredLevel())){ + filter.add(info); + } + } + result =filter; + } + + filter =new ArrayList(); + if(levelInfo.getEffectiveLevel()!=null){ + for(LoggerLevelInfo info : result){ + if(info.getEffectiveLevel()!=null && info.getEffectiveLevel().equals(levelInfo.getEffectiveLevel())){ + filter.add(info); + } + } + result =filter; + } + return result; + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/controller/OrgController.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/controller/OrgController.java index 10e03375..376711e5 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/controller/OrgController.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/controller/OrgController.java @@ -19,6 +19,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.Date; +import java.util.List; @RestController @RequestMapping("/api/system/org") @@ -32,13 +33,28 @@ public class OrgController extends RestCrudController queryOrgsByUser(@RequestParam(name="userId",required=false) String userId, QueryParameter queryParameter) throws Exception{ + @GetMapping("listAllOrgsWithSelectedStatusByUser") + public List listAllOrgsWithSelectedStatusByUser(@RequestParam(name="userId",required=false) String userId, QueryParameter queryParameter) throws Exception{ if(StringUtils.hasText(userId)){ - Page result =service.queryOrgsByUser(userId,queryParameter); + return service.listAllOrgsWithSelectedStatusByUser(userId,queryParameter); + } + return QueryResult.emptyList(); + } + + /** + * 查询用户所属机构 + * @param userId 用户ID + * @param queryParameter 查询参数 + * @return 用户所属机构 + * @throws Exception 违例 + */ + @GetMapping("listOrgsByUser") + public List listOrgsByUser(@RequestParam(name="userId",required=false) String userId, QueryParameter queryParameter) throws Exception{ + if(StringUtils.hasText(userId)){ + List result =service.listOrgsByUser(userId,queryParameter); return converter.toVo(result); } - return QueryResult.emptyPage(); + return QueryResult.emptyList(); } /** @@ -48,13 +64,13 @@ public class OrgController extends RestCrudController queryOtherOrgsByUser(@RequestParam(name="userId",required=false) String userId,QueryParameter queryParameter) throws Exception{ + @GetMapping("listOtherOrgsByUser") + public List listOtherOrgsByUser(@RequestParam(name="userId",required=false) String userId,QueryParameter queryParameter) throws Exception{ if(StringUtils.hasText(userId)){ - Page result =service.queryOtherOrgsByUser(userId,queryParameter); + List result =service.listOtherOrgsByUser(userId,queryParameter); return converter.toVo(result); } - return QueryResult.emptyPage(); + return QueryResult.emptyList(); } /** diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/convertor/OrgEntityVoConverter.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/convertor/OrgEntityVoConverter.java index 0d337f27..8ad39639 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/convertor/OrgEntityVoConverter.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/convertor/OrgEntityVoConverter.java @@ -21,7 +21,7 @@ public class OrgEntityVoConverter implements EntityVoConverter vo.setDescription(entity.getDescription()); vo.setEnable(entity.getEnable()); vo.setDepartment(entity.getIsDepartment()); - vo.setParentId(entity.getParent().getId()); + vo.setParentId(entity.getParent()==null?null:entity.getParent().getId()); return vo; } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/entity/OrgEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/entity/OrgEntity.java index 3947c4aa..42014f56 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/entity/OrgEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/entity/OrgEntity.java @@ -24,32 +24,32 @@ public class OrgEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID", length=36) + @Column(name="ID_", length=36) @Size(max=36) private String id; //组织结构代码 - @Column(name="_CODE",nullable=false,length=255) + @Column(name="CODE_",nullable=false,length=255) @Size(min=1,max=255) private String code; //组织名称 - @Column(name="_NAME", length=255) + @Column(name="NAME_", length=255) @Size(min=1,max=255) private String name; //描述 - @Column(name="_DESCRIPTION", length=255) + @Column(name="DESCRIPTION_", length=255) @Size(max=255) private String description; //是否可用 - @Column(name="_ENABLE") + @Column(name="ENABLE_") @Convert(converter= NumericBooleanConverter.class) private Boolean enable; //是否是部门 - @Column(name="_IS_DEPARTMENT") + @Column(name="IS_DEPARTMENT_") @Convert(converter=NumericBooleanConverter.class) private Boolean isDepartment; @@ -63,7 +63,7 @@ public class OrgEntity extends CorporationAuditorEntity { //父组织 @ManyToOne(fetch=FetchType.LAZY) - @JoinColumn(name="_PARENT_ID") + @JoinColumn(name="PARENT_ID_") private OrgEntity parent; //直接孩子组织集合 diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/support/OrgEntityJsonSerializer.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/support/OrgEntityJsonSerializer.java index 8cf088dc..616140ff 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/support/OrgEntityJsonSerializer.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/jpa/support/OrgEntityJsonSerializer.java @@ -19,7 +19,7 @@ public class OrgEntityJsonSerializer extends JsonSerializer{ gen.writeObjectField("description", value.getDescription()); gen.writeObjectField("enable", value.getEnable()); gen.writeObjectField("isDepartment", value.getIsDepartment()); - gen.writeObjectField("parent", value.getParent()==null?null:value.getParent().getCode()); + gen.writeObjectField("parentId", value.getParent()==null?null:value.getParent().getId()); CorporationAuditorEntityJsonSerializer.serializeJson(value, gen, serializers); gen.writeEndObject(); } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/OrgService.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/OrgService.java index b3f80ad6..3ab9c214 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/OrgService.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/OrgService.java @@ -2,13 +2,34 @@ package io.sc.platform.system.org.service; import io.sc.platform.orm.service.DaoService; import io.sc.platform.orm.service.support.QueryParameter; +import io.sc.platform.system.api.org.OrgVo; import io.sc.platform.system.org.jpa.entity.OrgEntity; import io.sc.platform.system.org.jpa.repository.OrgRepository; import org.springframework.data.domain.Page; +import java.util.List; import java.util.Set; public interface OrgService extends DaoService { + + /** + * 获取所有机构树,并对当前登录用户所属的机构做标记 + * @param userId 用户ID + * @param queryParameter 查询参数 + * @return 所有机构树,并对当前登录用户所属的机构做标记 + * @throws Exception 违例 + */ + public List listAllOrgsWithSelectedStatusByUser(String userId, QueryParameter queryParameter) throws Exception; + + /** + * 查询用户所属的机构 + * @param userId 用户ID + * @param queryParameter 查询参数 + * @return 用户所属的机构 + * @throws Exception 违例 + */ + public List listOrgsByUser(String userId, QueryParameter queryParameter) throws Exception; + /** * 查询用户所属的机构 * @param userId 用户ID @@ -18,6 +39,15 @@ public interface OrgService extends DaoService */ public Page queryOrgsByUser(String userId, QueryParameter queryParameter) throws Exception; + /** + * 查询用户不属于的机构 + * @param userId 用户ID + * @param queryParameter 查询参数 + * @return 用户不属于的机构 + * @throws Exception 违例 + */ + public List listOtherOrgsByUser(String userId, QueryParameter queryParameter) throws Exception; + /** * 查询用户不属于的机构 * @param userId 用户ID diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/impl/OrgServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/impl/OrgServiceImpl.java index 557ee478..d394bf15 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/impl/OrgServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/org/service/impl/OrgServiceImpl.java @@ -4,6 +4,8 @@ import io.sc.platform.jdbc.util.SqlBatcher; import io.sc.platform.orm.service.impl.DaoServiceImpl; import io.sc.platform.orm.service.support.QueryParameter; import io.sc.platform.orm.service.support.QueryResult; +import io.sc.platform.system.api.org.OrgVo; +import io.sc.platform.system.org.convertor.OrgEntityVoConverter; import io.sc.platform.system.org.jpa.entity.OrgEntity; import io.sc.platform.system.org.jpa.repository.OrgRepository; import io.sc.platform.system.org.service.OrgService; @@ -21,6 +23,9 @@ import javax.persistence.criteria.*; import javax.transaction.Transactional; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; import java.util.Set; @Service @@ -28,6 +33,37 @@ public class OrgServiceImpl extends DaoServiceImpl listAllOrgsWithSelectedStatusByUser(String userId, QueryParameter queryParameter) throws Exception { + OrgEntityVoConverter converter =new OrgEntityVoConverter(); + List allOrgEntities =repository.findAll(); + List selectedOrgEntities =listOrgsByUser(userId,queryParameter); + List allOrgs =converter.toVo(allOrgEntities); + List selectedOrgs =converter.toVo(selectedOrgEntities); + Set selectedOrgIds =new HashSet<>(); + for(OrgVo selectedOrg : selectedOrgs){ + selectedOrgIds.add(selectedOrg.getId()); + } + for(OrgVo allOrg : allOrgs){ + if(selectedOrgIds.contains(allOrg.getId())) { + allOrg.setSelected(true); + } + } + return allOrgs; + } + + @Override + public List listOrgsByUser(String userId, QueryParameter queryParameter) throws Exception { + if(StringUtils.hasText(userId)) { + Specification specification = (root, query, criteriaBuilder) -> { + Join join = root.join("users"); + return criteriaBuilder.equal(join.get("id"), userId); + }; + return this.list(specification, queryParameter); + } + return QueryResult.emptyList(); + } + @Override public Page queryOrgsByUser(String userId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(userId)) { @@ -40,12 +76,25 @@ public class OrgServiceImpl extends DaoServiceImpl listOtherOrgsByUser(String userId, QueryParameter queryParameter) throws Exception { + if(StringUtils.hasText(userId)) { + Specification specification = (root, query, criteriaBuilder) -> { + Join join = root.join("users",JoinType.LEFT); + return criteriaBuilder.isNull(join.get("id")); + }; + return this.list(specification, queryParameter); + } + return QueryResult.emptyList(); + } + @Override public Page queryOtherOrgsByUser(String userId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(userId)) { Specification specification = (root, query, criteriaBuilder) -> { + query.distinct(true); Join join = root.join("users"); - return criteriaBuilder.notEqual(join.get("id"), userId); + return criteriaBuilder.or(criteriaBuilder.notEqual(join.get("id"), userId),criteriaBuilder.isNull(join.get("id"))); }; return this.query(specification, queryParameter); } @@ -56,7 +105,7 @@ public class OrgServiceImpl extends DaoServiceImpl userIds) throws Exception { if(StringUtils.hasText(orgId) && userIds!=null && userIds.size()>0){ - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ORG(_USER_ID,_ORG_ID) values(?,?)"); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ORG(USER_ID_,ORG_ID_) values(?,?)"); for(String userId : userIds){ sqlBatcher.addArg(new Object[]{userId,orgId}); } @@ -71,12 +120,12 @@ public class OrgServiceImpl extends DaoServiceImpl userIds) throws Exception { if(StringUtils.hasText(orgId) && userIds!=null && !userIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ORG where _USER_ID=? and _ORG_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ORG where USER_ID_=? and ORG_ID_=?"); for(String userId : userIds){ sqlBatcher.addArg(new Object[]{userId,orgId}); } @@ -99,7 +148,7 @@ public class OrgServiceImpl extends DaoServiceImpl menuIds) throws Exception { if(StringUtils.hasText(orgId) && menuIds!=null && !menuIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(_MENU_ID,_ORG_ID) values(?,?)"); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ORG_MENU(MENU_ID_,ORG_ID_) values(?,?)"); for(String menuId : menuIds){ sqlBatcher.addArg(new Object[]{menuId,orgId}); } @@ -128,12 +177,12 @@ public class OrgServiceImpl extends DaoServiceImpl menuIds) throws Exception { if(StringUtils.hasText(orgId) && menuIds!=null && menuIds.size()>0){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where _MENU_ID=? and _ORG_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ORG_MENU where MENU_ID_=? and ORG_ID_=?"); for(String menuId : menuIds){ sqlBatcher.addArg(new Object[]{menuId,orgId}); } @@ -156,7 +205,7 @@ public class OrgServiceImpl extends DaoServiceImpl { } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/convertor/ParameterEntityVoConverter.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/convertor/ParameterEntityVoConverter.java new file mode 100644 index 00000000..84589495 --- /dev/null +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/convertor/ParameterEntityVoConverter.java @@ -0,0 +1,34 @@ +package io.sc.platform.system.parameter.convertor; + +import io.sc.platform.orm.EntityVoConverter; +import io.sc.platform.system.api.org.OrgVo; +import io.sc.platform.system.api.parameter.ParameterVo; +import io.sc.platform.system.org.jpa.entity.OrgEntity; +import io.sc.platform.system.parameter.jpa.entity.ParameterEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ParameterEntityVoConverter implements EntityVoConverter { + private static final Logger log = LoggerFactory.getLogger(ParameterEntityVoConverter.class); + + @Override + public ParameterVo toVo(ParameterEntity entity) { + if(entity==null){ + return null; + } + ParameterVo vo =new ParameterVo(); + vo.setId(entity.getId()); + vo.setCode(entity.getCode()); + vo.setValue(entity.getValue()); + vo.setParentId(entity.getParent()==null?null:entity.getParent().getId()); + return vo; + } + + @Override + public ParameterEntity fromVo(ParameterVo vo) { + if(vo==null){ + return null; + } + return null; + } +} diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/entity/ParameterEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/entity/ParameterEntity.java index f16cb74e..e98c6f74 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/entity/ParameterEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/entity/ParameterEntity.java @@ -1,17 +1,12 @@ package io.sc.platform.system.parameter.jpa.entity; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import io.sc.platform.orm.converter.NumericBooleanConverter; -import io.sc.platform.orm.entity.AuditorEntity; -import io.sc.platform.orm.entity.BaseEntity; import io.sc.platform.orm.entity.CorporationAuditorEntity; -import io.sc.platform.system.api.parameter.Parameter; import io.sc.platform.system.parameter.jpa.support.ParameterEntityJsonSerializer; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import javax.validation.constraints.Size; -import java.io.Serializable; /** * 法人实体类 @@ -23,18 +18,27 @@ public class ParameterEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID", length=36) + @Column(name="ID_", length=36) @Size(max=36) private String id; - @Column(name="_CODE") + @Column(name="CODE_") @Size(max=255) private String code; - @Column(name="_VALUE") + @Column(name="VALUE_") @Size(max=255) private String value; + @ManyToOne(fetch=FetchType.LAZY) + @JoinColumn(name="PARENT_ID_") + private ParameterEntity parent; + + public ParameterEntity(){} + public ParameterEntity(String id){ + this.id =id; + } + public String getId() { return id; } @@ -58,4 +62,12 @@ public class ParameterEntity extends CorporationAuditorEntity { public void setValue(String value) { this.value = value; } + + public ParameterEntity getParent() { + return parent; + } + + public void setParent(ParameterEntity parent) { + this.parent = parent; + } } \ No newline at end of file diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/repository/ParameterRepository.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/repository/ParameterRepository.java index 19709f61..c9130d3c 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/repository/ParameterRepository.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/repository/ParameterRepository.java @@ -2,7 +2,14 @@ package io.sc.platform.system.parameter.jpa.repository; import io.sc.platform.orm.repository.DaoRepository; import io.sc.platform.system.parameter.jpa.entity.ParameterEntity; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.List; public interface ParameterRepository extends DaoRepository { + public ParameterEntity getByCode(String code); + @Query("select entity from ParameterEntity entity where entity.code in (:codes)") + public List findByCodes(@Param("codes")String[] codes); } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/support/ParameterEntityJsonSerializer.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/support/ParameterEntityJsonSerializer.java index 0e45fc6a..5203e296 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/support/ParameterEntityJsonSerializer.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/jpa/support/ParameterEntityJsonSerializer.java @@ -17,6 +17,7 @@ public class ParameterEntityJsonSerializer extends JsonSerializer { +public interface ParameterService extends DaoService, SystemParameterService { } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/service/impl/ParameterServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/service/impl/ParameterServiceImpl.java index 656beb42..60734881 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/service/impl/ParameterServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/parameter/service/impl/ParameterServiceImpl.java @@ -5,8 +5,71 @@ import io.sc.platform.system.parameter.jpa.entity.ParameterEntity; import io.sc.platform.system.parameter.jpa.repository.ParameterRepository; import io.sc.platform.system.parameter.service.ParameterService; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Service public class ParameterServiceImpl extends DaoServiceImpl implements ParameterService { + @Override + public boolean containsParameter(String code) { + if(StringUtils.hasText(code)) { + ParameterEntity entity = repository.getByCode(code); + return entity!=null; + } + return false; + } + + @Override + public String getParameter(String code) { + if(StringUtils.hasText(code)) { + ParameterEntity entity = repository.getByCode(code); + if(entity!=null) { + return entity.getValue(); + } + } + return null; + } + + @Override + public String getParameter(String code, String defaultValue) { + if(StringUtils.hasText(code)) { + ParameterEntity entity = repository.getByCode(code); + if(entity!=null) { + return StringUtils.hasText(entity.getValue())?entity.getValue():defaultValue; + } + } + return defaultValue; + } + + @Override + public Map getParameters(String[] codes) { + if(codes!=null && codes.length>0){ + List entities = repository.findByCodes(codes); + if(entities!=null && !entities.isEmpty()){ + Map result =new HashMap<>(); + for(ParameterEntity entity : entities){ + result.put(entity.getCode(),entity.getValue()); + } + return result; + } + } + return Collections.emptyMap(); + } + @Override + public Map getParameters() { + List entities = repository.findAll(); + if(entities!=null && !entities.isEmpty()){ + Map result =new HashMap<>(); + for(ParameterEntity entity : entities){ + result.put(entity.getCode(),entity.getValue()); + } + return result; + } + return Collections.emptyMap(); + } } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/role/jpa/entity/RoleEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/role/jpa/entity/RoleEntity.java index 2bf8eee0..66a3c12b 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/role/jpa/entity/RoleEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/role/jpa/entity/RoleEntity.java @@ -28,32 +28,32 @@ public class RoleEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID", length=36) + @Column(name="ID_", length=36) @Size(max=36) private String id; //角色名称 - @Column(name="_CODE",nullable=false,length=254) + @Column(name="CODE_",nullable=false,length=254) @Size(max=254) private String code; //显示名称 - @Column(name="_NAME", length=254) + @Column(name="NAME_", length=254) @Size(min=1,max=255) private String name; //描述 - @Column(name="_DESCRIPTION", length=254) + @Column(name="DESCRIPTION_", length=254) @Size(max=254) private String description; //是否可用 - @Column(name="_ENABLE") + @Column(name="ENABLE_") @Convert(converter=NumericBooleanConverter.class) private Boolean enable; //默认首页面模版路径 - @Column(name="_INDEX_PAGE_URL", length=254) + @Column(name="INDEX_PAGE_URL_", length=254) @Size(max=254) private String indexPageUrl; @@ -66,12 +66,12 @@ public class RoleEntity extends CorporationAuditorEntity { private List menus =new ArrayList(); //角色可访问的帮助ID集合 - @Column(name="_HELP_IDS", length=1024) + @Column(name="HELP_IDS_", length=1024) @Convert(converter = SetStringConverter.class) private Set helpIds =new HashSet(); //角色可访问的首选项(系统配置)ID集合 - @Column(name="_PREFERENCE_IDS", length=1024) + @Column(name="PREFERENCE_IDS_", length=1024) @Convert(converter = SetStringConverter.class) private Set preferenceIds =new HashSet(); diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/role/service/impl/RoleServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/role/service/impl/RoleServiceImpl.java index 2587f4cc..01228695 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/role/service/impl/RoleServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/role/service/impl/RoleServiceImpl.java @@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import javax.persistence.criteria.Join; +import javax.persistence.criteria.JoinType; import javax.transaction.Transactional; import java.sql.ResultSet; import java.sql.SQLException; @@ -58,6 +59,9 @@ public class RoleServiceImpl extends DaoServiceImpl queryRolesByUser(String userId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(userId)) { + if(queryParameter!=null){ + queryParameter.addSortBy("name"); + } Specification specification = (root, query, criteriaBuilder) -> { Join join = root.join("users"); return criteriaBuilder.equal(join.get("id"), userId); @@ -70,9 +74,13 @@ public class RoleServiceImpl extends DaoServiceImpl queryOtherRolesByUser(String userId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(userId)) { + if(queryParameter!=null){ + queryParameter.addSortBy("name"); + } Specification specification = (root, query, criteriaBuilder) -> { - Join join = root.join("users"); - return criteriaBuilder.notEqual(join.get("id"), userId); + query.distinct(true); + Join join = root.join("users", JoinType.LEFT); + return criteriaBuilder.or(criteriaBuilder.isNull(join.get("id")),criteriaBuilder.notEqual(join.get("id"), userId)); }; return this.query(specification, queryParameter); } @@ -95,8 +103,9 @@ public class RoleServiceImpl extends DaoServiceImpl queryOtherRolesByMenu(String menuId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(menuId)) { Specification specification = (root, query, criteriaBuilder) -> { - Join join = root.join("menus"); - return criteriaBuilder.notEqual(join.get("id"), menuId); + query.distinct(true); + Join join = root.join("menus",JoinType.LEFT); + return criteriaBuilder.or(criteriaBuilder.notEqual(join.get("id"), menuId),criteriaBuilder.isNull(join.get("id"))); }; return this.query(specification, queryParameter); } @@ -107,7 +116,7 @@ public class RoleServiceImpl extends DaoServiceImpl userIds) throws Exception { if(StringUtils.hasText(roleId) && userIds!=null && !userIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ROLE(_USER_ID,_ROLE_ID) values(?,?)"); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ROLE(USER_ID_,ROLE_ID_) values(?,?)"); for(String userId : userIds){ sqlBatcher.addArg(new Object[]{userId,roleId}); } @@ -122,12 +131,12 @@ public class RoleServiceImpl extends DaoServiceImpl userIds) throws Exception{ if(StringUtils.hasText(roleId) && userIds!=null && userIds.size()>0){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ROLE where _USER_ID=? and _ROLE_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ROLE where USER_ID_=? and ROLE_ID_=?"); for(String userId : userIds){ sqlBatcher.addArg(new Object[]{userId,roleId}); } @@ -150,7 +159,7 @@ public class RoleServiceImpl extends DaoServiceImpl menuIds) throws Exception { if(StringUtils.hasText(roleId) && menuIds!=null && !menuIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(_MENU_ID,_ROLE_ID) values(?,?)"); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_ROLE_MENU(MENU_ID_,ROLE_ID_) values(?,?)"); for(String menuId : menuIds){ sqlBatcher.addArg(new Object[]{menuId,roleId}); } @@ -179,12 +188,12 @@ public class RoleServiceImpl extends DaoServiceImpl menuIds) throws Exception { if(StringUtils.hasText(roleId) && menuIds!=null && !menuIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where _MENU_ID=? and _ROLE_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_ROLE_MENU where MENU_ID_=? and ROLE_ID_=?"); for(String menuId : menuIds){ sqlBatcher.addArg(new Object[]{menuId,roleId}); } @@ -207,7 +216,7 @@ public class RoleServiceImpl extends DaoServiceImpl { private UserEntityVoConverter converter =new UserEntityVoConverter(); - @GetMapping(value={"session"}) + @GetMapping("session") public UserSession session(HttpServletRequest request){ return service.getUserSession(request); } diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/entity/UserEntity.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/entity/UserEntity.java index 3c090aff..61d7fec4 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/entity/UserEntity.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/entity/UserEntity.java @@ -24,47 +24,47 @@ public class UserEntity extends CorporationAuditorEntity { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid2") - @Column(name="_ID", length=36) + @Column(name="ID_", length=36) @Size(max=36) private String id; //登录名 - @Column(name="_LOGINNAME", nullable=false, length=255) + @Column(name="LOGINNAME_", nullable=false, length=255) @Size(min=1,max=255) private String loginName; //用户名 - @Column(name="_USERNAME", length=255) + @Column(name="USERNAME_", length=255) @Size(min=1,max=255) private String userName; //密码 - @Column(name="_PASSWORD", length=255) + @Column(name="PASSWORD_", length=255) @Size(max=255) private String password; //描述 - @Column(name="_DESCRIPTION", length=255) + @Column(name="DESCRIPTION_", length=255) @Size(max=255) private String description; //是否可用 - @Column(name="_ENABLE") + @Column(name="ENABLE_") @Convert(converter=NumericBooleanConverter.class) private Boolean enable; //账户是否过期 - @Column(name="_IS_ACCOUNT_EXPIRED") + @Column(name="IS_ACCOUNT_EXPIRED_") @Convert(converter=NumericBooleanConverter.class) private Boolean accountExpired; //账户是否被锁定 - @Column(name="_IS_ACCOUNT_LOCKED") + @Column(name="IS_ACCOUNT_LOCKED_") @Convert(converter=NumericBooleanConverter.class) private Boolean accountLocked; //密码是否过期 - @Column(name="_IS_CREDENTIALS_EXPIRED") + @Column(name="IS_CREDENTIALS_EXPIRED_") @Convert(converter=NumericBooleanConverter.class) private Boolean credentialsExpired; @@ -72,13 +72,13 @@ public class UserEntity extends CorporationAuditorEntity { @ManyToMany(fetch=FetchType.LAZY) @JoinTable( name = "SYS_USER_ROLE", - joinColumns = {@JoinColumn(name = "_USER_ID", nullable = false,referencedColumnName="_ID")}, - inverseJoinColumns = {@JoinColumn(name = "_ROLE_ID",nullable = false,referencedColumnName="_ID")} + joinColumns = {@JoinColumn(name = "USER_ID_", nullable = false,referencedColumnName="ID_")}, + inverseJoinColumns = {@JoinColumn(name = "ROLE_ID_",nullable = false,referencedColumnName="ID_")} ) private List roles =new ArrayList(); //默认所属角色ID - @Column(name="_DEFAULT_ROLE_ID",length=36) + @Column(name="DEFAULT_ROLE_ID_",length=36) @Size(max=36) private String defaultRoleId; @@ -86,38 +86,38 @@ public class UserEntity extends CorporationAuditorEntity { @ManyToMany(fetch=FetchType.LAZY) @JoinTable( name = "SYS_USER_ORG", - joinColumns = {@JoinColumn(name = "_USER_ID", nullable = false,referencedColumnName="_ID")}, - inverseJoinColumns = {@JoinColumn(name = "_ORG_ID",nullable = false,referencedColumnName="_ID")} + joinColumns = {@JoinColumn(name = "USER_ID_", nullable = false,referencedColumnName="ID_")}, + inverseJoinColumns = {@JoinColumn(name = "ORG_ID_",nullable = false,referencedColumnName="ID_")} ) private List orgs =new ArrayList(); //默认所属机构ID - @Column(name="_DEFAULT_ORG_ID",length=36) + @Column(name="DEFAULT_ORG_ID_",length=36) @Size(max=36) private String defaultOrgId; //email - @Column(name="_EMAIL",length=255) + @Column(name="EMAIL_",length=255) @Size(max=255) private String email; //电话 - @Column(name="_PHONE",length=18) + @Column(name="PHONE_",length=18) @Size(max=18) private String phone; //手机号 - @Column(name="_MOBILE",length=14) + @Column(name="MOBILE_",length=14) @Size(max=14) private String mobile; //微信号 - @Column(name="_WEIXIN",length=255) + @Column(name="WEIXIN_",length=255) @Size(max=255) private String weixin; //QQ号 - @Column(name="_QQ",length=255) + @Column(name="QQ_",length=255) @Size(max=255) private String qq; diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/repository/UserRepository.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/repository/UserRepository.java index b82e949c..8bb23808 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/repository/UserRepository.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/jpa/repository/UserRepository.java @@ -13,7 +13,7 @@ public interface UserRepository extends DaoRepository { * @param loginName 登录名 * @return 用户实体 */ - @Query("select user from UserEntity as user left join fetch user.roles where user.loginName=:loginName") + @Query("select user from UserEntity user left join fetch user.roles where user.loginName=:loginName") public UserEntity findByLoginName(@Param("loginName") String loginName); /** diff --git a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/service/impl/UserServiceImpl.java b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/service/impl/UserServiceImpl.java index 92454a68..8bb3453d 100644 --- a/io.sc.platform.system/src/main/java/io/sc/platform/system/user/service/impl/UserServiceImpl.java +++ b/io.sc.platform.system/src/main/java/io/sc/platform/system/user/service/impl/UserServiceImpl.java @@ -33,6 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import javax.persistence.criteria.Join; +import javax.persistence.criteria.JoinType; import javax.servlet.http.HttpServletRequest; import javax.transaction.Transactional; import java.sql.PreparedStatement; @@ -82,7 +83,7 @@ public class UserServiceImpl extends DaoServiceImpl queryOtherUsersByRole(String roleId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(roleId)) { Specification specification = (root, query, criteriaBuilder) -> { - Join join = root.join("roles"); - return criteriaBuilder.notEqual(join.get("id"), roleId); + query.distinct(true); + Join join = root.join("roles", JoinType.LEFT); + return criteriaBuilder.or(criteriaBuilder.isNull(join.get("id")),criteriaBuilder.notEqual(join.get("id"), roleId)); }; return this.query(specification, queryParameter); } @@ -177,7 +179,7 @@ public class UserServiceImpl extends DaoServiceImpl specification = (root, query, criteriaBuilder) -> { Join join = root.join("orgs"); - return criteriaBuilder.notEqual(join.get("id"), orgId); + return criteriaBuilder.equal(join.get("id"), orgId); }; return this.query(specification, queryParameter); } @@ -188,8 +190,9 @@ public class UserServiceImpl extends DaoServiceImpl queryOtherUsersByOrg(String orgId, QueryParameter queryParameter) throws Exception { if(StringUtils.hasText(orgId)) { Specification specification = (root, query, criteriaBuilder) -> { - Join join = root.join("orgs"); - return criteriaBuilder.notEqual(join.get("id"), orgId); + query.distinct(true); + Join join = root.join("orgs",JoinType.LEFT); + return criteriaBuilder.or(criteriaBuilder.notEqual(join.get("id"),orgId),criteriaBuilder.isNull(join.get("id"))); }; return this.query(specification, queryParameter); } @@ -200,7 +203,7 @@ public class UserServiceImpl extends DaoServiceImpl roleIds) throws Exception { if(StringUtils.hasText(userId) && roleIds!=null && !roleIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ROLE(_ROLE_ID,_USER_ID) values(?,?)"); + SqlBatcher sqlBatcher =new SqlBatcher("insert into SYS_USER_ROLE(ROLE_ID_,USER_ID_) values(?,?)"); for(String roleId : roleIds){ sqlBatcher.addArg(new Object[]{roleId,userId}); } @@ -215,12 +218,12 @@ public class UserServiceImpl extends DaoServiceImpl roleIds) throws Exception{ if(StringUtils.hasText(userId) && roleIds!=null && !roleIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ROLE where _ROLE_ID=? and _USER_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ROLE where ROLE_ID_=? and USER_ID_=?"); for(String roleId : roleIds){ sqlBatcher.addArg(new Object[]{roleId,userId}); } @@ -243,7 +246,7 @@ public class UserServiceImpl extends DaoServiceImpl orgIds) throws Exception { if(StringUtils.hasText(userId) && orgIds!=null && !orgIds.isEmpty()){ - SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ORG where _ORG_ID=? and _USER_ID=?"); + SqlBatcher sqlBatcher =new SqlBatcher("delete from SYS_USER_ORG where ORG_ID_=? and USER_ID_=?"); for(String orgId : orgIds){ sqlBatcher.addArg(new Object[]{orgId,userId}); } @@ -299,7 +302,7 @@ public class UserServiceImpl extends DaoServiceImpl - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + - + - + - + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - + + + + + + + + - + - + - + - + - - - - - - - - + + + + + + + + + - + - + - + - - - - - - - - + + + + + + + + - + - - + + - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + referencedColumnNames="ID_" onDelete="CASCADE"/> + + + + + + + + + + + + + + + + + + + + + + diff --git a/settings.gradle b/settings.gradle index c4d28dd3..29347589 100755 --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,6 @@ include ':io.sc.platform.app-nacos' include ':io.sc.platform.communication' include ':io.sc.platform.core' include ':io.sc.platform.core.frontend' -include ':io.sc.platform.components.frontend' include ':io.sc.platform.csv' include ':io.sc.platform.developer' include ':io.sc.platform.developer.frontend' @@ -26,6 +25,7 @@ include ':io.sc.platform.jdbc.driver.postgresql' include ':io.sc.platform.jdbc.driver.sqlite' include ':io.sc.platform.jdbc.driver.tidb' include ':io.sc.platform.jdbc.liquibase' +//include ':io.sc.platform.jdbc.schemacrawler-14.21.02' include ':io.sc.platform.jdbc.schemacrawler' //include ':io.sc.platform.job.scheduler' include ':io.sc.platform.lcdp'