first commit
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
.svn
|
||||
.idea
|
||||
target
|
||||
|
||||
|
||||
mini.iws
|
||||
|
||||
mini.iml
|
||||
|
||||
mini.ipr
|
||||
|
||||
src/main/resources/application.properties
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,182 @@
|
||||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.v</groupId>
|
||||
<artifactId>mini</artifactId>
|
||||
<version>5.3.0</version>
|
||||
<description>java web development framework, base on budwk and nutz</description>
|
||||
<url>https://budwk.com</url>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>wizzercn</id>
|
||||
<name>Wizzer</name>
|
||||
<email>wizzer@qq.com</email>
|
||||
<url>https://wizzer.cn</url>
|
||||
</developer>
|
||||
</developers>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>14</source>
|
||||
<target>14</target>
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<charset>UTF-8</charset>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<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>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nutz</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/libs-release</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
<id>nutz-snapshots</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
<id>nutz-snapshots</id>
|
||||
<url>https://jfrog.nutz.cn/artifactory/snapshots</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-test-junit4</artifactId>
|
||||
<version>2.4.2-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
<properties>
|
||||
<mysql-connector-java.version>8.0.16</mysql-connector-java.version>
|
||||
<jetty.version>9.4.47.v20220610</jetty.version>
|
||||
<emoji-java.veision>4.0.0</emoji-java.veision>
|
||||
<pinyin4j.version>2.5.1</pinyin4j.version>
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<poitl.version>1.9.1</poitl.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<v.version>1.0.1</v.version>
|
||||
<emoji-java.version>4.0.0</emoji-java.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<nutzwk.version>5.2.6</nutzwk.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<hutool-all.version>5.7.20</hutool-all.version>
|
||||
<pinyin4j.veision>2.5.1</pinyin4j.veision>
|
||||
<openoffice.version>4.1.2</openoffice.version>
|
||||
<nutz.version>1.r.68-SNAPSHOT</nutz.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<tencentcloud-sdk-java.version>4.0.11</tencentcloud-sdk-java.version>
|
||||
<commons-io.version>2.4</commons-io.version>
|
||||
<easypoi.version>4.5.0</easypoi.version>
|
||||
<java.version>15</java.version>
|
||||
<jsoup.veision>1.12.1</jsoup.veision>
|
||||
<jsoup.version>1.12.1</jsoup.version>
|
||||
<easy-captcha.version>1.6.2</easy-captcha.version>
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
<jodconverter.version>2.2.2</jodconverter.version>
|
||||
<nutzboot.version>2.4.2-SNAPSHOT</nutzboot.version>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -0,0 +1,859 @@
|
||||
<?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>io.v</groupId>
|
||||
<artifactId>mini</artifactId>
|
||||
<version>5.3.0</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>15</java.version>
|
||||
<nutzwk.version>5.2.6</nutzwk.version>
|
||||
<nutzboot.version>2.4.2-SNAPSHOT</nutzboot.version>
|
||||
<nutz.version>1.r.68-SNAPSHOT</nutz.version>
|
||||
<mysql-connector-java.version>8.0.16</mysql-connector-java.version>
|
||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<emoji-java.version>4.0.0</emoji-java.version>
|
||||
<jsoup.version>1.12.1</jsoup.version>
|
||||
<pinyin4j.version>2.5.1</pinyin4j.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<easy-captcha.version>1.6.2</easy-captcha.version>
|
||||
<tencentcloud-sdk-java.version>4.0.11</tencentcloud-sdk-java.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
<v.version>1.0.1</v.version>
|
||||
<hutool-all.version>5.7.20</hutool-all.version>
|
||||
<jodconverter.version>2.2.2</jodconverter.version>
|
||||
<openoffice.version>4.1.2</openoffice.version>
|
||||
<emoji-java.veision>4.0.0</emoji-java.veision>
|
||||
<pinyin4j.veision>2.5.1</pinyin4j.veision>
|
||||
<commons-io.version>2.4</commons-io.version>
|
||||
<jsoup.veision>1.12.1</jsoup.veision>
|
||||
<poitl.version>1.9.1</poitl.version>
|
||||
<easypoi.version>4.5.0</easypoi.version>
|
||||
<jetty.version>9.4.47.v20220610</jetty.version>
|
||||
</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>cn.smallbun.screw</groupId>
|
||||
<artifactId>screw-core</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>4.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.wizzer</groupId>
|
||||
<artifactId>wk-framework</artifactId>
|
||||
<version>${nutzwk.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-nutz-mvc</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-jetty</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-nutz-dao</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>druid</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-jdbc</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-redis</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-wkcache</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-starter-redis</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-shiro</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<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>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-words</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
<!--xlsx或xls转pdf-->
|
||||
<dependency>
|
||||
<groupId>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-cells</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
<!--ppt转pdf-->
|
||||
<dependency>
|
||||
<groupId>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-slides</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-test-junit4</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-logback-exts</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-starter-redis</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutzboot-starter-ftp</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>nutzboot-core</artifactId>
|
||||
<groupId>org.nutz</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
<!--hutool-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- 转pdf用 -->
|
||||
<dependency>
|
||||
<groupId>com.artofsolving</groupId>
|
||||
<artifactId>jodconverter</artifactId>
|
||||
<version>${jodconverter.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>juh</artifactId>
|
||||
<groupId>org.openoffice</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>ridl</artifactId>
|
||||
<groupId>org.openoffice</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>unoil</artifactId>
|
||||
<groupId>org.openoffice</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>juh</artifactId>
|
||||
<version>${openoffice.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>jurt</artifactId>
|
||||
<version>${openoffice.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>ridl</artifactId>
|
||||
<version>${openoffice.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>unoil</artifactId>
|
||||
<version>${openoffice.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<version>${emoji-java.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>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</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.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 导出导入 文档/excel 用 -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<version>${easypoi.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-web</artifactId>
|
||||
<version>${easypoi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>${poitl.version}</version>
|
||||
<exclusions><!-- 手动排除依赖,瘦身 -->
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>7.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm-all</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
<version>15.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>darabonba-java-core</artifactId>
|
||||
<version>0.1.5-beta</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibabacloud-dysmsapi20170525</artifactId>
|
||||
<version>2.0.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.draco1023</groupId>
|
||||
<artifactId>poi-tl-ext</artifactId>
|
||||
<version>0.3.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</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>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ws.schild</groupId>
|
||||
<artifactId>jave-all-deps</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>vod_api</artifactId>
|
||||
<version>2.1.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<groupId>commons-codec</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.56</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-cas</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<version>${tencentcloud-sdk-java.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>okio</artifactId>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- api token web server -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- html -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>${jsoup.veision}</version>
|
||||
</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>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jndi</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>14</source>
|
||||
<target>14</target>
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
</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>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</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>
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,992 @@
|
||||
package io.v.nutz;
|
||||
|
||||
import io.v.nutz.base.utils.AppIocUtil;
|
||||
import io.v.nutz.sys.models.*;
|
||||
import io.v.nutz.zhgh.proposal.models.ProposalUndertake;
|
||||
import io.v.nutz.sys.services.SysTaskService;
|
||||
import io.v.nutz.task.services.TaskPlatformService;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import io.v.nutz.web.commons.ext.pubsub.WebPubSub;
|
||||
import io.v.nutz.web.commons.filter.CsrfFilter;
|
||||
import io.v.nutz.web.commons.filter.SsrfFilter;
|
||||
import org.beetl.core.GroupTemplate;
|
||||
import org.nutz.boot.NbApp;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
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.integration.shiro.ShiroSessionProvider;
|
||||
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.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.mvc.annotation.*;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @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")
|
||||
@SessionBy(ShiroSessionProvider.class)
|
||||
@IocBy(args = {
|
||||
"*io.v.nutz.base.aop.ViReturnAopLoader",
|
||||
})
|
||||
@Filters(value = {@By(type = CsrfFilter.class), @By(type = SsrfFilter.class)})
|
||||
public class MainLauncher {
|
||||
private static final Log log = Logs.get();
|
||||
@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("io.v");
|
||||
nb.run();
|
||||
}
|
||||
|
||||
public static NbApp warMain(ServletContext sc) {
|
||||
NbApp nb = new NbApp().setPrintProcDoc(true);
|
||||
nb.getAppContext().setMainPackage("io.v");
|
||||
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();
|
||||
init_proposal_undertake();
|
||||
ioc.get(Globals.class);
|
||||
|
||||
// 存储Ioc
|
||||
AppIocUtil.setIoc(ioc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化承办单位表
|
||||
*/
|
||||
private void init_proposal_undertake() {
|
||||
int count = dao.count(ProposalUndertake.class, Cnd.NEW());
|
||||
if (count == 0) {
|
||||
List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where("unitlevel", "=", 3).and("parentId", "IS NOT", null));
|
||||
List<ProposalUndertake> proposalUnderTakes = units.stream().map(v -> {
|
||||
ProposalUndertake proposalUndertake = new ProposalUndertake();
|
||||
proposalUndertake.setUnitCode(v.getUnitcode());
|
||||
proposalUndertake.setUnitName(v.getName());
|
||||
proposalUndertake.setIsEnable(true);
|
||||
return proposalUndertake;
|
||||
}).collect(Collectors.toList());
|
||||
dao.insert(proposalUnderTakes);
|
||||
}
|
||||
}
|
||||
|
||||
private void init_task() {
|
||||
if (!dao.exists("sys_qrtz_triggers")) {
|
||||
//执行Quartz SQL脚本
|
||||
String dbType = dao.getJdbcExpert().getDatabaseType();
|
||||
log.debug("dbType:::" + dbType);
|
||||
FileSqlManager fmq = new FileSqlManager("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);
|
||||
}
|
||||
}
|
||||
if (0 == sysTaskService.count()) {
|
||||
//定时任务示例
|
||||
Sys_task task = new Sys_task();
|
||||
task.setDisabled(true);
|
||||
task.setName("测试任务");
|
||||
task.setJobClass("io.v.nutz.task.job.TestJob");
|
||||
task.setCron("*/5 * * * * ?");
|
||||
task.setData("{\"hi\":\"Wechat:wizzer | send red packets of support,thank u\"}");
|
||||
task.setNote("微信号:wizzer | 欢迎发送红包以示支持,多谢。。");
|
||||
sysTaskService.insert(task);
|
||||
}
|
||||
}
|
||||
|
||||
private void init_sys() {
|
||||
//通过POJO类创建表结构
|
||||
try {
|
||||
Daos.createTablesInPackage(dao, "io.v", false);
|
||||
//通过POJO类修改表结构
|
||||
Daos.migration(dao, "io.v", 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实例(为true时退出登录会更新sys_user表在线状态)");
|
||||
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);
|
||||
|
||||
//运维中心
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("00010004");
|
||||
menu.setName("运维中心");
|
||||
menu.setNote("运维中心");
|
||||
menu.setAliasName("Operation");
|
||||
menu.setIcon("ti-shield");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("");
|
||||
menu.setTarget("");
|
||||
menu.setShowit(true);
|
||||
menu.setHasChildren(true);
|
||||
menu.setParentId(m0.getId());
|
||||
menu.setType("menu");
|
||||
menu.setPermission("sys.operation");
|
||||
Sys_menu op0 = dao.insert(menu);
|
||||
//应用管理
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("000100040002");
|
||||
menu.setName("应用管理");
|
||||
menu.setAliasName("App");
|
||||
menu.setLocation(0);
|
||||
menu.setHref("/platform/sys/app");
|
||||
menu.setTarget("data-pjax");
|
||||
menu.setShowit(true);
|
||||
menu.setPermission("sys.operation.app");
|
||||
menu.setParentId(op0.getId());
|
||||
menu.setType("menu");
|
||||
Sys_menu op02 = dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000400020001");
|
||||
menu.setName("配置文件管理");
|
||||
menu.setAliasName("AppConfig");
|
||||
menu.setLocation(1);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.operation.app.conf");
|
||||
menu.setParentId(op02.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000400020002");
|
||||
menu.setName("Jar包管理");
|
||||
menu.setAliasName("AppJar");
|
||||
menu.setLocation(2);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.operation.app.jar");
|
||||
menu.setParentId(op02.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000400020003");
|
||||
menu.setName("实例管理");
|
||||
menu.setAliasName("AppInstance");
|
||||
menu.setLocation(3);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.operation.app.instance");
|
||||
menu.setParentId(op02.getId());
|
||||
menu.setType("data");
|
||||
dao.insert(menu);
|
||||
menu = new Sys_menu();
|
||||
menu.setDisabled(false);
|
||||
menu.setPath("0001000400020004");
|
||||
menu.setName("修改日志等级");
|
||||
menu.setAliasName("Loglevel");
|
||||
menu.setLocation(4);
|
||||
menu.setShowit(false);
|
||||
menu.setPermission("sys.operation.app.loglevel");
|
||||
menu.setParentId(op02.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.setId("43d2c4a34fc64f88acf2d95d2908d8ed");
|
||||
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.setLoginTheme("palette.3.css");
|
||||
user.setLoginBoxed(false);
|
||||
user.setLoginScroll(true);
|
||||
user.setLoginSidebar(false);
|
||||
user.setLoginPjax(true);
|
||||
user.setUnitid(dbunit.getId());
|
||||
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/");
|
||||
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,23 @@
|
||||
package io.v.nutz.base.annontation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 自定义注解防止表单重复提交
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RepeatSubmit {
|
||||
/**
|
||||
* 间隔时间(ms),小于此时间视为重复提交
|
||||
*/
|
||||
public int interval() default 5000;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
public String message() default "请求过于频繁,请稍后再试";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.v.nutz.base.annontation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Documented
|
||||
public @interface SelectEnum{
|
||||
String[] fields() default {};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.v.nutz.base.annontation;
|
||||
|
||||
public @interface Valid {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.v.nutz.base.annontation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.PARAMETER})
|
||||
@Documented
|
||||
public @interface ViRequired {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package io.v.nutz.base.annontation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
@Documented
|
||||
public @interface ViReturn {
|
||||
String successMsg() default "操作成功";
|
||||
|
||||
String errorMsg() default "操作失败";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.v.nutz.base.aop;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.interceptor.ViReturnInterceptor;
|
||||
import org.nutz.aop.MethodInterceptor;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.ioc.aop.SimpleAopMaker;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ViReturnAopLoader extends SimpleAopMaker<ViReturn> {
|
||||
public ViReturnAopLoader() {
|
||||
}
|
||||
|
||||
public List<? extends MethodInterceptor> makeIt(ViReturn tryCatch, Method method, Ioc ioc) {
|
||||
return Arrays.asList(new ViReturnInterceptor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.v.nutz.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 final static String REDIS_KEY_QIYE_WECHAT_ACCESS_TOKEN = "qiyewx:token:";
|
||||
|
||||
//健步走小程序TOKEN
|
||||
public final static String REDIS_KEY_WE_APP_ACCESS_TOKEN = "weapp:token:";
|
||||
|
||||
|
||||
/**
|
||||
* 接口重复提交前缀
|
||||
*/
|
||||
public static final String REPEAT_SUBMIT_PREFIX = PLATFORM_REDIS_PREFIX + "repeat_submit:";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.v.nutz.base.dao;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CndPlus extends Cnd {
|
||||
private final NutMap map = NutMap.NEW().addv("ascending", "asc").addv("descending", "desc");
|
||||
|
||||
public CndPlus() {
|
||||
}
|
||||
|
||||
private String getOrder(String key) {
|
||||
return this.map.getString(key);
|
||||
}
|
||||
|
||||
public static CndPlus create() {
|
||||
return new CndPlus();
|
||||
}
|
||||
|
||||
public CndPlus and(PageForm pageForm) {
|
||||
if (StrUtil.isAllNotBlank(pageForm.getSearchName(), pageForm.getSearchKeyword())) {
|
||||
this.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
this.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CndPlus andEx(String name, String op, Object value) {
|
||||
if (StrUtil.isNotBlank(name) && !Lang.isEmpty(value)) {
|
||||
this.and(name, op, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.v.nutz.base.enums;
|
||||
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
|
||||
@SelectEnum
|
||||
public enum AuditTypeEnum {
|
||||
AUDIT(0, "审核"),
|
||||
REJECT(1, "拒绝"),
|
||||
NODE_PASS(2, "节点通过"),
|
||||
PROCESS_PASS(3, "流程通过");
|
||||
|
||||
public Integer value;
|
||||
public String desc;
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
private AuditTypeEnum(Integer value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.v.nutz.base.enums;
|
||||
|
||||
public enum Env {
|
||||
dev,
|
||||
prod;
|
||||
|
||||
private Env() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.v.nutz.base.event.common;
|
||||
|
||||
|
||||
public interface SysCommonDataChange {
|
||||
|
||||
|
||||
/**
|
||||
* 系统通用数据变更
|
||||
*
|
||||
* @param changeType 变更类型
|
||||
* @param tClass 数据类型 例如user、unit...............
|
||||
* @param bizId 业务ID
|
||||
*/
|
||||
void exec(SysCommonDataChangeType changeType, Class<?> tClass, String bizId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.v.nutz.base.event.common;
|
||||
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/8/14 17:23
|
||||
* @description
|
||||
*/
|
||||
public class SysCommonDataChangeCenter {
|
||||
|
||||
public static void publish(SysCommonDataChangeType changeType, Class<?> tClass, String bizId){
|
||||
String[] names = Mvcs.getIoc().getNamesByType(SysCommonDataChange.class);
|
||||
for (String listener : names) {
|
||||
SysCommonDataChange listenerBean = Mvcs.getIoc().get(SysCommonDataChange.class, listener);
|
||||
listenerBean.exec(changeType, tClass, bizId);
|
||||
// 是否在事务中
|
||||
// boolean transactionNone = Trans.isTransactionNone();
|
||||
// if(transactionNone){
|
||||
//
|
||||
// }else{
|
||||
// ThreadUtil.execAsync(() ->);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.v.nutz.base.event.common;
|
||||
|
||||
/**
|
||||
* 数据变更类型
|
||||
*/
|
||||
public enum SysCommonDataChangeType {
|
||||
|
||||
INSERT(),
|
||||
UPDATE(),
|
||||
DELETE();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangeEventListener
|
||||
* @Date 2025/8/13 14:18
|
||||
* @注释
|
||||
*/
|
||||
public interface UserChangeEventListener {
|
||||
|
||||
void receive(UserChangeMsg message);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangeMsg
|
||||
* @Date 2025/8/13 11:51
|
||||
* @注释
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserChangeMsg {
|
||||
|
||||
/**
|
||||
* 变更资源,用户Id
|
||||
*/
|
||||
private List<String> userIds;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private Integer operationType;
|
||||
|
||||
/**
|
||||
* 变更前的单位Id,当operationType值为1时,该字段有效
|
||||
*/
|
||||
private String sourceUnitId;
|
||||
|
||||
/**
|
||||
* 变更后的单位Id,当operationType值为1时,该字段有效
|
||||
*/
|
||||
private String targetUnitId;
|
||||
|
||||
/**
|
||||
* 单位变动
|
||||
*/
|
||||
public final static int UNIT_CHANGE_OPERATION = 1;
|
||||
|
||||
/**
|
||||
* 退休
|
||||
*/
|
||||
public final static int RETIRE_OPERATION = 2;
|
||||
|
||||
/**
|
||||
* 入会
|
||||
*/
|
||||
public final static int RESTORE_OPERATION = 3;
|
||||
|
||||
|
||||
public UserChangeMsg(List<String> userIds, Integer operationType) {
|
||||
super();
|
||||
this.userIds = userIds;
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public UserChangeMsg(List<String> userIds, Integer operationType, String sourceUnitId) {
|
||||
super();
|
||||
this.userIds = userIds;
|
||||
this.operationType = operationType;
|
||||
this.sourceUnitId = sourceUnitId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package io.v.nutz.base.event.user;
|
||||
|
||||
import io.v.nutz.base.utils.AppIocUtil;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:UserChangePublisher
|
||||
* @Date 2025/8/13 14:23
|
||||
* @注释
|
||||
*/
|
||||
public class UserChangePublisher {
|
||||
|
||||
// 发送消息给所有订阅者
|
||||
public static void broadcast(UserChangeMsg msg) {
|
||||
Ioc ioc = AppIocUtil.get();
|
||||
|
||||
String[] names = ioc.getNamesByType(UserChangeEventListener.class);
|
||||
for (String listener : names) {
|
||||
UserChangeEventListener listenerBean = ioc.get(UserChangeEventListener.class, listener);
|
||||
listenerBean.receive(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.v.nutz.base.exception;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class BaseException extends RuntimeException{
|
||||
|
||||
private static final long serialVersionUID = 7192152812384031563L;
|
||||
|
||||
public BaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BaseException(String message, Object... arguments) {
|
||||
super(StrUtil.format(message, arguments));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.v.nutz.base.expression;
|
||||
|
||||
public interface Exp {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.v.nutz.base.expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Exp1 extends Exp {
|
||||
void run();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.v.nutz.base.expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Exp2<T> extends Exp {
|
||||
void run(T var1);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.v.nutz.base.expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Exp3 extends Exp {
|
||||
<E> void run(E... var1);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.v.nutz.base.expression;
|
||||
|
||||
public interface Exp4<T> extends Exp {
|
||||
Object run(T var1);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package io.v.nutz.base.interceptor;
|
||||
|
||||
import io.v.nutz.base.annontation.ViReturn;
|
||||
import io.v.nutz.base.result.Result;
|
||||
import org.nutz.aop.InterceptorChain;
|
||||
import org.nutz.aop.MethodInterceptor;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
|
||||
public class ViReturnInterceptor implements MethodInterceptor {
|
||||
private static final Log log = Logs.get();
|
||||
|
||||
@Override
|
||||
public void filter(InterceptorChain chain) throws Throwable {
|
||||
Object[] args = chain.getArgs();
|
||||
Parameter[] parameters = chain.getCallingMethod().getParameters();
|
||||
try {
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
Object param = args[i];
|
||||
Parameter parameter = parameters[i];
|
||||
Param paramAnnotation = parameter.getDeclaredAnnotation(Param.class);
|
||||
|
||||
if ((paramAnnotation == null || paramAnnotation.required()) && Lang.isEmpty(param)) {
|
||||
chain.setReturnValue(Result.error().addMsg(parameter.getName() + " is required!"));
|
||||
// throw new MissingParameterException(parameter.getName() + " must not null !");
|
||||
}
|
||||
}
|
||||
|
||||
//执行方法
|
||||
InterceptorChain doChain = chain.doChain();
|
||||
Object chainReturn = doChain.getReturn();
|
||||
|
||||
if (chainReturn instanceof Result) {
|
||||
chain.setReturnValue(chainReturn);
|
||||
}else if(chainReturn instanceof cn.wizzer.framework.base.Result){
|
||||
chain.setReturnValue(chainReturn);
|
||||
} else {
|
||||
Result success = Result.success();
|
||||
if (!chain.getCallingMethod().getReturnType().equals(Void.TYPE)) {
|
||||
success.addData(doChain.getReturn());
|
||||
}
|
||||
success.addMsg(chain.getCallingMethod().getAnnotation(ViReturn.class).successMsg());
|
||||
chain.setReturnValue(success);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//如果之前没有设返回值就在这里设
|
||||
if (chain.getReturn() == null) {
|
||||
// chain.setReturnValue(Result.error().addMsg(chain.getCallingMethod().getAnnotation(ViReturn.class).errorMsg()));
|
||||
chain.setReturnValue(Result.error().addMsg(e.getMessage()));
|
||||
}
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package io.v.nutz.base.interceptor.repeatSubmit;
|
||||
|
||||
import io.v.nutz.base.annontation.RepeatSubmit;
|
||||
import org.nutz.aop.MethodInterceptor;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.ioc.aop.SimpleAopMaker;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
@IocBean(name = "$aop_repeatSubmit")
|
||||
public class RepeatSubmitAopConfiguration extends SimpleAopMaker<RepeatSubmit> {
|
||||
|
||||
@Override
|
||||
public List<? extends MethodInterceptor> makeIt(RepeatSubmit repeatSubmit, Method method, Ioc ioc) {
|
||||
return List.of(new RepeatSubmitAopInterceptor(ioc, repeatSubmit, method));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package io.v.nutz.base.interceptor.repeatSubmit;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.v.nutz.base.annontation.RepeatSubmit;
|
||||
import io.v.nutz.base.constant.RedisConstant;
|
||||
import io.v.nutz.base.exception.BaseException;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import org.nutz.aop.InterceptorChain;
|
||||
import org.nutz.aop.MethodInterceptor;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.Ioc;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class RepeatSubmitAopInterceptor implements MethodInterceptor {
|
||||
|
||||
protected Ioc ioc;
|
||||
|
||||
public RepeatSubmitAopInterceptor(Ioc ioc, RepeatSubmit repeatSubmit, Method method) {
|
||||
RedisService redisService = ioc.get(RedisService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(InterceptorChain chain) throws Throwable {
|
||||
Method method = chain.getCallingMethod();
|
||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||
int interval = annotation.interval();
|
||||
RedisService redisService = Mvcs.getIoc().get(RedisService.class);
|
||||
String source = method.getDeclaringClass().getName() + "#" + method.getName();
|
||||
Object[] args = chain.getArgs();
|
||||
String parameterJson = "";
|
||||
if (ObjectUtil.isNotEmpty(args)) {
|
||||
parameterJson = JSONUtil.toJsonStr(args); // 序列化实际参数
|
||||
}
|
||||
String key = RedisConstant.REPEAT_SUBMIT_PREFIX + ShiroUtil.getUserId() + ":" + source;
|
||||
|
||||
Boolean exists = redisService.exists(key);
|
||||
if (exists) {
|
||||
// 判断
|
||||
String oldParameterJson = redisService.get(key);
|
||||
if (oldParameterJson != null && oldParameterJson.equalsIgnoreCase(parameterJson)) {
|
||||
throw new BaseException(annotation.message());
|
||||
}
|
||||
} else {
|
||||
redisService.setex(key, interval / 1000, parameterJson);
|
||||
}
|
||||
chain.doChain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package io.v.nutz.base.lang;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Enum {
|
||||
public Enum() {
|
||||
}
|
||||
|
||||
public static <E, C> E instance(Class<E> enumClass, C code) {
|
||||
Assert.isTrue(enumClass.isEnum(), String.format("%s not a enum", enumClass.getSimpleName()));
|
||||
Object[] enumConstants = enumClass.getEnumConstants();
|
||||
Field[] fields = ReflectUtil.getFields(enumClass);
|
||||
Object[] var4 = enumConstants;
|
||||
int var5 = enumConstants.length;
|
||||
|
||||
for(int var6 = 0; var6 < var5; ++var6) {
|
||||
Object object = var4[var6];
|
||||
Field[] var8 = fields;
|
||||
int var9 = fields.length;
|
||||
|
||||
for(int var10 = 0; var10 < var9; ++var10) {
|
||||
Field field = var8[var10];
|
||||
field.setAccessible(true);
|
||||
|
||||
try {
|
||||
if (code.equals(field.get(object))) {
|
||||
return (E) object;
|
||||
}
|
||||
} catch (IllegalAccessException var13) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <E> List<NutMap> transToList(Class<E> enumClass) {
|
||||
return transToList(enumClass, (List)null);
|
||||
}
|
||||
|
||||
public static <E> List<NutMap> transToList(Class<E> enumClass, List<String> fieldNames) {
|
||||
Assert.isTrue(enumClass.isEnum(), String.format("%s not a enum", enumClass.getSimpleName()));
|
||||
List<NutMap> result = new ArrayList();
|
||||
Object[] enumConstants = enumClass.getEnumConstants();
|
||||
Field[] fields = ReflectUtil.getFields(enumClass);
|
||||
Object[] var5 = enumConstants;
|
||||
int var6 = enumConstants.length;
|
||||
|
||||
for(int var7 = 0; var7 < var6; ++var7) {
|
||||
Object enumConstant = var5[var7];
|
||||
NutMap map = NutMap.NEW();
|
||||
Field[] var10 = fields;
|
||||
int var11 = fields.length;
|
||||
|
||||
for(int var12 = 0; var12 < var11; ++var12) {
|
||||
Field field = var10[var12];
|
||||
if (fieldNames == null || fieldNames.contains(field.getName())) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
map.setv(field.getName(), field.get(enumConstant));
|
||||
} catch (IllegalAccessException var15) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.add(map);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package io.v.nutz.base.lang;
|
||||
|
||||
import org.nutz.lang.Strings;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class Lang {
|
||||
public Lang() {
|
||||
}
|
||||
|
||||
public static boolean match(Object obj, boolean isNull) {
|
||||
if (obj instanceof String) {
|
||||
String s = (String)obj;
|
||||
return isNull ? Strings.isBlank(s) : Strings.isNotBlank(s);
|
||||
} else {
|
||||
return isNull == (obj == null);
|
||||
}
|
||||
}
|
||||
|
||||
public static String sqlAlias(String alias) {
|
||||
return Strings.isBlank(alias) ? "" : alias + ".";
|
||||
}
|
||||
|
||||
public static boolean isNull(Object... objects) {
|
||||
return Arrays.stream(objects).allMatch((v) -> {
|
||||
return match(v, true);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean notNull(Object... objects) {
|
||||
return Arrays.stream(objects).allMatch((v) -> {
|
||||
return match(v, false);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean anyNull(Object... objects) {
|
||||
return Arrays.stream(objects).anyMatch((v) -> {
|
||||
return match(v, true);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean anyNotNull(Object... objects) {
|
||||
return Arrays.stream(objects).anyMatch((v) -> {
|
||||
return match(v, false);
|
||||
});
|
||||
}
|
||||
|
||||
public static int eleSize(Object obj) {
|
||||
if (null == obj) {
|
||||
return 0;
|
||||
} else if (obj.getClass().isArray()) {
|
||||
return Array.getLength(obj);
|
||||
} else if (obj instanceof Collection) {
|
||||
Collection o = (Collection)obj;
|
||||
return o.size();
|
||||
} else {
|
||||
return obj instanceof Map ? ((Map)obj).size() : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.wizzer.framework.base.model.BaseModel;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import java.util.Date;
|
||||
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.Comment;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Prev;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
@Table("audit")
|
||||
public class Audit extends BaseModel {
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
@PrevInsert(
|
||||
uu32 = true
|
||||
)
|
||||
private String id;
|
||||
@Column
|
||||
@Comment("审核人")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.uid()")}
|
||||
)
|
||||
private String auditor;
|
||||
@Column
|
||||
@Comment("是否通过")
|
||||
@ColDefine(
|
||||
type = ColType.BOOLEAN
|
||||
)
|
||||
private Boolean auditPass;
|
||||
@Column
|
||||
@Comment("审核时间")
|
||||
@Prev(
|
||||
els = {@EL("$me.nowDate()")}
|
||||
)
|
||||
private Date auditTime;
|
||||
@Column
|
||||
@Comment("审核意见")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 500
|
||||
)
|
||||
private String auditOpinion;
|
||||
@Column
|
||||
@Comment("签字")
|
||||
@ColDefine(
|
||||
type = ColType.TEXT
|
||||
)
|
||||
private String auditSign;
|
||||
@Column
|
||||
@Comment("审核人姓名")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.userName()")}
|
||||
)
|
||||
private String username;
|
||||
@Column
|
||||
@Comment("审核人工号")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.loginName()")}
|
||||
)
|
||||
private String loginname;
|
||||
@Column
|
||||
@Comment("审核类型(1.通过 2.拒绝 3.退回)")
|
||||
@ColDefine(
|
||||
type = ColType.INT
|
||||
)
|
||||
private Integer auditType;
|
||||
|
||||
|
||||
public JSONObject getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public void setExt(JSONObject ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
@Column
|
||||
@Comment("扩展信息")
|
||||
@ColDefine(type = ColType.MYSQL_JSON)
|
||||
private JSONObject ext;
|
||||
|
||||
public Date nowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public String userName() {
|
||||
return ShiroUtil.getPrincipalProperty("username").toString();
|
||||
}
|
||||
|
||||
public String loginName() {
|
||||
return ShiroUtil.getPrincipalProperty("loginname").toString();
|
||||
}
|
||||
|
||||
public Audit() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getAuditor() {
|
||||
return this.auditor;
|
||||
}
|
||||
|
||||
public Boolean getAuditPass() {
|
||||
return this.auditPass;
|
||||
}
|
||||
|
||||
public Date getAuditTime() {
|
||||
return this.auditTime;
|
||||
}
|
||||
|
||||
public String getAuditOpinion() {
|
||||
return this.auditOpinion;
|
||||
}
|
||||
|
||||
public String getAuditSign() {
|
||||
return this.auditSign;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getLoginname() {
|
||||
return this.loginname;
|
||||
}
|
||||
|
||||
public Integer getAuditType() {
|
||||
return this.auditType;
|
||||
}
|
||||
|
||||
public Audit setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditor(String auditor) {
|
||||
this.auditor = auditor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditPass(Boolean auditPass) {
|
||||
this.auditPass = auditPass;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditTime(Date auditTime) {
|
||||
this.auditTime = auditTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditOpinion(String auditOpinion) {
|
||||
this.auditOpinion = auditOpinion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditSign(String auditSign) {
|
||||
this.auditSign = auditSign;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setUsername(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setLoginname(String loginname) {
|
||||
this.loginname = loginname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Audit setAuditType(Integer auditType) {
|
||||
this.auditType = auditType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = this.getId();
|
||||
return "Audit(id=" + var10000 + ", auditor=" + this.getAuditor() + ", auditPass=" + this.getAuditPass() + ", auditTime=" + this.getAuditTime() + ", auditOpinion=" + this.getAuditOpinion() + ", auditSign=" + this.getAuditSign() + ", username=" + this.getUsername() + ", loginname=" + this.getLoginname() + ", auditType=" + this.getAuditType() + ")";
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (!(o instanceof Audit)) {
|
||||
return false;
|
||||
} else {
|
||||
Audit other = (Audit)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
} else if (!super.equals(o)) {
|
||||
return false;
|
||||
} else {
|
||||
label121: {
|
||||
Object this$id = this.getId();
|
||||
Object other$id = other.getId();
|
||||
if (this$id == null) {
|
||||
if (other$id == null) {
|
||||
break label121;
|
||||
}
|
||||
} else if (this$id.equals(other$id)) {
|
||||
break label121;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$auditor = this.getAuditor();
|
||||
Object other$auditor = other.getAuditor();
|
||||
if (this$auditor == null) {
|
||||
if (other$auditor != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$auditor.equals(other$auditor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
label107: {
|
||||
Object this$auditPass = this.getAuditPass();
|
||||
Object other$auditPass = other.getAuditPass();
|
||||
if (this$auditPass == null) {
|
||||
if (other$auditPass == null) {
|
||||
break label107;
|
||||
}
|
||||
} else if (this$auditPass.equals(other$auditPass)) {
|
||||
break label107;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$auditTime = this.getAuditTime();
|
||||
Object other$auditTime = other.getAuditTime();
|
||||
if (this$auditTime == null) {
|
||||
if (other$auditTime != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$auditTime.equals(other$auditTime)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$auditOpinion = this.getAuditOpinion();
|
||||
Object other$auditOpinion = other.getAuditOpinion();
|
||||
if (this$auditOpinion == null) {
|
||||
if (other$auditOpinion != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$auditOpinion.equals(other$auditOpinion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
label86: {
|
||||
Object this$auditSign = this.getAuditSign();
|
||||
Object other$auditSign = other.getAuditSign();
|
||||
if (this$auditSign == null) {
|
||||
if (other$auditSign == null) {
|
||||
break label86;
|
||||
}
|
||||
} else if (this$auditSign.equals(other$auditSign)) {
|
||||
break label86;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
label79: {
|
||||
Object this$username = this.getUsername();
|
||||
Object other$username = other.getUsername();
|
||||
if (this$username == null) {
|
||||
if (other$username == null) {
|
||||
break label79;
|
||||
}
|
||||
} else if (this$username.equals(other$username)) {
|
||||
break label79;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$loginname = this.getLoginname();
|
||||
Object other$loginname = other.getLoginname();
|
||||
if (this$loginname == null) {
|
||||
if (other$loginname != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$loginname.equals(other$loginname)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object this$auditType = this.getAuditType();
|
||||
Object other$auditType = other.getAuditType();
|
||||
if (this$auditType == null) {
|
||||
if (other$auditType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!this$auditType.equals(other$auditType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof Audit;
|
||||
}
|
||||
|
||||
public static enum auditType {
|
||||
PASS(1, "通过"),
|
||||
REFUSE(2, "拒绝"),
|
||||
BACK(3, "退回");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
private auditType(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import java.util.List;
|
||||
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.Comment;
|
||||
import org.nutz.dao.entity.annotation.Id;
|
||||
import org.nutz.dao.entity.annotation.Many;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
@Table("audit_state")
|
||||
public class AuditState {
|
||||
@Column
|
||||
@Id(
|
||||
auto = false
|
||||
)
|
||||
@Comment("ID")
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
private Integer stateId;
|
||||
@Column
|
||||
@Comment("状态名")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String stateName;
|
||||
@Column
|
||||
@Comment("强调色")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 20
|
||||
)
|
||||
private String stateColor;
|
||||
@Column
|
||||
@Comment("隶属(***模块)")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String module;
|
||||
@Column
|
||||
@Comment("下个审核节点代码")
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
private Integer afterStateId;
|
||||
@Column
|
||||
@Comment("通过下个审核节点代码")
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
private Integer afterPassStateId;
|
||||
@Column
|
||||
@Comment("拒绝后下个节点代码")
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
private Integer afterRejectStateId;
|
||||
@Column
|
||||
@Comment("会议类型id 属于那个会议类型的流程")
|
||||
@ColDefine(
|
||||
type = ColType.INT
|
||||
)
|
||||
private Integer meetingTypeId;
|
||||
@Column
|
||||
@Comment("会议审核类型")
|
||||
@ColDefine(
|
||||
type = ColType.INT
|
||||
)
|
||||
private String auditAfterType;
|
||||
@Column
|
||||
@Comment("审核节点类型")
|
||||
@ColDefine(
|
||||
type = ColType.INT
|
||||
)
|
||||
private Integer stateAuditType;
|
||||
@Column
|
||||
@Comment("审核人员匹配条件")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR
|
||||
)
|
||||
private String matchCnd;
|
||||
@Many(
|
||||
field = "stateId"
|
||||
)
|
||||
private List<AuditStateUser> auditStateUserList;
|
||||
|
||||
public AuditState() {
|
||||
}
|
||||
|
||||
public Integer getStateId() {
|
||||
return this.stateId;
|
||||
}
|
||||
|
||||
public String getStateName() {
|
||||
return this.stateName;
|
||||
}
|
||||
|
||||
public String getStateColor() {
|
||||
return this.stateColor;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return this.module;
|
||||
}
|
||||
|
||||
public Integer getAfterStateId() {
|
||||
return this.afterStateId;
|
||||
}
|
||||
|
||||
public Integer getAfterPassStateId() {
|
||||
return this.afterPassStateId;
|
||||
}
|
||||
|
||||
public Integer getAfterRejectStateId() {
|
||||
return this.afterRejectStateId;
|
||||
}
|
||||
|
||||
public Integer getMeetingTypeId() {
|
||||
return this.meetingTypeId;
|
||||
}
|
||||
|
||||
public String getAuditAfterType() {
|
||||
return this.auditAfterType;
|
||||
}
|
||||
|
||||
public Integer getStateAuditType() {
|
||||
return this.stateAuditType;
|
||||
}
|
||||
|
||||
public String getMatchCnd() {
|
||||
return this.matchCnd;
|
||||
}
|
||||
|
||||
public List<AuditStateUser> getAuditStateUserList() {
|
||||
return this.auditStateUserList;
|
||||
}
|
||||
|
||||
public AuditState setStateId(Integer stateId) {
|
||||
this.stateId = stateId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setStateName(String stateName) {
|
||||
this.stateName = stateName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setStateColor(String stateColor) {
|
||||
this.stateColor = stateColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setModule(String module) {
|
||||
this.module = module;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setAfterStateId(Integer afterStateId) {
|
||||
this.afterStateId = afterStateId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setAfterPassStateId(Integer afterPassStateId) {
|
||||
this.afterPassStateId = afterPassStateId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setAfterRejectStateId(Integer afterRejectStateId) {
|
||||
this.afterRejectStateId = afterRejectStateId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setMeetingTypeId(Integer meetingTypeId) {
|
||||
this.meetingTypeId = meetingTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setAuditAfterType(String auditAfterType) {
|
||||
this.auditAfterType = auditAfterType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setStateAuditType(Integer stateAuditType) {
|
||||
this.stateAuditType = stateAuditType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setMatchCnd(String matchCnd) {
|
||||
this.matchCnd = matchCnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditState setAuditStateUserList(List<AuditStateUser> auditStateUserList) {
|
||||
this.auditStateUserList = auditStateUserList;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
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.Comment;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
@Table
|
||||
public class AuditStateUser {
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
@PrevInsert(
|
||||
uu32 = true
|
||||
)
|
||||
private String id;
|
||||
@Column
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
@Comment("审核状态id")
|
||||
private Integer stateId;
|
||||
@Column
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
@Comment("由谁来审核该状态(指定到某个用户)")
|
||||
private String userId;
|
||||
|
||||
public AuditStateUser() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Integer getStateId() {
|
||||
return this.stateId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public AuditStateUser setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditStateUser setStateId(Integer stateId) {
|
||||
this.stateId = stateId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuditStateUser setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
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 org.nutz.mvc.Mvcs;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by wizzer on 2016/6/21.
|
||||
*/
|
||||
@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;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("opBy")
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
private String opBy;
|
||||
|
||||
@Column
|
||||
@Comment("opAt")
|
||||
@ColDefine(type = ColType.VARCHAR)
|
||||
private String opAt;
|
||||
|
||||
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 {
|
||||
HttpServletRequest request = Mvcs.getReq();
|
||||
if (request != null) {
|
||||
return Strings.sNull(request.getSession(true).getAttribute("platform_uid"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String updatedByUid() {
|
||||
String uid = getUpdatedBy();
|
||||
if (Strings.isNotBlank(uid)) {
|
||||
return uid;
|
||||
}
|
||||
try {
|
||||
HttpServletRequest request = Mvcs.getReq();
|
||||
if (request != null) {
|
||||
return Strings.sNull(request.getSession(true).getAttribute("platform_uid"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.nutz.dao.entity.annotation.*;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2020/12/6 16:45
|
||||
* @description
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Table("Goods")
|
||||
public class Goods extends BaseModel {
|
||||
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@PrevInsert(uu32 = true)
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Comment("关联表id")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
private String reid;
|
||||
|
||||
|
||||
@Column
|
||||
@Comment("物品名称")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 100)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Comment("物品价格")
|
||||
@ColDefine(type = ColType.FLOAT, width = 30)
|
||||
private Double price;
|
||||
|
||||
@Column
|
||||
@Comment("实际物品价格")
|
||||
@ColDefine(type = ColType.FLOAT, width = 30)
|
||||
private Double actualPrice;
|
||||
|
||||
@Column
|
||||
@Comment("说明")
|
||||
@ColDefine(type = ColType.TEXT)
|
||||
private String notes;
|
||||
|
||||
@Column
|
||||
@Comment("活动编号")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String activityCode;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import cn.wizzer.framework.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.Comment;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("Review")
|
||||
@Deprecated
|
||||
@Data
|
||||
public class Review extends BaseModel {
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
@PrevInsert(
|
||||
uu32 = true
|
||||
)
|
||||
private String id;
|
||||
@Column
|
||||
@Comment("审核人姓名")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String username;
|
||||
@Column
|
||||
@Comment("审核人工号")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String loginname;
|
||||
@Column
|
||||
@Comment("审核时间")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 30
|
||||
)
|
||||
private String time;
|
||||
@Column
|
||||
@Comment("审核意见")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 500
|
||||
)
|
||||
private String opinion;
|
||||
@Column
|
||||
@Comment("签字")
|
||||
@ColDefine(
|
||||
type = ColType.TEXT
|
||||
)
|
||||
private String sign;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import lombok.Data;
|
||||
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.Comment;
|
||||
import org.nutz.dao.entity.annotation.Name;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
|
||||
@Table("State")
|
||||
@Deprecated
|
||||
@Data
|
||||
public class State {
|
||||
@Column
|
||||
@Name
|
||||
@Comment("ID")
|
||||
@ColDefine(
|
||||
type = ColType.INT,
|
||||
width = 8
|
||||
)
|
||||
private String state_id;
|
||||
@Column
|
||||
@Comment("状态名")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String state_name;
|
||||
@Column
|
||||
@Comment("强调色")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String state_color;
|
||||
@Column
|
||||
@Comment("隶属(***模块)")
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 50
|
||||
)
|
||||
private String belong;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package io.v.nutz.base.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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.Comment;
|
||||
import org.nutz.dao.entity.annotation.EL;
|
||||
import org.nutz.dao.interceptor.annotation.PrevInsert;
|
||||
import org.nutz.dao.interceptor.annotation.PrevUpdate;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.Mvcs;
|
||||
|
||||
public abstract class ViBaseModel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Column
|
||||
@Comment("创建人")
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.uid()")}
|
||||
)
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
private String createdBy;
|
||||
@Column
|
||||
@Comment("创建时间")
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.now()")}
|
||||
)
|
||||
private Date createdAt;
|
||||
@Column
|
||||
@Comment("修改人")
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.uid()")}
|
||||
)
|
||||
@PrevUpdate(
|
||||
els = {@EL("$me.uid()")}
|
||||
)
|
||||
@ColDefine(
|
||||
type = ColType.VARCHAR,
|
||||
width = 32
|
||||
)
|
||||
private String updatedBy;
|
||||
@Column
|
||||
@Comment("修改时间")
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.now()")}
|
||||
)
|
||||
private Date updatedAt;
|
||||
@Column
|
||||
@Comment("删除标记")
|
||||
@PrevInsert(
|
||||
els = {@EL("$me.flag()")}
|
||||
)
|
||||
@ColDefine(
|
||||
type = ColType.BOOLEAN
|
||||
)
|
||||
private Boolean delFlag;
|
||||
|
||||
public String uid() {
|
||||
String uid = this.getCreatedBy();
|
||||
if (Strings.isNotBlank(uid)) {
|
||||
return uid;
|
||||
} else {
|
||||
try {
|
||||
HttpServletRequest request = Mvcs.getReq();
|
||||
if (request != null) {
|
||||
return Strings.sNull(request.getSession(true).getAttribute("platform_uid"));
|
||||
}
|
||||
} catch (Exception var3) {
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public Date now() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public int nowYear() {
|
||||
return Calendar.getInstance().get(1);
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return this.createdBy;
|
||||
}
|
||||
|
||||
public boolean flag(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package io.v.nutz.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,57 @@
|
||||
package io.v.nutz.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 io.v.nutz.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 io.v.nutz.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 io.v.nutz.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 io.v.nutz.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,79 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.query;
|
||||
public class PageForm {
|
||||
private String searchName;
|
||||
private String searchKeyword;
|
||||
private Integer pageNumber;
|
||||
private Integer pageSize;
|
||||
private String pageOrderName;
|
||||
private String pageOrderBy;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public PageForm() {
|
||||
}
|
||||
|
||||
public String getSearchName() {
|
||||
return this.searchName;
|
||||
}
|
||||
|
||||
public String getSearchKeyword() {
|
||||
return this.searchKeyword;
|
||||
}
|
||||
|
||||
public Integer getPageNumber() {
|
||||
return this.pageNumber;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public String getPageOrderName() {
|
||||
return this.pageOrderName;
|
||||
}
|
||||
|
||||
public String getPageOrderBy() {
|
||||
return this.pageOrderBy;
|
||||
}
|
||||
|
||||
public void setSearchName(String searchName) {
|
||||
this.searchName = searchName;
|
||||
}
|
||||
|
||||
public void setSearchKeyword(String searchKeyword) {
|
||||
this.searchKeyword = searchKeyword;
|
||||
}
|
||||
|
||||
public void setPageNumber(Integer pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public void setPageOrderName(String pageOrderName) {
|
||||
this.pageOrderName = pageOrderName;
|
||||
}
|
||||
|
||||
public void setPageOrderBy(String pageOrderBy) {
|
||||
this.pageOrderBy = pageOrderBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package io.v.nutz.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 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,111 @@
|
||||
|
||||
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import io.v.nutz.base.expression.Exp;
|
||||
import io.v.nutz.base.expression.Exp1;
|
||||
import io.v.nutz.base.expression.Exp2;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.AsyncResult;
|
||||
|
||||
@IocBean
|
||||
public class AsyncService {
|
||||
private static final Logger log = LoggerFactory.getLogger(AsyncService.class);
|
||||
|
||||
public AsyncService() {
|
||||
}
|
||||
|
||||
public void exe2(Iterable iterable, Exp1 e) {
|
||||
this.listExe(iterable, e);
|
||||
}
|
||||
|
||||
public <E> void exe2(Iterable<E> iterable, Exp2<E> e) {
|
||||
this.listExe(iterable, e);
|
||||
}
|
||||
|
||||
public void exe(Iterable iterable, Exp1 e) {
|
||||
this.listExe2(iterable, e);
|
||||
}
|
||||
|
||||
public <E> void exe(Iterable<E> iterable, Exp2<E> e) {
|
||||
this.listExe2(iterable, e);
|
||||
}
|
||||
|
||||
private void listExe(Iterable iterable, Exp exp) {
|
||||
List<Future> futures = new ArrayList();
|
||||
Iterator var4 = iterable.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
Object o = var4.next();
|
||||
if (exp instanceof Exp1) {
|
||||
Exp1 exp1 = (Exp1)exp;
|
||||
futures.add(this._run(exp1));
|
||||
} else if (exp instanceof Exp2) {
|
||||
Exp2 exp2 = (Exp2)exp;
|
||||
futures.add(this._run(o, exp2));
|
||||
}
|
||||
}
|
||||
|
||||
var4 = futures.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
Future future = (Future)var4.next();
|
||||
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException var7) {
|
||||
var7.printStackTrace();
|
||||
} catch (ExecutionException var8) {
|
||||
var8.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void listExe2(Iterable par, Exp exp) {
|
||||
Iterator var3 = par.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Object o = var3.next();
|
||||
if (exp instanceof Exp1) {
|
||||
Exp1 exp1 = (Exp1)exp;
|
||||
this._run2(exp1);
|
||||
} else if (exp instanceof Exp2) {
|
||||
Exp2 exp2 = (Exp2)exp;
|
||||
this._run2(o, exp2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Async
|
||||
public Future _run(Exp1 e) {
|
||||
e.run();
|
||||
return new AsyncResult((Object)null);
|
||||
}
|
||||
|
||||
@Async
|
||||
public Future _run(Object o, Exp2 e) {
|
||||
e.run(o);
|
||||
return new AsyncResult((Object)null);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void _run2(Exp1 e) {
|
||||
e.run();
|
||||
}
|
||||
|
||||
@Async
|
||||
public void _run2(Object o, Exp2 e) {
|
||||
e.run(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
import io.v.nutz.base.model.Audit;
|
||||
|
||||
public interface AuditService extends ViService<Audit> {
|
||||
}
|
||||
@@ -0,0 +1,914 @@
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
import io.v.nutz.base.page.Pagination;
|
||||
import io.v.nutz.base.page.datatable.DataTableColumn;
|
||||
import io.v.nutz.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);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseService;
|
||||
import io.v.nutz.base.model.Review;
|
||||
|
||||
@Deprecated
|
||||
public interface ReviewService extends BaseService<Review> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description TODO
|
||||
* @createTime 2022年01月04日 13:55:00
|
||||
*/
|
||||
public interface SimpleService extends ViService {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package io.v.nutz.base.service;
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseService;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import io.v.nutz.base.expression.Exp1;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import java.util.List;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.FieldFilter;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
public interface ViService<T> extends BaseService<T> {
|
||||
void transactional(Exp1 var1);
|
||||
|
||||
<C extends Cnd> Pagination list(PageForm var1, C var2);
|
||||
|
||||
<C extends Cnd> Pagination listLinks(PageForm var1, C var2);
|
||||
|
||||
<C extends Cnd> Pagination listLinks(PageForm var1, C var2, FieldFilter var3);
|
||||
|
||||
Pagination list(PageForm var1, Sql var2);
|
||||
|
||||
<E> List<E> listEntity(Sql var1, Class<E> var2);
|
||||
|
||||
List<NutMap> listMap(Sql var1);
|
||||
|
||||
NutMap fetch(Sql var1);
|
||||
|
||||
T fetchLinks(String var1);
|
||||
|
||||
T fetchLinks(long var1);
|
||||
|
||||
T fetchLinks(String var1, FieldFilter var2);
|
||||
|
||||
T fetchLinks(long var1, FieldFilter var3);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package io.v.nutz.base.service.impl;
|
||||
|
||||
import io.v.nutz.base.model.Audit;
|
||||
import io.v.nutz.base.service.AuditService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
@IocBean(
|
||||
args = {"refer:dao"}
|
||||
)
|
||||
@CacheDefaults(
|
||||
cacheName = "audit"
|
||||
)
|
||||
public class AuditServiceImpl extends ViServiceImpl<Audit> implements AuditService {
|
||||
public AuditServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
package io.v.nutz.base.service.impl;
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseServiceImpl;
|
||||
import io.v.nutz.base.model.Review;
|
||||
import io.v.nutz.base.service.ReviewService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.plugins.wkcache.annotation.CacheDefaults;
|
||||
|
||||
@Deprecated
|
||||
@IocBean(
|
||||
args = {"refer:dao"}
|
||||
)
|
||||
@CacheDefaults(
|
||||
cacheName = "Review"
|
||||
)
|
||||
public class ReviewServiceImpl extends BaseServiceImpl<Review> implements ReviewService {
|
||||
public ReviewServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package io.v.nutz.base.service.impl;
|
||||
|
||||
import io.v.nutz.base.service.SimpleService;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description TODO
|
||||
* @createTime 2022年01月04日 13:55:00
|
||||
*/
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class SimpleServiceImpl extends ViServiceImpl implements SimpleService {
|
||||
public SimpleServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package io.v.nutz.base.service.impl;
|
||||
|
||||
import cn.wizzer.framework.base.service.BaseServiceImpl;
|
||||
import cn.wizzer.framework.page.Pagination;
|
||||
import java.util.List;
|
||||
|
||||
import io.v.nutz.base.dao.CndPlus;
|
||||
import io.v.nutz.base.expression.Exp1;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import io.v.nutz.base.service.ViService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.FieldFilter;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.pager.Pager;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.dao.util.Daos;
|
||||
import org.nutz.lang.Mirror;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.trans.Atom;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
public class ViServiceImpl<T> extends BaseServiceImpl<T> implements ViService<T> {
|
||||
public ViServiceImpl(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
public void transactional(final Exp1 exp) {
|
||||
Trans.exec(new Atom[]{new Atom() {
|
||||
public void run() {
|
||||
exp.run();
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
||||
public <T extends Cnd> Pagination list(PageForm pageForm, T cnd) {
|
||||
if (cnd instanceof CndPlus) {
|
||||
((CndPlus)cnd).and(pageForm);
|
||||
}
|
||||
|
||||
return super.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), cnd);
|
||||
}
|
||||
|
||||
public <C extends Cnd> Pagination listLinks(PageForm pageForm, C cnd) {
|
||||
return this.listLinks(pageForm, cnd, (FieldFilter)null);
|
||||
}
|
||||
|
||||
public <C extends Cnd> Pagination listLinks(PageForm pageForm, C cnd, FieldFilter fieldFilter) {
|
||||
int pageNumber = this.getPageNumber(pageForm.getPageNumber());
|
||||
int pageSize = this.getPageSize(pageForm.getPageSize());
|
||||
Pager pager = this.dao().createPager(pageNumber, pageSize);
|
||||
if (cnd instanceof CndPlus) {
|
||||
((CndPlus)cnd).and(pageForm);
|
||||
}
|
||||
|
||||
List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
|
||||
pager.setRecordCount(this.dao().count(this.getEntityClass(), cnd));
|
||||
if (null == fieldFilter) {
|
||||
this.dao().fetchLinks(list, (String)null);
|
||||
} else {
|
||||
Daos.ext(this.dao(), fieldFilter).fetchLinks(list, (String)null);
|
||||
}
|
||||
|
||||
return new Pagination(pageNumber, pageSize, pager.getRecordCount(), list);
|
||||
}
|
||||
|
||||
public Pagination list(PageForm pageForm, Sql sql) {
|
||||
return super.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
}
|
||||
|
||||
public <E> List<E> listEntity(Sql sql, Class<E> target) {
|
||||
sql.setEntity(this.dao().getEntity(Mirror.me(target).getType()));
|
||||
sql.setCallback(Sqls.callback.entities());
|
||||
this.dao().execute(sql);
|
||||
return sql.getList(target);
|
||||
}
|
||||
|
||||
public List<NutMap> listMap(Sql sql) {
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
this.dao().execute(sql);
|
||||
return sql.getList(NutMap.class);
|
||||
}
|
||||
|
||||
public NutMap fetch(Sql sql) {
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
this.dao().execute(sql);
|
||||
return (NutMap)sql.getObject(NutMap.class);
|
||||
}
|
||||
|
||||
public T fetchLinks(String id) {
|
||||
return this.fetchLinks(this.fetch(id), (String)null);
|
||||
}
|
||||
|
||||
public T fetchLinks(long id) {
|
||||
return this.fetchLinks(this.fetch(id), (String)null);
|
||||
}
|
||||
|
||||
public T fetchLinks(String id, FieldFilter fieldFilter) {
|
||||
return Daos.ext(this.dao(), fieldFilter).fetchLinks(this.fetch(id), (String)null);
|
||||
}
|
||||
|
||||
public T fetchLinks(long id, FieldFilter fieldFilter) {
|
||||
return Daos.ext(this.dao(), fieldFilter).fetchLinks(this.fetch(id), (String)null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.v.nutz.base.starter;
|
||||
|
||||
import cn.hutool.core.lang.ClassScanner;
|
||||
import io.v.nutz.base.annontation.SelectEnum;
|
||||
import io.v.nutz.base.lang.Enum;
|
||||
import io.v.nutz.base.service.AsyncService;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.base.utils.EnumUtil;
|
||||
import io.v.nutz.base.utils.ViResource;
|
||||
import org.nutz.boot.starter.ServerFace;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.entity.annotation.Table;
|
||||
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.util.NutMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@IocBean
|
||||
public class ViStarter implements ServerFace {
|
||||
protected static final String PRE = "v-nutz.";
|
||||
protected static final String BASE_PACKAGE = "io.v.nutz";
|
||||
public static Boolean ENABLE_VALID_PARAM = false;
|
||||
@Inject("refer:$ioc")
|
||||
private Ioc ioc;
|
||||
@Inject
|
||||
private Dao dao;
|
||||
@Inject
|
||||
private AsyncService asyncService;
|
||||
@Inject
|
||||
private PropertiesProxy propertiesProxy;
|
||||
|
||||
public ViStarter() {
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
this.load();
|
||||
}
|
||||
|
||||
private void load() {
|
||||
ViResource.ioc = this.ioc;
|
||||
ViResource.dao = this.dao;
|
||||
Set<Class<?>> classes = ClassScanner.scanPackageByAnnotation("io.v.nutz", Table.class);
|
||||
Iterator<Class<?>> iterator = classes.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Class<?> next = iterator.next();
|
||||
if (!this.ioc.has(next.getSimpleName())) {
|
||||
ViServiceImpl viService = new ViServiceImpl(this.dao);
|
||||
viService.setEntityType(next);
|
||||
this.ioc.addBean(next.getSimpleName(), viService);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Set<Class<?>> selectEnumClasses = ClassScanner.scanPackageByAnnotation("io.v.nutz", SelectEnum.class);
|
||||
Iterator<Class<?>> selectEnumClassesIterator = selectEnumClasses.iterator();
|
||||
|
||||
while (selectEnumClassesIterator.hasNext()) {
|
||||
Class<?> selectEnumClass = selectEnumClassesIterator.next();
|
||||
SelectEnum selectEnum = selectEnumClass.getAnnotation(SelectEnum.class);
|
||||
assert selectEnum != null;
|
||||
List<NutMap> list = Enum.transToList(selectEnumClass, selectEnum.fields().length > 0 ? Arrays.asList(selectEnum.fields()) : null);
|
||||
ViResource.selectEnums.put(selectEnumClass.getSimpleName(), list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import org.nutz.ioc.Ioc;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:AppIocUtil
|
||||
* @Date 2025/8/26 17:40
|
||||
* @注释
|
||||
*/
|
||||
public class AppIocUtil {
|
||||
|
||||
private static Ioc ioc;
|
||||
|
||||
public static void setIoc(Ioc ioc) {
|
||||
AppIocUtil.ioc = ioc;
|
||||
}
|
||||
|
||||
public static Ioc get() {
|
||||
if (ioc == null) {
|
||||
throw new IllegalStateException("Ioc not initialized yet!");
|
||||
}
|
||||
return ioc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package io.v.nutz.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.Calendar;
|
||||
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");
|
||||
|
||||
public static Integer getYear() {
|
||||
return Calendar.getInstance().get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前时间(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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字符串时间转时间戳
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static long formatDate(String data) {
|
||||
try {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(data).getTime();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import com.artofsolving.jodconverter.DocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 文档转换util
|
||||
*/
|
||||
public class DocConverter {
|
||||
private static final int environment = 1;// 环境1:windows,2:linux(涉及pdf2swf路径问题)
|
||||
private String fileString;
|
||||
private String outputPath = "";// 输入路径,如果不设置就输出在默认位置
|
||||
private String fileName;
|
||||
private File pdfFile;
|
||||
private File swfFile;
|
||||
private File docFile;
|
||||
|
||||
public DocConverter(String fileString) {
|
||||
ini(fileString);
|
||||
}
|
||||
|
||||
/*
|
||||
* 重新设置 file @param fileString
|
||||
*/
|
||||
public void setFile(String fileString) {
|
||||
ini(fileString);
|
||||
}
|
||||
|
||||
/*
|
||||
* 初始化 @param fileString
|
||||
*/
|
||||
private void ini(String fileString) {
|
||||
this.fileString = fileString;
|
||||
fileName = fileString.substring(0, fileString.lastIndexOf("."));
|
||||
docFile = new File(fileString);
|
||||
pdfFile = new File(fileName + ".pdf");
|
||||
swfFile = new File(fileName + ".swf");
|
||||
}
|
||||
|
||||
/*
|
||||
* 转为PDF @param file
|
||||
*/
|
||||
private void doc2pdf() throws Exception {
|
||||
if (docFile.exists()) {
|
||||
if (!pdfFile.exists()) {
|
||||
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
|
||||
try {
|
||||
connection.connect();
|
||||
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
|
||||
converter.convert(docFile, pdfFile);
|
||||
// close the connection
|
||||
connection.disconnect();
|
||||
System.out.println("****pdf转换成功,PDF输出:" + pdfFile.getPath() + "****");
|
||||
} catch (java.net.ConnectException e) {
|
||||
// ToDo Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println("****swf转换异常,openoffice服务未启动!****");
|
||||
throw e;
|
||||
} catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("****swf转换器异常,读取转换文件失败****");
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
System.out.println("****已经转换为pdf,不需要再进行转化****");
|
||||
}
|
||||
} else {
|
||||
System.out.println("****swf转换器异常,需要转换的文档不存在,无法转换****");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 转换成swf
|
||||
*/
|
||||
private void pdf2swf() throws Exception {
|
||||
Runtime r = Runtime.getRuntime();
|
||||
if (!swfFile.exists()) {
|
||||
if (pdfFile.exists()) {
|
||||
if (environment == 1)// windows环境处理
|
||||
{
|
||||
try {
|
||||
// 这里根据SWFTools安装路径需要进行相应更改
|
||||
Process p = r.exec("D:\\ewm\\hj\\pdf2swf\\pdf2swf.exe " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
|
||||
System.out.print(loadStream(p.getInputStream()));
|
||||
System.err.print(loadStream(p.getErrorStream()));
|
||||
System.out.print(loadStream(p.getInputStream()));
|
||||
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
// if (pdfFile.exists()) {
|
||||
// pdfFile.delete();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
} else if (environment == 2)// linux环境处理
|
||||
{
|
||||
try {
|
||||
Process p = r.exec("pdf2swf " + pdfFile.getPath() + " -o " + swfFile.getPath() + " -T 9");
|
||||
System.out.print(loadStream(p.getInputStream()));
|
||||
System.err.print(loadStream(p.getErrorStream()));
|
||||
System.err.println("****swf转换成功,文件输出:" + swfFile.getPath() + "****");
|
||||
if (pdfFile.exists()) {
|
||||
pdfFile.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("****pdf不存在,无法转换****");
|
||||
}
|
||||
} else {
|
||||
System.out.println("****swf已存在不需要转换****");
|
||||
}
|
||||
}
|
||||
|
||||
static String loadStream(InputStream in) throws IOException {
|
||||
int ptr = 0;
|
||||
//把InputStream字节流 替换为BufferedReader字符流 2013-07-17修改
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
while ((ptr = reader.read()) != -1) {
|
||||
buffer.append((char) ptr);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* 转换主方法
|
||||
*/
|
||||
public boolean conver() {
|
||||
if (swfFile.exists()) {
|
||||
System.out.println("****swf转换器开始工作,该文件已经转换为swf****");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (environment == 1) {
|
||||
System.out.println("****swf转换器开始工作,当前设置运行环境windows****");
|
||||
} else {
|
||||
System.out.println("****swf转换器开始工作,当前设置运行环境linux****");
|
||||
}
|
||||
|
||||
try {
|
||||
doc2pdf();
|
||||
pdf2swf();
|
||||
} catch (Exception e) {
|
||||
// TODO: Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (swfFile.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 返回文件路径 @param s
|
||||
*/
|
||||
public String getswfPath() {
|
||||
if (swfFile.exists()) {
|
||||
String tempString = swfFile.getPath();
|
||||
tempString = tempString.replaceAll("\\\\", "/");
|
||||
return tempString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 设置输出路径
|
||||
*/
|
||||
public void setOutputPath(String outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
if (!outputPath.equals("")) {
|
||||
String realName = fileName.substring(fileName.lastIndexOf("/"), fileName.lastIndexOf("."));
|
||||
if (outputPath.charAt(outputPath.length()) == '/') {
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
} else {
|
||||
swfFile = new File(outputPath + realName + ".swf");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String s[]) {
|
||||
DocConverter d = new DocConverter("C:\\Users\\mayn\\Desktop\\安全管理系统.docx");
|
||||
d.conver();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import cn.hutool.extra.mail.MailAccount;
|
||||
import cn.hutool.extra.mail.MailUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @Author zhf
|
||||
* @Date 2022/7/20 13:42
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class EmailUtil {
|
||||
|
||||
public void send(@Param("email") String email, String content, boolean isHtml, File... files) {
|
||||
try {
|
||||
MailAccount account = new MailAccount();
|
||||
account.setHost("smtp.163.com");
|
||||
account.setPort(25);
|
||||
account.setSslEnable(false);
|
||||
account.setStarttlsEnable(false);
|
||||
account.setAuth(true);
|
||||
account.setFrom("87785588@163.com");
|
||||
account.setUser("87785588@163");
|
||||
account.setPass("NMRRJRHMTCOOLPQV");
|
||||
String msgId = MailUtil.send(account, email, "智慧工会", content, isHtml,files);
|
||||
log.debug("邮件发送状态:{},id:{}", "发送成功", msgId);
|
||||
} catch (Exception e) {
|
||||
log.debug("邮件发送异常信息:{}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EnumUtil {
|
||||
public static List<NutMap> enumToListMap(Class<?> clazz) {
|
||||
List<NutMap> resultList = null;
|
||||
// 判断是否是枚举类型
|
||||
if ("java.lang.Enum".equals(clazz.getSuperclass().getCanonicalName())) {
|
||||
resultList = new ArrayList<>();
|
||||
// 获取所有public方法
|
||||
Method[] methods = clazz.getMethods();
|
||||
List<Field> fieldList = new ArrayList<>();
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
String methodName = methods[i].getName();
|
||||
if (methodName.startsWith("get") && !"getDeclaringClass".equals(methodName)
|
||||
&& !"getClass".equals(methodName)) { // 找到枚举类中的以get开头的(并且不是父类已定义的方法)所有方法
|
||||
Field field = null;
|
||||
try {
|
||||
field = clazz.getDeclaredField(StringUtils.uncapitalize(methodName.substring(3))); // 通过方法名获取自定义字段
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (field != null) { // 如果不为空则添加到fieldList集合中
|
||||
fieldList.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fieldList.isEmpty()) { // 判断fieldList集合是否为空
|
||||
NutMap map = null;
|
||||
Enum<?>[] enums = (Enum[])clazz.getEnumConstants(); // 获取所有枚举
|
||||
for (int i = 0; i < enums.length; i++) {
|
||||
map = new NutMap();
|
||||
for (int l = 0, len = fieldList.size(); l < len; l++) {
|
||||
Field field = fieldList.get(l);
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
map.put(field.getName(), field.get(enums[i])); // 向map集合添加字段名称 和 字段值
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
resultList.add(map);// 将Map添加到集合中
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.apache.poi.hssf.usermodel.*;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ExcelUtil {
|
||||
/**
|
||||
* 导出Excel
|
||||
* @param sheetName sheet名称
|
||||
* @param title 标题
|
||||
* @param values 内容
|
||||
* @param wb HSSFWorkbook对象
|
||||
* @return
|
||||
*/
|
||||
public static HSSFWorkbook getHSSFWorkbook(String sheetName, String []title, String [][]values, HSSFWorkbook wb){
|
||||
|
||||
// 第一步,创建一个HSSFWorkbook,对应一个Excel文件
|
||||
if(wb == null){
|
||||
wb = new HSSFWorkbook();
|
||||
}
|
||||
|
||||
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
|
||||
HSSFSheet sheet = wb.createSheet(sheetName);
|
||||
// sheet.setColumnWidth(0, 3766);
|
||||
|
||||
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
|
||||
HSSFRow row = sheet.createRow(0);
|
||||
|
||||
// 第四步,创建单元格,并设置值表头 设置表头居中
|
||||
HSSFCellStyle style = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
/*style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
|
||||
style.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
|
||||
style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
|
||||
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
|
||||
style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
|
||||
|
||||
HSSFFont font = wb.createFont();
|
||||
font.setFontName("黑体");
|
||||
font.setFontHeightInPoints((short) 12);//设置字体大小
|
||||
|
||||
style.setFont(font);
|
||||
|
||||
//声明列对象
|
||||
HSSFCell cell = null;
|
||||
|
||||
//创建标题
|
||||
for(int i=0;i<title.length;i++){
|
||||
cell = row.createCell(i);
|
||||
cell.setCellValue(title[i]);
|
||||
cell.setCellStyle(style);
|
||||
sheet.autoSizeColumn(i);
|
||||
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 35 / 10);
|
||||
}
|
||||
|
||||
HSSFCellStyle style1 = wb.createCellStyle();
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
//style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
||||
//创建内容
|
||||
for(int i=0;i<values.length;i++){
|
||||
row = sheet.createRow(i + 1);
|
||||
for(int j=0;j<values[i].length;j++){
|
||||
HSSFCell cellx = row.createCell(j);
|
||||
//将内容按顺序赋给对应的列对象
|
||||
cellx.setCellValue(values[i][j]);
|
||||
//样式
|
||||
cellx.setCellStyle(style1);
|
||||
}
|
||||
}
|
||||
return wb;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
* @param sheetName sheet名称
|
||||
* @param title 标题
|
||||
* @param values 内容
|
||||
* @param wb HSSFWorkbook对象
|
||||
* @return
|
||||
*/
|
||||
public static HSSFWorkbook getHSSFWorkbook2(String sheetName,String bigTitle,int bigTitleHbColumn, String []title, String [][]values, HSSFWorkbook wb){
|
||||
|
||||
|
||||
if(wb == null){
|
||||
wb = new HSSFWorkbook();
|
||||
}
|
||||
|
||||
HSSFSheet sheet = wb.createSheet(sheetName);
|
||||
|
||||
HSSFRow row0 = sheet.createRow(0);
|
||||
HSSFCellStyle style0 = wb.createCellStyle();
|
||||
style0.setAlignment(HorizontalAlignment.CENTER);
|
||||
/*style0.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
|
||||
style0.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
|
||||
style0.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
|
||||
style0.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
|
||||
style0.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
|
||||
HSSFFont font0 = wb.createFont();
|
||||
font0.setFontName("黑体");
|
||||
font0.setFontHeightInPoints((short) 20);//设置字体大小
|
||||
style0.setFont(font0);
|
||||
HSSFCell cell0 = row0.createCell(0);
|
||||
cell0.setCellStyle(style0);
|
||||
cell0.setCellValue(bigTitle);
|
||||
|
||||
|
||||
HSSFRow row1 = sheet.createRow(1);
|
||||
HSSFCellStyle style1 = wb.createCellStyle();
|
||||
style1.setAlignment(HorizontalAlignment.CENTER);
|
||||
/*style1.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
|
||||
style1.setBorderTop(HSSFCellStyle.BORDER_THIN); //上边框
|
||||
style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
|
||||
style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
|
||||
style1.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框*/
|
||||
HSSFFont font1 = wb.createFont();
|
||||
font1.setFontName("黑体");
|
||||
font1.setFontHeightInPoints((short) 12);//设置字体大小
|
||||
style1.setFont(font1);
|
||||
|
||||
|
||||
//声明列对象
|
||||
HSSFCell cell = null;
|
||||
|
||||
//创建标题
|
||||
for(int i=0;i<title.length;i++){
|
||||
cell = row1.createCell(i);
|
||||
cell.setCellValue(title[i]);
|
||||
cell.setCellStyle(style1);
|
||||
/* sheet.autoSizeColumn(i);*/
|
||||
sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 35 / 10);
|
||||
}
|
||||
//setSizeColumn(sheet,title.length);
|
||||
|
||||
|
||||
HSSFCellStyle style2 = wb.createCellStyle();
|
||||
/* style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式*/
|
||||
style2.setAlignment(HorizontalAlignment.CENTER);
|
||||
HSSFFont font2 = wb.createFont();
|
||||
font2.setFontName("宋体");
|
||||
font2.setFontHeightInPoints((short) 12);//设置字体大小
|
||||
style2.setFont(font2);
|
||||
|
||||
//创建内容
|
||||
for(int i=0;i<values.length;i++){
|
||||
row1 = sheet.createRow(i + 2);
|
||||
for(int j=0;j<values[i].length;j++){
|
||||
HSSFCell cellx = row1.createCell(j);
|
||||
//将内容按顺序赋给对应的列对象
|
||||
cellx.setCellValue(values[i][j]);
|
||||
//样式
|
||||
cellx.setCellStyle(style2);
|
||||
}
|
||||
}
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(0, 0, 0, bigTitleHbColumn);
|
||||
sheet.addMergedRegion(region);
|
||||
return wb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 自适应宽度(中文支持)
|
||||
private static void setSizeColumn(HSSFSheet sheet, int size) {
|
||||
for (int columnNum = 0; columnNum < size; columnNum++) {
|
||||
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
|
||||
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
|
||||
HSSFRow currentRow;
|
||||
//当前行未被使用过
|
||||
if (sheet.getRow(rowNum) == null) {
|
||||
currentRow = sheet.createRow(rowNum);
|
||||
} else {
|
||||
currentRow = sheet.getRow(rowNum);
|
||||
}
|
||||
|
||||
if (currentRow.getCell(columnNum) != null) {
|
||||
HSSFCell currentCell = currentRow.getCell(columnNum);
|
||||
if (currentCell.getCellType() == CellType.STRING) {
|
||||
int length = currentCell.getStringCellValue().getBytes().length;
|
||||
if (columnWidth < length) {
|
||||
columnWidth = length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.setColumnWidth(columnNum, columnWidth * 256);
|
||||
}
|
||||
}
|
||||
|
||||
public void readExcelFile(InputStream inputStream, String fileName) {
|
||||
|
||||
/**
|
||||
* 这个inputStream文件可以来源于本地文件的流,
|
||||
* 也可以来源与上传上来的文件的流,也就是MultipartFile的流,
|
||||
* 使用getInputStream()方法进行获取。
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 然后再读取文件的时候,应该excel文件的后缀名在不同的版本中对应的解析类不一样
|
||||
* 要对fileName进行后缀的解析
|
||||
*/
|
||||
Workbook workbook = null;
|
||||
try {
|
||||
//判断什么类型文件
|
||||
if (fileName.endsWith(".xls")) {
|
||||
workbook = new HSSFWorkbook(inputStream);
|
||||
} else if (fileName.endsWith(".xlsx")) {
|
||||
workbook = new XSSFWorkbook(inputStream);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (workbook == null) {
|
||||
return;
|
||||
} else {
|
||||
//获取所有的工作表的的数量
|
||||
int numOfSheet = workbook.getNumberOfSheets();
|
||||
System.out.println(numOfSheet + "--->numOfSheet");
|
||||
//遍历表
|
||||
for (int i = 0; i < numOfSheet; i++) {
|
||||
//获取一个sheet也就是一个工作本。
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
if (sheet == null) {
|
||||
continue;
|
||||
}
|
||||
//获取一个sheet有多少Row
|
||||
int lastRowNum = sheet.getLastRowNum();
|
||||
if (lastRowNum == 0) {
|
||||
continue;
|
||||
}
|
||||
Row row;
|
||||
for (int j = 1; j <= lastRowNum; j++) {
|
||||
row = sheet.getRow(j);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
//获取一个Row有多少Cell
|
||||
short lastCellNum = row.getLastCellNum();
|
||||
for (int k = 0; k <= lastCellNum; k++) {
|
||||
if (row.getCell(k) == null) {
|
||||
continue;
|
||||
}
|
||||
row.getCell(k).setCellType(CellType.STRING);
|
||||
String res = row.getCell(k).getStringCellValue().trim();
|
||||
//打印出cell(单元格的内容)
|
||||
System.out.println(res);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导出excel Utils
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
public class ExcelUtils {
|
||||
private static Configuration configuration = null;
|
||||
private static Map<String, Template> allTemplates = null;
|
||||
private static String realPath = "src/main/resources/ftl";
|
||||
|
||||
public ExcelUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建excel
|
||||
*
|
||||
* @param dataMap
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static File createExcel(Map<?, ?> dataMap, String type, String valueName) {
|
||||
try {
|
||||
configuration = new Configuration();
|
||||
configuration.setDefaultEncoding("UTF-8");
|
||||
configuration.setDirectoryForTemplateLoading(new File(realPath));
|
||||
allTemplates = new HashMap<String, Template>();
|
||||
allTemplates.put(type, configuration.getTemplate(valueName));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
String name = "temp" + (int) (Math.random() * 100000) + ".xls";
|
||||
File file = new File(name);
|
||||
Template template = allTemplates.get(type);
|
||||
try {
|
||||
Writer w = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
|
||||
template.process(dataMap, w);
|
||||
w.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
/**
|
||||
* @ClassName ExpressSelectUtil
|
||||
* @Description TODO
|
||||
* @Author zhf
|
||||
* @Date 2024/5/8 17:39
|
||||
*/
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class ExpressSelectUtil {
|
||||
|
||||
//快递信息url
|
||||
private static final String URL = "https://eolink.o.apispace.com/wlgj1/paidtobuy_api/trace_search";
|
||||
//获取快递公司codeURL
|
||||
private static final String EXPRESS_COMPANY_URL = "https://eolink.o.apispace.com/wlgj1/paidtobuy_api/mail_discern";
|
||||
private static final String TOKEN = "vvzpibv7yzp2l89noyp8ut7tdjqqf1fq";
|
||||
|
||||
|
||||
public JSONObject getExpressInfo(String mailNo, String tel) {
|
||||
|
||||
if (StrUtil.isBlank(mailNo) || StrUtil.isBlank(tel)) {
|
||||
// return Result.error("获取物流信息参数错误");
|
||||
throw new RuntimeException("获取物流信息参数错误");
|
||||
}
|
||||
|
||||
String expressCompanyCode = getExpressCompanyCode(mailNo);
|
||||
if (StrUtil.isBlank(expressCompanyCode)) {
|
||||
// return Result.error("获取物流公司代码失败");
|
||||
throw new RuntimeException("获取物流信息参数错误");
|
||||
}
|
||||
|
||||
NutMap map = new NutMap();
|
||||
map.setv("cpCode", expressCompanyCode);
|
||||
map.setv("mailNo", mailNo);
|
||||
map.setv("tel", tel);
|
||||
String body = HttpUtil.createPost(URL).header("X-APISpace-Token", TOKEN)
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().body();
|
||||
JSONObject jsonBody = JSON.parseObject(body);
|
||||
|
||||
if (jsonBody.getBoolean("success")) {
|
||||
JSONObject logisticsTrace = JSON.parseObject(jsonBody.getString("logisticsTrace"));
|
||||
// return Result.success(logisticsTrace);
|
||||
return logisticsTrace;
|
||||
} else {
|
||||
//失败才返回
|
||||
// return Result.error(jsonBody.getString("msg"));
|
||||
throw new RuntimeException(jsonBody.getString("msg"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getExpressCompanyCode(String mailNo) {
|
||||
NutMap map = new NutMap();
|
||||
map.setv("mailNo", mailNo);
|
||||
String body = HttpUtil.createPost(EXPRESS_COMPANY_URL).header("X-APISpace-Token", TOKEN)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonBody = JSON.parseObject(body);
|
||||
if (jsonBody.getBoolean("success")) {
|
||||
JSONArray expressCompanyList = jsonBody.getJSONArray("expressCompanyList");
|
||||
|
||||
JSONObject expressCompany = JSON.parseObject(JSON.toJSONString(expressCompanyList.get(0)));
|
||||
return expressCompany.getString("cpCode");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import io.v.nutz.base.service.BaseService;
|
||||
import org.nutz.boot.starter.ftp.FtpService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.entity.Record;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author 赵欣雨
|
||||
* @date 2020/8/18 11:35
|
||||
*/
|
||||
@IocBean
|
||||
public class FileService {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private FtpService ftpService;
|
||||
|
||||
/**
|
||||
* @param file 文件
|
||||
* @param id 关联表id
|
||||
* @param filePath 文件主路径
|
||||
*/
|
||||
public void upload(TempFile file, String id, String filePath) {
|
||||
try {
|
||||
String submittedFileName = file.getSubmittedFileName();
|
||||
String fileType = submittedFileName.substring(submittedFileName.lastIndexOf(".")).toLowerCase();
|
||||
String fileName = System.currentTimeMillis() + fileType;
|
||||
ftpService.upload(filePath, fileName, file.getInputStream());
|
||||
Chain fileChain = Chain.make("id", R.UU32()).add("reid", id).add("filename", submittedFileName).add("filepath", filePath + fileName);
|
||||
baseService.insert("sys_file", fileChain);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileid
|
||||
* @param filePath
|
||||
*/
|
||||
public void delete(String fileid, String filePath) {
|
||||
try {
|
||||
|
||||
Record filedata = baseService.dao().fetch("sys_file", Cnd.where("id", "=", fileid).or("filepath", "=", filePath));
|
||||
|
||||
// baseService.clear("sys_file",Cnd.where("id", "=", filedata.getString("id")));
|
||||
|
||||
if (null == fileid) {
|
||||
baseService.clear("sys_file", Cnd.where("filepath", "=", filedata.getString("filepath")));
|
||||
} else {
|
||||
baseService.clear("sys_file", Cnd.where("id", "=", filedata.getString("id")));
|
||||
}
|
||||
|
||||
// ftpService.delete(filedata.getString("filepath"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.safety.Whitelist;
|
||||
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.parser.ParserDelegator;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author: Aaron
|
||||
* @create: 2020-10-12 21:13
|
||||
* @description:
|
||||
**/
|
||||
public class Html2Text extends HTMLEditorKit.ParserCallback {
|
||||
private static Html2Text html2Text = new Html2Text();
|
||||
|
||||
StringBuffer s;
|
||||
|
||||
public Html2Text() {
|
||||
}
|
||||
|
||||
public void parse(String str) throws IOException {
|
||||
|
||||
InputStream iin = new ByteArrayInputStream(str.getBytes());
|
||||
Reader in = new InputStreamReader(iin);
|
||||
s = new StringBuffer();
|
||||
ParserDelegator delegator = new ParserDelegator();
|
||||
delegator.parse(in, this, Boolean.TRUE);
|
||||
iin.close();
|
||||
in.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleText(char[] text, int pos) {
|
||||
s.append(text);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public static String getContent(String str) {
|
||||
try {
|
||||
html2Text.parse(str);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return html2Text.getText();
|
||||
}
|
||||
|
||||
public static String toPlainText(String html) {
|
||||
if (StringUtils.isEmpty(html)) {
|
||||
return "";
|
||||
}
|
||||
Document document = Jsoup.parse(html);
|
||||
Document.OutputSettings outputSettings = new Document.OutputSettings().prettyPrint(false);
|
||||
document.outputSettings(outputSettings);
|
||||
document.select("br").append("\\n");
|
||||
document.select("p").prepend("\\n");
|
||||
document.select("p").append("\\n");
|
||||
String newHtml = document.html().replaceAll("\\\\n", "\n");
|
||||
String plainText = Jsoup.clean(newHtml, "", Whitelist.none(), outputSettings);
|
||||
String result = StringEscapeUtils.unescapeHtml(plainText.trim());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import io.v.nutz.sys.models.Sys_log;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.services.SysUserService;
|
||||
import io.v.nutz.web.commons.shiro.token.PlatformCaptchaToken;
|
||||
import io.v.nutz.web.commons.slog.SLogService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Times;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @author jug
|
||||
* @date 2023/07/06
|
||||
*/
|
||||
@IocBean
|
||||
public class LoginUtil {
|
||||
|
||||
public enum LoginOrigin {
|
||||
APP, WEB, WEB_H5, CAS, QI_YE_WEI_XIN, WEI_XIN;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private SLogService sLogService;
|
||||
|
||||
@Inject
|
||||
private SysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 密码登录
|
||||
*
|
||||
* @param token 令牌
|
||||
* @param request 请求
|
||||
* @param session 会话
|
||||
* @param loginOrigin 登录起源
|
||||
*/
|
||||
public void doLogin(AuthenticationToken token, HttpServletRequest request, HttpSession session, LoginOrigin loginOrigin) {
|
||||
|
||||
//设置登录源
|
||||
PlatformCaptchaToken platformCaptchaToken = (PlatformCaptchaToken) token;
|
||||
platformCaptchaToken.setLoginOrigin(loginOrigin);
|
||||
|
||||
//session失效咯
|
||||
if (token == null) {
|
||||
throw new RuntimeException("login.error.system");
|
||||
}
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
ThreadContext.bind(subject);
|
||||
subject.login(token);
|
||||
Sys_user user = (Sys_user) subject.getPrincipal();
|
||||
int count = user.getLoginCount() == null ? 0 : user.getLoginCount();
|
||||
org.nutz.dao.Chain userUpdateChain = Chain.make("loginIp", user.getLoginIp()).add("loginAt", Times.getTS()).add("loginCount", count + 1).add("userOnline", true).add("loginSessionId", session.getId());
|
||||
sysUserService.update(userUpdateChain, Cnd.where("id", "=", user.getId()));
|
||||
Sys_log sysLog = new Sys_log();
|
||||
sysLog.setType("info");
|
||||
sysLog.setTag("用户登陆:" + loginOrigin);
|
||||
sysLog.setSrc(this.getClass().getName() + "#doLogin");
|
||||
sysLog.setMsg("成功登录系统!");
|
||||
sysLog.setIp(Lang.getIP(request));
|
||||
sysLog.setCreatedBy(user.getId());
|
||||
sysLog.setUsername(user.getUsername());
|
||||
sysLog.setLoginname(user.getLoginname());
|
||||
sLogService.async(sysLog);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户名登录
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @param request 请求
|
||||
* @param session 会话
|
||||
* @param loginOrigin 登录起源
|
||||
*/
|
||||
public void doLogin(String loginName, HttpServletRequest request, HttpSession session, LoginOrigin loginOrigin) {
|
||||
PlatformCaptchaToken token = new PlatformCaptchaToken(loginName, loginOrigin);
|
||||
token.setLoginOrigin(loginOrigin);
|
||||
doLogin(token, request, session, loginOrigin);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author zzr
|
||||
* @name:ManyAddOrRenewUtil
|
||||
* @Date 2024/7/24 16:16
|
||||
* @注释
|
||||
*/
|
||||
@IocBean
|
||||
public class ManyAddOrRenewUtil {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
/**
|
||||
* 批量新增或更新
|
||||
* @param list
|
||||
* @param mode true新增;false更新
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public <T> void addOrRenew(List<T> list, boolean mode) {
|
||||
try {
|
||||
executeInBatches(list, mode);
|
||||
} catch (Exception e) {
|
||||
// 在实际应用中,应该有更精细的异常处理策略
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void executeInBatches(List<T> list, boolean mode) throws InterruptedException, ExecutionException {
|
||||
int numberOfThreads = Runtime.getRuntime().availableProcessors() * 2;
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
|
||||
ExecutorCompletionService<Void> ecs = new ExecutorCompletionService<>(executorService);
|
||||
|
||||
int batchSize = 100;
|
||||
|
||||
// 在调用ecs.submit的地方添加futures列表
|
||||
List<Future<Void>> futures = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
final int end = Math.min(i + batchSize, list.size());
|
||||
List<T> batch = list.subList(i, end);
|
||||
|
||||
Future<Void> future = ecs.submit(() -> processBatch(batch, mode));
|
||||
futures.add(future);
|
||||
}
|
||||
|
||||
completeAllTasks(ecs, futures);
|
||||
|
||||
// 关闭线程池
|
||||
executorService.shutdown();
|
||||
}
|
||||
|
||||
private <T> Void processBatch(List<T> batch, boolean mode) {
|
||||
// 执行数据库更新操作
|
||||
if (mode) {
|
||||
dao.insert(batch);
|
||||
} else {
|
||||
dao.update(batch);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void completeAllTasks(ExecutorCompletionService<Void> ecs, List<Future<Void>> futures) throws InterruptedException, ExecutionException {
|
||||
for (Future<Void> future : futures) {
|
||||
// 等待任务完成
|
||||
future.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.v.nutz.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,274 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.v.nutz.base.enums.Env;
|
||||
import io.v.nutz.task.model.TaskToken;
|
||||
import io.v.nutz.web.commons.base.Globals;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.boot.starter.ftp.FtpService;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.http.Http;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zxy
|
||||
* @Description 消息API
|
||||
* @createTime 2022年01月27日 11:20:00
|
||||
*/
|
||||
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class MsgApi {
|
||||
|
||||
|
||||
private static final String APPID = "A91E11A5-265F-538D-F006-9B767135CAAF";
|
||||
private static final String APP_SECRET = "43FEEF7C-53ED-989A-ACFF-3250690D8EB0";
|
||||
private static final Integer USER_ID = 111700;
|
||||
|
||||
|
||||
private static final String QiYE_APPID = "wx3adc7f6c8df963cc";
|
||||
|
||||
private static final String QiYE_SECRET = "0owg1mnm6aabSyd0qHwCuMkiQKNQo0pWxxqvllhkkp4";
|
||||
|
||||
private static final String taskType = "企业微信";
|
||||
|
||||
private static String accessTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s";
|
||||
|
||||
/**
|
||||
* 获取token接口
|
||||
*/
|
||||
private static final String tokenApi = "http://message.cpu.edu.cn/api/token";
|
||||
|
||||
|
||||
/**
|
||||
* 获取可用通讯渠道
|
||||
*/
|
||||
private static final String COMMUNICATE_API = "http://message.cpu.edu.cn/api/tools";
|
||||
|
||||
/**
|
||||
* 短信api
|
||||
*/
|
||||
private static final String MSG_API = "http://message.cpu.edu.cn/api/send";
|
||||
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
@Inject
|
||||
private FtpService ftpService;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
|
||||
/**
|
||||
* @param title 标题
|
||||
* @param url 跳转链接
|
||||
* @param msgtype 消息类型 (textcard、text)
|
||||
* @param description 描述
|
||||
* @param loginNames 收件人
|
||||
*/
|
||||
public void sendWxMsg(String title, String url, String msgtype, String description, List<String> loginNames, String contentUrl) {
|
||||
|
||||
if ("否".equals(Globals.MyConfig.getString("SengMsg"))) {
|
||||
log.info("发送失败,消息暂未开启!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isBlank(description) || Lang.isEmpty(loginNames)) {
|
||||
log.info("发送失败,缺少需要参数请检查!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!"news".equals(msgtype)) {
|
||||
// title = "智慧工会";
|
||||
// }
|
||||
|
||||
String sendKey = Json.toJson(loginNames) + description;
|
||||
if (StrUtil.isNotBlank(redisService.get("send_msg_limit_" + sendKey))) {
|
||||
throw new RuntimeException("短信发送频繁,请一分钟后再试!");
|
||||
}
|
||||
redisService.setex("send_msg_limit_" + sendKey, 60, sendKey);
|
||||
log.info(redisService.get(sendKey));
|
||||
|
||||
String accessToken = getAccessToken();
|
||||
|
||||
String qiYeUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s";
|
||||
|
||||
List<List<String>> splitList = ListUtil.split(loginNames, 500);
|
||||
|
||||
|
||||
for (List<String> everyLoginNames : splitList) {
|
||||
String touser = String.join("|", everyLoginNames);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("touser", touser);
|
||||
map.put("totag", "智慧工会消息");
|
||||
map.put("msgtype", msgtype);
|
||||
map.put("agentid", 1000019);
|
||||
map.put("safe", "0 ");
|
||||
map.put("enable_id_trans", "0");
|
||||
map.put("enable_duplicate_check", "0");
|
||||
map.put("duplicate_check_interval", "1800");
|
||||
if (msgtype.equals("textcard")) {
|
||||
Map<String, Object> textcard = new HashMap<>(1);
|
||||
textcard.put("title", title);
|
||||
textcard.put("url", url);
|
||||
textcard.put("description", description);
|
||||
map.put("textcard", textcard);
|
||||
} else if (msgtype.equals("text")) {
|
||||
map.put("text", new NutMap().setv("content", description));
|
||||
} else if (msgtype.equals("news")) {
|
||||
List<NutMap> list = new ArrayList<>();
|
||||
NutMap m = new NutMap();
|
||||
m.put("title", title);
|
||||
m.put("description", description);
|
||||
//m.put("url", "");
|
||||
m.put("picurl", "https://zhghydd.cpu.edu.cn/file_server/fileStreamPreview?id="+contentUrl);
|
||||
list.add(m);
|
||||
map.put("news", Map.of("articles", list));
|
||||
}
|
||||
try {
|
||||
String response = HttpUtil.post(qiYeUrl.formatted(accessToken), Json.toJson(map));
|
||||
NutMap nutMap = Json.fromJson(NutMap.class, response);
|
||||
if (nutMap.getInt("errcode") == 0) {
|
||||
log.error("发送成功>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
} else {
|
||||
log.error("发送失败>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
log.info(response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 企业微信发送通知
|
||||
*
|
||||
* @param content 发送信息
|
||||
* @param toLoginNameList 收件人工号集合
|
||||
*/
|
||||
public void sendMsg(String content, List<String> toLoginNameList) {
|
||||
try {
|
||||
|
||||
List<NutMap> mapList = new ArrayList<>();
|
||||
toLoginNameList.forEach(v->{
|
||||
NutMap nutMap = new NutMap();
|
||||
nutMap.setv("touser",v);
|
||||
mapList.add(nutMap);
|
||||
});
|
||||
|
||||
String token = getToken();
|
||||
log.info(token);
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
|
||||
NutMap a = new NutMap() {{
|
||||
put("fromuser", "111700");
|
||||
put("content", content);
|
||||
// put("title", title);
|
||||
put("type", "text");
|
||||
put("priority", "1");
|
||||
// put("url", "https://www.baidu.com");
|
||||
put("tools", new ArrayList<NutMap>() {{
|
||||
add(new NutMap() {{
|
||||
put("tool", "wechat_enterprise");
|
||||
}});
|
||||
}});
|
||||
put("tousers", mapList);
|
||||
// put("tousers", new ArrayList<NutMap>() {{
|
||||
// add(new NutMap() {{
|
||||
//// put("touser", toUser);
|
||||
// put("touser", "1020060885");
|
||||
// }});
|
||||
// }});
|
||||
}};
|
||||
body.put("message", Json.toJson(a));
|
||||
log.info(Json.toJson(body));
|
||||
String postUrl = MSG_API + "?appid=" + APPID + "&tokenid=" + token + "&schoolcode=4";
|
||||
String post = Http.post(postUrl, body,10000);
|
||||
|
||||
JSONObject parseObject = JSON.parseObject(post);
|
||||
|
||||
log.info(Json.toJson(parseObject));
|
||||
if (parseObject.getString("retcode").equals("0")) {
|
||||
log.info("发送成功>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
} else {
|
||||
log.error(parseObject.getString("retcode"));
|
||||
log.info("发送失败>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getToken() {
|
||||
String token = redisService.get("msg_token");
|
||||
if (StrUtil.isBlank(token)) {
|
||||
String content = Http.get(tokenApi + "?appid=" + APPID + "&appsecret=" + APP_SECRET + "&schoolcode=4").getContent();
|
||||
NutMap map = Json.fromJson(NutMap.class, content);
|
||||
token = map.getString("access_token");
|
||||
redisService.setex("msg_token", 60 * 60, token);
|
||||
}
|
||||
return token;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取可用通讯渠道
|
||||
// * @return
|
||||
// */
|
||||
// private NutMap getCommunicate(){
|
||||
// String token = getToken();
|
||||
// String content = Http.get(COMMUNICATE_API + "?appId=" + APPID + "&tokenid=" + token + "&userid=" + USER_ID + "&schoolcode=4").getContent();
|
||||
// List<NutMap> list = Json.fromJsonAsList(NutMap.class, content);
|
||||
// List<NutMap> collect = list.stream().filter(v -> v.getString("toolname").equals("微信企业号")).collect(Collectors.toList());
|
||||
// NutMap nutMap = collect.stream().findFirst().orElse(null);
|
||||
// assert nutMap != null;
|
||||
// return new NutMap().addv("tool",nutMap.getString("toolid"));
|
||||
// }
|
||||
|
||||
|
||||
public String getAccessToken() {
|
||||
TaskToken taskToken = dao.fetch(TaskToken.class, Cnd.where("token_type", "=", taskType));
|
||||
if (Lang.isNotEmpty(taskToken) && System.currentTimeMillis() / 1000 < (taskToken.getGet_time() + taskToken.getExpires_in() - 200)) {
|
||||
return taskToken.getToken();
|
||||
}
|
||||
accessTokenUrl = accessTokenUrl.formatted(QiYE_APPID, QiYE_SECRET);
|
||||
String access_token = Json.fromJson(NutMap.class, Http.get(accessTokenUrl).getContent()).getString("access_token");
|
||||
TaskToken t = new TaskToken();
|
||||
t.setToken(access_token);
|
||||
t.setExpires_in(7200);
|
||||
t.setToken_type(taskType);
|
||||
t.setGet_time(System.currentTimeMillis() / 1000);
|
||||
dao.clear("task_token", Cnd.where("token_type", "=", taskType));
|
||||
dao.insert("task_token", Chain.from(t));
|
||||
return access_token;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import com.artofsolving.jodconverter.DocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
|
||||
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.ConnectException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author zxy
|
||||
* Date 2019/10/17
|
||||
**/
|
||||
public class Office2Pdf {
|
||||
public static boolean officeToPDF(String sourceFile, String destFile) {
|
||||
try {
|
||||
|
||||
File inputFile = new File(sourceFile);
|
||||
if (!inputFile.exists()) {
|
||||
// 找不到源文件, 则返回false
|
||||
return false;
|
||||
}
|
||||
// 如果目标路径不存在, 则新建该路径
|
||||
File outputFile = new File(destFile);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
}
|
||||
//如果目标文件存在,则删除
|
||||
if (outputFile.exists()) {
|
||||
outputFile.delete();
|
||||
}
|
||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
|
||||
connection.connect();
|
||||
//用于测试openOffice连接时间
|
||||
System.out.println("连接时间:" + df.format(new Date()));
|
||||
/*DocumentConverter converter = new StreamOpenOfficeDocumentConverter(
|
||||
connection);*/
|
||||
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
|
||||
converter.convert(inputFile, outputFile);
|
||||
//测试word转PDF的转换时间
|
||||
System.out.println("转换时间:" + df.format(new Date()));
|
||||
connection.disconnect();
|
||||
return true;
|
||||
} catch (ConnectException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("openOffice连接失败!请检查IP,端口");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package io.v.nutz.base.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.sys.models.Sys_office_template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.boot.starter.ftp.FtpService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@IocBean
|
||||
@Slf4j
|
||||
public class OfficeTemplateUtil {
|
||||
|
||||
@Inject
|
||||
private FtpService ftpService;
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
public String getPath(String templateCode) throws IOException {
|
||||
if (StrUtil.isBlank(templateCode)) {
|
||||
throw new NullPointerException("templateCode is null");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(templateCode)) {
|
||||
Sys_office_template officeTemplate = dao.fetch(Sys_office_template.class, Cnd.where("templateCode", "=", templateCode));
|
||||
if (null == officeTemplate) {
|
||||
throw new RuntimeException("officeTemplate is null,please check [templateCode] is right?");
|
||||
}
|
||||
|
||||
String templatePath = officeTemplate.getTemplatePath();
|
||||
String templateName = officeTemplate.getTemplateName();
|
||||
String extName = FileUtil.extName(templateName);
|
||||
|
||||
Path localTempFilePath = Files.createTempFile(null, "." + extName);
|
||||
File localTempFile = localTempFilePath.toFile();
|
||||
FileOutputStream outputStream = new FileOutputStream(localTempFile);
|
||||
ftpService.download(templatePath, outputStream);
|
||||
|
||||
//一分钟后删除临时文件 哈哈哈🙉🙉🙉🙉🙉🙉🙉🙉
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
FileUtil.del(localTempFile);
|
||||
log.info(">>>>>>>>>>>>临时文件删除成功");
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, "OfficeTemplateUtil_deleteTemp").start();
|
||||
|
||||
return localTempFilePath.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputStream getInputStream(String templateCode) throws IOException {
|
||||
if (StrUtil.isBlank(templateCode)) {
|
||||
throw new NullPointerException("templateCode is null");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(templateCode)) {
|
||||
Sys_office_template officeTemplate = dao.fetch(Sys_office_template.class, Cnd.where("templateCode", "=", templateCode));
|
||||
if (null == officeTemplate) {
|
||||
throw new RuntimeException("officeTemplate is null,please check [templateCode] is right?");
|
||||
}
|
||||
|
||||
return ftpService.connect().retrieveFileStream(officeTemplate.getTemplatePath());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user