7.10 DDD工程初始化+微信公众号鉴权
This commit is contained in:
commit
f1119a54a2
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
/data/
|
||||||
|
/.idea/
|
20
docs/dev-ops/app/start.sh
Normal file
20
docs/dev-ops/app/start.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
CONTAINER_NAME=pay-mall
|
||||||
|
IMAGE_NAME=system/pay-mall:1.0-SNAPSHOT
|
||||||
|
PORT=8091
|
||||||
|
|
||||||
|
echo "容器部署开始 ${CONTAINER_NAME}"
|
||||||
|
|
||||||
|
# 停止容器
|
||||||
|
docker stop ${CONTAINER_NAME}
|
||||||
|
|
||||||
|
# 删除容器
|
||||||
|
docker rm ${CONTAINER_NAME}
|
||||||
|
|
||||||
|
# 启动容器
|
||||||
|
docker run --name ${CONTAINER_NAME} \
|
||||||
|
-p ${PORT}:${PORT} \
|
||||||
|
-d ${IMAGE_NAME}
|
||||||
|
|
||||||
|
echo "容器部署成功 ${CONTAINER_NAME}"
|
||||||
|
|
||||||
|
docker logs -f ${CONTAINER_NAME}
|
1
docs/dev-ops/app/stop.sh
Normal file
1
docs/dev-ops/app/stop.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
docker stop pay-mall
|
27
docs/dev-ops/docker-compose-app.yml
Normal file
27
docs/dev-ops/docker-compose-app.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# /usr/local/bin/docker-compose -f /docs/dev-ops/environment/environment-docker-compose-2.4.yml up -d
|
||||||
|
version: '3.8'
|
||||||
|
# docker-compose -f docker-compose-app.yml up -d
|
||||||
|
# 你需要修改system为你自身系统的仓库名
|
||||||
|
services:
|
||||||
|
pay-mall:
|
||||||
|
image: system/pay-mall:1.0-SNAPSHOT
|
||||||
|
container_name: pay-mall
|
||||||
|
restart: on-failure
|
||||||
|
ports:
|
||||||
|
- "8092:8092"
|
||||||
|
environment:
|
||||||
|
- TZ=PRC
|
||||||
|
- SERVER_PORT=8091
|
||||||
|
volumes:
|
||||||
|
- ./log:/data/log
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
my-network:
|
||||||
|
driver: bridge
|
87
docs/dev-ops/docker-compose-environment-aliyun.yml
Normal file
87
docs/dev-ops/docker-compose-environment-aliyun.yml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
# 命令执行 docker-compose -f docker-compose-environment-aliyun.yml up -d
|
||||||
|
# docker 代理和使用文档;https://bugstack.cn/md/road-map/docker.html
|
||||||
|
version: '3.9'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/mysql:8.0.32
|
||||||
|
container_name: mysql
|
||||||
|
command: --default-authentication-plugin=mysql_native_password
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
MYSQL_ROOT_PASSWORD: 123456
|
||||||
|
ports:
|
||||||
|
- "13306:3306"
|
||||||
|
volumes:
|
||||||
|
- ./mysql/sql:/docker-entrypoint-initdb.d
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
start_period: 15s
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
|
||||||
|
# phpmyadmin https://hub.docker.com/_/phpmyadmin
|
||||||
|
phpmyadmin:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/phpmyadmin:5.2.1
|
||||||
|
container_name: phpmyadmin
|
||||||
|
hostname: phpmyadmin
|
||||||
|
ports:
|
||||||
|
- 8899:80
|
||||||
|
environment:
|
||||||
|
- PMA_HOST=mysql
|
||||||
|
- PMA_PORT=3306
|
||||||
|
- MYSQL_ROOT_PASSWORD=123qwe!@#QWE
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
redis:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/redis:6.2
|
||||||
|
container_name: redis
|
||||||
|
restart: always
|
||||||
|
hostname: redis
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 16379:6379
|
||||||
|
volumes:
|
||||||
|
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
|
||||||
|
command: redis-server /usr/local/etc/redis/redis.conf
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "redis-cli", "ping" ]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
# RedisAdmin https://github.com/joeferner/redis-commander
|
||||||
|
# 账密 admin/admin
|
||||||
|
redis-admin:
|
||||||
|
image: registry.cn-hangzhou.aliyuncs.com/xfg-studio/redis-commander:0.8.0
|
||||||
|
container_name: redis-admin
|
||||||
|
hostname: redis-commander
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
environment:
|
||||||
|
- REDIS_HOSTS=local:redis:6379
|
||||||
|
- HTTP_USER=admin
|
||||||
|
- HTTP_PASSWORD=admin
|
||||||
|
- LANG=C.UTF-8
|
||||||
|
- LANGUAGE=C.UTF-8
|
||||||
|
- LC_ALL=C.UTF-8
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
depends_on:
|
||||||
|
redis:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
my-network:
|
||||||
|
driver: bridge
|
86
docs/dev-ops/docker-compose-environment.yml
Normal file
86
docs/dev-ops/docker-compose-environment.yml
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
# 命令执行 docker-compose -f docker-compose-environment-aliyun.yml up -d
|
||||||
|
# docker 代理和使用文档;https://bugstack.cn/md/road-map/docker.html
|
||||||
|
version: '3.9'
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0.32
|
||||||
|
container_name: mysql
|
||||||
|
command: --default-authentication-plugin=mysql_native_password
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
|
MYSQL_ROOT_PASSWORD: 123456
|
||||||
|
ports:
|
||||||
|
- "13306:3306"
|
||||||
|
volumes:
|
||||||
|
- ./mysql/sql:/docker-entrypoint-initdb.d
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
start_period: 15s
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
|
||||||
|
# phpmyadmin https://hub.docker.com/_/phpmyadmin
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin:5.2.1
|
||||||
|
container_name: phpmyadmin
|
||||||
|
hostname: phpmyadmin
|
||||||
|
ports:
|
||||||
|
- 8899:80
|
||||||
|
environment:
|
||||||
|
- PMA_HOST=mysql
|
||||||
|
- PMA_PORT=3306
|
||||||
|
- MYSQL_ROOT_PASSWORD=123456
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
|
||||||
|
# Redis
|
||||||
|
redis:
|
||||||
|
image: redis:6.2
|
||||||
|
container_name: redis
|
||||||
|
restart: always
|
||||||
|
hostname: redis
|
||||||
|
privileged: true
|
||||||
|
ports:
|
||||||
|
- 16379:6379
|
||||||
|
volumes:
|
||||||
|
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
|
||||||
|
command: redis-server /usr/local/etc/redis/redis.conf
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "redis-cli", "ping" ]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
# RedisAdmin https://github.com/joeferner/redis-commander
|
||||||
|
redis-admin:
|
||||||
|
image: spryker/redis-commander:0.8.0
|
||||||
|
container_name: redis-admin
|
||||||
|
hostname: redis-commander
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
environment:
|
||||||
|
- REDIS_HOSTS=local:redis:6379
|
||||||
|
- HTTP_USER=admin
|
||||||
|
- HTTP_PASSWORD=admin
|
||||||
|
- LANG=C.UTF-8
|
||||||
|
- LANGUAGE=C.UTF-8
|
||||||
|
- LC_ALL=C.UTF-8
|
||||||
|
networks:
|
||||||
|
- my-network
|
||||||
|
depends_on:
|
||||||
|
redis:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
networks:
|
||||||
|
my-network:
|
||||||
|
driver: bridge
|
108
docs/dev-ops/mysql/sql/xfg-frame-archetype.sql
Normal file
108
docs/dev-ops/mysql/sql/xfg-frame-archetype.sql
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : 127.0.0.1
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 50639
|
||||||
|
Source Host : localhost:3306
|
||||||
|
Source Schema : road-map
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 50639
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 15/07/2023 09:26:39
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
CREATE database if NOT EXISTS `xfg_frame_archetype` default character set utf8mb4 collate utf8mb4_0900_ai_ci;
|
||||||
|
use `xfg_frame_archetype`;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for employee
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `employee`;
|
||||||
|
CREATE TABLE `employee` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`employee_number` varchar(16) NOT NULL DEFAULT '' COMMENT '雇员ID',
|
||||||
|
`employee_name` varchar(32) NOT NULL DEFAULT '' COMMENT '雇员姓名',
|
||||||
|
`employee_level` varchar(8) NOT NULL DEFAULT '' COMMENT '雇员级别',
|
||||||
|
`employee_title` varchar(16) NOT NULL DEFAULT '' COMMENT '雇员岗位Title',
|
||||||
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `idx_employee_number` (`employee_number`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of employee
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `employee` VALUES (1, '10000001', 'sXvfDpsWnJdLsCVk64tJgw==', 'T-3', '中级工程师', '2023-07-14 15:26:26', '2023-07-14 15:26:26');
|
||||||
|
INSERT INTO `employee` VALUES (2, '10000010', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-14 15:34:40', '2023-07-14 15:34:40');
|
||||||
|
INSERT INTO `employee` VALUES (3, '10000011', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-14 15:34:40', '2023-07-14 15:34:40');
|
||||||
|
INSERT INTO `employee` VALUES (4, '10000012', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-14 15:34:40', '2023-07-14 15:34:40');
|
||||||
|
INSERT INTO `employee` VALUES (5, '10000013', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-14 15:34:40', '2023-07-14 15:34:40');
|
||||||
|
INSERT INTO `employee` VALUES (6, '10000014', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-14 15:34:40', '2023-07-14 15:34:40');
|
||||||
|
INSERT INTO `employee` VALUES (9, '10000002', 'sXvfDpsWnJdLsCVk64tJgw==', 'T2', '见习工程师', '2023-07-15 07:42:52', '2023-07-15 07:42:52');
|
||||||
|
INSERT INTO `employee` VALUES (22, '10000015', 'hMCgLG6WV3CsNBQ1UD6PEQ==', 'T2', '见习工程师', '2023-07-15 08:02:31', '2023-07-15 08:02:31');
|
||||||
|
INSERT INTO `employee` VALUES (23, '10000016', 'hMCgLG6WV3CsNBQ1UD6PEQ==', 'T2', '见习工程师', '2023-07-15 08:02:31', '2023-07-15 08:02:31');
|
||||||
|
INSERT INTO `employee` VALUES (24, '10000017', 'hMCgLG6WV3CsNBQ1UD6PEQ==', 'T2', '见习工程师', '2023-07-15 08:02:31', '2023-07-15 08:02:31');
|
||||||
|
INSERT INTO `employee` VALUES (39, '10000022', 'GyG+V0r6mBCNsdusuKl03g==', 'T1', '实习工程师', '2023-07-15 09:17:49', '2023-07-15 09:17:49');
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for employee_salary
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `employee_salary`;
|
||||||
|
CREATE TABLE `employee_salary` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`employee_number` varchar(16) NOT NULL DEFAULT '' COMMENT '雇员编号',
|
||||||
|
`salary_total_amount` decimal(8,2) NOT NULL COMMENT '薪资总额',
|
||||||
|
`salary_merit_amount` decimal(8,2) NOT NULL COMMENT '绩效工资',
|
||||||
|
`salary_base_amount` decimal(8,2) NOT NULL COMMENT '基础工资',
|
||||||
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_employee_number` (`employee_number`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of employee_salary
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `employee_salary` VALUES (1, '10000001', 5100.00, 1020.00, 4080.00, '2023-07-14 16:09:06', '2023-07-14 16:09:06');
|
||||||
|
INSERT INTO `employee_salary` VALUES (2, '10000010', 5000.00, 1000.00, 4000.00, '2023-07-14 16:17:10', '2023-07-14 16:17:10');
|
||||||
|
INSERT INTO `employee_salary` VALUES (3, '10000011', 5000.00, 1000.00, 4000.00, '2023-07-14 16:17:10', '2023-07-14 16:17:10');
|
||||||
|
INSERT INTO `employee_salary` VALUES (4, '10000012', 5000.00, 1000.00, 4000.00, '2023-07-14 16:17:10', '2023-07-14 16:17:10');
|
||||||
|
INSERT INTO `employee_salary` VALUES (5, '10000013', 5000.00, 1000.00, 4000.00, '2023-07-14 16:17:10', '2023-07-14 16:17:10');
|
||||||
|
INSERT INTO `employee_salary` VALUES (6, '10000014', 5000.00, 1000.00, 4000.00, '2023-07-14 16:17:10', '2023-07-14 16:17:10');
|
||||||
|
INSERT INTO `employee_salary` VALUES (8, '10000022', 100.00, 10.00, 90.00, '2023-07-15 09:17:49', '2023-07-15 09:17:49');
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for employee_salary_adjust
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `employee_salary_adjust`;
|
||||||
|
CREATE TABLE `employee_salary_adjust` (
|
||||||
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`employee_number` varchar(16) NOT NULL DEFAULT '' COMMENT '雇员编号',
|
||||||
|
`adjust_order_id` varchar(32) NOT NULL DEFAULT '' COMMENT '调薪单号',
|
||||||
|
`adjust_total_amount` decimal(8,2) NOT NULL COMMENT '总额调薪',
|
||||||
|
`adjust_base_amount` decimal(8,2) NOT NULL COMMENT '基础调薪',
|
||||||
|
`adjust_merit_amount` decimal(8,2) NOT NULL COMMENT '绩效调薪',
|
||||||
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `idx_order_id` (`adjust_order_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of employee_salary_adjust
|
||||||
|
-- ----------------------------
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO `employee_salary_adjust` VALUES (1, '10000001', '109089990198888811', 1000.00, 800.00, 200.00, '2023-07-14 16:55:53', '2023-07-14 16:55:53');
|
||||||
|
INSERT INTO `employee_salary_adjust` VALUES (2, '10000001', '100908977676001', 100.00, 20.00, 80.00, '2023-07-14 21:57:39', '2023-07-14 21:57:39');
|
||||||
|
COMMIT;
|
38
pay-mall-api/pom.xml
Normal file
38
pay-mall-api/pom.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-api</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.26</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 数据传输对象 xxxRequestDTO xxxResponseDTO
|
||||||
|
*/
|
||||||
|
package edu.whut.api.dto;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 定义api接口
|
||||||
|
*/
|
||||||
|
package edu.whut.api;
|
@ -0,0 +1,22 @@
|
|||||||
|
package edu.whut.api.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Response<T> implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7000723935764546321L;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String info;
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
}
|
17
pay-mall-app/Dockerfile
Normal file
17
pay-mall-app/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# 基础镜像
|
||||||
|
FROM openjdk:8-jre-slim
|
||||||
|
|
||||||
|
# 作者
|
||||||
|
MAINTAINER smile
|
||||||
|
|
||||||
|
# 配置
|
||||||
|
ENV PARAMS=""
|
||||||
|
|
||||||
|
# 时区
|
||||||
|
ENV TZ=PRC
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# 添加应用
|
||||||
|
ADD target/pay-mall-app.jar /pay-mall-app.jar
|
||||||
|
|
||||||
|
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS /pay-mall-app.jar $PARAMS"]
|
137
pay-mall-app/pom.xml
Normal file
137
pay-mall-app/pom.xml
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-app</artifactId>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- # 多数据源路由配置
|
||||||
|
# mysql 5.x driver-class-name: com.mysql.jdbc.Driver mysql-connector-java 5.1.34
|
||||||
|
# mysql 8.x driver-class-name: com.mysql.cj.jdbc.Driver mysql-connector-java 8.0.22-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
|
<artifactId>converter-gson</artifactId>
|
||||||
|
<version>2.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工程模块;启动依赖 trigger->domain, infrastructure-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-trigger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-infrastructure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>pay-mall-app</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
<testFailureIgnore>false</testFailureIgnore>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Test.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>edu.whut.Application</mainClass>
|
||||||
|
<layout>JAR</layout>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
15
pay-mall-app/src/main/java/edu/whut/Application.java
Normal file
15
pay-mall-app/src/main/java/edu/whut/Application.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package edu.whut;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Configurable;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@Configurable
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
SpringApplication.run(Application.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
pay-mall-app/src/main/java/edu/whut/config/GuavaConfig.java
Normal file
20
pay-mall-app/src/main/java/edu/whut/config/GuavaConfig.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package edu.whut.config;
|
||||||
|
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class GuavaConfig {
|
||||||
|
|
||||||
|
@Bean(name = "cache")
|
||||||
|
public Cache<String, String> cache() {
|
||||||
|
return CacheBuilder.newBuilder()
|
||||||
|
.expireAfterWrite(3, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package edu.whut.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@EnableAsync
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties(ThreadPoolConfigProperties.class)
|
||||||
|
public class ThreadPoolConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(ThreadPoolExecutor.class)
|
||||||
|
public ThreadPoolExecutor threadPoolExecutor(ThreadPoolConfigProperties properties) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
// 实例化策略
|
||||||
|
RejectedExecutionHandler handler;
|
||||||
|
switch (properties.getPolicy()){
|
||||||
|
case "AbortPolicy":
|
||||||
|
handler = new ThreadPoolExecutor.AbortPolicy();
|
||||||
|
break;
|
||||||
|
case "DiscardPolicy":
|
||||||
|
handler = new ThreadPoolExecutor.DiscardPolicy();
|
||||||
|
break;
|
||||||
|
case "DiscardOldestPolicy":
|
||||||
|
handler = new ThreadPoolExecutor.DiscardOldestPolicy();
|
||||||
|
break;
|
||||||
|
case "CallerRunsPolicy":
|
||||||
|
handler = new ThreadPoolExecutor.CallerRunsPolicy();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
handler = new ThreadPoolExecutor.AbortPolicy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 创建线程池
|
||||||
|
return new ThreadPoolExecutor(properties.getCorePoolSize(),
|
||||||
|
properties.getMaxPoolSize(),
|
||||||
|
properties.getKeepAliveTime(),
|
||||||
|
TimeUnit.SECONDS,
|
||||||
|
new LinkedBlockingQueue<>(properties.getBlockQueueSize()),
|
||||||
|
Executors.defaultThreadFactory(),
|
||||||
|
handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package edu.whut.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "thread.pool.executor.config", ignoreInvalidFields = true)
|
||||||
|
public class ThreadPoolConfigProperties {
|
||||||
|
|
||||||
|
/** 核心线程数 */
|
||||||
|
private Integer corePoolSize = 20;
|
||||||
|
/** 最大线程数 */
|
||||||
|
private Integer maxPoolSize = 200;
|
||||||
|
/** 最大等待时间 */
|
||||||
|
private Long keepAliveTime = 10L;
|
||||||
|
/** 最大队列数 */
|
||||||
|
private Integer blockQueueSize = 5000;
|
||||||
|
/*
|
||||||
|
* AbortPolicy:丢弃任务并抛出RejectedExecutionException异常。
|
||||||
|
* DiscardPolicy:直接丢弃任务,但是不会抛出异常
|
||||||
|
* DiscardOldestPolicy:将最早进入队列的任务删除,之后再尝试加入队列的任务被拒绝
|
||||||
|
* CallerRunsPolicy:如果任务添加线程池失败,那么主线程自己执行该任务
|
||||||
|
* */
|
||||||
|
private String policy = "AbortPolicy";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 1. 用于管理引入的Jar所需的资源启动或者初始化处理
|
||||||
|
* 2. 如果有AOP切面,可以再建一个aop包,来写切面逻辑
|
||||||
|
*/
|
||||||
|
package edu.whut.config;
|
||||||
|
|
4
pay-mall-app/src/main/java/edu/whut/package-info.java
Normal file
4
pay-mall-app/src/main/java/edu/whut/package-info.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 应用启动层,注意Application所在的包路径,是在上一层。这样才能扫描到其他 module
|
||||||
|
* */
|
||||||
|
package edu.whut;
|
48
pay-mall-app/src/main/resources/application-dev.yml
Normal file
48
pay-mall-app/src/main/resources/application-dev.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
server:
|
||||||
|
port: 8092
|
||||||
|
|
||||||
|
# 线程池配置
|
||||||
|
thread:
|
||||||
|
pool:
|
||||||
|
executor:
|
||||||
|
config:
|
||||||
|
core-pool-size: 20
|
||||||
|
max-pool-size: 50
|
||||||
|
keep-alive-time: 5000
|
||||||
|
block-queue-size: 5000
|
||||||
|
policy: CallerRunsPolicy
|
||||||
|
|
||||||
|
# 数据库配置;启动时配置数据库资源信息
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
username: root
|
||||||
|
password: 123456
|
||||||
|
url: jdbc:mysql://127.0.0.1:13306/pay-mall?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
hikari:
|
||||||
|
pool-name: Retail_HikariCP
|
||||||
|
minimum-idle: 15 #最小空闲连接数量
|
||||||
|
idle-timeout: 180000 #空闲连接存活最大时间,默认600000(10分钟)
|
||||||
|
maximum-pool-size: 25 #连接池最大连接数,默认是10
|
||||||
|
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
|
||||||
|
max-lifetime: 1800000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
|
||||||
|
connection-timeout: 30000 #数据库连接超时时间,默认30秒,即30000
|
||||||
|
connection-test-query: SELECT 1
|
||||||
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
||||||
|
# MyBatis 配置【如需使用记得打开】
|
||||||
|
#mybatis:
|
||||||
|
# mapper-locations: classpath:/mybatis/mapper/*.xml
|
||||||
|
# config-location: classpath:/mybatis/config/mybatis-config.xml
|
||||||
|
|
||||||
|
# 微信公众号对接
|
||||||
|
weixin:
|
||||||
|
config:
|
||||||
|
originalid: gh_b748269e1f4c
|
||||||
|
token: b8b6
|
||||||
|
|
||||||
|
# 日志
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
config: classpath:logback-spring.xml
|
41
pay-mall-app/src/main/resources/application-prod.yml
Normal file
41
pay-mall-app/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
server:
|
||||||
|
port: 8092
|
||||||
|
|
||||||
|
# 线程池配置
|
||||||
|
thread:
|
||||||
|
pool:
|
||||||
|
executor:
|
||||||
|
config:
|
||||||
|
core-pool-size: 20
|
||||||
|
max-pool-size: 50
|
||||||
|
keep-alive-time: 5000
|
||||||
|
block-queue-size: 5000
|
||||||
|
policy: CallerRunsPolicy
|
||||||
|
|
||||||
|
# 数据库配置
|
||||||
|
#spring:
|
||||||
|
# datasource:
|
||||||
|
# username: root
|
||||||
|
# password: 123456
|
||||||
|
# url: jdbc:mysql://127.0.0.1:3306/pay-mall?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
|
||||||
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
# hikari:
|
||||||
|
# pool-name: Retail_HikariCP
|
||||||
|
# minimum-idle: 15 #最小空闲连接数量
|
||||||
|
# idle-timeout: 180000 #空闲连接存活最大时间,默认600000(10分钟)
|
||||||
|
# maximum-pool-size: 25 #连接池最大连接数,默认是10
|
||||||
|
# auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
|
||||||
|
# max-lifetime: 1800000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
|
||||||
|
# connection-timeout: 30000 #数据库连接超时时间,默认30秒,即30000
|
||||||
|
# connection-test-query: SELECT 1
|
||||||
|
# type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
||||||
|
#mybatis:
|
||||||
|
# mapper-locations: classpath:/mybatis/mapper/*.xml
|
||||||
|
# config-location: classpath:/mybatis/config/mybatis-config.xml
|
||||||
|
|
||||||
|
# 日志
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
config: classpath:logback-spring.xml
|
41
pay-mall-app/src/main/resources/application-test.yml
Normal file
41
pay-mall-app/src/main/resources/application-test.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
server:
|
||||||
|
port: 8092
|
||||||
|
|
||||||
|
# 线程池配置
|
||||||
|
thread:
|
||||||
|
pool:
|
||||||
|
executor:
|
||||||
|
config:
|
||||||
|
core-pool-size: 20
|
||||||
|
max-pool-size: 50
|
||||||
|
keep-alive-time: 5000
|
||||||
|
block-queue-size: 5000
|
||||||
|
policy: CallerRunsPolicy
|
||||||
|
|
||||||
|
# 数据库配置
|
||||||
|
#spring:
|
||||||
|
# datasource:
|
||||||
|
# username: root
|
||||||
|
# password: 123456
|
||||||
|
# url: jdbc:mysql://127.0.0.1:3306/pay-mall?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true
|
||||||
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
# hikari:
|
||||||
|
# pool-name: Retail_HikariCP
|
||||||
|
# minimum-idle: 15 #最小空闲连接数量
|
||||||
|
# idle-timeout: 180000 #空闲连接存活最大时间,默认600000(10分钟)
|
||||||
|
# maximum-pool-size: 25 #连接池最大连接数,默认是10
|
||||||
|
# auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
|
||||||
|
# max-lifetime: 1800000 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
|
||||||
|
# connection-timeout: 30000 #数据库连接超时时间,默认30秒,即30000
|
||||||
|
# connection-test-query: SELECT 1
|
||||||
|
# type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
||||||
|
#mybatis:
|
||||||
|
# mapper-locations: classpath:/mybatis/mapper/*.xml
|
||||||
|
# config-location: classpath:/mybatis/config/mybatis-config.xml
|
||||||
|
|
||||||
|
# 日志
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
config: classpath:logback-spring.xml
|
5
pay-mall-app/src/main/resources/application.yml
Normal file
5
pay-mall-app/src/main/resources/application.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
spring:
|
||||||
|
config:
|
||||||
|
name: pay-mall-app
|
||||||
|
profiles:
|
||||||
|
active: dev
|
113
pay-mall-app/src/main/resources/logback-spring.xml
Normal file
113
pay-mall-app/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||||
|
<configuration scan="true" scanPeriod="10 seconds">
|
||||||
|
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
||||||
|
<springProperty scope="context" name="log.path" source="logging.path"/>
|
||||||
|
<!-- 日志格式 -->
|
||||||
|
<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"/>
|
||||||
|
|
||||||
|
<!-- 输出到控制台 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- 此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>info</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0}%X{ServiceId} -%X{trace-id} %m%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!--输出到文件-->
|
||||||
|
<!-- 时间滚动输出 level为 INFO 日志 -->
|
||||||
|
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||||
|
<file>./data/log/log_info.log</file>
|
||||||
|
<!--日志文件输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0}%X{ServiceId} -%X{trace-id} %m%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 每天日志归档路径以及格式 -->
|
||||||
|
<fileNamePattern>./data/log/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文件保留天数-->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
<totalSizeCap>10GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 时间滚动输出 level为 ERROR 日志 -->
|
||||||
|
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||||
|
<file>./data/log/log_error.log</file>
|
||||||
|
<!--日志文件输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yy-MM-dd.HH:mm:ss.SSS} [%-16t] %-5p %-22c{0}%X{ServiceId} -%X{trace-id} %m%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>./data/log/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!-- 日志文件保留天数【根据服务器预留,可自行调整】 -->
|
||||||
|
<maxHistory>7</maxHistory>
|
||||||
|
<totalSizeCap>5GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- WARN 级别及以上 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>WARN</level>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 异步输出 -->
|
||||||
|
<appender name="ASYNC_FILE_INFO" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<!-- 队列剩余容量小于discardingThreshold,则会丢弃TRACT、DEBUG、INFO级别的日志;默认值-1,为queueSize的20%;0不丢失日志 -->
|
||||||
|
<discardingThreshold>0</discardingThreshold>
|
||||||
|
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||||
|
<queueSize>8192</queueSize>
|
||||||
|
<!-- neverBlock:true 会丢失日志,但业务性能不受影响 -->
|
||||||
|
<neverBlock>true</neverBlock>
|
||||||
|
<!--是否提取调用者数据-->
|
||||||
|
<includeCallerData>false</includeCallerData>
|
||||||
|
<appender-ref ref="INFO_FILE"/>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNC_FILE_ERROR" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<!-- 队列剩余容量小于discardingThreshold,则会丢弃TRACT、DEBUG、INFO级别的日志;默认值-1,为queueSize的20%;0不丢失日志 -->
|
||||||
|
<discardingThreshold>0</discardingThreshold>
|
||||||
|
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||||
|
<queueSize>1024</queueSize>
|
||||||
|
<!-- neverBlock:true 会丢失日志,但业务性能不受影响 -->
|
||||||
|
<neverBlock>true</neverBlock>
|
||||||
|
<!--是否提取调用者数据-->
|
||||||
|
<includeCallerData>false</includeCallerData>
|
||||||
|
<appender-ref ref="ERROR_FILE"/>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 开发环境:控制台打印 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<logger name="com.nmys.view" level="debug"/>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<!-- 异步日志-INFO -->
|
||||||
|
<appender-ref ref="ASYNC_FILE_INFO"/>
|
||||||
|
<!-- 异步日志-ERROR -->
|
||||||
|
<appender-ref ref="ASYNC_FILE_ERROR"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE configuration
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<!-- 暂时未使用 文档:https://mybatis.org/mybatis-3/zh/configuration.html#typeAliases -->
|
||||||
|
<typeAliases>
|
||||||
|
</typeAliases>
|
||||||
|
</configuration>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?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="edu.whut.infrastructure.persistent.dao.Xxx">
|
||||||
|
|
||||||
|
<resultMap id="CaseMap" type="edu.whut.infrastructure.persistent.po.A">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="insert" parameterType="edu.whut.infrastructure.persistent.po.A">
|
||||||
|
INSERT INTO table(a,b,c) VALUES(#{a}, #{b}, #{c})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="update" parameterType="edu.whut.infrastructure.persistent.po.A">
|
||||||
|
UPDATE table SET a = #{a} WHERE b = #{b}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="queryEmployeeByEmployNumber" parameterType="java.lang.String" resultMap="CaseMap">
|
||||||
|
SELECT a, b, c
|
||||||
|
FROM table
|
||||||
|
WHERE a = #{a}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
19
pay-mall-app/src/test/java/edu/whut/test/ApiTest.java
Normal file
19
pay-mall-app/src/test/java/edu/whut/test/ApiTest.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package edu.whut.test;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class ApiTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
log.info("测试完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
75
pay-mall-domain/pom.xml
Normal file
75
pay-mall-domain/pom.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-domain</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 系统模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-types</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>pay-mall-domain</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-archetype-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>create-from-project</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<compilerVersion>${java.version}</compilerVersion>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 外部接口适配器层;当需要调用外部接口时,则创建出这一层,并定义接口,之后由基础设施层的 adapter 层具体实现
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.adapter;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 外部接口适配器层;当需要调用外部接口时,则创建出这一层,并定义接口,之后由基础设施层的 adapter 层具体实现
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.adapter.port;
|
@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* 仓储服务
|
||||||
|
* 1. 定义仓储接口,之后由基础设施层做具体实现
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.adapter.repository;
|
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* 聚合对象;
|
||||||
|
* 1. 聚合实体和值对象
|
||||||
|
* 2. 聚合是聚合的对象,和提供基础处理对象的方法。但不建议在聚合中引入仓储和接口来做过大的逻辑。而这些复杂的操作应该放到service中处理
|
||||||
|
* 3. 对象名称 XxxAggregate
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.model.aggregate;
|
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* 实体对象;
|
||||||
|
* 1. 一般和数据库持久化对象1v1的关系,但因各自开发系统的不同,也有1vn的可能。
|
||||||
|
* 2. 如果是老系统改造,那么旧的库表冗余了太多的字段,可能会有nv1的情况
|
||||||
|
* 3. 对象名称 XxxEntity
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.model.entity;
|
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 值对象;
|
||||||
|
* 1. 用于描述对象属性的值,如一个库表中有json后者一个字段多个属性信息的枚举对象
|
||||||
|
* 2. 对象名称如;XxxVO
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.xxx.model.valobj;
|
@ -0,0 +1 @@
|
|||||||
|
package edu.whut.domain.xxx.service;
|
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* 聚合对象;
|
||||||
|
* 1. 聚合实体和值对象
|
||||||
|
* 2. 聚合是聚合的对象,和提供基础处理对象的方法。但不建议在聚合中引入仓储和接口来做过大的逻辑。而这些复杂的操作应该放到service中处理
|
||||||
|
* 3. 对象名称 XxxAggregate
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.yyy.model.aggregate;
|
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* 实体对象;
|
||||||
|
* 1. 一般和数据库持久化对象1v1的关系,但因各自开发系统的不同,也有1vn的可能。
|
||||||
|
* 2. 如果是老系统改造,那么旧的库表冗余了太多的字段,可能会有nv1的情况
|
||||||
|
* 3. 对象名称 XxxEntity
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.yyy.model.entity;
|
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* 值对象;
|
||||||
|
* 1. 用于描述对象属性的值,如一个库表中有json后者一个字段多个属性信息的枚举对象
|
||||||
|
* 2. 对象名称如;XxxVO
|
||||||
|
*/
|
||||||
|
package edu.whut.domain.yyy.model.valobj;
|
@ -0,0 +1 @@
|
|||||||
|
package edu.whut.domain.yyy.service;
|
46
pay-mall-infrastructure/pom.xml
Normal file
46
pay-mall-infrastructure/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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-infrastructure</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 系统模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>pay-mall-infrastructure</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-archetype-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>create-from-project</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 实现对外部的api调用,类的名称为 XxxPort 接口定义在 domain 中
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.adapter.port;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 仓储实现;用于实现 domain 中定义的仓储接口,如;IXxxRepository 在 Repository 中调用服务
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.adapter.repository;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* DAO 接口;IXxxDao
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.dao;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 持久化对象;XxxPO 最后的 PO 是大写,UserPO
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.dao.po;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 定义http、rpc接口,调用外部。在 adapter 中调用这部分内容。
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.gateway;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 提供redis链接配置
|
||||||
|
*/
|
||||||
|
package edu.whut.infrastructure.redis;
|
63
pay-mall-trigger/pom.xml
Normal file
63
pay-mall-trigger/pom.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-trigger</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-tx</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 系统模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-types</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-domain</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>pay-mall-trigger</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-archetype-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>create-from-project</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,76 @@
|
|||||||
|
package edu.whut.trigger.http;
|
||||||
|
import edu.whut.types.weixin.MessageTextEntity;
|
||||||
|
import edu.whut.types.weixin.SignatureUtil;
|
||||||
|
import edu.whut.types.weixin.XmlUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index 平台地址
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController()
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RequestMapping("/api/v1/weixin/portal/")
|
||||||
|
public class WeixinPortalController {
|
||||||
|
|
||||||
|
@Value("${weixin.config.originalid}")
|
||||||
|
private String originalid;
|
||||||
|
@Value("${weixin.config.token}")
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
@GetMapping(value = "receive", produces = "text/plain;charset=utf-8")
|
||||||
|
public String validate(@RequestParam(value = "signature", required = false) String signature,
|
||||||
|
@RequestParam(value = "timestamp", required = false) String timestamp,
|
||||||
|
@RequestParam(value = "nonce", required = false) String nonce,
|
||||||
|
@RequestParam(value = "echostr", required = false) String echostr) {
|
||||||
|
try {
|
||||||
|
log.info("微信公众号验签信息开始 [{}, {}, {}, {}]", signature, timestamp, nonce, echostr);
|
||||||
|
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
|
||||||
|
throw new IllegalArgumentException("请求参数非法,请核实!");
|
||||||
|
}
|
||||||
|
boolean check = SignatureUtil.check(token, signature, timestamp, nonce);
|
||||||
|
log.info("微信公众号验签信息完成 check:{}", check);
|
||||||
|
if (!check) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return echostr;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("微信公众号验签信息失败 [{}, {}, {}, {}]", signature, timestamp, nonce, echostr, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "receive", produces = "application/xml; charset=UTF-8")
|
||||||
|
public String post(@RequestBody String requestBody,
|
||||||
|
@RequestParam("signature") String signature,
|
||||||
|
@RequestParam("timestamp") String timestamp,
|
||||||
|
@RequestParam("nonce") String nonce,
|
||||||
|
@RequestParam("openid") String openid,
|
||||||
|
@RequestParam(name = "encrypt_type", required = false) String encType,
|
||||||
|
@RequestParam(name = "msg_signature", required = false) String msgSignature) {
|
||||||
|
try {
|
||||||
|
log.info("接收微信公众号信息请求{}开始 {}", openid, requestBody);
|
||||||
|
// 消息转换
|
||||||
|
MessageTextEntity message = XmlUtil.xmlToBean(requestBody, MessageTextEntity.class);
|
||||||
|
return buildMessageTextEntity(openid, "你好," + message.getContent());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("接收微信公众号信息请求{}失败 {}", openid, requestBody, e);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildMessageTextEntity(String openid, String content) {
|
||||||
|
MessageTextEntity res = new MessageTextEntity();
|
||||||
|
// 公众号分配的ID
|
||||||
|
res.setFromUserName(originalid);
|
||||||
|
res.setToUserName(openid);
|
||||||
|
res.setCreateTime(String.valueOf(System.currentTimeMillis() / 1000L));
|
||||||
|
res.setMsgType("text");
|
||||||
|
res.setContent(content);
|
||||||
|
return XmlUtil.beanToXml(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* HTTP 接口服务
|
||||||
|
*/
|
||||||
|
package edu.whut.trigger.http;
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 任务服务,可以选择使用 Spring 默认提供的 Schedule https://bugstack.cn/md/road-map/quartz.html
|
||||||
|
*/
|
||||||
|
package edu.whut.trigger.job;
|
@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* 监听服务;在单体服务中,解耦流程。类似MQ的使用,如Spring的Event,Guava的事件总线都可以。如果使用了 Redis 那么也可以有发布/订阅使用。
|
||||||
|
* Guava:https://bugstack.cn/md/road-map/guava.html
|
||||||
|
*/
|
||||||
|
package edu.whut.trigger.listener;
|
53
pay-mall-types/pom.xml
Normal file
53
pay-mall-types/pom.xml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-mall-types</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dom4j</groupId>
|
||||||
|
<artifactId>dom4j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>pay-mall-types</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-archetype-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>create-from-project</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,7 @@
|
|||||||
|
package edu.whut.types.common;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
|
||||||
|
public final static String SPLIT = ",";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package edu.whut.types.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum ResponseCode {
|
||||||
|
|
||||||
|
SUCCESS("0000", "成功"),
|
||||||
|
UN_ERROR("0001", "未知失败"),
|
||||||
|
ILLEGAL_PARAMETER("0002", "非法参数"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package edu.whut.types.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class AppException extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5317680961212299217L;
|
||||||
|
|
||||||
|
/** 异常码 */
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 异常信息 */
|
||||||
|
private String info;
|
||||||
|
|
||||||
|
public AppException(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppException(String code, Throwable cause) {
|
||||||
|
this.code = code;
|
||||||
|
super.initCause(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppException(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppException(String code, String message, Throwable cause) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = message;
|
||||||
|
super.initCause(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "edu.whut.x.api.types.exception.XApiException{" +
|
||||||
|
"code='" + code + '\'' +
|
||||||
|
", info='" + info + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
package edu.whut.types.weixin;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
|
||||||
|
@XStreamAlias("xml")
|
||||||
|
public class MessageTextEntity {
|
||||||
|
|
||||||
|
@XStreamAlias("ToUserName")
|
||||||
|
private String toUserName;
|
||||||
|
|
||||||
|
@XStreamAlias("FromUserName")
|
||||||
|
private String fromUserName;
|
||||||
|
|
||||||
|
@XStreamAlias("CreateTime")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@XStreamAlias("MsgType")
|
||||||
|
private String msgType;
|
||||||
|
|
||||||
|
@XStreamAlias("Event")
|
||||||
|
private String event;
|
||||||
|
|
||||||
|
@XStreamAlias("EventKey")
|
||||||
|
private String eventKey;
|
||||||
|
|
||||||
|
@XStreamAlias("MsgId")
|
||||||
|
private String msgId;
|
||||||
|
|
||||||
|
@XStreamAlias("Status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@XStreamAlias("Ticket")
|
||||||
|
private String ticket;
|
||||||
|
|
||||||
|
@XStreamAlias("Content")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
// Getters and Setters
|
||||||
|
public String getToUserName() {
|
||||||
|
return toUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToUserName(String toUserName) {
|
||||||
|
this.toUserName = toUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFromUserName() {
|
||||||
|
return fromUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromUserName(String fromUserName) {
|
||||||
|
this.fromUserName = fromUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(String createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsgType() {
|
||||||
|
return msgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsgType(String msgType) {
|
||||||
|
this.msgType = msgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEvent() {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEvent(String event) {
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsgId() {
|
||||||
|
return msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsgId(String msgId) {
|
||||||
|
this.msgId = msgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventKey() {
|
||||||
|
return eventKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventKey(String eventKey) {
|
||||||
|
this.eventKey = eventKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTicket() {
|
||||||
|
return ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTicket(String ticket) {
|
||||||
|
this.ticket = ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package edu.whut.types.weixin;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
public class SignatureUtil {
|
||||||
|
/**
|
||||||
|
* 验证签名
|
||||||
|
*/
|
||||||
|
public static boolean check(String token, String signature, String timestamp, String nonce) {
|
||||||
|
String[] arr = new String[]{token, timestamp, nonce};
|
||||||
|
// 将token、timestamp、nonce三个参数进行字典序排序
|
||||||
|
sort(arr);
|
||||||
|
StringBuilder content = new StringBuilder();
|
||||||
|
for (String s : arr) {
|
||||||
|
content.append(s);
|
||||||
|
}
|
||||||
|
MessageDigest md;
|
||||||
|
String tmpStr = null;
|
||||||
|
try {
|
||||||
|
md = MessageDigest.getInstance("SHA-1");
|
||||||
|
// 将三个参数字符串拼接成一个字符串进行sha1加密
|
||||||
|
byte[] digest = md.digest(content.toString().getBytes());
|
||||||
|
tmpStr = byteToStr(digest);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 将sha1加密后的字符串可与signature对比,标识该请求来源于微信
|
||||||
|
return tmpStr != null && tmpStr.equals(signature.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字节数组转换为十六进制字符串
|
||||||
|
*/
|
||||||
|
private static String byteToStr(byte[] byteArray) {
|
||||||
|
StringBuilder strDigest = new StringBuilder();
|
||||||
|
for (byte b : byteArray) {
|
||||||
|
strDigest.append(byteToHexStr(b));
|
||||||
|
}
|
||||||
|
return strDigest.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字节转换为十六进制字符串
|
||||||
|
*/
|
||||||
|
private static String byteToHexStr(byte mByte) {
|
||||||
|
char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
|
char[] tempArr = new char[2];
|
||||||
|
tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
|
||||||
|
tempArr[1] = Digit[mByte & 0X0F];
|
||||||
|
return new String(tempArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进行字典排序
|
||||||
|
*/
|
||||||
|
private static void sort(String[] str) {
|
||||||
|
for (int i = 0; i < str.length - 1; i++) {
|
||||||
|
for (int j = i + 1; j < str.length; j++) {
|
||||||
|
if (str[j].compareTo(str[i]) < 0) {
|
||||||
|
String temp = str[i];
|
||||||
|
str[i] = str[j];
|
||||||
|
str[j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
151
pay-mall-types/src/main/java/edu/whut/types/weixin/XmlUtil.java
Normal file
151
pay-mall-types/src/main/java/edu/whut/types/weixin/XmlUtil.java
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package edu.whut.types.weixin;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.XStream;
|
||||||
|
import com.thoughtworks.xstream.core.util.QuickWriter;
|
||||||
|
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||||
|
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||||
|
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
|
||||||
|
import com.thoughtworks.xstream.io.xml.XppDriver;
|
||||||
|
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class XmlUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析微信发来的请求(xml)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Map<String, String> xmlToMap(HttpServletRequest request) throws Exception {
|
||||||
|
// 从request中取得输入流
|
||||||
|
try (InputStream inputStream = request.getInputStream()) {
|
||||||
|
// 将解析结果存储在HashMap中
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
// 读取输入流
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
// 得到xml文档
|
||||||
|
Document document = reader.read(inputStream);
|
||||||
|
// 得到xml根元素
|
||||||
|
Element root = document.getRootElement();
|
||||||
|
// 得到根元素的所有子节点
|
||||||
|
List<Element> elementList = root.elements();
|
||||||
|
// 遍历所有子节点
|
||||||
|
for (Element e : elementList)
|
||||||
|
map.put(e.getName(), e.getText());
|
||||||
|
// 释放资源
|
||||||
|
inputStream.close();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将map转化成xml响应给微信服务器
|
||||||
|
*/
|
||||||
|
static String mapToXML(Map map) {
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
sb.append("<xml>");
|
||||||
|
mapToXML2(map, sb);
|
||||||
|
sb.append("</xml>");
|
||||||
|
try {
|
||||||
|
return sb.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mapToXML2(Map map, StringBuffer sb) {
|
||||||
|
Set set = map.keySet();
|
||||||
|
for (Object o : set) {
|
||||||
|
String key = (String) o;
|
||||||
|
Object value = map.get(key);
|
||||||
|
if (null == value)
|
||||||
|
value = "";
|
||||||
|
if (value.getClass().getName().equals("java.util.ArrayList")) {
|
||||||
|
ArrayList list = (ArrayList) map.get(key);
|
||||||
|
sb.append("<").append(key).append(">");
|
||||||
|
for (Object o1 : list) {
|
||||||
|
HashMap hm = (HashMap) o1;
|
||||||
|
mapToXML2(hm, sb);
|
||||||
|
}
|
||||||
|
sb.append("</").append(key).append(">");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (value instanceof HashMap) {
|
||||||
|
sb.append("<").append(key).append(">");
|
||||||
|
mapToXML2((HashMap) value, sb);
|
||||||
|
sb.append("</").append(key).append(">");
|
||||||
|
} else {
|
||||||
|
sb.append("<").append(key).append("><![CDATA[").append(value).append("]]></").append(key).append(">");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XStream getMyXStream() {
|
||||||
|
return new XStream(new XppDriver() {
|
||||||
|
@Override
|
||||||
|
public HierarchicalStreamWriter createWriter(Writer out) {
|
||||||
|
return new PrettyPrintWriter(out) {
|
||||||
|
// 对所有xml节点都增加CDATA标记
|
||||||
|
boolean cdata = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startNode(String name, Class clazz) {
|
||||||
|
super.startNode(name, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeText(QuickWriter writer, String text) {
|
||||||
|
if (cdata && !StringUtils.isNumeric(text)) {
|
||||||
|
writer.write("<![CDATA[");
|
||||||
|
writer.write(text);
|
||||||
|
writer.write("]]>");
|
||||||
|
} else {
|
||||||
|
writer.write(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bean转成微信的xml消息格式
|
||||||
|
*/
|
||||||
|
public static String beanToXml(Object object) {
|
||||||
|
XStream xStream = getMyXStream();
|
||||||
|
xStream.alias("xml", object.getClass());
|
||||||
|
xStream.processAnnotations(object.getClass());
|
||||||
|
String xml = xStream.toXML(object);
|
||||||
|
if (!StringUtils.isEmpty(xml)) {
|
||||||
|
return xml;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xml转成bean泛型方法
|
||||||
|
*/
|
||||||
|
public static <T> T xmlToBean(String resultXml, Class clazz) {
|
||||||
|
// XStream对象设置默认安全防护,同时设置允许的类
|
||||||
|
XStream stream = new XStream(new DomDriver());
|
||||||
|
stream.addPermission(AnyTypePermission.ANY);
|
||||||
|
XStream.setupDefaultSecurity(stream);
|
||||||
|
stream.allowTypes(new Class[]{clazz});
|
||||||
|
stream.processAnnotations(new Class[]{clazz});
|
||||||
|
stream.setMode(XStream.NO_REFERENCES);
|
||||||
|
stream.alias("xml", clazz);
|
||||||
|
return (T) stream.fromXML(resultXml);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
203
pom.xml
Normal file
203
pom.xml
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>pay-mall-api</module>
|
||||||
|
<module>pay-mall-app</module>
|
||||||
|
<module>pay-mall-domain</module>
|
||||||
|
<module>pay-mall-trigger</module>
|
||||||
|
<module>pay-mall-infrastructure</module>
|
||||||
|
<module>pay-mall-types</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>nexus-aliyun</id>
|
||||||
|
<name>nexus-aliyun</name>
|
||||||
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>xiaofuge</name>
|
||||||
|
<email>184172133@qq.com</email>
|
||||||
|
<organization>fuzhengwei</organization>
|
||||||
|
<organizationUrl>https://github.com/fuzhengwei</organizationUrl>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>Apache License, Version 2.0</name>
|
||||||
|
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.7.12</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- # 多数据源路由配置
|
||||||
|
# mysql 5.x driver-class-name: com.mysql.jdbc.Driver mysql-connector-java 5.1.34
|
||||||
|
# mysql 8.x driver-class-name: com.mysql.cj.jdbc.Driver mysql-connector-java 8.0.22-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.22</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>2.0.28</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.9</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>32.1.3-jre</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dom4j</groupId>
|
||||||
|
<artifactId>dom4j</artifactId>
|
||||||
|
<version>1.6.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>1.4.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
<version>4.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>1.15</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工程模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-domain</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-infrastructure</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-types</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>edu.whut</groupId>
|
||||||
|
<artifactId>pay-mall-trigger</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>versions-maven-plugin</artifactId>
|
||||||
|
<version>2.7</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>dev</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<java_jvm>-Xms1G -Xmx1G -server -XX:MaxPermSize=256M -Xss256K -Dspring.profiles.active=test -XX:+DisableExplicitGC -XX:+UseG1GC -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/export/Logs/pay-mall-boot -Xloggc:/export/Logs/pay-mall-boot/gc-pay-mall-boot.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps</java_jvm>
|
||||||
|
<profileActive>dev</profileActive>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>test</id>
|
||||||
|
<properties>
|
||||||
|
<java_jvm>-Xms1G -Xmx1G -server -XX:MaxPermSize=256M -Xss256K -Dspring.profiles.active=test -XX:+DisableExplicitGC -XX:+UseG1GC -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/export/Logs/pay-mall-boot -Xloggc:/export/Logs/pay-mall-boot/gc-pay-mall-boot.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps</java_jvm>
|
||||||
|
<profileActive>test</profileActive>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>prod</id>
|
||||||
|
<properties>
|
||||||
|
<java_jvm>-Xms6G -Xmx6G -server -XX:MaxPermSize=256M -Xss256K -Dspring.profiles.active=release -XX:+DisableExplicitGC -XX:+UseG1GC -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/export/Logs/fq-mall-activity-app -Xloggc:/export/Logs/pay-mall-boot/gc-pay-mall-boot.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps</java_jvm>
|
||||||
|
<profileActive>prod</profileActive>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
</project>
|
Loading…
x
Reference in New Issue
Block a user