2022-03-31初始化
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
34
.idea/compiler.xml
generated
Normal file
34
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="yyd-base-common" />
|
||||
<module name="yyd-log-api" />
|
||||
<module name="yyd-base-jdbc" />
|
||||
<module name="demo-biz" />
|
||||
<module name="yyd-log-biz" />
|
||||
<module name="yyd-base-redis" />
|
||||
<module name="yyd-center-gateway" />
|
||||
<module name="demo-api" />
|
||||
<module name="yyd-base-handler" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="demo-api" options="-parameters" />
|
||||
<module name="demo-biz" options="-parameters" />
|
||||
<module name="yyd-base-common" options="-parameters" />
|
||||
<module name="yyd-base-handler" options="-parameters" />
|
||||
<module name="yyd-base-jdbc" options="-parameters" />
|
||||
<module name="yyd-base-redis" options="-parameters" />
|
||||
<module name="yyd-center-gateway" options="-parameters" />
|
||||
<module name="yyd-log-api" options="-parameters" />
|
||||
<module name="yyd-log-biz" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/encodings.xml
generated
Normal file
14
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/yyd-base/yyd-base-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-base/yyd-base-handler/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-base/yyd-base-jdbc/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-base/yyd-base-redis/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-center/yyd-center-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-demo/demo-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-demo/demo-biz/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-log/yyd-log-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/yyd-log/yyd-log-biz/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
15
.idea/git_toolbox_prj.xml
generated
Normal file
15
.idea/git_toolbox_prj.xml
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxProjectSettings">
|
||||
<option name="commitMessageIssueKeyValidationOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
<option name="commitMessageValidationEnabledOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
40
.idea/jarRepositories.xml
generated
Normal file
40
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="aliyun-google" />
|
||||
<option name="name" value="aliyun-google" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/google" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="aliyun-public" />
|
||||
<option name="name" value="aliyun-public" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="aliyun-central" />
|
||||
<option name="name" value="aliyun-central" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/central" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="aliyun-spring" />
|
||||
<option name="name" value="aliyun-spring" />
|
||||
<option name="url" value="https://maven.aliyun.com/repository/spring" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/misc.xml
generated
Normal file
12
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
10
.idea/runConfigurations.xml
generated
Normal file
10
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
14
HELP.md
Normal file
14
HELP.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Getting Started
|
||||
|
||||
### Reference Documentation
|
||||
For further reference, please consider the following sections:
|
||||
|
||||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
|
||||
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.4.1/maven-plugin/reference/html/)
|
||||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.4.1/maven-plugin/reference/html/#build-image)
|
||||
|
||||
### Guides
|
||||
The following guides illustrate how to use some features concretely:
|
||||
|
||||
* [Service Registration and Discovery](https://spring.io/guides/gs/service-registration-and-discovery/)
|
||||
|
||||
30
README.md
Normal file
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
## 赢乒网项目结构
|
||||
### 一、目录说明
|
||||
```
|
||||
ttvictory -- 根项目
|
||||
│ ├─yyd-base -- 微服务的基础设施中心
|
||||
│ │ ├─yyd-base-common -- DTO/VO/QUERY/BASEENTITY等的声明
|
||||
│ │ ├─yyd-base-handler -- 全局异常处理模块
|
||||
│ │ ├─yyd-base-jdbc -- 数据库访问层集成了mybaties
|
||||
│ │ ├─yyd-base-reids -- 公共的 redis 操作模块
|
||||
│ ├─yyd-center -- 公共基础依赖模块
|
||||
│ │ ├─yyd-center-gateway -- 提供统一的路由方式和网关基本的功能,例如:安全,监控/指标,和限流。通过kafak记录请求日志。
|
||||
│ ├─yyd-demo --业务模块: 练习演示
|
||||
│ │ ├─yyd-demo-api -- 演示模块的 DTO、VO、FEIGN 等的声明和定义
|
||||
│ │ ├─yyd-demo-biz -- 演示模块的 Feign 远程调用模块,包含controller层、service层、dao层的代码实现
|
||||
│ ├─yyd-log --日志模块: 通过消费kafa消息来实现平台访问日志的存储
|
||||
│ │ ├─yyd-log-api -- DTO、VO、FEIGN 等的声明和定义
|
||||
│ │ ├─yyd-log-biz -- Feign 远程调用模块,包含controller层、service层、dao层的代码实现
|
||||
```
|
||||
### 二、项目用到的组件
|
||||
```
|
||||
1、nacos
|
||||
2、redis
|
||||
3、zookeeper
|
||||
4、kafka
|
||||
5、mybaties
|
||||
6、mysql
|
||||
7、SpringClude
|
||||
8、gateway
|
||||
```
|
||||
88
doc/demo.sql
Normal file
88
doc/demo.sql
Normal file
File diff suppressed because one or more lines are too long
15
open-api/open-api.iml
Normal file
15
open-api/open-api.iml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
15
open-api/pom.xml
Normal file
15
open-api/pom.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>open-api</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
461
pom.xml
Normal file
461
pom.xml
Normal file
@@ -0,0 +1,461 @@
|
||||
<?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>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yyd-demo</module>
|
||||
<module>yyd-base</module>
|
||||
<module>yyd-center</module>
|
||||
<module>yyd-log</module>
|
||||
</modules>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>ttvictory</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<!-- 使用的JAVA版本号 -->
|
||||
<java.version>1.8</java.version>
|
||||
<!-- 项目构建编码 -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- 项目输出编码 -->
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<!-- Spring相关组件 -->
|
||||
<!-- SpringBoot 依赖配置 -->
|
||||
<spring-boot.version>2.2.9.RELEASE</spring-boot.version>
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
|
||||
<!-- SpringCloud Alibaba 微服务 -->
|
||||
<spring-cloud-alibaba.version>2.2.1.RELEASE</spring-cloud-alibaba.version>
|
||||
<!-- springboot管理界面
|
||||
<spring-boot-admin.version>2.2.3</spring-boot-admin.version>-->
|
||||
<!-- nacos客户端 -->
|
||||
<nacos.version>1.3.0</nacos.version>
|
||||
|
||||
<!-- 公共的基础组件 -->
|
||||
<!-- io常用工具类 -->
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons-codec.version>1.14</commons-codec.version>
|
||||
<!--Bean工具 -->
|
||||
<commons.beanutils.version>1.9.3</commons.beanutils.version>
|
||||
<!-- 线程池工具 -->
|
||||
<common-pool.version>2.6.2</common-pool.version>
|
||||
<!-- mybatis,mybatis-plus已经引用
|
||||
<spring-boot.mybatis>2.1.2</spring-boot.mybatis>-->
|
||||
<!-- mybatis-plus -->
|
||||
<mybatis-plus.version>3.4.0</mybatis-plus.version>
|
||||
<!-- JSON 解析器和生成器 -->
|
||||
<fastjson.version>1.2.73</fastjson.version>
|
||||
<!--Token生成与解析 -->
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
|
||||
<!-- 辅助组件 -->
|
||||
<!-- Swagger 依赖配置 -->
|
||||
<swagger.fox.version>2.9.2</swagger.fox.version>
|
||||
<knife4j-Swagger>2.0.5</knife4j-Swagger>
|
||||
<!-- <knife4j-Swagger>3.0.3</knife4j-Swagger>-->
|
||||
<!-- excel工具 -->
|
||||
<poi.version>3.17</poi.version>
|
||||
<!-- 验证码 -->
|
||||
<kaptcha.version>2.3.2</kaptcha.version>
|
||||
<!-- 解析客户端操作系统、浏览器等 -->
|
||||
<bitwalker.version>1.19</bitwalker.version>
|
||||
<!-- velocity模板引擎 -->
|
||||
<velocity.version>1.7</velocity.version>
|
||||
|
||||
|
||||
<!-- Hutool组件 -->
|
||||
<hutool.version>5.4.0</hutool.version>
|
||||
<hibernate-validator.version>6.0.20.Final</hibernate-validator.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
<jedis.version>3.1.0</jedis.version>
|
||||
<java-jwt.version>3.10.1</java-jwt.version>
|
||||
<redis.version>2.2.9.RELEASE</redis.version>
|
||||
<poi-tl.version>1.8.1</poi-tl.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<flowable.version>6.5.0</flowable.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba 微服务 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${spring-cloud-alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- Alibaba Nacos 配置 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
<!--Redis配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>${redis.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${java-jwt.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec.version}</version>
|
||||
</dependency>
|
||||
<!--Bean工具 -->
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>${commons.beanutils.version}</version>
|
||||
</dependency>
|
||||
<!-- 公共资源池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>${common-pool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<!-- JSON 解析器和生成器 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<!--Token生成与解析 -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-dependencies</artifactId>
|
||||
<version>${knife4j-Swagger}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
<version>${knife4j-Swagger}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
<version>${knife4j-Swagger}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j-Swagger}</version>
|
||||
</dependency>-->
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<!-- 验证码 -->
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
<!-- 解析客户端操作系统、浏览器等 -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>${bitwalker.version}</version>
|
||||
</dependency>
|
||||
<!-- 代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool所有模块 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 核心,包括Bean操作、日期、各种Util等 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 基于HttpUrlConnection的Http客户端封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 加密解密模块,提供对称、非对称和摘要算法封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 简单缓存实现 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-cache</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 图片验证码实现 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-captcha</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 针对POI中Excel和Word的封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-poi</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool JSON实现 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-json</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 定时任务模块,提供类Crontab表达式的定时任务 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-cron</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 系统参数调用封装(JVM信息等) -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-system</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 功能更强大的Setting配置文件和Properties封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-setting</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 扩展模块,对第三方封装(模板引擎、邮件、Servlet、二维码、Emoji、FTP、分词等) -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-extra</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool JDK动态代理封装,提供非IOC下的切面支持 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-aop</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 布隆过滤,提供一些Hash算法的布隆过滤 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-bloomFilter</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool JDBC封装后的数据操作,基于ActiveRecord思想 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-db</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 自动识别日志实现的日志门面 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-log</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 基于Java的NIO和AIO的Socket封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-socket</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 基于DFA模型的多关键字查找 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-dfa</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 脚本执行封装,例如Javascript -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-script</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.deepoove/poi-tl -->
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>${poi-tl.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<!--flowable组件-->
|
||||
<dependency>
|
||||
<groupId>org.flowable</groupId>
|
||||
<artifactId>flowable-engine</artifactId>
|
||||
<version>${flowable.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.flowable</groupId>
|
||||
<artifactId>flowable-spring-boot-starter-basic</artifactId>
|
||||
<version>${flowable.version}</version>
|
||||
<exclusions><!-- 需要排除flowable的mybatis依赖,不然会跟mybatis-plus冲突 -->
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun-central</id>
|
||||
<url>https://maven.aliyun.com/repository/central</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aliyun-public</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aliyun-google</id>
|
||||
<url>https://maven.aliyun.com/repository/google</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aliyun-spring</id>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>aliyun-central</id>
|
||||
<url>https://maven.aliyun.com/repository/central</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>aliyun-public</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>aliyun-google</id>
|
||||
<url>https://maven.aliyun.com/repository/google</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>aliyun-spring</id>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
21
yyd-base/pom.xml
Normal file
21
yyd-base/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yyd-base-common</module>
|
||||
<module>yyd-base-redis</module>
|
||||
<module>yyd-base-jdbc</module>
|
||||
<module>yyd-base-handler</module>
|
||||
</modules>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
191
yyd-base/yyd-base-common/pom.xml
Normal file
191
yyd-base/yyd-base-common/pom.xml
Normal file
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.73</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 二维码 -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--极光推送-->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jiguang-common</artifactId>
|
||||
<version>1.1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.6.Final</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 拼音 -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--工具包-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,158 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: BaseEntity.java <br/>
|
||||
* Class: com.yxt.common.core.domain.BaseEntity <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 1:01 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BaseEntity extends EntityWithId {
|
||||
|
||||
public String getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public void setSid(String sid) {
|
||||
this.sid = sid;
|
||||
}
|
||||
|
||||
public Integer getLockVersion() {
|
||||
return lockVersion;
|
||||
}
|
||||
|
||||
public void setLockVersion(Integer lockVersion) {
|
||||
this.lockVersion = lockVersion;
|
||||
}
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(Integer state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Integer getIsEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public void setIsEnable(Integer isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
|
||||
public void setIsDelete(Integer isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String getCreateBySid() {
|
||||
return createBySid;
|
||||
}
|
||||
|
||||
public void setCreateBySid(String createBySid) {
|
||||
this.createBySid = createBySid;
|
||||
}
|
||||
|
||||
public String getUpdateBySid() {
|
||||
return updateBySid;
|
||||
}
|
||||
|
||||
public void setUpdateBySid(String updateBySid) {
|
||||
this.updateBySid = updateBySid;
|
||||
}
|
||||
|
||||
@ApiModelProperty("字符型编号")
|
||||
private String sid = UUID.randomUUID().toString();
|
||||
|
||||
// @Version
|
||||
@ApiModelProperty("记录版本,锁")
|
||||
private Integer lockVersion = 0;
|
||||
|
||||
@ApiModelProperty("记录创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime = new Date();
|
||||
@ApiModelProperty("记录最后修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date modifyTime = new Date();
|
||||
@ApiModelProperty("记录状态值")
|
||||
private Integer state = 1;
|
||||
@ApiModelProperty("记录是否可用,1:可用(默认),0:不可用")
|
||||
private Integer isEnable = 1;
|
||||
|
||||
// @TableLogic
|
||||
@ApiModelProperty("记录是否被删除,0:未删除(默认),1:已经删除")
|
||||
private Integer isDelete = 0;
|
||||
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remarks;
|
||||
@ApiModelProperty("创建者")
|
||||
private String createBySid;
|
||||
@ApiModelProperty("更新者")
|
||||
private String updateBySid;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Entity implements Serializable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yyd.base.common.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class EntityWithId extends Entity {
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ApiModelProperty("ID值的字符串形式")
|
||||
public String getIdStr() {
|
||||
if (null == id) {
|
||||
return "";
|
||||
}
|
||||
return "" + id;
|
||||
}
|
||||
|
||||
@ApiModelProperty("ID,唯一编号")
|
||||
private Integer id;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClassName:" + getClass().getName() + ";id:" + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int id2 = Long.hashCode(getId());
|
||||
return super.hashCode() + id2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof EntityWithId)) {
|
||||
return false;
|
||||
}
|
||||
EntityWithId entity = (EntityWithId) obj;
|
||||
return this.getId().equals(entity.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.dto;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.yyd.base.common.domain.Entity;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Dto.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.dto.Dto <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/17 23:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Dto extends Vo {
|
||||
|
||||
default <E extends Entity> void fillEntity(E e) {
|
||||
BeanUtil.copyProperties(this, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.query;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: PagerQuery.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.query.PagerQuery <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:58 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class PagerQuery<T extends Query> implements Serializable {
|
||||
|
||||
public PagerQuery() {
|
||||
}
|
||||
|
||||
public PagerQuery(long current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public PagerQuery(long current, long size) {
|
||||
this.size = size;
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("总记录数")
|
||||
//private long total = 0L; //总记录数
|
||||
@ApiModelProperty(value = "每页记录数", example = "10")
|
||||
private long size = 10L; //每页记录数
|
||||
@ApiModelProperty(value = "当前页号", example = "1")
|
||||
private long current = 1L; //当前页号
|
||||
@ApiModelProperty("查询条件的项")
|
||||
private T params;
|
||||
|
||||
// @ApiModelProperty("每页记录数,size的别名,默认值为10")
|
||||
// public PagerQuery set_p_size(long _p_size) {
|
||||
// this.size = _p_size;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @ApiModelProperty("当前页号,current的别名,默认值为1")
|
||||
// public PagerQuery set_p_no(long _p_no) {
|
||||
// this.current = _p_no;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// @ApiModelProperty("总记录数,total的别名,默认值为0")
|
||||
// public PagerQuery set_p_total(long _p_total) {
|
||||
// this.total = _p_total;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/* public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public PagerQuery setTotal(long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
*/
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public PagerQuery setSize(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public PagerQuery setCurrent(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public PagerQuery setParams(T params) {
|
||||
this.params = params;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void fromPagerQuery(PagerQuery s_query)
|
||||
{
|
||||
this.setCurrent(s_query.getCurrent()).setSize(s_query.getSize()).setParams(params.fromMap(s_query.getParams().toMap()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.query;
|
||||
|
||||
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Query.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.query.Query <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:24 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Query extends Vo {
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author liuguohui
|
||||
* @Date 2021/10/11
|
||||
*/
|
||||
@ApiModel(description = "手机端返回数据结构(同查询数据字典)")
|
||||
@Data
|
||||
public class AppResultData {
|
||||
|
||||
@ApiModelProperty(value = "数据字典项sid")
|
||||
private String sid;
|
||||
|
||||
@ApiModelProperty(value = "数据字典项key")
|
||||
private String dictKey;
|
||||
|
||||
@ApiModelProperty(value = "数据字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ApiModelProperty(value = "数据字典项名称")
|
||||
private String dictValue;
|
||||
@ApiModelProperty(value = "父级sid:0为第一级")
|
||||
private String parentSid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2021/6/16 10:50
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class HttpStatus {
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR = 500;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: IResultCodeMsg.java <br/>
|
||||
* Class: com.yxt.common.core.result.IResultCodeMsg <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021/9/11 下午11:00 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface IResultCodeMsg {
|
||||
String getCode();
|
||||
String getMsg();
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: yxt-common-core <br/>
|
||||
* File: ResultBean.java <br/>
|
||||
* Class: com.yxt.common.core.result.ResultBean <br/>
|
||||
* Description: 通过接口、Rest、逻辑处理执行后的结果信息. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 0:51 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(description = "返回结果")
|
||||
public class ResultBean<T> implements Serializable {
|
||||
private static final long serialVersionUID = 4529658978692424234L;
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private Class<T> clazz() {
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[0];
|
||||
//// if(targetClass==null)
|
||||
//// targetClass=Object.class;
|
||||
// return targetClass;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private T obj() {
|
||||
// T instance = null;
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[1];
|
||||
// try {
|
||||
// instance = targetClass.newInstance();
|
||||
// } catch (InstantiationException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return instance;
|
||||
// }
|
||||
|
||||
@ApiModelProperty("对象创建的时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
// 是否成功
|
||||
@ApiModelProperty("是否成功: true or false")
|
||||
private boolean success;
|
||||
|
||||
// 消息 返回结果的说明
|
||||
@ApiModelProperty("返回结果的说明")
|
||||
private String msg;
|
||||
|
||||
// 结果状态码
|
||||
@ApiModelProperty("结果状态码")
|
||||
private String code;
|
||||
|
||||
// 数据
|
||||
@ApiModelProperty("业务数据")
|
||||
private T data;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ResultBean<T> setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean() {
|
||||
}
|
||||
|
||||
public ResultBean(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public ResultBean(boolean success, String msg) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResultBean(boolean success, String msg, String code) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ResultBean(T data) {
|
||||
this.success = true;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBean(String code, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBean(String code, String msg, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ResultBean<T> setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public ResultBean<T> setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ResultBean<T> setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
// if (this.data == null && this.map != null && !this.map.isEmpty()) {
|
||||
//// Object t = new Object();
|
||||
//// Object r = (Object)this.map;map
|
||||
//// BeanUtil.fillBeanWithMap(this.map, t, false);
|
||||
// this.data = obj();
|
||||
// BeanUtil.copyProperties(this.map, this.data, true);
|
||||
//// this.data = (T) t;
|
||||
//// return t;
|
||||
// }
|
||||
return data;
|
||||
}
|
||||
|
||||
public ResultBean<T> setData(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> successOne() {
|
||||
this.setSuccess(true);
|
||||
this.setCode("0");
|
||||
this.setMessage("成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> failOne() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMessage("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> success() {
|
||||
this.setSuccess(true);
|
||||
this.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
this.setMsg("操作成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBean<T> fail() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMsg("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> fireSuccess() {
|
||||
ResultBean<T> rb = new ResultBean<T>();
|
||||
rb.setSuccess(true);
|
||||
rb.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
rb.setMsg("操作成功!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> fireFail() {
|
||||
ResultBean<T> rb = new ResultBean<T>();
|
||||
rb.setSuccess(false);
|
||||
rb.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
rb.setMsg("操作失败!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("无类型的业务数据对象")
|
||||
//// @JsonIgnore
|
||||
// private Map<String, Object> map = Collections.emptyMap();
|
||||
//
|
||||
// public ResultBean<T> clear() {
|
||||
// this.map = null;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Object get(String key) {
|
||||
// if (this.map == null)
|
||||
// return null;
|
||||
// return this.map.get(key);
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> remove(String key) {
|
||||
// if (this.map == null)
|
||||
// return this;
|
||||
// this.map.remove(key);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> put(String key, Object value) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.put(key, value);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Map<String, Object> getMap() {
|
||||
// return this.map;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> setMap(Map<String, Object> map) {
|
||||
// this.map = map;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> putAll(Map<String, Object> map) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.putAll(map);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置返回code及msg
|
||||
*
|
||||
* @param codeMsg Code和Msg的枚举
|
||||
* @return
|
||||
*/
|
||||
public ResultBean<T> setCode(IResultCodeMsg codeMsg) {
|
||||
this.code = codeMsg.getCode();
|
||||
this.msg = codeMsg.getMsg();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败信息,并指定结果code
|
||||
* @param codeMsg Code和Msg的枚举
|
||||
* @return
|
||||
*/
|
||||
public ResultBean<T> fail(IResultCodeMsg codeMsg) {
|
||||
this.setSuccess(false);
|
||||
this.code = codeMsg.getCode();
|
||||
this.msg = codeMsg.getMsg();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.result;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: yxt-common-core <br/>
|
||||
* File: ResultBean.java <br/>
|
||||
* Class: com.yxt.common.core.result.ResultBean <br/>
|
||||
* Description: 通过接口、Rest、逻辑处理执行后的结果信息. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/4 0:51 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(description = "返回结果")
|
||||
public class ResultBeanOfEnum<T> implements Serializable {
|
||||
private static final long serialVersionUID = 4529658978692424234L;
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private Class<T> clazz() {
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[0];
|
||||
//// if(targetClass==null)
|
||||
//// targetClass=Object.class;
|
||||
// return targetClass;
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private T obj() {
|
||||
// T instance = null;
|
||||
// Class<T> targetClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
// .getActualTypeArguments()[1];
|
||||
// try {
|
||||
// instance = targetClass.newInstance();
|
||||
// } catch (InstantiationException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return instance;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("对象创建的时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
// 是否成功
|
||||
@ApiModelProperty("是否成功: true or false")
|
||||
private boolean success;
|
||||
|
||||
// 消息 返回结果的说明
|
||||
@ApiModelProperty("返回结果的说明")
|
||||
private String msg;
|
||||
|
||||
// 结果状态码
|
||||
@ApiModelProperty("结果状态码")
|
||||
private String code;
|
||||
|
||||
// 数据
|
||||
@ApiModelProperty("业务数据")
|
||||
private T data;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum() {
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success, String msg) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(boolean success, String msg, String code) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(T data) {
|
||||
this.success = true;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(String code, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum(String code, String msg, T data) {
|
||||
this.success = true;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setCode(String code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setCode(CodeMsg codeMsg) {
|
||||
// this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
// if (this.data == null && this.map != null && !this.map.isEmpty()) {
|
||||
//// Object t = new Object();
|
||||
//// Object r = (Object)this.map;map
|
||||
//// BeanUtil.fillBeanWithMap(this.map, t, false);
|
||||
// this.data = obj();
|
||||
// BeanUtil.copyProperties(this.map, this.data, true);
|
||||
//// this.data = (T) t;
|
||||
//// return t;
|
||||
// }
|
||||
return data;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> setData(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
public ResultBeanOfEnum<T> successOne() {
|
||||
this.setSuccess(true);
|
||||
this.setCode("0");
|
||||
this.setMessage("成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> failOne() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMessage("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> success() {
|
||||
this.setSuccess(true);
|
||||
this.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
this.setMsg("操作成功!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResultBeanOfEnum<T> fail() {
|
||||
this.setSuccess(false);
|
||||
this.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
this.setMsg("操作失败!");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static <T> ResultBeanOfEnum<T> fireSuccess() {
|
||||
ResultBeanOfEnum<T> rb = new ResultBeanOfEnum<T>();
|
||||
rb.setSuccess(true);
|
||||
rb.setCode(String.valueOf(HttpStatus.SUCCESS));
|
||||
rb.setMsg("操作成功!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
public static <T> ResultBeanOfEnum<T> fireFail() {
|
||||
ResultBeanOfEnum<T> rb = new ResultBeanOfEnum<T>();
|
||||
rb.setSuccess(false);
|
||||
rb.setCode(String.valueOf(HttpStatus.ERROR));
|
||||
rb.setMsg("操作失败!");
|
||||
return rb;
|
||||
}
|
||||
|
||||
// @ApiModelProperty("无类型的业务数据对象")
|
||||
//// @JsonIgnore
|
||||
// private Map<String, Object> map = Collections.emptyMap();
|
||||
//
|
||||
// public ResultBean<T> clear() {
|
||||
// this.map = null;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Object get(String key) {
|
||||
// if (this.map == null)
|
||||
// return null;
|
||||
// return this.map.get(key);
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> remove(String key) {
|
||||
// if (this.map == null)
|
||||
// return this;
|
||||
// this.map.remove(key);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> put(String key, Object value) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.put(key, value);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public Map<String, Object> getMap() {
|
||||
// return this.map;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> setMap(Map<String, Object> map) {
|
||||
// this.map = map;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public ResultBean<T> putAll(Map<String, Object> map) {
|
||||
// if (this.map == null)
|
||||
// this.map = new HashMap<>();
|
||||
// this.map.putAll(map);
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public enum CodeMsg{
|
||||
/**
|
||||
* 返回正常
|
||||
*/
|
||||
HTML200("200","返回正常"),
|
||||
|
||||
/**
|
||||
* 页面不存在
|
||||
*/
|
||||
HTML404("404","页面不存在"),
|
||||
|
||||
/**
|
||||
* 服务器错误
|
||||
*/
|
||||
HTML500("500","服务器错误");
|
||||
|
||||
private String code;
|
||||
private String msg;
|
||||
|
||||
private CodeMsg(String code,String msg){
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg(){
|
||||
return msg;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code得到枚举实例
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static CodeMsg byCode(String code){
|
||||
for(CodeMsg cm: CodeMsg.values()){
|
||||
if(cm.getCode().equals(code)){
|
||||
return cm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: PagerUtil.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.base.utils.PagerUtil <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/22 上午9:35 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class PagerUtil {
|
||||
|
||||
public static <T> IPage<T> queryToPage(PagerQuery pq) {
|
||||
IPage<T> page = new Page<>();
|
||||
page.setSize(pq.getSize()).setCurrent(pq.getCurrent());
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <V, T> PagerVo<V> pageToVo(IPage pr, PagerVo<V> pv) {
|
||||
if (pv == null)
|
||||
pv = new PagerVo<V>();
|
||||
pv.setCurrent(pr.getCurrent()).setSize(pr.getSize())
|
||||
.setTotal(pr.getTotal()).setPages(pr.getPages())
|
||||
.setRecords(pr.getRecords());
|
||||
return pv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换pagerVo
|
||||
*
|
||||
* @param soure
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <S extends Vo, T extends Vo> PagerVo<T> switchPagerVo(
|
||||
PagerVo<S> soure) {
|
||||
if (soure == null)
|
||||
return null;
|
||||
|
||||
PagerVo<T> target = new PagerVo<>();
|
||||
target.setCurrent(soure.getCurrent()).setPages(soure.getPages())
|
||||
.setSize(soure.getSize()).setTotal(soure.getTotal());
|
||||
target.setRecords(new ArrayList<T>());
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
/*
|
||||
* public static <S, V> PagerVo<V> pageVoToVo(PagerVo<S> pvs, PagerVo<V>
|
||||
* pvt) { if (pvt == null) pvt = new PagerVo<V>();
|
||||
* pvt.setCurrent(pvs.getCurrent
|
||||
* ()).setSize(pvs.getSize()).setTotal(pvs.getTotal
|
||||
* ()).setPages(pvs.getPages());
|
||||
*
|
||||
* for(int i=0;i<pvs.getRecords().size();i++) { WfTaskAppVo taskAppVo=new
|
||||
* WfTaskAppVo();
|
||||
*
|
||||
* pvt.getRecords().add(taskAppVo.fromMap(pvs.getRecords().get(i).toMap()));
|
||||
* }
|
||||
*
|
||||
*
|
||||
* return pv; }
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel(description = "返回的分页结果")
|
||||
public class PagerVo<T> implements Serializable {
|
||||
|
||||
@ApiModelProperty("总页数")
|
||||
private long pages = 1L; //总页数
|
||||
@ApiModelProperty("总记录数")
|
||||
private long total = 0L; //总记录数
|
||||
@ApiModelProperty("每页记录数")
|
||||
private long size = 10L; //每页记录数
|
||||
@ApiModelProperty("当前页号")
|
||||
private long current = 1L; //当前页号
|
||||
|
||||
@ApiModelProperty("当前页的数据")
|
||||
private List<T> records = Collections.emptyList(); //当前页的数据
|
||||
@ApiModelProperty("统计信息")
|
||||
private String msg = "";
|
||||
@ApiModelProperty("其它信息")
|
||||
private Map<String, Object> map = Collections.emptyMap();
|
||||
|
||||
|
||||
public PagerVo() {
|
||||
this.pages = 1L; //总页数
|
||||
this.total = 0L; //总记录数
|
||||
this.size = 10L; //每页记录数
|
||||
this.current = 1L; //当前页号
|
||||
this.records = Collections.emptyList(); //当前页的数据
|
||||
}
|
||||
|
||||
public PagerVo(long current) {
|
||||
this.pages = 1L; //总页数
|
||||
this.total = 0L; //总记录数
|
||||
this.size = 10L; //每页记录数
|
||||
this.current = current; //当前页号
|
||||
this.records = Collections.emptyList(); //当前页的数据
|
||||
}
|
||||
|
||||
public long getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public PagerVo<T> setPages(long pages) {
|
||||
this.pages = pages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public PagerVo<T> setTotal(long total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public PagerVo<T> setSize(long size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public PagerVo<T> setCurrent(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<T> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public PagerVo<T> setRecords(List<T> records) {
|
||||
this.records = records;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map<String, Object> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Tail.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.Tail <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:22 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Tail extends Serializable {
|
||||
public Object get(String key);
|
||||
public void set(String key,Object value);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: TailBean.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.TailBean <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/21 下午3:22 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class TailBean implements Tail {
|
||||
|
||||
protected Map<String, Object> extMap = new HashMap<String, Object>();
|
||||
|
||||
public Object get(String key) {
|
||||
return extMap.get(key);
|
||||
}
|
||||
|
||||
public void set(String key, Object value) {
|
||||
this.extMap.put(key, value);
|
||||
}
|
||||
|
||||
public Map<String, Object> getTails() {
|
||||
return extMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.common.vo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.yyd.base.common.domain.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: Vo.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.core.vo.Vo <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/18 0:03 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface Vo extends Serializable {
|
||||
|
||||
default Map<String, Object> toMap() {
|
||||
return BeanUtil.beanToMap(this);
|
||||
}
|
||||
|
||||
default <V extends Vo> V fromMap(Map<String, Object> map) {
|
||||
return (V) BeanUtil.fillBeanWithMap(map, this, false);
|
||||
}
|
||||
default <E extends Entity> void fromEntity(E e) {
|
||||
BeanUtil.copyProperties(e, this);
|
||||
|
||||
}
|
||||
}
|
||||
202
yyd-base/yyd-base-handler/pom.xml
Normal file
202
yyd-base/yyd-base-handler/pom.xml
Normal file
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-base-handler</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.73</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 二维码 -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--极光推送-->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jiguang-common</artifactId>
|
||||
<version>1.1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.6.Final</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 拼音 -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--工具包-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,99 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.handler;
|
||||
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* Project: jbsc-commons <br/>
|
||||
* File: GlobalExceptionHandler.java <br/>
|
||||
* Class: org.jbase.jbsc.commons.base.config.handler.GlobalExceptionHandler <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/9/17 上午10:34 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger L = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
/**
|
||||
* 路径错误
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public ResultBean handlerNoFoundException(Exception e) {
|
||||
L.error(e.getMessage(), e);
|
||||
return ResultBean.fireFail().setCode("404").setMsg("路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResultBean handleException(Exception e) {
|
||||
L.error(e.getMessage(), e);
|
||||
//发送邮件
|
||||
return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义验证异常
|
||||
*/
|
||||
@ExceptionHandler(BindException.class)
|
||||
public ResultBean validatedBindException(BindException e) {
|
||||
L.error(e.getMessage(), e);
|
||||
String message = e.getAllErrors().get(0).getDefaultMessage();
|
||||
return ResultBean.fireFail().setCode("405").setMsg(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法参数验证异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResultBean validExceptionHandler(MethodArgumentNotValidException e) {
|
||||
L.error(e.getMessage(), e);
|
||||
String message = e.getBindingResult().getFieldError().getDefaultMessage();
|
||||
return ResultBean.fireFail().setCode("405").setMsg(message);
|
||||
}
|
||||
}
|
||||
194
yyd-base/yyd-base-jdbc/pom.xml
Normal file
194
yyd-base/yyd-base-jdbc/pom.xml
Normal file
@@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-base-jdbc</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-ui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-micro-spring-boot-starter</artifactId>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.73</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.14</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 二维码 -->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--极光推送-->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jiguang-common</artifactId>
|
||||
<version>1.1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.6.Final</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 拼音 -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--工具包-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,67 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.jdbc;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: MybatisPlusConfig.java <br/>
|
||||
* Class: com.yxt.common.base.config.MybatisPlusConfig <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/24 下午12:42 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
/*
|
||||
* 分页插件,自动识别数据库类型 多租户,请参考官网【插件扩展】
|
||||
*/
|
||||
// @Bean
|
||||
// public MybatisPlusInterceptor paginationInterceptor() {
|
||||
// return new MybatisPlusInterceptor();
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
|
||||
// paginationInterceptor.setOverflow(false);
|
||||
// 设置最大单页限制数量,默认 500 条,-1 不受限制
|
||||
// paginationInterceptor.setLimit(500);
|
||||
// 开启 count 的 join 优化,只针对部分 left join
|
||||
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
|
||||
return paginationInterceptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
/*********************************************************
|
||||
*********************************************************
|
||||
******************** *******************
|
||||
************* ************
|
||||
******* _oo0oo_ *******
|
||||
*** o8888888o ***
|
||||
* 88" . "88 *
|
||||
* (| -_- |) *
|
||||
* 0\ = /0 *
|
||||
* ___/`---'\___ *
|
||||
* .' \\| |// '. *
|
||||
* / \\||| : |||// \ *
|
||||
* / _||||| -:- |||||- \ *
|
||||
* | | \\\ - /// | | *
|
||||
* | \_| ''\---/'' |_/ | *
|
||||
* \ .-\__ '-' ___/-. / *
|
||||
* ___'. .' /--.--\ `. .'___ *
|
||||
* ."" '< `.___\_<|>_/___.' >' "". *
|
||||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | *
|
||||
* \ \ `_. \_ __\ /__ _/ .-` / / *
|
||||
* =====`-.____`.___ \_____/___.-`___.-'===== *
|
||||
* `=---=' *
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
|
||||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
|
||||
*********************************************************/
|
||||
package com.yyd.base.jdbc.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yyd.base.common.domain.BaseEntity;
|
||||
import com.yyd.base.common.dto.Dto;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.query.Query;
|
||||
import com.yyd.base.common.utils.PagerUtil;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Project: yxt-common <br/>
|
||||
* File: MybatisBaseService.java <br/>
|
||||
* Class: PACKAGE_NAME.MybatisBaseService <br/>
|
||||
* Description: <描述类的功能>. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2020/8/24 下午2:41 <br/>
|
||||
*
|
||||
* @author popo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MybatisBaseService<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T entity() {
|
||||
T instance = null;
|
||||
Class<T> entityClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass())
|
||||
.getActualTypeArguments()[1];
|
||||
try {
|
||||
instance = entityClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
protected Long checkId(Map<String, Object> map) {
|
||||
Object object = map.get("id");
|
||||
if (object == null)
|
||||
return 0L;
|
||||
String sId = object.toString();
|
||||
if (StringUtils.isBlank(sId))
|
||||
return 0L;
|
||||
Long id = Long.valueOf(sId);
|
||||
return id;
|
||||
}
|
||||
|
||||
protected String checkSid(Map<String, Object> map) {
|
||||
Object object = map.get("sid");
|
||||
if (object == null)
|
||||
return null;
|
||||
// if (StringUtils.isBlank(object.toString()))
|
||||
// return null;
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : 将Map转换为实体对象. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param map
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected T map2entity(Map<String, Object> map, T t) {
|
||||
map.remove("id");
|
||||
map.remove("sid");
|
||||
map.remove("createTime");
|
||||
map.remove("modifyTime");
|
||||
if (t instanceof BaseEntity) {
|
||||
((BaseEntity) t).setModifyTime(new Date());
|
||||
t = (T) (BaseEntity) t;
|
||||
}
|
||||
BeanUtil.fillBeanWithMapIgnoreCase(map, t, false);
|
||||
return t;
|
||||
}
|
||||
|
||||
public int insert(T paramT) {
|
||||
return baseMapper.insert(paramT);
|
||||
}
|
||||
|
||||
public int insert(Map<String, Object> map) {
|
||||
T t = entity();
|
||||
t = map2entity(map, t);
|
||||
return insert(t);
|
||||
}
|
||||
|
||||
public int deleteBySid(String sid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sid", sid);
|
||||
return baseMapper.deleteByMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public int delByIds(String ids) {
|
||||
String[] split = ids.split(",");
|
||||
if (split.length < 1) {
|
||||
return 0;
|
||||
} else if (split.length == 1) {
|
||||
return baseMapper.deleteById(Long.valueOf(ids));
|
||||
} else {
|
||||
List<Long> list = new ArrayList<>();
|
||||
for (String id : split) {
|
||||
list.add(Long.valueOf(id));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param sids
|
||||
* @return
|
||||
*/
|
||||
public int delBySids(String[] sids) {
|
||||
if (sids == null || sids.length < 1)
|
||||
return 0;
|
||||
else if (sids.length == 1) {
|
||||
String sid = sids[0];
|
||||
return deleteBySid(sid);
|
||||
} else {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String sid : sids) {
|
||||
list.add(sid);
|
||||
}
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.in("sid", list);
|
||||
return baseMapper.delete(qw);
|
||||
}
|
||||
}
|
||||
|
||||
public int updateById(Map<String, Object> map) {
|
||||
Long id = checkId(map);
|
||||
if (id.equals(0L))
|
||||
return 0;
|
||||
return updateById(map, id);
|
||||
}
|
||||
|
||||
public int updateById(Map<String, Object> map, Serializable id) {
|
||||
T t = fetchById(id);
|
||||
if (t == null)
|
||||
return -1;
|
||||
t = map2entity(map, t);
|
||||
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int updateBySid(Map<String, Object> map) {
|
||||
String sid = checkSid(map);
|
||||
if (StringUtils.isBlank(sid))
|
||||
return 0;
|
||||
return updateBySid(map, sid);
|
||||
}
|
||||
|
||||
public int updateBySid(Dto dto, String sid) {
|
||||
T t = fetchBySid(sid);
|
||||
if (t == null)
|
||||
return -1;
|
||||
BeanUtil.copyProperties(dto,t);
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int updateBySid(Map<String, Object> map, String sid) {
|
||||
T t = fetchBySid(sid);
|
||||
if (t == null)
|
||||
return -1;
|
||||
t = map2entity(map, t);
|
||||
|
||||
if (t instanceof BaseEntity) {
|
||||
if(((BaseEntity) t).getLockVersion()!=null) {
|
||||
((BaseEntity) t).setLockVersion(((BaseEntity) t).getLockVersion() + 1);
|
||||
}
|
||||
}
|
||||
return baseMapper.updateById(t);
|
||||
}
|
||||
|
||||
public int insertOrUpdateById(Map<String, Object> map) {
|
||||
Long id = checkId(map);
|
||||
if (id.equals(0L))
|
||||
return insert(map);
|
||||
return updateById(map, id);
|
||||
}
|
||||
|
||||
public int insertOrUpdateBySid(Map<String, Object> map) {
|
||||
String sid = checkSid(map);
|
||||
if (StringUtils.isBlank(sid))
|
||||
return insert(map);
|
||||
return updateBySid(map, sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T fetchById(Serializable id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
public T fetchBySid(String sid) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq("sid", sid);
|
||||
return baseMapper.selectOne(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param page
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public IPage<T> pagging(IPage<T> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return pagging(page, qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param page
|
||||
* @param qw
|
||||
* @return
|
||||
*/
|
||||
public IPage<T> pagging(IPage<T> page, QueryWrapper<T> qw) {
|
||||
IPage<T> selectPage = baseMapper.selectPage(page, qw);
|
||||
if (selectPage.getPages() < selectPage.getCurrent()) {
|
||||
page.setCurrent(selectPage.getPages());
|
||||
page.setTotal(selectPage.getTotal());
|
||||
selectPage = baseMapper.selectPage(page, qw);
|
||||
}
|
||||
return selectPage;
|
||||
}
|
||||
|
||||
public IPage<Map<String, Object>> paggingMap(IPage<Map<String, Object>> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return paggingMap(page, qw);
|
||||
}
|
||||
|
||||
|
||||
public IPage<Map<String, Object>> paggingMap(IPage<Map<String, Object>> page, QueryWrapper<T> qw) {
|
||||
IPage<Map<String, Object>> selectMapsPage = baseMapper.selectMapsPage(page, qw);
|
||||
|
||||
if (selectMapsPage.getPages() < selectMapsPage.getCurrent()) {
|
||||
page.setCurrent(selectMapsPage.getPages());
|
||||
page.setTotal(selectMapsPage.getTotal());
|
||||
selectMapsPage = baseMapper.selectMapsPage(page, qw);
|
||||
}
|
||||
|
||||
return selectMapsPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : <描述函数实现的功能>. <br/>
|
||||
* <p>
|
||||
*
|
||||
* @param params
|
||||
*/
|
||||
private QueryWrapper<T> defaultPageQueryWrapper(Map<String, Object> params) {
|
||||
if (params == null || params.isEmpty())
|
||||
return Wrappers.emptyWrapper();
|
||||
|
||||
QueryWrapper<T> qw = new QueryWrapper<T>();
|
||||
for (String key : params.keySet()) {
|
||||
qw.like(key, params.get(key));
|
||||
}
|
||||
return qw;
|
||||
}
|
||||
|
||||
public IPage<T> page(IPage<T> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return super.page(page, qw);
|
||||
}
|
||||
|
||||
public IPage<Map<String, Object>> pageMaps(IPage<Map<String, Object>> page, Map<String, Object> params) {
|
||||
QueryWrapper<T> qw = defaultPageQueryWrapper(params);
|
||||
return super.pageMaps(page, qw);
|
||||
}
|
||||
|
||||
public <V extends Vo, Q extends Query> PagerVo<V> page(PagerQuery<Q> pagerQuery) {
|
||||
Q params = pagerQuery.getParams();
|
||||
IPage<T> page = PagerUtil.queryToPage(pagerQuery);
|
||||
Map<String, Object> paramsMap = null;
|
||||
if (params != null)
|
||||
paramsMap = params.toMap();
|
||||
IPage pageResult = this.page(page, paramsMap);
|
||||
PagerVo<V> pv = PagerUtil.pageToVo(pageResult, null);
|
||||
return pv;
|
||||
}
|
||||
|
||||
public <Q extends Query> PagerVo<Map<String, Object>> pageMaps(PagerQuery<Q> pagerQuery) {
|
||||
Q params = pagerQuery.getParams();
|
||||
IPage<T> page = PagerUtil.queryToPage(pagerQuery);
|
||||
Map<String, Object> paramsMap = null;
|
||||
if (params != null)
|
||||
paramsMap = params.toMap();
|
||||
IPage pageResult = this.page(page, paramsMap);
|
||||
PagerVo<Map<String, Object>> pv = PagerUtil.pageToVo(pageResult, new PagerVo<>());
|
||||
return pv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等的数据列表
|
||||
*
|
||||
* @param filedName 字段名
|
||||
* @param filedValue 相等的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiled(String filedName, String filedValue) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
return list(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等,但不等于id的数据列表
|
||||
*
|
||||
* @param filedName 字段名
|
||||
* @param filedValue 相等的值
|
||||
* @param id id的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiledNeId(String filedName, String filedValue, Serializable id) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
qw.ne("id", id);
|
||||
return list(qw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询与某一字段值相等,但与另一字段的值不相等的数据列表
|
||||
*
|
||||
* @param filedName 相等的字段名
|
||||
* @param filedValue 相等的值
|
||||
* @param neName 不相等的字段名
|
||||
* @param neValue 不相等的值
|
||||
* @return
|
||||
*/
|
||||
public List<T> listEqFiledWithNe(String filedName, String filedValue, String neName, String neValue) {
|
||||
QueryWrapper<T> qw = new QueryWrapper<>();
|
||||
qw.eq(filedName, filedValue);
|
||||
qw.ne(neName, neValue);
|
||||
return list(qw);
|
||||
}
|
||||
}
|
||||
39
yyd-base/yyd-base-redis/pom.xml
Normal file
39
yyd-base/yyd-base-redis/pom.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-base</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-base-redis</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.yyd.base.redis;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/9/18 19:37
|
||||
* @description
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${spring.redis.timeout}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-active}")
|
||||
private int redisPoolMaxActive;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-wait}")
|
||||
private int redisPoolMaxWait;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.max-idle}")
|
||||
private int redisPoolMaxIdle;
|
||||
|
||||
@Value("${spring.redis.jedis.pool.min-idle}")
|
||||
private int redisPoolMinIdle;
|
||||
@Value("${spring.redis.database}")
|
||||
private int database;
|
||||
|
||||
@Bean
|
||||
public JedisPoolConfig getJedisPoolConfig() {
|
||||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||
//最大空闲数
|
||||
jedisPoolConfig.setMaxIdle(redisPoolMaxIdle);
|
||||
//最小空闲数
|
||||
jedisPoolConfig.setMinIdle(redisPoolMinIdle);
|
||||
//最大建立连接等待时间
|
||||
jedisPoolConfig.setMaxWaitMillis(redisPoolMaxWait);
|
||||
//连接池的最大数据库连接数
|
||||
jedisPoolConfig.setMaxTotal(redisPoolMaxActive);
|
||||
return jedisPoolConfig;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
|
||||
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(jedisPoolConfig);
|
||||
jedisConnectionFactory.setDatabase(database);
|
||||
//IP地址
|
||||
jedisConnectionFactory.setHostName(host);
|
||||
//如果redis设置有密码
|
||||
jedisConnectionFactory.setPassword(password);
|
||||
//端口号
|
||||
jedisConnectionFactory.setPort(port);
|
||||
//客户端超时时间单位是毫秒
|
||||
jedisConnectionFactory.setTimeout(timeout);
|
||||
// jedisConnectionFactory.afterPropertiesSet(); //记得添加这行!
|
||||
return jedisConnectionFactory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
// 使用Jackson2JsonRedisSerialize 替换默认序列化
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
// key采用String的序列化方式
|
||||
//redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
// hash的key也采用String的序列化方式
|
||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
||||
// value序列化方式采用jackson
|
||||
// redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
redisTemplate.setValueSerializer(stringRedisSerializer);
|
||||
// hash的value序列化方式采用jackson
|
||||
redisTemplate.setHashValueSerializer(stringRedisSerializer);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package com.yyd.base.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/9/9 17:35
|
||||
* @description redis工具类
|
||||
*/
|
||||
@Service
|
||||
public class RedisUtil {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 字符串类型:根据key设置value值,如果key中的value存在,那么返回false
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Boolean setnx(final String key, final String value, final long expration, final TimeUnit timeUnit) {
|
||||
return (Boolean) redisTemplate.execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection redisConnection) throws DataAccessException {
|
||||
RedisSerializer<String> redisSerializer = redisTemplate.getStringSerializer();
|
||||
byte keys[] = redisSerializer.serialize(key);
|
||||
byte values[] = redisSerializer.serialize(value);
|
||||
return redisConnection.set(keys, values, Expiration.from(expration, timeUnit), RedisStringCommands.SetOption.SET_IF_ABSENT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入缓存
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean set(final String key, final String value) {
|
||||
|
||||
boolean result = (boolean) redisTemplate.execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
connection.set(serializer.serialize(key), serializer.serialize(value));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入缓存设置时效时间
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean set(final String key, Object value, Long expireTime) {
|
||||
boolean result = false;
|
||||
try {
|
||||
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value);
|
||||
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
|
||||
result = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean expire(String key, long expire) {
|
||||
return redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取缓存
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String get(final String key) {
|
||||
String result = (String) redisTemplate.execute(new RedisCallback<String>() {
|
||||
@Override
|
||||
public String doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
byte[] value = connection.get(serializer.serialize(key));
|
||||
return serializer.deserialize(value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则获取key集合
|
||||
*
|
||||
* @param pattern
|
||||
* @return
|
||||
*/
|
||||
public Set<String> keys(String pattern) {
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除对应的value
|
||||
*
|
||||
* @param keys
|
||||
*/
|
||||
public void remove(final String... keys) {
|
||||
for (String key : keys) {
|
||||
remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除key
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
public void removePattern(final String pattern) {
|
||||
Set<Serializable> keys = redisTemplate.keys(pattern);
|
||||
if (keys.size() > 0) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Long remove(final String key) {
|
||||
return (Long) redisTemplate.execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection redisConnection) throws DataAccessException {
|
||||
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
|
||||
byte keys[] = serializer.serialize(key);
|
||||
return redisConnection.del(keys);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断缓存中是否有对应的value
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean exists(final String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 哈希 添加
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @param value
|
||||
*/
|
||||
public void hmSet(String key, Object hashKey, Object value) {
|
||||
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
|
||||
hash.put(key, hashKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 哈希获取数据
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @return
|
||||
*/
|
||||
public String hmGet(String key, Object hashKey) {
|
||||
HashOperations<String, String, String> hash = redisTemplate.opsForHash();
|
||||
return hash.get(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取哈希 keys
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<String> hmGetKeys(String key) {
|
||||
HashOperations<String, String, String> hash = redisTemplate.opsForHash();
|
||||
return hash.keys(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合中的key
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
*/
|
||||
public void hmDelete(String key, Object hashKey) {
|
||||
HashOperations<String, Object, Object> hash = redisTemplate.opsForHash();
|
||||
hash.delete(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表添加
|
||||
*
|
||||
* @param k
|
||||
* @param v
|
||||
*/
|
||||
public void lPush(String k, Object v) {
|
||||
ListOperations<String, Object> list = redisTemplate.opsForList();
|
||||
list.rightPush(k, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表获取
|
||||
*
|
||||
* @param k
|
||||
* @param l
|
||||
* @param l1
|
||||
* @return
|
||||
*/
|
||||
public List<Object> lRange(String k, long l, long l1) {
|
||||
ListOperations<String, Object> list = redisTemplate.opsForList();
|
||||
return list.range(k, l, l1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 集合添加
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public void add(String key, Object value) {
|
||||
SetOperations<String, Object> set = redisTemplate.opsForSet();
|
||||
set.add(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 集合获取
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> setMembers(String key) {
|
||||
SetOperations<String, Object> set = redisTemplate.opsForSet();
|
||||
return set.members(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有序集合添加
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param scoure
|
||||
*/
|
||||
public void zAdd(String key, Object value, double scoure) {
|
||||
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
|
||||
zset.add(key, value, scoure);
|
||||
}
|
||||
|
||||
/**
|
||||
* 有序集合获取
|
||||
*
|
||||
* @param key
|
||||
* @param scoure
|
||||
* @param scoure1
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> rangeByScore(String key, double scoure, double scoure1) {
|
||||
ZSetOperations<String, Object> zset = redisTemplate.opsForZSet();
|
||||
return zset.rangeByScore(key, scoure, scoure1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现命令:TTL key 以秒为单位,返回给定key的剩余生存时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public long ttl(String key) {
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyPrefix: key前缀
|
||||
* @description: 根据前缀获取所有的符合该keyvalue值
|
||||
* @author: dimengzhe
|
||||
* @date: 2021/11/6 16:16
|
||||
* @return: java.util.List<java.lang.String>
|
||||
*/
|
||||
public List<String> getValuesByPrefix(String keyPrefix) {
|
||||
List<String> keys = getKeysByPrefix(keyPrefix);
|
||||
List<Object> values = redisTemplate.opsForValue().multiGet(keys);
|
||||
return (List<String>) (List) values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyPrefix: key前缀
|
||||
* @description: 根据前缀获取所有的符合该key的所有key值集合
|
||||
* @author: dimengzhe
|
||||
* @date: 2021/11/6 16:17
|
||||
* @return: java.util.List<java.lang.String>
|
||||
*/
|
||||
public List<String> getKeysByPrefix(String keyPrefix) {
|
||||
Set<String> keys = redisTemplate.keys(keyPrefix + "*");
|
||||
return Arrays.asList(keys.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
18
yyd-center/pom.xml
Normal file
18
yyd-center/pom.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modules>
|
||||
<module>yyd-center-gateway</module>
|
||||
</modules>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>yyd-center</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
117
yyd-center/yyd-center-gateway/pom.xml
Normal file
117
yyd-center/yyd-center-gateway/pom.xml
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-center</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-center-gateway</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-redis</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
<!--
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>-->
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,265 @@
|
||||
package com.yyd.gateway;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.yyd.base.redis.RedisUtil;
|
||||
import com.yyd.gateway.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.cloud.gateway.route.Route;
|
||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 9:52
|
||||
* @description 网关鉴权
|
||||
* 1.某些接口不需要不进行登录验证,如登录,注册,获取验证码等接口。(uri白名单)
|
||||
*2.某些接口需要登录验证,但是不需要刷新token有效时间,如客户端轮询请求的接口。
|
||||
*3.特定场景下IP黑、白名单。
|
||||
*4.处于安全考虑的接口流量控制。
|
||||
*/
|
||||
@Component
|
||||
public class AuthFilter implements GlobalFilter, Ordered {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
||||
//过期时间设置为4小时
|
||||
private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60;
|
||||
private final static long EXPIRE_TIME_APP =Constants.TOKEN_EXPIRE_APP * 60;
|
||||
|
||||
// 排除过滤的 uri 地址,nacos自行添加
|
||||
@Autowired
|
||||
private IgnoreWhiteProperties ignoreWhite;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private KafkaProducerService kafkaProducerService;
|
||||
/*
|
||||
redis中数据存储结构为两个键值对
|
||||
键为用户ID,值为用户token,可以通过用户ID查询用户token,实现立刻失效用户token功能。
|
||||
键为用户token,值为用户数据,实现token有效性,用户数据缓存功能。
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
|
||||
Route route = (Route)exchange.getAttributes().get(ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR);
|
||||
String token = getToken(exchange.getRequest());
|
||||
//2.验证有无令牌。 从请求的header中获取token
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
//客户端IP
|
||||
// String ip = IpUtil.getIpAddress(request);
|
||||
//请求路径
|
||||
String url = exchange.getRequest().getURI().getPath();
|
||||
|
||||
if (StringUtils.matches(url, ignoreWhite.getWhites())) {
|
||||
return chain.filter(exchange);
|
||||
}else if(StringUtils.matchesTwo(url, ignoreWhite.getWhitesTwo())){
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return setUnauthorizedResponse(exchange, "令牌不能为空");
|
||||
}
|
||||
//3.验证token是否有效。(a.验证token是否合法 b.验证token是否过期)
|
||||
//从redis缓存中获取key对应的内容
|
||||
String userName = redisUtil.get(token)==null?"":redisUtil.get(token);
|
||||
/*if (StringUtils.isBlank(userName)) {
|
||||
return setUnauthorizedResponse(exchange, "登录状态已过期");
|
||||
}*/
|
||||
|
||||
//请求方法
|
||||
String methodValue = request.getMethodValue();
|
||||
//请求参数
|
||||
String params = getParamsStr(request,methodValue);
|
||||
//请求头
|
||||
Map<String, String> heads = new LinkedHashMap<>();
|
||||
HttpHeaders headers = request.getHeaders(); //Enumeration<String> headerNames =
|
||||
Set<Map.Entry<String, List<String>>> entries = headers.entrySet();
|
||||
for (Map.Entry<String, List<String>> entry : entries) {
|
||||
String key = entry.getKey();
|
||||
List<String> values = entry.getValue();
|
||||
if (values != null) {
|
||||
for (String value : values) {
|
||||
heads.put( key, value);
|
||||
}
|
||||
} else {
|
||||
heads.put( key, "");
|
||||
}
|
||||
}
|
||||
String ip = getIpAddress(request);
|
||||
if ("POST".equals(methodValue) ){
|
||||
return DataBufferUtils.join(exchange.getRequest().getBody())
|
||||
.flatMap(dataBuffer -> {
|
||||
byte[] bytes = new byte[dataBuffer.readableByteCount()];
|
||||
dataBuffer.read(bytes);
|
||||
try {
|
||||
String bodyString = new String(bytes, "utf-8");
|
||||
sendLog(route.getId(),url,bodyString,methodValue,ip,heads,userName);
|
||||
exchange.getAttributes().put("POST_BODY",bodyString);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
Flux<DataBuffer> cachedFlux = Flux.defer(() -> {
|
||||
DataBuffer buffer = exchange.getResponse().bufferFactory()
|
||||
.wrap(bytes);
|
||||
return Mono.just(buffer);
|
||||
});
|
||||
|
||||
ServerHttpRequest mutatedRequest = new ServerHttpRequestDecorator(
|
||||
exchange.getRequest()) {
|
||||
@Override
|
||||
public Flux<DataBuffer> getBody() {
|
||||
return cachedFlux;
|
||||
}
|
||||
};
|
||||
return chain.filter(exchange.mutate().request(mutatedRequest)
|
||||
.build());
|
||||
});
|
||||
}
|
||||
|
||||
sendLog(route.getId(),url,params,methodValue,ip,heads,userName);
|
||||
// kafkaProducerService.sendMessage("topic02",JSON.toJSON(map).toString());
|
||||
|
||||
//1.uri白名单。 跳过不需要验证的路径
|
||||
|
||||
//验签:需要验证token中的签名是否与用户sid一致,后台用密钥+userSid+token除签名以外的内容,重新生成签名,与token中的签名进行比较
|
||||
|
||||
//刷新token过期日期
|
||||
if(token.contains("App")){
|
||||
//redisUtil.set(token, userName, EXPIRE_TIME_APP);
|
||||
redisUtil.expire(token, EXPIRE_TIME_APP);
|
||||
}else{
|
||||
//redisUtil.set(token, userName, EXPIRE_TIME);
|
||||
redisUtil.expire(token, EXPIRE_TIME);
|
||||
}
|
||||
|
||||
// 在请求中增加用户信息
|
||||
ServerHttpRequest mutableReq = exchange.getRequest().mutate()
|
||||
.header(CacheConstants.DETAILS_USERNAME, userName).build();
|
||||
ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build();
|
||||
return chain.filter(mutableExchange);
|
||||
}
|
||||
private void sendLog(String routeId,String url,String params,String methodValue,String ip, Map<String, String> heads,String userName){
|
||||
//请求时间
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("routeId", routeId);
|
||||
map.put("uri", url);
|
||||
map.put("params", params);
|
||||
map.put("method", methodValue);
|
||||
map.put("requestTime", new Date());
|
||||
map.put("ip", ip);
|
||||
map.put("heads", heads);
|
||||
|
||||
map.put("userName", userName);
|
||||
|
||||
// log.info("gateway:{}",JSON.toJSON(map));
|
||||
log.info(JSON.toJSONString(map, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteMapNullValue));
|
||||
}
|
||||
private String getParamsStr(ServerHttpRequest request,String method) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
MultiValueMap<String, String> paramsMap = request.getQueryParams();
|
||||
Set<Map.Entry<String, List<String>>> entrySet = paramsMap.entrySet();
|
||||
for (Map.Entry<String, List<String>> entry : entrySet) {
|
||||
String key = entry.getKey();
|
||||
List<String> values = entry.getValue();
|
||||
if (values != null) {
|
||||
for (String value : values) {
|
||||
result.append(String.format("&%s=%s", key, value));
|
||||
}
|
||||
} else {
|
||||
result.append(String.format("&%s=%s", key, ""));
|
||||
}
|
||||
}
|
||||
return result.toString().replaceFirst("&", "");
|
||||
}
|
||||
private String getIpAddress(ServerHttpRequest request) {
|
||||
HttpHeaders headers = request.getHeaders();
|
||||
String ip = headers.getFirst("x-forwarded-for");
|
||||
if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
|
||||
// 多次反向代理后会有多个ip值,第一个ip才是真实ip
|
||||
if (ip.indexOf(",") != -1) {
|
||||
ip = ip.split(",")[0];
|
||||
}
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = headers.getFirst("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = headers.getFirst("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = headers.getFirst("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = headers.getFirst("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = headers.getFirst("X-Real-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddress().getAddress().getHostAddress();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
/**
|
||||
* 鉴权异常处理
|
||||
* @param exchange
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
private Mono<Void> setUnauthorizedResponse(ServerWebExchange exchange, String msg) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
||||
response.setStatusCode(HttpStatus.OK);
|
||||
|
||||
log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
|
||||
|
||||
return response.writeWith(Mono.fromSupplier(() -> {
|
||||
DataBufferFactory bufferFactory = response.bufferFactory();
|
||||
return bufferFactory.wrap(JSON.toJSONBytes(R.fail(msg)));
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求token
|
||||
*/
|
||||
private String getToken(ServerHttpRequest request) {
|
||||
String token = request.getHeaders().getFirst(CacheConstants.HEADER);
|
||||
// if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) {
|
||||
// token = token.replace(CacheConstants.TOKEN_PREFIX, "");
|
||||
// }
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yyd.gateway;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class},scanBasePackages = {
|
||||
"com.yyd.gateway",
|
||||
"com.yyd.base",
|
||||
"com.yyd.base.redis"
|
||||
})
|
||||
public class GateWayApplication {
|
||||
private static final Logger LOG=LoggerFactory.getLogger(GateWayApplication.class);
|
||||
public static void main(String[] args) {
|
||||
SpringApplication app = new SpringApplication(GateWayApplication.class);
|
||||
Environment env = app.run(args).getEnvironment();
|
||||
LOG.info("启动成功!!");
|
||||
LOG.info("Gateway地址: \thttp://127.0.0.1:{}", env.getProperty("server.port"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yyd.gateway;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.support.SendResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* KafkaProducerService
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class KafkaProducerService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
|
||||
public void sendMessage(String topic, Object object) {
|
||||
|
||||
ListenableFuture<SendResult<String, Object>> future = kafkaTemplate.send(topic, object);
|
||||
|
||||
future.addCallback(new ListenableFutureCallback<SendResult<String, Object>>() {
|
||||
@Override
|
||||
public void onSuccess(SendResult<String, Object> result) {
|
||||
log.info("发送消息成功: " + result.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
log.error("发送消息失败: " + throwable.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 9:58
|
||||
* @description 缓存的key 常量
|
||||
*/
|
||||
|
||||
public class CacheConstants {
|
||||
|
||||
/**
|
||||
* 令牌自定义标识
|
||||
*/
|
||||
public static final String HEADER = "token";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* 用户名字段
|
||||
*/
|
||||
public static final String DETAILS_USERNAME = "userName";
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 10:02
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class CharsetKit {
|
||||
|
||||
/** ISO-8859-1 */
|
||||
public static final String ISO_8859_1 = "ISO-8859-1";
|
||||
/** UTF-8 */
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
/** GBK */
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/** ISO-8859-1 */
|
||||
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
|
||||
/** UTF-8 */
|
||||
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
|
||||
/** GBK */
|
||||
public static final Charset CHARSET_GBK = Charset.forName(GBK);
|
||||
|
||||
/**
|
||||
* 转换为Charset对象
|
||||
*
|
||||
* @param charset 字符集,为空则返回默认字符集
|
||||
* @return Charset
|
||||
*/
|
||||
public static Charset charset(String charset)
|
||||
{
|
||||
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符串的字符集编码
|
||||
*
|
||||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert(String source, String srcCharset, String destCharset)
|
||||
{
|
||||
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符串的字符集编码
|
||||
*
|
||||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert(String source, Charset srcCharset, Charset destCharset)
|
||||
{
|
||||
if (null == srcCharset)
|
||||
{
|
||||
srcCharset = StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
|
||||
if (null == destCharset)
|
||||
{
|
||||
destCharset = StandardCharsets.UTF_8;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
||||
{
|
||||
return source;
|
||||
}
|
||||
return new String(source.getBytes(srcCharset), destCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 系统字符集编码
|
||||
*/
|
||||
public static String systemCharset()
|
||||
{
|
||||
return Charset.defaultCharset().name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 9:56
|
||||
* @description 通用常量信息
|
||||
*/
|
||||
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* 成功标记
|
||||
*/
|
||||
public static final Integer SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 失败标记
|
||||
*/
|
||||
public static final Integer FAIL = 5000;
|
||||
|
||||
public static final boolean fail = false;
|
||||
public static final boolean success = true;
|
||||
|
||||
/**
|
||||
* 令牌有效期(分钟)
|
||||
*/
|
||||
public final static long TOKEN_EXPIRE = 4*60;
|
||||
public final static long TOKEN_EXPIRE_APP = 15*24*60;
|
||||
}
|
||||
@@ -0,0 +1,999 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 10:01
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class Convert {
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue)
|
||||
{
|
||||
if (null == value)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String)
|
||||
{
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value)
|
||||
{
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value, Character defaultValue)
|
||||
{
|
||||
if (null == value)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Character)
|
||||
{
|
||||
return (Character) value;
|
||||
}
|
||||
|
||||
final String valueStr = toStr(value, null);
|
||||
return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value)
|
||||
{
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Byte)
|
||||
{
|
||||
return (Byte) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Byte.parseByte(valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value)
|
||||
{
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Short)
|
||||
{
|
||||
return (Short) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Short.parseShort(valueStr.trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value)
|
||||
{
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value, Number defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return (Number) value;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return NumberFormat.getInstance().parse(valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value)
|
||||
{
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Integer)
|
||||
{
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value)
|
||||
{
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str)
|
||||
{
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str)
|
||||
{
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str)
|
||||
{
|
||||
if (StringUtils.isEmpty(str))
|
||||
{
|
||||
return new Integer[] {};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Integer[] ints = new Integer[arr.length];
|
||||
for (int i = 0; i < arr.length; i++)
|
||||
{
|
||||
final Integer v = toInt(arr[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str)
|
||||
{
|
||||
if (StringUtils.isEmpty(str))
|
||||
{
|
||||
return new Long[] {};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++)
|
||||
{
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str)
|
||||
{
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str)
|
||||
{
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Long)
|
||||
{
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value)
|
||||
{
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value, Double defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Double)
|
||||
{
|
||||
return (Double) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).doubleValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value)
|
||||
{
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value, Float defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Float)
|
||||
{
|
||||
return (Float) value;
|
||||
}
|
||||
if (value instanceof Number)
|
||||
{
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Float.parseFloat(valueStr.trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value)
|
||||
{
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value, Boolean defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Boolean)
|
||||
{
|
||||
return (Boolean) value;
|
||||
}
|
||||
String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
switch (valueStr)
|
||||
{
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
case "yes":
|
||||
return true;
|
||||
case "ok":
|
||||
return true;
|
||||
case "no":
|
||||
return false;
|
||||
case "1":
|
||||
return true;
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value)
|
||||
{
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (clazz.isAssignableFrom(value.getClass()))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
E myE = (E) value;
|
||||
return myE;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(clazz, valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
|
||||
{
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigInteger)
|
||||
{
|
||||
return (BigInteger) value;
|
||||
}
|
||||
if (value instanceof Long)
|
||||
{
|
||||
return BigInteger.valueOf((Long) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigInteger(valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value)
|
||||
{
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigDecimal)
|
||||
{
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof Long)
|
||||
{
|
||||
return new BigDecimal((Long) value);
|
||||
}
|
||||
if (value instanceof Double)
|
||||
{
|
||||
return new BigDecimal((Double) value);
|
||||
}
|
||||
if (value instanceof Integer)
|
||||
{
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigDecimal(valueStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value)
|
||||
{
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String utf8Str(Object obj)
|
||||
{
|
||||
return str(obj, CharsetKit.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, String charsetName)
|
||||
{
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, Charset charset)
|
||||
{
|
||||
if (null == obj)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (obj instanceof String)
|
||||
{
|
||||
return (String) obj;
|
||||
}
|
||||
else if (obj instanceof byte[] || obj instanceof Byte[])
|
||||
{
|
||||
return str((Byte[]) obj, charset);
|
||||
}
|
||||
else if (obj instanceof ByteBuffer)
|
||||
{
|
||||
return str((ByteBuffer) obj, charset);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte数组转为字符串
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(byte[] bytes, String charset)
|
||||
{
|
||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码字节码
|
||||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String str(byte[] data, Charset charset)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null == charset)
|
||||
{
|
||||
return new String(data);
|
||||
}
|
||||
return new String(data, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, String charset)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return str(data, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, Charset charset)
|
||||
{
|
||||
if (null == charset)
|
||||
{
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
return charset.decode(data).toString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input)
|
||||
{
|
||||
return toSBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input, Set<Character> notConvertSet)
|
||||
{
|
||||
char c[] = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++)
|
||||
{
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||
{
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == ' ')
|
||||
{
|
||||
c[i] = '\u3000';
|
||||
}
|
||||
else if (c[i] < '\177')
|
||||
{
|
||||
c[i] = (char) (c[i] + 65248);
|
||||
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 半角字符串
|
||||
*/
|
||||
public static String toDBC(String input)
|
||||
{
|
||||
return toDBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换全角为半角
|
||||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 替换后的字符
|
||||
*/
|
||||
public static String toDBC(String text, Set<Character> notConvertSet)
|
||||
{
|
||||
char c[] = text.toCharArray();
|
||||
for (int i = 0; i < c.length; i++)
|
||||
{
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i]))
|
||||
{
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == '\u3000')
|
||||
{
|
||||
c[i] = ' ';
|
||||
}
|
||||
else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
|
||||
{
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
String returnString = new String(c);
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
* @param n 数字
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
public static String digitUppercase(double n)
|
||||
{
|
||||
String[] fraction = { "角", "分" };
|
||||
String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
|
||||
String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } };
|
||||
|
||||
String head = n < 0 ? "负" : "";
|
||||
n = Math.abs(n);
|
||||
|
||||
String s = "";
|
||||
for (int i = 0; i < fraction.length; i++)
|
||||
{
|
||||
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||
}
|
||||
if (s.length() < 1)
|
||||
{
|
||||
s = "整";
|
||||
}
|
||||
int integerPart = (int) Math.floor(n);
|
||||
|
||||
for (int i = 0; i < unit[0].length && integerPart > 0; i++)
|
||||
{
|
||||
String p = "";
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++)
|
||||
{
|
||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||
integerPart = integerPart / 10;
|
||||
}
|
||||
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
|
||||
}
|
||||
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 9:54
|
||||
* @description 放行白名单配置
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "ignore")
|
||||
public class IgnoreWhiteProperties {
|
||||
|
||||
/**
|
||||
* 放行白名单配置,网关不校验此处的白名单
|
||||
*/
|
||||
private List<String> whites = new ArrayList<>();
|
||||
|
||||
public List<String> getWhites() {
|
||||
return whites;
|
||||
}
|
||||
|
||||
public void setWhites(List<String> whites) {
|
||||
this.whites = whites;
|
||||
}
|
||||
|
||||
private List<String> whitesTwo = new ArrayList<>();
|
||||
|
||||
public List<String> getWhitesTwo() {
|
||||
return whitesTwo;
|
||||
}
|
||||
|
||||
public void setWhitesTwo(List<String> whitesTwo) {
|
||||
this.whitesTwo = whitesTwo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 10:07
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = Constants.SUCCESS;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int FAIL = Constants.FAIL;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
private boolean success;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, SUCCESS, null, true);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, SUCCESS, null, true);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg, true);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, null, false);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return restResult(null, FAIL, msg, false);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data) {
|
||||
return restResult(data, FAIL, null, false);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data, String msg) {
|
||||
return restResult(data, FAIL, msg, false);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return restResult(null, code, msg, false);
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg, boolean success) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
apiResult.setSuccess(success);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 10:00
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class StrFormatter {
|
||||
|
||||
public static final String EMPTY_JSON = "{}";
|
||||
public static final char C_BACKSLASH = '\\';
|
||||
public static final char C_DELIM_START = '{';
|
||||
public static final char C_DELIM_END = '}';
|
||||
|
||||
/**
|
||||
* 格式化字符串<br>
|
||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||
* 例:<br>
|
||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||
*
|
||||
* @param strPattern 字符串模板
|
||||
* @param argArray 参数列表
|
||||
* @return 结果
|
||||
*/
|
||||
public static String format(final String strPattern, final Object... argArray)
|
||||
{
|
||||
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
|
||||
{
|
||||
return strPattern;
|
||||
}
|
||||
final int strPatternLength = strPattern.length();
|
||||
|
||||
// 初始化定义好的长度以获得更好的性能
|
||||
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
|
||||
|
||||
int handledPosition = 0;
|
||||
int delimIndex;// 占位符所在位置
|
||||
for (int argIndex = 0; argIndex < argArray.length; argIndex++)
|
||||
{
|
||||
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
|
||||
if (delimIndex == -1)
|
||||
{
|
||||
if (handledPosition == 0)
|
||||
{
|
||||
return strPattern;
|
||||
}
|
||||
else
|
||||
{ // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
|
||||
sbuf.append(strPattern, handledPosition, strPatternLength);
|
||||
return sbuf.toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
|
||||
{
|
||||
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
|
||||
{
|
||||
// 转义符之前还有一个转义符,占位符依旧有效
|
||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||
handledPosition = delimIndex + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 占位符被转义
|
||||
argIndex--;
|
||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||
sbuf.append(C_DELIM_START);
|
||||
handledPosition = delimIndex + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 正常占位符
|
||||
sbuf.append(strPattern, handledPosition, delimIndex);
|
||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||
handledPosition = delimIndex + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 加入最后一个占位符后所有的字符
|
||||
sbuf.append(strPattern, handledPosition, strPattern.length());
|
||||
|
||||
return sbuf.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,526 @@
|
||||
package com.yyd.gateway.utils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/12/2 9:59
|
||||
* @description
|
||||
*/
|
||||
|
||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
|
||||
/**
|
||||
* 空字符串
|
||||
*/
|
||||
private static final String NULLSTR = "";
|
||||
|
||||
/**
|
||||
* 下划线
|
||||
*/
|
||||
private static final char SEPARATOR = '_';
|
||||
|
||||
/**
|
||||
* 星号
|
||||
*/
|
||||
private static final String START = "*";
|
||||
|
||||
/**
|
||||
* 获取参数不为空值
|
||||
*
|
||||
* @param value defaultValue 要判断的value
|
||||
* @return value 返回值
|
||||
*/
|
||||
public static <T> T nvl(T value, T defaultValue) {
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Collection<?> coll) {
|
||||
return isNull(coll) || coll.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Collection<?> coll) {
|
||||
return !isEmpty(coll);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象数组是否为空
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
* * @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Object[] objects) {
|
||||
return isNull(objects) || (objects.length == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象数组是否非空
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Object[] objects) {
|
||||
return !isEmpty(objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return isNull(map) || map.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||
return !isEmpty(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个字符串是否为空串
|
||||
*
|
||||
* @param str String
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
return isNull(str) || NULLSTR.equals(str.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个字符串是否为非空串
|
||||
*
|
||||
* @param str String
|
||||
* @return true:非空串 false:空串
|
||||
*/
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否为空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isNull(Object object) {
|
||||
return object == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否非空
|
||||
*
|
||||
* @param object Object
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotNull(Object object) {
|
||||
return !isNull(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||
*
|
||||
* @param object 对象
|
||||
* @return true:是数组 false:不是数组
|
||||
*/
|
||||
public static boolean isArray(Object object) {
|
||||
return isNotNull(object) && object.getClass().isArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 去空格
|
||||
*/
|
||||
public static String trim(String str) {
|
||||
return (str == null ? "" : str.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @return 结果
|
||||
*/
|
||||
public static String substring(final String str, int start) {
|
||||
if (str == null) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = str.length() + start;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (start > str.length()) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
return str.substring(start);
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @param end 结束
|
||||
* @return 结果
|
||||
*/
|
||||
public static String substring(final String str, int start, int end) {
|
||||
if (str == null) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (end < 0) {
|
||||
end = str.length() + end;
|
||||
}
|
||||
if (start < 0) {
|
||||
start = str.length() + start;
|
||||
}
|
||||
|
||||
if (end > str.length()) {
|
||||
end = str.length();
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = 0;
|
||||
}
|
||||
|
||||
return str.substring(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化文本, {} 表示占位符<br>
|
||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||
* 例:<br>
|
||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||
*
|
||||
* @param template 文本模板,被替换的部分用 {} 表示
|
||||
* @param params 参数值
|
||||
* @return 格式化后的文本
|
||||
*/
|
||||
public static String format(String template, Object... params) {
|
||||
if (isEmpty(params) || isEmpty(template)) {
|
||||
return template;
|
||||
}
|
||||
return StrFormatter.format(template, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下划线转驼峰命名
|
||||
*/
|
||||
public static String toUnderScoreCase(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 前置字符是否大写
|
||||
boolean preCharIsUpperCase = true;
|
||||
// 当前字符是否大写
|
||||
boolean curreCharIsUpperCase = true;
|
||||
// 下一字符是否大写
|
||||
boolean nexteCharIsUpperCase = true;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (i > 0) {
|
||||
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
||||
} else {
|
||||
preCharIsUpperCase = false;
|
||||
}
|
||||
|
||||
curreCharIsUpperCase = Character.isUpperCase(c);
|
||||
|
||||
if (i < (str.length() - 1)) {
|
||||
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
||||
}
|
||||
|
||||
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
|
||||
sb.append(SEPARATOR);
|
||||
} else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
|
||||
sb.append(SEPARATOR);
|
||||
}
|
||||
sb.append(Character.toLowerCase(c));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含字符串
|
||||
*
|
||||
* @param str 验证字符串
|
||||
* @param strs 字符串组
|
||||
* @return 包含返回true
|
||||
*/
|
||||
public static boolean inStringIgnoreCase(String str, String... strs) {
|
||||
if (str != null && strs != null) {
|
||||
for (String s : strs) {
|
||||
if (str.equalsIgnoreCase(trim(s))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
||||
*
|
||||
* @param name 转换前的下划线大写方式命名的字符串
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String convertToCamelCase(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty()) {
|
||||
// 没必要转换
|
||||
return "";
|
||||
} else if (!name.contains("_")) {
|
||||
// 不含下划线,仅将首字母大写
|
||||
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
// 用下划线将原始字符串分割
|
||||
String[] camels = name.split("_");
|
||||
for (String camel : camels) {
|
||||
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||
if (camel.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
// 首字母大写
|
||||
result.append(camel.substring(0, 1).toUpperCase());
|
||||
result.append(camel.substring(1).toLowerCase());
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 驼峰式命名法 例如:user_name->userName
|
||||
*/
|
||||
public static String toCamelCase(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
s = s.toLowerCase();
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
boolean upperCase = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (c == SEPARATOR) {
|
||||
upperCase = true;
|
||||
} else if (upperCase) {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
upperCase = false;
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matchesTwo(String str, List<String> strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
for (String testStr : strs) {
|
||||
if (matchesTwo(str, testStr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(String str, List<String> strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
for (String testStr : strs) {
|
||||
if (matches(str, testStr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否匹配指定字符串数组中的任意一个字符串
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matches(String str, String... strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
for (String testStr : strs) {
|
||||
if (matches(str, testStr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean matches(String str, String pattern) {
|
||||
if (isEmpty(pattern) || isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pattern = pattern.replaceAll("\\s*", ""); // 替换空格
|
||||
int beginOffset = 0; // pattern截取开始位置
|
||||
int formerStarOffset = -1; // 前星号的偏移位置
|
||||
int latterStarOffset = -1; // 后星号的偏移位置
|
||||
|
||||
String remainingURI = str;
|
||||
String prefixPattern = "";
|
||||
String suffixPattern = "";
|
||||
|
||||
boolean result = false;
|
||||
do {
|
||||
formerStarOffset = indexOf(pattern, START, beginOffset);
|
||||
prefixPattern = substring(pattern, beginOffset, formerStarOffset > -1 ? formerStarOffset : pattern.length());
|
||||
|
||||
// 匹配前缀Pattern
|
||||
result = remainingURI.equals(prefixPattern);
|
||||
// 已经没有星号,直接返回
|
||||
if (formerStarOffset == -1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 匹配失败,直接返回
|
||||
if (!result){
|
||||
return false;
|
||||
}
|
||||
if (!isEmpty(prefixPattern)) {
|
||||
remainingURI = substringAfter(str, prefixPattern);
|
||||
}
|
||||
|
||||
// 匹配后缀Pattern
|
||||
latterStarOffset = indexOf(pattern, START, formerStarOffset + 1);
|
||||
suffixPattern = substring(pattern, formerStarOffset + 1, latterStarOffset > -1 ? latterStarOffset : pattern.length());
|
||||
|
||||
result = remainingURI.equals(suffixPattern);
|
||||
// 匹配失败,直接返回
|
||||
if (!result){
|
||||
return false;
|
||||
}
|
||||
if (!isEmpty(suffixPattern)) {
|
||||
remainingURI = substringAfter(str, suffixPattern);
|
||||
}
|
||||
|
||||
// 移动指针
|
||||
beginOffset = latterStarOffset + 1;
|
||||
|
||||
}
|
||||
while (!isEmpty(suffixPattern) && !isEmpty(remainingURI));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找指定字符串是否匹配
|
||||
*
|
||||
* @param str 指定字符串
|
||||
* @param pattern 需要检查的字符串
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matchesTwo(String str, String pattern) {
|
||||
if (isEmpty(pattern) || isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pattern = pattern.replaceAll("\\s*", ""); // 替换空格
|
||||
int beginOffset = 0; // pattern截取开始位置
|
||||
int formerStarOffset = -1; // 前星号的偏移位置
|
||||
int latterStarOffset = -1; // 后星号的偏移位置
|
||||
|
||||
String remainingURI = str;
|
||||
String prefixPattern = "";
|
||||
String suffixPattern = "";
|
||||
|
||||
boolean result = false;
|
||||
do {
|
||||
formerStarOffset = indexOf(pattern, START, beginOffset);
|
||||
prefixPattern = substring(pattern, beginOffset, formerStarOffset > -1 ? formerStarOffset : pattern.length());
|
||||
|
||||
// 匹配前缀Pattern
|
||||
result = remainingURI.contains(prefixPattern);
|
||||
// 已经没有星号,直接返回
|
||||
if (formerStarOffset == -1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 匹配失败,直接返回
|
||||
if (!result){
|
||||
return false;
|
||||
}
|
||||
if (!isEmpty(prefixPattern)) {
|
||||
remainingURI = substringAfter(str, prefixPattern);
|
||||
}
|
||||
|
||||
// 匹配后缀Pattern
|
||||
latterStarOffset = indexOf(pattern, START, formerStarOffset + 1);
|
||||
suffixPattern = substring(pattern, formerStarOffset + 1, latterStarOffset > -1 ? latterStarOffset : pattern.length());
|
||||
|
||||
result = remainingURI.contains(suffixPattern);
|
||||
// 匹配失败,直接返回
|
||||
if (!result){
|
||||
return false;
|
||||
}
|
||||
if (!isEmpty(suffixPattern)) {
|
||||
remainingURI = substringAfter(str, suffixPattern);
|
||||
}
|
||||
|
||||
// 移动指针
|
||||
beginOffset = latterStarOffset + 1;
|
||||
|
||||
}
|
||||
while (!isEmpty(suffixPattern) && !isEmpty(remainingURI));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cast(Object obj) {
|
||||
return (T) obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
resources:
|
||||
static-locations: file:D://anrui
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
resources:
|
||||
static-locations: file:D://anrui
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
resources:
|
||||
static-locations: file:D://anrui
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 39.104.100.138:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 39.104.100.138
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
@@ -0,0 +1,53 @@
|
||||
logging:
|
||||
config: classpath:log4j.xml
|
||||
hystrix:
|
||||
command:
|
||||
default:
|
||||
execution:
|
||||
isolation:
|
||||
strategy: SEMAPHORE
|
||||
thread:
|
||||
timeoutInMilliseconds: 300000
|
||||
server:
|
||||
port: 8111
|
||||
spring:
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092
|
||||
producer:
|
||||
retries: 0
|
||||
batch-size: 16384
|
||||
buffer-memory: 33554432
|
||||
key-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||
value-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||
acks: 1
|
||||
application:
|
||||
name: gateway-server
|
||||
profiles:
|
||||
active: devv
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: yyd-demo
|
||||
predicates:
|
||||
- Path= /demo/**
|
||||
uri: lb://yyd-demo
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
|
||||
ignore:
|
||||
whites:
|
||||
- /portal/v1/sysuser/login #pc端登录
|
||||
- /portal/v1/sysuser/signOut #pc 退出登录
|
||||
- /demo/v1/sysuser/list
|
||||
|
||||
whitesTwo: #包含所有
|
||||
###swagger相关开始
|
||||
- /doc.html
|
||||
- /webjars/**
|
||||
- /swagger-resources
|
||||
- /v2/**
|
||||
- /favicon.ico
|
||||
- /upload/**
|
||||
###swagger相关结束
|
||||
|
||||
41
yyd-center/yyd-center-gateway/src/main/resources/log4j.xml
Normal file
41
yyd-center/yyd-center-gateway/src/main/resources/log4j.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,
|
||||
你会看到log4j2内部各种详细输出。可以设置成OFF(关闭)或Error(只输出错误信息) -->
|
||||
<Configuration status="OFF">
|
||||
<Properties>
|
||||
<!-- 配置日志文件输出目录 -->
|
||||
<Property name="log_path" value="log/" />
|
||||
<Property name="file_name">log</Property>
|
||||
<Property name="kafka_log_topic">kafka_log_topic</Property>
|
||||
<Property name="bootstrap_servers">localhost:9092</Property>
|
||||
</Properties>
|
||||
|
||||
<Appenders>
|
||||
<!-- 输出控制台日志的配置 -->
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
|
||||
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
|
||||
<!-- 输出日志的格式 -->
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
<File name="log_file" fileName="${log_path}/${file_name}.log" append="true" immediateFlush="true">
|
||||
<PatternLayout pattern="%d{yy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</File>
|
||||
<Kafka name="kafka" topic="${kafka_log_topic}">
|
||||
<!--<PatternLayout pattern="%date %message"/>-->
|
||||
<Property name="bootstrap.servers">${bootstrap_servers}</Property>
|
||||
<!--json格式输出-->
|
||||
<JsonLayout compact="true" locationInfo="true" complete="false" eventEol="true"/>
|
||||
</Kafka>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="kafka"/>
|
||||
<AppenderRef ref="console"/>
|
||||
<AppenderRef ref="log_file"/>
|
||||
</Root>
|
||||
<!-- <Logger name="org.apache.kafka" level="INFO" />--> <!-- avoid recursive logging -->
|
||||
<logger name="org.springframework" level="INFO"/>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
46
yyd-demo/demo-api/pom.xml
Normal file
46
yyd-demo/demo-api/pom.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-demo</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>demo-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.yyd.base.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel(value = "用户表", description = "用户表")
|
||||
@TableName("sys_user")
|
||||
@Data
|
||||
public class SysUser extends BaseEntity {
|
||||
|
||||
@ApiModelProperty("登录名,登录名不能相同")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("密码(加密或签名后)")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("密码修改时限")
|
||||
private String pwdDayslimit;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@ApiModelProperty("最后一次密码修改时间")
|
||||
private Date pwdModifyTime;
|
||||
|
||||
@ApiModelProperty("在线状态(0为离线、1为在线)")
|
||||
private Integer onlineState;
|
||||
|
||||
@ApiModelProperty("用户登录时随机生成身份验证字符串")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty("是否是管理员:1管理员,2一般用户,0是超级管理员,3尚无单位人员")
|
||||
private String isAdmin;
|
||||
|
||||
@ApiModelProperty("手机登录唯一标识,手机与用户绑定字段")
|
||||
private String appId;
|
||||
|
||||
@ApiModelProperty("关联的人员sid")
|
||||
private String staffSid;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("用户类型:1员工、2客户、3供应商")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户头像")
|
||||
private String headImage;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
import com.yyd.base.common.dto.Dto;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@ApiModel(value = "用户表 数据传输对象", description = "用户表 数据传输对象")
|
||||
@Data
|
||||
public class SysUserDto implements Dto {
|
||||
@ApiModelProperty("手机号")
|
||||
private String mobile;
|
||||
@ApiModelProperty("用户类型:1员工、2客户、3供应商")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "姓名", required = true)
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "验证码", required = true)
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
@ApiModelProperty(value = "部门sid")
|
||||
private String deptSid;
|
||||
@ApiModelProperty(value = "岗位sid")
|
||||
private String postSid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "用户表")
|
||||
@FeignClient(
|
||||
contextId = "yyd-demo-SysUser",
|
||||
name = "yyd-demo",
|
||||
path = "v1/sysuser",
|
||||
fallback = SysUserFeignFallback.class)
|
||||
public interface SysUserFeign {
|
||||
|
||||
@ApiOperation("获取一条记录")
|
||||
@GetMapping("/fetch/{id}")
|
||||
public ResultBean<SysUserVo> fetch(@PathVariable("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class SysUserFeignFallback implements SysUserFeign {
|
||||
|
||||
@Override
|
||||
public ResultBean<SysUserVo> fetch(String id){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
return rb.setMsg("接口anrui_portal/sysuser/fetch无法访问");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
|
||||
import com.yyd.base.common.query.Query;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SysUserQuery.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.sysuser.SysUserQuery <br/>
|
||||
* Description: 用户表 查询条件. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(value = "用户表 查询条件", description = "用户表 查询条件")
|
||||
@Data
|
||||
public class SysUserQuery implements Query {
|
||||
|
||||
|
||||
@ApiModelProperty("角色sid")
|
||||
private String roleSid;
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("密码(加密或签名后)")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户登录时随机生成身份验证字符串")
|
||||
private String token;
|
||||
@ApiModelProperty("用户登录时随机生成的验证码字符串")
|
||||
private String verifyCode;
|
||||
private String uuid;
|
||||
|
||||
@ApiModelProperty("手机登录唯一标识,手机与用户绑定字段")
|
||||
private String appId;
|
||||
@ApiModelProperty("手机登录类型:1、密码登录2、验证码登录")
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "用户表 视图数据对象", description = "用户表 视图数据对象")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SysUserVo implements Vo {
|
||||
@ApiModelProperty("部门sid")
|
||||
private String departmentSid;
|
||||
@ApiModelProperty("部门名称")
|
||||
private String departmentName;
|
||||
@ApiModelProperty("岗位名称")
|
||||
private String postName;
|
||||
@ApiModelProperty("岗位Sid")
|
||||
private String postSid;
|
||||
@ApiModelProperty("单位sid")
|
||||
private String organizationSid;
|
||||
@ApiModelProperty("单位名称")
|
||||
private String organizationName;
|
||||
@ApiModelProperty("用户姓名")
|
||||
private String name;
|
||||
@ApiModelProperty("登录名,登录名不能相同")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private Integer id;
|
||||
@ApiModelProperty("用户sid")
|
||||
private String sid;
|
||||
@ApiModelProperty("是否是管理员:1管理员,2一般用户,0是超级管理员,3尚无单位人员")
|
||||
private String isAdmin;
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
|
||||
@ApiModelProperty("关联的人员sid")
|
||||
private String staffSid;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("用户类型:1员工、2客户、3供应商")
|
||||
private String userType;
|
||||
@ApiModelProperty("用户类型:1、2、3")
|
||||
private String userTypeKey;
|
||||
@ApiModelProperty("用户头像")
|
||||
private String headImage;
|
||||
@ApiModelProperty(value = "token")
|
||||
private String token;
|
||||
@ApiModelProperty(value = "角色sids")
|
||||
private List<String> roleSids = new ArrayList<>();
|
||||
}
|
||||
252
yyd-demo/demo-biz/pom.xml
Normal file
252
yyd-demo/demo-biz/pom.xml
Normal file
@@ -0,0 +1,252 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-demo</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>demo-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-redis</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-handler</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>demo-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-jdbc</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dongliu</groupId>
|
||||
<artifactId>apk-parser</artifactId>
|
||||
<version>2.6.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--引入redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.axis</groupId>
|
||||
<artifactId>axis</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>axis</groupId>
|
||||
<artifactId>axis-jaxrpc</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-discovery/commons-discovery -->
|
||||
<dependency>
|
||||
<groupId>commons-discovery</groupId>
|
||||
<artifactId>commons-discovery</artifactId>
|
||||
<version>0.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j -->
|
||||
<dependency>
|
||||
<groupId>wsdl4j</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<version>1.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.73</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.14</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.6.Final</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--工具包-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*Mapper.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>-->
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yyd.demo;
|
||||
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = {
|
||||
"com.yyd.base",
|
||||
"com.yyd.base.redis",
|
||||
"com.yyd.demo.*"
|
||||
})
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {"com.yyd.demo.*","com.yyd.base.*"})
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yyd.demo.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* @author dimengzhe
|
||||
* @date 2020/9/9 16:42
|
||||
* @description
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableKnife4j
|
||||
public class Swagger2Config {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo()).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.yyd"))
|
||||
.paths(PathSelectors.any()).build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder().title("宇运动").description("门户建设接口").version("1.0")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Project: (门户建设) <br/>
|
||||
* File: SysUserMapper.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.sysuser.SysUserMapper <br/>
|
||||
* Description: 用户表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
IPage<SysUserVo> selectPageVo(IPage<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> ew);
|
||||
|
||||
List<SysUserVo> selectListAllVo(@Param(Constants.WRAPPER) Wrapper<SysUser> qw);
|
||||
|
||||
@Select("SELECT user.*,staff.name FROM sys_user user left join sys_staffinfo staff on user.staffSid=staff.sid where user.isDelete=0")
|
||||
List<SysUserVo> selectListVo();
|
||||
|
||||
public int updatePassword(String sid, String password);
|
||||
|
||||
public int updatePasswordApp(String sid, String password);
|
||||
|
||||
SysUser selectByUserName(String userName);
|
||||
|
||||
SysUser selectByUserNameApp(String userName);
|
||||
|
||||
SysUser selectByAppId(String appId);
|
||||
|
||||
@Update("UPDATE sys_user SET appId=#{appId} WHERE sid=#{sid} and userType=1")
|
||||
int updateAppId(@Param("sid") String sid, @Param("appId") String appId);
|
||||
|
||||
@Update("UPDATE sys_user SET token=#{token} WHERE sid=#{sid}")
|
||||
int updateToken(@Param("sid") String sid, @Param("token") String token);
|
||||
|
||||
SysUser fetchByMobile(String mobile);
|
||||
|
||||
void delBySid(String sid);
|
||||
|
||||
@Update("UPDATE sys_user SET headImage=#{headImage} WHERE sid=#{sid}")
|
||||
int updateHeadImage(@Param("sid") String sid, @Param("headImage") String headImage);
|
||||
|
||||
/**
|
||||
* @param mobile 手机号
|
||||
* @param userType 用户类型
|
||||
* @description: 根据手机号和用户类型查询客户是否存在
|
||||
* @return:
|
||||
* @Author: dimengzhe
|
||||
* @Date: 2021/10/6 11:35
|
||||
*/
|
||||
SysUser selectByMobileAndType(@Param("mobile") String mobile, @Param("userType") int userType);
|
||||
|
||||
|
||||
// @Select("SELECT * FROM sys_user WHERE staffSid=#{staffSid} and isDelete=0")
|
||||
SysUserVo selectByStaffsid(@Param("staffSid") String staffSid);
|
||||
|
||||
@Update("update sys_user set isDelete=1 where isDelete=0 and userType=2 and userName=#{mobile}")
|
||||
int delSysUserByMobile(@Param("mobile")String mobile);
|
||||
|
||||
@Select("select sid from sys_user")
|
||||
List<String> selectAllUserSid();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yyd.demo.sysuser.SysUserMapper">
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
<select id="selectPageVo" resultType="com.yyd.demo.sysuser.SysUserVo">
|
||||
SELECT DISTINCT user.staffSid,
|
||||
(
|
||||
SELECT GROUP_CONCAT(org.name)
|
||||
FROM sys_staff_org staffOrg
|
||||
LEFT JOIN sys_organization org ON org.sid = staffOrg.orgSid
|
||||
WHERE staffOrg.staffSid = user.staffSid
|
||||
) departmentName,
|
||||
(
|
||||
SELECT GROUP_CONCAT(org.sid)
|
||||
FROM sys_staff_org staffOrg
|
||||
LEFT JOIN sys_organization org ON org.sid = staffOrg.orgSid
|
||||
WHERE staffOrg.staffSid = user.staffSid
|
||||
) departmentSid,
|
||||
(
|
||||
SELECT GROUP_CONCAT(post.name)
|
||||
FROM sys_staff_post staffPost
|
||||
LEFT JOIN sys_post post ON post.sid = staffPost.postSid
|
||||
WHERE staffPost.staffSid = user.staffSid
|
||||
) postName,
|
||||
(
|
||||
SELECT GROUP_CONCAT(post.sid)
|
||||
FROM sys_staff_post staffPost
|
||||
LEFT JOIN sys_post post ON post.sid = staffPost.postSid
|
||||
WHERE staffPost.staffSid = user.staffSid
|
||||
) postSid,
|
||||
user.userName,
|
||||
user.sid sid,
|
||||
staff.name,
|
||||
(
|
||||
SELECT GROUP_CONCAT(role.name)
|
||||
FROM sys_user_role user_role
|
||||
LEFT JOIN sys_role role ON role.sid = user_role.roleSid
|
||||
WHERE user_role.userSid = USER.sid
|
||||
) roleName,
|
||||
dict.dictValue userType,
|
||||
user.userType userTypeKey
|
||||
FROM sys_user USER
|
||||
LEFT JOIN sys_user_role user_role ON user_role.userSid = USER.sid
|
||||
LEFT JOIN sys_role role ON role.sid = user_role.roleSid
|
||||
LEFT JOIN dict_common dict ON dict.dictKey = user.userType AND dict.dictType = 'userType'
|
||||
LEFT JOIN sys_staffinfo staff ON staff.sid = user.staffSid
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListAllVo" resultType="com.yyd.demo.sysuser.SysUserVo">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByUserName" resultType="com.yyd.demo.sysuser.SysUser">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
where userName = #{param1}
|
||||
and isDelete = 0
|
||||
</select>
|
||||
<select id="selectByUserNameApp" resultType="com.yyd.demo.sysuser.SysUser">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
where userName = #{param1}
|
||||
and isDelete = 0
|
||||
and userType = 1
|
||||
</select>
|
||||
<select id="selectByAppId" resultType="com.yyd.demo.sysuser.SysUser">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
where appId = #{appId}
|
||||
and isDelete = 0
|
||||
and userType = 1
|
||||
</select>
|
||||
<select id="fetchByMobile" resultType="com.yyd.demo.sysuser.SysUser">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
where mobile = #{param1}
|
||||
and isDelete = 0
|
||||
</select>
|
||||
<!--updatePassword-->
|
||||
<update id="updatePassword">
|
||||
update sys_user
|
||||
set password=#{param2}
|
||||
where sid = #{param1}
|
||||
</update>
|
||||
<update id="updatePasswordApp">
|
||||
update sys_user
|
||||
set password=#{param2}
|
||||
where sid = #{param1}
|
||||
and userType = 1
|
||||
</update>
|
||||
<delete id="delBySid">
|
||||
delete
|
||||
from sys_user
|
||||
where sid = #{param1}
|
||||
</delete>
|
||||
<!--根据手机号用户名和用户类型查询是否存在该用户-->
|
||||
<select id="selectByMobileAndType" resultType="com.yyd.demo.sysuser.SysUser">
|
||||
SELECT *
|
||||
FROM sys_user
|
||||
WHERE isDelete = 0
|
||||
AND userName = #{mobile}
|
||||
AND userType = #{userType}
|
||||
</select>
|
||||
|
||||
<select id="selectByStaffsid" resultType="com.yyd.demo.sysuser.SysUserVo">
|
||||
SELECT *
|
||||
FROM sys_user su
|
||||
LEFT JOIN sys_staffinfo ss ON su.staffSid = ss.sid
|
||||
WHERE su.staffSid = #{staffSid}
|
||||
AND su.isDelete = 0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.redis.RedisUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SysUserFeignFallback.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.sysuser.SysUserRest <br/>
|
||||
* Description: 用户表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Api(tags = "用户表")
|
||||
@RestController
|
||||
@RequestMapping("v1/sysuser")
|
||||
public class SysUserRest implements SysUserFeign {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserRest.class);
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
// 定义点选文字图片验证码允许的误差值
|
||||
private static final int ERROR_AMOUNT = 50;// 定义允许的误差值,单位是px
|
||||
|
||||
|
||||
@Override
|
||||
public ResultBean<SysUserVo> fetch(String id) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
// http://USER-SERVICE/user?name={name)
|
||||
/*Get请求之——getForEntity(Stringurl,Class responseType,Object…urlVariables)
|
||||
该方法提供了三个参数,其中url为请求的地址,responseType为请求响应body的包装类型,urlVariables为url中的参数绑定,该方法的参考调用如下:*/
|
||||
RestTemplate restTemplate=new RestTemplate();
|
||||
Map<String,String> params=new HashMap<>();
|
||||
params.put("name","dada"); //
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("token", "token");
|
||||
/*ResponseEntity<String> responseEntity=restTemplate.getForEntity("http://127.0.0.1:8112/demo/v1/sysuser/fetch/1",
|
||||
new HttpEntity<String>(headers),
|
||||
String.class,params);*/
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(
|
||||
"http://127.0.0.1:8112/demo2/v1/sysuser/fetch/1",
|
||||
HttpMethod.GET,
|
||||
new HttpEntity<String>(headers),
|
||||
String.class, params
|
||||
);
|
||||
/* Get请求之——getForEntity(URI url,Class responseType)
|
||||
该方法使用URI对象来替代之前的url和urlVariables参数来指定访问地址和参数绑定。URI是JDK http://java.net包下的一个类,表示一个统一资源标识符(Uniform Resource Identifier)引用。参考如下:*/
|
||||
/* UriComponents uriComponents= UriComponentsBuilder.fromUriString("http://127.0.0.1:8112/demo/v1/sysuser/fetch/1")
|
||||
.build()
|
||||
.expand("dodo")
|
||||
.encode();
|
||||
URI uri=uriComponents.toUri();
|
||||
String body = restTemplate.getForEntity(uri, String.class).getBody();
|
||||
*/
|
||||
/* Get请求之——getForObject
|
||||
getForObject方法可以理解为对getForEntity的进一步封装,它通过HttpMessageConverterExtractor对HTTP的请求响应体body内容进行对象转换,实现请求直接返回包装好的对象内容。getForObject方法有如下:
|
||||
*/
|
||||
/* getForObject(String url,Class responseType,Object...urlVariables)
|
||||
getForObject(String url,Class responseType,Map urlVariables)
|
||||
getForObject(URI url,Class responseType)*/
|
||||
|
||||
/* Post 请求
|
||||
Post请求提供有三种方法,postForEntity、postForObject和postForLocation。其中每种方法都存在三种方法,postForEntity方法使用如下:
|
||||
*/
|
||||
SysUser user=new SysUser();
|
||||
user.setMobile("15097321111");
|
||||
// responseEntity=restTemplate.postForEntity("http://127.0.0.1:8112/demo/v1/sysuser/save",user,String.class); //提交的body内容为user对象,请求的返回的body类型为String
|
||||
HttpEntity<String> formEntity = new HttpEntity<String>(JSON.toJSONString(user), headers);
|
||||
ResponseEntity<SysUser> exchange = restTemplate.exchange(
|
||||
"http://127.0.0.1:8112/demo2/v1/sysuser/save",
|
||||
HttpMethod.POST,
|
||||
new HttpEntity<String>(headers),
|
||||
SysUser.class,
|
||||
params
|
||||
);
|
||||
String body=responseEntity.getBody();
|
||||
|
||||
/*postForEntity存在如下三种方法的重载
|
||||
postForEntity(String url,Object request,Class responseType,Object... uriVariables)
|
||||
postForEntity(String url,Object request,Class responseType,Map uriVariables)
|
||||
postForEntity(URI url,Object request,Class responseType)*/
|
||||
|
||||
SysUserVo vo = sysUserService.fetchByIdVo(id);
|
||||
return rb.success().setData(vo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.yyd.demo.sysuser;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.utils.PagerUtil;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.jdbc.service.MybatisBaseService;
|
||||
import com.yyd.base.redis.RedisUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.util.concurrent.Executors.newScheduledThreadPool;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SysUserService.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.sysuser.SysUserService <br/>
|
||||
* Description: 用户表 业务逻辑. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysUserService extends MybatisBaseService<SysUserMapper, SysUser> {
|
||||
|
||||
/**
|
||||
* 设置redis的过期时间为4小时
|
||||
*/
|
||||
public static final long USERS_REDIS_SESSION_TL_PC = 4 * 3600;
|
||||
public static final long USERS_REDIS_SESSION_TL_App = 24 * 15 * 3600;
|
||||
/**
|
||||
* 验证码长度
|
||||
*/
|
||||
static final int LENGTH_OF_CODE = 4;
|
||||
/**
|
||||
* 调用发送短信接口返回值
|
||||
*/
|
||||
static final String RESULT_CODE = "1";
|
||||
/**
|
||||
* 手机短信登录验证码时效(秒)
|
||||
*/
|
||||
static final long APP_LOGIN_CODE_TIME_LIMIT = 300L;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
public PagerVo<SysUser> listPage(PagerQuery<SysUserQuery> pq) {
|
||||
SysUserQuery query = pq.getParams();
|
||||
QueryWrapper<SysUser> qw = createQueryWrapper(query);
|
||||
IPage<SysUser> page = PagerUtil.queryToPage(pq);
|
||||
IPage<SysUser> pagging = baseMapper.selectPage(page, qw);
|
||||
PagerVo<SysUser> p = PagerUtil.pageToVo(pagging, null);
|
||||
return p;
|
||||
}
|
||||
|
||||
public List<SysUser> listAll(SysUserQuery query) {
|
||||
QueryWrapper<SysUser> qw = createQueryWrapper(query);
|
||||
return baseMapper.selectList(qw);
|
||||
}
|
||||
|
||||
private QueryWrapper<SysUser> createQueryWrapper(SysUserQuery query) {
|
||||
// todo: 这里根据具体业务调整查询条件
|
||||
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
||||
QueryWrapper<SysUser> qw = new QueryWrapper<>();
|
||||
|
||||
if (StringUtils.isNotBlank(query.getUserName())) {
|
||||
qw.like("user.userName", query.getUserName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(query.getRoleSid())) {
|
||||
qw.eq("role.sid", query.getRoleSid());
|
||||
}
|
||||
|
||||
return qw;
|
||||
}
|
||||
|
||||
public PagerVo<SysUserVo> listPageVo(PagerQuery<SysUserQuery> pq) {
|
||||
SysUserQuery query = pq.getParams();
|
||||
QueryWrapper<SysUser> qw = createQueryWrapper(query);
|
||||
IPage<SysUser> page = PagerUtil.queryToPage(pq);
|
||||
IPage<SysUserVo> pagging = baseMapper.selectPageVo(page, qw);
|
||||
PagerVo<SysUserVo> p = PagerUtil.pageToVo(pagging, null);
|
||||
return p;
|
||||
}
|
||||
|
||||
public List<SysUserVo> listAllVo(SysUserQuery query) {
|
||||
QueryWrapper<SysUser> qw = createQueryWrapper(query);
|
||||
return baseMapper.selectListAllVo(qw);
|
||||
}
|
||||
|
||||
public List<SysUserVo> listVo() {
|
||||
return baseMapper.selectListVo();
|
||||
}
|
||||
|
||||
|
||||
public SysUserVo fetchByIdVo(String id) {
|
||||
SysUser entity = this.fetchById(id);
|
||||
SysUserVo vo = new SysUserVo();
|
||||
BeanUtil.copyProperties(entity, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public SysUserVo fetchBySidVo(String sid) {
|
||||
SysUser entity = this.fetchBySid(sid);
|
||||
String staffSid = entity.getStaffSid();
|
||||
SysUserVo vo = new SysUserVo();
|
||||
BeanUtil.copyProperties(entity, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
public int updatePassword(String sid, String password) {
|
||||
return baseMapper.updatePassword(sid, password);
|
||||
}
|
||||
|
||||
|
||||
public SysUser selectByUserName(String userName) {
|
||||
return baseMapper.selectByUserName(userName);
|
||||
}
|
||||
|
||||
public SysUser selectByUserNameApp(String userName) {
|
||||
return baseMapper.selectByUserNameApp(userName);
|
||||
}
|
||||
|
||||
public SysUser selectByAppId(String appId) {
|
||||
return baseMapper.selectByAppId(appId);
|
||||
}
|
||||
|
||||
public int updateAppId(String sid, String appId) {
|
||||
return baseMapper.updateAppId(sid, appId);
|
||||
}
|
||||
|
||||
public int updateToken(String sid, String token) {
|
||||
return baseMapper.updateToken(sid, token);
|
||||
}
|
||||
|
||||
public SysUser fetchByMobile(String mobile) {
|
||||
SysUser sysUsers = baseMapper.fetchByMobile(mobile);
|
||||
return sysUsers;
|
||||
}
|
||||
|
||||
public void delBySid(String sid) {
|
||||
baseMapper.delBySid(sid);
|
||||
}
|
||||
|
||||
}
|
||||
32
yyd-demo/demo-biz/src/main/resources/application-devv.yml
Normal file
32
yyd-demo/demo-biz/src/main/resources/application-devv.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: root
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
|
||||
image:
|
||||
upload:
|
||||
path: D:\\anrui\\upload\\
|
||||
url:
|
||||
prefix: http://127.0.0.1:7003/upload/
|
||||
login:
|
||||
path: D:\\images\\pic-click
|
||||
|
||||
|
||||
30
yyd-demo/demo-biz/src/main/resources/application-pro.yml
Normal file
30
yyd-demo/demo-biz/src/main/resources/application-pro.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
|
||||
username: root
|
||||
password: root
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
|
||||
image:
|
||||
upload:
|
||||
path: D:\anrui\upload\
|
||||
url:
|
||||
prefix: http://120.46.131.15:8111/upload/
|
||||
login:
|
||||
path: D:\images\pic-click
|
||||
30
yyd-demo/demo-biz/src/main/resources/application-test.yml
Normal file
30
yyd-demo/demo-biz/src/main/resources/application-test.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: root
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password:
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
image:
|
||||
upload:
|
||||
path: D:\\anrui\\upload\\
|
||||
url:
|
||||
prefix: http://127.0.0.1:7003/upload/
|
||||
login:
|
||||
path: D:\\images\\pic-click
|
||||
|
||||
47
yyd-demo/demo-biz/src/main/resources/application.yml
Normal file
47
yyd-demo/demo-biz/src/main/resources/application.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
spring:
|
||||
application:
|
||||
name: yyd-demo
|
||||
profiles:
|
||||
active: devv
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
servlet:
|
||||
#上传文件
|
||||
multipart:
|
||||
max-file-size: 50MB
|
||||
max-request-size: 100MB
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
mvc:
|
||||
async:
|
||||
request-timeout: 20000
|
||||
|
||||
server:
|
||||
port: 7003
|
||||
max-http-header-size: 102400
|
||||
undertow:
|
||||
max-http-post-size: -1
|
||||
#mybatis
|
||||
mybatis-plus:
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapper-locations: classpath*:**Mapper.xml
|
||||
global-config:
|
||||
refresh: true
|
||||
db-config:
|
||||
#定义生成ID的类型
|
||||
id-type: Auto
|
||||
db-type: mysql
|
||||
configuration:
|
||||
map-underscore-to-camel-case: false
|
||||
cache-enabled: true
|
||||
call-setters-on-nulls: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
logging:
|
||||
config: classpath:log4j.xml
|
||||
|
||||
|
||||
|
||||
|
||||
41
yyd-demo/demo-biz/src/main/resources/log4j.xml
Normal file
41
yyd-demo/demo-biz/src/main/resources/log4j.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,
|
||||
你会看到log4j2内部各种详细输出。可以设置成OFF(关闭)或Error(只输出错误信息) -->
|
||||
<Configuration status="OFF">
|
||||
<Properties>
|
||||
<!-- 配置日志文件输出目录 -->
|
||||
<Property name="log_path" value="log/" />
|
||||
<Property name="file_name">log</Property>
|
||||
<Property name="kafka_log_topic">kafka_log_topic</Property>
|
||||
<Property name="bootstrap_servers">localhost:9092</Property>
|
||||
</Properties>
|
||||
|
||||
<Appenders>
|
||||
<!-- 输出控制台日志的配置 -->
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
|
||||
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
|
||||
<!-- 输出日志的格式 -->
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
<File name="log_file" fileName="${log_path}/${file_name}.log" append="true" immediateFlush="true">
|
||||
<PatternLayout pattern="%d{yy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</File>
|
||||
<Kafka name="kafka" topic="${kafka_log_topic}">
|
||||
<!--<PatternLayout pattern="%date %message"/>-->
|
||||
<Property name="bootstrap.servers">${bootstrap_servers}</Property>
|
||||
<!--json格式输出-->
|
||||
<JsonLayout compact="true" locationInfo="true" complete="false" eventEol="true"/>
|
||||
</Kafka>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="kafka"/>
|
||||
<AppenderRef ref="console"/>
|
||||
<AppenderRef ref="log_file"/>
|
||||
</Root>
|
||||
<!-- <Logger name="org.apache.kafka" level="INFO" />--> <!-- avoid recursive logging -->
|
||||
<logger name="org.springframework" level="INFO"/>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
19
yyd-demo/pom.xml
Normal file
19
yyd-demo/pom.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>demo-api</module>
|
||||
<module>demo-biz</module>
|
||||
</modules>
|
||||
<artifactId>yyd-demo</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
17
yyd-log/pom.xml
Normal file
17
yyd-log/pom.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ttvictory</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>yyd-log</artifactId>
|
||||
<modules>
|
||||
<module>yyd-log-api</module>
|
||||
<module>yyd-log-biz</module>
|
||||
</modules>
|
||||
</project>
|
||||
46
yyd-log/yyd-log-api/pom.xml
Normal file
46
yyd-log/yyd-log-api/pom.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-log</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-log-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yyd.base.common.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLog.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLog <br/>
|
||||
* Description: 系统日志表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(value = "系统日志表", description = "系统日志表")
|
||||
@TableName("system_log")
|
||||
@Data
|
||||
public class SystemLog extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("事件名称或类别")
|
||||
private String eventName;
|
||||
|
||||
@ApiModelProperty("事件内容")
|
||||
private String eventContent;
|
||||
|
||||
@ApiModelProperty("事件url")
|
||||
private String eventUrl;
|
||||
|
||||
@ApiModelProperty("用户sid")
|
||||
private String userSid;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户iP")
|
||||
private String userIp;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
|
||||
import com.yyd.base.common.dto.Dto;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogDto.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLogDto <br/>
|
||||
* Description: 系统日志表 数据传输对象. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Builder
|
||||
@ApiModel(value = "系统日志表 数据传输对象", description = "系统日志表 数据传输对象")
|
||||
@Data
|
||||
public class SystemLogDto implements Dto {
|
||||
|
||||
|
||||
@ApiModelProperty("事件名称或类别")
|
||||
private String eventName;
|
||||
|
||||
@ApiModelProperty("事件内容")
|
||||
private String eventContent;
|
||||
|
||||
@ApiModelProperty("事件url")
|
||||
private String eventUrl;
|
||||
|
||||
@ApiModelProperty("用户sid")
|
||||
private String userSid;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户iP")
|
||||
private String userIp;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogFeign.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLogFeign <br/>
|
||||
* Description: 系统日志表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Api(tags = "系统日志表")
|
||||
@FeignClient(
|
||||
contextId = "yyd-log",
|
||||
name = "yyd-log",
|
||||
path = "v1/systemlog",
|
||||
fallback = SystemLogFeignFallback.class)
|
||||
public interface SystemLogFeign {
|
||||
|
||||
@ApiOperation("根据条件分页查询数据的列表")
|
||||
@PostMapping("/listPage")
|
||||
public ResultBean<PagerVo<SystemLogVo>> listPage(@RequestBody PagerQuery<SystemLogQuery> pq);
|
||||
|
||||
@ApiOperation("根据条件查询所有数据列表")
|
||||
@PostMapping("/listAll")
|
||||
public ResultBean<List<SystemLogVo>> listAll(@RequestBody SystemLogQuery query);
|
||||
|
||||
@ApiOperation("所有数据列表")
|
||||
@GetMapping("/list")
|
||||
public ResultBean<List<SystemLogVo>> list();
|
||||
|
||||
@ApiOperation("新增保存")
|
||||
@PostMapping("/save")
|
||||
public ResultBean save(@RequestBody SystemLogDto dto);
|
||||
|
||||
@ApiOperation("修改保存")
|
||||
@PostMapping("/update/{sid}")
|
||||
public ResultBean update(@RequestBody SystemLogDto dto,@PathVariable("sid") String sid);
|
||||
|
||||
@ApiOperation("删除记录")
|
||||
@GetMapping("/del/{ids}")
|
||||
public ResultBean del(@PathVariable("ids") String ids);
|
||||
|
||||
@ApiOperation("获取一条记录")
|
||||
@GetMapping("/fetch/{id}")
|
||||
public ResultBean<SystemLogVo> fetch(@PathVariable("id") String id);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogFeignFallback.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLogFeignFallback <br/>
|
||||
* Description: 系统日志表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
public class SystemLogFeignFallback implements SystemLogFeign {
|
||||
|
||||
@Override
|
||||
public ResultBean<PagerVo<SystemLogVo>> listPage(PagerQuery<SystemLogQuery> pq){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
return rb.setMsg("接口anrui_portal/systemlog/listPage无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<List<SystemLogVo>> listAll(SystemLogQuery query){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
return rb.setMsg("接口anrui_portal/systemlog/listAll无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<List<SystemLogVo>> list(){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
return rb.setMsg("接口anrui_portal/systemlog/list无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean save(SystemLogDto dto){
|
||||
return ResultBean.fireFail().setMsg("接口anrui_portal/systemlog/save无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean update(SystemLogDto dto, String sid){
|
||||
return ResultBean.fireFail().setMsg("接口anrui_portal/systemlog/update无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean del(String ids){
|
||||
return ResultBean.fireFail().setMsg("接口anrui_portal/systemlog/del无法访问");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<SystemLogVo> fetch(String id){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
return rb.setMsg("接口anrui_portal/systemlog/fetch无法访问");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
|
||||
import com.yyd.base.common.query.Query;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogQuery.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLogQuery <br/>
|
||||
* Description: 系统日志表 查询条件. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(value = "系统日志表 查询条件", description = "系统日志表 查询条件")
|
||||
@Data
|
||||
public class SystemLogQuery implements Query {
|
||||
|
||||
|
||||
@ApiModelProperty("事件名称或类别")
|
||||
private String eventName;
|
||||
|
||||
@ApiModelProperty("事件内容")
|
||||
private String eventContent;
|
||||
|
||||
@ApiModelProperty("事件url")
|
||||
private String eventUrl;
|
||||
|
||||
@ApiModelProperty("用户sid")
|
||||
private String userSid;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户iP")
|
||||
private String userIp;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yyd.log.api;
|
||||
|
||||
|
||||
import com.yyd.base.common.vo.Vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogVo.java <br/>
|
||||
* Class: com.yxt.anrui.portal.api.systemlog.SystemLogVo <br/>
|
||||
* Description: 系统日志表 视图数据对象. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel(value = "系统日志表 视图数据对象", description = "系统日志表 视图数据对象")
|
||||
@Data
|
||||
public class SystemLogVo implements Vo {
|
||||
|
||||
|
||||
@ApiModelProperty("事件名称或类别")
|
||||
private String eventName;
|
||||
|
||||
@ApiModelProperty("事件内容")
|
||||
private String eventContent;
|
||||
|
||||
@ApiModelProperty("事件url")
|
||||
private String eventUrl;
|
||||
|
||||
@ApiModelProperty("用户sid")
|
||||
private String userSid;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("用户iP")
|
||||
private String userIp;
|
||||
}
|
||||
80
yyd-log/yyd-log-biz/pom.xml
Normal file
80
yyd-log/yyd-log-biz/pom.xml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yyd-log</artifactId>
|
||||
<groupId>com.yyd</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yyd-log-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-common</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-base-jdbc</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!--mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dongliu</groupId>
|
||||
<artifactId>apk-parser</artifactId>
|
||||
<version>2.6.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yyd</groupId>
|
||||
<artifactId>yyd-log-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yyd.log;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {
|
||||
"com.yyd.log.*"
|
||||
})
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {"com.yyd.log.*","com.yyd.base.*"})
|
||||
public class LogApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LogApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yyd.log.biz;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yyd.log.api.SystemLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.kafka.support.Acknowledgment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* KafkaConsumerService
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class KafkaConsumerService {
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
@KafkaListener(groupId = "group02", topics = "kafka_log_topic")
|
||||
public void onMessage(ConsumerRecord<String, Object> record, Acknowledgment acknowledgment, Consumer<?, ?> consumer) {
|
||||
// log.info("消费端接收消息: {}", record.value());
|
||||
JSONObject jsonObject = JSONObject.parseObject( record.value().toString());
|
||||
JSONObject message=null;
|
||||
try{
|
||||
message = JSONObject.parseObject(jsonObject.get("message").toString());
|
||||
SystemLog log=new SystemLog();
|
||||
if(message.get("routeId")!=null){
|
||||
log.setEventName(message.get("routeId").toString());
|
||||
}else {
|
||||
log.setEventName("");
|
||||
}
|
||||
/* log.setEventContent(jsonObject.get("heads").toString());*/
|
||||
if(message.get("params")!=null){
|
||||
log.setEventContent(message.get("params").toString());
|
||||
}else{
|
||||
log.setEventContent("");
|
||||
}
|
||||
if(message.get("uri")!=null){
|
||||
log.setEventUrl(message.get("uri").toString());
|
||||
}else{
|
||||
log.setEventUrl("");
|
||||
}
|
||||
if(message.get("userName")!=null){
|
||||
|
||||
log.setUserName(message.get("userName").toString());
|
||||
}else{
|
||||
log.setUserName("");
|
||||
|
||||
}
|
||||
if(message.get("ip")!=null){
|
||||
|
||||
log.setUserIp(message.get("ip").toString());
|
||||
}else{
|
||||
log.setUserIp("");
|
||||
}
|
||||
systemLogService.save(log);
|
||||
}catch (Exception e){
|
||||
message=new JSONObject();
|
||||
}
|
||||
// 手工签收机制
|
||||
acknowledgment.acknowledge();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yyd.log.biz;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.yyd.log.api.SystemLog;
|
||||
import com.yyd.log.api.SystemLogVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogMapper.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.systemlog.SystemLogMapper <br/>
|
||||
* Description: 系统日志表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemLogMapper extends BaseMapper<SystemLog> {
|
||||
|
||||
//@Update("update system_log set name=#{msg} where id=#{id}")
|
||||
//IPage<SystemLogVo> voPage(IPage<SystemLog> page, @Param(Constants.WRAPPER) QueryWrapper<SystemLog> qw);
|
||||
|
||||
IPage<SystemLogVo> selectPageVo(IPage<SystemLog> page, @Param(Constants.WRAPPER) Wrapper<SystemLog> qw);
|
||||
|
||||
List<SystemLogVo> selectListAllVo(@Param(Constants.WRAPPER) Wrapper<SystemLog> qw);
|
||||
|
||||
@Select("select * from system_log")
|
||||
List<SystemLogVo> selectListVo();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yyd.log.consumer.systemlog.biz.SystemLogMapper">
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
<select id="selectPageVo" resultType="com.yyd.log.consumer.systemlog.api.SystemLogVo">
|
||||
SELECT * FROM system_log <where> ${ew.sqlSegment} </where>
|
||||
</select>
|
||||
|
||||
<select id="selectListAllVo" resultType="com.yyd.log.consumer.systemlog.api.SystemLogVo">
|
||||
SELECT * FROM system_log <where> ${ew.sqlSegment} </where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.yyd.log.biz;
|
||||
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.result.ResultBean;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.log.api.SystemLogDto;
|
||||
import com.yyd.log.api.SystemLogFeign;
|
||||
import com.yyd.log.api.SystemLogQuery;
|
||||
import com.yyd.log.api.SystemLogVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogFeignFallback.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.systemlog.SystemLogRest <br/>
|
||||
* Description: 系统日志表. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Api(tags = "系统日志表")
|
||||
@RestController
|
||||
@RequestMapping("v1/systemlog")
|
||||
public class SystemLogRest implements SystemLogFeign {
|
||||
|
||||
@Resource
|
||||
private SystemLogService systemLogService;
|
||||
|
||||
@Override
|
||||
public ResultBean<PagerVo<SystemLogVo>> listPage(@RequestBody PagerQuery<SystemLogQuery> pq){
|
||||
/*SystemLogDto systemLogDto = SystemLogDto.builder()
|
||||
.userIp(WebUtil.getIp())
|
||||
.eventContent("日志列表查询")
|
||||
.eventName("日志列表查询")
|
||||
.eventUrl("/v1/systemlog/listPage")
|
||||
.userName("")
|
||||
.userSid("")
|
||||
.build();*/
|
||||
/*systemLogService.saveOrUpdateDto(systemLogDto);*/
|
||||
/* SystemLog log=new SystemLog();
|
||||
log.setEventName("日志列表查询");
|
||||
log.setEventContent("日志列表查询");
|
||||
log.setUserName("");
|
||||
log.setUserIp("0.0.0.0");
|
||||
systemLogService.save(log);*/
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
PagerVo<SystemLogVo> pv = systemLogService.listPageVo(pq);
|
||||
return rb.success().setData(pv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<List<SystemLogVo>> listAll(@RequestBody SystemLogQuery query){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
List<SystemLogVo> list = systemLogService.listAllVo(query);
|
||||
return rb.success().setData(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<List<SystemLogVo>> list(){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
List<SystemLogVo> list = systemLogService.listVo();
|
||||
return rb.success().setData(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean save(SystemLogDto dto){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
systemLogService.saveOrUpdateDto(dto);
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean update(SystemLogDto dto,String sid){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
systemLogService.updateBySid(dto.toMap(),sid);
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean del(String ids){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
systemLogService.delByIds(ids);
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultBean<SystemLogVo> fetch(String id){
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
SystemLogVo vo = systemLogService.fetchByIdVo(id);
|
||||
return rb.success().setData(vo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.yyd.log.biz;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yyd.base.common.query.PagerQuery;
|
||||
import com.yyd.base.common.utils.PagerUtil;
|
||||
import com.yyd.base.common.vo.PagerVo;
|
||||
import com.yyd.base.jdbc.service.MybatisBaseService;
|
||||
import com.yyd.log.api.SystemLog;
|
||||
import com.yyd.log.api.SystemLogDto;
|
||||
import com.yyd.log.api.SystemLogQuery;
|
||||
import com.yyd.log.api.SystemLogVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Project: anrui_portal(门户建设) <br/>
|
||||
* File: SystemLogService.java <br/>
|
||||
* Class: com.yxt.anrui.portal.biz.systemlog.SystemLogService <br/>
|
||||
* Description: 系统日志表 业务逻辑. <br/>
|
||||
* Copyright: Copyright (c) 2011 <br/>
|
||||
* Company: https://gitee.com/liuzp315 <br/>
|
||||
* Makedate: 2021-08-03 00:24:30 <br/>
|
||||
*
|
||||
* @author liupopo
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@Service
|
||||
public class SystemLogService extends MybatisBaseService<SystemLogMapper, SystemLog> {
|
||||
public PagerVo<SystemLog> listPage(PagerQuery<SystemLogQuery> pq) {
|
||||
SystemLogQuery query = pq.getParams();
|
||||
QueryWrapper<SystemLog> qw = createQueryWrapper(query);
|
||||
IPage<SystemLog> page = PagerUtil.queryToPage(pq);
|
||||
IPage<SystemLog> pagging = baseMapper.selectPage(page, qw);
|
||||
PagerVo<SystemLog> p = PagerUtil.pageToVo(pagging, null);
|
||||
return p;
|
||||
}
|
||||
public List<SystemLog> listAll(SystemLogQuery query) {
|
||||
QueryWrapper<SystemLog> qw = createQueryWrapper(query);
|
||||
return baseMapper.selectList(qw);
|
||||
}
|
||||
private QueryWrapper<SystemLog> createQueryWrapper(SystemLogQuery query) {
|
||||
// todo: 这里根据具体业务调整查询条件
|
||||
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
||||
QueryWrapper<SystemLog> qw = new QueryWrapper<>();
|
||||
|
||||
|
||||
if (StringUtils.isNotBlank(query.getEventName())) {
|
||||
qw.eq("eventName", query.getEventName());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(query.getEventContent())) {
|
||||
qw.eq("eventContent", query.getEventContent());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(query.getEventUrl())) {
|
||||
qw.eq("eventUrl", query.getEventUrl());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(query.getUserSid())) {
|
||||
qw.eq("userSid", query.getUserSid());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(query.getUserName())) {
|
||||
qw.eq("userName", query.getUserName());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(query.getUserIp())) {
|
||||
qw.eq("userIp", query.getUserIp());
|
||||
}
|
||||
return qw;
|
||||
}
|
||||
|
||||
public PagerVo<SystemLogVo> listPageVo(PagerQuery<SystemLogQuery> pq) {
|
||||
SystemLogQuery query = pq.getParams();
|
||||
QueryWrapper<SystemLog> qw = createQueryWrapper(query);
|
||||
IPage<SystemLog> page = PagerUtil.queryToPage(pq);
|
||||
IPage<SystemLogVo> pagging = baseMapper.selectPageVo(page, qw);
|
||||
PagerVo<SystemLogVo> p = PagerUtil.pageToVo(pagging, null);
|
||||
return p;
|
||||
}
|
||||
|
||||
public List<SystemLogVo> listAllVo(SystemLogQuery query) {
|
||||
QueryWrapper<SystemLog> qw = createQueryWrapper(query);
|
||||
return baseMapper.selectListAllVo(qw);
|
||||
}
|
||||
|
||||
public List<SystemLogVo> listVo() {
|
||||
return baseMapper.selectListVo();
|
||||
}
|
||||
|
||||
public void saveOrUpdateDto(SystemLogDto dto){
|
||||
SystemLog entity = new SystemLog();
|
||||
dto.fillEntity(entity);
|
||||
this.saveOrUpdate(entity);
|
||||
}
|
||||
|
||||
public SystemLogVo fetchByIdVo(String id){
|
||||
SystemLog entity = this.fetchById(id);
|
||||
SystemLogVo vo = new SystemLogVo();
|
||||
BeanUtil.copyProperties(entity, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
32
yyd-log/yyd-log-biz/src/main/resources/application-devv.yml
Normal file
32
yyd-log/yyd-log-biz/src/main/resources/application-devv.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/anrui_portal?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: root
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
|
||||
image:
|
||||
upload:
|
||||
path: D:\\anrui\\upload\\
|
||||
url:
|
||||
prefix: http://127.0.0.1:7003/upload/
|
||||
login:
|
||||
path: D:\\images\\pic-click
|
||||
|
||||
|
||||
30
yyd-log/yyd-log-biz/src/main/resources/application-pro.yml
Normal file
30
yyd-log/yyd-log-biz/src/main/resources/application-pro.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://120.46.131.15:3306/anrui_portal?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
|
||||
username: root
|
||||
password: anrui_@root
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password: 123456
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
|
||||
image:
|
||||
upload:
|
||||
path: D:\anrui\upload\
|
||||
url:
|
||||
prefix: http://120.46.131.15:8111/upload/
|
||||
login:
|
||||
path: D:\images\pic-click
|
||||
30
yyd-log/yyd-log-biz/src/main/resources/application-test.yml
Normal file
30
yyd-log/yyd-log-biz/src/main/resources/application-test.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://39.104.142.192:3306/anrui_portal?serverTimezone=GMT%2B8&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123456
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
redis:
|
||||
database: 3 # Redis数据库索引(默认为0)
|
||||
host: 127.0.0.1
|
||||
jedis:
|
||||
pool:
|
||||
max-active: -1 #连接池最大连接数(使用负值表示没有限制)
|
||||
max-idle: 8 #连接池中的最大空闲连接
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
password:
|
||||
port: 6379
|
||||
timeout: 0 # 连接超时时间(毫秒)
|
||||
image:
|
||||
upload:
|
||||
path: D:\\anrui\\upload\\
|
||||
url:
|
||||
prefix: http://127.0.0.1:7003/upload/
|
||||
login:
|
||||
path: D:\\images\\pic-click
|
||||
|
||||
55
yyd-log/yyd-log-biz/src/main/resources/application.yml
Normal file
55
yyd-log/yyd-log-biz/src/main/resources/application.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
spring:
|
||||
application:
|
||||
name: yyd-log
|
||||
profiles:
|
||||
active: devv
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
servlet:
|
||||
#上传文件
|
||||
multipart:
|
||||
max-file-size: 50MB
|
||||
max-request-size: 100MB
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
mvc:
|
||||
async:
|
||||
request-timeout: 20000
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092
|
||||
listener:
|
||||
missing-topics-fatal: false
|
||||
ack-mode: manual
|
||||
concurrency: 5
|
||||
consumer:
|
||||
enable-auto-commit: false
|
||||
auto-offset-reset: earliest
|
||||
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||
server:
|
||||
port: 8002
|
||||
servlet:
|
||||
context-path: /consumser
|
||||
max-http-header-size: 102400
|
||||
undertow:
|
||||
max-http-post-size: -1
|
||||
#mybatis
|
||||
mybatis-plus:
|
||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||
mapper-locations: classpath*:**Mapper.xml
|
||||
global-config:
|
||||
refresh: true
|
||||
db-config:
|
||||
#定义生成ID的类型
|
||||
id-type: Auto
|
||||
db-type: mysql
|
||||
configuration:
|
||||
map-underscore-to-camel-case: false
|
||||
cache-enabled: true
|
||||
call-setters-on-nulls: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
50
yyd-log/yyd-log-biz/src/main/resources/logback-spring.xml
Normal file
50
yyd-log/yyd-log-biz/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<property name="log.base" value="logs/yyd-demo" />
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 :
|
||||
|%blue(%thread) 线程 如 :DiscoveryClient-CacheRefreshExecutor-0-->
|
||||
<!--<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>-->
|
||||
<pattern>%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%green(%logger:%line) |%blue(%msg%n)
|
||||
</pattern>
|
||||
<!--<charset>UTF-8</charset> -->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 彩色日志 -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<appender name="FILEOUT"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.base}.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.base}.%d{yyyyMMdd}.%i.log.zip
|
||||
</fileNamePattern>
|
||||
<!-- 当文件大小超过10MB时触发滚动 -->
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>1MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<!--<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>-->
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}
|
||||
-%msg%n</Pattern>
|
||||
<!--<charset>UTF-8</charset> -->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILEOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user