first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
*.iml
|
||||
*.idea
|
||||
target/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
@@ -0,0 +1,3 @@
|
||||
**/wangEditor/*.js
|
||||
**/nprogress/*.js
|
||||
**/assets/platform/plugins/**
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"printWidth": 150,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"rangeStart": 0,
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"vueIndentScriptAndStyle": false,
|
||||
"endOfLine": "auto",
|
||||
"useTabs": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM openjdk:11.0.13-jdk
|
||||
COPY ./target/mini.jar /app/
|
||||
COPY ./target/classes/application.yaml /app/
|
||||
ENV TZ Asia/Shanghai
|
||||
|
||||
WORKDIR /app
|
||||
CMD ["java","-jar","-Dnutz.boot.configure.yaml.dir=/app","/app/mini.jar"]
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://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
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+393
@@ -0,0 +1,393 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<groupId>com.budwk</groupId>
|
||||
<artifactId>mini</artifactId>
|
||||
<version>5.6.0-plus</version>
|
||||
|
||||
<properties>
|
||||
<nutzboot.version>2.6.0-SNAPSHOT</nutzboot.version>
|
||||
<nutz.version>1.r.70-SNAPSHOT</nutz.version>
|
||||
<mysql-connector-java.version>8.0.28</mysql-connector-java.version>
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
<slf4j.version>1.7.25</slf4j.version>
|
||||
<logback.version>1.2.9</logback.version>
|
||||
<sa-token.version>1.25.0</sa-token.version>
|
||||
<easy-captcha.version>1.6.2</easy-captcha.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<emoji-java.veision>4.0.0</emoji-java.veision>
|
||||
<jsoup.veision>1.15.3</jsoup.veision>
|
||||
<pinyin4j.veision>2.5.1</pinyin4j.veision>
|
||||
<poi.version>4.1.1</poi.version>
|
||||
<tencentcloud-sdk-java.version>4.0.11</tencentcloud-sdk-java.version>
|
||||
<lombok.version>1.18.18</lombok.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<url>https://budwk.com</url>
|
||||
<description>java web development framework, base on budwk and nutz</description>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>wizzercn</id>
|
||||
<name>Wizzer</name>
|
||||
<email>wizzer@qq.com</email>
|
||||
<url>https://wizzer.cn</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.xfire</groupId>
|
||||
<artifactId>xfire-all</artifactId>
|
||||
<version>1.2.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xfire-spring</artifactId>
|
||||
<groupId>org.codehaus.xfire</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<groupId>xerces</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>stax-api</artifactId>
|
||||
<groupId>stax</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xfire-xmlbeans</artifactId>
|
||||
<groupId>org.codehaus.xfire</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
<version>15.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<version>${tencentcloud-sdk-java.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-nutz-mvc</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-jetty</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-nutz-dao</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-jdbc</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.oracle</groupId>-->
|
||||
<!--<artifactId>classes12</artifactId>-->
|
||||
<!--<version>10.2.0.2.0</version>-->
|
||||
<!--<scope>system</scope>-->
|
||||
<!--<systemPath>D://oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar</systemPath>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-redis</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-wkcache</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-weixin</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-ftp</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-beetl</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-quartz</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<version>${emoji-java.veision}</version>
|
||||
</dependency>
|
||||
<!-- api token web server -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<!-- sa-token -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-core</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-servlet</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
</dependency>
|
||||
<!-- html -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>${jsoup.veision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>${pinyin4j.veision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<!-- json4excel,poi -->
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-integration-json4excel</artifactId>
|
||||
<version>${nutz.version}</version>
|
||||
<exclusions><!-- 手动排除依赖,瘦身 -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-test-junit4</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.whvcse</groupId>
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
<version>${easy-captcha.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-parent</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb-api.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<charset>UTF-8</charset>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.0</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.nutz.boot</groupId>
|
||||
<artifactId>nutzboot-maven-plugin</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nutz</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/libs-release</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nutz-snapshots</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>nutz-snapshots</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
@@ -0,0 +1,893 @@
|
||||
package com.budwk.app;
|
||||
|
||||
import cn.dev33.satoken.SaManager;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import com.budwk.app.sys.models.*;
|
||||
import com.budwk.app.sys.services.SysTaskService;
|
||||
import com.budwk.app.task.services.TaskPlatformService;
|
||||
import com.budwk.app.web.commons.auth.satoken.SaTokenContextImpl;
|
||||
import com.budwk.app.web.commons.auth.satoken.SaTokenDaoRedisImpl;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpInterfaceImpl;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import com.budwk.app.web.commons.ext.pubsub.WebPubSub;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
import org.nutz.boot.NbApp;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.impl.FileSqlManager;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.integration.jedis.JedisAgent;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.ioc.impl.PropertiesProxy;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Mirror;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.mvc.annotation.ChainBy;
|
||||
import org.nutz.mvc.annotation.Encoding;
|
||||
import org.nutz.mvc.annotation.Localization;
|
||||
import org.quartz.Scheduler;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.servlet.ServletContext;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
@IocBean(create = "init", depose = "depose")
|
||||
@Localization(value = "locales/", defaultLocalizationKey = "zh_CN")
|
||||
@Encoding(input = "UTF-8", output = "UTF-8")
|
||||
@ChainBy(args = "chain/mvc-chain.json")
|
||||
@Slf4j
|
||||
public class MainLauncher {
|
||||
protected static final String PRE = "security.";
|
||||
@Inject("refer:$ioc")
|
||||
private Ioc ioc;
|
||||
@Inject
|
||||
private PropertiesProxy conf;
|
||||
@Inject
|
||||
private JedisAgent jedisAgent;
|
||||
@Inject
|
||||
private WebPubSub webPubSub;//注入一下为了初始化
|
||||
@Inject
|
||||
private GroupTemplate groupTemplate;
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
@Inject
|
||||
private SysTaskService sysTaskService;
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
|
||||
nb.getAppContext().setMainPackage("com.budwk");
|
||||
nb.run();
|
||||
}
|
||||
|
||||
public static NbApp warMain(ServletContext sc) {
|
||||
NbApp nb = new NbApp().setPrintProcDoc(true);
|
||||
nb.getAppContext().setMainPackage("com.budwk");
|
||||
return nb;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Mvcs.DISABLE_X_POWERED_BY = true;
|
||||
Globals.AppBase = Mvcs.getServletContext().getContextPath();
|
||||
Globals.AppRoot = Mvcs.getServletContext().getRealPath("/");
|
||||
init_sys();
|
||||
init_task();
|
||||
ioc.get(Globals.class);
|
||||
init_auth();
|
||||
}
|
||||
|
||||
public void init_auth() {
|
||||
SaTokenConfig saTokenConfig = conf.makeDeep(SaTokenConfig.class, PRE);
|
||||
String tokenName = conf.get(PRE + "tokenName", "token");
|
||||
// 注意这里的token默认超时时间与控制中心 websocket 超时时间保持一致
|
||||
saTokenConfig.setTimeout(conf.getLong(PRE + "timeout", 86400));
|
||||
saTokenConfig.setTokenName(tokenName);
|
||||
saTokenConfig.setIsV(false);
|
||||
SaManager.setConfig(saTokenConfig);
|
||||
SaManager.setSaTokenContext(ioc.get(SaTokenContextImpl.class));
|
||||
SaManager.setSaTokenDao(ioc.get(SaTokenDaoRedisImpl.class));
|
||||
SaManager.setStpInterface(ioc.get(StpInterfaceImpl.class));
|
||||
//初始化小程序登录类型logic
|
||||
StpLogic stp = StpClientUtil.STP;
|
||||
}
|
||||
|
||||
|
||||
private void init_task() {
|
||||
if (log.isDebugEnabled() && !dao.exists("sys_qrtz_triggers") && !dao.exists("sys_qrtz_triggers".toUpperCase())) {
|
||||
//执行Quartz SQL脚本
|
||||
String dbType = dao.getJdbcExpert().getDatabaseType();
|
||||
log.debug("dbType:::" + dbType);
|
||||
FileSqlManager fmq = new FileSqlManager("db/quartz/" + dbType.toLowerCase() + ".sql");
|
||||
List<Sql> sqlListq = fmq.createCombo(fmq.keys());
|
||||
Sql[] sqlsq = sqlListq.toArray(new Sql[sqlListq.size()]);
|
||||
for (Sql sql : sqlsq) {
|
||||
dao.execute(sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void init_sys() {
|
||||
if (log.isDebugEnabled()) {
|
||||
//通过POJO类创建表结构
|
||||
try {
|
||||
Daos.createTablesInPackage(dao, "com.budwk", false);
|
||||
//通过POJO类修改表结构
|
||||
Daos.migration(dao, "com.budwk", true, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 若必要的数据表不存在,则初始化数据库
|
||||
if (0 == dao.count(Sys_user.class)) {
|
||||
//初始化配置表
|
||||
Sys_config conf = new Sys_config();
|
||||
conf.setConfigKey("AppName");
|
||||
conf.setConfigValue("BudWk-V5 mini");
|
||||
conf.setNote("系统名称");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("AppShrotName");
|
||||
conf.setConfigValue("budwk");
|
||||
conf.setNote("系统短名称");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("AppDomain");
|
||||
conf.setConfigValue("http://127.0.0.1:8080");
|
||||
conf.setNote("系统域名");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("AppFileDomain");
|
||||
conf.setConfigValue("");
|
||||
conf.setNote("文件访问域名");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("AppUploadBase");
|
||||
conf.setConfigValue("/upload");
|
||||
conf.setNote("文件访问路径");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("SessionOnlyOne");
|
||||
conf.setConfigValue("true");
|
||||
conf.setNote("用户登录只允许一个Session实例(踢其他人下线)");
|
||||
dao.insert(conf);
|
||||
conf = new Sys_config();
|
||||
conf.setConfigKey("WebNotification");
|
||||
conf.setConfigValue("false");
|
||||
conf.setNote("启用浏览器通知");
|
||||
dao.insert(conf);
|
||||
//初始化单位
|
||||
Sys_unit unit = new Sys_unit();
|
||||
unit.setPath("0001");
|
||||
unit.setName("系统管理");
|
||||
unit.setAliasName("System");
|
||||
unit.setUnitcode("system");
|
||||
unit.setLocation(0);
|
||||
unit.setAddress("银河-太阳系-地球");
|
||||
unit.setEmail("wizzer@qq.com");
|
||||
unit.setTelephone("");
|
||||
unit.setHasChildren(false);
|
||||
unit.setParentId("");
|
||||
unit.setWebsite("https://budwk.com");
|
||||
Sys_unit dbunit = dao.insert(unit);
|
||||
//初始化菜单
|
||||
List<Sys_menu> menuList = new ArrayList<Sys_menu>();
|
||||
Sys_menu menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001");
|
||||
menu.setName("系统");
|
||||
menu.setNote("系统");
|
||||
menu.setAliasName("System");
|
||||
menu.setIcon("ti-settings");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("");
|
||||
menu.setTarget("");
|
||||
menu.setShowit(true);
|
||||
menu.setHasChildren(true);
|
||||
menu.setParentId("");
|
||||
menu.setType("menu");
|
||||
menu.setPermission("sys");
|
||||
Sys_menu m0 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("00010001");
|
||||
menu.setName("系统管理");
|
||||
menu.setNote("系统管理");
|
||||
menu.setAliasName("Manager");
|
||||
menu.setIcon("ti-settings");
|
||||
menu.setLocation(1);
|
||||
menu.setHref("");
|
||||
menu.setTarget("");
|
||||
menu.setShowit(true);
|
||||
menu.setHasChildren(true);
|
||||
menu.setParentId(m0.getId());
|
||||
menu.setType("menu");
|
||||
menu.setPermission("sys.manager");
|
||||
Sys_menu m1 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010001");
|
||||
menu.setName("单位管理");
|
||||
menu.setAliasName("Unit");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/unit");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.unit");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m2 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100010001");
|
||||
menu.setName("添加单位");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.unit.add");
|
||||
menu.setParentId(m2.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m21 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100010002");
|
||||
menu.setName("修改单位");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.unit.edit");
|
||||
menu.setParentId(m2.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m22 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100010003");
|
||||
menu.setName("删除单位");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.unit.delete");
|
||||
menu.setParentId(m2.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m23 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010002");
|
||||
menu.setName("用户管理");
|
||||
menu.setAliasName("User");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/user");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.user");
|
||||
menu.setHasChildren(false);
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m3 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100020001");
|
||||
menu.setName("添加用户");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.user.add");
|
||||
menu.setParentId(m3.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m31 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100020002");
|
||||
menu.setName("修改用户");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.user.edit");
|
||||
menu.setParentId(m3.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m32 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100020003");
|
||||
menu.setName("删除用户");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.user.delete");
|
||||
menu.setParentId(m3.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m33 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010003");
|
||||
menu.setName("角色管理");
|
||||
menu.setAliasName("Role");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/role");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.role");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m4 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100030001");
|
||||
menu.setName("添加角色");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.role.add");
|
||||
menu.setParentId(m4.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m41 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100030002");
|
||||
menu.setName("修改角色");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.role.edit");
|
||||
menu.setParentId(m4.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m42 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100030003");
|
||||
menu.setName("删除角色");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.role.delete");
|
||||
menu.setParentId(m4.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m43 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100030004");
|
||||
menu.setName("分配菜单");
|
||||
menu.setAliasName("SetMenu");
|
||||
menu.setLocation(4);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.role.menu");
|
||||
menu.setParentId(m4.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m44 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100030005");
|
||||
menu.setName("分配用户");
|
||||
menu.setAliasName("SetUser");
|
||||
menu.setLocation(5);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.role.user");
|
||||
menu.setParentId(m4.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m45 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010004");
|
||||
menu.setName("菜单管理");
|
||||
menu.setAliasName("Menu");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/menu");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.menu");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m5 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100040001");
|
||||
menu.setName("添加菜单");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.menu.add");
|
||||
menu.setParentId(m5.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m51 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100040002");
|
||||
menu.setName("修改菜单");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.menu.edit");
|
||||
menu.setParentId(m5.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m52 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100040003");
|
||||
menu.setName("删除菜单");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.menu.delete");
|
||||
menu.setParentId(m5.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m53 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010005");
|
||||
menu.setName("系统参数");
|
||||
menu.setAliasName("Param");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/conf");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.conf");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m6 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100050001");
|
||||
menu.setName("添加参数");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.conf.add");
|
||||
menu.setParentId(m6.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m61 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100050002");
|
||||
menu.setName("修改参数");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.conf.edit");
|
||||
menu.setParentId(m6.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m62 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100050003");
|
||||
menu.setName("删除参数");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.conf.delete");
|
||||
menu.setParentId(m6.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m63 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010006");
|
||||
menu.setName("日志管理");
|
||||
menu.setAliasName("Log");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/log");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.log");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m7 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100060001");
|
||||
menu.setName("清除日志");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.log.delete");
|
||||
menu.setParentId(m7.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m71 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010007");
|
||||
menu.setName("定时任务");
|
||||
menu.setAliasName("Task");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/task");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.task");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m8 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100070001");
|
||||
menu.setName("添加任务");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.task.add");
|
||||
menu.setParentId(m8.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m81 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100070002");
|
||||
menu.setName("修改任务");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.task.edit");
|
||||
menu.setParentId(m8.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m82 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100070003");
|
||||
menu.setName("删除任务");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.task.delete");
|
||||
menu.setParentId(m8.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m83 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010008");
|
||||
menu.setName("自定义路由");
|
||||
menu.setAliasName("Route");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/route");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.route");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu m9 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100080001");
|
||||
menu.setName("添加路由");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.route.add");
|
||||
menu.setParentId(m9.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m91 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100080002");
|
||||
menu.setName("修改路由");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.route.edit");
|
||||
menu.setParentId(m9.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m92 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100080003");
|
||||
menu.setName("删除路由");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.route.delete");
|
||||
menu.setParentId(m9.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu m93 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setParentId(m0.getId());
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("00010002");
|
||||
menu.setName("系统配置");
|
||||
menu.setAliasName("Config");
|
||||
menu.setType("menu");
|
||||
menu.setLocation(2);
|
||||
menu.setIcon("ti-pencil-alt");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.config");
|
||||
menu.setHasChildren(true);
|
||||
Sys_menu pp1 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100020001");
|
||||
menu.setName("数据字典");
|
||||
menu.setAliasName("Dict");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/dict");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.dict");
|
||||
menu.setParentId(pp1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu d = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200010001");
|
||||
menu.setName("添加字典");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.dict.add");
|
||||
menu.setParentId(d.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu d1 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200010002");
|
||||
menu.setName("修改字典");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.dict.edit");
|
||||
menu.setParentId(d.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu d2 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200010003");
|
||||
menu.setName("删除字典");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.dict.delete");
|
||||
menu.setParentId(d.getId());
|
||||
menu.setType("data");
|
||||
Sys_menu d3 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100020002");
|
||||
menu.setName("密钥管理");
|
||||
menu.setAliasName("Api");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/api");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.api");
|
||||
menu.setParentId(pp1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu appManger = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200020001");
|
||||
menu.setName("添加密钥");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.api.add");
|
||||
menu.setParentId(appManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200020002");
|
||||
menu.setName("修改密钥");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.api.edit");
|
||||
menu.setParentId(appManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000200020003");
|
||||
menu.setName("删除密钥");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.api.delete");
|
||||
menu.setParentId(appManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
|
||||
//消息中心及消息管理
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("00010003");
|
||||
menu.setName("消息中心");
|
||||
menu.setNote("消息中心");
|
||||
menu.setAliasName("InnerMsg");
|
||||
menu.setIcon("ti-bell");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("");
|
||||
menu.setTarget("");
|
||||
menu.setShowit(true);
|
||||
menu.setHasChildren(true);
|
||||
menu.setParentId(m0.getId());
|
||||
menu.setType("menu");
|
||||
menu.setPermission("sys.msg");
|
||||
Sys_menu msg0 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100030001");
|
||||
menu.setName("全部消息");
|
||||
menu.setAliasName("All");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/msg/user/all");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.msg.all");
|
||||
menu.setParentId(msg0.getId());
|
||||
menu.setType("menu");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100030002");
|
||||
menu.setName("未读消息");
|
||||
menu.setAliasName("Unread");
|
||||
menu.setLocation(1);
|
||||
menu.setHref("/platform/sys/msg/user/unread");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.msg.unread");
|
||||
menu.setParentId(msg0.getId());
|
||||
menu.setType("menu");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100030003");
|
||||
menu.setName("已读消息");
|
||||
menu.setAliasName("Read");
|
||||
menu.setLocation(2);
|
||||
menu.setHref("/platform/sys/msg/user/read");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.msg.read");
|
||||
menu.setParentId(msg0.getId());
|
||||
menu.setType("menu");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100010009");
|
||||
menu.setName("消息管理");
|
||||
menu.setAliasName("Msg");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/msg");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.manager.msg");
|
||||
menu.setParentId(m1.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu msgManger = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100090001");
|
||||
menu.setName("添加消息");
|
||||
menu.setAliasName("Add");
|
||||
menu.setLocation(0);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.msg.add");
|
||||
menu.setParentId(msgManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100090002");
|
||||
menu.setName("修改消息");
|
||||
menu.setAliasName("Edit");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.msg.edit");
|
||||
menu.setParentId(msgManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000100090003");
|
||||
menu.setName("删除消息");
|
||||
menu.setAliasName("Delete");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.manager.msg.delete");
|
||||
menu.setParentId(msgManger.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
|
||||
//初始化角色
|
||||
Sys_role role = new Sys_role();
|
||||
role.setName("公共角色");
|
||||
role.setCode("public");
|
||||
role.setAliasName("Public");
|
||||
role.setNote("All user has role");
|
||||
role.setUnitid("");
|
||||
role.setDisabled(false);
|
||||
dao.insert(role);
|
||||
role = new Sys_role();
|
||||
role.setName("系统管理员");
|
||||
role.setCode("sysadmin");
|
||||
role.setAliasName("Sysadmin");
|
||||
role.setNote("System Admin");
|
||||
role.setUnitid("");
|
||||
role.setMenus(menuList);
|
||||
role.setDisabled(false);
|
||||
Sys_role dbrole = dao.insert(role);
|
||||
//初始化用户
|
||||
Sys_user user = new Sys_user();
|
||||
user.setLoginname("superadmin");
|
||||
user.setUsername("超级管理员");
|
||||
user.setCreateAt(System.currentTimeMillis());
|
||||
//String slat=R.UU32();
|
||||
//new Sha256Hash("1",ByteSource.Util.bytes(s), 1024).toHex();
|
||||
user.setSalt("r5tdr01s7uglfokpsdmtu15602");
|
||||
user.setPassword("1bba9287ebc50b766bff84273d11ccefaa7a8da95d078960f05f116e9d970fb0");
|
||||
user.setLoginIp("127.0.0.1");
|
||||
user.setLoginAt(0L);
|
||||
user.setLoginCount(0);
|
||||
user.setEmail("wizzer@qq.com");
|
||||
user.setUnitId(dbunit.getId());
|
||||
user.setUnitPath(dbunit.getPath());
|
||||
Sys_user dbuser = dao.insert(user);
|
||||
//不同的插入数据方式(安全)
|
||||
dao.insert("sys_user_unit", org.nutz.dao.Chain.make("userId", dbuser.getId()).add("unitId", dbunit.getId()));
|
||||
dao.insert("sys_user_role", Chain.make("userId", dbuser.getId()).add("roleId", dbrole.getId()));
|
||||
//执行SQL脚本
|
||||
FileSqlManager fm = new FileSqlManager("db/menu/");
|
||||
List<Sql> sqlList = fm.createCombo(fm.keys());
|
||||
Sql[] sqls = sqlList.toArray(new Sql[sqlList.size()]);
|
||||
for (Sql sql : sqls) {
|
||||
dao.execute(sql);
|
||||
}
|
||||
//菜单关联到角色
|
||||
dao.execute(Sqls.create("INSERT INTO sys_role_menu(roleId,menuId) SELECT @roleId,id FROM sys_menu").setParam("roleId", dbrole.getId()));
|
||||
//消息中心放第一个位置
|
||||
dao.execute(Sqls.create("update sys_menu set location=0 where path='00010003'"));
|
||||
//初始化自定义路由
|
||||
Sys_route route = new Sys_route();
|
||||
route.setDisabled(false);
|
||||
route.setUrl("/sysadmin");
|
||||
route.setToUrl("/platform/login");
|
||||
route.setType("hide");
|
||||
dao.insert(route);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void depose() {
|
||||
// 非mysql数据库,或多webapp共享mysql驱动的话,以下语句删掉
|
||||
try {
|
||||
Mirror.me(Class.forName("com.mysql.jdbc.AbandonedConnectionCleanupThread")).invoke(null, "shutdown");
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
// 解决quartz有时候无法停止的问题
|
||||
try {
|
||||
ioc.get(Scheduler.class).shutdown(true);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
// 解决com.alibaba.druid.proxy.DruidDriver和com.mysql.jdbc.Driver在reload时报warning的问题
|
||||
// 多webapp共享mysql驱动的话,以下语句删掉
|
||||
Enumeration<Driver> en = DriverManager.getDrivers();
|
||||
while (en.hasMoreElements()) {
|
||||
try {
|
||||
Driver driver = en.nextElement();
|
||||
String className = driver.getClass().getName();
|
||||
log.debug("deregisterDriver: " + className);
|
||||
DriverManager.deregisterDriver(driver);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
ObjectName objectName = new ObjectName("com.alibaba.druid:type=MockDriver");
|
||||
if (mbeanServer.isRegistered(objectName))
|
||||
mbeanServer.unregisterMBean(objectName);
|
||||
objectName = new ObjectName("com.alibaba.druid:type=DruidDriver");
|
||||
if (mbeanServer.isRegistered(objectName))
|
||||
mbeanServer.unregisterMBean(objectName);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.budwk.app.base.constant;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public class RedisConstant {
|
||||
public final static String PLATFORM_REDIS_PREFIX = "budwk5mini:";
|
||||
public final static String PLATFORM_REDIS_WKCACHE_PREFIX = PLATFORM_REDIS_PREFIX + "wkcache:";
|
||||
public final static String REDIS_KEY_WSROOM = PLATFORM_REDIS_PREFIX + "wsroom:";
|
||||
public final static String REDIS_KEY_LOGIN_ADMIN_CAPTCHA = PLATFORM_REDIS_PREFIX + "admin:login:captcha:";
|
||||
public final static String REDIS_KEY_ADMIN_PUBSUB = PLATFORM_REDIS_PREFIX + "admin:pubsub:";
|
||||
public final static String REDIS_KEY_WX_TOKEN = PLATFORM_REDIS_PREFIX + "wx:token:";
|
||||
public final static String REDIS_CAPTCHA_KEY = PLATFORM_REDIS_PREFIX + "platfrom:captcha:";
|
||||
public final static String REDIS_SMSCODE_KEY = PLATFORM_REDIS_PREFIX + "platfrom:smscode:";
|
||||
|
||||
public final static String REDIS_KEY_API_SIGN_DEPLOY_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:deploy:nonce:";
|
||||
public final static String REDIS_KEY_API_SIGN_OPEN_NONCE = PLATFORM_REDIS_PREFIX + "api:sign:open:nonce:";
|
||||
|
||||
/**
|
||||
* Token 缓存前缀
|
||||
*/
|
||||
public static final String TOKEN = PLATFORM_REDIS_PREFIX + "token:";
|
||||
|
||||
/**
|
||||
* 验证码前缀
|
||||
*/
|
||||
public static final String UCENTER_CAPTCHA = PLATFORM_REDIS_PREFIX + "ucenter:captcha:";
|
||||
|
||||
/**
|
||||
* 短信验证码前缀
|
||||
*/
|
||||
public static final String UCENTER_SMSCODE = PLATFORM_REDIS_PREFIX + "ucenter:smscode:";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.budwk.app.base.exception;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public class BaseException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = -3148500348308095226L;
|
||||
|
||||
public BaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.budwk.app.base.model;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
import org.nutz.dao.interceptor.annotation.PrevUpdate;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
* Update by wizzer on 2021/8/30.
|
||||
*/
|
||||
@Data
|
||||
public abstract class BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Comment("创建人")
|
||||
@PrevInsert(els = @EL("$me.createdByUid()"))
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
|
||||
* 13位时间戳哦,不再是11位
|
||||
*/
|
||||
@Column
|
||||
@Comment("创建时间")
|
||||
@PrevInsert(now = true)
|
||||
private Long createdAt;
|
||||
|
||||
@Column
|
||||
@Comment("修改人")
|
||||
@PrevInsert(els = @EL("$me.updatedByUid()"))
|
||||
@PrevUpdate(els = @EL("$me.updatedByUid()"))
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
|
||||
* 13位时间戳哦,不再是11位
|
||||
*/
|
||||
@Column
|
||||
@Comment("修改时间")
|
||||
@PrevInsert(now = true)
|
||||
@PrevUpdate(now = true)
|
||||
private Long updatedAt;
|
||||
|
||||
@Column
|
||||
@Comment("删除标记")
|
||||
@PrevInsert(els = @EL("$me.flag()"))
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean delFlag;
|
||||
|
||||
public String toJsonString() {
|
||||
return Json.toJson(this, JsonFormat.compact());
|
||||
}
|
||||
|
||||
public Boolean flag() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String createdByUid() {
|
||||
String uid = getCreatedBy();
|
||||
if (Strings.isNotBlank(uid)) {
|
||||
return uid;
|
||||
}
|
||||
try {
|
||||
return StpUtil.getLoginIdAsString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String updatedByUid() {
|
||||
String uid = getUpdatedBy();
|
||||
if (Strings.isNotBlank(uid)) {
|
||||
return uid;
|
||||
}
|
||||
try {
|
||||
return StpUtil.getLoginIdAsString();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.budwk.app.base.page;
|
||||
|
||||
import org.nutz.dao.pager.Pager;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 指定偏移量及大小的Pager, 这样就不会受限于原生Pager的offset=(pageNumber-1)*pageSize
|
||||
*
|
||||
* @author wendal
|
||||
*/
|
||||
|
||||
public class OffsetPager extends Pager implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1385308131663113162L;
|
||||
|
||||
protected int offset = -1;
|
||||
|
||||
protected OffsetPager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建一个指定偏移量及大小的Pager
|
||||
*
|
||||
* @param offset 偏移量
|
||||
* @param size 数据大小
|
||||
*/
|
||||
public OffsetPager(int offset, int size) {
|
||||
super();
|
||||
this.offset = offset;
|
||||
setPageSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖超类的计算得到的offset
|
||||
*/
|
||||
public int getOffset() {
|
||||
if (offset > -1)
|
||||
return offset;
|
||||
return super.getOffset();
|
||||
}
|
||||
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.budwk.app.base.page;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class PageForm {
|
||||
|
||||
@NotNull(message = "pageNumber不能为空")
|
||||
@Min(value = 1, message = "pageNumber最小为1")
|
||||
private Integer pageNumber;
|
||||
|
||||
@NotNull(message = "pageSize不能为空")
|
||||
@Max(value = 50, message = "pageSize最大为50")
|
||||
private Integer pageSize;
|
||||
|
||||
private String pageOrderName;
|
||||
|
||||
private String pageOrderBy;
|
||||
|
||||
private String searchName;
|
||||
|
||||
private String searchKeyword;
|
||||
|
||||
public PageForm defaultSort(String column, String order) {
|
||||
this.setPageOrderName(column);
|
||||
this.setPageOrderBy(order);
|
||||
return this;
|
||||
}
|
||||
|
||||
public PageForm defaultSortAsc(String column) {
|
||||
return this.defaultSort(column, "ascending");
|
||||
}
|
||||
|
||||
public PageForm defaultSortDesc(String column) {
|
||||
return this.defaultSort(column, "descending");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.budwk.app.base.page;
|
||||
|
||||
public interface Paginable {
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getTotalCount();
|
||||
|
||||
/**
|
||||
* 总页数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getTotalPage();
|
||||
|
||||
/**
|
||||
* 每页记录数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPageSize();
|
||||
|
||||
/**
|
||||
* 当前页号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getPageNo();
|
||||
|
||||
/**
|
||||
* 是否第一页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFirstPage();
|
||||
|
||||
/**
|
||||
* 是否最后一页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isLastPage();
|
||||
|
||||
/**
|
||||
* 返回下页的页号
|
||||
*/
|
||||
public int getNextPage();
|
||||
|
||||
/**
|
||||
* 返回上页的页号
|
||||
*/
|
||||
public int getPrePage();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.budwk.app.base.page;
|
||||
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Pagination extends SimplePage implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Pagination() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 每页几条数据
|
||||
* @param totalCount 总共几条数据
|
||||
*/
|
||||
public Pagination(int pageNo, int pageSize, int totalCount) {
|
||||
super(pageNo, pageSize, totalCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 每页几条数据
|
||||
* @param totalCount 总共几条数据
|
||||
* @param list 分页内容
|
||||
*/
|
||||
public Pagination(int pageNo, int pageSize, int totalCount, List list) {
|
||||
super(pageNo, pageSize, totalCount);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第一条数据位置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getFirstResult() {
|
||||
return (pageNo - 1) * pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前页的数据
|
||||
*/
|
||||
private List list;
|
||||
|
||||
/**
|
||||
* 获得分页内容
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public <T> List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classOfT 列表容器內的元素类型
|
||||
* @param <T> 列表容器內的元素类型
|
||||
* @return
|
||||
*/
|
||||
public <T> List<T> getList(Class<T> classOfT) {
|
||||
return Lang.collection2list(list, classOfT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置分页内容
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
public void setList(List list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.budwk.app.base.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimplePage implements java.io.Serializable, Paginable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final int DEF_COUNT = 10;
|
||||
private List<Integer> localArrayList = new ArrayList<Integer>();
|
||||
|
||||
public List<Integer> getSegment() {
|
||||
return localArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查页码 checkPageNo
|
||||
*
|
||||
* @param pageNo
|
||||
* @return if pageNo==null or pageNo 小于 1 then return 1 else return pageNo
|
||||
*/
|
||||
public static int cpn(Integer pageNo) {
|
||||
return (pageNo == null || pageNo < 1) ? 1 : pageNo;
|
||||
}
|
||||
|
||||
public SimplePage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造器
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 每页几条数据
|
||||
* @param totalCount 总共几条数据
|
||||
*/
|
||||
public SimplePage(int pageNo, int pageSize, int totalCount) {
|
||||
setTotalCount(totalCount);
|
||||
setPageSize(pageSize);
|
||||
setPageNo(pageNo);
|
||||
adjustPageNo();
|
||||
int totalPages = getTotalPage();
|
||||
minPage = minPage < 1 ? 1 : minPage;
|
||||
maxPage = maxPage > totalPages ? totalPages : maxPage;
|
||||
for (int i = minPage; i <= maxPage; i++) {
|
||||
localArrayList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整页码,使不超过最大页数
|
||||
*/
|
||||
public void adjustPageNo() {
|
||||
if (pageNo == 1) {
|
||||
return;
|
||||
}
|
||||
int tp = getTotalPage();
|
||||
if (pageNo > tp) {
|
||||
pageNo = tp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得页码
|
||||
*/
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每页几条数据
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 总共几条数据
|
||||
*/
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 总共几页
|
||||
*/
|
||||
public int getTotalPage() {
|
||||
int totalPage = totalCount / pageSize;
|
||||
if (totalPage == 0 || totalCount % pageSize != 0) {
|
||||
totalPage++;
|
||||
}
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否第一页
|
||||
*/
|
||||
public boolean isFirstPage() {
|
||||
return pageNo <= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否最后一页
|
||||
*/
|
||||
public boolean isLastPage() {
|
||||
return pageNo >= getTotalPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下一页页码
|
||||
*/
|
||||
public int getNextPage() {
|
||||
if (isLastPage()) {
|
||||
return pageNo;
|
||||
} else {
|
||||
return pageNo + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上一页页码
|
||||
*/
|
||||
public int getPrePage() {
|
||||
if (isFirstPage()) {
|
||||
return pageNo;
|
||||
} else {
|
||||
return pageNo - 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected int totalCount = 0;
|
||||
protected int pageSize = 20;
|
||||
protected int pageNo = 1;
|
||||
|
||||
/**
|
||||
* if totalCount 小于 0 then totalCount=0
|
||||
*
|
||||
* @param totalCount
|
||||
*/
|
||||
public void setTotalCount(int totalCount) {
|
||||
if (totalCount < 0) {
|
||||
this.totalCount = 0;
|
||||
} else {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if pageSize 小于 1 then pageSize=DEF_COUNT
|
||||
*
|
||||
* @param pageSize
|
||||
*/
|
||||
public void setPageSize(int pageSize) {
|
||||
if (pageSize < 1) {
|
||||
this.pageSize = DEF_COUNT;
|
||||
} else {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if pageNo 小于 1 then pageNo=1
|
||||
*
|
||||
* @param pageNo
|
||||
*/
|
||||
public void setPageNo(int pageNo) {
|
||||
if (pageNo < 1) {
|
||||
this.pageNo = 1;
|
||||
} else {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
}
|
||||
|
||||
int minPage = pageNo - (int) Math.floor((pageSize - 1) / 2.0D);
|
||||
int maxPage = pageNo + (int) Math.ceil((pageSize - 1) / 2.0D);
|
||||
int totalPage = getTotalPage();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.budwk.app.base.page.datatable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/27.
|
||||
*/
|
||||
public class DataTableColumn implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected String data;
|
||||
protected String name;
|
||||
protected boolean searchable;
|
||||
protected boolean orderable;
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isSearchable() {
|
||||
return searchable;
|
||||
}
|
||||
|
||||
public void setSearchable(boolean searchable) {
|
||||
this.searchable = searchable;
|
||||
}
|
||||
|
||||
public boolean isOrderable() {
|
||||
return orderable;
|
||||
}
|
||||
|
||||
public void setOrderable(boolean orderable) {
|
||||
this.orderable = orderable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.budwk.app.base.page.datatable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/27.
|
||||
*/
|
||||
public class DataTableOrder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected int column;
|
||||
protected String dir;
|
||||
|
||||
public int getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
public void setColumn(int column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
public String getDir() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public void setDir(String dir) {
|
||||
this.dir = dir;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.budwk.app.base.result;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public interface IResultCode {
|
||||
int getCode();
|
||||
|
||||
String getMsg();
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.budwk.app.base.result;
|
||||
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/21.
|
||||
*/
|
||||
public class Result implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
private long time;
|
||||
|
||||
public Result() {
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static Result NEW() {
|
||||
return new Result();
|
||||
}
|
||||
|
||||
|
||||
public Result addCode(int code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result addMsg(String msg) {
|
||||
if (Strings.isBlank(msg) || Mvcs.getActionContext() == null || Mvcs.getActionContext().getRequest() == null || Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg) == null) {
|
||||
this.msg = Strings.sNull(msg);
|
||||
} else {
|
||||
this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result addData(Object data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result(int code, String msg, Object data) {
|
||||
this.code = code;
|
||||
if (Strings.isBlank(msg) || Mvcs.getActionContext() == null || Mvcs.getActionContext().getRequest() == null || Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg) == null) {
|
||||
this.msg = Strings.sNull(msg);
|
||||
} else {
|
||||
this.msg = Mvcs.getMessage(Mvcs.getActionContext().getRequest(), msg);
|
||||
}
|
||||
this.data = data;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static Result success(String content) {
|
||||
return new Result(0, content, null);
|
||||
}
|
||||
|
||||
public static Result success(String content, Object data) {
|
||||
return new Result(0, content, data);
|
||||
}
|
||||
|
||||
public static Result success(Object data) {
|
||||
return new Result(0, "system.success", data);
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return this.code == ResultCode.SUCCESS.code;
|
||||
}
|
||||
|
||||
public static Result error(IResultCode resultCode) {
|
||||
return new Result(resultCode.getCode(), resultCode.getMsg(), null);
|
||||
}
|
||||
|
||||
public static Result error(int code, String content) {
|
||||
return new Result(code, content, null);
|
||||
}
|
||||
|
||||
public static Result error(String content) {
|
||||
return new Result(1, content, null);
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
return new Result(0, "system.success", null);
|
||||
}
|
||||
|
||||
public static Result error() {
|
||||
return new Result(1, "system.error", null);
|
||||
}
|
||||
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static Result condition(boolean flag) {
|
||||
return flag ? success("system.error") : error("system.error");
|
||||
}
|
||||
|
||||
public String toJsonString() {
|
||||
return Json.toJson(this, JsonFormat.compact());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.budwk.app.base.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ResultCode implements IResultCode {
|
||||
SUCCESS(0,"操作成功"),
|
||||
FAILURE(200400,"业务异常"),
|
||||
NOT_FOUND(200404,"服务未找到"),
|
||||
TOO_MANY_REQUESTS(200429, "请求次数过多"),
|
||||
SERVER_ERROR(200500,"服务异常"),
|
||||
IOC_ERROR(500000,"IOC对象加载异常"),
|
||||
NULL_DATA_ERROR(500100,"数据不存在"),
|
||||
HAVE_DATA_ERROR(500110,"数据已存在"),
|
||||
PARAM_ERROR(500200,"参数错误"),
|
||||
XSS_SQL_ERROR(500300,"传参被拦截"),
|
||||
BLACKLIST_ERROR(500400,"IP黑名单"),
|
||||
DAO_ERROR(500600,"DAO数据库查询错误"),
|
||||
DEMO_ERROR(500700,"演示环境,限制操作"),
|
||||
|
||||
USER_NOT_LOGIN(600098, "用户未登录"),
|
||||
USER_NOT_ROLE(600099, "无此角色"),
|
||||
USER_NOT_PERMISSION(600100, "无此权限"),
|
||||
USER_NOT_FOUND(600101, "用户不存在"),
|
||||
USER_DISABLED(600102, "用户被禁用"),
|
||||
USER_LOCKED(600103, "用户已锁定"),
|
||||
USER_NAME_ERROR(600104, "用户名错误"),
|
||||
USER_PWD_ERROR(600105, "用户密码错误"),
|
||||
USER_PWD_EXPIRED(600106, "用户密码过期"),
|
||||
USER_VERIFY_ERROR(600107, "验证码错误"),
|
||||
USER_LOGIN_FAIL(600108, "用户登录失败");
|
||||
|
||||
final int code;
|
||||
final String msg;
|
||||
}
|
||||
@@ -0,0 +1,914 @@
|
||||
package com.budwk.app.base.service;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.page.datatable.DataTableColumn;
|
||||
import com.budwk.app.base.page.datatable.DataTableOrder;
|
||||
import org.nutz.dao.*;
|
||||
import org.nutz.dao.entity.Entity;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface BaseService<T> {
|
||||
|
||||
Dao dao();
|
||||
|
||||
/**
|
||||
* 获取实体的Entity
|
||||
*
|
||||
* @return 实体的Entity
|
||||
*/
|
||||
Entity<T> getEntity();
|
||||
|
||||
/**
|
||||
* 获取实体类型
|
||||
*
|
||||
* @return 实体类型
|
||||
*/
|
||||
Class<T> getEntityClass();
|
||||
|
||||
/**
|
||||
* 统计符合条件的对象表条数
|
||||
*
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int count(Condition cnd);
|
||||
|
||||
/**
|
||||
* 统计对象表条数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int count();
|
||||
|
||||
/**
|
||||
* 统计符合条件的记录条数
|
||||
*
|
||||
* @param tableName
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int count(String tableName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 统计表记录条数
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
int count(String tableName);
|
||||
|
||||
/**
|
||||
* 自定义SQL统计
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
int count(Sql sql);
|
||||
|
||||
/**
|
||||
* 通过数字型主键查询对象
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
T fetch(long id);
|
||||
|
||||
/**
|
||||
* 通过字符型主键查询对象
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
T fetch(String id);
|
||||
|
||||
/**
|
||||
* 查询关联表
|
||||
*
|
||||
* @param obj 数据对象,可以是普通对象或集合,但不是类
|
||||
* @param regex 为null查询全部,支持通配符 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
<T> T fetchLinks(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 查询关联表
|
||||
*
|
||||
* @param obj 数据对象,可以是普通对象或集合,但不是类
|
||||
* @param regex 为null查询全部,支持通配符 ^(a|b)$
|
||||
* @param cnd 关联字段的过滤(排序,条件语句,分页等)
|
||||
* @return
|
||||
*/
|
||||
<T> T fetchLinks(T obj, String regex, Condition cnd);
|
||||
|
||||
|
||||
/**
|
||||
* 查出符合条件的第一条记录
|
||||
*
|
||||
* @param cnd 查询条件
|
||||
* @return 实体, 如不存在则为null
|
||||
*/
|
||||
T fetch(Condition cnd);
|
||||
|
||||
/**
|
||||
* 复合主键专用
|
||||
*
|
||||
* @param pks 键值
|
||||
* @return 对象 T
|
||||
*/
|
||||
T fetchx(Object... pks);
|
||||
|
||||
/**
|
||||
* 复合主键专用
|
||||
*
|
||||
* @param pks 键值
|
||||
* @return 对象 T
|
||||
*/
|
||||
boolean exists(Object... pks);
|
||||
|
||||
/**
|
||||
* 将一个对象插入到一个数据库
|
||||
*
|
||||
* @param obj 要被插入的对象
|
||||
* 它可以是:
|
||||
* 普通 POJO
|
||||
* 集合
|
||||
* 数组
|
||||
* Map
|
||||
* 注意:如果是集合,数组或者 Map,所有的对象必须类型相同,否则可能会出错
|
||||
* @return 插入后的对象
|
||||
*/
|
||||
<T> T insert(T obj);
|
||||
|
||||
/**
|
||||
* 将一个对象按FieldFilter过滤后,插入到一个数据源。
|
||||
* <p>
|
||||
* <code>dao.insert(pet, FieldFilter.create(Pet.class, FieldMatcher.create(false)));</code>
|
||||
*
|
||||
* @param obj 要被插入的对象
|
||||
* @param filter 字段过滤器, 其中FieldMatcher.isIgnoreId生效
|
||||
* @return 插入后的对象
|
||||
* @see Dao#insert(Object)
|
||||
*/
|
||||
<T> T insert(T obj, FieldFilter filter);
|
||||
|
||||
/**
|
||||
* 根据对象的主键(@Id/@Name/@Pk)先查询, 如果存在就更新, 不存在就插入
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 原对象
|
||||
*/
|
||||
<T> T insertOrUpdate(T obj);
|
||||
|
||||
/**
|
||||
* 根据对象的主键(@Id/@Name/@Pk)先查询, 如果存在就更新, 不存在就插入
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param insertFieldFilter 插入时的字段过滤, 可以是null
|
||||
* @param updateFieldFilter 更新时的字段过滤,可以是null
|
||||
* @return 原对象
|
||||
*/
|
||||
<T> T insertOrUpdate(T obj, FieldFilter insertFieldFilter, FieldFilter updateFieldFilter);
|
||||
|
||||
/**
|
||||
* 自由的向一个数据表插入一条数据
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param chain 数据名值链
|
||||
*/
|
||||
void insert(String tableName, Chain chain);
|
||||
|
||||
/**
|
||||
* 快速插入一个对象,对象的 '@Prev' 以及 '@Next' 在这个函数里不起作用
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
<T> T fastInsert(T obj);
|
||||
|
||||
/**
|
||||
* 将对象插入数据库同时,也将符合一个正则表达式的所有关联字段关联的对象统统插入相应的数据库
|
||||
* <p>
|
||||
* 关于关联字段更多信息,请参看 '@One' | '@Many' | '@ManyMany' 更多的描述
|
||||
*
|
||||
* @param obj 数据对象
|
||||
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被插入
|
||||
* @return 数据对象本身
|
||||
* @see org.nutz.dao.entity.annotation.One
|
||||
* @see org.nutz.dao.entity.annotation.Many
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
<T> T insertWith(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 根据一个正则表达式,仅将对象所有的关联字段插入到数据库中,并不包括对象本身
|
||||
*
|
||||
* @param obj 数据对象
|
||||
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被插入
|
||||
* @return 数据对象本身
|
||||
* @see org.nutz.dao.entity.annotation.One
|
||||
* @see org.nutz.dao.entity.annotation.Many
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
<T> T insertLinks(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 将对象的一个或者多个,多对多的关联信息,插入数据表
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param regex 正则表达式,描述了那种多对多关联字段将被执行该操作
|
||||
* @return 对象自身
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
<T> T insertRelation(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
int update(Object obj);
|
||||
|
||||
/**
|
||||
* 更新数据忽略值为null的字段
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
int updateIgnoreNull(Object obj);
|
||||
|
||||
/**
|
||||
* 部分更新实体表
|
||||
*
|
||||
* @param chain
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int update(Chain chain, Condition cnd);
|
||||
|
||||
/**
|
||||
* 部分更新表
|
||||
*
|
||||
* @param tableName
|
||||
* @param chain
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int update(String tableName, Chain chain, Condition cnd);
|
||||
|
||||
/**
|
||||
* 将对象更新的同时,也将符合一个正则表达式的所有关联字段关联的对象统统更新
|
||||
* <p>
|
||||
* 关于关联字段更多信息,请参看 '@One' | '@Many' | '@ManyMany' 更多的描述
|
||||
*
|
||||
* @param obj 数据对象
|
||||
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被更新
|
||||
* @return 数据对象本身
|
||||
* @see org.nutz.dao.entity.annotation.One
|
||||
* @see org.nutz.dao.entity.annotation.Many
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
<T> T updateWith(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 根据一个正则表达式,仅更新对象所有的关联字段,并不包括对象本身
|
||||
*
|
||||
* @param obj 数据对象
|
||||
* @param regex 正则表达式,描述了什么样的关联字段将被关注。如果为 null,则表示全部的关联字段都会被更新
|
||||
* @return 数据对象本身
|
||||
* @see org.nutz.dao.entity.annotation.One
|
||||
* @see org.nutz.dao.entity.annotation.Many
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
<T> T updateLinks(T obj, String regex);
|
||||
|
||||
/**
|
||||
* 多对多关联是通过一个中间表将两条数据表记录关联起来。
|
||||
* <p>
|
||||
* 而这个中间表可能还有其他的字段,比如描述关联的权重等
|
||||
* <p>
|
||||
* 这个操作可以让你一次更新某一个对象中多个多对多关联的数据
|
||||
*
|
||||
* @param classOfT 对象类型
|
||||
* @param regex 正则表达式,描述了那种多对多关联字段将被执行该操作
|
||||
* @param chain 针对中间关联表的名值链。
|
||||
* @param cnd 针对中间关联表的 WHERE 条件
|
||||
* @return 共有多少条数据被更新
|
||||
* @see org.nutz.dao.entity.annotation.ManyMany
|
||||
*/
|
||||
int updateRelation(Class<?> classOfT, String regex, Chain chain, Condition cnd);
|
||||
|
||||
/**
|
||||
* 基于版本的更新,版本不一样无法更新到数据
|
||||
*
|
||||
* @param obj 需要更新的对象, 必须有version属性
|
||||
* @return 若更新成功, 大于0, 否则小于0
|
||||
*/
|
||||
int updateWithVersion(Object obj);
|
||||
|
||||
/**
|
||||
* 基于版本的更新,版本不一样无法更新到数据
|
||||
*
|
||||
* @param obj 需要更新的对象, 必须有version属性
|
||||
* @param filter 需要过滤的字段设置
|
||||
* @return 若更新成功, 大于0, 否则小于0
|
||||
*/
|
||||
int updateWithVersion(Object obj, FieldFilter filter);
|
||||
|
||||
/**
|
||||
* 乐观锁, 以特定字段的值作为限制条件,更新对象,并自增该字段.
|
||||
* <p>
|
||||
* 执行的sql如下:
|
||||
* <p>
|
||||
* <code>update t_user set age=30, city="广州", version=version+1 where name="wendal" and version=124;</code>
|
||||
*
|
||||
* @param obj 需要更新的对象, 必须带@Id/@Name/@Pk中的其中一种.
|
||||
* @param fieldFilter 需要过滤的属性. 若设置了哪些字段不更新,那务必确保过滤掉fieldName的字段
|
||||
* @param fieldName 参考字段的Java属性名.默认是"version",可以是任意数值字段
|
||||
* @return 若更新成功, 返回值大于0, 否则小于等于0
|
||||
*/
|
||||
int updateAndIncrIfMatch(Object obj, FieldFilter fieldFilter, String fieldName);
|
||||
|
||||
/**
|
||||
* 获取某个对象,最大的 ID 值,这个对象必须声明了 '@Id'
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getMaxId();
|
||||
|
||||
/**
|
||||
* 通过long主键删除数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delete(long id);
|
||||
|
||||
/**
|
||||
* 通过int主键删除数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delete(int id);
|
||||
|
||||
/**
|
||||
* 通过string主键删除数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delete(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void delete(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void delete(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void delete(String[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 清空表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int clear();
|
||||
|
||||
/**
|
||||
* 清空表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int clear(String tableName);
|
||||
|
||||
/**
|
||||
* 按条件清除一组数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int clear(Condition cnd);
|
||||
|
||||
/**
|
||||
* 按条件清除一组数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int clear(String tableName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 伪删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int vDelete(String id);
|
||||
|
||||
/**
|
||||
* 批量伪删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int vDelete(String[] ids);
|
||||
|
||||
/**
|
||||
* 批量伪删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int vDelete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据条件进行伪删除
|
||||
*
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int vDelete(Condition cnd);
|
||||
|
||||
/**
|
||||
* 根据条件进行伪删除
|
||||
*
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
int vDelete(String tableName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 通过LONG主键获取部分字段值
|
||||
*
|
||||
* @param fieldName
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
T getField(String fieldName, long id);
|
||||
|
||||
/**
|
||||
* 通过INT主键获取部分字段值
|
||||
*
|
||||
* @param fieldName
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
T getField(String fieldName, int id);
|
||||
|
||||
/**
|
||||
* 通过NAME主键获取部分字段值
|
||||
*
|
||||
* @param fieldName 支持通配符 ^(a|b)$
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
T getField(String fieldName, String name);
|
||||
|
||||
/**
|
||||
* 通过条件获取部分字段值
|
||||
*
|
||||
* @param fieldName 支持通配符 ^(a|b)$
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
T getField(String fieldName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 查询获取部分字段
|
||||
*
|
||||
* @param fieldName 支持通配符 ^(a|b)$
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
List<T> query(String fieldName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 查询一组对象。你可以为这次查询设定条件
|
||||
*
|
||||
* @param cnd WHERE 条件。如果为 null,将获取全部数据,顺序为数据库原生顺序<br>
|
||||
* 只有在调用这个函数的时候, cnd.limit 才会生效
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<T> query(Condition cnd);
|
||||
|
||||
/**
|
||||
* 获取全部数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<T> query();
|
||||
|
||||
/**
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联字段,支持正则 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
List<T> query(Condition cnd, String linkName);
|
||||
|
||||
/**
|
||||
* 获取表及关联表全部数据(支持子查询)
|
||||
*
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联字段,支持正则 ^(a|b)$
|
||||
* @param linkCnd 关联条件
|
||||
* @return
|
||||
*/
|
||||
List<T> query(Condition cnd, String linkName, Condition linkCnd);
|
||||
|
||||
/**
|
||||
* 获取表及关联表全部数据
|
||||
*
|
||||
* @param linkName 关联字段,支持正则 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
List<T> query(String linkName);
|
||||
|
||||
/**
|
||||
* 分页关联字段查询
|
||||
*
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联字段,支持正则 ^(a|b)$
|
||||
* @param pager 分页对象
|
||||
* @return
|
||||
*/
|
||||
List<T> query(Condition cnd, String linkName, Pager pager);
|
||||
|
||||
/**
|
||||
* 分页关联字段查询(支持关联条件)
|
||||
*
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联字段,支持正则 ^(a|b)$
|
||||
* @param linkCnd 关联条件
|
||||
* @param pager 分页对象
|
||||
* @return
|
||||
*/
|
||||
List<T> query(Condition cnd, String linkName, Condition linkCnd, Pager pager);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param cnd 查询条件
|
||||
* @param pager 分页对象
|
||||
* @return
|
||||
*/
|
||||
List<T> query(Condition cnd, Pager pager);
|
||||
|
||||
/**
|
||||
* 查询获取NutMap对象
|
||||
*
|
||||
* @param keyColumnName 作为key的字段名
|
||||
* @param valueColumnName 作为value的字段名
|
||||
* @param cnd 查询条件
|
||||
* @return
|
||||
*/
|
||||
NutMap query(String keyColumnName, String valueColumnName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 查询获取NutMap对象
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param keyColumnName 作为key的字段名
|
||||
* @param valueColumnName 作为value的字段名
|
||||
* @param cnd 查询条件
|
||||
* @return
|
||||
*/
|
||||
NutMap query(String tableName, String keyColumnName, String valueColumnName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 计算子节点TREEID
|
||||
*
|
||||
* @param tableName
|
||||
* @param colName
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
String getSubPath(String tableName, String colName, String value);
|
||||
|
||||
/**
|
||||
* 获取TREEID父级
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
String getParentPath(String path);
|
||||
|
||||
|
||||
/**
|
||||
* 执行一条自定义SQL
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Sql execute(Sql sql);
|
||||
|
||||
/**
|
||||
* 自定义SQL返回Record记录集,Record是个MAP但不区分大小写
|
||||
* 别返回Map对象,因为MySql和Oracle中字段名有大小写之分
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
List<Record> list(Sql sql);
|
||||
|
||||
/**
|
||||
* 自定义SQL返回NutMap记录集,区分大小写
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
List<NutMap> listMap(Sql sql);
|
||||
|
||||
/**
|
||||
* 自定义查询,并返回当前实体类对象
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
List<T> listEntity(Sql sql);
|
||||
|
||||
/**
|
||||
* 自定义sql获取map key-value
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Map getMap(Sql sql);
|
||||
|
||||
/**
|
||||
* 自定义sql获取NutMap key-value
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
NutMap getNutMap(Sql sql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, Condition cnd);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, Sql sql);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询(sql)
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, int pageSize, Sql sql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param sql 查询语句
|
||||
* @param countSql 统计语句
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, Sql sql, Sql countSql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param sql 查询语句
|
||||
* @param countSql 统计语句
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, int pageSize, Sql sql, Sql countSql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, Sql sql);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询(sql)
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, int pageSize, Sql sql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param sql 查询语句
|
||||
* @param countSql 统计语句
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, Sql sql, Sql countSql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param sql 查询语句
|
||||
* @param countSql 统计语句
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, int pageSize, Sql sql, Sql countSql);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param tableName
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, String tableName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 分页查询(cnd)
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, int pageSize, Condition cnd);
|
||||
|
||||
/**
|
||||
* 分页查询,获取部分字段(cnd)
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param cnd
|
||||
* @param fieldName 支持通配符 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, int pageSize, Condition cnd, String fieldName);
|
||||
|
||||
/**
|
||||
* 关联查询
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param cnd
|
||||
* @param linkName 支持通配符 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageLinks(Integer pageNumber, int pageSize, Condition cnd, String linkName);
|
||||
|
||||
/**
|
||||
* 关联查询,带子查询条件
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param cnd
|
||||
* @param linkName 支持通配符 ^(a|b)$
|
||||
* @param subCnd 子查询条件
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageLinks(Integer pageNumber, int pageSize, Condition cnd, String linkName, Condition subCnd);
|
||||
|
||||
/**
|
||||
* 分页查询(tabelName)
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param tableName
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPage(Integer pageNumber, int pageSize, String tableName, Condition cnd);
|
||||
|
||||
/**
|
||||
* 分页查询并返回包含实体类内容的NutMap对象
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, Condition cnd);
|
||||
|
||||
/**
|
||||
* 分页查询并返回包含实体类内容的NutMap对象
|
||||
*
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @param cnd
|
||||
* @return
|
||||
*/
|
||||
Pagination listPageMap(Integer pageNumber, int pageSize, Condition cnd);
|
||||
|
||||
|
||||
/**
|
||||
* DataTable Page
|
||||
*
|
||||
* @param length 页大小
|
||||
* @param start start
|
||||
* @param draw draw
|
||||
* @param orders 排序
|
||||
* @param columns 字段
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联查询 支持通配符 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName);
|
||||
|
||||
/**
|
||||
* DataTable Page
|
||||
*
|
||||
* @param length 页大小
|
||||
* @param start start
|
||||
* @param draw draw
|
||||
* @param orders 排序
|
||||
* @param columns 字段
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联查询 支持通配符 ^(a|b)$
|
||||
* @param subCnd 关联查询条件
|
||||
* @return
|
||||
*/
|
||||
NutMap data(int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName, Cnd subCnd);
|
||||
|
||||
/**
|
||||
* DataTable Page 自定义SQL
|
||||
*
|
||||
* @param length 页大小
|
||||
* @param start start
|
||||
* @param draw draw
|
||||
* @param countSql 统计查询语句
|
||||
* @param orderSql 结果查询语句
|
||||
* @return
|
||||
*/
|
||||
NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql);
|
||||
|
||||
/**
|
||||
* DataTable Page 自定义SQL
|
||||
*
|
||||
* @param length 页大小
|
||||
* @param start start
|
||||
* @param draw draw
|
||||
* @param countSql 统计查询语句
|
||||
* @param orderSql 结果查询语句
|
||||
* @param countOnly 统计查询语句是否只有count()
|
||||
* @return
|
||||
*/
|
||||
NutMap data(int length, int start, int draw, Sql countSql, Sql orderSql, boolean countOnly);
|
||||
|
||||
/**
|
||||
* DataTable Page
|
||||
*
|
||||
* @param length 页大小
|
||||
* @param start start
|
||||
* @param draw draw
|
||||
* @param cnd 查询条件
|
||||
* @param linkName 关联查询 支持通配符 ^(a|b)$
|
||||
* @return
|
||||
*/
|
||||
NutMap data(int length, int start, int draw, Cnd cnd, String linkName);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,116 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.nutz.lang.Times;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/24.
|
||||
*/
|
||||
public class DateUtil {
|
||||
private static final Locale DEFAULT_LOCALE = Locale.CHINA;
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/**
|
||||
* 获取当前时间(HH:mm:ss)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getDate() {
|
||||
return DateFormatUtils.format(new Date(), "yyyy-MM-dd", DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间(HH:mm:ss)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getTime() {
|
||||
return DateFormatUtils.format(new Date(), "HH:mm:ss", DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间(yyyy-MM-dd HH:mm:ss)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getDateTime() {
|
||||
return DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换日期格式(yyyy-MM-dd HH:mm:ss)
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static String formatDateTime(Date date) {
|
||||
if (date == null) return "";
|
||||
return DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换日期格式(yyyy-MM-dd HH:mm:ss)
|
||||
*
|
||||
* @param date
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
public static String format(Date date, String f) {
|
||||
if (date == null) return "";
|
||||
return DateFormatUtils.format(date, f, DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳日期
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static String getDate(long time) {
|
||||
return DateFormatUtils.format(new Date(time * 1000), "yyyy-MM-dd HH:mm:ss", DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间戳日期
|
||||
*
|
||||
* @param time
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
public static String getDate(long time, String f) {
|
||||
return DateFormatUtils.format(new Date(time * 1000), f, DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字符串时间获取时间戳 nutzwk5.0改为long
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static long getTime(String date) {
|
||||
try {
|
||||
return Times.parse(sdf, date).getTime() / 1000;
|
||||
} catch (ParseException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字符串时间获取时间戳 nutzwk5.0改为long
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static long getTime(SimpleDateFormat sdf, String date) {
|
||||
try {
|
||||
return Times.parse(sdf, date).getTime() / 1000;
|
||||
} catch (ParseException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* 分页获取文件列表
|
||||
*
|
||||
* @param basePath 目录
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 页大小
|
||||
* @param sort 按文件名排序
|
||||
* @return 列表
|
||||
* @throws Exception
|
||||
*/
|
||||
public static NutMap readListPage(String basePath, Integer pageNumber, Integer pageSize, String sort)
|
||||
throws Exception {
|
||||
int offset = (pageNumber - 1) * pageSize;
|
||||
int limit = pageNumber * pageSize;
|
||||
long total = 0;
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
Comparator<Path> comparator = Comparator.naturalOrder();
|
||||
if ("desc".equals(sort)) {
|
||||
comparator = Comparator.reverseOrder();
|
||||
}
|
||||
try (Stream<Path> fileList = Files.list(Paths.get(basePath))) {
|
||||
total = fileList.count();
|
||||
}
|
||||
try (Stream<Path> fileList = Files.list(Paths.get(basePath)).sorted(comparator).skip(offset)
|
||||
.limit(limit)) {
|
||||
fileList.forEach(file -> {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
String fileName = file.getFileName().toString();
|
||||
nutMap.addv("fileName", fileName);
|
||||
if (Files.isDirectory(file.toAbsolutePath())) {
|
||||
nutMap.addv("folder", true);
|
||||
nutMap.addv("suffix", "folder");
|
||||
} else {
|
||||
String suffix = fileName.substring(fileName.indexOf(".") + 1).toLowerCase();
|
||||
nutMap.addv("folder", false);
|
||||
nutMap.addv("suffix", suffix);
|
||||
}
|
||||
list.add(nutMap);
|
||||
});
|
||||
return NutMap.NEW().addv("total", total).addv("list", list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2017/7/21.
|
||||
*/
|
||||
public class MapUtil {
|
||||
/**
|
||||
* 使用 Map按key进行排序
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> sortMapByKey(Map<String, Object> map) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> sortMap = new TreeMap<>(
|
||||
new MapKeyComparator());
|
||||
sortMap.putAll(map);
|
||||
return sortMap;
|
||||
}
|
||||
}
|
||||
|
||||
class MapKeyComparator implements Comparator<String> {
|
||||
@Override
|
||||
public int compare(String str1, String str2) {
|
||||
return str1.compareTo(str2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
//package com.budwk.app.base.utils;
|
||||
//
|
||||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.net.util.Base64;
|
||||
//import org.nutz.aop.interceptor.async.Async;
|
||||
//import org.nutz.ioc.loader.annotation.IocBean;
|
||||
//import org.nutz.lang.Strings;
|
||||
//import java.security.MessageDigest;
|
||||
//import java.security.NoSuchAlgorithmException;
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.*;
|
||||
//import java.util.concurrent.ExecutorService;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//@IocBean
|
||||
//@Slf4j
|
||||
//public class MsgApi {
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * token -redis - name
|
||||
// */
|
||||
// private static final String msgTokenName = "msg_token";
|
||||
// /**
|
||||
// * 发送消息接口
|
||||
// */
|
||||
// private static final String smsSendMsgApi = "http://txgl.cug.edu.cn/tp_mp/service/SmsService?wsdl";
|
||||
//
|
||||
// private static final String weChatSendMsgApi = "http://txgl.cug.edu.cn/tp_mp/service/WechatService?wsdl";
|
||||
// /**
|
||||
// * 密钥
|
||||
// */
|
||||
// private static final String PASSWORD = "kzOm2sr9ki0ZREJX6GbrpQJyM5E=";
|
||||
//
|
||||
// /**
|
||||
// * 通用模板id
|
||||
// */
|
||||
// private static final String COMMON_TEMPLATE_ID = "7218401631600640";
|
||||
//
|
||||
// private static ExecutorService pool;
|
||||
//
|
||||
// /**
|
||||
// * 发送短信信息
|
||||
// */
|
||||
// @Async
|
||||
// public void sendSmsMsg(String person_info, String sms_info) {
|
||||
//
|
||||
//
|
||||
// ObjectMapper mapper = new ObjectMapper();
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// try {
|
||||
//// ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[]{});
|
||||
//// Resource resource = appContext.getResource("url:" + smsSendMsgApi);
|
||||
// Date date = new Date();
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// //秘钥,必须
|
||||
// map.put("secret_key", getSHA(PASSWORD));
|
||||
//
|
||||
// //对应的第三方系统名称(协议值),必须
|
||||
// map.put("tp_name", "zhihuigonghui");
|
||||
//
|
||||
// //对应的模块名称(协议值),必须
|
||||
// map.put("module_id", "sms");
|
||||
//
|
||||
// //对应的平台系统名称(协议值),必须
|
||||
// map.put("sys_id", "mp");
|
||||
//
|
||||
// //对应的接口方法名称(协议值),必须
|
||||
// map.put("interface_method", "saveSmsInfo");
|
||||
//
|
||||
// //接收人信息,每个人员信息格式为: 名字|学工号|部门ID|部门名称|电话号码|邮箱,人与人之间用“^@^”隔开(如果数据无法提供,可以写空,但是“|”不可省略),必须
|
||||
// map.put("person_info", person_info);
|
||||
//
|
||||
// //邮件内容,必须
|
||||
// map.put("sms_info", sms_info);
|
||||
//
|
||||
// //发送优先级(1:紧急通知;2:验证码;3:立即发送;4:发送),必须
|
||||
// map.put("send_priority", "3");
|
||||
//
|
||||
// //发送时间,String型,可为空,参数不可省略
|
||||
// map.put("send_time", sdf.format(date));
|
||||
//
|
||||
// //发送人UID,发送模板的时候不可为空,参数不可省略;发送人一般为部门信息管理员(在职教职工6位工号)。
|
||||
// map.put("operator_id", "");
|
||||
//
|
||||
// //发送人ID_NUMBER,需要发送回执的时候不可为空,其他可为空,参数不可省略;发送人一般为部门信息管理员(在职教职工6位工号)。
|
||||
// map.put("operator_id_number", "");
|
||||
//
|
||||
// //发送人姓名,需和发送人工号匹配,可为空,参数不可省略。
|
||||
// map.put("operator_name", "");
|
||||
//
|
||||
// //发送人部门ID,不可为空,参数不可省略,有关于短信的配额问题;必须填写实际的发送部门编号,可咨询网信中心。
|
||||
// map.put("operator_unit_id", "421");
|
||||
//
|
||||
// //发送人部门名称,可为空,参数不可省略。使用短信配额的机构名称,和部门编号匹配。
|
||||
// map.put("operator_unit_name", "工会");
|
||||
//
|
||||
// //发送模板选择,不发送模板值为”0”,参数不可省略。这里使用网信中心提供的通用模板ID:7218401631600640。模板内容:【智慧地大】${ person_info}您好!${ person_send }通知信息:${ sms_info }。
|
||||
// map.put("templet_id", COMMON_TEMPLATE_ID);
|
||||
//
|
||||
// //发送回执选择,不发送模板值为”0”,参数不可省略
|
||||
// map.put("receipt_id", "0");
|
||||
//
|
||||
// //发送人签名,参数不可省略。通用模板中有“发送人签名”标签,必须填写准确的系统名称。
|
||||
// map.put("person_send", "智慧工会");
|
||||
//
|
||||
// //发送平台码,必须
|
||||
// map.put("send_sys_id", "1");
|
||||
//
|
||||
// //发送平台名称,必须
|
||||
// map.put("send_sys_name", "智慧工会");
|
||||
//
|
||||
// //发送使用的浏览器,可为空,参数不可省略
|
||||
// map.put("user_browser", "");
|
||||
// //转化
|
||||
// String json = mapper.writeValueAsString(map);
|
||||
// System.out.println("json:" + json);
|
||||
// //调用
|
||||
//
|
||||
// try {
|
||||
// /* Client client = null;
|
||||
// client = new Client(resource.getInputStream(), null);
|
||||
// //输出结果 boolean型,true代表推送成功,false为失败
|
||||
// Object[] result = client.invoke("saveSmsInfo", new Object[]{json});
|
||||
// System.out.println(result[0]);
|
||||
// System.out.println(person_info);
|
||||
// log.info("短信发送成功!{}", result[0]);
|
||||
// client.close();*/
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取token
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// private String getSHA(String password) {
|
||||
// try {
|
||||
// MessageDigest sha = MessageDigest.getInstance("SHA");
|
||||
// sha.update(password.getBytes());
|
||||
// byte[] hash = sha.digest();
|
||||
// return new String(Base64.encodeBase64(hash));
|
||||
// } catch (NoSuchAlgorithmException e1) {
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// return "";
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public String userData(String mobile) {
|
||||
// List<String> list = new ArrayList<>();
|
||||
// list.add("");
|
||||
// list.add("");
|
||||
// list.add("");
|
||||
// list.add("");
|
||||
// list.add(Strings.isNotBlank(mobile) ? mobile : "");
|
||||
// list.add("");
|
||||
// list.add("");
|
||||
// String collect = list.stream().collect(Collectors.joining("|"));
|
||||
// return collect;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018.09
|
||||
*/
|
||||
public class PageUtil {
|
||||
public static String getOrder(String key) {
|
||||
NutMap map = NutMap.NEW().addv("ascending", "asc").addv("descending", "desc");
|
||||
return map.getString(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import net.sourceforge.pinyin4j.PinyinHelper;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2017/5/24.
|
||||
*/
|
||||
@IocBean
|
||||
public class PinyinUtil {
|
||||
/**
|
||||
* 将汉字转换为全拼
|
||||
*/
|
||||
public static String getPingYin(String name) {
|
||||
char[] charArray = name.toCharArray();
|
||||
StringBuilder pinyin = new StringBuilder();
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
if (Character.toString(charArray[i]).matches("[\\u4E00-\\u9FA5]+")) {
|
||||
pinyin.append(PinyinHelper.toHanyuPinyinStringArray(charArray[i])[0]);
|
||||
} else {
|
||||
pinyin.append(charArray[i]);
|
||||
}
|
||||
}
|
||||
return pinyin.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回中文的首字母
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String getPinYinHeadChar(String str) {
|
||||
|
||||
String convert = "";
|
||||
for (int j = 0; j < str.length(); j++) {
|
||||
char word = str.charAt(j);
|
||||
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
|
||||
if (pinyinArray != null) {
|
||||
convert += pinyinArray[0].charAt(0);
|
||||
} else {
|
||||
convert += word;
|
||||
}
|
||||
}
|
||||
return convert;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串转移为ASCII码
|
||||
*
|
||||
* @param cnStr
|
||||
* @return
|
||||
*/
|
||||
public static String getCnASCII(String cnStr) {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
byte[] bGBK = cnStr.getBytes();
|
||||
for (int i = 0; i < bGBK.length; i++) {
|
||||
strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
|
||||
}
|
||||
return strBuf.toString();
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println(getPingYin("綦江qq县"));
|
||||
// System.out.println(getPinYinHeadChar("綦江县"));
|
||||
// System.out.println(getCnASCII("綦江县"));
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* 为老兼容老的密码加密方式
|
||||
*
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public class PwdUtil {
|
||||
|
||||
public static String getPassword(String passowrd, String salt) {
|
||||
byte[] bytes = hash(passowrd.getBytes(), salt.getBytes(), 1024);
|
||||
if (bytes != null) {
|
||||
return Lang.fixedHexString(bytes);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static byte[] hash(byte[] bytes, byte[] salt, int hashIterations) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
if (salt != null) {
|
||||
digest.reset();
|
||||
digest.update(salt);
|
||||
}
|
||||
|
||||
byte[] hashed = digest.digest(bytes);
|
||||
int iterations = hashIterations - 1;
|
||||
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
digest.reset();
|
||||
hashed = digest.digest(hashed);
|
||||
}
|
||||
return hashed;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.lang.Lang;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/6/28.
|
||||
*/
|
||||
public class SignUtil {
|
||||
|
||||
public static String createSign(String appkey, Map<String, Object> params) {
|
||||
Map<String, Object> map = MapUtil.sortMapByKey(params);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Set<String> keySet = map.keySet();
|
||||
Iterator<String> it = keySet.iterator();
|
||||
while (it.hasNext()) {
|
||||
String k = it.next();
|
||||
String v = (String) map.get(k);
|
||||
if (null != v && !"".equals(v)
|
||||
&& !"sign".equals(k)) {
|
||||
sb.append(k + "=" + v + "&");
|
||||
}
|
||||
}
|
||||
sb.append("appkey=" + appkey);
|
||||
String sign = Lang.md5(sb.toString());
|
||||
return sign;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/3/17.
|
||||
*/
|
||||
public class StringUtil {
|
||||
/**
|
||||
* 去掉URL中?后的路径
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public static String getPath(String p) {
|
||||
if (Strings.sNull(p).contains("?")) {
|
||||
return p.substring(0, p.indexOf("?"));
|
||||
}
|
||||
return Strings.sNull(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得父节点ID
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String getParentId(String s) {
|
||||
if (!Strings.isEmpty(s) && s.length() > 4) {
|
||||
return s.substring(0, s.length() - 4);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到n位随机数
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String getRndNumber(int s) {
|
||||
Random ra = new Random();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s; i++) {
|
||||
sb.append(String.valueOf(ra.nextInt(8)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否以字符串开头
|
||||
*
|
||||
* @param str
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public boolean startWith(String str, String s) {
|
||||
return Strings.sNull(str).startsWith(Strings.sNull(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否包含字符串
|
||||
*
|
||||
* @param str
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(String str, String s) {
|
||||
return Strings.sNull(str).contains(Strings.sNull(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串(页面上使用)
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public String toJson(Object obj) {
|
||||
return Json.toJson(obj, JsonFormat.compact());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.budwk.app.base.utils;
|
||||
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Encoding;
|
||||
import org.nutz.mvc.view.UTF8JsonView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author wizzer@qq.com
|
||||
*/
|
||||
public class WebUtil {
|
||||
|
||||
public static String AjaxEncode = Encoding.UTF8;
|
||||
|
||||
public static boolean isAjax(HttpServletRequest req) {
|
||||
String value = req.getHeader("X-Requested-With");
|
||||
return value != null && "XMLHttpRequest".equalsIgnoreCase(value.trim());
|
||||
}
|
||||
|
||||
public static void rendAjaxResp(HttpServletRequest req, HttpServletResponse resp, Object re) {
|
||||
try {
|
||||
if (AjaxEncode != null) {
|
||||
resp.setCharacterEncoding(AjaxEncode);
|
||||
}
|
||||
(new UTF8JsonView(JsonFormat.compact())).render(req, resp, re);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isMiniApp(HttpServletRequest request) {
|
||||
return request.getHeader("X-WK-MiniApp") != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.budwk.app.client.auth.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Client_user;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.satoken.StpClientUtil;
|
||||
import com.budwk.app.web.commons.auth.service.ValidateService;
|
||||
import com.budwk.app.web.commons.slog.SLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* 客户端登录认证
|
||||
*/
|
||||
@IocBean
|
||||
@At("/client/auth")
|
||||
@Slf4j
|
||||
public class ClientAuthController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private SLogService sLogService;
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@Inject
|
||||
private SysMsgService sysMsgService;
|
||||
@Inject
|
||||
private ValidateService validateService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/login.html")
|
||||
@Filters
|
||||
public void login(HttpServletRequest req, HttpSession session) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信登录
|
||||
* @param mobile 手机号
|
||||
* @param code 验证码
|
||||
* @param req 请求
|
||||
*/
|
||||
@At("/doSmsLogin")
|
||||
@Ok("json")
|
||||
public Object doSmsLogin(@Param("mobile") String mobile, @Param("code") String code, HttpServletRequest req) {
|
||||
try {
|
||||
int count = dao.count(Client_user.class, Cnd.where(Client_user::getMobile, "=", mobile));
|
||||
if (count == 0) {
|
||||
return Result.error("手机号不存在");
|
||||
}
|
||||
Client_user user = null;
|
||||
validateService.checkSMSCode(mobile, code);
|
||||
user = dao.fetch(Client_user.class, Cnd.where(Client_user::getMobile, "=", mobile));
|
||||
if (user == null) {
|
||||
return Result.error("用户登录失败");
|
||||
}
|
||||
StpClientUtil.STP.login(user.getId());
|
||||
StpClientUtil.STP.checkLogin();
|
||||
return Result.success("login.success");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.budwk.app.client.module.activity.controller;
|
||||
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.client.module.activity.service.ClientActivityService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.adaptor.JsonAdaptor;
|
||||
import org.nutz.mvc.annotation.AdaptBy;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
@IocBean
|
||||
@At("/client/activity")
|
||||
@Ok("json:full")
|
||||
public class ClientActivityController {
|
||||
|
||||
@Inject
|
||||
private ClientActivityService clientActivityService;
|
||||
|
||||
@At
|
||||
@AdaptBy(type = JsonAdaptor.class)
|
||||
public Result pageData(PageForm pageForm) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t1.id,
|
||||
t1.title,
|
||||
t1.address,
|
||||
t1.startTime,
|
||||
t1.endTime,
|
||||
t1.signStartTime,
|
||||
t1.signEndTime
|
||||
FROM
|
||||
activity t1
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = clientActivityService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.budwk.app.client.module.activity.controller;
|
||||
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
@IocBean
|
||||
@At("/client/home")
|
||||
@Ok("json:full")
|
||||
public class ClientHomeController {
|
||||
|
||||
@At("")
|
||||
@Ok("re")
|
||||
public String index(){
|
||||
return "beetl:/client/home/index.html";
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.budwk.app.client.module.activity.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
|
||||
public interface ClientActivityService extends BaseService<Activity> {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.budwk.app.client.module.activity.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.client.module.activity.service.ClientActivityService;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class ClientActivityServiceImpl extends BaseServiceImpl<Activity> implements ClientActivityService {
|
||||
public ClientActivityServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
package com.budwk.app.module.activity.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.budwk.app.base.page.PageForm;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.models.ActivityItem;
|
||||
import com.budwk.app.module.activity.service.ActivityManageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/activity/manage")
|
||||
@Slf4j
|
||||
@Ok("json:full")
|
||||
public class ActivityManageController {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private ActivityManageService activityService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/activity/manage/index.html")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
public Result pageData(@Param("pageForm") PageForm pageForm) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
Pagination pagination = activityService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存活动
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result save(Activity activity) {
|
||||
// activityService.insertWith(activity, "items");
|
||||
activityService.insert(activity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新活动
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result update(Activity activity) {
|
||||
activityService.updateIgnoreNull(activity);
|
||||
|
||||
|
||||
// // 查询出旧的活动信息
|
||||
// Activity oldActivity = activityService.fetch(activity.getId());
|
||||
// activityService.fetchLinks(oldActivity, "items");
|
||||
//
|
||||
// // 更新活动基础信息
|
||||
// activityService.updateIgnoreNull(activity);
|
||||
//
|
||||
// // 更新项目信息 找出需要新增的 找出需要删除的
|
||||
// List<Long> oldItemIdList = oldActivity.getItems().stream().map(ActivityItem::getId).toList();
|
||||
// dao.insertOrUpdate(activity.getItems());
|
||||
// List<Long> newItemIdList = activity.getItems().stream().map(ActivityItem::getId).toList();
|
||||
//
|
||||
// // 删除旧的项目信息
|
||||
// Collection<Long> deleteItemIdList = CollUtil.subtract(oldItemIdList, newItemIdList);
|
||||
// dao.clear(ActivityItem.class, Cnd.where("id", "in", deleteItemIdList));
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除活动
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result delete(@Param("id") Long id) {
|
||||
// 删除活动信息
|
||||
activityService.delete(id);
|
||||
// 删除项目信息
|
||||
dao.clear(ActivityItem.class, Cnd.where("activityId", "=", id));
|
||||
// 删除报名信息等等。。。。。
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动信息
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result get(@Param("id") Long id) {
|
||||
Activity activity = activityService.fetch(id);
|
||||
return Result.success(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动信息及项目信息
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result getFull(@Param("id") Long id) {
|
||||
Activity activity = activityService.fetch(id);
|
||||
activityService.fetchLinks(activity, "items");
|
||||
return Result.success(activity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目信息
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result getItems(@Param("id") Long id) {
|
||||
List<ActivityItem> items = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", id));
|
||||
return Result.success(items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新活动项目信息
|
||||
*/
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result updateItem(Long id, @Param("items") ActivityItem[] items) {
|
||||
// 查询出旧的活动信息
|
||||
List<ActivityItem> oldItems = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", id));
|
||||
// 更新项目信息
|
||||
List<Long> oldItemIdList = oldItems.stream().map(ActivityItem::getId).toList();
|
||||
// 更新项目信息
|
||||
for (ActivityItem item : items) {
|
||||
item.setActivityId(id);
|
||||
}
|
||||
dao.insertOrUpdate(items);
|
||||
// 找出需要新增的 找出需要删除的
|
||||
List<Long> newItemIdList = Arrays.stream(items).map(ActivityItem::getId).toList();
|
||||
// 删除旧的项目信息
|
||||
Collection<Long> deleteItemIdList = CollUtil.subtract(oldItemIdList, newItemIdList);
|
||||
dao.clear(ActivityItem.class, Cnd.where("id", "in", deleteItemIdList));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.budwk.app.module.activity.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("activity")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("活动")
|
||||
@Data
|
||||
public class Activity extends BaseModel {
|
||||
|
||||
@Id
|
||||
@Comment("ID")
|
||||
private Long id;
|
||||
|
||||
@Comment("标题")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String title;
|
||||
|
||||
@Comment("地点")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String address;
|
||||
|
||||
@Comment("活动开始时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Comment("活动结束时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Comment("报名开始时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private LocalDateTime signStartTime;
|
||||
|
||||
@Comment("报名结束时间")
|
||||
@Column
|
||||
@ColDefine(type = ColType.DATETIME)
|
||||
private LocalDateTime signEndTime;
|
||||
|
||||
@Comment("主办单位")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String hostUnit;
|
||||
|
||||
@Comment("承办单位")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String coHostUnit;
|
||||
|
||||
@Comment("联系人")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String contact;
|
||||
|
||||
@Comment("活动内容")
|
||||
@Column
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String content;
|
||||
|
||||
@Comment("封面")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 500)
|
||||
private String cover;
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
*/
|
||||
@Many(field = "activityId")
|
||||
private List<ActivityItem> items;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.budwk.app.module.activity.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("activity_item")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("活动项目")
|
||||
@Data
|
||||
public class ActivityItem extends BaseModel {
|
||||
|
||||
@Id
|
||||
@Comment("ID")
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
@Comment("活动ID")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Long activityId;
|
||||
|
||||
@Comment("项目名称")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 30)
|
||||
private String name;
|
||||
|
||||
@Comment("活动形式")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 300)
|
||||
private String form;
|
||||
|
||||
@Comment("评分规则")
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 300)
|
||||
private String rule;
|
||||
|
||||
@Comment("排序")
|
||||
@Column
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.budwk.app.module.activity.service;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
|
||||
public interface ActivityManageService extends BaseService<Activity> {
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.budwk.app.module.activity.service.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.service.ActivityManageService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class ActivityManageServiceImpl extends BaseServiceImpl<Activity> implements ActivityManageService {
|
||||
public ActivityManageServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.services.SysApiService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/24.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/api")
|
||||
public class SysApiController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysApiService sysApiService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/api/index.html")
|
||||
@SaCheckPermission("sys.manager.api")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.api.add")
|
||||
@SLog(tag = "新建密钥", msg = "应用名称:${name}")
|
||||
public Object addDo(@Param("name") String name, HttpServletRequest req) {
|
||||
try {
|
||||
sysApiService.createAppkey(name, SecurityUtil.getUserId());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.api.delete")
|
||||
@SLog(tag = "删除密钥", msg = "Appid:${appid}")
|
||||
public Object delete(String appid, HttpServletRequest req) {
|
||||
try {
|
||||
sysApiService.deleteAppkey(appid);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.api.edit")
|
||||
@SLog(tag = "启用密钥", msg = "Appid:${appid}")
|
||||
public Object enable(String appid, HttpServletRequest req) {
|
||||
try {
|
||||
sysApiService.updateAppkey(appid, false);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.api.edit")
|
||||
@SLog(tag = "禁用密钥", msg = "Appid:${appid}")
|
||||
public Object disable(String appid, HttpServletRequest req) {
|
||||
try {
|
||||
sysApiService.updateAppkey(appid, true);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.api")
|
||||
public Object data(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysApiService.listPage(pageNumber, pageSize, cnd));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.models.Sys_config;
|
||||
import com.budwk.app.sys.services.SysConfigService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.integration.jedis.pubsub.PubSubService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/28.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/conf")
|
||||
public class SysConfController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysConfigService sysConfigService;
|
||||
@Inject
|
||||
private PubSubService pubSubService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/conf/index.html")
|
||||
@SaCheckPermission("sys.manager.conf")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.conf.add")
|
||||
@SLog(tag = "添加参数", msg = "${conf.configKey}:${conf.configValue}")
|
||||
public Object addDo(@Param("..") Sys_config conf) {
|
||||
try {
|
||||
conf.setCreatedBy(SecurityUtil.getUserId());
|
||||
if (sysConfigService.insert(conf) != null) {
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_config");
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.conf")
|
||||
public Object edit(String id) {
|
||||
try {
|
||||
return Result.success().addData(sysConfigService.fetch(id));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.conf.edit")
|
||||
@SLog(tag = "修改参数", msg = "${conf.configKey}:${conf.configValue}")
|
||||
public Object editDo(@Param("..") Sys_config conf) {
|
||||
try {
|
||||
conf.setUpdatedBy(SecurityUtil.getUserId());
|
||||
if (sysConfigService.updateIgnoreNull(conf) > 0) {
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_config");
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.conf.delete")
|
||||
@SLog(tag = "删除参数", msg = "参数:${configKey}")
|
||||
public Object delete(String configKey) {
|
||||
try {
|
||||
if (Strings.sBlank(configKey).startsWith("App")) {
|
||||
return Result.error("系统参数不可删除");
|
||||
}
|
||||
if (sysConfigService.delete(configKey) > 0) {
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_config");
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.conf")
|
||||
public Object data(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysConfigService.listPage(pageNumber, pageSize, cnd));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_dict;
|
||||
import com.budwk.app.sys.services.SysDictService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/24.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/dict")
|
||||
public class SysDictController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysDictService sysDictService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/dict/index.html")
|
||||
@SaCheckPermission("sys.manager.dict")
|
||||
public Object index() {
|
||||
return sysDictService.query(Cnd.where("parentId", "=", "").or("parentId", "is", null).asc("location").asc("path"));
|
||||
}
|
||||
|
||||
|
||||
@At("/child")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object child(@Param("pid") String pid, HttpServletRequest req) {
|
||||
List<Sys_dict> list = new ArrayList<>();
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysDictService.query(cnd);
|
||||
for (Sys_dict sysDict : list) {
|
||||
if (sysDictService.count(Cnd.where("parentId", "=", sysDict.getId())) > 0) {
|
||||
sysDict.setHasChildren(true);
|
||||
}
|
||||
NutMap map = Lang.obj2nutmap(sysDict);
|
||||
map.addv("expanded", false);
|
||||
map.addv("children", new ArrayList<>());
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
}
|
||||
|
||||
@At("/tree")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object tree(@Param("pid") String pid, HttpServletRequest req) {
|
||||
try {
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
if (Strings.isBlank(pid)) {
|
||||
NutMap root = NutMap.NEW().addv("value", "root").addv("label", "不选择菜单").addv("leaf", true);
|
||||
treeList.add(root);
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
List<Sys_dict> list = sysDictService.query(cnd);
|
||||
for (Sys_dict sysDict : list) {
|
||||
NutMap map = NutMap.NEW().addv("value", sysDict.getId()).addv("label", sysDict.getName());
|
||||
if (sysDict.isHasChildren()) {
|
||||
map.addv("children", new ArrayList<>());
|
||||
map.addv("leaf", false);
|
||||
} else {
|
||||
map.addv("leaf", true);
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.add")
|
||||
@SLog(tag = "新建字典", msg = "字典名称:${args[0].name}")
|
||||
public Object addDo(@Param("..") Sys_dict dict, @Param(value = "parentId", df = "") String parentId, HttpServletRequest req) {
|
||||
try {
|
||||
if ("root".equals(parentId)) {
|
||||
parentId = "";
|
||||
}
|
||||
dict.setHasChildren(false);
|
||||
dict.setCreatedBy(SecurityUtil.getUserId());
|
||||
sysDictService.save(dict, parentId);
|
||||
sysDictService.clearCache();
|
||||
return Result.success("system.success");
|
||||
} catch (Exception e) {
|
||||
return Result.error("system.error");
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict")
|
||||
public Object edit(String id, HttpServletRequest req) {
|
||||
try {
|
||||
return Result.success().addData(sysDictService.fetch(id));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.edit")
|
||||
@SLog(tag = "编辑字典", msg = "字典名称:${args[0].name}")
|
||||
public Object editDo(@Param("..") Sys_dict dict, @Param("parentId") String parentId, HttpServletRequest req) {
|
||||
try {
|
||||
dict.setUpdatedBy(SecurityUtil.getUserId());
|
||||
sysDictService.updateIgnoreNull(dict);
|
||||
sysDictService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.delete")
|
||||
@SLog(tag = "删除字典", msg = "字典名称:${args[1].getAttribute('name')}")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_dict dict = sysDictService.fetch(id);
|
||||
req.setAttribute("name", dict.getName());
|
||||
sysDictService.deleteAndChild(dict);
|
||||
sysDictService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.edit")
|
||||
@SLog(tag = "启用菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object enable(String menuId, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("name", sysDictService.fetch(menuId).getName());
|
||||
sysDictService.update(org.nutz.dao.Chain.make("disabled", false), Cnd.where("id", "=", menuId));
|
||||
sysDictService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.edit")
|
||||
@SLog(tag = "禁用菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object disable(String menuId, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("name", sysDictService.fetch(menuId).getName());
|
||||
sysDictService.update(org.nutz.dao.Chain.make("disabled", true), Cnd.where("id", "=", menuId));
|
||||
sysDictService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/menuAll")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict")
|
||||
public Object menuAll(HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_dict> list = sysDictService.query(Cnd.NEW().asc("location").asc("path"));
|
||||
NutMap menuMap = NutMap.NEW();
|
||||
for (Sys_dict unit : list) {
|
||||
List<Sys_dict> list1 = menuMap.getList(unit.getParentId(), Sys_dict.class);
|
||||
if (list1 == null) {
|
||||
list1 = new ArrayList<>();
|
||||
}
|
||||
list1.add(unit);
|
||||
menuMap.put(unit.getParentId(), list1);
|
||||
}
|
||||
return Result.success().addData(getTree(menuMap, ""));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
private List<NutMap> getTree(NutMap menuMap, String pid) {
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
List<Sys_dict> subList = menuMap.getList(pid, Sys_dict.class);
|
||||
for (Sys_dict menu : subList) {
|
||||
NutMap map = Lang.obj2nutmap(menu);
|
||||
map.put("label", menu.getName());
|
||||
if (menu.isHasChildren() || (menuMap.get(menu.getId()) != null)) {
|
||||
map.put("children", getTree(menuMap, menu.getId()));
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return treeList;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.dict.edit")
|
||||
public Object sortDo(@Param("ids") String ids, HttpServletRequest req) {
|
||||
try {
|
||||
String[] menuIds = StringUtils.split(ids, ",");
|
||||
int i = 0;
|
||||
sysDictService.execute(Sqls.create("update sys_dict set location=0"));
|
||||
for (String s : menuIds) {
|
||||
if (!Strings.isBlank(s)) {
|
||||
sysDictService.update(org.nutz.dao.Chain.make("location", i), Cnd.where("id", "=", s));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
sysDictService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result dictOptions(String code) {
|
||||
return Result.success(sysDictService.getSubListByCode(code));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/23.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/home")
|
||||
public class SysHomeController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@At("")
|
||||
@Ok("re")
|
||||
@SaCheckLogin
|
||||
public String home(HttpSession session, HttpServletRequest req) {
|
||||
// if (StpUtil.hasRole("sysadmin")) {
|
||||
// return "beetl:/platform/sys/dashboard.html";
|
||||
// }
|
||||
return "beetl:/platform/sys/home.html";
|
||||
}
|
||||
|
||||
@At("/403")
|
||||
@Ok("re")
|
||||
public Object error403(HttpServletRequest req) {
|
||||
StpUtil.checkLogin();
|
||||
if (Strings.sNull(req.getAttribute("original_request_uri")).startsWith("/platform")) {
|
||||
return "beetl:/platform/sys/403.html";
|
||||
} else {
|
||||
return ">>:/error/404.html";
|
||||
}
|
||||
}
|
||||
|
||||
@At("/404")
|
||||
@Ok("re")
|
||||
public Object error404(HttpServletRequest req) {
|
||||
StpUtil.checkLogin();
|
||||
if (Strings.sNull(req.getAttribute("original_request_uri")).startsWith("/platform")) {
|
||||
return "beetl:/platform/sys/404.html";
|
||||
} else {
|
||||
return ">>:/error/404.html";
|
||||
}
|
||||
}
|
||||
|
||||
@At("/500")
|
||||
@Ok("re")
|
||||
public Object error500(HttpServletRequest req) {
|
||||
StpUtil.checkLogin();
|
||||
if (Strings.sNull(req.getAttribute("original_request_uri")).startsWith("/platform")) {
|
||||
return "beetl:/platform/sys/500.html";
|
||||
} else {
|
||||
return ">>:/error/500.html";
|
||||
}
|
||||
}
|
||||
|
||||
@At(value = {"/", "/index"}, top = true)
|
||||
@Ok(">>:/sysadmin")
|
||||
public void index() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.DateUtil;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.services.SysLogService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/29.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/log")
|
||||
public class SysLogController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/log/index.html")
|
||||
@SaCheckPermission("sys.manager.log")
|
||||
public void index(HttpServletRequest req) {
|
||||
req.setAttribute("today", DateUtil.getDate());
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.log")
|
||||
public Object data(@Param("searchDate") String searchDate, @Param("searchType") String searchType, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
String[] date = StringUtils.split(searchDate, ",");
|
||||
return Result.success().addData(sysLogService.data(date, searchType, pageOrderName, PageUtil.getOrder(pageOrderBy), pageNumber, pageSize));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import com.budwk.app.sys.models.Sys_role;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUnitService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.service.ValidateService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import com.budwk.app.web.commons.slog.SLogService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Filters;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/22.
|
||||
*/
|
||||
@IocBean // 声明为Ioc容器中的一个Bean
|
||||
@At("/platform/login") // 整个模块的路径前缀
|
||||
@Ok("json:{locked:'password|createAt',ignoreNull:true}") // 忽略password和createAt属性,忽略空属性的json输出
|
||||
public class SysLoginController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
@Inject
|
||||
private SysUnitService sysUnitService;
|
||||
@Inject
|
||||
private SLogService sLogService;
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@Inject
|
||||
private SysMsgService sysMsgService;
|
||||
@Inject
|
||||
private ValidateService validateService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/login.html")
|
||||
@Filters
|
||||
public void login(HttpServletRequest req, HttpSession session) {
|
||||
|
||||
}
|
||||
|
||||
@At("/noPermission")
|
||||
@Ok("beetl:/platform/sys/noPermission.html")
|
||||
@Filters
|
||||
public void noPermission() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@At("/doLogin")
|
||||
@Ok("json")
|
||||
public Object doLogin(@Param("username") String username,
|
||||
@Param("password") String password,
|
||||
@Param("platformKey") String captchaKey,
|
||||
@Param("platformCaptcha") String captchaCode,
|
||||
HttpServletRequest req, HttpSession session) {
|
||||
try {
|
||||
Sys_user user = null;
|
||||
sysUserService.checkLoginname(username);
|
||||
validateService.checkCode(captchaKey, captchaCode);
|
||||
user = sysUserService.loginByPassword(username, password);
|
||||
if (user == null) {
|
||||
throw new BaseException("用户登录失败");
|
||||
}
|
||||
StpUtil.login(user.getId());
|
||||
StpUtil.checkLogin();
|
||||
StpUtil.getSession(true).set("loginname", Strings.sNull(user.getLoginname()))
|
||||
.set("username", Strings.sNull(user.getUsername()))
|
||||
.set("unitId", Strings.sNull(user.getUnitId()))
|
||||
.set("unitPath", Strings.sNull(user.getUnitPath()));
|
||||
sysUserService.setLoginInfo(user.getId(), Lang.getIP(req));
|
||||
Sys_log sysLog = new Sys_log();
|
||||
sysLog.setType("info");
|
||||
sysLog.setTag("用户登陆");
|
||||
sysLog.setSrc(this.getClass().getName() + "#doLogin");
|
||||
sysLog.setMsg("成功登录系统!");
|
||||
sysLog.setIp(Lang.getIP(req));
|
||||
sysLog.setCreatedBy(user.getId());
|
||||
sysLog.setUsername(user.getUsername());
|
||||
sysLog.setLoginname(user.getLoginname());
|
||||
sLogService.async(sysLog);
|
||||
return Result.success("login.success");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At("/doSmsLogin")
|
||||
@Ok("json")
|
||||
public Object doSmsLogin(@Param("mobile") String mobile, @Param("code") String code, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_user user = null;
|
||||
sysUserService.checkMobile(mobile);
|
||||
validateService.checkSMSCode(mobile, code);
|
||||
user = sysUserService.loginByMobile(mobile);
|
||||
if (user == null) {
|
||||
throw new BaseException("用户登录失败");
|
||||
}
|
||||
StpUtil.login(user.getId());
|
||||
StpUtil.checkLogin();
|
||||
StpUtil.getSession(true).set("loginname", Strings.sNull(user.getLoginname()))
|
||||
.set("username", Strings.sNull(user.getUsername()))
|
||||
.set("unitId", Strings.sNull(user.getUnitId()))
|
||||
.set("unitPath", Strings.sNull(user.getUnitPath()));
|
||||
sysUserService.setLoginInfo(user.getId(), Lang.getIP(req));
|
||||
Sys_log sysLog = new Sys_log();
|
||||
sysLog.setType("info");
|
||||
sysLog.setTag("用户登陆");
|
||||
sysLog.setSrc(this.getClass().getName() + "#doLogin");
|
||||
sysLog.setMsg("成功登录系统!");
|
||||
sysLog.setIp(Lang.getIP(req));
|
||||
sysLog.setCreatedBy(user.getId());
|
||||
sysLog.setUsername(user.getUsername());
|
||||
sysLog.setLoginname(user.getLoginname());
|
||||
sLogService.async(sysLog);
|
||||
return Result.success("login.success");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退出系统
|
||||
*/
|
||||
@At
|
||||
@Ok(">>:/platform/login")
|
||||
public void logout(HttpSession session, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
StpUtil.logout();
|
||||
if (user != null) {
|
||||
Sys_log sysLog = new Sys_log();
|
||||
sysLog.setType("info");
|
||||
sysLog.setTag("用户登出");
|
||||
sysLog.setSrc(this.getClass().getName() + "#logout");
|
||||
sysLog.setMsg("成功退出系统!");
|
||||
sysLog.setIp(Lang.getIP(req));
|
||||
sysLog.setCreatedBy(user.getId());
|
||||
sysLog.setUsername(user.getUsername());
|
||||
sysLog.setLoginname(user.getLoginname());
|
||||
sLogService.async(sysLog);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("Logout error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@At("/captcha")
|
||||
@Ok("json")
|
||||
public Object next() {
|
||||
return Result.success(validateService.getCaptcha());
|
||||
}
|
||||
|
||||
@At("/sendSmsCode")
|
||||
@Ok("json")
|
||||
public Object sendSmsCode(@Param("mobile") String mobile) {
|
||||
try {
|
||||
validateService.getSmsCode(mobile);
|
||||
return Result.success(NutMap.NEW().addv("key", RedisConstant.UCENTER_SMSCODE + mobile)).addMsg("发送成功");
|
||||
} catch (BaseException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At("/doReg")
|
||||
@Ok("json")
|
||||
public Object doReg(@Param("mobile") String mobile, @Param("password") String password, @Param("code") String code, HttpServletRequest req) {
|
||||
try {
|
||||
int count = sysUserService.count(Cnd.where("loginname", "=", Strings.trim(mobile)));
|
||||
if (count > 0) {
|
||||
return Result.error("手机号已存在");
|
||||
}
|
||||
validateService.checkSMSCode(mobile, code);
|
||||
Sys_user user = new Sys_user();
|
||||
user.setLoginname(mobile);
|
||||
user.setUsername(mobile);
|
||||
user.setMobile(mobile);
|
||||
String salt = R.UU32();
|
||||
user.setSalt(salt);
|
||||
user.setPassword(PwdUtil.getPassword(password, salt));
|
||||
user.setLoginCount(0);
|
||||
user.setCreatedBy(SecurityUtil.getUserId());
|
||||
Sys_unit unit = sysUnitService.fetch(Cnd.where("unitcode", "=", Globals.MyConfig.getString("AppDefaultUserUnit")));
|
||||
if (unit != null) {
|
||||
user.setUnitId(unit.getId());
|
||||
user.setUnitPath(unit.getPath());
|
||||
}
|
||||
Sys_role role = sysRoleService.fetch(Cnd.where("code", "=", Globals.MyConfig.getString("AppDefaultUserRole")));
|
||||
sysUserService.insert(user);
|
||||
if (role != null)
|
||||
sysRoleService.insert("sys_user_role", Chain.make("roleId", role.getId()).add("userId", user.getId()));
|
||||
sysUserService.clearCache();
|
||||
return Result.success();
|
||||
} catch (BaseException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/28.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/menu")
|
||||
public class SysMenuController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/menu/index.html")
|
||||
@SaCheckPermission("sys.manager.menu")
|
||||
public void index(HttpServletRequest req) {
|
||||
}
|
||||
|
||||
@At("/child")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object child(@Param("pid") String pid, HttpServletRequest req) {
|
||||
List<Sys_menu> list = new ArrayList<>();
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and(Cnd.exps("parentId", "=", "").or("parentId", "is", null));
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysMenuService.query(cnd);
|
||||
for (Sys_menu menu : list) {
|
||||
if (sysMenuService.count(Cnd.where("parentId", "=", menu.getId())) > 0) {
|
||||
menu.setHasChildren(true);
|
||||
}
|
||||
NutMap map = Lang.obj2nutmap(menu);
|
||||
map.addv("expanded", false);
|
||||
map.addv("children", new ArrayList<>());
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
}
|
||||
|
||||
@At("/tree")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object tree(@Param("pid") String pid, HttpServletRequest req) {
|
||||
try {
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
if (Strings.isBlank(pid)) {
|
||||
NutMap root = NutMap.NEW().addv("value", "root").addv("label", "不选择菜单").addv("leaf", true);
|
||||
treeList.add(root);
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and(Cnd.exps("parentId", "=", "").or("parentId", "is", null));
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.and("type", "=", "menu");
|
||||
cnd.asc("location").asc("path");
|
||||
List<Sys_menu> list = sysMenuService.query(cnd);
|
||||
for (Sys_menu menu : list) {
|
||||
NutMap map = NutMap.NEW().addv("value", menu.getId()).addv("label", menu.getName());
|
||||
if (menu.isHasChildren()) {
|
||||
map.addv("children", new ArrayList<>());
|
||||
map.addv("leaf", false);
|
||||
} else {
|
||||
map.addv("leaf", true);
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.add")
|
||||
@SLog(tag = "新建菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object addDo(@Param("..") NutMap nutMap, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_menu sysMenu = nutMap.getAs("menu", Sys_menu.class);
|
||||
List<NutMap> buttons = Json.fromJsonAsList(NutMap.class, nutMap.getString("buttons"));
|
||||
int num = sysMenuService.count(Cnd.where("permission", "=", sysMenu.getPermission().trim()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
for (NutMap map : buttons) {
|
||||
num = sysMenuService.count(Cnd.where("permission", "=", map.getString("permission", "").trim()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
}
|
||||
String parentId = sysMenu.getParentId();
|
||||
if ("root".equals(sysMenu.getParentId())) {
|
||||
parentId = "";
|
||||
}
|
||||
sysMenu.setHasChildren(false);
|
||||
sysMenu.setShowit(true);
|
||||
sysMenu.setCreatedBy(SecurityUtil.getUserId());
|
||||
sysMenuService.save(sysMenu, Strings.sNull(parentId), buttons);
|
||||
req.setAttribute("name", sysMenu.getName());
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
//编辑菜单,组装一下js表单数据
|
||||
@At("/editMenu/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu")
|
||||
public Object editMenu(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_menu menu = sysMenuService.fetch(id);
|
||||
NutMap map = Lang.obj2nutmap(menu);
|
||||
map.put("parentName", "无");
|
||||
map.put("children", "false");
|
||||
if (Strings.isNotBlank(menu.getParentId())) {
|
||||
map.put("parentName", sysMenuService.fetch(menu.getParentId()).getName());
|
||||
}
|
||||
List<Sys_menu> list = sysMenuService.query(Cnd.where("parentId", "=", id).and("type", "=", "data").asc("location").asc("path"));
|
||||
List<NutMap> buttons = new ArrayList<>();
|
||||
if (list != null && list.size() > 0) {
|
||||
map.put("children", "true");
|
||||
for (Sys_menu m : list) {
|
||||
buttons.add(NutMap.NEW().addv("key", m.getId()).addv("name", m.getName()).addv("permission", m.getPermission()));
|
||||
}
|
||||
}
|
||||
map.put("buttons", buttons);
|
||||
return Result.success().addData(map);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.edit")
|
||||
@SLog(tag = "修改菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object editMenuDo(@Param("..") NutMap nutMap, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_menu sysMenu = nutMap.getAs("menu", Sys_menu.class);
|
||||
List<NutMap> buttons = Json.fromJsonAsList(NutMap.class, nutMap.getString("buttons"));
|
||||
//如果权限标识不是自己的,并且被其他记录占用
|
||||
int num = sysMenuService.count(Cnd.where("permission", "=", sysMenu.getPermission().trim()).and("id", "<>", sysMenu.getId()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
for (NutMap map : buttons) {
|
||||
num = sysMenuService.count(Cnd.where("permission", "=", map.getString("permission", "").trim()).and("id", "<>", map.getString("key", "")));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
}
|
||||
sysMenu.setHasChildren(false);
|
||||
sysMenu.setShowit(true);
|
||||
sysMenu.setUpdatedBy(SecurityUtil.getUserId());
|
||||
sysMenuService.edit(sysMenu, sysMenu.getParentId(), buttons);
|
||||
req.setAttribute("name", sysMenu.getName());
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/editData/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu")
|
||||
public Object editData(String id, HttpServletRequest req) {
|
||||
try {
|
||||
return Result.success().addData(sysMenuService.fetch(id));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.edit")
|
||||
@SLog(tag = "修改权限", msg = "权限名称:${args[0].name}")
|
||||
public Object editDataDo(@Param("..") Sys_menu menu, HttpServletRequest req) {
|
||||
try {
|
||||
int num = sysMenuService.count(Cnd.where("permission", "=", menu.getPermission().trim()).and("id", "<>", menu.getId()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
sysMenuService.updateIgnoreNull(menu);
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.delete")
|
||||
@SLog(tag = "删除菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_menu menu = sysMenuService.fetch(id);
|
||||
req.setAttribute("name", menu.getName());
|
||||
if (menu.getPath().startsWith("0001")) {
|
||||
return Result.error("system.not.allow");
|
||||
}
|
||||
sysMenuService.deleteAndChild(menu);
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.edit")
|
||||
@SLog(tag = "启用菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object enable(String menuId, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("name", sysMenuService.fetch(menuId).getName());
|
||||
sysMenuService.update(org.nutz.dao.Chain.make("disabled", false), Cnd.where("id", "=", menuId));
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.edit")
|
||||
@SLog(tag = "禁用菜单", msg = "菜单名称:${args[1].getAttribute('name')}")
|
||||
public Object disable(String menuId, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("name", sysMenuService.fetch(menuId).getName());
|
||||
sysMenuService.update(org.nutz.dao.Chain.make("disabled", true), Cnd.where("id", "=", menuId));
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/menuAll")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu")
|
||||
public Object menuAll(HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_menu> list = sysMenuService.query(Cnd.where("type", "=", "menu").asc("location").asc("path"));
|
||||
NutMap menuMap = NutMap.NEW();
|
||||
for (Sys_menu unit : list) {
|
||||
List<Sys_menu> list1 = menuMap.getList(unit.getParentId(), Sys_menu.class);
|
||||
if (list1 == null) {
|
||||
list1 = new ArrayList<>();
|
||||
}
|
||||
list1.add(unit);
|
||||
menuMap.put(unit.getParentId(), list1);
|
||||
}
|
||||
return Result.success().addData(getTree(menuMap, ""));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
private List<NutMap> getTree(NutMap menuMap, String pid) {
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
List<Sys_menu> subList = menuMap.getList(pid, Sys_menu.class);
|
||||
for (Sys_menu menu : subList) {
|
||||
NutMap map = Lang.obj2nutmap(menu);
|
||||
map.put("label", menu.getName());
|
||||
if (menu.isHasChildren() || (menuMap.get(menu.getId()) != null)) {
|
||||
map.put("children", getTree(menuMap, menu.getId()));
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return treeList;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.menu.edit")
|
||||
public Object sortDo(@Param("ids") String ids, HttpServletRequest req) {
|
||||
try {
|
||||
String[] menuIds = StringUtils.split(ids, ",");
|
||||
int i = 0;
|
||||
sysMenuService.execute(Sqls.create("update sys_menu set location=0"));
|
||||
for (String s : menuIds) {
|
||||
if (!Strings.isBlank(s)) {
|
||||
sysMenuService.update(org.nutz.dao.Chain.make("location", i), Cnd.where("id", "=", s));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.models.Sys_msg;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysMsgUserService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/sys/msg")
|
||||
public class SysMsgController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysMsgService sysMsgService;
|
||||
@Inject
|
||||
private SysMsgUserService sysMsgUserService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@At({"/", "/list/?"})
|
||||
@Ok("beetl:/platform/sys/msg/index.html")
|
||||
@SaCheckPermission("sys.manager.msg")
|
||||
public void index(String type, HttpServletRequest req) {
|
||||
req.setAttribute("type", Strings.isBlank(type) ? "all" : type);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.msg")
|
||||
public Object data(@Param("searchType") String searchType, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(searchType) && !"all".equals(searchType)) {
|
||||
cnd.and("type", "=", searchType);
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
List<Map> mapList = new ArrayList<>();
|
||||
Pagination pagination = sysMsgService.listPage(pageNumber, pageSize, cnd);
|
||||
for (Object msg : pagination.getList()) {
|
||||
NutMap map = Lang.obj2nutmap(msg);
|
||||
map.put("all_num", sysMsgUserService.count(Cnd.where("msgId", "=", map.get("id", ""))));
|
||||
map.put("unread_num", sysMsgUserService.count(Cnd.where("msgId", "=", map.get("id", "")).and("status", "=", 0)));
|
||||
mapList.add(map);
|
||||
}
|
||||
pagination.setList(mapList);
|
||||
return Result.success().addData(pagination);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.msg")
|
||||
public Object user_view_data(@Param("type") String type, @Param("id") String id, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
String sql = "SELECT a.loginname,a.username,a.mobile,a.email,a.disabled,a.unitid,b.name as unitname,c.status,c.readat FROM sys_user a,sys_unit b,sys_msg_user c WHERE a.unitid=b.id \n" +
|
||||
"and a.loginname=c.loginname and c.msgId='" + id + "' ";
|
||||
if (Strings.isNotBlank(type) && "unread".equals(type)) {
|
||||
sql += " and c.status=0 ";
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
sql += " order by a." + pageOrderName + " " + PageUtil.getOrder(pageOrderBy);
|
||||
}
|
||||
return Result.success().addData(sysMsgService.listPage(pageNumber, pageSize, Sqls.create(sql)));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/addDo")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.msg.add")
|
||||
@SLog(tag = "站内消息", msg = "${args[0].title}")
|
||||
public Object addDo(@Param("..") NutMap nutMap, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_msg sysMsg = nutMap.getAs("msg", Sys_msg.class);
|
||||
sysMsg.setNote(nutMap.getString("note", ""));
|
||||
sysMsg.setSendAt(Times.getTS());
|
||||
sysMsg.setCreatedBy(SecurityUtil.getUserId());
|
||||
String[] users = StringUtils.split(nutMap.getString("users", ""), ",");
|
||||
sysMsgService.saveMsg(sysMsg, users);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:{locked:'password|salt',ignoreNull:false}")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public Object user_data(@Param("searchUnit") String searchUnit, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysUserService.listPageLinks(pageNumber, pageSize, cnd, "unit"));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At({"/delete/?"})
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.msg.delete")
|
||||
@SLog(tag = "站内消息", msg = "站内信标题:${req.getAttribute('title')}")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("title", sysMsgService.fetch(id).getTitle());
|
||||
sysMsgService.deleteMsg(id);
|
||||
sysMsgUserService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysMsgUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/sys/msg/user")
|
||||
public class SysMsgUserController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysMsgUserService sysMsgUserService;
|
||||
@Inject
|
||||
private SysMsgService sysMsgService;
|
||||
|
||||
@At("/all")
|
||||
@Ok("beetl:/platform/sys/msg/user/indexAll.html")
|
||||
@SaCheckPermission("sys.msg.all")
|
||||
public void index(@Param("type") String type, HttpServletRequest req) {
|
||||
req.setAttribute("type", Strings.isBlank(type) ? "all" : type);
|
||||
}
|
||||
|
||||
@At("/read")
|
||||
@Ok("beetl:/platform/sys/msg/user/indexRead.html")
|
||||
@SaCheckPermission("sys.msg.read")
|
||||
public void read(@Param("type") String type, HttpServletRequest req) {
|
||||
req.setAttribute("type", Strings.isBlank(type) ? "all" : type);
|
||||
|
||||
}
|
||||
|
||||
@At("/unread")
|
||||
@Ok("beetl:/platform/sys/msg/user/indexUnread.html")
|
||||
@SaCheckPermission("sys.msg.unread")
|
||||
public void unread(@Param("type") String type, HttpServletRequest req) {
|
||||
req.setAttribute("type", Strings.isBlank(type) ? "all" : type);
|
||||
}
|
||||
|
||||
@At("/data/?")
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
public Object data(String status, @Param("searchType") String type, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(status) && "read".equals(status)) {
|
||||
cnd.and("a.status", "=", 1);
|
||||
}
|
||||
if (Strings.isNotBlank(status) && "unread".equals(status)) {
|
||||
cnd.and("a.status", "=", 0);
|
||||
}
|
||||
cnd.and("a.loginname", "=", SecurityUtil.getUserLoginname());
|
||||
cnd.and("a.delFlag", "=", false);
|
||||
cnd.desc("a.createdAt");
|
||||
if (Strings.isNotBlank(type) && !"all".equals(type)) {
|
||||
cnd.and("b.type", "=", type);
|
||||
}
|
||||
Sql sql = Sqls.create("SELECT b.type,b.title,b.sendat,a.* FROM sys_msg b LEFT JOIN sys_msg_user a ON b.id=a.msgid $condition");
|
||||
sql.setCondition(cnd);
|
||||
Sql sqlCount = Sqls.create("SELECT count(*) FROM sys_msg b LEFT JOIN sys_msg_user a ON b.id=a.msgid $condition");
|
||||
sqlCount.setCondition(cnd);
|
||||
return Result.success().addData(sysMsgService.listPage(pageNumber, pageSize, sql, sqlCount));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At({"/delete/?", "/delete"})
|
||||
@Ok("json")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
@SLog(tag = "站内消息", msg = "${req.getAttribute('id')}")
|
||||
public Object delete(String id, @Param("ids") String[] ids, HttpServletRequest req) {
|
||||
try {
|
||||
if (ids != null && ids.length > 0) {
|
||||
sysMsgUserService.update(Chain.make("delFlag", true)
|
||||
.add("updatedAt", System.currentTimeMillis())
|
||||
.add("updatedBy", SecurityUtil.getUserId()), Cnd.where("id", "in", ids).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
req.setAttribute("id", Arrays.toString(ids));
|
||||
} else {
|
||||
sysMsgUserService.update(Chain.make("delFlag", true)
|
||||
.add("updatedAt", System.currentTimeMillis())
|
||||
.add("updatedBy", SecurityUtil.getUserId()), Cnd.where("id", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
req.setAttribute("id", id);
|
||||
}
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object unread_num() {
|
||||
try {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.put("system", sysMsgUserService.count(Sqls.create("SELECT count(*) from sys_msg a,sys_msg_user b WHERE a.id=b.msgId AND a.type='system' AND a.delFlag=false AND b.status=0 AND b.delFlag=false AND b.loginname=@loginname").setParam("loginname", SecurityUtil.getUserLoginname())));
|
||||
nutMap.put("user", sysMsgUserService.count(Sqls.create("SELECT count(*) from sys_msg a,sys_msg_user b WHERE a.id=b.msgId AND a.type='user' AND a.delFlag=false AND b.status=0 AND b.delFlag=false AND b.loginname=@loginname").setParam("loginname", SecurityUtil.getUserLoginname())));
|
||||
return Result.success().addData(nutMap);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/status/read")
|
||||
@Ok("json")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
@SLog(tag = "站内消息", msg = "${req.getAttribute('id')}")
|
||||
public Object read(@Param("ids") String[] ids, HttpServletRequest req) {
|
||||
try {
|
||||
sysMsgUserService.update(Chain.make("status", 1).add("readAt", Times.getTS())
|
||||
.add("createdAt", System.currentTimeMillis())
|
||||
.add("createdBy", SecurityUtil.getUserId()), Cnd.where("id", "in", ids).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
req.setAttribute("id", Arrays.toString(ids));
|
||||
return Result.success("system.success");
|
||||
} catch (Exception e) {
|
||||
return Result.error("system.error");
|
||||
}
|
||||
}
|
||||
|
||||
@At("/status/readAll")
|
||||
@Ok("json")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
@SLog(tag = "站内消息", msg = "readAll")
|
||||
public Object readAll(HttpServletRequest req) {
|
||||
try {
|
||||
sysMsgUserService.update(Chain.make("status", 1).add("readAt", Times.getTS())
|
||||
.add("createdAt", System.currentTimeMillis()).add("createdBy", SecurityUtil.getUserId()), Cnd.where("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/all/detail/?")
|
||||
@Ok("beetl:/platform/sys/msg/user/detailAll.html")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
public void allDetail(String id, HttpServletRequest req) {
|
||||
if (!Strings.isBlank(id)) {
|
||||
//判断用户是否是正常获取消息
|
||||
int num = sysMsgUserService.count(Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
if (num > 0) {
|
||||
req.setAttribute("obj", sysMsgService.fetch(id));
|
||||
sysMsgUserService.update(Chain.make("status", 1), Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
}
|
||||
|
||||
@At("/read/detail/?")
|
||||
@Ok("beetl:/platform/sys/msg/user/detailRead.html")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
public void readDetail(String id, HttpServletRequest req) {
|
||||
if (!Strings.isBlank(id)) {
|
||||
//判断用户是否是正常获取消息
|
||||
int num = sysMsgUserService.count(Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
if (num > 0) {
|
||||
req.setAttribute("obj", sysMsgService.fetch(id));
|
||||
sysMsgUserService.update(Chain.make("status", 1), Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
}
|
||||
|
||||
@At("/unread/detail/?")
|
||||
@Ok("beetl:/platform/sys/msg/user/detailUnread.html")
|
||||
@SaCheckPermission(value = {"sys.msg.all", "sys.msg.read", "sys.msg.unread"}, mode = SaMode.OR)
|
||||
public void unreadDetail(String id, HttpServletRequest req) {
|
||||
if (!Strings.isBlank(id)) {
|
||||
//判断用户是否是正常获取消息
|
||||
int num = sysMsgUserService.count(Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
if (num > 0) {
|
||||
req.setAttribute("obj", sysMsgService.fetch(id));
|
||||
sysMsgUserService.update(Chain.make("status", 1), Cnd.where("msgid", "=", id).and("loginname", "=", SecurityUtil.getUserLoginname()));
|
||||
sysMsgUserService.deleteCache(SecurityUtil.getUserLoginname());
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
} else {
|
||||
req.setAttribute("obj", null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.models.Sys_role;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUnitService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/28.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/role")
|
||||
public class SysRoleController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysUnitService sysUnitService;
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/role/index.html")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At("/tree")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object tree(@Param("pid") String pid, HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_unit> list = new ArrayList<>();
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
if (Strings.isBlank(pid)) {
|
||||
NutMap root = NutMap.NEW().addv("value", "root").addv("label", "不选择单位");
|
||||
treeList.add(root);
|
||||
|
||||
}
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
if (Strings.isBlank(pid)) {
|
||||
NutMap sys = NutMap.NEW().addv("value", "system").addv("label", "系统角色");
|
||||
treeList.add(sys);
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (user != null && Strings.isBlank(pid)) {
|
||||
list = sysUnitService.query(Cnd.where("id", "=", user.getUnitId()).asc("path"));
|
||||
} else {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
}
|
||||
}
|
||||
for (Sys_unit unit : list) {
|
||||
NutMap map = NutMap.NEW().addv("value", unit.getId()).addv("label", unit.getName());
|
||||
if (unit.isHasChildren()) {
|
||||
map.addv("children", new ArrayList<>());
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object data(@Param("searchUnit") String searchUnit, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
if ("system".equals(searchUnit)) {
|
||||
cnd.and("unitid", "=", "");
|
||||
} else if (Strings.isNotBlank(searchUnit)) {
|
||||
cnd.and("unitid", "=", searchUnit);
|
||||
}
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (Strings.isNotBlank(searchUnit)) {
|
||||
Sys_unit unit = sysUnitService.fetch(searchUnit);
|
||||
if (unit == null || !unit.getPath().startsWith(user.getUnit().getPath())) {
|
||||
//防止有人越级访问
|
||||
return Result.error("非法操作");
|
||||
} else
|
||||
cnd.and("unitid", "=", searchUnit);
|
||||
} else {
|
||||
cnd.and("unitid", "=", user.getUnitId());
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysRoleService.listPageLinks(pageNumber, pageSize, cnd, "unit"));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.edit")
|
||||
@SLog(tag = "启用角色", msg = "角色名称:${args[1].getAttribute('name')}")
|
||||
public Object enable(String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
sysRoleService.update(org.nutz.dao.Chain.make("disabled", false), Cnd.where("id", "=", roleId));
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.edit")
|
||||
@SLog(tag = "禁用角色", msg = "角色名称:${args[1].getAttribute('name')}")
|
||||
public Object disable(String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
sysRoleService.update(org.nutz.dao.Chain.make("disabled", true), Cnd.where("id", "=", roleId));
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
//加载当前用户所拥有的所有权限菜单
|
||||
@At("/menuAll")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object menuAll(HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_menu> list;
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
list = sysMenuService.query(Cnd.orderBy().asc("location").asc("path"));
|
||||
} else {
|
||||
list = sysUserService.getMenusAndButtons(SecurityUtil.getUserId());
|
||||
}
|
||||
NutMap menuMap = NutMap.NEW();
|
||||
for (Sys_menu unit : list) {
|
||||
List<Sys_menu> list1 = menuMap.getList(unit.getParentId(), Sys_menu.class);
|
||||
if (list1 == null) {
|
||||
list1 = new ArrayList<>();
|
||||
}
|
||||
list1.add(unit);
|
||||
menuMap.put(unit.getParentId(), list1);
|
||||
}
|
||||
return Result.success().addData(getTree(menuMap, ""));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
//加载可分配的权限菜单
|
||||
@At("/menuRole/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object menuRole(String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_menu> hasList = sysRoleService.getMenusAndButtons(roleId);
|
||||
List<Sys_menu> list;
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
list = sysMenuService.query(Cnd.orderBy().asc("location").asc("path"));
|
||||
} else {
|
||||
list = sysUserService.getMenusAndButtons(SecurityUtil.getUserId());
|
||||
}
|
||||
NutMap menuMap = NutMap.NEW();
|
||||
for (Sys_menu unit : list) {
|
||||
List<Sys_menu> list1 = menuMap.getList(unit.getParentId(), Sys_menu.class);
|
||||
if (list1 == null) {
|
||||
list1 = new ArrayList<>();
|
||||
}
|
||||
list1.add(unit);
|
||||
menuMap.put(unit.getParentId(), list1);
|
||||
}
|
||||
List<String> cmenu = new ArrayList<>();
|
||||
for (Sys_menu menu : hasList) {
|
||||
cmenu.add(menu.getId());
|
||||
}
|
||||
return Result.success().addData(NutMap.NEW().addv("menu", getTree(menuMap, "")).addv("cmenu", cmenu));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
private List<NutMap> getTree(NutMap menuMap, String pid) {
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
List<Sys_menu> subList = menuMap.getList(pid, Sys_menu.class);
|
||||
for (Sys_menu menu : subList) {
|
||||
NutMap map = Lang.obj2nutmap(menu);
|
||||
map.put("label", menu.getName());
|
||||
if (menu.isHasChildren() || (menuMap.get(menu.getId()) != null)) {
|
||||
map.put("children", getTree(menuMap, menu.getId()));
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return treeList;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.add")
|
||||
@SLog(tag = "添加角色", msg = "角色名称:${args[1].name}")
|
||||
public Object addDo(@Param("menuIds") String menuIds, @Param("..") Sys_role role, HttpServletRequest req) {
|
||||
try {
|
||||
int num = sysRoleService.count(Cnd.where("code", "=", role.getCode().trim()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
String[] ids = StringUtils.split(menuIds, ",");
|
||||
if ("root".equals(role.getUnitid()) || "system".equals(role.getUnitid()))
|
||||
role.setUnitid("");
|
||||
role.setCreatedBy(SecurityUtil.getUserId());
|
||||
Sys_role r = sysRoleService.insert(role);
|
||||
if (r != null) {
|
||||
sysRoleService.saveMenu(ids, r.getId());
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
//查看角色拥有的权限
|
||||
@At("/menu/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object menu(String id, @Param("pid") String pid) {
|
||||
try {
|
||||
List<Sys_menu> list = sysRoleService.getRoleMenus(id, pid);
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
for (Sys_menu unit : list) {
|
||||
if (!unit.isHasChildren() && sysRoleService.hasChildren(id, unit.getId())) {
|
||||
unit.setHasChildren(true);
|
||||
}
|
||||
NutMap map = Lang.obj2nutmap(unit);
|
||||
map.addv("expanded", false);
|
||||
map.addv("children", new ArrayList<>());
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.delete")
|
||||
@SLog(tag = "删除角色", msg = "角色名称:${args[1].getAttribute('name')}")
|
||||
public Object delete(String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
if ("sysadmin".equals(role.getCode()) || "public".equals(role.getCode())) {
|
||||
return Result.error("system.not.allow");
|
||||
}
|
||||
sysRoleService.del(roleId);
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object edit(String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
return Result.success().addData(sysRoleService.fetch(roleId));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
//修改角色
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.edit")
|
||||
@SLog(tag = "修改角色", msg = "角色名称:${args[0].name}")
|
||||
public Object editDo(@Param("..") Sys_role role, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_role oldRole = sysRoleService.fetch(role.getId());
|
||||
if (oldRole != null && !Strings.sBlank(oldRole.getCode()).equalsIgnoreCase(role.getCode())) {
|
||||
int num = sysRoleService.count(Cnd.where("code", "=", role.getCode().trim()));
|
||||
if (num > 0) {
|
||||
return Result.error("sys.role.code");
|
||||
}
|
||||
}
|
||||
if ("root".equals(role.getUnitid()) || "system".equals(role.getUnitid()))
|
||||
role.setUnitid("");
|
||||
role.setUpdatedBy(SecurityUtil.getUserId());
|
||||
sysRoleService.updateIgnoreNull(role);
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.menu")
|
||||
@SLog(tag = "分配角色菜单", msg = "角色名称:${args[2].getAttribute('name')}")
|
||||
public Object menuDo(@Param("menuIds") String menuIds, @Param("roleId") String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
String[] ids = StringUtils.split(menuIds, ",");
|
||||
sysRoleService.saveMenu(ids, roleId);
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object user(@Param("roleId") String roleId, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword,
|
||||
@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Sql sql = Sqls.create("SELECT a.*,c.name as unitname FROM sys_user a,sys_user_role b,sys_unit c WHERE a.unitid=c.id and a.id=b.userId and b.roleId=@roleId $s $o");
|
||||
sql.params().set("roleId", roleId);
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
sql.vars().set("s", " and a." + searchName + " like '%" + searchKeyword + "%'");
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
sql.vars().set("o", " order by a." + pageOrderName + " " + PageUtil.getOrder(pageOrderBy));
|
||||
|
||||
}
|
||||
return Result.success().addData(sysUserService.listPage(pageNumber, pageSize, sql));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.role")
|
||||
public Object userSearch(@Param("query") String keyword, @Param("roleId") String roleId) {
|
||||
try {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
return Result.success().addData(sysRoleService.userSearch(roleId, keyword, StpUtil.hasRole("sysadmin"), user.getUnit()));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.user")
|
||||
@SLog(tag = "添加用户到角色", msg = "角色名称:${args[2].getAttribute('name')},用户ID:${args[0]}")
|
||||
public Object usersAdd(@Param("users") String users, @Param("roleId") String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
String[] ids = StringUtils.split(users, ",");
|
||||
for (String s : ids) {
|
||||
sysRoleService.insert("sys_user_role", org.nutz.dao.Chain.make("roleId", roleId).add("userId", s));
|
||||
}
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.role.user")
|
||||
@SLog(tag = "从角色中移除用户", msg = "角色名称:${args[2].getAttribute('name')},用户ID:${args[0]}")
|
||||
public Object usersDel(@Param("users") String users, @Param("roleId") String roleId, HttpServletRequest req) {
|
||||
try {
|
||||
String superadminId = sysUserService.fetch(Cnd.where("loginname", "=", "superadmin")).getId();
|
||||
String sysadminRoleid = sysRoleService.fetch(Cnd.where("code", "=", "sysadmin")).getId();
|
||||
String[] ids = StringUtils.split(users, ",");
|
||||
if (Lang.contains(ids, superadminId) && roleId.equals(sysadminRoleid)) {
|
||||
return Result.error("超级管理员不能从[系统管理员]角色里删除");
|
||||
}
|
||||
sysRoleService.clear("sys_user_role", Cnd.where("userId", "in", ids).and("roleId", "=", roleId));
|
||||
Sys_role role = sysRoleService.fetch(roleId);
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("name", role.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.models.Sys_route;
|
||||
import com.budwk.app.sys.services.SysRouteService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.integration.jedis.pubsub.PubSubService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/sys/route")
|
||||
public class SysRouteController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysRouteService routeService;
|
||||
@Inject
|
||||
private PubSubService pubSubService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/route/index.html")
|
||||
@SaCheckPermission("sys.manager.route")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.route")
|
||||
public Object data(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(routeService.listPage(pageNumber, pageSize, cnd));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SLog(tag = "新建路由", msg = "URL:${args[0].url}")
|
||||
@SaCheckPermission("sys.manager.route.add")
|
||||
public Object addDo(@Param("..") Sys_route route, HttpServletRequest req) {
|
||||
try {
|
||||
route.setCreatedBy(SecurityUtil.getUserId());
|
||||
routeService.insert(route);
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_route");
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.route")
|
||||
public Object edit(String id) {
|
||||
try {
|
||||
return Result.success().addData(routeService.fetch(id));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SLog(tag = "修改路由", msg = "URL:${args[0].url}")
|
||||
@SaCheckPermission("sys.manager.route.edit")
|
||||
public Object editDo(@Param("..") Sys_route route, HttpServletRequest req) {
|
||||
try {
|
||||
route.setUpdatedBy(SecurityUtil.getUserId());
|
||||
routeService.updateIgnoreNull(route);
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_route");
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SLog(tag = "删除路由", msg = "路由ID:${args[0]}")
|
||||
@SaCheckPermission("sys.manager.route.delete")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
routeService.delete(id);
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_route");
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.route.edit")
|
||||
@SLog(tag = "启用路由", msg = "URL:${args[1].getAttribute('url')}")
|
||||
public Object enable(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_route route = routeService.fetch(id);
|
||||
req.setAttribute("url", route.getUrl());
|
||||
routeService.update(Chain.make("disabled", false), Cnd.where("id", "=", id));
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_route");
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.route.edit")
|
||||
@SLog(tag = "禁用路由", msg = "URL:${args[1].getAttribute('name')}")
|
||||
public Object disable(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_route route = routeService.fetch(id);
|
||||
req.setAttribute("url", route.getUrl());
|
||||
routeService.update(Chain.make("disabled", true), Cnd.where("id", "=", id));
|
||||
pubSubService.fire(RedisConstant.PLATFORM_REDIS_PREFIX + "web:platform", "sys_route");
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.sys.models.Sys_task;
|
||||
import com.budwk.app.sys.services.SysTaskService;
|
||||
import com.budwk.app.task.services.TaskPlatformService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/sys/task")
|
||||
public class SysTaskController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysTaskService sysTaskService;
|
||||
@Inject
|
||||
private TaskPlatformService taskPlatformService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/task/index.html")
|
||||
@SaCheckPermission("sys.manager.task")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("beetl:/platform/sys/task/cron.html")
|
||||
@SaCheckPermission("sys.manager.task")
|
||||
public void cron() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.task")
|
||||
public Object cronExp(@Param("cron") String cron) {
|
||||
try {
|
||||
return Result.success().addData(taskPlatformService.getCronExeTimes(cron));
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("sys.manager.task")
|
||||
public Object data(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysTaskService.listPage(pageNumber, pageSize, cnd));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SLog(tag = "新建任务", msg = "任务名称:${args[0].name}")
|
||||
@SaCheckPermission("sys.manager.task.add")
|
||||
public Object addDo(@Param("..") Sys_task task, HttpServletRequest req) {
|
||||
try {
|
||||
task.setCreatedBy(SecurityUtil.getUserId());
|
||||
Sys_task sysTask = sysTaskService.insert(task);
|
||||
taskPlatformService.add(sysTask.getId(), sysTask.getId(), sysTask.getJobClass(), sysTask.getCron(),
|
||||
sysTask.getNote(), sysTask.getData());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.task")
|
||||
public Object edit(String id) {
|
||||
try {
|
||||
return Result.success().addData(sysTaskService.fetch(id));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SLog(tag = "修改任务", msg = "任务名称:${args[0].name}")
|
||||
@SaCheckPermission("sys.manager.task.edit")
|
||||
public Object editDo(@Param("..") Sys_task task, HttpServletRequest req) {
|
||||
try {
|
||||
task.setUpdatedBy(SecurityUtil.getUserId());
|
||||
sysTaskService.updateIgnoreNull(task);
|
||||
if (taskPlatformService.isExist(task.getId(), task.getId())) {
|
||||
taskPlatformService.delete(task.getId(), task.getId());
|
||||
}
|
||||
if (!task.isDisabled()) {
|
||||
taskPlatformService.add(task.getId(), task.getId(), task.getJobClass(), task.getCron(),
|
||||
task.getNote(), task.getData());
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SLog(tag = "删除任务", msg = "任务名称:${args[1].getAttribute('name')}")
|
||||
@SaCheckPermission("sys.manager.task.delete")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_task sysTask = sysTaskService.fetch(id);
|
||||
try {
|
||||
if (taskPlatformService.isExist(sysTask.getId(), sysTask.getId())) {
|
||||
taskPlatformService.delete(sysTask.getId(), sysTask.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
sysTaskService.delete(id);
|
||||
req.setAttribute("name", sysTask.getName());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.task.edit")
|
||||
@SLog(tag = "启用任务", msg = "任务名:${args[1].getAttribute('name')}")
|
||||
public Object enable(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_task sysTask = sysTaskService.fetch(id);
|
||||
req.setAttribute("name", sysTask.getName());
|
||||
sysTaskService.update(org.nutz.dao.Chain.make("disabled", false), Cnd.where("id", "=", id));
|
||||
if (!taskPlatformService.isExist(sysTask.getId(), sysTask.getId())) {
|
||||
taskPlatformService.add(sysTask.getId(), sysTask.getId(), sysTask.getJobClass(), sysTask.getCron(),
|
||||
sysTask.getNote(), sysTask.getData());
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.task.edit")
|
||||
@SLog(tag = "禁用任务", msg = "任务名:${args[1].getAttribute('name')}")
|
||||
public Object disable(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_task sysTask = sysTaskService.fetch(id);
|
||||
req.setAttribute("name", sysTask.getName());
|
||||
sysTaskService.update(org.nutz.dao.Chain.make("disabled", true), Cnd.where("id", "=", id));
|
||||
if (taskPlatformService.isExist(sysTask.getId(), sysTask.getId())) {
|
||||
taskPlatformService.delete(sysTask.getId(), sysTask.getId());
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.sys.models.Sys_role;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.models.Sys_user_role;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUnitService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/24.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/unit")
|
||||
public class SysUnitController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysUnitService sysUnitService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/unit/index.html")
|
||||
@SaCheckPermission("sys.manager.unit")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At("/child")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object child(@Param("pid") String pid, HttpServletRequest req) {
|
||||
List<Sys_unit> list = new ArrayList<>();
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (user != null && Strings.isBlank(pid)) {
|
||||
list = sysUnitService.query(Cnd.where("id", "=", user.getUnitId()).asc("path"));
|
||||
} else {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
}
|
||||
}
|
||||
for (Sys_unit unit : list) {
|
||||
NutMap map = Lang.obj2nutmap(unit);
|
||||
map.addv("expanded", false);
|
||||
map.addv("children", new ArrayList<>());
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
}
|
||||
|
||||
|
||||
@At("/tree")
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object tree(@Param("pid") String pid, HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_unit> list = new ArrayList<>();
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
if (Strings.isBlank(pid)) {
|
||||
NutMap root = NutMap.NEW().addv("value", "root").addv("label", "不选择单位").addv("leaf", true);
|
||||
treeList.add(root);
|
||||
}
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (user != null && Strings.isBlank(pid)) {
|
||||
list = sysUnitService.query(Cnd.where("id", "=", user.getUnitId()).asc("path"));
|
||||
} else {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (Strings.isBlank(pid)) {
|
||||
cnd.and("parentId", "=", "").or("parentId", "is", null);
|
||||
} else {
|
||||
cnd.and("parentId", "=", pid);
|
||||
}
|
||||
cnd.asc("location").asc("path");
|
||||
list = sysUnitService.query(cnd);
|
||||
}
|
||||
}
|
||||
for (Sys_unit unit : list) {
|
||||
NutMap map = NutMap.NEW().addv("value", unit.getId()).addv("label", unit.getName());
|
||||
if (unit.isHasChildren()) {
|
||||
map.addv("children", new ArrayList<>());
|
||||
map.addv("leaf", false);
|
||||
} else {
|
||||
map.addv("leaf", true);
|
||||
}
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.unit.add")
|
||||
@SLog(tag = "新建单位", msg = "单位名称:${args[0].name}")
|
||||
public Object addDo(@Param("..") Sys_unit unit, @Param("parentId") String parentId, @Param(value = "roleTableData") String roleTableData) {
|
||||
try {
|
||||
if ("root".equals(parentId)) {
|
||||
parentId = "";
|
||||
}
|
||||
unit.setCreatedBy(SecurityUtil.getUserId());
|
||||
sysUnitService.save(unit, parentId);
|
||||
if (ObjectUtil.isNotEmpty(roleTableData)) {
|
||||
Sys_role sysRole = sysUnitService.dao().fetch(Sys_role.class, Cnd.where("code", "=", "unitAdmin"));
|
||||
List<Sys_user_role> userRoleList = Json.fromJsonAsList(Sys_user_role.class, roleTableData);
|
||||
userRoleList.forEach(sys_user_role -> {
|
||||
sys_user_role.setUnitId(unit.getId());
|
||||
sys_user_role.setRoleId(sysRole.getId());
|
||||
});
|
||||
sysUnitService.insert(userRoleList);
|
||||
}
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.unit")
|
||||
public Object edit(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_unit unit = sysUnitService.fetch(id);
|
||||
return Result.success().addData(unit);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.unit.edit")
|
||||
@SLog(tag = "编辑单位", msg = "单位名称:${args[0].name}")
|
||||
public Object editDo(@Param("..") Sys_unit unit, @Param("roleTableData") String roleTableData) {
|
||||
try {
|
||||
sysUnitService.dao().clear(Sys_user_role.class, Cnd.where("unitId", "=", unit.getId()));
|
||||
if (ObjectUtil.isNotEmpty(roleTableData)) {
|
||||
Sys_role sysRole = sysUnitService.dao().fetch(Sys_role.class, Cnd.where("code", "=", "unitAdmin"));
|
||||
List<Sys_user_role> userRoleList = Json.fromJsonAsList(Sys_user_role.class, roleTableData);
|
||||
userRoleList.forEach(sys_user_role -> {
|
||||
sys_user_role.setUnitId(unit.getId());
|
||||
sys_user_role.setRoleId(sysRole.getId());
|
||||
});
|
||||
sysUnitService.insert(userRoleList);
|
||||
}
|
||||
unit.setUpdatedBy(SecurityUtil.getUserId());
|
||||
sysUnitService.updateIgnoreNull(unit);
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.unit.delete")
|
||||
@SLog(tag = "删除单位", msg = "单位名称:${args[1].getAttribute('name')}")
|
||||
public Object delete(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_unit unit = sysUnitService.fetch(id);
|
||||
req.setAttribute("name", unit.getName());
|
||||
/* if ("0001".equals(unit.getPath())) {
|
||||
return Result.error("system.not.allow");
|
||||
}*/
|
||||
sysRoleService.dao().clear(Sys_user_role.class, Cnd.where("unitId", "=", unit.getId()));
|
||||
sysUnitService.deleteAndChild(unit);
|
||||
sysMenuService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result listUnion(String unionId) {
|
||||
List<Sys_unit> unitList = sysUnitService.dao().query(Sys_unit.class,
|
||||
Cnd.where("LENGTH(path)", "=", 4).andEX("id", "=", unionId).and("isEnable", "=", 1).asc("path"));
|
||||
return Result.success(unitList);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result listUnit(String unionId) {
|
||||
List<Sys_unit> unitList = sysUnitService.dao().query(Sys_unit.class,
|
||||
Cnd.where("isThisSchoolUnit", "is", true).andEX("parentId", "=", unionId).and("isEnable", "=", 1).asc("location"));
|
||||
return Result.success(unitList);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result getRoleOption() {
|
||||
List<Sys_role> roleList = sysUnitService.dao().query(Sys_role.class,
|
||||
Cnd.where("code", "in", List.of("unitAdmin", "twoUnitAdmin")).asc("code"));
|
||||
return Result.success(roleList);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result getUserOption(String unitId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
u.id userId,
|
||||
u.username userName,
|
||||
it.`name` unitName,
|
||||
(SELECT COUNT(*)
|
||||
FROM sys_user_role
|
||||
WHERE userId = u.id AND unitId = @unitId) AS disabled
|
||||
FROM
|
||||
sys_user u
|
||||
LEFT JOIN sys_unit it ON it.id = u.unitId
|
||||
WHERE u.unitId = @unitId
|
||||
""").setParam("unitId", unitId);
|
||||
List<NutMap> map = sysUnitService.listMap(sql);
|
||||
return Result.success(map);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result getRoleTableData(String unitId) {
|
||||
List<Sys_user_role> userRoleList = sysUnitService.dao().query(Sys_user_role.class, Cnd.where("unitId", "=", unitId));
|
||||
return Result.success(userRoleList);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Result doIsEnable(@Param("id") String id, Boolean isEnable) {
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
return Result.error("参数错误");
|
||||
}
|
||||
sysUnitService.update(Chain.make("isEnable", isEnable), Cnd.where("id", "=", id));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
package com.budwk.app.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.utils.PageUtil;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysUnitService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import com.budwk.app.web.commons.slog.annotation.SLog;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.integration.json4excel.J4E;
|
||||
import org.nutz.integration.json4excel.J4EColumn;
|
||||
import org.nutz.integration.json4excel.J4EConf;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/23.
|
||||
*/
|
||||
@IocBean
|
||||
@At("/platform/sys/user")
|
||||
public class SysUserController {
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysUnitService sysUnitService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/sys/user/index.html")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public void index() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.add")
|
||||
@SLog(tag = "新建用户", msg = "用户名:${user.loginname}")
|
||||
public Object addDo(@Param("..") Sys_user user, HttpServletRequest req) {
|
||||
try {
|
||||
if (Strings.isNotBlank(user.getLoginname())) {
|
||||
int num = sysUserService.count(Cnd.where("loginname", "=", Strings.trim(user.getLoginname())));
|
||||
if (num > 0) {
|
||||
return Result.error("用户名已存在!");
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(user.getMobile())) {
|
||||
int num = sysUserService.count(Cnd.where("mobile", "=", Strings.trim(user.getMobile())));
|
||||
if (num > 0) {
|
||||
return Result.error("手机号已存在!");
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(user.getEmail())) {
|
||||
int num = sysUserService.count(Cnd.where("email", "=", Strings.trim(user.getEmail())));
|
||||
if (num > 0) {
|
||||
return Result.error("邮箱已存在!");
|
||||
}
|
||||
}
|
||||
String salt = R.UU32();
|
||||
user.setSalt(salt);
|
||||
user.setPassword(PwdUtil.getPassword(user.getPassword(), salt));
|
||||
user.setLoginCount(0);
|
||||
// user.setUnitPath(sysUnitService.fetch(user.getUnitId()).getPath());
|
||||
sysUserService.insert(user);
|
||||
sysUserService.clearCache();
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/edit/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public Object edit(String id) {
|
||||
try {
|
||||
return Result.success().addData(sysUserService.fetchLinks(sysUserService.fetch(id), "unit"));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.edit")
|
||||
@SLog(tag = "修改用户", msg = "用户名:${user.loginname}")
|
||||
public Object editDo(@Param("..") Sys_user user, HttpServletRequest req) {
|
||||
try {
|
||||
sysUserService.updateIgnoreNull(user);
|
||||
sysUserService.deleteCache(user.getId());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/resetPwd/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.edit")
|
||||
@SLog(tag = "重置密码", msg = "用户名:${args[1].getAttribute('loginname')}")
|
||||
public Object resetPwd(String id, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_user user = sysUserService.fetch(id);
|
||||
String salt = R.UU32();
|
||||
String pwd = R.captchaNumber(6);
|
||||
String hashedPasswordBase64 = PwdUtil.getPassword(pwd, salt);
|
||||
sysUserService.update(Chain.make("salt", salt).add("password", hashedPasswordBase64), Cnd.where("id", "=", id));
|
||||
sysUserService.deleteCache(user.getId());
|
||||
req.setAttribute("loginname", user.getLoginname());
|
||||
return Result.success().addData(pwd);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.delete")
|
||||
@SLog(tag = "删除用户", msg = "用户名:${args[1].getAttribute('loginname')}")
|
||||
public Object delete(String userId, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_user user = sysUserService.fetch(userId);
|
||||
if ("superadmin".equals(user.getLoginname())) {
|
||||
return Result.error("system.not.allow");
|
||||
}
|
||||
sysUserService.deleteById(userId);
|
||||
sysUserService.deleteCache(user.getId());
|
||||
req.setAttribute("loginname", user.getLoginname());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/delete")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.delete")
|
||||
@SLog(tag = "批量删除用户", msg = "用户ID:${args[1].getAttribute('ids')}")
|
||||
public Object deletes(@Param("ids") String[] userIds, HttpServletRequest req) {
|
||||
try {
|
||||
Sys_user user = sysUserService.fetch(Cnd.where("loginname", "=", "superadmin"));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : userIds) {
|
||||
if (s.equals(user.getId())) {
|
||||
return Result.error("system.not.allow");
|
||||
}
|
||||
sb.append(s).append(",");
|
||||
}
|
||||
sysUserService.deleteByIds(userIds);
|
||||
sysUserService.clearCache();
|
||||
req.setAttribute("ids", sb.toString());
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/enable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.edit")
|
||||
@SLog(tag = "启用用户", msg = "用户名:${args[1].getAttribute('loginname')}")
|
||||
public Object enable(String userId, HttpServletRequest req) {
|
||||
try {
|
||||
req.setAttribute("loginname", sysUserService.fetch(userId).getLoginname());
|
||||
sysUserService.update(Chain.make("disabled", false), Cnd.where("id", "=", userId));
|
||||
sysUserService.deleteCache(userId);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/disable/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user.edit")
|
||||
@SLog(tag = "禁用用户", msg = "用户名:${req.getAttribute('loginname')}")
|
||||
public Object disable(String userId, HttpServletRequest req) {
|
||||
try {
|
||||
String loginname = sysUserService.fetch(userId).getLoginname();
|
||||
if ("superadmin".equals(loginname)) {
|
||||
return Result.error("system.not.allow");
|
||||
}
|
||||
req.setAttribute("loginname", loginname);
|
||||
sysUserService.update(Chain.make("disabled", true), Cnd.where("id", "=", userId));
|
||||
sysUserService.deleteCache(userId);
|
||||
return Result.success();
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At("/menu/?")
|
||||
@Ok("json")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public Object menu(String id, @Param("pid") String pid, HttpServletRequest req) {
|
||||
try {
|
||||
List<Sys_menu> list = sysUserService.getRoleMenus(id, pid);
|
||||
List<NutMap> treeList = new ArrayList<>();
|
||||
for (Sys_menu unit : list) {
|
||||
if (!unit.isHasChildren() && sysUserService.hasChildren(id, unit.getId())) {
|
||||
unit.setHasChildren(true);
|
||||
}
|
||||
NutMap map = Lang.obj2nutmap(unit);
|
||||
map.addv("expanded", false);
|
||||
map.addv("children", new ArrayList<>());
|
||||
treeList.add(map);
|
||||
}
|
||||
return Result.success().addData(treeList);
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json:{locked:'password|salt',ignoreNull:false}")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public Object data(@Param("searchUnit") String searchUnit, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy) {
|
||||
try {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
if (Strings.isNotBlank(searchUnit)) {
|
||||
cnd.and("unitid", "=", searchUnit);
|
||||
}
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (Strings.isNotBlank(searchUnit)) {
|
||||
Sys_unit unit = sysUnitService.fetch(searchUnit);
|
||||
if (unit == null || !unit.getPath().startsWith(user.getUnit().getPath())) {
|
||||
//防止有人越级访问
|
||||
return Result.error("非法操作");
|
||||
} else
|
||||
cnd.and("unitId", "=", searchUnit);
|
||||
} else {
|
||||
cnd.and("unitId", "=", user.getUnitId());
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
return Result.success().addData(sysUserService.listPageLinks(pageNumber, pageSize, cnd, "unit"));
|
||||
} catch (Exception e) {
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@SaCheckPermission("sys.manager.user")
|
||||
public void export(@Param("searchUnit") String searchUnit, @Param("searchName") String searchName, @Param("searchKeyword") String searchKeyword, @Param("pageOrderName") String pageOrderName, @Param("pageOrderBy") String pageOrderBy, HttpServletResponse response) {
|
||||
try {
|
||||
J4EConf j4eConf = J4EConf.from(Sys_user.class);
|
||||
List<J4EColumn> jcols = j4eConf.getColumns();
|
||||
for (J4EColumn j4eColumn : jcols) {
|
||||
if ("createdBy".equals(j4eColumn.getFieldName()) || "createdAt".equals(j4eColumn.getFieldName()) || "delFlag".equals(j4eColumn.getFieldName())) {
|
||||
j4eColumn.setIgnore(true);
|
||||
}
|
||||
}
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StpUtil.hasRole("sysadmin")) {
|
||||
if (Strings.isNotBlank(searchUnit)) {
|
||||
cnd.and("unitid", "=", searchUnit);
|
||||
}
|
||||
} else {
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
if (Strings.isNotBlank(searchUnit)) {
|
||||
Sys_unit unit = sysUnitService.fetch(searchUnit);
|
||||
if (unit == null || !unit.getPath().startsWith(user.getUnit().getPath())) {
|
||||
//防止有人越级访问
|
||||
throw Lang.makeThrow("非法操作");
|
||||
} else
|
||||
cnd.and("unitId", "=", searchUnit);
|
||||
} else {
|
||||
cnd.and("unitId", "=", user.getUnitId());
|
||||
}
|
||||
}
|
||||
if (Strings.isNotBlank(searchName) && Strings.isNotBlank(searchKeyword)) {
|
||||
cnd.and(searchName, "like", "%" + searchKeyword + "%");
|
||||
}
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
|
||||
}
|
||||
OutputStream out = response.getOutputStream();
|
||||
response.setHeader("content-type", "application/shlnd.ms-excel;charset=utf-8");
|
||||
response.setHeader("content-disposition", "attachment; filename=" + new String("用户信息".getBytes(), "ISO-8859-1") + ".xls");
|
||||
J4E.toExcel(out, sysUserService.query(cnd, "unit"), j4eConf);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("beetl:/platform/sys/user/pass.html")
|
||||
@SaCheckLogin
|
||||
public void pass() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("beetl:/platform/sys/user/info.html")
|
||||
@SaCheckLogin
|
||||
public void info(HttpServletRequest req) {
|
||||
Sys_user user = sysUserService.fetch(SecurityUtil.getUserId());
|
||||
req.setAttribute("user", user);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("beetl:/platform/sys/user/custom.html")
|
||||
@SaCheckLogin
|
||||
public void custom() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("beetl:/platform/sys/user/mode.html")
|
||||
@SaCheckLogin
|
||||
public void mode() {
|
||||
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object doChangePassword(@Param("oldPassword") String oldPassword, @Param("newPassword") String newPassword, HttpServletRequest req) {
|
||||
if ("superadmin".equals(SecurityUtil.getUserLoginname()) && Globals.MyConfig.getBoolean("AppDemoEnv")) {
|
||||
return Result.error("演示环境,不予操作");
|
||||
}
|
||||
Sys_user user = sysUserService.getUserById(SecurityUtil.getUserId());
|
||||
String old = PwdUtil.getPassword(oldPassword, user.getSalt());
|
||||
if (old.equals(user.getPassword())) {
|
||||
String salt = R.UU32();
|
||||
String hashedPasswordBase64 = PwdUtil.getPassword(newPassword, salt);
|
||||
user.setSalt(salt);
|
||||
user.setPassword(hashedPasswordBase64);
|
||||
sysUserService.update(Chain.make("salt", salt).add("password", hashedPasswordBase64), Cnd.where("id", "=", user.getId()));
|
||||
sysUserService.deleteCache(user.getId());
|
||||
return Result.success("修改成功");
|
||||
} else {
|
||||
return Result.error("旧密码错误");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@SaCheckLogin
|
||||
public Object doChangeInfo(@Param("username") String username, @Param("mobile") String mobile, @Param("email") String email, HttpServletRequest req) {
|
||||
if ("superadmin".equals(SecurityUtil.getUserLoginname()) && Globals.MyConfig.getBoolean("AppDemoEnv")) {
|
||||
return Result.error("演示环境,不予操作");
|
||||
}
|
||||
sysUserService.update(Chain.make("username", username).add("mobile", mobile).add("email", email), Cnd.where("id", "=", SecurityUtil.getUserId()));
|
||||
sysUserService.deleteCache(SecurityUtil.getUserId());
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("client_user")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@Comment("手机端用户")
|
||||
public class Client_user extends BaseModel implements Serializable {
|
||||
|
||||
@Id
|
||||
@Comment("ID")
|
||||
private Long id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
@Comment("姓名")
|
||||
private String userName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 1)
|
||||
@Comment("性别")
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 11)
|
||||
@Comment("手机号")
|
||||
private String mobile;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
@Comment("openId")
|
||||
private String openId;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* API密钥管理
|
||||
* Created by wizzer on 2019/2/26.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_api")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_api extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String appid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String appkey;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 应用管理--配置文件表
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@Table("sys_app_conf")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_app_conf extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("实例名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String confName;
|
||||
|
||||
@Column
|
||||
@Comment("版本号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String confVersion;
|
||||
|
||||
@Column
|
||||
@Comment("配置内容")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String confData;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@One(field = "createdBy")
|
||||
private Sys_user user;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getConfName() {
|
||||
return confName;
|
||||
}
|
||||
|
||||
public void setConfName(String confName) {
|
||||
this.confName = confName;
|
||||
}
|
||||
|
||||
public String getConfVersion() {
|
||||
return confVersion;
|
||||
}
|
||||
|
||||
public void setConfVersion(String confVersion) {
|
||||
this.confVersion = confVersion;
|
||||
}
|
||||
|
||||
public String getConfData() {
|
||||
return confData;
|
||||
}
|
||||
|
||||
public void setConfData(String confData) {
|
||||
this.confData = confData;
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
public Sys_user getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(Sys_user user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 应用管理--应用实例表
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@Data
|
||||
@Table("sys_app_list")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_app_list extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("实例名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String appName;
|
||||
|
||||
@Column
|
||||
@Comment("版本号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String appVersion;
|
||||
|
||||
@Column
|
||||
@Comment("文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
@Column
|
||||
@Comment("文件路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String filePath;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@One(field = "createdBy")
|
||||
private Sys_user user;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 应用管理--推送任务表
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@Data
|
||||
@Table("sys_app_task")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_app_task extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@Prev(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("实例名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("执行动作")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String action;
|
||||
|
||||
@Column
|
||||
@Comment("APP版本")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String appVersion;
|
||||
|
||||
@Column
|
||||
@Comment("配置版本")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String confVersion;
|
||||
|
||||
@Column
|
||||
@Comment("进程ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String processId;
|
||||
|
||||
@Column
|
||||
@Comment("推送主机")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String hostName;//主机名 如果是推送给全部主机则为多条
|
||||
|
||||
@Column
|
||||
@Comment("主机IP")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String hostAddress;//只为展示用
|
||||
|
||||
@Column
|
||||
@Comment("推送状态")
|
||||
@ColDefine(type = ColType.INT, width = 1)
|
||||
private Integer status;//0-待执行,1-执行中,2-执行成功,3-执行失败,4-撤销任务
|
||||
|
||||
@Column
|
||||
@Comment("反馈时间")
|
||||
private Long pushAt;
|
||||
|
||||
@Column
|
||||
@Comment("反馈结果")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String pushResult;
|
||||
|
||||
@One(field = "createdBy")
|
||||
private Sys_user user;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_config")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_config extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Name
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String configKey;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String configValue;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String note;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.DB;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_dict")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@TableIndexes({@Index(name = "INDEX_SYS_DICT_PATH", fields = {"path"}, unique = true)})
|
||||
public class Sys_dict extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("父级ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String parentId;
|
||||
|
||||
@Column
|
||||
@Comment("树路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String path;
|
||||
|
||||
@Column
|
||||
@Comment("名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("机构编码")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String code;
|
||||
|
||||
@Column
|
||||
@Comment("启用状态")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@Column
|
||||
@Comment("排序字段")
|
||||
@Prev({
|
||||
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_dict"),
|
||||
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_dict")
|
||||
})
|
||||
private Integer location;
|
||||
|
||||
@Column
|
||||
@Comment("有子节点")
|
||||
private boolean hasChildren;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_log_${month}")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_log extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("操作人姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@Comment("操作人用户名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@Comment("日志类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String type;
|
||||
|
||||
@Column
|
||||
@Comment("日志标识")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String tag;
|
||||
|
||||
@Column
|
||||
@Comment("执行类")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String src;
|
||||
|
||||
@Column
|
||||
@Comment("来源IP")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String ip;
|
||||
|
||||
@Column
|
||||
@Comment("日志内容")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String msg;
|
||||
|
||||
@Column
|
||||
@Comment("请求结果")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String param;
|
||||
|
||||
@Column
|
||||
@Comment("执行结果")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String result;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.DB;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_menu")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@TableIndexes({@Index(name = "INDEX_SYS_MENU_PATH", fields = {"path"}, unique = true), @Index(name = "INDEX_SYS_MENU_PREM", fields = {"permission"}, unique = true)})
|
||||
public class Sys_menu extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("父级ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String parentId;
|
||||
|
||||
@Column
|
||||
@Comment("树路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String path;
|
||||
|
||||
@Column
|
||||
@Comment("菜单名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("菜单别名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String aliasName;
|
||||
|
||||
@Column
|
||||
@Comment("资源类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String type;
|
||||
|
||||
@Column
|
||||
@Comment("菜单链接")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String href;
|
||||
|
||||
@Column
|
||||
@Comment("打开方式")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String target;
|
||||
|
||||
@Column
|
||||
@Comment("菜单图标")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String icon;
|
||||
|
||||
@Column
|
||||
@Comment("是否显示")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean showit;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@Column
|
||||
@Comment("权限标识")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String permission;
|
||||
|
||||
@Column
|
||||
@Comment("菜单介绍")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@Comment("排序字段")
|
||||
@Prev({
|
||||
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_menu"),
|
||||
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_menu")
|
||||
})
|
||||
private Integer location;
|
||||
|
||||
@Column
|
||||
@Comment("有子节点")
|
||||
private boolean hasChildren;
|
||||
|
||||
private List<Sys_menu> buttons;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/6/29.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_msg")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_msg extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("消息类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String type;
|
||||
|
||||
@Column
|
||||
@Comment("消息标题")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String title;
|
||||
|
||||
@Column
|
||||
@Comment("消息内容")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@Comment("消息URL")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String url;
|
||||
|
||||
@Column
|
||||
@Comment("发送时间")
|
||||
//Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
|
||||
private Long sendAt;
|
||||
|
||||
@Many(field = "msgId")
|
||||
private List<Sys_msg_user> userList;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2018/6/29.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_msg_user")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_msg_user extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("消息ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String msgId;
|
||||
|
||||
@Column
|
||||
@Comment("用户名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 120)
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@Comment("消息状态")
|
||||
@ColDefine(type = ColType.INT)
|
||||
private int status;//0--未读 1--已读
|
||||
|
||||
@Column
|
||||
@Comment("读取时间")
|
||||
//Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
|
||||
private Long readAt;
|
||||
|
||||
@One(field = "msgId")
|
||||
private Sys_msg msg;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_role")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@TableIndexes({@Index(name = "INDEX_SYS_ROLE_CODE", fields = {"code"}, unique = true)})
|
||||
public class Sys_role extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String code;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String aliasName;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitid;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String note;
|
||||
|
||||
@One(field = "unitid")
|
||||
public Sys_unit unit;
|
||||
|
||||
@ManyMany(from = "roleId", relation = "sys_role_menu", to = "menuId")
|
||||
protected List<Sys_menu> menus;
|
||||
|
||||
@ManyMany(from = "roleId", relation = "sys_user_role", to = "userId")
|
||||
private List<Sys_user> users;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Wizzer on 2016/7/31.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_route")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_route extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("原始路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String url;
|
||||
|
||||
@Column
|
||||
@Comment("跳转路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String toUrl;
|
||||
|
||||
@Column
|
||||
@Comment("转发类型")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
private String type;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Wizzer on 2016/7/30.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_task")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
public class Sys_task extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("任务名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("执行类")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String jobClass;
|
||||
|
||||
@Column
|
||||
@Comment("任务说明")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@Comment("定时规则")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String cron;
|
||||
|
||||
@Column
|
||||
@Comment("执行参数")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String data;
|
||||
|
||||
@Column
|
||||
@Comment("执行时间")
|
||||
private Long exeAt;
|
||||
|
||||
@Column
|
||||
@Comment("执行结果")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String exeResult;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.DB;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_unit")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@TableIndexes({@Index(name = "INDEX_SYS_UNIT_PATH", fields = {"path"}, unique = true),
|
||||
@Index(name = "INDEX_SYS_UNIT_UNITCODE", fields = {"unitcode"}, unique = true)
|
||||
})
|
||||
public class Sys_unit extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(els = {@EL("uuid()")})
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("父级ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String parentId;
|
||||
|
||||
@Column
|
||||
@Comment("树路径")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String path;
|
||||
|
||||
@Column
|
||||
@Comment("单位名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("单位别名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String aliasName;
|
||||
|
||||
@Column
|
||||
@Comment("机构编码")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitcode;
|
||||
|
||||
@Column
|
||||
@Comment("单位介绍")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String note;
|
||||
|
||||
@Column
|
||||
@Comment("单位地址")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String address;
|
||||
|
||||
@Column
|
||||
@Comment("联系电话")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 20)
|
||||
private String telephone;
|
||||
|
||||
@Column
|
||||
@Comment("单位邮箱")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String email;
|
||||
|
||||
@Column
|
||||
@Comment("单位网站")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String website;
|
||||
|
||||
@Column
|
||||
@Comment("排序字段")
|
||||
@Prev({
|
||||
@SQL(db = DB.MYSQL, value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_unit"),
|
||||
@SQL(db = DB.ORACLE, value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_unit")
|
||||
})
|
||||
private Integer location;
|
||||
|
||||
@Column
|
||||
@Comment("有子节点")
|
||||
private boolean hasChildren;
|
||||
|
||||
@Column
|
||||
@Comment("单位logo")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String logo;
|
||||
|
||||
@Column
|
||||
@Comment("是否本校单位")
|
||||
@Default("0")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isThisSchoolUnit;
|
||||
|
||||
@Column
|
||||
@Comment("是否启用")
|
||||
@Default("1")
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
import org.nutz.integration.json4excel.annotation.J4EIgnore;
|
||||
import org.nutz.integration.json4excel.annotation.J4EName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_user")
|
||||
@TableMeta("{'mysql-charset':'utf8mb4'}")
|
||||
@J4EName("用户数据")
|
||||
@TableIndexes({@Index(name = "INDEX_SYS_USER_LOGINNAMAE", fields = {"loginname"}, unique = true)})
|
||||
public class Sys_user extends BaseModel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("用户名")
|
||||
@J4EName("用户名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 120)
|
||||
private String loginname;
|
||||
|
||||
@Column
|
||||
@Comment("密码")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String password;// transient 修饰符可让此字段不在对象里显示
|
||||
|
||||
@Column
|
||||
@Comment("密码盐")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String salt;
|
||||
|
||||
@Column
|
||||
@Comment("姓名")
|
||||
@J4EName("姓名")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String username;
|
||||
|
||||
@Column
|
||||
@Comment("头像")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String avatar;
|
||||
|
||||
@Column
|
||||
@Comment("是否在线")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean userOnline;
|
||||
|
||||
@Column
|
||||
@Comment("是否禁用")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.BOOLEAN)
|
||||
private boolean disabled;
|
||||
|
||||
@Column
|
||||
@Comment("电子邮箱")
|
||||
@J4EName("电子邮箱")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String email;
|
||||
|
||||
@Column
|
||||
@Comment("手机号码")
|
||||
@J4EName("手机号码")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String mobile;
|
||||
|
||||
@Column
|
||||
@Comment("创建时间")
|
||||
@J4EIgnore
|
||||
@PrevInsert(now = true)
|
||||
private Long createAt;
|
||||
|
||||
@Column
|
||||
@Comment("登陆时间")
|
||||
@J4EIgnore
|
||||
private Long loginAt;
|
||||
|
||||
@Column
|
||||
@Comment("登陆IP")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String loginIp;
|
||||
|
||||
@Column
|
||||
@Comment("登陆次数")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.INT)
|
||||
private Integer loginCount;
|
||||
|
||||
@Column
|
||||
@Comment("登陆SessionId")
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String loginSessionId;
|
||||
|
||||
@Column
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
@J4EIgnore
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String unitPath;
|
||||
|
||||
@One(field = "unitId")
|
||||
@J4EIgnore
|
||||
private Sys_unit unit;
|
||||
|
||||
@ManyMany(from = "userId", relation = "sys_user_role", to = "roleId")
|
||||
@J4EIgnore
|
||||
private List<Sys_role> roles;
|
||||
|
||||
@ManyMany(from = "userId", relation = "sys_user_unit", to = "unitId")
|
||||
@J4EIgnore
|
||||
protected List<Sys_unit> units;
|
||||
|
||||
@J4EIgnore
|
||||
protected List<Sys_menu> menus;
|
||||
|
||||
@J4EIgnore
|
||||
protected List<Sys_menu> firstMenus;
|
||||
|
||||
@J4EIgnore
|
||||
protected Map<String, List<Sys_menu>> secondMenus;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.budwk.app.sys.models;
|
||||
|
||||
import com.budwk.app.base.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.ColDefine;
|
||||
import org.nutz.dao.entity.annotation.ColType;
|
||||
import org.nutz.dao.entity.annotation.Column;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName Sys_role_user
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2025/3/18 上午10:11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("sys_user_role")
|
||||
public class Sys_user_role extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String roleId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String unitId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.sys.models.Sys_api;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
|
||||
public interface SysApiService extends BaseService<Sys_api> {
|
||||
/**
|
||||
* 创建密钥
|
||||
*/
|
||||
void createAppkey(String name, String userId) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除密钥
|
||||
*/
|
||||
void deleteAppkey(String appid) throws Exception;
|
||||
|
||||
/**
|
||||
* 启用禁用
|
||||
*/
|
||||
void updateAppkey(String appid, boolean disabled) throws Exception;
|
||||
|
||||
/**
|
||||
* 通过appid获取appkey
|
||||
*
|
||||
* @param appid appid
|
||||
* @return Sys_api
|
||||
*/
|
||||
String getAppkey(String appid);
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param appid appid
|
||||
*/
|
||||
void deleteCache(String appid);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_app_conf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysAppConfService extends BaseService<Sys_app_conf> {
|
||||
List<String> getConfNameList();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_app_list;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysAppListService extends BaseService<Sys_app_list> {
|
||||
List<String> getAppNameList();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_app_task;
|
||||
|
||||
public interface SysAppTaskService extends BaseService<Sys_app_task> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.sys.models.Sys_config;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/23.
|
||||
*/
|
||||
public interface SysConfigService extends BaseService<Sys_config> {
|
||||
/**
|
||||
* 查询所有数据
|
||||
* @return
|
||||
*/
|
||||
List<Sys_config> getAllList();
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_dict;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SysDictService extends BaseService<Sys_dict> {
|
||||
/**
|
||||
* 通过code获取名称
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
String getNameByCode(String code);
|
||||
|
||||
/**
|
||||
* 通过ID获取名称
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String getNameById(String id);
|
||||
|
||||
/**
|
||||
* 通过树PATH获取子级
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
List<Sys_dict> getSubListByPath(String path);
|
||||
|
||||
/**
|
||||
* 通过ID获取子级
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Sys_dict> getSubListById(String id);
|
||||
|
||||
/**
|
||||
* 通过code获取子级
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<Sys_dict> getSubListByCode(String code);
|
||||
|
||||
/**
|
||||
* 通过树PATH获取子级
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
Map getSubMapByPath(String path);
|
||||
|
||||
/**
|
||||
* 通过ID获取子级
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Map getSubMapById(String id);
|
||||
|
||||
/**
|
||||
* 通过code获取子级
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Map getSubMapByCode(String code);
|
||||
|
||||
/**
|
||||
* 保存数据字典
|
||||
*
|
||||
* @param dict
|
||||
* @param pid
|
||||
*/
|
||||
void save(Sys_dict dict, String pid);
|
||||
|
||||
/**
|
||||
* 级联删除数据
|
||||
*
|
||||
* @param dict
|
||||
*/
|
||||
void deleteAndChild(Sys_dict dict);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.base.page.datatable.DataTableColumn;
|
||||
import com.budwk.app.base.page.datatable.DataTableOrder;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysLogService extends BaseService<Sys_log> {
|
||||
/**
|
||||
* 快速插入日志
|
||||
*
|
||||
* @param syslog
|
||||
*/
|
||||
void fastInsertSysLog(Sys_log syslog);
|
||||
|
||||
/**
|
||||
* 分表查询数据
|
||||
*
|
||||
* @param tableName
|
||||
* @param length
|
||||
* @param start
|
||||
* @param draw
|
||||
* @param orders
|
||||
* @param columns
|
||||
* @param cnd
|
||||
* @param linkName
|
||||
* @return
|
||||
*/
|
||||
NutMap logData(String tableName, int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName);
|
||||
|
||||
/**
|
||||
* 查询日期
|
||||
*
|
||||
* @param tablaeName 分表名称
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 页大小
|
||||
* @param cnd 查询条件
|
||||
* @return
|
||||
*/
|
||||
Pagination data(String tablaeName, int pageNumber, int pageSize, Cnd cnd);
|
||||
|
||||
/**
|
||||
* 多月日志条件查询
|
||||
*
|
||||
* @param date 时间范围
|
||||
* @param type 日志类型
|
||||
* @param pageOrderName 排序字段名称
|
||||
* @param pageOrderBy 排序方式
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 页大小
|
||||
* @return
|
||||
*/
|
||||
Pagination data(String[] date, String type, String pageOrderName, String pageOrderBy, int pageNumber, int pageSize);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysMenuService extends BaseService<Sys_menu> {
|
||||
/**
|
||||
* 保存菜单
|
||||
*
|
||||
* @param menu
|
||||
* @param pid
|
||||
*/
|
||||
void save(Sys_menu menu, String pid, List<NutMap> datas);
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*
|
||||
* @param menu
|
||||
* @param pid
|
||||
*/
|
||||
void edit(Sys_menu menu, String pid, List<NutMap> datas);
|
||||
|
||||
/**
|
||||
* 级联删除菜单
|
||||
*
|
||||
* @param menu
|
||||
*/
|
||||
void deleteAndChild(Sys_menu menu);
|
||||
|
||||
/**
|
||||
* 获取左侧菜单
|
||||
*
|
||||
* @param href
|
||||
* @return
|
||||
*/
|
||||
Sys_menu getLeftMenu(String href);
|
||||
|
||||
/**
|
||||
* 获取左侧菜单路径
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
Sys_menu getLeftPathMenu(List<String> list);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_msg;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysMsgService extends BaseService<Sys_msg> {
|
||||
/**
|
||||
* 保存信息同时发送
|
||||
*
|
||||
* @param sysMsg
|
||||
* @param users
|
||||
*/
|
||||
Sys_msg saveMsg(Sys_msg sysMsg, String[] users);
|
||||
|
||||
/**
|
||||
* 删除消息及消息用户表数据
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteMsg(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 通知客户端弹窗
|
||||
*
|
||||
* @param innerMsg
|
||||
* @param rooms
|
||||
*/
|
||||
void notify(Sys_msg innerMsg, String rooms[]);
|
||||
|
||||
/**
|
||||
* 通知客户端有新消息及消息数量
|
||||
*
|
||||
* @param room 用户名
|
||||
* @param size
|
||||
* @param list
|
||||
*/
|
||||
void innerMsg(String room, int size, List<NutMap> list);
|
||||
|
||||
/**
|
||||
* 获取某用户的未读消息数量及列表
|
||||
*
|
||||
* @param loginname 用户名
|
||||
*/
|
||||
void getMsg(String loginname);
|
||||
|
||||
/**
|
||||
* 通知下线
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @param httpSessionId
|
||||
*/
|
||||
void offline(String loginname, String httpSessionId);
|
||||
|
||||
/**
|
||||
* 向用户发送站内消息
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @param title 标题
|
||||
* @param body 内容
|
||||
* @param sender 发送者
|
||||
*/
|
||||
void sendMsg(String loginname, String title, String body, String sender);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_msg_user;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysMsgUserService extends BaseService<Sys_msg_user> {
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*
|
||||
* @param loginname
|
||||
* @return
|
||||
*/
|
||||
int getUnreadNum(String loginname);
|
||||
|
||||
/**
|
||||
* 获取未读消息列表
|
||||
*
|
||||
* @param loginname
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
List<Sys_msg_user> getUnreadList(String loginname, int pageNumber, int pageSize);
|
||||
|
||||
/**
|
||||
* 删除用户缓存
|
||||
*
|
||||
* @param loginname
|
||||
*/
|
||||
void deleteCache(String loginname);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.models.Sys_role;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysRoleService extends BaseService<Sys_role> {
|
||||
/**
|
||||
* 获取角色权限
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @return
|
||||
*/
|
||||
List<String> getPermissionList(Sys_role role);
|
||||
/**
|
||||
* 通过角色ID获取菜单及数据权限
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getMenusAndButtons(String roleId);
|
||||
|
||||
/**
|
||||
* 通过角色ID获取菜单数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getDatas(String roleId);
|
||||
|
||||
/**
|
||||
* 获取所有菜单数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getDatas();
|
||||
|
||||
/**
|
||||
* 通过角色获取权限标识符
|
||||
*
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
List<String> getPermissionNameList(Sys_role role);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleid
|
||||
*/
|
||||
void del(String roleid);
|
||||
|
||||
/**
|
||||
* 批量删除角色
|
||||
*
|
||||
* @param roleids
|
||||
*/
|
||||
void del(String[] roleids);
|
||||
|
||||
/**
|
||||
* 保存菜单数据
|
||||
* @param menuIds
|
||||
* @param roleId
|
||||
*/
|
||||
void saveMenu(String[] menuIds,String roleId);
|
||||
/**
|
||||
* 通过角色ID和菜单父ID获取下级权限菜单
|
||||
*
|
||||
* @param roleId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getRoleMenus(String roleId, String pid);
|
||||
|
||||
/**
|
||||
* 判断角色是否有下级数据权限
|
||||
*
|
||||
* @param roleId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
boolean hasChildren(String roleId, String pid);
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param roleId
|
||||
* @param keyword
|
||||
* @param isAdmin
|
||||
* @param sysUnit
|
||||
* @return
|
||||
*/
|
||||
Pagination userSearch(String roleId, String keyword, boolean isAdmin, Sys_unit sysUnit);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_route;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/23.
|
||||
*/
|
||||
public interface SysRouteService extends BaseService<Sys_route> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_task;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysTaskService extends BaseService<Sys_task> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysUnitService extends BaseService<Sys_unit> {
|
||||
/**
|
||||
* 保存单位
|
||||
*
|
||||
* @param unit
|
||||
* @param pid
|
||||
*/
|
||||
void save(Sys_unit unit, String pid);
|
||||
|
||||
/**
|
||||
* 级联删除单位及单位下用户
|
||||
*
|
||||
* @param unit
|
||||
*/
|
||||
void deleteAndChild(Sys_unit unit);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.budwk.app.sys.services;
|
||||
|
||||
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
public interface SysUserService extends BaseService<Sys_user> {
|
||||
/**
|
||||
* 获取用户权限标识
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<String> getPermissionList(String userId);
|
||||
|
||||
/**
|
||||
* 查询用户的角色
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
List<String> getRoleCodeList(Sys_user user);
|
||||
|
||||
/**
|
||||
* 通过用户ID获取菜单及权限
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getMenusAndButtons(String userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID获取菜单
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getDatas(String userId);
|
||||
|
||||
/**
|
||||
* 绑定菜单到用户
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
Sys_user fillMenu(Sys_user user);
|
||||
|
||||
/**
|
||||
* 通过用户ID获取菜单
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getMenus(String userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteById(String userId);
|
||||
|
||||
/**
|
||||
* 批量删除用户
|
||||
*
|
||||
* @param userIds
|
||||
*/
|
||||
void deleteByIds(String[] userIds);
|
||||
|
||||
/**
|
||||
* 通过用户ID和菜单父ID获取下级权限菜单
|
||||
*
|
||||
* @param userId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
List<Sys_menu> getRoleMenus(String userId, String pid);
|
||||
|
||||
/**
|
||||
* 判断用户是否有下级数据权限
|
||||
*
|
||||
* @param userId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
boolean hasChildren(String userId, String pid);
|
||||
|
||||
/**
|
||||
* 清除一个用户的缓存
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void deleteCache(String userId);
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
void clearCache();
|
||||
|
||||
/**
|
||||
* 检查用户是否存在
|
||||
*
|
||||
* @param loginname 用户名
|
||||
*/
|
||||
void checkLoginname(String loginname) throws BaseException;
|
||||
|
||||
/**
|
||||
* 检查用户是否存在
|
||||
*
|
||||
* @param mobile 手机号码
|
||||
*/
|
||||
void checkMobile(String mobile) throws BaseException;
|
||||
|
||||
/**
|
||||
* 通过用户名和密码获取用户信息
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @param passowrd 密码
|
||||
* @return
|
||||
* @throws BaseException
|
||||
*/
|
||||
Sys_user loginByPassword(String loginname, String passowrd) throws BaseException;
|
||||
|
||||
/**
|
||||
* 通过短信验证码登录
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @return
|
||||
* @throws BaseException
|
||||
*/
|
||||
Sys_user loginByMobile(String mobile) throws BaseException;
|
||||
|
||||
/**
|
||||
* 通过用户名获取用户信息
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @return
|
||||
* @throws BaseException
|
||||
*/
|
||||
Sys_user getUserByLoginname(String loginname) throws BaseException;
|
||||
|
||||
/**
|
||||
* 通过用户ID获取用户信息
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @return
|
||||
* @throws BaseException
|
||||
*/
|
||||
Sys_user getUserById(String id) throws BaseException;
|
||||
|
||||
/**
|
||||
* 获取登录用户及菜单信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return
|
||||
*/
|
||||
Sys_user getUserAndMenuById(String userId);
|
||||
|
||||
/**
|
||||
* 通过用户名重置密码
|
||||
*
|
||||
* @param loginname 用户名
|
||||
* @param password 新密码
|
||||
* @throws BaseException
|
||||
*/
|
||||
void setPwdByLoginname(String loginname, String password) throws BaseException;
|
||||
|
||||
/**
|
||||
* 通过用户ID重置密码
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @param password 新密码
|
||||
* @throws BaseException
|
||||
*/
|
||||
void setPwdById(String id, String password) throws BaseException;
|
||||
|
||||
/**
|
||||
* 设置用户自定义样式
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @param themeConfig 样式内容
|
||||
*/
|
||||
void setThemeConfig(String id, String themeConfig);
|
||||
|
||||
/**
|
||||
* 更新用户登录信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param ip IP地址
|
||||
*/
|
||||
void setLoginInfo(String userId, String ip);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_api;
|
||||
import com.budwk.app.sys.services.SysApiService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemove;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = RedisConstant.PLATFORM_REDIS_WKCACHE_PREFIX + "sys_api",isHash = true)
|
||||
public class SysApiServiceImpl extends BaseServiceImpl<Sys_api> implements SysApiService {
|
||||
public SysApiServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private String getAppid() {
|
||||
String appid = R.sg(16).next().replaceAll("_", "z");
|
||||
if (this.count(Cnd.where("appid", "=", appid)) > 0) {
|
||||
return getAppid();
|
||||
}
|
||||
return appid;
|
||||
}
|
||||
|
||||
public void createAppkey(String name, String userId) throws Exception {
|
||||
String appid = getAppid();
|
||||
Sys_api sysApi = new Sys_api();
|
||||
sysApi.setName(name);
|
||||
sysApi.setDisabled(false);
|
||||
sysApi.setAppid(appid);
|
||||
sysApi.setAppkey(R.sg(30).next().replaceAll("_", "z"));
|
||||
sysApi.setCreatedBy(userId);
|
||||
sysApi.setCreatedAt(System.currentTimeMillis());
|
||||
this.insert(sysApi);
|
||||
this.getAppkey(appid);//调用生成缓存
|
||||
}
|
||||
|
||||
public void deleteAppkey(String appid) throws Exception {
|
||||
this.delete(appid);
|
||||
this.deleteCache(appid);
|
||||
}
|
||||
|
||||
public void updateAppkey(String appid, boolean disabled) throws Exception {
|
||||
this.update(Chain.make("disabled", disabled), Cnd.where("appid", "=", appid));
|
||||
this.deleteCache(appid);
|
||||
this.getAppkey(appid);//调用生成缓存
|
||||
}
|
||||
|
||||
//注意这个cacheKey 是和 web-api 对应一致的,便于直接从redis取值,而不用依赖sys模块
|
||||
@CacheResult(cacheKey = "${appid}_appkey")
|
||||
public String getAppkey(String appid) {
|
||||
Sys_api sysApi = this.fetch(Cnd.where("appid", "=", appid).and("disabled", "=", false));
|
||||
if (sysApi != null) {
|
||||
return sysApi.getAppkey();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@CacheRemove(cacheKey = "${appid}_*")
|
||||
//可以通过el表达式加 * 通配符来批量删除一批缓存
|
||||
public void deleteCache(String appid) {
|
||||
|
||||
}
|
||||
|
||||
@CacheRemoveAll
|
||||
public void clearCache() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_app_conf;
|
||||
import com.budwk.app.sys.services.SysAppConfService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysAppConfServiceImpl extends BaseServiceImpl<Sys_app_conf> implements SysAppConfService {
|
||||
public SysAppConfServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public List<String> getConfNameList() {
|
||||
Sql sql = Sqls.create("SELECT DISTINCT confName FROM sys_app_conf");
|
||||
sql.setCallback(Sqls.callback.strs());
|
||||
this.dao().execute(sql);
|
||||
return sql.getList(String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_app_list;
|
||||
import com.budwk.app.sys.services.SysAppListService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysAppListServiceImpl extends BaseServiceImpl<Sys_app_list> implements SysAppListService {
|
||||
public SysAppListServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public List<String> getAppNameList() {
|
||||
Sql sql = Sqls.create("SELECT DISTINCT appName FROM sys_app_list");
|
||||
sql.setCallback(Sqls.callback.strs());
|
||||
this.dao().execute(sql);
|
||||
return sql.getList(String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_app_task;
|
||||
import com.budwk.app.sys.services.SysAppTaskService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2019/2/27.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysAppTaskServiceImpl extends BaseServiceImpl<Sys_app_task> implements SysAppTaskService {
|
||||
public SysAppTaskServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_config;
|
||||
import com.budwk.app.sys.services.SysConfigService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/23.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysConfigServiceImpl extends BaseServiceImpl<Sys_config> implements SysConfigService {
|
||||
public SysConfigServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public List<Sys_config> getAllList() {
|
||||
return this.query(Cnd.where("delFlag", "=", false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.sys.services.SysDictService;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_dict;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = RedisConstant.PLATFORM_REDIS_WKCACHE_PREFIX + "sys_dict",isHash = true)
|
||||
public class SysDictServiceImpl extends BaseServiceImpl<Sys_dict> implements SysDictService {
|
||||
public SysDictServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获取name
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public String getNameByCode(String code) {
|
||||
Sys_dict dict = this.fetch(Cnd.where("code", "=", code));
|
||||
return dict == null ? "" : dict.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id获取name
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public String getNameById(String id) {
|
||||
Sys_dict dict = this.fetch(id);
|
||||
return dict == null ? "" : dict.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过树path获取下级列表
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public List<Sys_dict> getSubListByPath(String path) {
|
||||
return this.query(Cnd.where("path", "like", Strings.sNull(path) + "____").asc("location"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过父id获取下级列表
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public List<Sys_dict> getSubListById(String id) {
|
||||
return this.query(Cnd.where("parentId", "=", Strings.sNull(id)).asc("location"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获取下级列表
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public List<Sys_dict> getSubListByCode(String code) {
|
||||
Sys_dict dict = this.fetch(Cnd.where("code", "=", code));
|
||||
return dict == null ? new ArrayList<>() : this.query(Cnd.where("parentId", "=", Strings.sNull(dict.getId())).asc("location"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过path获取下级map
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public Map getSubMapByPath(String path) {
|
||||
return this.getMap(Sqls.create("select code,name from sys_dict where path like @path order by location asc").setParam("path", path + "____"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id获取下级map
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public Map getSubMapById(String id) {
|
||||
return this.getMap(Sqls.create("select code,name from sys_dict where parentId = @id order by location asc").setParam("id", id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获取下级map
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public Map getSubMapByCode(String code) {
|
||||
Sys_dict dict = this.fetch(Cnd.where("code", "=", code));
|
||||
return dict == null ? new HashMap() : this.getMap(Sqls.create("select code,name from sys_dict where parentId = @id order by location asc").setParam("id", dict.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典
|
||||
*
|
||||
* @param dict
|
||||
* @param pid
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void save(Sys_dict dict, String pid) {
|
||||
String path = "";
|
||||
if (!Strings.isEmpty(pid)) {
|
||||
Sys_dict pp = this.fetch(pid);
|
||||
path = pp.getPath();
|
||||
}
|
||||
dict.setPath(getSubPath("sys_dict", "path", path));
|
||||
dict.setParentId(pid);
|
||||
dao().insert(dict);
|
||||
if (!Strings.isEmpty(pid)) {
|
||||
this.update(Chain.make("hasChildren", true), Cnd.where("id", "=", pid));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 级联删除单位
|
||||
*
|
||||
* @param dict
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void deleteAndChild(Sys_dict dict) {
|
||||
dao().execute(Sqls.create("delete from sys_dict where path like @path").setParam("path", dict.getPath() + "%"));
|
||||
if (!Strings.isEmpty(dict.getParentId())) {
|
||||
int count = count(Cnd.where("parentId", "=", dict.getParentId()));
|
||||
if (count < 1) {
|
||||
dao().execute(Sqls.create("update sys_dict set hasChildren=0 where id=@pid").setParam("pid", dict.getParentId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CacheRemoveAll
|
||||
public void clearCache() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.sys.services.SysLogService;
|
||||
import com.budwk.app.base.page.datatable.DataTableColumn;
|
||||
import com.budwk.app.base.page.datatable.DataTableOrder;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_log;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysLogServiceImpl extends BaseServiceImpl<Sys_log> implements SysLogService {
|
||||
public SysLogServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按月分表的dao实例
|
||||
*/
|
||||
protected Map<String, Dao> ymDaos = new HashMap<String, Dao>();
|
||||
|
||||
/**
|
||||
* 获取按月分表的Dao实例,即当前日期的dao实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Dao logDao() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
String key = String.format("%d%02d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1);
|
||||
return logDao(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特定月份的Dao实例
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Dao logDao(String key) {
|
||||
Dao dao = ymDaos.get(key);
|
||||
if (dao == null) {
|
||||
synchronized (this) {
|
||||
dao = ymDaos.get(key);
|
||||
if (dao == null) {
|
||||
dao = Daos.ext(this.dao(), key);
|
||||
dao.create(Sys_log.class, false);
|
||||
ymDaos.put(key, dao);
|
||||
try {
|
||||
Daos.migration(dao, Sys_log.class, true, false);
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dao;
|
||||
}
|
||||
|
||||
@Async
|
||||
public void fastInsertSysLog(Sys_log syslog) {
|
||||
logDao().insert(syslog);
|
||||
}
|
||||
|
||||
public NutMap logData(String tableName, int length, int start, int draw, List<DataTableOrder> orders, List<DataTableColumn> columns, Cnd cnd, String linkName) {
|
||||
if (logDao(tableName).exists(Sys_log.class)) {
|
||||
SysLogService sysLogService2 = new SysLogServiceImpl(logDao(tableName));
|
||||
return sysLogService2.data(length, start, draw, orders, columns, cnd, null);
|
||||
} else
|
||||
return this.data(length, start, draw, orders, columns, cnd, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询日期
|
||||
*
|
||||
* @param tablaeName 分表名称
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 页大小
|
||||
* @param cnd 查询条件
|
||||
* @return
|
||||
*/
|
||||
public Pagination data(String tablaeName, int pageNumber, int pageSize, Cnd cnd) {
|
||||
Pager pager = this.logDao(tablaeName).createPager(pageNumber, pageSize);
|
||||
List<Sys_log> list = this.logDao(tablaeName).query(this.getEntityClass(), cnd, pager);
|
||||
pager.setRecordCount(this.logDao(tablaeName).count(this.getEntityClass(), cnd));
|
||||
return new Pagination(pageNumber, pageSize, pager.getRecordCount(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多月日志条件查询
|
||||
*
|
||||
* @param date 时间范围
|
||||
* @param type 日志类型
|
||||
* @param pageOrderName 排序字段名称
|
||||
* @param pageOrderBy 排序方式
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 页大小
|
||||
* @return
|
||||
*/
|
||||
public Pagination data(String[] date, String type, String pageOrderName, String pageOrderBy, int pageNumber, int pageSize) {
|
||||
String tableName = Times.format("yyyyMM", new Date());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("select sl.* from (");
|
||||
if (date == null || date.length == 0) {
|
||||
stringBuilder.append(" select * from sys_log_" + tableName);
|
||||
if (Strings.isNotBlank(type)) {
|
||||
stringBuilder.append(" where type='" + type + "'");
|
||||
}
|
||||
} else {
|
||||
int m1 = NumberUtils.toInt(Times.format("yyyyMM", Times.D(date[0])));
|
||||
int m2 = NumberUtils.toInt(Times.format("yyyyMM", Times.D(date[1])));
|
||||
if (m1 == m2) {
|
||||
stringBuilder.append(" select * from sys_log_" + m1 + " where 1=1 ");
|
||||
if (Strings.isNotBlank(type)) {
|
||||
stringBuilder.append(" and type='" + type + "'");
|
||||
}
|
||||
stringBuilder.append(" and createdAt>=" + Times.d2TS(Times.D(date[0])));
|
||||
stringBuilder.append(" and createdAt<=" + Times.d2TS(Times.D(date[1])));
|
||||
} else {
|
||||
for (int i = m1; i < m2 + 1; i++) {
|
||||
if (this.dao().exists("sys_log_" + i)) {
|
||||
stringBuilder.append(" select * from sys_log_" + i + " where 1=1 ");
|
||||
if (Strings.isNotBlank(type)) {
|
||||
stringBuilder.append(" and type='" + type + "'");
|
||||
}
|
||||
stringBuilder.append(" and createdAt>=" + Times.d2TS(Times.D(date[0])));
|
||||
stringBuilder.append(" and createdAt<=" + Times.d2TS(Times.D(date[1])));
|
||||
if (i < m2) {
|
||||
stringBuilder.append(" UNION ALL ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuilder.append(")sl ");
|
||||
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
|
||||
stringBuilder.append(" order by sl." + pageOrderName + " " + pageOrderBy);
|
||||
}
|
||||
return this.listPage(pageNumber, pageSize, Sqls.create(stringBuilder.toString()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = RedisConstant.PLATFORM_REDIS_WKCACHE_PREFIX + "sys_menu",isHash = true)
|
||||
public class SysMenuServiceImpl extends BaseServiceImpl<Sys_menu> implements SysMenuService {
|
||||
public SysMenuServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
* 新增菜单
|
||||
*
|
||||
* @param menu
|
||||
* @param pid
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void save(Sys_menu menu, String pid, List<NutMap> datas) {
|
||||
String path = "";
|
||||
if (!Strings.isEmpty(pid)) {
|
||||
Sys_menu pp = this.fetch(pid);
|
||||
path = pp.getPath();
|
||||
} else pid = "";
|
||||
menu.setPath(getSubPath("sys_menu", "path", path));
|
||||
menu.setParentId(pid);
|
||||
dao().insert(menu);
|
||||
if (!Strings.isEmpty(pid) && "menu".equals(menu.getType())) {
|
||||
this.update(Chain.make("hasChildren", true), Cnd.where("id", "=", pid));
|
||||
}
|
||||
if (datas != null) {
|
||||
for (NutMap map : datas) {
|
||||
Sys_menu m = new Sys_menu();
|
||||
m.setParentId(menu.getId());
|
||||
m.setHasChildren(false);
|
||||
m.setShowit(false);
|
||||
m.setLocation(0);
|
||||
m.setType("data");
|
||||
m.setPermission(map.getString("permission", ""));
|
||||
m.setName(map.getString("name", ""));
|
||||
m.setPath(getSubPath("sys_menu", "path", menu.getPath()));
|
||||
m.setCreatedBy(menu.getCreatedBy());
|
||||
if (Strings.isNotBlank(m.getPermission()))
|
||||
dao().insert(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
*
|
||||
* @param menu
|
||||
* @param pid
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void edit(Sys_menu menu, String pid, List<NutMap> datas) {
|
||||
this.updateIgnoreNull(menu);
|
||||
if (datas == null || datas.size() == 0) {
|
||||
//如果子权限是空,那就清空咯
|
||||
this.clear(Cnd.where("type", "=", "data").and("parentId", "=", menu.getId()));
|
||||
} else {
|
||||
List<String> notInIds = new ArrayList<>();
|
||||
for (NutMap map : datas) {
|
||||
String id = map.getString("key", "");
|
||||
Sys_menu d = this.fetch(id);
|
||||
if (d != null) {
|
||||
d.setPermission(map.getString("permission", ""));
|
||||
d.setName(map.getString("name", ""));
|
||||
this.updateIgnoreNull(d);
|
||||
notInIds.add(d.getId());
|
||||
} else {
|
||||
Sys_menu m = new Sys_menu();
|
||||
m.setParentId(menu.getId());
|
||||
m.setHasChildren(false);
|
||||
m.setShowit(false);
|
||||
m.setLocation(0);
|
||||
m.setType("data");
|
||||
m.setPermission(map.getString("permission", ""));
|
||||
m.setName(map.getString("name", ""));
|
||||
m.setPath(getSubPath("sys_menu", "path", menu.getPath()));
|
||||
m.setCreatedBy(menu.getCreatedBy());
|
||||
if (Strings.isNotBlank(m.getPermission()))
|
||||
this.insert(m);
|
||||
notInIds.add(m.getId());
|
||||
}
|
||||
}
|
||||
if (notInIds.size() > 0) {
|
||||
//删除不在提交表单里的权限数据,注意查询条件,别把子菜单给删了
|
||||
this.clear(Cnd.where("id", "not in", notInIds).and("type", "=", "data").and("parentId", "=", menu.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 级联删除菜单
|
||||
*
|
||||
* @param menu
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void deleteAndChild(Sys_menu menu) {
|
||||
dao().execute(Sqls.create("delete from sys_menu where path like @path").setParam("path", menu.getPath() + "%"));
|
||||
dao().execute(Sqls.create("delete from sys_role_menu where menuId=@id or menuId in(SELECT id FROM sys_menu WHERE path like @path)").setParam("id", menu.getId()).setParam("path", menu.getPath() + "%"));
|
||||
if (!Strings.isEmpty(menu.getParentId())) {
|
||||
int count = count(Cnd.where("parentId", "=", menu.getParentId()));
|
||||
if (count < 1) {
|
||||
dao().execute(Sqls.create("update sys_menu set hasChildren=false where id=@pid").setParam("pid", menu.getParentId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CacheResult
|
||||
public Sys_menu getLeftMenu(String href) {
|
||||
return this.fetch(Cnd.where("href", "=", href));
|
||||
}
|
||||
|
||||
@CacheResult
|
||||
public Sys_menu getLeftPathMenu(List<String> list) {
|
||||
return this.fetch(Cnd.where("href", "in", list).desc("href").desc("path"));
|
||||
}
|
||||
|
||||
|
||||
@CacheRemoveAll
|
||||
public void clearCache() {
|
||||
sysRoleService.clearCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_msg;
|
||||
import com.budwk.app.sys.models.Sys_msg_user;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.sys.services.SysMsgService;
|
||||
import com.budwk.app.sys.services.SysMsgUserService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.integration.jedis.JedisAgent;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.integration.jedis.pubsub.PubSubService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.Times;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import redis.clients.jedis.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysMsgServiceImpl extends BaseServiceImpl<Sys_msg> implements SysMsgService {
|
||||
public SysMsgServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
private static final Log log = Logs.get();
|
||||
@Inject
|
||||
private SysMsgUserService sysMsgUserService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
@Inject
|
||||
private JedisAgent jedisAgent;
|
||||
@Inject
|
||||
private PubSubService pubSubService;
|
||||
|
||||
private static NutMap typeMap = NutMap.NEW().addv("system", "系统消息").addv("user", "用户消息");
|
||||
|
||||
public Sys_msg saveMsg(Sys_msg sysMsg, String[] users) {
|
||||
Sys_msg dbMsg = this.insert(sysMsg);
|
||||
if (dbMsg != null) {
|
||||
if ("user".equals(dbMsg.getType()) && users != null) {
|
||||
for (String loginname : users) {
|
||||
Sys_msg_user sys_msg_user = new Sys_msg_user();
|
||||
sys_msg_user.setMsgId(dbMsg.getId());
|
||||
sys_msg_user.setStatus(0);
|
||||
sys_msg_user.setLoginname(loginname);
|
||||
sysMsgUserService.insert(sys_msg_user);
|
||||
}
|
||||
}
|
||||
if ("system".equals(dbMsg.getType())) {
|
||||
Cnd cnd = Cnd.where("disabled", "=", false).and("delFlag", "=", false);
|
||||
int total = sysUserService.count(cnd);
|
||||
int size = 1000;
|
||||
Pagination pagination = new Pagination();
|
||||
pagination.setTotalCount(total);
|
||||
pagination.setPageSize(size);
|
||||
for (int i = 1; i <= pagination.getTotalPage(); i++) {
|
||||
Pagination pagination2 = sysUserService.listPage(i, size, cnd);
|
||||
for (Object sysUser : pagination2.getList()) {
|
||||
Sys_user user = (Sys_user) sysUser;
|
||||
Sys_msg_user sys_msg_user = new Sys_msg_user();
|
||||
sys_msg_user.setMsgId(dbMsg.getId());
|
||||
sys_msg_user.setStatus(0);
|
||||
sys_msg_user.setLoginname(user.getLoginname());
|
||||
sysMsgUserService.insert(sys_msg_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sysMsgUserService.clearCache();
|
||||
notify(dbMsg, users);
|
||||
return dbMsg;
|
||||
}
|
||||
|
||||
public void deleteMsg(String id) {
|
||||
this.vDelete(id);
|
||||
sysMsgUserService.vDelete(Cnd.where("msgId", "=", id));
|
||||
sysMsgUserService.clearCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void notify(Sys_msg innerMsg, String rooms[]) {
|
||||
String url = "/platform/sys/msg/user/all";
|
||||
if (Strings.isNotBlank(innerMsg.getUrl())) {
|
||||
url = innerMsg.getUrl();
|
||||
}
|
||||
NutMap map = new NutMap();
|
||||
map.put("action", "notify");
|
||||
map.put("title", "您有新的消息");
|
||||
map.put("body", innerMsg.getTitle());
|
||||
map.put("url", url);
|
||||
String msg = Json.toJson(map, JsonFormat.compact());
|
||||
if ("system".equals(innerMsg.getType())) {//系统消息发送给所有在线用户
|
||||
if (jedisAgent.isClusterMode()) {
|
||||
JedisCluster jedisCluster = jedisAgent.getJedisClusterWrapper().getJedisCluster();
|
||||
for (JedisPool pool : jedisCluster.getClusterNodes().values()) {
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + "*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = jedis.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String room : scan.getResult()) {
|
||||
pubSubService.fire(room, msg);
|
||||
getMsg(room.split(":")[2]);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + "*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = redisService.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String room : scan.getResult()) {
|
||||
pubSubService.fire(room, msg);
|
||||
getMsg(room.split(":")[2]);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
} else if ("user".equals(innerMsg.getType())) {//用户消息发送给指定在线用户
|
||||
for (String room : rooms) {
|
||||
getMsg(room);
|
||||
if (jedisAgent.isClusterMode()) {
|
||||
JedisCluster jedisCluster = jedisAgent.getJedisClusterWrapper().getJedisCluster();
|
||||
for (JedisPool pool : jedisCluster.getClusterNodes().values()) {
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + room + ":*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = jedis.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String key : scan.getResult()) {
|
||||
pubSubService.fire(key, msg);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + room + ":*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = redisService.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String key : scan.getResult()) {
|
||||
pubSubService.fire(key, msg);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void innerMsg(String room, int size, List<NutMap> list) {
|
||||
NutMap map = new NutMap();
|
||||
map.put("action", "innerMsg");
|
||||
map.put("size", size);//未读消息数
|
||||
map.put("list", list);//最新3条消息列表 type--系统消息/用户消息 title--标题 time--时间戳
|
||||
String msg = Json.toJson(map, JsonFormat.compact());
|
||||
log.debug("msg::::" + msg);
|
||||
if (jedisAgent.isClusterMode()) {
|
||||
JedisCluster jedisCluster = jedisAgent.getJedisClusterWrapper().getJedisCluster();
|
||||
for (JedisPool pool : jedisCluster.getClusterNodes().values()) {
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + room + ":*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = jedis.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String key : scan.getResult()) {
|
||||
pubSubService.fire(key, msg);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ScanParams match = new ScanParams().match(RedisConstant.REDIS_KEY_WSROOM + room + ":*");
|
||||
ScanResult<String> scan = null;
|
||||
do {
|
||||
scan = redisService.scan(scan == null ? ScanParams.SCAN_POINTER_START : scan.getStringCursor(), match);
|
||||
for (String key : scan.getResult()) {
|
||||
pubSubService.fire(key, msg);
|
||||
}
|
||||
} while (!scan.isCompleteIteration());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void getMsg(String loginname) {
|
||||
try {
|
||||
//通过用户名查询未读消息
|
||||
int size = sysMsgUserService.getUnreadNum(loginname);
|
||||
List<Sys_msg_user> list = sysMsgUserService.getUnreadList(loginname, 1, 5);
|
||||
List<NutMap> mapList = new ArrayList<>();
|
||||
for (Sys_msg_user msgUser : list) {
|
||||
String url = "/platform/sys/msg/user/all/detail/" + msgUser.getMsgId();
|
||||
if (Strings.isNotBlank(msgUser.getMsg().getUrl())) {
|
||||
url = msgUser.getMsg().getUrl();
|
||||
}
|
||||
mapList.add(NutMap.NEW().addv("msgId", msgUser.getMsgId()).addv("type", typeMap.getString(msgUser.getMsg().getType()))
|
||||
.addv("title", msgUser.getMsg().getTitle())
|
||||
.addv("url", url)
|
||||
.addv("time", Times.format("yyyy-MM-dd HH:mm", Times.D(1000 * msgUser.getMsg().getSendAt()))));
|
||||
}
|
||||
innerMsg(loginname, size, mapList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void offline(String room, String userToken) {
|
||||
NutMap map = new NutMap();
|
||||
map.put("action", "offline");
|
||||
String msg = Json.toJson(map, JsonFormat.compact());
|
||||
try {
|
||||
room = RedisConstant.REDIS_KEY_WSROOM + room + ":" + userToken;
|
||||
log.debugf("offline room(name=%s)", room);
|
||||
pubSubService.fire(room, msg);
|
||||
redisService.expire(room, 60 * 3);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMsg(String loginname, String title, String body, String sender) {
|
||||
Sys_msg sysMsg = new Sys_msg();
|
||||
sysMsg.setTitle(title);
|
||||
sysMsg.setNote(body);
|
||||
sysMsg.setSendAt(Times.getTS());
|
||||
sysMsg.setCreatedBy(sender);
|
||||
this.saveMsg(sysMsg, new String[]{loginname});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_msg_user;
|
||||
import com.budwk.app.sys.services.SysMsgUserService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemove;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = RedisConstant.PLATFORM_REDIS_WKCACHE_PREFIX + "sys_msg_user",isHash = true)
|
||||
public class SysMsgUserServiceImpl extends BaseServiceImpl<Sys_msg_user> implements SysMsgUserService {
|
||||
public SysMsgUserServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*
|
||||
* @param loginname
|
||||
* @return
|
||||
*/
|
||||
@CacheResult(cacheKey = "${args[0]}_getUnreadNum")
|
||||
public int getUnreadNum(String loginname) {
|
||||
int size = this.count(Cnd.where("delFlag", "=", false).and("loginname", "=", loginname)
|
||||
.and("status", "=", 0));
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息列表
|
||||
*
|
||||
* @param loginname
|
||||
* @param pageNumber
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@CacheResult(cacheKey = "${args[0]}_getUnreadList", ignoreNull = true)
|
||||
public List<Sys_msg_user> getUnreadList(String loginname, int pageNumber, int pageSize) {
|
||||
return this.query(Cnd.where("delFlag", "=", false).and("loginname", "=", loginname).and("status", "=", 0)
|
||||
.desc("createdAt"), "msg", Cnd.orderBy().desc("sendAt"), new Pager().setPageNumber(pageNumber).setPageSize(pageSize));
|
||||
}
|
||||
|
||||
@CacheRemove(cacheKey = "${args[0]}_*")
|
||||
//可以通过el表达式加 * 通配符来批量删除一批缓存
|
||||
public void deleteCache(String loginname) {
|
||||
|
||||
}
|
||||
|
||||
@CacheRemoveAll
|
||||
public void clearCache() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.constant.RedisConstant;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_menu;
|
||||
import com.budwk.app.sys.models.Sys_role;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.*;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheRemoveAll;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/22.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@CacheDefaults(cacheName = RedisConstant.PLATFORM_REDIS_WKCACHE_PREFIX + "sys_role",isHash = true)
|
||||
public class SysRoleServiceImpl extends BaseServiceImpl<Sys_role> implements SysRoleService {
|
||||
public SysRoleServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private SysMenuService sysMenuService;
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public List<String> getPermissionList(Sys_role role) {
|
||||
this.fetchLinks(role, "menus", Cnd.where("disabled", "=", false));
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Sys_menu menu : role.getMenus()) {
|
||||
if (!Strings.isEmpty(menu.getPermission())) {
|
||||
list.add(menu.getPermission());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@CacheResult
|
||||
public List<Sys_menu> getMenusAndButtons(String roleId) {
|
||||
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
|
||||
" b.roleId=@roleId and a.disabled=@f order by a.location ASC,a.path asc");
|
||||
sql.params().set("roleId", roleId);
|
||||
sql.params().set("f", false);
|
||||
return sysMenuService.listEntity(sql);
|
||||
}
|
||||
|
||||
@CacheResult
|
||||
public List<Sys_menu> getDatas(String roleId) {
|
||||
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
|
||||
" b.roleId=@roleId and a.type='data' and a.disabled=@f order by a.location ASC,a.path asc");
|
||||
sql.params().set("roleId", roleId);
|
||||
sql.params().set("f", false);
|
||||
return sysMenuService.listEntity(sql);
|
||||
}
|
||||
|
||||
@CacheResult
|
||||
public List<Sys_menu> getDatas() {
|
||||
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and a.type='data' order by a.location ASC,a.path asc");
|
||||
return sysMenuService.listEntity(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限
|
||||
*
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
//如果传参是对象,那么要取字符串做为cacheKey值,因为对象的标识是变动的
|
||||
@CacheResult(cacheKey = "${args[0].id}_getPermissionNameList")
|
||||
public List<String> getPermissionNameList(Sys_role role) {
|
||||
dao().fetchLinks(role, "menus");
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Sys_menu menu : role.getMenus()) {
|
||||
if (!Strings.isEmpty(menu.getPermission()) && !menu.isDisabled()) {
|
||||
list.add(menu.getPermission());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void del(String roleid) {
|
||||
this.dao().clear("sys_user_role", Cnd.where("roleId", "=", roleid));
|
||||
this.dao().clear("sys_role_menu", Cnd.where("roleId", "=", roleid));
|
||||
this.delete(roleid);
|
||||
}
|
||||
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void del(String[] roleids) {
|
||||
this.dao().clear("sys_user_role", Cnd.where("roleId", "in", roleids));
|
||||
this.dao().clear("sys_role_menu", Cnd.where("roleId", "in", roleids));
|
||||
this.delete(roleids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存菜单数据
|
||||
*
|
||||
* @param menuIds
|
||||
* @param roleId
|
||||
*/
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void saveMenu(String[] menuIds, String roleId) {
|
||||
this.clear("sys_role_menu", Cnd.where("roleId", "=", roleId));
|
||||
for (String s : menuIds) {
|
||||
this.insert("sys_role_menu", Chain.make("roleId", roleId).add("menuId", s));
|
||||
Sys_menu menu = sysMenuService.fetch(s);
|
||||
//要把上级菜单插入关联表
|
||||
for (int i = 4; i < menu.getPath().length(); i = i + 4) {
|
||||
Sys_menu tMenu = sysMenuService.fetch(Cnd.where("path", "=", menu.getPath().substring(0, i)));
|
||||
int c = this.count("sys_role_menu", Cnd.where("roleId", "=", roleId).and("menuId", "=", tMenu.getId()));
|
||||
if (c == 0) {
|
||||
this.insert("sys_role_menu", Chain.make("roleId", roleId).add("menuId", tMenu.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.clearCache();
|
||||
sysUserService.clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public List<Sys_menu> getRoleMenus(String roleId, String pid) {
|
||||
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and " +
|
||||
"$m and b.roleId=@roleId and a.disabled=@f order by a.location ASC,a.path asc");
|
||||
sql.params().set("roleId", roleId);
|
||||
sql.params().set("f", false);
|
||||
if (Strings.isNotBlank(pid)) {
|
||||
sql.vars().set("m", "a.parentId='" + pid + "'");
|
||||
} else {
|
||||
sql.vars().set("m", "(a.parentId='' or a.parentId is null)");
|
||||
}
|
||||
return sysMenuService.listEntity(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param roleId
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
@CacheResult
|
||||
public boolean hasChildren(String roleId, String pid) {
|
||||
Sql sql = Sqls.create("select count(*) from sys_menu a,sys_role_menu b where a.id=b.menuId and " +
|
||||
"$m and b.roleId=@roleId and a.disabled=@f order by a.location ASC,a.path asc");
|
||||
sql.params().set("roleId", roleId);
|
||||
sql.params().set("f", false);
|
||||
if (Strings.isNotBlank(pid)) {
|
||||
sql.vars().set("m", "a.parentId='" + pid + "'");
|
||||
} else {
|
||||
sql.vars().set("m", "(a.parentId='' or a.parentId is null)");
|
||||
}
|
||||
return sysMenuService.count(sql) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param roleId
|
||||
* @param keyword
|
||||
* @param isAdmin
|
||||
* @param sysUnit
|
||||
* @return
|
||||
*/
|
||||
public Pagination userSearch(String roleId, String keyword, boolean isAdmin, Sys_unit sysUnit) {
|
||||
Sql sql;
|
||||
if (DB.ORACLE.name().equals(this.dao().getJdbcExpert().getDatabaseType()) || DB.DM.name().equals(this.dao().getJdbcExpert().getDatabaseType())) {
|
||||
//拼接字符串兼容oracle
|
||||
sql = Sqls.create("SELECT a.id AS VALUE,a.loginname||'('||a.username||')' AS label,a.disabled,a.unitid,b.name as unitname FROM sys_user a,sys_unit b WHERE a.unitid=b.id and a.id NOT IN(SELECT b.userId FROM sys_user_role b WHERE b.roleId=@roleId) $s1 $s2 order by a.createdAt desc");
|
||||
} else {
|
||||
sql = Sqls.create("SELECT a.id AS VALUE,CONCAT(a.loginname,'(',a.username,')') AS label,a.disabled,a.unitid,b.name as unitname FROM sys_user a,sys_unit b WHERE a.unitid=b.id and a.id NOT IN(SELECT b.userId FROM sys_user_role b WHERE b.roleId=@roleId) $s1 $s2 order by a.createdAt desc");
|
||||
}
|
||||
sql.params().set("roleId", roleId);
|
||||
if (!isAdmin) {
|
||||
//非超级管理员只可查询本单位及下级单位用户
|
||||
String menuPath = sysUnit.getPath();
|
||||
sql.vars().set("s1", " and b.path like '" + menuPath + "%'");
|
||||
}
|
||||
if (Strings.isNotBlank(keyword)) {
|
||||
sql.vars().set("s2", " and (a.loginname like '%" + keyword + "%' or a.username like '%" + keyword + "%')");
|
||||
}
|
||||
return this.listPage(1, 10, sql);
|
||||
}
|
||||
|
||||
@CacheRemoveAll
|
||||
public void clearCache() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.budwk.app.sys.services.impl;
|
||||
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_route;
|
||||
import com.budwk.app.sys.services.SysRouteService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/12/23.
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SysRouteServiceImpl extends BaseServiceImpl<Sys_route> implements SysRouteService {
|
||||
public SysRouteServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user