换成maven构建工具

This commit is contained in:
liwen
2020-12-29 21:48:00 +08:00
parent df481557b6
commit 4110bc5d20
301 changed files with 668 additions and 749 deletions

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

View File

Binary file not shown.

View File

@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

View File

Binary file not shown.

View File

Binary file not shown.

164
falsework-sever/pom.xml Normal file
View File

@@ -0,0 +1,164 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.epri</groupId>
<artifactId>falsework-sever</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>falsework-sever</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.14</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency>
<dependency>
<groupId>DmJdbcDriver</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/DmJdbcDriver-1.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>pinyin4j</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/pinyin4j-2.5.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,29 @@
create table auth_client_service
(
id INTEGER not null
constraint INDEX33557415
primary key,
service_id VARCHAR(255),
client_id VARCHAR(255),
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (1, '3', '1', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2, '2', '1', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (3, '2', '3', null, '2017-12-31 08:58:03.000000', 'null', 'null', 'null', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (16, '1', '7', null, '2018-11-15 19:50:50.055000', '9', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (17, '2', '7', null, '2018-11-15 19:50:50.067000', '9', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (18, '3', '7', null, '2018-11-15 19:50:50.072000', '9', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.auth_client_service (id, service_id, client_id, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (19, '7', '7', null, '2018-11-15 19:50:50.077000', '9', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,53 @@
create table base_element
(
id INTEGER not null
constraint INDEX33557417
primary key,
code VARCHAR(255),
type VARCHAR(255),
name VARCHAR(255),
uri VARCHAR(255),
menu_id VARCHAR(255),
parent_id VARCHAR(255),
path VARCHAR(2000),
method VARCHAR(10),
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (4, 'menuManager:element', 'uri', '按钮页面', '/admin/element', '6', null, null, 'GET', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (5, 'menuManager:btn_add', 'button', '新增', '/admin/menu/{*}', '6', null, null, 'POST', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (6, 'menuManager:btn_edit', 'button', '编辑', '/admin/menu/{*}', '6', '', '', 'PUT', '', '2017-06-24 00:00:00.000000', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (7, 'menuManager:btn_del', 'button', '删除', '/admin/menu/{*}', '6', '', '', 'DELETE', '', '2017-06-24 00:00:00.000000', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (8, 'menuManager:btn_element_add', 'button', '新增元素', '/admin/element', '6', null, null, 'POST', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (9, 'menuManager:btn_element_edit', 'button', '编辑元素', '/admin/element/{*}', '6', null, null, 'PUT', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (10, 'menuManager:btn_element_del', 'button', '删除元素', '/admin/element/{*}', '6', null, null, 'DELETE', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (12, 'groupManager:btn_edit', 'button', '编辑', '/admin/group/{*}', '7', null, null, 'PUT', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (14, 'groupManager:btn_userManager', 'button', '分配用户', '/admin/group/{*}/user', '7', null, null, 'PUT', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (15, 'groupManager:btn_resourceManager', 'button', '分配权限', '/admin/group/{*}/authority', '7', null, null, 'GET', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (16, 'groupManager:menu', 'uri', '分配菜单', '/admin/group/{*}/authority/menu', '7', null, null, 'POST', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (17, 'groupManager:element', 'uri', '分配资源', '/admin/group/{*}/authority/element', '7', null, null, 'POST', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (19, 'menuManager:view', 'uri', '查看', '/admin/menu/{*}', '6', '', '', 'GET', '', '2017-06-26 00:00:00.000000', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (20, 'menuManager:element_view', 'uri', '查看', '/admin/element/{*}', '6', null, null, 'GET', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (22, 'groupTypeManager:view', 'uri', '查看', '/admin/groupType/{*}', '8', null, null, 'GET', '', null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (23, 'groupTypeManager:btn_add', 'button', '新增', '/admin/groupType', '8', null, null, 'POST', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (24, 'groupTypeManager:btn_edit', 'button', '编辑', '/admin/groupType/{*}', '8', null, null, 'PUT', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (25, 'groupTypeManager:btn_del', 'button', '删除', '/admin/groupType/{*}', '8', null, null, 'DELETE', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (27, 'serviceManager:view', 'URI', '查看', '/auth/service/{*}', '10', null, null, 'GET', null, '2017-12-26 20:17:42.000000', '1', 'Mr.AG', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (28, 'serviceManager:btn_add', 'button', '新增', '/auth/service', '10', null, null, 'POST', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (29, 'serviceManager:btn_edit', 'button', '编辑', '/auth/service/{*}', '10', null, null, 'PUT', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (30, 'serviceManager:btn_del', 'button', '删除', '/auth/service/{*}', '10', null, null, 'DELETE', null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (31, 'serviceManager:btn_clientManager', 'button', '服务授权', '/auth/service/{*}/client', '10', null, null, 'POST', null, '2017-12-30 16:32:48.000000', '1', 'Mr.AG', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (34, 'home', 'uri', '查看', 'home/', '16', null, null, 'GET', null, '2018-11-08 17:50:05.437000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_element (id, code, type, name, uri, menu_id, parent_id, path, method, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (37, 'userManager:btn_add', 'button', '添加', '', '1', null, null, 'POST', '', '2020-09-17 09:31:03.257000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,34 @@
create table base_group
(
id INTEGER not null
constraint INDEX33557421
primary key,
code VARCHAR(255),
name VARCHAR(255),
parent_id INTEGER not null,
path VARCHAR(2000),
type CHAR(1),
group_type INTEGER not null,
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
upd_time TIMESTAMP(26,6),
upd_user VARCHAR(255),
upd_name VARCHAR(255),
upd_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_group (id, code, name, parent_id, path, type, group_type, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (7, 'financeDepart', '财务部', 6, '/company/financeDepart', null, 2, '', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group (id, code, name, parent_id, path, type, group_type, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (8, 'hrDepart', '人力资源部', 6, '/company/hrDepart', null, 2, '', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group (id, code, name, parent_id, path, type, group_type, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (9, 'admin', '管理员', -1, null, null, 1, '管理员', '2020-09-16 16:52:18.174000', '1', 'admin', '127.0.0.1', '2020-09-16 16:52:18.175000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group (id, code, name, parent_id, path, type, group_type, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (10, 'youke', '游客', -1, null, null, 1, 'aaa', '2020-10-26 16:10:36.949000', '1', 'admin', '127.0.0.1', '2020-10-26 16:10:36.949000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,30 @@
create table base_group_leader
(
id INTEGER not null
constraint INDEX33557423
primary key,
group_id INTEGER,
user_id INTEGER,
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
upd_time TIMESTAMP(26,6),
upd_user VARCHAR(255),
upd_name VARCHAR(255),
upd_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_group_leader (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (32, 4, 29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_leader (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (35, 3, 29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_leader (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (36, 1, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_leader (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (37, 9, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,32 @@
create table base_group_member
(
id INTEGER not null
constraint INDEX33557425
primary key,
group_id INTEGER,
user_id INTEGER,
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
upd_time TIMESTAMP(26,6),
upd_user VARCHAR(255),
upd_name VARCHAR(255),
upd_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (54, 4, 29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (57, 3, 29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (58, 1, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (59, 1, 4, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (60, 1, 29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_member (id, group_id, user_id, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (61, 9, 1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,29 @@
create table base_group_type
(
id INTEGER not null
constraint INDEX33557429
primary key,
code VARCHAR(255),
name VARCHAR(255),
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
upd_time TIMESTAMP(26,6),
upd_user VARCHAR(255),
upd_name VARCHAR(255),
upd_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_group_type (id, code, name, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (1, 'role', '角色类型', 'role', null, null, null, null, '2017-08-25 17:52:37.000000', '1', 'Mr.AG', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_type (id, code, name, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2, 'depart', '部门类型', '部门类型', null, null, null, null, '2020-08-01 19:25:33.984000', '1', 'Mr.AG', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_group_type (id, code, name, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (3, 'free', '自定义类型', 'sadf', null, null, null, null, '2017-08-26 08:22:25.000000', '1', 'Mr.AG', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,46 @@
create table base_menu
(
id INTEGER not null
constraint INDEX33557431
primary key,
code VARCHAR(255),
title VARCHAR(255),
parent_id INTEGER not null,
href VARCHAR(255),
icon VARCHAR(255),
type CHAR(10),
order_num INTEGER default 0 not null,
description VARCHAR(255),
path VARCHAR(500),
enabled CHAR(1),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
upd_time TIMESTAMP(26,6),
upd_user VARCHAR(255),
upd_name VARCHAR(255),
upd_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (1, 'userManager', '用户管理', 5, 'com.epri.fx.client.gui.uicomponents.admin.user.UserManagementController', 'yonghuguanli_huaban', 'menu ', 11, '', '/adminSys/baseManager/userManager', null, '2020-10-14 15:59:15.380000', '1', 'admin', '127.0.0.1', '2020-10-14 15:59:15.381000', '1', 'admin', '127.0.0.1', 'admin/user/index', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (5, 'baseManager', '基础配置管理', 13, '/admin', 'jichupeizhi', 'dirt ', 2, '', '/adminSys/baseManager', null, '2020-10-14 16:15:25.384000', '1', 'admin', '127.0.0.1', '2020-10-14 16:15:25.384000', '1', 'admin', '127.0.0.1', 'Layout', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (6, 'menuManager', '菜单管理', 5, 'com.epri.fx.client.gui.uicomponents.admin.menu.MenuManagementController', 'jiaoyixulie', 'menu ', 12, '你大爷', '/adminSys/baseManager/menuManager', null, '2020-09-18 16:53:21.998000', '1', 'admin', '127.0.0.1', '2020-09-18 16:53:21.998000', '1', 'admin', '127.0.0.1', 'admin/menu/index', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (7, 'groupManager', '角色权限管理', 5, 'com.epri.fx.client.gui.uicomponents.admin.group.GroupManagementController', 'gongnengjiaosequanxianguanli', 'menu ', 13, '', '/adminSys/baseManager/groupManager', null, '2020-08-20 15:45:42.451000', '1', 'admin', '127.0.0.1', '2020-08-20 15:45:42.451000', '1', 'admin', '127.0.0.1', 'admin/group/index', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (8, 'groupTypeManager', '角色类型管理', 5, 'com.epri.fx.client.gui.uicomponents.admin.grouptype.GroupTypeManagementController', 'jiaoseleixing', 'menu ', 14, '', '/adminSys/baseManager/groupTypeManager', null, '2020-08-20 15:45:48.931000', '1', 'admin', '127.0.0.1', '2020-08-20 15:45:48.931000', '1', 'admin', '127.0.0.1', 'admin/groupType/index', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (13, 'adminSys', '系统菜单', -1, '/base', 'align-justify', 'dirt ', 0, '', '/adminSys', null, '2020-08-02 18:39:34.519000', '1', 'admin', '127.0.0.1', '2020-08-02 18:39:34.520000', '1', 'admin', '127.0.0.1', 'Layout', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (27, 'gateLogManager', '操作日志', 5, '/admin/gateLog', 'caozuorizhi', 'menu ', 15, '', '/adminSys/baseManager/gateLogManager', null, '2020-08-20 15:45:55.329000', '1', 'admin', '127.0.0.1', '2020-08-20 15:45:55.329000', '1', 'admin', '127.0.0.1', 'admin/gateLog/index', null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (44, 'home', '主页', 13, 'com.epri.fx.client.gui.uicomponents.home.HomeController', 'home-outline', null, 0, '', 'com.epri.fx.client.gui.uicomponents.home.HomeController', null, '2020-08-03 15:51:48.077000', '1', 'admin', '127.0.0.1', '2020-08-03 15:51:48.077000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (45, 'baseInfo', '基础信息录入', 13, '', 'jichuxinxi', null, 1, '基础信息录入', null, null, '2020-10-14 17:20:25.202000', '1', 'admin', '127.0.0.1', '2020-10-14 17:20:25.202000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (46, 'base', '基础参数', 45, 'com.epri.fx.client.gui.uicomponents.basicInfo.BasicDataSetController', 'jichucanshu', null, 0, '', null, null, '2020-10-14 17:20:04.099000', '1', 'admin', '127.0.0.1', '2020-10-14 17:20:04.099000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (47, '', '煤价差', 45, 'com.epri.fx.client.gui.uicomponents.basicInfo.CoalPriceDiffController', 'Energy-', null, 1, '', null, null, '2020-10-14 17:19:46.835000', '1', 'admin', '127.0.0.1', '2020-10-14 17:19:46.835000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (48, '', '铁路成本', 45, 'com.epri.fx.client.gui.uicomponents.basicInfo.RailwayCostController', 'tieluyunshu', null, 2, '', null, null, '2020-10-14 17:20:41.287000', '1', 'admin', '127.0.0.1', '2020-10-14 17:20:41.287000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_menu (id, code, title, parent_id, href, icon, type, order_num, description, path, enabled, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (49, '', '现行运价', 45, 'com.epri.fx.client.gui.uicomponents.basicInfo.CurrentFreightController', 'hangzheng', null, 3, '', null, null, '2020-10-14 17:21:09.450000', '1', 'admin', '127.0.0.1', '2020-10-14 17:21:09.450000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,86 @@
create table base_resource_authority
(
id INTEGER not null
constraint INDEX33557407
primary key,
authority_id VARCHAR(255),
authority_type VARCHAR(255),
resource_id VARCHAR(255),
resource_type VARCHAR(255),
parent_id VARCHAR(255),
path VARCHAR(2000),
description VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255),
attr1 VARCHAR(255),
attr2 VARCHAR(255),
attr3 VARCHAR(255),
attr4 VARCHAR(255),
attr5 VARCHAR(255),
attr6 VARCHAR(255),
attr7 VARCHAR(255),
attr8 VARCHAR(255)
);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2165, '1', 'group', '1', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2166, '1', 'group', '5', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2167, '1', 'group', '4', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2168, '1', 'group', '5', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2169, '1', 'group', '6', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2170, '1', 'group', '7', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2171, '1', 'group', '8', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2172, '1', 'group', '9', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2173, '1', 'group', '10', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2174, '1', 'group', '19', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2175, '1', 'group', '20', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2176, '1', 'group', '6', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2177, '1', 'group', '11', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2178, '1', 'group', '12', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2179, '1', 'group', '13', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2180, '1', 'group', '14', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2181, '1', 'group', '15', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2182, '1', 'group', '16', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2183, '1', 'group', '17', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2184, '1', 'group', '21', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2185, '1', 'group', '26', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2186, '1', 'group', '7', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2187, '1', 'group', '22', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2188, '1', 'group', '23', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2189, '1', 'group', '24', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2190, '1', 'group', '25', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2191, '1', 'group', '8', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2192, '1', 'group', '27', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2193, '1', 'group', '44', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2316, '9', 'group', '37', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2317, '9', 'group', '1', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2318, '9', 'group', '5', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2319, '9', 'group', '4', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2320, '9', 'group', '5', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2321, '9', 'group', '6', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2322, '9', 'group', '7', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2323, '9', 'group', '8', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2324, '9', 'group', '9', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2325, '9', 'group', '10', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2326, '9', 'group', '19', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2327, '9', 'group', '20', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2328, '9', 'group', '6', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2329, '9', 'group', '12', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2330, '9', 'group', '14', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2331, '9', 'group', '15', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2332, '9', 'group', '16', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2333, '9', 'group', '17', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2334, '9', 'group', '7', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2335, '9', 'group', '22', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2336, '9', 'group', '23', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2337, '9', 'group', '24', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2338, '9', 'group', '25', 'button', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2339, '9', 'group', '8', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2340, '9', 'group', '27', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2341, '9', 'group', '44', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2342, '9', 'group', '45', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2343, '9', 'group', '46', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2344, '9', 'group', '47', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2345, '9', 'group', '48', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_resource_authority (id, authority_id, authority_type, resource_id, resource_type, parent_id, path, description, crt_time, crt_user, crt_name, crt_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (2346, '9', 'group', '49', 'menu', '-1', null, null, null, null, null, null, null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,38 @@
create table base_user
(
id INTEGER not null
constraint INDEX33557409
primary key,
username VARCHAR(255) default 'NULL',
password VARCHAR(255) default 'NULL',
name VARCHAR(255) default 'NULL',
birthday VARCHAR(255) default 'NULL',
address VARCHAR(255) default 'NULL',
mobile_phone VARCHAR(255) default 'NULL',
tel_phone VARCHAR(255) default 'NULL',
email VARCHAR(255) default 'NULL',
sex CHAR(2) default 'NULL',
type CHAR(1) default 'NULL',
status CHAR(1) default 'NULL',
description VARCHAR(255) default 'NULL',
crt_time TIMESTAMP(26,6) default NULL,
crt_user VARCHAR(255) default 'NULL',
crt_name VARCHAR(255) default 'NULL',
crt_host VARCHAR(255) default 'NULL',
upd_time TIMESTAMP(26,6) default NULL,
upd_user VARCHAR(255) default 'NULL',
upd_name VARCHAR(255) default 'NULL',
upd_host VARCHAR(255) default 'NULL',
attr1 VARCHAR(255) default 'NULL',
attr2 VARCHAR(255) default 'NULL',
attr3 VARCHAR(255) default 'NULL',
attr4 VARCHAR(255) default 'NULL',
attr5 VARCHAR(255) default 'NULL',
attr6 VARCHAR(255) default 'NULL',
attr7 VARCHAR(255) default 'NULL',
attr8 VARCHAR(255) default 'NULL'
);
INSERT INTO IPSM_DBA.base_user (id, username, password, name, birthday, address, mobile_phone, tel_phone, email, sex, type, status, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (1, 'admin', '$2a$12$/Xa6YcdVm387zA.EE/6xce11UX.AZBiwerBztXLAVBMhVKQ/pZfNW', 'liwen', '', null, '', null, '', '', null, null, '', '2020-09-10 16:58:10.327000', '1', 'admin', '127.0.0.1', '2020-10-28 10:08:32.279000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_user (id, username, password, name, birthday, address, mobile_phone, tel_phone, email, sex, type, status, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (4, 'blog', '$2a$12$oAXfILUbaRuD.ccalygnSeGvgg0MKkg9IqKHaYEf.rEtppqB67lrS', 'Mr.Liwen(博主)', '', null, '', null, '', '', null, null, '12', '2020-10-22 09:51:08.219000', '1', 'admin', '127.0.0.1', '2020-10-22 09:51:08.220000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);
INSERT INTO IPSM_DBA.base_user (id, username, password, name, birthday, address, mobile_phone, tel_phone, email, sex, type, status, description, crt_time, crt_user, crt_name, crt_host, upd_time, upd_user, upd_name, upd_host, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8) VALUES (29, 'test', '$2a$12$OjXths1o8rJ3oGykW3yQyuDokbZqMUlp2KXNfgYA2IObA8HVqXlJK', 'test', null, null, null, null, null, '', null, null, 'test', '2020-08-03 16:48:49.075000', '1', 'admin', '127.0.0.1', '2020-08-04 17:17:42.056000', '1', 'admin', '127.0.0.1', null, null, null, null, null, null, null, null);

View File

@@ -0,0 +1,51 @@
create table gate_log
(
id INTEGER not null
constraint INDEX33557411
primary key,
menu VARCHAR(255),
opt VARCHAR(255),
uri VARCHAR(255),
crt_time TIMESTAMP(26,6),
crt_user VARCHAR(255),
crt_name VARCHAR(255),
crt_host VARCHAR(255)
);
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (23, '用户管理', '删除', '/admin/user/{*}', '2018-11-16 14:33:52.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (24, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:35:39.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (25, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:36:44.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (26, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:39:28.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (27, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:40:56.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (28, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:42:25.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (29, '用户管理', '编辑', '/admin/user/{*}', '2018-11-16 14:43:54.000000', '9', 'admin', '/127.0.0.1:53169');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (30, '角色类型管理', '删除', '/admin/groupType/{*}', '2018-11-16 15:17:57.000000', '9', 'admin', '/127.0.0.1:54049');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (31, '角色类型管理', '删除', '/admin/groupType/{*}', '2018-11-16 15:17:58.000000', '9', 'admin', '/127.0.0.1:54049');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (32, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:51.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (33, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:52.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (34, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:53.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (35, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:54.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (36, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:55.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (37, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-16 15:40:57.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (38, '角色权限管理', '分配菜单', '/admin/group/{*}/authority/menu', '2018-11-16 15:41:54.000000', '9', 'admin', '/127.0.0.1:54428');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (39, '角色类型管理', '新增', '/admin/groupType', '2018-11-16 15:43:08.000000', '9', 'admin', '/127.0.0.1:54454');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (40, '角色权限管理', '新增', '/admin/group', '2018-11-16 15:52:53.000000', '9', 'admin', '/127.0.0.1:54780');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (41, '角色权限管理', '新增', '/admin/group', '2018-11-16 15:53:18.000000', '9', 'admin', '/127.0.0.1:54780');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (42, '角色类型管理', '删除', '/admin/groupType/{*}', '2018-11-16 15:59:20.000000', '9', 'admin', '/127.0.0.1:54909');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (43, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:02:49.000000', '9', 'admin', '/127.0.0.1:56699');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (44, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:03:03.000000', '9', 'admin', '/127.0.0.1:56699');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (45, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:03:18.000000', '9', 'admin', '/127.0.0.1:56699');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (46, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:04:27.000000', '9', 'admin', '/127.0.0.1:56747');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (47, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:04:53.000000', '9', 'admin', '/127.0.0.1:56747');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (48, '菜单管理', '编辑', '/admin/menu/{*}', '2018-11-21 11:05:06.000000', '9', 'admin', '/127.0.0.1:56747');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (49, '角色权限管理', '分配资源', '/admin/group/{*}/authority/element', '2018-11-29 10:29:00.000000', '9', 'admin', '/127.0.0.1:53564');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (50, '角色权限管理', '分配菜单', '/admin/group/{*}/authority/menu', '2018-11-29 10:29:05.000000', '9', 'admin', '/127.0.0.1:53564');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (51, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:29:56.000000', '9', 'admin', '/127.0.0.1:53611');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (52, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:34:34.000000', '9', 'admin', '/127.0.0.1:53688');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (53, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:37:14.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (54, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:37:16.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (55, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:37:17.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (56, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:37:33.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (57, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:38:27.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (58, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:39:24.000000', '9', 'admin', '/127.0.0.1:53745');
INSERT INTO IPSM_DBA.gate_log (id, menu, opt, uri, crt_time, crt_user, crt_name, crt_host) VALUES (59, '用户管理', '编辑', '/admin/user/{*}', '2018-11-29 10:39:48.000000', '9', 'admin', '/127.0.0.1:53745');

View File

@@ -0,0 +1,25 @@
create table rsa_key
(
KEY VARCHAR(200) not null
constraint INDEX33557624
primary key,
VALUE VARCHAR(2000) not null
);
INSERT INTO IPSM_DBA.rsa_key ("KEY", "VALUE") VALUES ('IPSM:AUTH:JWT:PRI', 'MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIaPvusxk+x8KcVONjFUo+ursfLx
SwOIvci5q0xPa+nUm3C0uu3jX1RQP+s3hWqCb7KgR67HDcZUS8bn2pNzJJWJ352lrpVrb1wftOot
mrWPhnrdr9sdcgE2pLV8HAy18pq+agXmjWnkf+T558zo5k3I8VBVcTfzsL6HLc5mFt/dAgMBAAEC
gYAYkZpsWwsFPM5rphIjA69CUoEVOJVXudndEnmCX2X2tckD1RvkX4WCYXyqN+L2RYabeMRd1x5e
vflwAdlY3sco+otA0Ld9vP9yadlbfjuxzA8XyuvomaZPeJjMxL3dZnEvy29SMkNx3358ILp3BwGg
e16GYPNZAjbB9fF+9YcggQJBAMs67m65cu2/h9Fe8+kevU32VVF6WZ3+506tYJFmsEbNILp+HFMK
yp/OXX5DIMJIVA5f9ZYzG9GIgyaNMaKaFlECQQCpgEkflrwhwMkyOqJ0bJDB6GDk6iql2onR4bzF
2sExbwYh5FjKdSQay+UIvrxLDvJOHyiySKL3rHxQggrgtbHNAkBVfQSvLvNZbygCup5/gZ7AHM7m
50CrZX6HagclIr0kC0WpLUNc6z0w2+4YHsS49RPmuBbmh7k7+uCwZtRqQccBAkAeFunkM6v+Ce0t
f38rT8J6ybe5q2AaxSrGGV6bePPmxKDAD3s7pYPdRejInqNqZ6LX/2wICiDz+qiu2gb4UQjZAkAx
RtRw7QzNu/5aLnU5pxdD33lE+fubQSkq17y3JfeLO2/HsIl0BnKUQGg4TaKpYOaEoHZpgyd2pwlm
UuNuRalU
');
INSERT INTO IPSM_DBA.rsa_key ("KEY", "VALUE") VALUES ('IPSM:AUTH:JWT:PUB', 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCGj77rMZPsfCnFTjYxVKPrq7Hy8UsDiL3IuatM
T2vp1JtwtLrt419UUD/rN4Vqgm+yoEeuxw3GVEvG59qTcySVid+dpa6Va29cH7TqLZq1j4Z63a/b
HXIBNqS1fBwMtfKavmoF5o1p5H/k+efM6OZNyPFQVXE387C+hy3OZhbf3QIDAQAB
');

View File

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server;
import com.epri.fx.server.util.DBLog;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@MapperScan("com.epri.fx.server.mapper")
@SpringBootApplication(exclude=SecurityAutoConfiguration.class)
public class ServerApplication {
public static void main(String[] args) {
DBLog.getInstance().start();
SpringApplication.run(ServerApplication.class, args);
}
}

View File

@@ -0,0 +1,42 @@
package com.epri.fx.server.config;
import com.epri.fx.server.filter.ReplaceStreamFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter;
/**
* @author 01
* @program wrapper-demo
* @description 过滤器配置类
* @create 2018-12-24 21:06
* @since 1.0
**/
@Configuration
public class FilterConfig {
/**
* 注册过滤器
*
* @return FilterRegistrationBean
*/
@Bean
public FilterRegistrationBean someFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(replaceStreamFilter());
registration.addUrlPatterns("/*");
registration.setName("streamFilter");
return registration;
}
/**
* 实例化StreamFilter
*
* @return Filter
*/
@Bean(name = "replaceStreamFilter")
public Filter replaceStreamFilter() {
return new ReplaceStreamFilter();
}
}

View File

@@ -0,0 +1,18 @@
package com.epri.fx.server.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* @author ace
* @create 2017/12/17.
*/
@Configuration
@Data
public class KeyConfiguration {
@Value("${jwt.rsa-secret}")
private String userSecret;
private byte[] userPubKey;
private byte[] userPriKey;
}

View File

@@ -0,0 +1,42 @@
package com.epri.fx.server.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
/**
* @Description:
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:55 上午
*/
@Configuration
public class UserAuthConfig {
@Value("${auth.user.token-header}")
private String tokenHeader;
private byte[] pubKeyByte;
public String getTokenHeader() {
return tokenHeader;
}
public void setTokenHeader(String tokenHeader) {
this.tokenHeader = tokenHeader;
}
public String getToken(HttpServletRequest request) {
return request.getHeader(this.getTokenHeader());
}
public byte[] getPubKeyByte() {
return pubKeyByte;
}
public void setPubKeyByte(byte[] pubKeyByte) {
this.pubKeyByte = pubKeyByte;
}
}

View File

@@ -0,0 +1,16 @@
package com.epri.fx.server.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* @author ace
* @create 2017/12/26.
*/
@Configuration
@Data
public class UserConfiguration {
@Value("${jwt.token-header}")
private String userTokenHeader;
}

View File

@@ -0,0 +1,63 @@
package com.epri.fx.server.config;
import com.epri.fx.server.handler.GlobalExceptionHandler;
import com.epri.fx.server.interceptor.LogInterceptor;
import com.epri.fx.server.interceptor.UserAuthRestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.ArrayList;
import java.util.Collections;
/**
* @author ace
* @date 2017/9/8
*/
@Configuration("admimWebConfig")
@Primary
public class WebConfiguration implements WebMvcConfigurer {
@Bean
GlobalExceptionHandler getGlobalExceptionHandler() {
return new GlobalExceptionHandler();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getUserAuthRestInterceptor()).addPathPatterns(getIncludePathPatterns());
registry.addInterceptor(getLogInterceptor()).addPathPatterns(getIncludePathPatterns());
}
@Bean
UserAuthRestInterceptor getUserAuthRestInterceptor() {
return new UserAuthRestInterceptor();
}
@Bean
LogInterceptor getLogInterceptor() {
return new LogInterceptor();
}
/**
* 需要用户和服务认证判断的路径
* @return
*/
private ArrayList<String> getIncludePathPatterns() {
ArrayList<String> list = new ArrayList<>();
String[] urls = {
"/element/**",
"/gateLog/**",
"/group/**",
"/groupType/**",
"/menu/**",
"/user/**",
"/api/permissions"
};
Collections.addAll(list, urls);
return list;
}
}

View File

@@ -0,0 +1,41 @@
package com.epri.fx.server.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
//@Configuration
//@EnableWebSecurity//开启Spring安全
//@EnableGlobalMethodSecurity(prePostEnabled=true)//开启Spring方法级安全
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
/*
* 配置为从内存中进行加载认证信息.
* 这里配置了两个用户 admin和user
*/
auth.inMemoryAuthentication()
.withUser("admin")
.password(passwordEncoder().encode("123456"))
.roles("admin");
auth.inMemoryAuthentication()
.withUser("user")
.password(passwordEncoder().encode("123456"))
.roles("normal");
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}

View File

@@ -0,0 +1,36 @@
package com.epri.fx.server.constant;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/7/2 12:40 下午
*/
public class AdminCommonConstant {
public final static int ROOT = -1;
public final static int DEFAULT_GROUP_TYPE = 0;
/**
* 权限关联类型
*/
public final static String AUTHORITY_TYPE_GROUP = "group";
/**
* 权限资源类型
*/
public final static String RESOURCE_TYPE_MENU = "menu";
public final static String RESOURCE_TYPE_BTN = "button";
public final static String RESOURCE_REQUEST_METHOD_GET = "GET";
public final static String RESOURCE_REQUEST_METHOD_PUT = "PUT";
public final static String RESOURCE_REQUEST_METHOD_DELETE = "DELETE";
public final static String RESOURCE_REQUEST_METHOD_POST = "POST";
public final static String RESOURCE_ACTION_VISIT = "访问";
public final static String BOOLEAN_NUMBER_FALSE = "0";
public final static String BOOLEAN_NUMBER_TRUE = "1";
}

View File

@@ -0,0 +1,28 @@
package com.epri.fx.server.constant;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:55 上午
*/
public class CommonConstants {
public final static String RESOURCE_TYPE_MENU = "menu";
public final static String RESOURCE_TYPE_BTN = "button";
// 用户token异常
public static final Integer EX_USER_INVALID_CODE = 40101;
public static final Integer EX_USER_PASS_INVALID_CODE = 40001;
// 客户端token异常
public static final Integer EX_CLIENT_INVALID_CODE = 40301;
public static final Integer EX_CLIENT_FORBIDDEN_CODE = 40331;
public static final Integer EX_OTHER_CODE = 500;
public static final String CONTEXT_KEY_USER_ID = "currentUserId";
public static final String CONTEXT_KEY_USERNAME = "currentUserName";
public static final String CONTEXT_KEY_USER_NAME = "currentUser";
public static final String CONTEXT_KEY_USER_TOKEN = "currentUserToken";
public static final String JWT_KEY_USER_ID = "userId";
public static final String JWT_KEY_NAME = "name";
}

View File

@@ -0,0 +1,16 @@
package com.epri.fx.server.constant;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:55 上午
*/
public class RestCodeConstants {
public static final int TOKEN_ERROR_CODE = 40101;
public static final int TOKEN_FORBIDDEN_CODE = 40301;
}

View File

@@ -0,0 +1,11 @@
package com.epri.fx.server.constant;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-14 8:36
*/
public class UserConstant {
public static int PW_ENCORDER_SALT = 12;
}

View File

@@ -0,0 +1,89 @@
package com.epri.fx.server.context;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:55 上午
*/
public class BaseContextHandler {
public static ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<Map<String, Object>>();
public static void set(String key, Object value) {
Map<String, Object> map = threadLocal.get();
if (map == null) {
map = new HashMap<String, Object>();
threadLocal.set(map);
}
map.put(key, value);
}
public static Object get(String key) {
Map<String, Object> map = threadLocal.get();
if (map == null) {
map = new HashMap<String, Object>();
threadLocal.set(map);
}
return map.get(key);
}
public static String getUserID() {
Object value = get(CommonConstants.CONTEXT_KEY_USER_ID);
return returnObjectValue(value);
}
public static String getUsername() {
Object value = get(CommonConstants.CONTEXT_KEY_USERNAME);
return returnObjectValue(value);
}
public static String getName() {
Object value = get(CommonConstants.CONTEXT_KEY_USER_NAME);
return StringHelper.getObjectValue(value);
}
public static String getToken() {
Object value = get(CommonConstants.CONTEXT_KEY_USER_TOKEN);
return StringHelper.getObjectValue(value);
}
public static void setToken(String token) {
set(CommonConstants.CONTEXT_KEY_USER_TOKEN, token);
}
public static void setName(String name) {
set(CommonConstants.CONTEXT_KEY_USER_NAME, name);
}
public static void setUserID(String userID) {
set(CommonConstants.CONTEXT_KEY_USER_ID, userID);
}
public static void setUsername(String username) {
set(CommonConstants.CONTEXT_KEY_USERNAME, username);
}
private static String returnObjectValue(Object value) {
return value == null ? null : value.toString();
}
public static void remove() {
threadLocal.remove();
}
}

View File

@@ -0,0 +1,58 @@
package com.epri.fx.server.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class Element implements Serializable {
private Integer id;
private String code;
private String type;
private String name;
private String uri;
private String menuId;
private String parentId;
private String path;
private String method;
private String description;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private static final long serialVersionUID = 1L;
public Element() {
}
}

View File

@@ -0,0 +1,248 @@
package com.epri.fx.server.entity;
import java.io.Serializable;
import java.util.Date;
public class Group implements Serializable {
private Integer id;
private String code;
private String name;
private Integer parentId;
private String path;
private String type;
private Integer groupType;
private String description;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private Date updTime;
private String updUser;
private String updName;
private String updHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path == null ? null : path.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public Integer getGroupType() {
return groupType;
}
public void setGroupType(Integer groupType) {
this.groupType = groupType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Date getCrtTime() {
return crtTime;
}
public void setCrtTime(Date crtTime) {
this.crtTime = crtTime;
}
public String getCrtUser() {
return crtUser;
}
public void setCrtUser(String crtUser) {
this.crtUser = crtUser == null ? null : crtUser.trim();
}
public String getCrtName() {
return crtName;
}
public void setCrtName(String crtName) {
this.crtName = crtName == null ? null : crtName.trim();
}
public String getCrtHost() {
return crtHost;
}
public void setCrtHost(String crtHost) {
this.crtHost = crtHost == null ? null : crtHost.trim();
}
public Date getUpdTime() {
return updTime;
}
public void setUpdTime(Date updTime) {
this.updTime = updTime;
}
public String getUpdUser() {
return updUser;
}
public void setUpdUser(String updUser) {
this.updUser = updUser == null ? null : updUser.trim();
}
public String getUpdName() {
return updName;
}
public void setUpdName(String updName) {
this.updName = updName == null ? null : updName.trim();
}
public String getUpdHost() {
return updHost;
}
public void setUpdHost(String updHost) {
this.updHost = updHost == null ? null : updHost.trim();
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1 == null ? null : attr1.trim();
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2 == null ? null : attr2.trim();
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3 == null ? null : attr3.trim();
}
public String getAttr4() {
return attr4;
}
public void setAttr4(String attr4) {
this.attr4 = attr4 == null ? null : attr4.trim();
}
public String getAttr5() {
return attr5;
}
public void setAttr5(String attr5) {
this.attr5 = attr5 == null ? null : attr5.trim();
}
public String getAttr6() {
return attr6;
}
public void setAttr6(String attr6) {
this.attr6 = attr6 == null ? null : attr6.trim();
}
public String getAttr7() {
return attr7;
}
public void setAttr7(String attr7) {
this.attr7 = attr7 == null ? null : attr7.trim();
}
public String getAttr8() {
return attr8;
}
public void setAttr8(String attr8) {
this.attr8 = attr8 == null ? null : attr8.trim();
}
}

View File

@@ -0,0 +1,208 @@
package com.epri.fx.server.entity;
import java.io.Serializable;
import java.util.Date;
public class GroupType implements Serializable {
private Integer id;
private String code;
private String name;
private String description;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private Date updTime;
private String updUser;
private String updName;
private String updHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Date getCrtTime() {
return crtTime;
}
public void setCrtTime(Date crtTime) {
this.crtTime = crtTime;
}
public String getCrtUser() {
return crtUser;
}
public void setCrtUser(String crtUser) {
this.crtUser = crtUser == null ? null : crtUser.trim();
}
public String getCrtName() {
return crtName;
}
public void setCrtName(String crtName) {
this.crtName = crtName == null ? null : crtName.trim();
}
public String getCrtHost() {
return crtHost;
}
public void setCrtHost(String crtHost) {
this.crtHost = crtHost == null ? null : crtHost.trim();
}
public Date getUpdTime() {
return updTime;
}
public void setUpdTime(Date updTime) {
this.updTime = updTime;
}
public String getUpdUser() {
return updUser;
}
public void setUpdUser(String updUser) {
this.updUser = updUser == null ? null : updUser.trim();
}
public String getUpdName() {
return updName;
}
public void setUpdName(String updName) {
this.updName = updName == null ? null : updName.trim();
}
public String getUpdHost() {
return updHost;
}
public void setUpdHost(String updHost) {
this.updHost = updHost == null ? null : updHost.trim();
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1 == null ? null : attr1.trim();
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2 == null ? null : attr2.trim();
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3 == null ? null : attr3.trim();
}
public String getAttr4() {
return attr4;
}
public void setAttr4(String attr4) {
this.attr4 = attr4 == null ? null : attr4.trim();
}
public String getAttr5() {
return attr5;
}
public void setAttr5(String attr5) {
this.attr5 = attr5 == null ? null : attr5.trim();
}
public String getAttr6() {
return attr6;
}
public void setAttr6(String attr6) {
this.attr6 = attr6 == null ? null : attr6.trim();
}
public String getAttr7() {
return attr7;
}
public void setAttr7(String attr7) {
this.attr7 = attr7 == null ? null : attr7.trim();
}
public String getAttr8() {
return attr8;
}
public void setAttr8(String attr8) {
this.attr8 = attr8 == null ? null : attr8.trim();
}
}

View File

@@ -0,0 +1,71 @@
package com.epri.fx.server.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class Menu implements Serializable {
private Integer id;
private String code;
private String title;
private Integer parentId;
private String href;
private String icon;
private String type;
private Integer orderNum;
private String description;
private String path;
private String enabled;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private Date updTime;
private String updUser;
private String updName;
private String updHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private List<Element> elementList;
private static final long serialVersionUID = 1L;
public Menu() {
}
}

View File

@@ -0,0 +1,216 @@
package com.epri.fx.server.entity;
import java.io.Serializable;
import java.util.Date;
public class ResourceAuthority implements Serializable {
private Integer id;
private String authorityId;
private String authorityType;
private String resourceId;
private String resourceType;
private String parentId;
private String path;
private String description;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private static final long serialVersionUID = 1L;
public ResourceAuthority() {
}
public ResourceAuthority(String authorityType, String resourceType) {
this.authorityType = authorityType;
this.resourceType = resourceType;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAuthorityId() {
return authorityId;
}
public void setAuthorityId(String authorityId) {
this.authorityId = authorityId == null ? null : authorityId.trim();
}
public String getAuthorityType() {
return authorityType;
}
public void setAuthorityType(String authorityType) {
this.authorityType = authorityType == null ? null : authorityType.trim();
}
public String getResourceId() {
return resourceId;
}
public void setResourceId(String resourceId) {
this.resourceId = resourceId == null ? null : resourceId.trim();
}
public String getResourceType() {
return resourceType;
}
public void setResourceType(String resourceType) {
this.resourceType = resourceType == null ? null : resourceType.trim();
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId == null ? null : parentId.trim();
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path == null ? null : path.trim();
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Date getCrtTime() {
return crtTime;
}
public void setCrtTime(Date crtTime) {
this.crtTime = crtTime;
}
public String getCrtUser() {
return crtUser;
}
public void setCrtUser(String crtUser) {
this.crtUser = crtUser == null ? null : crtUser.trim();
}
public String getCrtName() {
return crtName;
}
public void setCrtName(String crtName) {
this.crtName = crtName == null ? null : crtName.trim();
}
public String getCrtHost() {
return crtHost;
}
public void setCrtHost(String crtHost) {
this.crtHost = crtHost == null ? null : crtHost.trim();
}
public String getAttr1() {
return attr1;
}
public void setAttr1(String attr1) {
this.attr1 = attr1 == null ? null : attr1.trim();
}
public String getAttr2() {
return attr2;
}
public void setAttr2(String attr2) {
this.attr2 = attr2 == null ? null : attr2.trim();
}
public String getAttr3() {
return attr3;
}
public void setAttr3(String attr3) {
this.attr3 = attr3 == null ? null : attr3.trim();
}
public String getAttr4() {
return attr4;
}
public void setAttr4(String attr4) {
this.attr4 = attr4 == null ? null : attr4.trim();
}
public String getAttr5() {
return attr5;
}
public void setAttr5(String attr5) {
this.attr5 = attr5 == null ? null : attr5.trim();
}
public String getAttr6() {
return attr6;
}
public void setAttr6(String attr6) {
this.attr6 = attr6 == null ? null : attr6.trim();
}
public String getAttr7() {
return attr7;
}
public void setAttr7(String attr7) {
this.attr7 = attr7 == null ? null : attr7.trim();
}
public String getAttr8() {
return attr8;
}
public void setAttr8(String attr8) {
this.attr8 = attr8 == null ? null : attr8.trim();
}
}

View File

@@ -0,0 +1,15 @@
package com.epri.fx.server.entity;
import lombok.Data;
import java.io.Serializable;
@Data
public class RsaKey implements Serializable {
private String key;
private String value;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,74 @@
package com.epri.fx.server.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class User implements Serializable {
private Integer id;
private String username;
private String password;
private String name;
private String birthday;
private String address;
private String mobilePhone;
private String telPhone;
private String email;
private String sex;
private String type;
private String status;
private String description;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private Date updTime;
private String updUser;
private String updName;
private String updHost;
private String attr1;
private String attr2;
private String attr3;
private String attr4;
private String attr5;
private String attr6;
private String attr7;
private String attr8;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
return name;
}
}

View File

@@ -0,0 +1,68 @@
package com.epri.fx.server.entity;
import java.io.Serializable;
import java.util.Date;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-21 8:12
*/
public class UserInfo implements Serializable{
public String id;
public String username;
public String password;
public String name;
private String description;
public Date getUpdTime() {
return updTime;
}
public void setUpdTime(Date updTime) {
this.updTime = updTime;
}
private Date updTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@@ -0,0 +1,32 @@
package com.epri.fx.server.entity.log;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* gate_log
* @author
*/
@Data
public class GateLog implements Serializable {
private Integer id;
private String menu;
private String opt;
private String uri;
private Date crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private String body;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,115 @@
package com.epri.fx.server.entity.log;
import java.io.Serializable;
import java.util.Date;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-07-01 11:18
*/
public class LogInfo implements Serializable{
private String id;
private String menu;
private String opt;
private String uri;
private Long crtTime;
private String crtUser;
private String crtName;
private String crtHost;
private String body;
public LogInfo(String menu, String option, String uri, Date crtTime, String crtUser, String crtName, String crtHost, String body) {
this.menu = menu;
this.opt = option;
this.uri = uri;
this.crtTime = crtTime.getTime();
this.crtUser = crtUser;
this.crtName = crtName;
this.crtHost = crtHost;
this.body = body;
}
public LogInfo() {
}
public String getMenu() {
return menu;
}
public void setMenu(String menu) {
this.menu = menu;
}
public String getOpt() {
return opt;
}
public void setOpt(String option) {
this.opt = option;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public Long getCrtTime() {
return crtTime;
}
public void setCrtTime(Date crtTime) {
this.crtTime = crtTime.getTime();
}
public String getCrtUser() {
return crtUser;
}
public void setCrtUser(String crtUser) {
this.crtUser = crtUser;
}
public String getCrtName() {
return crtName;
}
public void setCrtName(String crtName) {
this.crtName = crtName;
}
public String getCrtHost() {
return crtHost;
}
public void setCrtHost(String crtHost) {
this.crtHost = crtHost;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@@ -0,0 +1,46 @@
package com.epri.fx.server.exception;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
public class BaseException extends RuntimeException {
private int status = 200;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public BaseException() {
}
public BaseException(String message,int status) {
super(message);
this.status = status;
}
public BaseException(String message) {
super(message);
}
public BaseException(String message, Throwable cause) {
super(message, cause);
}
public BaseException(Throwable cause) {
super(cause);
}
public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@@ -0,0 +1,21 @@
package com.epri.fx.server.exception.auth;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class ClientForbiddenException extends BaseException {
public ClientForbiddenException(String message) {
super(message, CommonConstants.EX_CLIENT_FORBIDDEN_CODE);
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.exception.auth;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class ClientInvalidException extends BaseException {
public ClientInvalidException(String message) {
super(message, CommonConstants.EX_CLIENT_INVALID_CODE);
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.exception.auth;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class ClientTokenException extends BaseException {
public ClientTokenException(String message) {
super(message, CommonConstants.EX_CLIENT_INVALID_CODE);
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.exception.auth;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class UserInvalidException extends BaseException {
public UserInvalidException(String message) {
super(message, CommonConstants.EX_USER_PASS_INVALID_CODE);
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.exception.auth;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class UserTokenException extends BaseException {
public UserTokenException(String message) {
super(message, CommonConstants.EX_USER_INVALID_CODE);
}
}

View File

@@ -0,0 +1,33 @@
package com.epri.fx.server.filter;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* @author 01
* @program wrapper-demo
* @description 替换HttpServletRequest
* @create 2018-12-24 21:04
* @since 1.0
**/
@Slf4j
public class ReplaceStreamFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
log.info("StreamFilter初始化...");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
ServletRequest requestWrapper = new RequestWrapper((HttpServletRequest) request);
chain.doFilter(requestWrapper, response);
}
@Override
public void destroy() {
log.info("StreamFilter销毁...");
}
}

View File

@@ -0,0 +1,124 @@
package com.epri.fx.server.filter;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.*;
import java.nio.charset.Charset;
/**
* @author 01
* @program wrapper-demo
* @description 包装HttpServletRequest目的是让其输入流可重复读
* @create 2018-12-24 20:48
* @since 1.0
**/
@Slf4j
public class RequestWrapper extends HttpServletRequestWrapper {
/**
* 存储body数据的容器
*/
private final byte[] body;
public RequestWrapper(HttpServletRequest request) throws IOException {
super(request);
// 将body数据存储起来
String bodyStr = getBodyString(request);
body = bodyStr.getBytes(Charset.defaultCharset());
}
/**
* 获取请求Body
*
* @param request request
* @return String
*/
public String getBodyString(final ServletRequest request) {
try {
return inputStream2String(request.getInputStream());
} catch (IOException e) {
log.error("", e);
throw new RuntimeException(e);
}
}
/**
* 获取请求Body
*
* @return String
*/
public String getBodyString() {
final InputStream inputStream = new ByteArrayInputStream(body);
return inputStream2String(inputStream);
}
/**
* 将inputStream里的数据读取出来并转换成字符串
*
* @param inputStream inputStream
* @return String
*/
private String inputStream2String(InputStream inputStream) {
StringBuilder sb = new StringBuilder();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(inputStream, Charset.defaultCharset()));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
log.error("", e);
throw new RuntimeException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
log.error("", e);
}
}
}
return sb.toString();
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(getInputStream()));
}
@Override
public ServletInputStream getInputStream() throws IOException {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(body);
return new ServletInputStream() {
@Override
public int read() throws IOException {
return inputStream.read();
}
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return false;
}
@Override
public void setReadListener(ReadListener readListener) {
}
};
}
}

View File

@@ -0,0 +1,61 @@
package com.epri.fx.server.handler;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.exception.BaseException;
import com.epri.fx.server.exception.auth.ClientTokenException;
import com.epri.fx.server.exception.auth.UserInvalidException;
import com.epri.fx.server.exception.auth.UserTokenException;
import com.epri.fx.server.msg.BaseResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
/**
* Created by ace on 2017/9/8.
*/
@ControllerAdvice("com.epri.fx.server")
@ResponseBody
public class GlobalExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(ClientTokenException.class)
public BaseResponse clientTokenExceptionHandler(HttpServletResponse response, ClientTokenException ex) {
response.setStatus(403);
logger.error(ex.getMessage(),ex);
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
@ExceptionHandler(UserTokenException.class)
public BaseResponse userTokenExceptionHandler(HttpServletResponse response, UserTokenException ex) {
response.setStatus(200);
logger.error(ex.getMessage(),ex);
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
@ExceptionHandler(UserInvalidException.class)
public BaseResponse userInvalidExceptionHandler(HttpServletResponse response, UserInvalidException ex) {
response.setStatus(200);
logger.error(ex.getMessage(),ex);
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
@ExceptionHandler(BaseException.class)
public BaseResponse baseExceptionHandler(HttpServletResponse response, BaseException ex) {
logger.error(ex.getMessage(),ex);
response.setStatus(500);
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
@ExceptionHandler(Exception.class)
public BaseResponse otherExceptionHandler(HttpServletResponse response, Exception ex) {
response.setStatus(500);
logger.error(ex.getMessage(),ex);
return new BaseResponse(CommonConstants.EX_OTHER_CODE, ex.getMessage());
}
}

View File

@@ -0,0 +1,149 @@
package com.epri.fx.server.interceptor;
import com.epri.fx.server.config.UserConfiguration;
import com.epri.fx.server.context.BaseContextHandler;
import com.epri.fx.server.entity.log.LogInfo;
import com.epri.fx.server.filter.RequestWrapper;
import com.epri.fx.server.jwt.IJWTInfo;
import com.epri.fx.server.service.PermissionService;
import com.epri.fx.server.service.log.GateLogService;
import com.epri.fx.server.util.DBLog;
import com.epri.fx.server.util.user.JwtTokenUtil;
import com.epri.fx.server.vo.PermissionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Created by ace on 2017/9/10.
*/
public class LogInterceptor extends HandlerInterceptorAdapter {
private Logger logger = LoggerFactory.getLogger(LogInterceptor.class);
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
private UserConfiguration userConfiguration;
@Autowired
private GateLogService gateLogService;
@Autowired
private PermissionService permissionService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
String token = request.getHeader(userConfiguration.getUserTokenHeader());
IJWTInfo infoFromToken = jwtTokenUtil.getInfoFromToken(token);
HttpServletRequest requestWrapper = null;
//遇到post方法才对request进行包装
String methodType = request.getMethod();
List<PermissionInfo> permissionIfs = permissionService.getAllPermission();
// 判断资源是否启用权限约束
Stream<PermissionInfo> stream = getPermissionIfs(request.getRequestURI(), request.getMethod().toString(), permissionIfs);
List<PermissionInfo> result = stream.collect(Collectors.toList());
PermissionInfo[] permissions = result.toArray(new PermissionInfo[]{});
if (permissions.length > 0) {
checkUserPermission(permissions, request, infoFromToken);
}
return super.preHandle(request, response, handler);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
BaseContextHandler.remove();
super.afterCompletion(request, response, handler, ex);
}
private boolean checkUserPermission(PermissionInfo[] permissions, HttpServletRequest ctx, IJWTInfo user) {
List<PermissionInfo> permissionInfos = permissionService.getPermissionByUsername(user.getUniqueName());
PermissionInfo current = null;
for (PermissionInfo info : permissions) {
boolean anyMatch = permissionInfos.parallelStream().anyMatch(permissionInfo -> permissionInfo.getCode().equals(info.getCode()));
if (anyMatch) {
current = info;
break;
}
}
if (current == null) {
return true;
} else {
if (!RequestMethod.GET.toString().equals(current.getMethod())) {
setCurrentUserInfoAndLog(ctx, user, current);
}
return false;
}
}
private void setCurrentUserInfoAndLog(HttpServletRequest request, IJWTInfo user, PermissionInfo pm) {
String host = request.getRemoteHost();
if (isJson(request)) {
// 获取json字符串
String jsonParam = null;
try {
jsonParam = new RequestWrapper(request).getBodyString();
LogInfo logInfo = new LogInfo(pm.getMenu(), pm.getName(), pm.getUri(), new Date(), user.getId(), user.getName(), host, jsonParam);
DBLog.getInstance().setLogService(gateLogService).offerQueue(logInfo);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 获取目标权限资源
*
* @param requestUri
* @param method
* @param serviceInfo
* @return
*/
private Stream<PermissionInfo> getPermissionIfs(final String requestUri, final String method, List<PermissionInfo> serviceInfo) {
return serviceInfo.parallelStream().filter(permissionInfo -> {
String uri = permissionInfo.getUri();
if (uri.indexOf("{") > 0) {
uri = uri.replaceAll("\\{\\*\\}", "[a-zA-Z\\\\d]+");
}
String regEx = "^" + uri + "$";
return (Pattern.compile(regEx).matcher(requestUri).find())
&& method.equals(permissionInfo.getMethod());
});
}
/**
* 判断本次请求的数据类型是否为json
*
* @param request request
* @return boolean
*/
private boolean isJson(HttpServletRequest request) {
if (request.getContentType() != null) {
return request.getContentType().equals(MediaType.APPLICATION_JSON_VALUE) ||
request.getContentType().equals(MediaType.APPLICATION_JSON_UTF8_VALUE);
}
return false;
}
}

View File

@@ -0,0 +1,51 @@
package com.epri.fx.server.interceptor;
import com.epri.fx.server.config.UserConfiguration;
import com.epri.fx.server.context.BaseContextHandler;
import com.epri.fx.server.jwt.IJWTInfo;
import com.epri.fx.server.service.PermissionService;
import com.epri.fx.server.service.log.GateLogService;
import com.epri.fx.server.util.user.JwtTokenUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by ace on 2017/9/10.
*/
public class UserAuthRestInterceptor extends HandlerInterceptorAdapter {
private Logger logger = LoggerFactory.getLogger(UserAuthRestInterceptor.class);
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
private UserConfiguration userConfiguration;
@Autowired
private GateLogService gateLogService;
@Autowired
private PermissionService permissionService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
String token = request.getHeader(userConfiguration.getUserTokenHeader());
IJWTInfo infoFromToken = jwtTokenUtil.getInfoFromToken(token);
BaseContextHandler.setUsername(infoFromToken.getUniqueName());
BaseContextHandler.setName(infoFromToken.getName());
BaseContextHandler.setUserID(infoFromToken.getId());
return super.preHandle(request, response, handler);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
BaseContextHandler.remove();
super.afterCompletion(request, response, handler, ex);
}
}

View File

@@ -0,0 +1,30 @@
package com.epri.fx.server.jwt;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:55 上午
*/
public interface IJWTInfo {
/**
* 获取用户名
* @return
*/
String getUniqueName();
/**
* 获取用户ID
* @return
*/
String getId();
/**
* 获取名称
* @return
*/
String getName();
}

View File

@@ -0,0 +1,111 @@
package com.epri.fx.server.jwt;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.util.StringHelper;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.joda.time.DateTime;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 11:08 上午
*/
public class JWTHelper {
private static RsaKeyHelper rsaKeyHelper = new RsaKeyHelper();
/**
* 密钥加密token
*
* @param jwtInfo
* @param priKeyPath
* @param expire
* @return
* @throws Exception
*/
public static String generateToken(IJWTInfo jwtInfo, String priKeyPath, int expire) throws Exception {
String compactJws = Jwts.builder()
.setSubject(jwtInfo.getUniqueName())
.claim(CommonConstants.JWT_KEY_USER_ID, jwtInfo.getId())
.claim(CommonConstants.JWT_KEY_NAME, jwtInfo.getName())
.setExpiration(DateTime.now().plusSeconds(expire).toDate())
.signWith(SignatureAlgorithm.RS256, rsaKeyHelper.getPrivateKey(priKeyPath))
.compact();
return compactJws;
}
/**
* 密钥加密token
*
* @param jwtInfo
* @param priKey
* @param expire
* @return
* @throws Exception
*/
public static String generateToken(IJWTInfo jwtInfo, byte priKey[], int expire) throws Exception {
String compactJws = Jwts.builder()
.setSubject(jwtInfo.getUniqueName())
.claim(CommonConstants.JWT_KEY_USER_ID, jwtInfo.getId())
.claim(CommonConstants.JWT_KEY_NAME, jwtInfo.getName())
.setExpiration(DateTime.now().plusSeconds(expire).toDate())
.signWith(SignatureAlgorithm.RS256, rsaKeyHelper.getPrivateKey(priKey))
.compact();
return compactJws;
}
/**
* 公钥解析token
*
* @param token
* @return
* @throws Exception
*/
public static Jws<Claims> parserToken(String token, String pubKeyPath) throws Exception {
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(rsaKeyHelper.getPublicKey(pubKeyPath)).parseClaimsJws(token);
return claimsJws;
}
/**
* 公钥解析token
*
* @param token
* @return
* @throws Exception
*/
public static Jws<Claims> parserToken(String token, byte[] pubKey) throws Exception {
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(rsaKeyHelper.getPublicKey(pubKey)).parseClaimsJws(token);
return claimsJws;
}
/**
* 获取token中的用户信息
*
* @param token
* @param pubKeyPath
* @return
* @throws Exception
*/
public static IJWTInfo getInfoFromToken(String token, String pubKeyPath) throws Exception {
Jws<Claims> claimsJws = parserToken(token, pubKeyPath);
Claims body = claimsJws.getBody();
return new JWTInfo(body.getSubject(), StringHelper.getObjectValue(body.get(CommonConstants.JWT_KEY_USER_ID)), StringHelper.getObjectValue(body.get(CommonConstants.JWT_KEY_NAME)));
}
/**
* 获取token中的用户信息
*
* @param token
* @param pubKey
* @return
* @throws Exception
*/
public static IJWTInfo getInfoFromToken(String token, byte[] pubKey) throws Exception {
Jws<Claims> claimsJws = parserToken(token, pubKey);
Claims body = claimsJws.getBody();
return new JWTInfo(body.getSubject(), StringHelper.getObjectValue(body.get(CommonConstants.JWT_KEY_USER_ID)), StringHelper.getObjectValue(body.get(CommonConstants.JWT_KEY_NAME)));
}
}

View File

@@ -0,0 +1,76 @@
package com.epri.fx.server.jwt;
import java.io.Serializable;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class JWTInfo implements Serializable, IJWTInfo {
private String username;
private String userId;
private String name;
public JWTInfo(String username, String userId, String name) {
this.username = username;
this.userId = userId;
this.name = name;
}
@Override
public String getUniqueName() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String getId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
JWTInfo jwtInfo = (JWTInfo) o;
if (username != null ? !username.equals(jwtInfo.username) : jwtInfo.username != null) {
return false;
}
return userId != null ? userId.equals(jwtInfo.userId) : jwtInfo.userId == null;
}
@Override
public int hashCode() {
int result = username != null ? username.hashCode() : 0;
result = 31 * result + (userId != null ? userId.hashCode() : 0);
return result;
}
}

View File

@@ -0,0 +1,174 @@
package com.epri.fx.server.jwt;
import org.apache.commons.codec.binary.Base64;
import java.io.DataInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class RsaKeyHelper {
/**
* 获取公钥
*
* @param filename
* @return
* @throws Exception
*/
public PublicKey getPublicKey(String filename) throws Exception {
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(filename);
DataInputStream dis = new DataInputStream(resourceAsStream);
byte[] keyBytes = new byte[resourceAsStream.available()];
dis.readFully(keyBytes);
dis.close();
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePublic(spec);
}
/**
* 获取密钥
*
* @param filename
* @return
* @throws Exception
*/
public PrivateKey getPrivateKey(String filename) throws Exception {
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(filename);
DataInputStream dis = new DataInputStream(resourceAsStream);
byte[] keyBytes = new byte[resourceAsStream.available()];
dis.readFully(keyBytes);
dis.close();
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePrivate(spec);
}
/**
* 获取公钥
*
* @param publicKey
* @return
* @throws Exception
*/
public PublicKey getPublicKey(byte[] publicKey) throws Exception {
X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKey);
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePublic(spec);
}
/**
* 获取密钥
*
* @param privateKey
* @return
* @throws Exception
*/
public PrivateKey getPrivateKey(byte[] privateKey) throws Exception {
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(privateKey);
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePrivate(spec);
}
/**
* 生存rsa公钥和密钥
*
* @param publicKeyFilename
* @param privateKeyFilename
* @param password
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public void generateKey(String publicKeyFilename, String privateKeyFilename, String password) throws IOException, NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom(password.getBytes());
keyPairGenerator.initialize(1024, secureRandom);
KeyPair keyPair = keyPairGenerator.genKeyPair();
byte[] publicKeyBytes = keyPair.getPublic().getEncoded();
FileOutputStream fos = new FileOutputStream(publicKeyFilename);
fos.write(publicKeyBytes);
fos.close();
byte[] privateKeyBytes = keyPair.getPrivate().getEncoded();
fos = new FileOutputStream(privateKeyFilename);
fos.write(privateKeyBytes);
fos.close();
}
/**
* 生存rsa公钥
*
* @param password
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static byte[] generatePublicKey(String password) throws IOException, NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom(password.getBytes());
keyPairGenerator.initialize(1024, secureRandom);
KeyPair keyPair = keyPairGenerator.genKeyPair();
return keyPair.getPublic().getEncoded();
}
/**
* 生存rsa公钥
*
* @param password
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static byte[] generatePrivateKey(String password) throws IOException, NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom(password.getBytes());
keyPairGenerator.initialize(1024, secureRandom);
KeyPair keyPair = keyPairGenerator.genKeyPair();
return keyPair.getPrivate().getEncoded();
}
public static Map<String, byte[]> generateKey(String password) throws IOException, NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom(password.getBytes());
keyPairGenerator.initialize(1024, secureRandom);
KeyPair keyPair = keyPairGenerator.genKeyPair();
byte[] publicKeyBytes = keyPair.getPublic().getEncoded();
byte[] privateKeyBytes = keyPair.getPrivate().getEncoded();
Map<String, byte[]> map = new HashMap<String, byte[]>();
map.put("pub", publicKeyBytes);
map.put("pri", privateKeyBytes);
return map;
}
public static String toHexString(byte[] b) {
return Base64.encodeBase64String(b);
}
public static final byte[] toBytes(String s) throws IOException {
return Base64.decodeBase64(s);
}
public static void main(String[] args) throws NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom("123".getBytes());
keyPairGenerator.initialize(1024, secureRandom);
KeyPair keyPair = keyPairGenerator.genKeyPair();
System.out.println(keyPair.getPublic().getEncoded());
}
}

View File

@@ -0,0 +1,34 @@
package com.epri.fx.server.jwt;
import com.epri.fx.server.config.UserAuthConfig;
import com.epri.fx.server.exception.auth.UserTokenException;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.SignatureException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
@Configuration
public class UserAuthUtil {
@Autowired
private UserAuthConfig userAuthConfig;
public IJWTInfo getInfoFromToken(String token) throws Exception {
try {
return JWTHelper.getInfoFromToken(token, userAuthConfig.getPubKeyByte());
}catch (ExpiredJwtException ex){
throw new UserTokenException("User token expired!");
}catch (SignatureException ex){
throw new UserTokenException("User token signature error!");
}catch (IllegalArgumentException ex){
throw new UserTokenException("User token is null or empty!");
}
}
}

View File

@@ -0,0 +1,28 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.Element;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ElementMapper {
int deleteByPrimaryKey(Integer id);
int deleteByMenuId(Integer menuId);
int insert(Element record);
int insertSelective(Element record);
Element selectByPrimaryKey(Integer id);
List<Element> selectElementList(Integer menuId);
int updateByPrimaryKeySelective(Element record);
int updateByPrimaryKey(Element record);
List<Element> selectAllElementPermissions();
List<Element> selectAuthorityElementByUserId(@Param("userId") String userId);
}

View File

@@ -0,0 +1,23 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.User;
import com.epri.fx.server.entity.log.GateLog;
import java.util.List;
public interface GateLogMapper {
int deleteByPrimaryKey(Integer id);
int insert(GateLog record);
int insertSelective(GateLog record);
GateLog selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(GateLog record);
int updateByPrimaryKey(GateLog record);
List<GateLog> selectPage(String keyId);
}

View File

@@ -0,0 +1,35 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.Group;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface GroupMapper {
int deleteByPrimaryKey(Integer id);
int deleteChilder(Integer id);
int insert(Group record);
int insertSelective(Group record);
Group selectByPrimaryKey(Integer id);
List<Group> selectGroupList(Integer groupType);
int updateByPrimaryKeySelective(Group record);
int updateByPrimaryKey(Group record);
int deleteGroupMembersById(@Param("groupId") int groupId);
int deleteGroupLeadersById(@Param("groupId") int groupId);
int insertGroupMembersById(@Param("groupId") int groupId, @Param("userId") int userId);
int insertGroupLeadersById(@Param("groupId") int groupId, @Param("userId") int userId);
List<Group> selectUserGroupList(Integer userId);
}

View File

@@ -0,0 +1,21 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.GroupType;
import java.util.List;
public interface GroupTypeMapper {
int deleteByPrimaryKey(Integer id);
int insert(GroupType record);
int insertSelective(GroupType record);
GroupType selectByPrimaryKey(Integer id);
List<GroupType> selectListAll();
int updateByPrimaryKeySelective(GroupType record);
int updateByPrimaryKey(GroupType record);
}

View File

@@ -0,0 +1,29 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.Menu;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MenuMapper {
int deleteByPrimaryKey(Integer id);
int deleteAllChild(Integer parentId);
int insert(Menu record);
int insertSelective(Menu record);
Menu selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Menu record);
int updateByPrimaryKey(Menu record);
List<Menu> selectMenuAll();
List<Menu> selectMenuByAuthorityId(@Param("authorityId") String authorityId,@Param("authorityType") String authorityType);
List<Menu> selectAuthorityMenuByUserId (@Param("userId") int userId);
}

View File

@@ -0,0 +1,27 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.ResourceAuthority;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ResourceAuthorityMapper {
int deleteByPrimaryKey(Integer id);
int insert(ResourceAuthority record);
int insertSelective(ResourceAuthority record);
ResourceAuthority selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ResourceAuthority record);
int updateByPrimaryKey(ResourceAuthority record);
List<ResourceAuthority> select(ResourceAuthority record);
int deleteByAuthorityIdAndResourceType(@Param("authorityId")String authorityId);
int deleteByresourceIdAndResourceType(@Param("resourceId")String resourceId,@Param("resourceType")String resourceType);
int deleteByAuthorityIdAndResourceId(@Param("authorityId")String authorityId,@Param("resourceId") String resourceId);
}

View File

@@ -0,0 +1,17 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.RsaKey;
public interface RsaKeyMapper {
int deleteByPrimaryKey(String key);
int insert(RsaKey record);
int insertSelective(RsaKey record);
RsaKey selectByPrimaryKey(String key);
int updateByPrimaryKeySelective(RsaKey record);
int updateByPrimaryKey(RsaKey record);
}

View File

@@ -0,0 +1,29 @@
package com.epri.fx.server.mapper;
import com.epri.fx.server.entity.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface UserMapper {
int deleteByPrimaryKey(Integer id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(Integer id);
User selectOne(String username );
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
List<User> selectAll();
List<User> selectPage(String keyId);
public List<User> selectMemberByGroupId(@Param("groupId") int groupId);
public List<User> selectLeaderByGroupId(@Param("groupId") int groupId);
}

View File

@@ -0,0 +1,41 @@
package com.epri.fx.server.msg;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class BaseResponse {
private int status = 200;
private String message;
public BaseResponse(int status, String message) {
this.status = status;
this.message = message;
}
public BaseResponse() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@@ -0,0 +1,60 @@
package com.epri.fx.server.msg;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-09 7:32
*/
public class ListRestResponse<T> {
String msg;
T result;
int count;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public ListRestResponse count(int count) {
this.setCount(count);
return this;
}
public ListRestResponse count(Long count) {
this.setCount(count.intValue());
return this;
}
public ListRestResponse msg(String msg) {
this.setMsg(msg);
return this;
}
public ListRestResponse result(T result) {
this.setResult(result);
return this;
}
}

View File

@@ -0,0 +1,45 @@
package com.epri.fx.server.msg;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:57 上午
*/
public class ObjectRestResponse<T> extends BaseResponse {
T data;
boolean rel;
public boolean isRel() {
return rel;
}
public void setRel(boolean rel) {
this.rel = rel;
}
public ObjectRestResponse rel(boolean rel) {
this.setRel(rel);
return this;
}
public ObjectRestResponse data(T data) {
this.setData(data);
return this;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

View File

@@ -0,0 +1,39 @@
package com.epri.fx.server.msg;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-14 22:40
*/
public class TableResultResponse<T> extends BaseResponse {
private long total;
private List<T> datas;
public TableResultResponse(long total, List<T> rows) {
this.total = total;
this.datas = rows;
}
public TableResultResponse() {
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public List<T> getDatas() {
return datas;
}
public void setDatas(List<T> datas) {
this.datas = datas;
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.msg.auth;
import com.epri.fx.server.constant.RestCodeConstants;
import com.epri.fx.server.msg.BaseResponse;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
public class TokenErrorResponse extends BaseResponse {
public TokenErrorResponse(String message) {
super(RestCodeConstants.TOKEN_ERROR_CODE, message);
}
}

View File

@@ -0,0 +1,20 @@
package com.epri.fx.server.msg.auth;
import com.epri.fx.server.constant.RestCodeConstants;
import com.epri.fx.server.msg.BaseResponse;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
public class TokenForbiddenResponse extends BaseResponse {
public TokenForbiddenResponse(String message) {
super(RestCodeConstants.TOKEN_FORBIDDEN_CODE, message);
}
}

View File

@@ -0,0 +1,47 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.msg.ObjectRestResponse;
import com.epri.fx.server.service.security.auth.AuthService;
import com.epri.fx.server.util.user.JwtAuthenticationRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("jwt")
@Slf4j
public class AuthController {
@Value("${jwt.token-header}")
private String tokenHeader;
@Autowired
private AuthService authService;
@RequestMapping(value = "token", method = RequestMethod.POST)
public ObjectRestResponse<String> createAuthenticationToken(
@RequestBody JwtAuthenticationRequest authenticationRequest) throws Exception {
log.info(authenticationRequest.getUsername()+" require logging...");
final String token = authService.login(authenticationRequest);
return new ObjectRestResponse<>().data(token);
}
@RequestMapping(value = "refresh", method = RequestMethod.GET)
public ObjectRestResponse<String> refreshAndGetAuthenticationToken(
HttpServletRequest request) throws Exception {
String token = request.getHeader(tokenHeader);
String refreshedToken = authService.refresh(token);
return new ObjectRestResponse<>().data(refreshedToken);
}
@RequestMapping(value = "verify", method = RequestMethod.GET)
public ObjectRestResponse<?> verify(String token) throws Exception {
authService.validate(token);
return new ObjectRestResponse<>();
}
}

View File

@@ -0,0 +1,49 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.entity.Element;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.service.ElementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @description:
* @className: ElementController
* @author: liwen
* @date: 2020/7/19 12:44
*/
@RestController
@RequestMapping("element")
public class ElementController {
@Autowired
private ElementService elementService;
@GetMapping(value = "/list/{menuId}")
@ResponseBody
public TableResultResponse<Element> getElement(@PathVariable Integer menuId) {
return elementService.getElement(menuId);
}
@PostMapping(value = "")
@ResponseBody
public Integer addElement(@RequestBody Element element) {
return elementService.addElement(element);
}
@PutMapping(value = "")
@ResponseBody
public Integer updateElement(@RequestBody Element element) {
return elementService.updateElement(element);
}
@DeleteMapping(value = "/{id}")
@ResponseBody
public Integer deleteElement(@PathVariable Integer id) {
return elementService.deleteElement(id);
}
}

View File

@@ -0,0 +1,93 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.service.GroupService;
import com.epri.fx.server.vo.GroupUsers;
import com.epri.fx.server.vo.GroupVO;
import com.epri.fx.server.vo.MenuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-12 8:49
*/
@Controller
@RequestMapping("group")
public class GroupController {
@Autowired
private GroupService groupService;
@GetMapping("/{groupId}/authority/menu")
@ResponseBody
public List<MenuVO> getAuthorityMenuElementAll(@PathVariable Integer groupId) {
return groupService.getAuthorityMenuElementAll(groupId);
}
@GetMapping(value = "/treeList/{groupTypeId}")
@ResponseBody
public List<GroupVO> getGroupList(@PathVariable Integer groupTypeId) {
return groupService.getGroupList(groupTypeId);
}
@PostMapping(value = "")
@ResponseBody
public Integer addGroup(@RequestBody GroupVO groupVO) {
return groupService.addGroup(groupVO);
}
@PutMapping(value = "")
@ResponseBody
public Integer updateGroup(@RequestBody GroupVO groupVO) {
return groupService.updateGroup(groupVO);
}
@DeleteMapping(value = "")
@ResponseBody
public Integer deleteGroup(@RequestBody GroupVO groupVO) {
return groupService.deleteGroup(groupVO);
}
@RequestMapping(value = "/{id}/authority/element", method = RequestMethod.GET)
@ResponseBody
public List<Integer> getElementAuthority(@PathVariable int id) {
return groupService.getAuthorityElement(id);
}
@PutMapping(value = "/{groupId}/authority/menu")
@ResponseBody
public Integer modifyMenuAuthority(@PathVariable int groupId, @RequestBody List<MenuVO> menuVOList) {
return groupService.modifyAuthorityMenu(groupId, menuVOList);
}
@RequestMapping(value = "/{id}/user", method = RequestMethod.PUT)
@ResponseBody
public Integer modifiyUsers(@PathVariable int id, String members, String leaders) {
return groupService.modifyGroupUsers(id, members, leaders);
}
@RequestMapping(value = "/{id}/user", method = RequestMethod.GET)
@ResponseBody
public GroupUsers getUsers(@PathVariable int id) {
return groupService.getGroupUsers(id);
}
}

View File

@@ -0,0 +1,54 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.service.GroupTypeService;
import com.epri.fx.server.vo.GroupTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-12 8:49
*/
@RestController
@RequestMapping("groupType")
public class GroupTypeController {
@Autowired
private GroupTypeService groupTypeService;
@GetMapping(value = "/all")
@ResponseBody
public List<GroupTypeVO> getAllGroupTypes() {
return groupTypeService.getAllGroupTypes();
}
@PostMapping(value = "")
@ResponseBody
public Integer addGroupType(@RequestBody GroupTypeVO groupTypeVO) {
return groupTypeService.addGroupType(groupTypeVO);
}
@PutMapping(value = "")
@ResponseBody
public Integer updateGroupType(@RequestBody GroupTypeVO groupTypeVO) {
return groupTypeService.updateGroupType(groupTypeVO);
}
@DeleteMapping(value = "/{groupTypeId}")
@ResponseBody
public Integer deleteGroupType(@PathVariable int groupTypeId) {
return groupTypeService.deleteGroupType(groupTypeId);
}
}

View File

@@ -0,0 +1,35 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/hello")
public class HelloController {
@Autowired
private MenuService menuService;
@GetMapping
public String getWelcomeMsg() {
return "Hello,Spring Security";
}
@GetMapping("/helloAdmin")
@PreAuthorize("hasAnyRole('admin')")
public String helloAdmin() {
return menuService.getMenuAll().toString();
}
@GetMapping("/helloUser")
@PreAuthorize("hasAnyRole('user','normal')")
public String helloUser() {
return "Hello,user";
}
}

View File

@@ -0,0 +1,53 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.entity.User;
import com.epri.fx.server.entity.UserInfo;
import com.epri.fx.server.entity.log.GateLog;
import com.epri.fx.server.entity.log.LogInfo;
import com.epri.fx.server.msg.ObjectRestResponse;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.service.PermissionService;
import com.epri.fx.server.service.UserService;
import com.epri.fx.server.service.log.GateLogService;
import com.epri.fx.server.vo.FrontUser;
import com.epri.fx.server.vo.MenuVO;
import com.epri.fx.server.vo.PermissionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @Description:
* @param:
* @return:
* @auther: liwen
* @date: 2020/9/11 9:28 上午
*/
@RestController
@RequestMapping("log")
public class LogController {
@Autowired
private GateLogService gateLogService;
@GetMapping(value = "/page")
@ResponseBody
public TableResultResponse<GateLog> getPageList(@RequestParam Map<String, Object> params) {
return gateLogService.getPageList(params);
}
@DeleteMapping("/{id}")
@ResponseBody
public ObjectRestResponse<Integer> add(@PathVariable Integer id) {
return gateLogService.remove(id);
}
}

View File

@@ -0,0 +1,13 @@
package com.epri.fx.server.rest;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @className: LoginController
* @author: liwen
* @date: 2020/8/1 19:59
*/
@RestController
public class LoginController {
}

View File

@@ -0,0 +1,56 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.entity.Menu;
import com.epri.fx.server.service.MenuService;
import com.epri.fx.server.vo.MenuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-12 8:49
*/
@Controller
@RequestMapping("menu")
public class MenuController {
@Autowired
private MenuService service;
@GetMapping("/all")
@ResponseBody
public List<MenuVO> getMenuAll() {
return service.getMenuAll();
}
@PostMapping("")
@ResponseBody
public Integer addMenu(@RequestBody MenuVO menuVO) {
return service.addMenu(menuVO);
}
@PutMapping("")
@ResponseBody
public Integer updateMenu(@RequestBody MenuVO menuVO) {
return service.updateMenu(menuVO);
}
@DeleteMapping("")
@ResponseBody
public Integer deleteMenu(@RequestBody MenuVO menuVO) {
return service.deleteMenu(menuVO);
}
}

View File

@@ -0,0 +1,110 @@
package com.epri.fx.server.rest;
import com.epri.fx.server.entity.User;
import com.epri.fx.server.entity.UserInfo;
import com.epri.fx.server.msg.ObjectRestResponse;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.service.PermissionService;
import com.epri.fx.server.service.UserService;
import com.epri.fx.server.vo.FrontUser;
import com.epri.fx.server.vo.MenuVO;
import com.epri.fx.server.vo.PermissionInfo;
import com.epri.fx.server.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/9/11 9:28 上午
*/
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private PermissionService permissionService;
@GetMapping(value = "/page")
@ResponseBody
public TableResultResponse<User> getPageList(@RequestParam Map<String, Object> params) {
return userService.getPageList(params);
}
@PutMapping("/{id}")
@ResponseBody
public ObjectRestResponse<Integer> update(@PathVariable int id, @RequestBody User entity) {
return userService.update(entity);
}
@PutMapping("/password/{id}")
@ResponseBody
public ObjectRestResponse<Integer> restPasswrod(@PathVariable Integer id) {
return userService.restPassword(id);
}
@PostMapping("")
@ResponseBody
public ObjectRestResponse<Integer> add(@RequestBody User entity) {
return userService.add(entity);
}
@DeleteMapping("/{id}")
@ResponseBody
public ObjectRestResponse<Integer> add(@PathVariable Integer id) {
return userService.remove(id);
}
@RequestMapping(value = "/permissions", method = RequestMethod.GET)
@ResponseBody
public List<PermissionInfo> getAllPermission() {
return permissionService.getAllPermission();
}
@RequestMapping(value = "/user/un/{username}/permissions", method = RequestMethod.GET)
@ResponseBody
public List<PermissionInfo> getPermissionByUsername(@PathVariable("username") String username) {
return permissionService.getPermissionByUsername(username);
}
@RequestMapping(value = "/user/validate", method = RequestMethod.POST)
@ResponseBody
public UserInfo validate(@RequestBody Map<String, String> body) {
return permissionService.validate(body.get("username"), body.get("password"));
}
@GetMapping(value = "/front/info/{token}")
@ResponseBody
public ObjectRestResponse<FrontUser> getUserInfo(@PathVariable String token) throws Exception {
FrontUser userInfo = permissionService.getUserInfo(token);
return new ObjectRestResponse<FrontUser>().data(userInfo).rel(true);
}
@RequestMapping(value = "/front/menus/{token}", method = RequestMethod.GET)
public @ResponseBody
List<MenuVO> getMenusByUsername(@PathVariable String token) throws Exception {
return permissionService.getMenusByUsername(token);
}
}

View File

@@ -0,0 +1,51 @@
package com.epri.fx.server.runner;
import com.epri.fx.server.config.KeyConfiguration;
import com.epri.fx.server.config.UserAuthConfig;
import com.epri.fx.server.entity.RsaKey;
import com.epri.fx.server.jwt.RsaKeyHelper;
import com.epri.fx.server.service.RsaKeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Map;
/**
* @author ace
* @create 2017/12/17.
*/
@Configuration
public class AuthServerRunner implements CommandLineRunner {
@Autowired
private RsaKeyService rsaKeyService;
private static final String REDIS_USER_PRI_KEY = "IPSM:AUTH:JWT:PRI";
private static final String REDIS_USER_PUB_KEY = "IPSM:AUTH:JWT:PUB";
@Autowired
private KeyConfiguration keyConfiguration;
@Autowired
private UserAuthConfig userAuthConfig;
@Override
public void run(String... args) throws Exception {
if (rsaKeyService.hasKey(REDIS_USER_PRI_KEY) && rsaKeyService.hasKey(REDIS_USER_PUB_KEY)) {
keyConfiguration.setUserPriKey(RsaKeyHelper.toBytes(rsaKeyService.get(REDIS_USER_PRI_KEY)));
keyConfiguration.setUserPubKey(RsaKeyHelper.toBytes(rsaKeyService.get(REDIS_USER_PUB_KEY)));
} else {
Map<String, byte[]> keyMap = RsaKeyHelper.generateKey(keyConfiguration.getUserSecret());
keyConfiguration.setUserPriKey(keyMap.get("pri"));
keyConfiguration.setUserPubKey(keyMap.get("pub"));
rsaKeyService.set(REDIS_USER_PRI_KEY, RsaKeyHelper.toHexString(keyMap.get("pri")));
rsaKeyService.set(REDIS_USER_PUB_KEY, RsaKeyHelper.toHexString(keyMap.get("pub")));
}
refreshUserPubKey();
}
@Scheduled(cron = "0 0/1 * * * ?")
public void refreshUserPubKey() {
this.userAuthConfig.setPubKeyByte(keyConfiguration.getUserPubKey());
}
}

View File

@@ -0,0 +1,51 @@
package com.epri.fx.server.service;
import com.epri.fx.server.entity.Element;
import com.epri.fx.server.mapper.ElementMapper;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @className: ElementService
* @author: liwen
* @date: 2020/7/19 12:44
*/
@Service
public class ElementService {
@Autowired
private ElementMapper elementMapper;
public TableResultResponse<Element> getElement(Integer menuId) {
List<Element> elementList = elementMapper.selectElementList(menuId);
return new TableResultResponse<Element>(elementList.size(), elementList);
}
public Integer addElement(Element element) {
EntityUtils.setCreatAndUpdatInfo(element);
return elementMapper.insertSelective(element);
}
public Integer updateElement(Element element) {
EntityUtils.setCreatAndUpdatInfo(element);
return elementMapper.updateByPrimaryKeySelective(element);
}
public Integer deleteElement(Integer id) {
return elementMapper.deleteByPrimaryKey(id);
}
public List<Element> getAllElementPermissions(){
return elementMapper.selectAllElementPermissions();
}
public List<Element> getAuthorityElementByUserId(String userId){
return elementMapper.selectAuthorityElementByUserId(userId);
}
}

View File

@@ -0,0 +1,228 @@
package com.epri.fx.server.service;
import com.epri.fx.server.constant.AdminCommonConstant;
import com.epri.fx.server.entity.Element;
import com.epri.fx.server.entity.Group;
import com.epri.fx.server.entity.Menu;
import com.epri.fx.server.entity.ResourceAuthority;
import com.epri.fx.server.mapper.*;
import com.epri.fx.server.util.EntityUtils;
import com.epri.fx.server.vo.ElementVO;
import com.epri.fx.server.vo.GroupUsers;
import com.epri.fx.server.vo.GroupVO;
import com.epri.fx.server.vo.MenuVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @description:
* @className: GroupTypeService
* @author: liwen
* @date: 2020/6/30 21:58
*/
@Service
public class GroupService {
@Autowired
private GroupMapper groupMapper;
@Autowired
private MenuMapper menuMapper;
@Autowired
private ResourceAuthorityMapper resourceAuthorityMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ElementMapper elementMapper;
public List<GroupVO> getGroupList(Integer groupTypeId) {
List<Group> groupList = groupMapper.selectGroupList(groupTypeId);
List<GroupVO> groupVOList = new ArrayList<>();
for (Group group : groupList) {
GroupVO groupVO = new GroupVO();
BeanUtils.copyProperties(group, groupVO);
groupVOList.add(groupVO);
}
return groupVOList;
}
public Integer addGroup(GroupVO groupVO) {
Group group = new Group();
BeanUtils.copyProperties(groupVO, group);
group.setId(null);
EntityUtils.setCreatAndUpdatInfo(group);
return groupMapper.insertSelective(group);
}
public Integer updateGroup(GroupVO groupVO) {
Group group = new Group();
BeanUtils.copyProperties(groupVO, group);
EntityUtils.setCreatAndUpdatInfo(group);
return groupMapper.updateByPrimaryKeySelective(group);
}
public Integer deleteGroup(GroupVO groupVO) {
int result = -1;
result = groupMapper.deleteByPrimaryKey(groupVO.getId());
result = groupMapper.deleteChilder(groupVO.getId());
return result;
}
public List<MenuVO> getAuthorityMenuElementAll(Integer groupId) {
List<Menu> menus = menuMapper.selectMenuAll();
List<MenuVO> menuVOList = new ArrayList<>();
Map<Integer, Menu> authorityMenuMap = getAuthorityMenu(groupId).stream().collect(Collectors.toMap(Menu::getId, a -> a, (k1, k2) -> k1));
List<Integer> authorityElementList = getAuthorityElement(groupId);
for (Menu menu : menus) {
boolean sel = authorityMenuMap.get(menu.getId()) != null;
List<Element> elements = elementMapper.selectElementList(menu.getId());
menu.setElementList(elements);
MenuVO menuVO = new MenuVO();
BeanUtils.copyProperties(menu, menuVO);
List<ElementVO> elementVOList = new ArrayList<>();
for (Element element : elements) {
ElementVO elementVO = new ElementVO();
BeanUtils.copyProperties(element, elementVO);
elementVO.setSel(authorityElementList.contains(element.getId()));
elementVOList.add(elementVO);
}
menuVO.setSel(sel);
menuVOList.add(menuVO);
menuVO.getElementVOS().addAll(elementVOList);
}
return menuVOList;
}
/**
* 获取群主关联的菜单
*
* @param groupId
* @return
*/
public List<Menu> getAuthorityMenu(int groupId) {
List<Menu> menus = menuMapper.selectMenuByAuthorityId(String.valueOf(groupId), AdminCommonConstant.AUTHORITY_TYPE_GROUP);
return menus;
}
/**
* 获取群组关联的资源
*
* @param groupId
* @return
*/
public List<Integer> getAuthorityElement(int groupId) {
ResourceAuthority authority = new ResourceAuthority(AdminCommonConstant.AUTHORITY_TYPE_GROUP, AdminCommonConstant.RESOURCE_TYPE_BTN);
authority.setAuthorityId(groupId + "");
List<ResourceAuthority> authorities = resourceAuthorityMapper.select(authority);
List<Integer> ids = new ArrayList<Integer>();
for (ResourceAuthority auth : authorities) {
ids.add(Integer.parseInt(auth.getResourceId()));
}
return ids;
}
/**
* 变更群组关联的菜单
*
* @param groupId
* @param menus
*/
public Integer modifyAuthorityMenu(int groupId, List<MenuVO> menus) {
int result = -1;
resourceAuthorityMapper.deleteByAuthorityIdAndResourceType(groupId + "");
ResourceAuthority authority = null;
for (MenuVO menu : menus) {
for (ElementVO element : menu.getElementVOS()) {
authority = new ResourceAuthority(AdminCommonConstant.AUTHORITY_TYPE_GROUP, AdminCommonConstant.RESOURCE_TYPE_BTN);
authority.setAuthorityId(groupId + "");
authority.setResourceId(element.getId() + "");
authority.setParentId("-1");
resourceAuthorityMapper.insertSelective(authority);
}
authority = new ResourceAuthority(AdminCommonConstant.AUTHORITY_TYPE_GROUP, AdminCommonConstant.RESOURCE_TYPE_MENU);
authority.setAuthorityId(groupId + "");
authority.setResourceId(menu.getId() + "");
authority.setParentId("-1");
result = resourceAuthorityMapper.insertSelective(authority);
}
return result;
}
/**
* 获取群组关联用户
*
* @param groupId
* @return
*/
public GroupUsers getGroupUsers(int groupId) {
return new GroupUsers(userMapper.selectMemberByGroupId(groupId), userMapper.selectLeaderByGroupId(groupId), userMapper.selectAll());
}
/**
* 获取用户关联群组
*
* @param userId
* @return
*/
public List<GroupVO> getUserGroups(int userId) {
List<Group> groups = groupMapper.selectUserGroupList(userId);
List<GroupVO> groupVOList = new ArrayList<>();
for (Group group : groups) {
GroupVO groupVO = new GroupVO();
BeanUtils.copyProperties(group, groupVO);
groupVOList.add(groupVO);
}
return groupVOList;
}
/**
* 变更群主所分配用户
*
* @param groupId
* @param members
* @param leaders
*/
public Integer modifyGroupUsers(int groupId, String members, String leaders) {
int result = -1;
result = groupMapper.deleteGroupLeadersById(groupId);
result = groupMapper.deleteGroupMembersById(groupId);
if (!StringUtils.isEmpty(members)) {
members = members.replace("[", "").replace("]", "");
String[] mem = members.split(",");
for (String m : mem) {
result = groupMapper.insertGroupMembersById(groupId, Integer.parseInt(m.trim()));
}
}
if (!StringUtils.isEmpty(leaders)) {
leaders = leaders.replace("[", "").replace("]", "");
String[] mem = leaders.split(",");
for (String m : mem) {
result = groupMapper.insertGroupLeadersById(groupId, Integer.parseInt(m));
}
}
return result;
}
}

View File

@@ -0,0 +1,57 @@
package com.epri.fx.server.service;
import com.epri.fx.server.entity.GroupType;
import com.epri.fx.server.mapper.GroupTypeMapper;
import com.epri.fx.server.util.EntityUtils;
import com.epri.fx.server.vo.GroupTypeVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @description:
* @className: GroupTypeService
* @author: liwen
* @date: 2020/6/30 21:58
*/
@Service
public class GroupTypeService {
@Autowired
private GroupTypeMapper groupTypeMapper;
public List<GroupTypeVO> getAllGroupTypes() {
List<GroupType> groupTypeList = groupTypeMapper.selectListAll();
List<GroupTypeVO> groupTypeVOList = new ArrayList<>();
for (GroupType type : groupTypeList) {
GroupTypeVO groupTypeVO = new GroupTypeVO();
BeanUtils.copyProperties(type, groupTypeVO);
groupTypeVOList.add(groupTypeVO);
}
return groupTypeVOList;
}
public Integer addGroupType(GroupTypeVO groupTypeVO) {
GroupType groupType = new GroupType();
BeanUtils.copyProperties(groupTypeVO, groupType);
EntityUtils.setCreatAndUpdatInfo(groupType);
groupType.setId(null);
return groupTypeMapper.insertSelective(groupType);
}
public Integer updateGroupType(GroupTypeVO groupTypeVO) {
GroupType groupType = new GroupType();
BeanUtils.copyProperties(groupTypeVO, groupType);
EntityUtils.setUpdatedInfo(groupType);
return groupTypeMapper.updateByPrimaryKeySelective(groupType);
}
public Integer deleteGroupType(int groupTypeId) {
return groupTypeMapper.deleteByPrimaryKey(groupTypeId);
}
}

View File

@@ -0,0 +1,104 @@
package com.epri.fx.server.service;
import com.epri.fx.server.constant.AdminCommonConstant;
import com.epri.fx.server.entity.Element;
import com.epri.fx.server.entity.Menu;
import com.epri.fx.server.entity.ResourceAuthority;
import com.epri.fx.server.mapper.ElementMapper;
import com.epri.fx.server.mapper.MenuMapper;
import com.epri.fx.server.mapper.ResourceAuthorityMapper;
import com.epri.fx.server.util.EntityUtils;
import com.epri.fx.server.vo.ElementVO;
import com.epri.fx.server.vo.GroupVO;
import com.epri.fx.server.vo.MenuVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @description:
* @className: MenuServer
* @author: liwen
* @date: 2020/6/30 21:58
*/
@Service
public class MenuService {
@Autowired
private MenuMapper menuMapper;
@Autowired
private ElementMapper elementMapper;
@Autowired
private ResourceAuthorityMapper resourceAuthorityMapper;
public List<MenuVO> getMenuAll() {
List<Menu> menus = menuMapper.selectMenuAll();
List<MenuVO> menuVOList = new ArrayList<>();
for (Menu menu : menus) {
MenuVO menuVO = new MenuVO();
BeanUtils.copyProperties(menu, menuVO);
menuVOList.add(menuVO);
}
return menuVOList;
}
public List<Menu> selectListAll() {
return menuMapper.selectMenuAll();
}
public Integer addMenu(MenuVO menuVO) {
Menu menu = new Menu();
BeanUtils.copyProperties(menuVO, menu);
menu.setId(null);
EntityUtils.setCreatAndUpdatInfo(menu);
return menuMapper.insertSelective(menu);
}
public Integer updateMenu(MenuVO menuVO) {
Menu menu = new Menu();
BeanUtils.copyProperties(menuVO, menu);
EntityUtils.setCreatAndUpdatInfo(menu);
return menuMapper.updateByPrimaryKeySelective(menu);
}
public Integer deleteMenu(MenuVO menuVO) {
int result = menuMapper.deleteByPrimaryKey(menuVO.getId());
result = menuMapper.deleteAllChild(menuVO.getId());
result = resourceAuthorityMapper.deleteByresourceIdAndResourceType(menuVO.getId() + "",AdminCommonConstant.RESOURCE_TYPE_MENU);
result = elementMapper.deleteByMenuId(menuVO.getId() );
List<ElementVO> list = menuVO.getElementVOS();
if (list != null) {
for (ElementVO element : menuVO.getElementVOS()) {
result = resourceAuthorityMapper.deleteByresourceIdAndResourceType(element.getId() + "",AdminCommonConstant.RESOURCE_TYPE_BTN);
}
}
return result;
}
/**
* 获取用户可以访问的菜单
*
* @param id
* @return
*/
public List<Menu> getUserAuthorityMenuByUserId(int id) {
return menuMapper.selectAuthorityMenuByUserId(id);
}
}

View File

@@ -0,0 +1,173 @@
package com.epri.fx.server.service;
import com.epri.fx.server.constant.AdminCommonConstant;
import com.epri.fx.server.constant.CommonConstants;
import com.epri.fx.server.entity.Element;
import com.epri.fx.server.entity.Menu;
import com.epri.fx.server.entity.User;
import com.epri.fx.server.entity.UserInfo;
import com.epri.fx.server.jwt.UserAuthUtil;
import com.epri.fx.server.util.EncryptUtil;
import com.epri.fx.server.vo.FrontUser;
import com.epri.fx.server.vo.GroupVO;
import com.epri.fx.server.vo.MenuVO;
import com.epri.fx.server.vo.PermissionInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description:
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
@Service
public class PermissionService {
@Autowired
private UserService userService;
@Autowired
private MenuService menuService;
@Autowired
private ElementService elementService;
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private GroupService groupService;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
public UserInfo getUserByUsername(String username) {
UserInfo info = new UserInfo();
User user = userService.getUserByUsername(username);
BeanUtils.copyProperties(user, info);
info.setId(user.getId().toString());
return info;
}
public UserInfo validate(String username, String password) {
UserInfo info = new UserInfo();
User user = userService.getUserByUsername(username);
String pwd = "";
try {
pwd = EncryptUtil.getInstance().Base64Decode(password);
} catch (Exception e) {
e.printStackTrace();
}
if (user != null && encoder.matches(pwd, user.getPassword())) {
BeanUtils.copyProperties(user, info);
info.setId(user.getId().toString());
}
return info;
}
public List<PermissionInfo> getAllPermission() {
List<Menu> menus = menuService.selectListAll();
List<PermissionInfo> result = new ArrayList<PermissionInfo>();
PermissionInfo info = null;
menu2permission(menus, result);
List<Element> elements = elementService.getAllElementPermissions();
element2permission(result, elements);
return result;
}
private void menu2permission(List<Menu> menus, List<PermissionInfo> result) {
PermissionInfo info;
for (Menu menu : menus) {
if (StringUtils.isBlank(menu.getHref())) {
menu.setHref("/" + menu.getCode());
}
info = new PermissionInfo();
info.setCode(menu.getCode());
info.setType(AdminCommonConstant.RESOURCE_TYPE_MENU);
info.setName(AdminCommonConstant.RESOURCE_ACTION_VISIT);
String uri = menu.getHref();
if (!uri.startsWith("/")) {
uri = "/" + uri;
}
info.setUri(uri);
info.setMethod(AdminCommonConstant.RESOURCE_REQUEST_METHOD_GET);
result.add(info
);
info.setMenu(menu.getTitle());
}
}
public List<PermissionInfo> getPermissionByUsername(String username) {
User user = userService.getUserByUsername(username);
List<Menu> menus = menuService.getUserAuthorityMenuByUserId(user.getId());
List<PermissionInfo> result = new ArrayList<PermissionInfo>();
PermissionInfo info = null;
menu2permission(menus, result);
List<Element> elements = elementService.getAuthorityElementByUserId(user.getId() + "");
element2permission(result, elements);
return result;
}
private void element2permission(List<PermissionInfo> result, List<Element> elements) {
PermissionInfo info;
for (Element element : elements) {
info = new PermissionInfo();
info.setCode(element.getCode());
info.setType(element.getType());
info.setUri(element.getUri());
info.setMethod(element.getMethod());
info.setName(element.getName());
info.setMenu(element.getMenuId());
result.add(info);
}
}
public FrontUser getUserInfo(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
return null;
}
UserInfo user = this.getUserByUsername(username);
FrontUser frontUser = new FrontUser();
BeanUtils.copyProperties(user, frontUser);
List<PermissionInfo> permissionInfos = this.getPermissionByUsername(username);
Stream<PermissionInfo> menus = permissionInfos.parallelStream().filter((permission) -> {
return permission.getType().equals(CommonConstants.RESOURCE_TYPE_MENU);
});
frontUser.setMenus(menus.collect(Collectors.toList()));
Stream<PermissionInfo> elements = permissionInfos.parallelStream().filter((permission) -> {
return !permission.getType().equals(CommonConstants.RESOURCE_TYPE_MENU);
});
frontUser.setElements(elements.collect(Collectors.toList()));
List<GroupVO> groupVOList= groupService.getUserGroups(Integer.parseInt(user.getId()));
frontUser.setRoles(groupVOList);
return frontUser;
}
public List<MenuVO> getMenusByUsername(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
return null;
}
User user = userService.getUserByUsername(username);
List<Menu> menus = menuService.getUserAuthorityMenuByUserId(user.getId());
List<MenuVO> menuVOS = new ArrayList<>();
for (Menu menu : menus) {
MenuVO menuVO = new MenuVO();
BeanUtils.copyProperties(menu, menuVO);
menuVOS.add(menuVO);
}
return menuVOS;
}
}

View File

@@ -0,0 +1,35 @@
package com.epri.fx.server.service;
import com.epri.fx.server.entity.RsaKey;
import com.epri.fx.server.mapper.RsaKeyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @description:
* @className: RsaKeyService
* @author: liwen
* @date: 2020/8/2 11:12
*/
@Service
public class RsaKeyService {
@Autowired
private RsaKeyMapper rsaKeyMapper;
public boolean hasKey(String key) {
return rsaKeyMapper.selectByPrimaryKey(key) != null;
}
public String get(String key) {
RsaKey rsaKey = rsaKeyMapper.selectByPrimaryKey(key);
return rsaKey == null ? "" : rsaKey.getValue();
}
public int set(String key, String value) {
RsaKey rsaKey = new RsaKey();
rsaKey.setKey(key);
rsaKey.setValue(value);
return rsaKeyMapper.insert(rsaKey);
}
}

View File

@@ -0,0 +1,99 @@
package com.epri.fx.server.service;
import com.alibaba.druid.util.StringUtils;
import com.epri.fx.server.constant.UserConstant;
import com.epri.fx.server.entity.Menu;
import com.epri.fx.server.entity.User;
import com.epri.fx.server.entity.UserInfo;
import com.epri.fx.server.mapper.MenuMapper;
import com.epri.fx.server.mapper.UserMapper;
import com.epri.fx.server.msg.ObjectRestResponse;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.util.EntityUtils;
import com.epri.fx.server.util.Query;
import com.epri.fx.server.util.user.JwtAuthenticationRequest;
import com.epri.fx.server.vo.UserVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* @description:
* @className: MenuServer
* @author: liwen
* @date: 2020/6/30 21:58
*/
@Service
public class UserService {
@Autowired
private UserMapper userMapper;
@Autowired
private PermissionService permissionService;
public TableResultResponse<User> getPageList(Map<String, Object> params) {
Query query = new Query(params);
Page<Object> page = PageHelper.startPage(query.getPage(), query.getLimit());
String keyId = (String) params.get("keyId");
List<User> list = userMapper.selectPage(StringUtils.isEmpty(keyId) ? null : keyId);
int total = (int) Math.ceil(page.getTotal() / (float) query.getLimit());
return new TableResultResponse<User>(total == 0 ? 1 : total, list);
}
public ObjectRestResponse<Integer> update(User user) {
EntityUtils.setCreatAndUpdatInfo(user);
userMapper.updateByPrimaryKeySelective(user);
return new ObjectRestResponse<Integer>().rel(true);
}
public ObjectRestResponse<Integer> restPassword(Integer id) {
User user = new User();
user.setId(id);
EntityUtils.setUpdatedInfo(user);
String password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode("111111");
user.setPassword(password);
userMapper.updateByPrimaryKeySelective(user);
return new ObjectRestResponse<Integer>().rel(true);
}
public ObjectRestResponse<Integer> add(User user) {
String password = new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(user.getPassword());
user.setPassword(password);
EntityUtils.setCreatAndUpdatInfo(user);
userMapper.insertSelective(user);
return new ObjectRestResponse<Integer>().rel(true);
}
public ObjectRestResponse<Integer> remove(Integer id) {
userMapper.deleteByPrimaryKey(id);
return new ObjectRestResponse<Integer>().rel(true);
}
/**
* 根据用户名获取用户信息
* @param username
* @return
*/
public User getUserByUsername(String username){
User user = new User();
user.setUsername(username);
return userMapper.selectOne(username);
}
public UserInfo validate(JwtAuthenticationRequest authenticationRequest){
return permissionService.validate(authenticationRequest.getUsername(),authenticationRequest.getPassword());
}
}

View File

@@ -0,0 +1,55 @@
package com.epri.fx.server.service.log;
import com.alibaba.druid.util.StringUtils;
import com.epri.fx.server.entity.log.GateLog;
import com.epri.fx.server.entity.log.LogInfo;
import com.epri.fx.server.mapper.GateLogMapper;
import com.epri.fx.server.msg.ObjectRestResponse;
import com.epri.fx.server.msg.TableResultResponse;
import com.epri.fx.server.util.Query;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @description:
* @className: GateLogService
* @author: liwen
* @date: 2020/12/3 10:33
*/
@Service
public class GateLogService {
@Autowired
private GateLogMapper gateLogMapper;
public void saveLog(LogInfo info){
GateLog log = new GateLog();
BeanUtils.copyProperties(info,log);
log.setCrtTime(new Date(info.getCrtTime()));
gateLogMapper.insertSelective(log);
}
public TableResultResponse<GateLog> getPageList(Map<String, Object> params) {
Query query = new Query(params);
Page<Object> page = PageHelper.startPage(query.getPage(), query.getLimit());
String keyId = (String) params.get("keyId");
List<GateLog> list = gateLogMapper.selectPage(StringUtils.isEmpty(keyId) ? null : keyId);
int total = (int) Math.ceil(page.getTotal() / (float) query.getLimit());
return new TableResultResponse<GateLog>(total == 0 ? 1 : total, list);
}
public ObjectRestResponse<Integer> remove(Integer id) {
gateLogMapper.deleteByPrimaryKey(id);
return new ObjectRestResponse<Integer>().rel(true);
}
}

View File

@@ -0,0 +1,10 @@
package com.epri.fx.server.service.security.auth;
import com.epri.fx.server.util.user.JwtAuthenticationRequest;
public interface AuthService {
String login(JwtAuthenticationRequest authenticationRequest) throws Exception;
String refresh(String oldToken) throws Exception;
void validate(String token) throws Exception;
}

View File

@@ -0,0 +1,46 @@
package com.epri.fx.server.service.security.auth.impl;
import com.epri.fx.server.entity.UserInfo;
import com.epri.fx.server.exception.auth.UserInvalidException;
import com.epri.fx.server.jwt.JWTInfo;
import com.epri.fx.server.service.security.auth.AuthService;
import com.epri.fx.server.service.UserService;
import com.epri.fx.server.util.user.JwtAuthenticationRequest;
import com.epri.fx.server.util.user.JwtTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@Service
public class AuthServiceImpl implements AuthService {
private JwtTokenUtil jwtTokenUtil;
private UserService userService;
@Autowired
public AuthServiceImpl(
JwtTokenUtil jwtTokenUtil,
UserService userService) {
this.jwtTokenUtil = jwtTokenUtil;
this.userService = userService;
}
@Override
public String login(JwtAuthenticationRequest authenticationRequest) throws Exception {
UserInfo info = userService.validate(authenticationRequest);
if (!StringUtils.isEmpty(info.getId())) {
return jwtTokenUtil.generateToken(new JWTInfo(info.getUsername(), info.getId() + "", info.getName()));
}
throw new UserInvalidException("用户不存在或账户密码错误!");
}
@Override
public void validate(String token) throws Exception {
jwtTokenUtil.getInfoFromToken(token);
}
@Override
public String refresh(String oldToken) throws Exception {
return jwtTokenUtil.generateToken(jwtTokenUtil.getInfoFromToken(oldToken));
}
}

View File

@@ -0,0 +1,24 @@
package com.epri.fx.server.util;
import javax.servlet.http.HttpServletRequest;
public class ClientUtil {
/**
* 获取客户端真实ip
* @param request
* @return
*/
public static String getClientIp(HttpServletRequest request){
String ip = request.getHeader("x-forwarded-for");
if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip==null||ip.length()==0||"unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
}

View File

@@ -0,0 +1,86 @@
package com.epri.fx.server.util;
import com.epri.fx.server.entity.log.LogInfo;
import com.epri.fx.server.service.log.GateLogService;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-07-01 15:28
*/
@Slf4j
public class DBLog extends Thread {
private static DBLog dblog = null;
private static BlockingQueue<LogInfo> logInfoQueue = new LinkedBlockingQueue<LogInfo>(1024);
public GateLogService get() {
return logService;
}
public DBLog setLogService(GateLogService logService) {
if (this.logService == null) {
this.logService = logService;
}
return this;
}
private GateLogService logService;
public static synchronized DBLog getInstance() {
if (dblog == null) {
dblog = new DBLog();
}
return dblog;
}
private DBLog() {
super("CLogOracleWriterThread");
}
public void offerQueue(LogInfo logInfo) {
try {
logInfoQueue.offer(logInfo);
} catch (Exception e) {
log.error("日志写入失败", e);
}
}
@Override
public void run() {
List<LogInfo> bufferedLogList = new ArrayList<LogInfo>(); // 缓冲队列
while (true) {
try {
bufferedLogList.add(logInfoQueue.take());
logInfoQueue.drainTo(bufferedLogList);
if (bufferedLogList != null && bufferedLogList.size() > 0) {
// 写入日志
for (LogInfo log : bufferedLogList) {
logService.saveLog(log);
}
}
} catch (Exception e) {
e.printStackTrace();
// 防止缓冲队列填充数据出现异常时不断刷屏
try {
Thread.sleep(1000);
} catch (Exception eee) {
}
} finally {
if (bufferedLogList != null && bufferedLogList.size() > 0) {
try {
bufferedLogList.clear();
} catch (Exception e) {
}
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
package com.epri.fx.server.util;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtils {
/** 时间格式(yyyy-MM-dd) */
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static String format(Date date) {
return format(date, DATE_PATTERN);
}
public static String format(Date date, String pattern) {
if(date != null){
SimpleDateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
}
return null;
}
}

View File

@@ -0,0 +1,319 @@
package com.epri.fx.server.util;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.security.SecureRandom;
public class EncryptUtil {
public static final String MD5 = "MD5";
public static final String SHA1 = "SHA1";
public static final String HmacMD5 = "HmacMD5";
public static final String HmacSHA1 = "HmacSHA1";
public static final String DES = "DES";
public static final String AES = "AES";
/**
* 编码格式默认使用uft-8
*/
public String charset = "utf-8";
/**
* DES
*/
public int keysizeDES = 0;
/**
* AES
*/
public int keysizeAES = 128;
public static EncryptUtil me;
private EncryptUtil() {
//单例
}
//双重锁
public static EncryptUtil getInstance() {
if (me == null) {
synchronized (EncryptUtil.class) {
if (me == null) {
me = new EncryptUtil();
}
}
}
return me;
}
/**
* 使用MessageDigest进行单向加密无密码
*
* @param res 被加密的文本
* @param algorithm 加密算法名称
* @return
*/
private String messageDigest(String res, String algorithm) {
try {
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] resBytes = charset == null ? res.getBytes() : res.getBytes(charset);
return base64(md.digest(resBytes));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 使用KeyGenerator进行单向/双向加密(可设密码)
*
* @param res 被加密的原文
* @param algorithm 加密使用的算法名称
* @param key 加密使用的秘钥
* @return
*/
private String keyGeneratorMac(String res, String algorithm, String key) {
try {
SecretKey sk = null;
if (key == null) {
KeyGenerator kg = KeyGenerator.getInstance(algorithm);
sk = kg.generateKey();
} else {
byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset);
sk = new SecretKeySpec(keyBytes, algorithm);
}
Mac mac = Mac.getInstance(algorithm);
mac.init(sk);
byte[] result = mac.doFinal(res.getBytes());
return base64(result);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 使用KeyGenerator双向加密DES/AES注意这里转化为字符串的时候是将2进制转为16进制格式的字符串不是直接转因为会出错
*
* @param res 加密的原文
* @param algorithm 加密使用的算法名称
* @param key 加密的秘钥
* @param keysize
* @param isEncode
* @return
*/
private String keyGeneratorES(String res, String algorithm, String key, int keysize, boolean isEncode) {
try {
KeyGenerator kg = KeyGenerator.getInstance(algorithm);
if (keysize == 0) {
byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset);
kg.init(new SecureRandom(keyBytes));
} else if (key == null) {
kg.init(keysize);
} else {
byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset);
kg.init(keysize, new SecureRandom(keyBytes));
}
SecretKey sk = kg.generateKey();
SecretKeySpec sks = new SecretKeySpec(sk.getEncoded(), algorithm);
Cipher cipher = Cipher.getInstance(algorithm);
if (isEncode) {
cipher.init(Cipher.ENCRYPT_MODE, sks);
byte[] resBytes = charset == null ? res.getBytes() : res.getBytes(charset);
return parseByte2HexStr(cipher.doFinal(resBytes));
} else {
cipher.init(Cipher.DECRYPT_MODE, sks);
return new String(cipher.doFinal(parseHexStr2Byte(res)));
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private String base64(byte[] res) {
return Base64.encode(res);
}
/**
* 将二进制转换成16进制
*/
public static String parseByte2HexStr(byte buf[]) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
/**
* 将16进制转换为二进制
*/
public static byte[] parseHexStr2Byte(String hexStr) {
if (hexStr.length() < 1) {
return null;
}
byte[] result = new byte[hexStr.length() / 2];
for (int i = 0; i < hexStr.length() / 2; i++) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result[i] = (byte) (high * 16 + low);
}
return result;
}
/**
* md5加密算法进行加密不可逆
*
* @param res 需要加密的原文
* @return
*/
public String MD5(String res) {
return messageDigest(res, MD5);
}
/**
* md5加密算法进行加密不可逆
*
* @param res 需要加密的原文
* @param key 秘钥
* @return
*/
public String MD5(String res, String key) {
return keyGeneratorMac(res, HmacMD5, key);
}
/**
* 使用SHA1加密算法进行加密不可逆
*
* @param res 需要加密的原文
* @return
*/
public String SHA1(String res) {
return messageDigest(res, SHA1);
}
/**
* 使用SHA1加密算法进行加密不可逆
*
* @param res 需要加密的原文
* @param key 秘钥
* @return
*/
public String SHA1(String res, String key) {
return keyGeneratorMac(res, HmacSHA1, key);
}
/**
* 使用DES加密算法进行加密可逆
*
* @param res 需要加密的原文
* @param key 秘钥
* @return
*/
public String DESencode(String res, String key) {
return keyGeneratorES(res, DES, key, keysizeDES, true);
}
/**
* 对使用DES加密算法的密文进行解密可逆
*
* @param res 需要解密的密文
* @param key 秘钥
* @return
*/
public String DESdecode(String res, String key) {
return keyGeneratorES(res, DES, key, keysizeDES, false);
}
/**
* 使用AES加密算法经行加密可逆
*
* @param res 需要加密的密文
* @param key 秘钥
* @return
*/
public String AESencode(String res, String key) {
return keyGeneratorES(res, AES, key, keysizeAES, true);
}
/**
* 对使用AES加密算法的密文进行解密
*
* @param res 需要解密的密文
* @param key 秘钥
* @return
*/
public String AESdecode(String res, String key) {
return keyGeneratorES(res, AES, key, keysizeAES, false);
}
/**
* 使用异或进行加密
*
* @param res 需要加密的密文
* @param key 秘钥
* @return
*/
public String XORencode(String res, String key) {
byte[] bs = res.getBytes();
for (int i = 0; i < bs.length; i++) {
bs[i] = (byte) ((bs[i]) ^ key.hashCode());
}
return parseByte2HexStr(bs);
}
/**
* 使用异或进行解密
*
* @param res 需要解密的密文
* @param key 秘钥
* @return
*/
public String XORdecode(String res, String key) {
byte[] bs = parseHexStr2Byte(res);
for (int i = 0; i < bs.length; i++) {
bs[i] = (byte) ((bs[i]) ^ key.hashCode());
}
return new String(bs);
}
/**
* 直接使用异或(第一调用加密,第二次调用解密)
*
* @param res 密文
* @param key 秘钥
* @return
*/
public int XOR(int res, String key) {
return res ^ key.hashCode();
}
/**
* 使用Base64进行加密
*
* @param res 密文
* @return
*/
public String Base64Encode(String res) {
return Base64.encode(res.getBytes());
}
/**
* 使用Base64进行解密
*
* @param res
* @return
*/
public String Base64Decode(String res) {
return new String(Base64.decode(res));
}
}

View File

@@ -0,0 +1,143 @@
package com.epri.fx.server.util;
import com.epri.fx.server.context.BaseContextHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.util.Date;
/**
* @Description: 实体类相关工具类
* 解决问题: 1、快速对实体的常驻字段crtUser、crtHost、updUser等值快速注入
* @param:
* @return:
* @auther: liwen
* @date: 2020/7/2 12:38 下午
*/
public class EntityUtils {
/**
* @Description: 快速将bean的crtUser、crtHost、crtTime、updUser、updHost、updTime附上相关值
* @param: [entity]
* @return: void
* @auther: liwen
* @date: 2020/7/2 12:38 下午
*/
public static <T> void setCreatAndUpdatInfo(T entity) {
setCreateInfo(entity);
setUpdatedInfo(entity);
}
/**
* @Description: 快速将bean的crtUser、crtHost、crtTime附上相关值
* @param: [entity]
* @return: void
* @auther: liwen
* @date: 2020/7/2 12:39 下午
*/
public static <T> void setCreateInfo(T entity) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String hostIp = "";
String name = "";
String id = "";
if (request != null) {
hostIp = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
name = StringUtils.trimToEmpty(request.getHeader("userName"));
name = URLDecoder.decode(name);
id = StringUtils.trimToEmpty(request.getHeader("userId"));
}
if (StringUtils.isBlank(name)) {
name = BaseContextHandler.getUsername();
}
if (StringUtils.isBlank(id)) {
id = BaseContextHandler.getUserID();
}
// 默认属性
String[] fields = {"crtName", "crtUser", "crtHost", "crtTime"};
Field field = ReflectionUtils.getAccessibleField(entity, "crtTime");
// 默认值
Object[] value = null;
if (field != null && field.getType().equals(Date.class)) {
value = new Object[]{name, id, hostIp, new Date()};
}
// 填充默认属性值
setDefaultValues(entity, fields, value);
}
/**
* 快速将bean的updUser、updHost、updTime附上相关值
*
* @param entity 实体bean
* @author liwen
*/
public static <T> void setUpdatedInfo(T entity) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String hostIp = "";
String name = "";
String id = "";
if (request != null) {
hostIp = StringUtils.defaultIfBlank(request.getHeader("userHost"), ClientUtil.getClientIp(request));
name = StringUtils.trimToEmpty(request.getHeader("userName"));
name = URLDecoder.decode(name);
id = StringUtils.trimToEmpty(request.getHeader("userId"));
}
if (StringUtils.isBlank(name)) {
name = BaseContextHandler.getUsername();
}
if (StringUtils.isBlank(id)) {
id = BaseContextHandler.getUserID();
}
// 默认属性
String[] fields = {"updName", "updUser", "updHost", "updTime"};
Field field = ReflectionUtils.getAccessibleField(entity, "updTime");
Object[] value = null;
if (field != null && field.getType().equals(Date.class)) {
value = new Object[]{name, id, hostIp, new Date()};
}
// 填充默认属性值
setDefaultValues(entity, fields, value);
}
/**
* 依据对象的属性数组和值数组对对象的属性进行赋值
*
* @param entity 对象
* @param fields 属性数组
* @param value 值数组
* @author liwen
*/
private static <T> void setDefaultValues(T entity, String[] fields, Object[] value) {
for (int i = 0; i < fields.length; i++) {
String field = fields[i];
if (ReflectionUtils.hasField(entity, field)) {
ReflectionUtils.invokeSetter(entity, field, value[i]);
}
}
}
/**
* 根据主键属性,判断主键是否值为空
*
* @param entity
* @param field
* @return 主键为空则返回false主键有值返回true
* @author liwen
* @date 2016年4月28日
*/
public static <T> boolean isPKNotNull(T entity, String field) {
if (!ReflectionUtils.hasField(entity, field)) {
return false;
}
Object value = ReflectionUtils.getFieldValue(entity, field);
return value != null && !"".equals(value);
}
}

View File

@@ -0,0 +1,46 @@
package com.epri.fx.server.util;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 查询参数
*/
public class Query extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = 1L;
//当前页码
private int page = 1;
//每页条数
private int limit = 10;
public Query(Map<String, Object> params){
this.putAll(params);
//分页参数
if(params.get("page")!=null) {
this.page = Integer.parseInt(params.get("page").toString());
}
if(params.get("limit")!=null) {
this.limit = Integer.parseInt(params.get("limit").toString());
}
this.remove("page");
this.remove("limit");
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}

View File

@@ -0,0 +1,341 @@
package com.epri.fx.server.util;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import java.lang.reflect.*;
/**
* 反射工具类.
* 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
* @author calvin
* @version 2013-01-15
*/
@SuppressWarnings("rawtypes")
public class ReflectionUtils {
private static final String SETTER_PREFIX = "set";
private static final String GETTER_PREFIX = "get";
private static final String CGLIB_CLASS_SEPARATOR = "$$";
private static Logger logger = LoggerFactory.getLogger(ReflectionUtils.class);
/**
* 调用Getter方法.
* 支持多级,如:对象名.对象名.方法
*/
public static Object invokeGetter(Object obj, String propertyName) {
Object object = obj;
for (String name : StringUtils.split(propertyName, ".")){
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
}
return object;
}
/**
* 调用Setter方法, 仅匹配方法名。
* 支持多级,如:对象名.对象名.方法
*/
public static void invokeSetter(Object obj, String propertyName, Object value) {
Object object = obj;
String[] names = StringUtils.split(propertyName, ".");
for (int i=0; i<names.length; i++){
if(i<names.length-1){
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
}else{
String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
invokeMethodByName(object, setterMethodName, new Object[] { value });
}
}
}
/**
* 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
*/
public static Object getFieldValue(final Object obj, final String fieldName) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
}
Object result = null;
try {
result = field.get(obj);
} catch (IllegalAccessException e) {
logger.error("不可能抛出的异常{}", e.getMessage());
}
return result;
}
/**
* 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
*/
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
logger.error("Could not find field [" + fieldName + "] on target [" + obj + "]");
return;
//throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
}
try {
field.set(obj, convert(value, field.getType()));
} catch (IllegalAccessException e) {
logger.error("不可能抛出的异常:{}", e.getMessage());
}
}
public static Object convert(Object object, Class<?> type) {
if (object instanceof Number) {
Number number = (Number) object;
if (type.equals(byte.class) || type.equals(Byte.class)) {
return number.byteValue();
}
if (type.equals(short.class) || type.equals(Short.class)) {
return number.shortValue();
}
if (type.equals(int.class) || type.equals(Integer.class)) {
return number.intValue();
}
if (type.equals(long.class) || type.equals(Long.class)) {
return number.longValue();
}
if (type.equals(float.class) || type.equals(Float.class)) {
return number.floatValue();
}
if (type.equals(double.class) || type.equals(Double.class)) {
return number.doubleValue();
}
}
if(type.equals(String.class)){
return object==null?"":object.toString();
}
return object;
}
/**
* 直接调用对象方法, 无视private/protected修饰符.
* 用于一次性调用的情况否则应使用getAccessibleMethod()函数获得Method后反复调用.
* 同时匹配方法名+参数类型,
*/
public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
final Object[] args) {
Method method = getAccessibleMethod(obj, methodName, parameterTypes);
if (method == null) {
throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
}
try {
return method.invoke(obj, args);
} catch (Exception e) {
throw convertReflectionExceptionToUnchecked(e);
}
}
/**
* 直接调用对象方法, 无视private/protected修饰符
* 用于一次性调用的情况否则应使用getAccessibleMethodByName()函数获得Method后反复调用.
* 只匹配函数名,如果有多个同名函数调用第一个。
*/
public static Object invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
Method method = getAccessibleMethodByName(obj, methodName);
if (method == null) {
throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]");
}
try {
return method.invoke(obj, args);
} catch (Exception e) {
throw convertReflectionExceptionToUnchecked(e);
}
}
/**
* 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
*
* 如向上转型到Object仍无法找到, 返回null.
*/
public static Field getAccessibleField(final Object obj, final String fieldName) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(fieldName, "fieldName can't be blank");
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Field field = superClass.getDeclaredField(fieldName);
makeAccessible(field);
return field;
} catch (NoSuchFieldException e) {//NOSONAR
// Field不在当前类定义,继续向上转型
continue;// new add
}
}
return null;
}
/**
* 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
* 如向上转型到Object仍无法找到, 返回null.
* 匹配函数名+参数类型。
*
* 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethod(final Object obj, final String methodName,
final Class<?>... parameterTypes) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
try {
Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
makeAccessible(method);
return method;
} catch (NoSuchMethodException e) {
// Method不在当前类定义,继续向上转型
continue;// new add
}
}
return null;
}
/**
* 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
* 如向上转型到Object仍无法找到, 返回null.
* 只匹配函数名。
*
* 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
Method[] methods = searchType.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName)) {
makeAccessible(method);
return method;
}
}
}
return null;
}
/**
* 改变private/protected的方法为public尽量不调用实际改动的语句避免JDK的SecurityManager抱怨。
*/
public static void makeAccessible(Method method) {
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
&& !method.isAccessible()) {
method.setAccessible(true);
}
}
/**
* 改变private/protected的成员变量为public尽量不调用实际改动的语句避免JDK的SecurityManager抱怨。
*/
public static void makeAccessible(Field field) {
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || Modifier
.isFinal(field.getModifiers())) && !field.isAccessible()) {
field.setAccessible(true);
}
}
/**
* 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处
* 如无法找到, 返回Object.class.
* eg.
* public UserDao extends HibernateDao<User>
*
* @param clazz The class to introspect
* @return the first generic declaration, or Object.class if cannot be determined
*/
@SuppressWarnings("unchecked")
public static <T> Class<T> getClassGenricType(final Class clazz) {
return getClassGenricType(clazz, 0);
}
/**
* 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
* 如无法找到, 返回Object.class.
*
* 如public UserDao extends HibernateDao<User,Long>
*
* @param clazz clazz The class to introspect
* @param index the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be determined
*/
public static Class getClassGenricType(final Class clazz, final int index) {
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+ params.length);
return Object.class;
}
if (!(params[index] instanceof Class)) {
logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
return Object.class;
}
return (Class) params[index];
}
public static Class<?> getUserClass(Object instance) {
Assert.notNull(instance, "Instance must not be null");
Class clazz = instance.getClass();
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
Class<?> superClass = clazz.getSuperclass();
if (superClass != null && !Object.class.equals(superClass)) {
return superClass;
}
}
return clazz;
}
/**
* 将反射时的checked exception转换为unchecked exception.
*/
public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) {
if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
|| e instanceof NoSuchMethodException) {
return new IllegalArgumentException(e);
} else if (e instanceof InvocationTargetException) {
return new RuntimeException(((InvocationTargetException) e).getTargetException());
} else if (e instanceof RuntimeException) {
return (RuntimeException) e;
}
return new RuntimeException("Unexpected Checked Exception.", e);
}
/**
* 判断某个对象是否拥有某个属性
*
* @param obj 对象
* @param fieldName 属性名
* @return 有属性返回true
* 无属性返回false
*/
public static boolean hasField(final Object obj, final String fieldName){
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,16 @@
package com.epri.fx.server.util;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
public class StringHelper {
public static String getObjectValue(Object obj){
return obj==null?"":obj.toString();
}
}

View File

@@ -0,0 +1,75 @@
package com.epri.fx.server.util;
import com.epri.fx.server.vo.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Ace on 2017/6/12.
*/
public class TreeUtil {
/**
* 两层循环实现建树
*
* @param treeNodes 传入的树节点列表
* @return
*/
public static <T extends TreeNode> List<T> bulid(List<T> treeNodes, Object root) {
List<T> trees = new ArrayList<T>();
for (T treeNode : treeNodes) {
if (root.equals(treeNode.getParentId())) {
trees.add(treeNode);
}
for (T it : treeNodes) {
if (it.getParentId() == treeNode.getId()) {
if (treeNode.getChildren() == null) {
treeNode.setChildren(new ArrayList<TreeNode>());
}
treeNode.add(it);
}
}
}
return trees;
}
/**
* 使用递归方法建树
*
* @param treeNodes
* @return
*/
public static <T extends TreeNode> List<T> buildByRecursive(List<T> treeNodes,Object root) {
List<T> trees = new ArrayList<T>();
for (T treeNode : treeNodes) {
if (root.equals(treeNode.getParentId())) {
trees.add(findChildren(treeNode, treeNodes));
}
}
return trees;
}
/**
* 递归查找子节点
*
* @param treeNodes
* @return
*/
public static <T extends TreeNode> T findChildren(T treeNode, List<T> treeNodes) {
for (T it : treeNodes) {
if (treeNode.getId() == it.getParentId()) {
if (treeNode.getChildren() == null) {
treeNode.setChildren(new ArrayList<TreeNode>());
}
treeNode.add(findChildren(it, treeNodes));
}
}
return treeNode;
}
}

View File

@@ -0,0 +1,34 @@
package com.epri.fx.server.util;
import java.util.UUID;
/**
*
* @Description:
*
* @param:
* @return:
* @auther: liwen
* @date: 2020/8/2 10:56 上午
*/
public class UUIDUtils {
public static String[] chars = new String[] { "a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z" };
public static String generateShortUuid() {
StringBuffer shortBuffer = new StringBuffer();
String uuid = UUID.randomUUID().toString().replace("-", "");
for (int i = 0; i < 8; i++) {
String str = uuid.substring(i * 4, i * 4 + 4);
int x = Integer.parseInt(str, 16);
shortBuffer.append(chars[x % 0x3E]);
}
return shortBuffer.toString();
}
}

Some files were not shown because too many files have changed in this diff Show More