初始化
This commit is contained in:
commit
d341cabc39
|
|
@ -0,0 +1,41 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
**/static/**
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
WebMvcConfiguration.java
|
||||
WebSocketConfig.java
|
||||
application-dev.yml
|
||||
application-local.yml
|
||||
/logs/anmo.log
|
||||
/logs
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
**项目说明**
|
||||
- sqx-fast是一个轻量级的,前后端分离的Java快速开发平台,能快速开发项目并交付
|
||||
- 支持MySQL、PostgreSQL等主流数据库
|
||||
<br>
|
||||
|
||||
|
||||
**具有如下特点**
|
||||
- 友好的代码结构及注释,便于阅读及二次开发
|
||||
- 实现前后端分离,通过token进行数据交互,前端再也不用关注后端技术
|
||||
- 灵活的权限控制,可控制到页面或按钮,满足绝大部分的权限需求
|
||||
- 页面交互使用Vue2.x,极大的提高了开发效率
|
||||
- 完善的代码生成机制,可在线生成entity、xml、dao、service、vue、sql代码,减少70%以上的开发任务
|
||||
- 引入quartz定时任务,可动态完成任务的添加、修改、删除、暂停、恢复及日志查看等功能
|
||||
- 引入API模板,根据token作为登录令牌,极大的方便了APP接口开发
|
||||
- 引入Hibernate Validator校验框架,轻松实现后端校验
|
||||
- 引入云存储服务,已支持:七牛云、阿里云、腾讯云等
|
||||
- 引入swagger文档支持,方便编写API接口文档
|
||||
<br>
|
||||
|
||||
**项目结构**
|
||||
```
|
||||
sqx_fast
|
||||
├─db 项目SQL语句
|
||||
│
|
||||
├─common 公共模块
|
||||
│ ├─aspect 系统日志
|
||||
│ ├─exception 异常处理
|
||||
│ ├─validator 后台校验
|
||||
│ └─xss XSS过滤
|
||||
│
|
||||
├─config 配置信息
|
||||
│
|
||||
├─modules 功能模块
|
||||
│ ├─app API接口模块(APP调用)
|
||||
│ ├─job 定时任务模块
|
||||
│ ├─oss 文件服务模块
|
||||
│ └─sys 权限模块
|
||||
│
|
||||
├─sqxApplication 项目启动类
|
||||
│
|
||||
├──resources
|
||||
│ ├─mapper SQL对应的XML文件
|
||||
│ └─static 静态资源
|
||||
|
||||
```
|
||||
<br>
|
||||
|
||||
**技术选型:**
|
||||
- 核心框架:Spring Boot 2.1
|
||||
- 安全框架:Apache Shiro 1.4
|
||||
- 视图框架:Spring MVC 5.0
|
||||
- 持久层框架:MyBatis 3.3
|
||||
- 定时器:Quartz 2.3
|
||||
- 数据库连接池:Druid 1.0
|
||||
- 日志管理:SLF4J 1.7、Log4j
|
||||
- 页面交互:Vue2.x
|
||||
<br>
|
||||
|
||||
|
||||
**后端部署**
|
||||
- 通过git下载源码
|
||||
- idea、eclipse需安装lombok插件,不然会提示找不到entity的get set方法
|
||||
- 创建数据库sqx_fast,数据库编码为UTF-8
|
||||
- 执行db/mysql.sql文件,初始化数据
|
||||
- 修改application-dev.yml,更新MySQL账号和密码
|
||||
- Eclipse、IDEA运行sqxApplication.java,则可启动项目
|
||||
- Swagger文档路径:http://localhost:8080/sqx_fast/swagger/index.html
|
||||
- Swagger注解路径:http://localhost:8080/sqx_fast/swagger-ui.html
|
||||
|
||||
|
||||
<br>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,25 @@
|
|||
--common_info表增加多少分钟等1积分 数据(type=100000)
|
||||
INSERT INTO `anmo`.`common_info` (`id`, `create_at`, `max`, `min`, `type`, `value`, `condition_from`) VALUES (430, '2024-02-01 11:19:11', NULL, '多少分钟等1积分', 100000, '10', 'xitong');
|
||||
|
||||
|
||||
--新增 积分等级字典表 artificer_partitioning_details.sql sql脚本在db文件夹下
|
||||
|
||||
--新增 积分储值表
|
||||
CREATE TABLE `anmo`.`user_recharge` (
|
||||
`id` bigint(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_recharge` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '用户充值积分',
|
||||
`orders_id` int(11) NULL DEFAULT NULL COMMENT '订单id',
|
||||
`user_id` int(11) NULL DEFAULT NULL COMMENT '用户id',
|
||||
`type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '积分类型(1在线积分2储值积分)',
|
||||
`artificer_id` int(11) NULL DEFAULT NULL COMMENT '技师id',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
--artificer 技师表增加grade
|
||||
ALTER TABLE `anmo`.`artificer`
|
||||
ADD COLUMN `grade` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前等级' AFTER `up_time`;
|
||||
--artificer 技师表增加up_time
|
||||
ALTER TABLE `anmo`.`artificer`
|
||||
ADD COLUMN `up_time` datetime(0) NULL DEFAULT NULL COMMENT '上线时间' AFTER `grade`;
|
||||
|
||||
INSERT INTO `anmo`.`common_info` (`id`, `create_at`, `max`, `min`, `type`, `value`, `condition_from`) VALUES (436, '2024-02-18 15:52:12', NULL, '中医忙时时间切换(只限输入 30半个小时 60一个小时)', 436, '60', 'fuwufei');
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : 192.168.1.102
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50722 (5.7.22-log)
|
||||
Source Host : 192.168.1.102:3306
|
||||
Source Schema : anmoceshi
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 50722 (5.7.22-log)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 21/03/2024 15:08:11
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for artificer_partitioning_details
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `artificer_partitioning_details`;
|
||||
CREATE TABLE `artificer_partitioning_details` (
|
||||
`id` bigint(20) NOT NULL,
|
||||
`grade` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '等级',
|
||||
`outstanding_achievement` decimal(20, 2) NULL DEFAULT NULL COMMENT '最低业绩',
|
||||
`clock_rate` decimal(20, 2) NULL DEFAULT NULL COMMENT '加钟率',
|
||||
`deposit_rate` decimal(20, 2) NULL DEFAULT NULL COMMENT '充值率',
|
||||
`duration_online` int(11) NULL DEFAULT NULL COMMENT '在线时长',
|
||||
`integral` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '积分',
|
||||
`proportional_sharing` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '分成比例',
|
||||
`classify_id` int(11) NULL DEFAULT NULL COMMENT '项目类型id',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '技师等级表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of artificer_partitioning_details
|
||||
-- ----------------------------
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (1, '新', 0.00, 0.00, 0.00, 0, '0', '0.65', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (3, 'A0', 0.00, 0.00, 0.00, 50, '0', '0.6', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (5, 'A1', 4000.00, 0.06, 0.10, 80, '0', '0.7', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (7, 'A2', 6000.00, 0.15, 0.15, 0, '1000', '0.75', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (9, 'A3', 8000.00, 0.20, 0.20, 0, '1200', '0.8', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (11, 'A4', 10000.00, 0.30, 0.30, 0, '2500', '0.9', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (13, 'A5', 12000.00, 0.35, 0.35, 0, '6000', '0.95', 91);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (27, '新', 0.00, 0.00, 0.00, 0, '0', '0.65', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (29, 'A0', 0.00, 0.00, 0.00, 50, '0', '0.6', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (31, 'A1', 4000.00, 0.10, 0.20, 80, '0', '0.7', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (33, 'A2', 6000.00, 0.15, 0.15, 0, '1000', '0.75', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (35, 'A3', 8000.00, 0.20, 0.20, 0, '1200', '0.8', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (37, 'A4', 10000.00, 0.30, 0.30, 0, '2500', '0.9', 95);
|
||||
INSERT INTO `artificer_partitioning_details` VALUES (39, 'A5', 12000.00, 0.35, 0.35, 0, '6000', '0.95', 95);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
@echo off
|
||||
echo 更新后台代码中...
|
||||
git.exe pull -v --progress "origin"
|
||||
echo 更新成功
|
||||
PAUSE
|
||||
exit
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
#
|
||||
# There is insufficient memory for the Java Runtime Environment to continue.
|
||||
# Native memory allocation (mmap) failed to map 268435456 bytes for G1 virtual space
|
||||
# Possible reasons:
|
||||
# The system is out of physical RAM or swap space
|
||||
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
|
||||
# Possible solutions:
|
||||
# Reduce memory load on the system
|
||||
# Increase physical memory or swap space
|
||||
# Check if swap backing store is full
|
||||
# Decrease Java heap size (-Xmx/-Xms)
|
||||
# Decrease number of Java threads
|
||||
# Decrease Java thread stack sizes (-Xss)
|
||||
# Set larger code cache with -XX:ReservedCodeCacheSize=
|
||||
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
|
||||
# placed in the first 32GB address space. The Java Heap base address is the
|
||||
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
|
||||
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
|
||||
# This output file may be truncated or incomplete.
|
||||
#
|
||||
# Out of Memory Error (os_windows.cpp:3825), pid=36964, tid=32736
|
||||
#
|
||||
# JRE version: (17.0.9+7) (build )
|
||||
# Java VM: OpenJDK 64-Bit Server VM (17.0.9+7-b1087.9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
|
||||
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
|
||||
#
|
||||
|
||||
--------------- S U M M A R Y ------------
|
||||
|
||||
Command Line: git4idea.http.GitAskPassApp Username for 'https://gitee.com':
|
||||
|
||||
Host: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz, 6 cores, 15G, Windows 10 , 64 bit Build 19041 (10.0.19041.3636)
|
||||
Time: Tue Apr 2 13:41:41 2024 Windows 10 , 64 bit Build 19041 (10.0.19041.3636) elapsed time: 0.039108 seconds (0d 0h 0m 0s)
|
||||
|
||||
--------------- T H R E A D ---------------
|
||||
|
||||
Current thread (0x000002889d97c530): JavaThread "Unknown thread" [_thread_in_vm, id=32736, stack(0x0000009f06a00000,0x0000009f06b00000)]
|
||||
|
||||
Stack: [0x0000009f06a00000,0x0000009f06b00000]
|
||||
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
|
||||
V [jvm.dll+0x688349]
|
||||
V [jvm.dll+0x841bfa]
|
||||
V [jvm.dll+0x84383e]
|
||||
V [jvm.dll+0x843ea3]
|
||||
V [jvm.dll+0x24bdef]
|
||||
V [jvm.dll+0x6850f9]
|
||||
V [jvm.dll+0x67988a]
|
||||
V [jvm.dll+0x30cbfb]
|
||||
V [jvm.dll+0x3140a6]
|
||||
V [jvm.dll+0x363ede]
|
||||
V [jvm.dll+0x36410f]
|
||||
V [jvm.dll+0x2e29c8]
|
||||
V [jvm.dll+0x2e3934]
|
||||
V [jvm.dll+0x812771]
|
||||
V [jvm.dll+0x371d41]
|
||||
V [jvm.dll+0x7f12bc]
|
||||
V [jvm.dll+0x3f59cf]
|
||||
V [jvm.dll+0x3f7601]
|
||||
C [jli.dll+0x528f]
|
||||
C [ucrtbase.dll+0x21bb2]
|
||||
C [KERNEL32.DLL+0x17344]
|
||||
C [ntdll.dll+0x526b1]
|
||||
|
||||
|
||||
--------------- P R O C E S S ---------------
|
||||
|
||||
Threads class SMR info:
|
||||
_java_thread_list=0x00007ffc3951df18, length=0, elements={
|
||||
}
|
||||
|
||||
Java Threads: ( => current thread )
|
||||
|
||||
Other Threads:
|
||||
0x000002889d9e76f0 GCTaskThread "GC Thread#0" [stack: 0x0000009f06b00000,0x0000009f06c00000] [id=36344]
|
||||
0x000002889d9f85c0 ConcurrentGCThread "G1 Main Marker" [stack: 0x0000009f06c00000,0x0000009f06d00000] [id=24640]
|
||||
0x000002889d9f8fe0 ConcurrentGCThread "G1 Conc#0" [stack: 0x0000009f06d00000,0x0000009f06e00000] [id=23712]
|
||||
|
||||
[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc38cd3597]
|
||||
|
||||
VM state: not at safepoint (not fully initialized)
|
||||
|
||||
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
|
||||
[0x000002889d9789f0] Heap_lock - owner thread: 0x000002889d97c530
|
||||
|
||||
Heap address: 0x0000000700800000, size: 4088 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
|
||||
|
||||
CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1.
|
||||
Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0
|
||||
|
||||
GC Precious Log:
|
||||
<Empty>
|
||||
|
||||
Heap:
|
||||
garbage-first heap total 0K, used 0K [0x0000000700800000, 0x0000000800000000)
|
||||
region size 2048K, 0 young (0K), 0 survivors (0K)
|
||||
Metaspace used 0K, committed 0K, reserved 0K
|
||||
class space used 0K, committed 0K, reserved 0K
|
||||
|
||||
Heap Regions: E=young(eden), S=young(survivor), O=old, HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, OA=open archive, CA=closed archive, TAMS=top-at-mark-start (previous, next)
|
||||
|
||||
Card table byte_map: [0x00000288b0a10000,0x00000288b1210000] _byte_map_base: 0x00000288ad20c000
|
||||
|
||||
Marking Bits (Prev, Next): (CMBitMap*) 0x000002889d9e7d10, (CMBitMap*) 0x000002889d9e7d50
|
||||
Prev Bits: [0x00000288b1a10000, 0x00000288b59f0000)
|
||||
Next Bits: [0x00000288b59f0000, 0x00000288b99d0000)
|
||||
|
||||
GC Heap History (0 events):
|
||||
No events
|
||||
|
||||
Dll operation events (1 events):
|
||||
Event: 0.024 Loaded shared library C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.dll
|
||||
|
||||
Deoptimization events (0 events):
|
||||
No events
|
||||
|
||||
Classes unloaded (0 events):
|
||||
No events
|
||||
|
||||
Classes redefined (0 events):
|
||||
No events
|
||||
|
||||
Internal exceptions (0 events):
|
||||
No events
|
||||
|
||||
VM Operations (0 events):
|
||||
No events
|
||||
|
||||
Events (0 events):
|
||||
No events
|
||||
|
||||
|
||||
Dynamic libraries:
|
||||
0x00007ff726640000 - 0x00007ff72664a000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.exe
|
||||
0x00007ffc72ff0000 - 0x00007ffc731e8000 C:\Windows\SYSTEM32\ntdll.dll
|
||||
0x00007ffc71250000 - 0x00007ffc7130d000 C:\Windows\System32\KERNEL32.DLL
|
||||
0x00007ffc70800000 - 0x00007ffc70af6000 C:\Windows\System32\KERNELBASE.dll
|
||||
0x00007ffc706a0000 - 0x00007ffc707a0000 C:\Windows\System32\ucrtbase.dll
|
||||
0x00007ffc636a0000 - 0x00007ffc636b7000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\jli.dll
|
||||
0x00007ffc655f0000 - 0x00007ffc6560b000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\VCRUNTIME140.dll
|
||||
0x00007ffc71be0000 - 0x00007ffc71d7e000 C:\Windows\System32\USER32.dll
|
||||
0x00007ffc707a0000 - 0x00007ffc707c2000 C:\Windows\System32\win32u.dll
|
||||
0x00007ffc72d00000 - 0x00007ffc72d2b000 C:\Windows\System32\GDI32.dll
|
||||
0x00007ffc70b00000 - 0x00007ffc70c17000 C:\Windows\System32\gdi32full.dll
|
||||
0x00007ffc70f80000 - 0x00007ffc7101d000 C:\Windows\System32\msvcp_win.dll
|
||||
0x00007ffc62590000 - 0x00007ffc6282a000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_60b6a03d71f818d5\COMCTL32.dll
|
||||
0x00007ffc71ac0000 - 0x00007ffc71b5e000 C:\Windows\System32\msvcrt.dll
|
||||
0x00007ffc72e10000 - 0x00007ffc72e42000 C:\Windows\System32\IMM32.DLL
|
||||
0x00007ffc6a360000 - 0x00007ffc6a36c000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\vcruntime140_1.dll
|
||||
0x00007ffc592d0000 - 0x00007ffc5935d000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\msvcp140.dll
|
||||
0x00007ffc389e0000 - 0x00007ffc39662000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\server\jvm.dll
|
||||
0x00007ffc72e60000 - 0x00007ffc72f10000 C:\Windows\System32\ADVAPI32.dll
|
||||
0x00007ffc72f10000 - 0x00007ffc72fb0000 C:\Windows\System32\sechost.dll
|
||||
0x00007ffc71d80000 - 0x00007ffc71ea5000 C:\Windows\System32\RPCRT4.dll
|
||||
0x00007ffc707d0000 - 0x00007ffc707f7000 C:\Windows\System32\bcrypt.dll
|
||||
0x00007ffc6fc40000 - 0x00007ffc6fc8b000 C:\Windows\SYSTEM32\POWRPROF.dll
|
||||
0x00007ffc67ca0000 - 0x00007ffc67cc7000 C:\Windows\SYSTEM32\WINMM.dll
|
||||
0x00007ffc6a350000 - 0x00007ffc6a35a000 C:\Windows\SYSTEM32\VERSION.dll
|
||||
0x00007ffc6be30000 - 0x00007ffc6be39000 C:\Windows\SYSTEM32\WSOCK32.dll
|
||||
0x00007ffc71b70000 - 0x00007ffc71bdb000 C:\Windows\System32\ws2_32.DLL
|
||||
0x00007ffc6fab0000 - 0x00007ffc6fac2000 C:\Windows\SYSTEM32\UMPDC.dll
|
||||
0x00007ffc6ef30000 - 0x00007ffc6ef42000 C:\Windows\SYSTEM32\kernel.appcore.dll
|
||||
0x00007ffc6bf00000 - 0x00007ffc6bf0a000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\jimage.dll
|
||||
0x00007ffc6e160000 - 0x00007ffc6e344000 C:\Windows\SYSTEM32\DBGHELP.DLL
|
||||
0x00007ffc57240000 - 0x00007ffc57274000 C:\Windows\SYSTEM32\dbgcore.DLL
|
||||
0x00007ffc70cd0000 - 0x00007ffc70d52000 C:\Windows\System32\bcryptPrimitives.dll
|
||||
0x00007ffc63f20000 - 0x00007ffc63f45000 C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\java.dll
|
||||
|
||||
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
|
||||
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_60b6a03d71f818d5;C:\Program Files\JetBrains\IntelliJ IDEA 2023.3.2\jbr\bin\server
|
||||
|
||||
VM Arguments:
|
||||
java_command: git4idea.http.GitAskPassApp Username for 'https://gitee.com':
|
||||
java_class_path (initial): C:/Program Files/JetBrains/IntelliJ IDEA 2023.3.2/plugins/vcs-git/lib/git4idea-rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA 2023.3.2/lib/externalProcess-rt.jar
|
||||
Launcher Type: SUN_STANDARD
|
||||
|
||||
[Global flags]
|
||||
intx CICompilerCount = 3 {product} {ergonomic}
|
||||
uint ConcGCThreads = 2 {product} {ergonomic}
|
||||
uint G1ConcRefinementThreads = 6 {product} {ergonomic}
|
||||
size_t G1HeapRegionSize = 2097152 {product} {ergonomic}
|
||||
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
|
||||
size_t InitialHeapSize = 268435456 {product} {ergonomic}
|
||||
size_t MarkStackSize = 4194304 {product} {ergonomic}
|
||||
size_t MaxHeapSize = 4286578688 {product} {ergonomic}
|
||||
size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic}
|
||||
size_t MinHeapSize = 8388608 {product} {ergonomic}
|
||||
uintx NonNMethodCodeHeapSize = 5832780 {pd product} {ergonomic}
|
||||
uintx NonProfiledCodeHeapSize = 122912730 {pd product} {ergonomic}
|
||||
uintx ProfiledCodeHeapSize = 122912730 {pd product} {ergonomic}
|
||||
uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic}
|
||||
bool SegmentedCodeCache = true {product} {ergonomic}
|
||||
size_t SoftMaxHeapSize = 4286578688 {manageable} {ergonomic}
|
||||
bool UseCompressedClassPointers = true {product lp64_product} {ergonomic}
|
||||
bool UseCompressedOops = true {product lp64_product} {ergonomic}
|
||||
bool UseG1GC = true {product} {ergonomic}
|
||||
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
|
||||
|
||||
Logging:
|
||||
Log output configuration:
|
||||
#0: stdout all=warning uptime,level,tags
|
||||
#1: stderr all=off uptime,level,tags
|
||||
|
||||
Environment Variables:
|
||||
PATH=C:/Program Files/Git/mingw64/libexec/git-core;C:/Program Files/Git/mingw64/libexec/git-core;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Administrator\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\TortoiseGit\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm
|
||||
USERNAME=Administrator
|
||||
DISPLAY=:0.0
|
||||
LC_ALL=en_US.UTF-8
|
||||
TERM=xterm-256color
|
||||
TMPDIR=C:\Users\Administrator\AppData\Local\Temp
|
||||
OS=Windows_NT
|
||||
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
|
||||
TMP=C:\Users\Administrator\AppData\Local\Temp
|
||||
TEMP=C:\Users\Administrator\AppData\Local\Temp
|
||||
|
||||
|
||||
|
||||
Periodic native trim disabled
|
||||
|
||||
JNI global refs:
|
||||
JNI global refs: 0, weak refs: 0
|
||||
|
||||
JNI global refs memory usage: 0, weak refs: 0
|
||||
|
||||
OOME stack traces (most recent first):
|
||||
Classloader memory used:
|
||||
|
||||
|
||||
--------------- S Y S T E M ---------------
|
||||
|
||||
OS:
|
||||
Windows 10 , 64 bit Build 19041 (10.0.19041.3636)
|
||||
OS uptime: 19 days 19:43 hours
|
||||
|
||||
CPU: total 6 (initial active 6) (6 cores per cpu, 1 threads per core) family 6 model 158 stepping 10 microcode 0xb4, cx8, cmov, fxsr, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, adx, fma, vzeroupper, clflush, clflushopt
|
||||
Processor Information for all 6 processors :
|
||||
Max Mhz: 2904, Current Mhz: 2904, Mhz Limit: 2904
|
||||
|
||||
Memory: 4k page, system-wide physical 16349M (1308M free)
|
||||
TotalPageFile size 35549M (AvailPageFile size 98M)
|
||||
current process WorkingSet (physical memory assigned to process): 10M, peak: 10M
|
||||
current process commit charge ("private bytes"): 56M, peak: 312M
|
||||
|
||||
vm_info: OpenJDK 64-Bit Server VM (17.0.9+7-b1087.9) for windows-amd64 JRE (17.0.9+7-b1087.9), built on 2023-12-05 by "builduser" with MS VC++ 16.10 / 16.11 (VS2019)
|
||||
|
||||
END.
|
||||
|
|
@ -0,0 +1,533 @@
|
|||
<?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>com.sqx</groupId>
|
||||
<artifactId>anmo</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>anmo</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.11</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<mybatisplus.version>3.2.0</mybatisplus.version>
|
||||
<mysql.version>8.0.17</mysql.version>
|
||||
<mssql.version>4.0</mssql.version>
|
||||
<oracle.version>11.2.0.3</oracle.version>
|
||||
<druid.version>1.1.13</druid.version>
|
||||
<quartz.version>2.3.0</quartz.version>
|
||||
<commons.lang.version>2.6</commons.lang.version>
|
||||
<commons.fileupload.version>1.2.2</commons.fileupload.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.codec.version>1.10</commons.codec.version>
|
||||
<commons.configuration.version>1.10</commons.configuration.version>
|
||||
<shiro.version>1.10.1</shiro.version>
|
||||
<jwt.version>0.7.0</jwt.version>
|
||||
<kaptcha.version>0.0.9</kaptcha.version>
|
||||
<qiniu.version>7.2.23</qiniu.version>
|
||||
<aliyun.oss.version>3.4.0</aliyun.oss.version>
|
||||
<qcloud.cos.version>4.4</qcloud.cos.version>
|
||||
<swagger.version>2.7.0</swagger.version>
|
||||
<joda.time.version>2.9.9</joda.time.version>
|
||||
<gson.version>2.8.5</gson.version>
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<hutool.version>5.8.16</hutool.version>
|
||||
<lombok.version>1.18.22</lombok.version>
|
||||
|
||||
<!--wagon plugin 配置-->
|
||||
<!--<service-path>/work/sz</service-path>
|
||||
<pack-name>${project.artifactId}-${project.version}.jar</pack-name>
|
||||
<remote-addr>192.168.1.10:22</remote-addr>
|
||||
<remote-username>root</remote-username>
|
||||
<remote-passwd>123456</remote-passwd>-->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 云呼平台 -->
|
||||
<dependency>
|
||||
<groupId>com.winnerlook</groupId>
|
||||
<artifactId>voice-sdk</artifactId>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--websocket-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
|
||||
<!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
|
||||
<version>3.1.792</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dyplsapi20170525</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dyvmsapi20170525</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gavaghan</groupId>
|
||||
<artifactId>geodesy</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org</groupId>
|
||||
<artifactId>jaudiotagger</artifactId>
|
||||
<version>2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-websocket</artifactId>
|
||||
<version>5.1.2.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
<!-- 苹果工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>jwks-rsa</artifactId>
|
||||
<version>0.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
<!-- excel工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<!-- excel工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.qcloudsms</groupId>
|
||||
<artifactId>qcloudsms</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
<!--阿里云短信-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<!-- 集成支付宝sdk -->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.10.29.ALL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.wxpay</groupId>
|
||||
<artifactId>wxpay-sdk</artifactId>
|
||||
<version>0.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.liyiorg</groupId>
|
||||
<artifactId>weixin-popular</artifactId>
|
||||
<version>2.8.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.springframework.boot</groupId>-->
|
||||
<!--<artifactId>spring-boot-devtools</artifactId>-->
|
||||
<!--<optional>true</optional>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<!--oracle驱动-->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>${oracle.version}</version>
|
||||
</dependency>
|
||||
<!--mssql驱动-->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<version>${mssql.version}</version>
|
||||
</dependency>
|
||||
<!--postgresql驱动-->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>${quartz.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons.lang.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>${commons.fileupload.version}</version>
|
||||
</dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>${commons.configuration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>${shiro.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.axet</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>${qiniu.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
<version>${qcloud.cos.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${joda.time.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--二维码生成架包引用-->
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-mp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-pay</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<groupId>org.mybatis</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.dozermapper</groupId>
|
||||
<artifactId>dozer-core</artifactId>
|
||||
<version>6.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.getui.push</groupId>
|
||||
<artifactId>restful-sdk</artifactId>
|
||||
<version>1.0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.soundlibs/jlayer -->
|
||||
<!-- 音频处理,支持mp3-->
|
||||
<dependency>
|
||||
<groupId>com.googlecode.soundlibs</groupId>
|
||||
<artifactId>jlayer</artifactId>
|
||||
<version>1.0.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.soundlibs</groupId>
|
||||
<artifactId>mp3spi</artifactId>
|
||||
<version>1.9.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.soundlibs</groupId>
|
||||
<artifactId>tritonus-all</artifactId>
|
||||
<version>0.3.7.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.baidu.aip</groupId>-->
|
||||
<!-- <artifactId>java-sdk</artifactId>-->
|
||||
<!-- <version>4.11.3</version>-->
|
||||
<!--</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>2.8</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 跳过单元测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>wagon-maven-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
<!--<configuration>
|
||||
<fromFile>target/${pack-name}</fromFile>
|
||||
<url><![CDATA[scp://${remote-username}:${remote-passwd}@${remote-addr}${service-path}]]></url>
|
||||
<commands>
|
||||
<!– Kill Old Process –>
|
||||
<command>kill -9 `ps -ef |grep ${project.artifactId}.jar|grep -v "grep" |awk '{print $2}'`</command>
|
||||
<command><![CDATA[nohup java -jar ${service-path}/${pack-name} --spring.profiles.active=test > ${service-path}/sz.log 2>&1 & ]]></command>
|
||||
<command><![CDATA[netstat -nptl]]></command>
|
||||
<command><![CDATA[ps -ef | grep java | grep -v grep]]></command>
|
||||
</commands>
|
||||
<!– 运行命令 mvn clean package wagon:upload-single wagon:sshexec–>
|
||||
<displayCommandOutputs>true</displayCommandOutputs>
|
||||
</configuration>-->
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.14</version>
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<phase>package</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>build</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<configuration>
|
||||
<imageName>sqx/fast</imageName>
|
||||
<dockerDirectory>${project.basedir}</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<!-- 运行命令 mvn clean package docker:build 打包并生成docker镜像 -->
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
@echo off && chcp 65001
|
||||
#call mvn clean package
|
||||
for /f "delims=" %%i in ('dir target\*.jar /b ') do @set jarPath=%%i
|
||||
call java -jar -Dfile.encoding=utf-8 -Dspring.profiles.active=dev -Xms1024m -Xmx1536m -XX:PermSize=128M -XX:MaxPermSize=256M target\%jarPath%
|
||||
pause
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
@echo off && title 编译并发布生产环境
|
||||
echo 切换配置文件
|
||||
ren .\src\main\resources\application.yml application.yml.dev
|
||||
ren .\src\main\resources\application.yml.prod application.yml
|
||||
echo 切换完毕,执行打包
|
||||
call mvn clean package
|
||||
echo 打包结束,还原配置文件
|
||||
ren .\src\main\resources\application.yml application.yml.prod
|
||||
ren .\src\main\resources\application.yml.dev application.yml
|
||||
echo 还原完毕,请输入三次密码
|
||||
echo Xrtx*2022
|
||||
echo 按下任意键开始发版
|
||||
pause
|
||||
::先杀进程
|
||||
ssh root@49.232.154.11 "cd /home/springboot/jdbiJava/ && sh killJar.sh"
|
||||
scp ./target/jdyybi-0.0.1.jar root@49.232.154.11:/home/springboot/jdbiJava
|
||||
ssh root@49.232.154.11 "cd /home/springboot/jdbiJava/ && sh run.sh"
|
||||
pause
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
ps -ef | grep anmo.jar | grep -v grep
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
ps -ef | grep anmo.jar | grep -v grep | awk '{print $2}' | xargs kill -9
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
#nohup
|
||||
JAVA_OPTS="-server -Xms400m -Xmx400m -Xmn30m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xverify:none -XX:+DisableExplicitGC -Djava.awt.headless=true"
|
||||
#java $JAVA_OPTS -jar ./jdyybi-0.0.1.jar 1>/dev/null 2>./out.log &
|
||||
nohup java $JAVA_OPTS -jar ./anmo.jar >nohup.log 2>&1 &
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.sqx;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class SqxApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SqxApplication.class, args);
|
||||
log.info("(♥◠‿◠)ノ゙ 按摩项目启动成功 ლ(´ڡ`ლ)゙ \n"+
|
||||
" _ \n" +
|
||||
" | | \n" +
|
||||
" ___ | | __\n" +
|
||||
" / _ \\| |/ /\n" +
|
||||
"| (_) | < \n" +
|
||||
" \\___/|_|\\_\\");
|
||||
System.out.println("swagger访问地址:http://localhost:8187/sqx_fast/doc.html");
|
||||
System.out.println("-------------======= 华丽的分割线 =========----------");
|
||||
//返回Java虚拟机中的堆内存总量
|
||||
long xmsMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
|
||||
//返回Java虚拟机中使用的最大堆内存
|
||||
long xmxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
|
||||
System.out.println("-Xms:" + xmsMemory + "M");
|
||||
System.out.println("-Xmx:" + xmxMemory + "M");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.sqx.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 系统日志注解
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SysLog {
|
||||
|
||||
String value() default "";
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.sqx.common.aspect;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Redis切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Configuration
|
||||
public class RedisAspect {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
//是否开启redis缓存 true开启 false关闭
|
||||
@Value("${spring.redis.open: false}")
|
||||
private boolean open;
|
||||
|
||||
@Around("execution(* com.sqx.common.utils.RedisUtils.*(..))")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
Object result = null;
|
||||
if(open){
|
||||
try{
|
||||
result = point.proceed();
|
||||
}catch (Exception e){
|
||||
logger.error("redis error", e);
|
||||
throw new SqxException("Redis服务异常");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.sqx.common.aspect;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.sqx.common.utils.HttpContextUtils;
|
||||
import com.sqx.common.utils.IPUtils;
|
||||
import com.sqx.common.annotation.SysLog;
|
||||
import com.sqx.modules.sys.entity.SysLogEntity;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.modules.sys.service.SysLogService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 系统日志,切面处理类
|
||||
*
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class SysLogAspect {
|
||||
@Autowired
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@Pointcut("@annotation(com.sqx.common.annotation.SysLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("logPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime;
|
||||
|
||||
//保存日志
|
||||
saveSysLog(point, time);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
SysLogEntity sysLog = new SysLogEntity();
|
||||
SysLog syslog = method.getAnnotation(SysLog.class);
|
||||
if(syslog != null){
|
||||
//注解上的描述
|
||||
sysLog.setOperation(syslog.value());
|
||||
}
|
||||
|
||||
//请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = signature.getName();
|
||||
sysLog.setMethod(className + "." + methodName + "()");
|
||||
|
||||
//请求的参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
try{
|
||||
String params = new Gson().toJson(args);
|
||||
sysLog.setParams(params);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
//获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request));
|
||||
|
||||
//用户名
|
||||
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||
sysLog.setUsername(username);
|
||||
|
||||
sysLog.setTime(time);
|
||||
sysLog.setCreateDate(new Date());
|
||||
//保存系统日志
|
||||
sysLogService.save(sysLog);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.sqx.common.exception;
|
||||
|
||||
/**
|
||||
* 自定义异常
|
||||
*
|
||||
*/
|
||||
public class SqxException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String msg;
|
||||
private int code = 500;
|
||||
|
||||
public SqxException(String msg) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public SqxException(String msg, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public SqxException(String msg, int code) {
|
||||
super(msg);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public SqxException(String msg, int code, Throwable e) {
|
||||
super(msg, e);
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.common.exception;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* 异常处理器
|
||||
*
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class SqxExceptionHandler {
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(SqxException.class)
|
||||
public Result handleException(SqxException e){
|
||||
Result r = new Result();
|
||||
r.put("code", e.getCode());
|
||||
r.put("msg", e.getMessage());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public Result handlerNoFoundException(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error(404, "路径不存在,请检查路径是否正确");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public Result handleDuplicateKeyException(DuplicateKeyException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error("数据库中已存在该记录");
|
||||
}
|
||||
|
||||
@ExceptionHandler(AuthorizationException.class)
|
||||
public Result handleAuthorizationException(AuthorizationException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public Result handleException(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
/**
|
||||
* 系统参数相关Key
|
||||
*
|
||||
*/
|
||||
public class ConfigConstant {
|
||||
/**
|
||||
* 云存储配置KEY
|
||||
*/
|
||||
public final static String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY";
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
*
|
||||
*/
|
||||
public class Constant {
|
||||
/** 超级管理员ID */
|
||||
public static final int SUPER_ADMIN = 1;
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
public static final String PAGE = "page";
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String LIMIT = "limit";
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
public static final String ORDER_FIELD = "sidx";
|
||||
/**
|
||||
* 排序方式
|
||||
*/
|
||||
public static final String ORDER = "order";
|
||||
/**
|
||||
* 升序
|
||||
*/
|
||||
public static final String ASC = "asc";
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
public enum MenuType {
|
||||
/**
|
||||
* 目录
|
||||
*/
|
||||
CATALOG(0),
|
||||
/**
|
||||
* 菜单
|
||||
*/
|
||||
MENU(1),
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
BUTTON(2);
|
||||
|
||||
private int value;
|
||||
|
||||
MenuType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务状态
|
||||
*/
|
||||
public enum ScheduleStatus {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL(0),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE(1);
|
||||
|
||||
private int value;
|
||||
|
||||
ScheduleStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 云服务商
|
||||
*/
|
||||
public enum CloudService {
|
||||
/**
|
||||
* 七牛云
|
||||
*/
|
||||
QINIU(1),
|
||||
/**
|
||||
* 阿里云
|
||||
*/
|
||||
ALIYUN(2),
|
||||
/**
|
||||
* 腾讯云
|
||||
*/
|
||||
QCLOUD(3);
|
||||
|
||||
private int value;
|
||||
|
||||
CloudService(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 日期处理
|
||||
*
|
||||
*/
|
||||
public class DateUtils {
|
||||
/** 时间格式(yyyy-MM-dd) */
|
||||
public final static String DATE_PATTERN = "yyyy-MM-dd";
|
||||
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
|
||||
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date) {
|
||||
return format(date, DATE_TIME_PATTERN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期格式化 日期格式为:yyyy-MM-dd
|
||||
* @param date 日期
|
||||
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
* @return 返回yyyy-MM-dd格式日期
|
||||
*/
|
||||
public static String format(Date date, String pattern) {
|
||||
if(date != null){
|
||||
SimpleDateFormat df = new SimpleDateFormat(pattern);
|
||||
return df.format(date);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换成日期
|
||||
* @param strDate 日期字符串
|
||||
* @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN
|
||||
*/
|
||||
public static Date stringToDate(String strDate, String pattern) {
|
||||
if (StringUtils.isBlank(strDate)){
|
||||
return null;
|
||||
}
|
||||
|
||||
DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
|
||||
return fmt.parseLocalDateTime(strDate).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据周数,获取开始日期、结束日期
|
||||
* @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周
|
||||
* @return 返回date[0]开始日期、date[1]结束日期
|
||||
*/
|
||||
public static Date[] getWeekStartAndEnd(int week) {
|
||||
DateTime dateTime = new DateTime();
|
||||
LocalDate date = new LocalDate(dateTime.plusWeeks(week));
|
||||
|
||||
date = date.dayOfWeek().withMinimumValue();
|
||||
Date beginDate = date.toDate();
|
||||
Date endDate = date.plusDays(6).toDate();
|
||||
return new Date[]{beginDate, endDate};
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【秒】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param seconds 秒数,负数为减
|
||||
* @return 加/减几秒后的日期
|
||||
*/
|
||||
public static Date addDateSeconds(Date date, int seconds) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusSeconds(seconds).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【分钟】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param minutes 分钟数,负数为减
|
||||
* @return 加/减几分钟后的日期
|
||||
*/
|
||||
public static Date addDateMinutes(Date date, int minutes) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMinutes(minutes).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【小时】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param hours 小时数,负数为减
|
||||
* @return 加/减几小时后的日期
|
||||
*/
|
||||
public static Date addDateHours(Date date, int hours) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusHours(hours).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【天】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param days 天数,负数为减
|
||||
* @return 加/减几天后的日期
|
||||
*/
|
||||
public static Date addDateDays(Date date, int days) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusDays(days).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【周】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param weeks 周数,负数为减
|
||||
* @return 加/减几周后的日期
|
||||
*/
|
||||
public static Date addDateWeeks(Date date, int weeks) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusWeeks(weeks).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【月】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param months 月数,负数为减
|
||||
* @return 加/减几月后的日期
|
||||
*/
|
||||
public static Date addDateMonths(Date date, int months) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusMonths(months).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对日期的【年】进行加/减
|
||||
*
|
||||
* @param date 日期
|
||||
* @param years 年数,负数为减
|
||||
* @return 加/减几年后的日期
|
||||
*/
|
||||
public static Date addDateYears(Date date, int years) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime.plusYears(years).toDate();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class HttpContextUtils {
|
||||
|
||||
public static HttpServletRequest getHttpServletRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
|
||||
public static String getDomain(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
StringBuffer url = request.getRequestURL();
|
||||
return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
|
||||
}
|
||||
|
||||
public static String getOrigin(){
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
return request.getHeader("Origin");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*
|
||||
*/
|
||||
public class IPUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
*
|
||||
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
|
||||
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = null;
|
||||
try {
|
||||
ip = request.getHeader("x-forwarded-for");
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("IPUtils ERROR ", e);
|
||||
}
|
||||
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ListUtils {
|
||||
/**
|
||||
* list 集合分组
|
||||
*
|
||||
* @param list 待分组集合
|
||||
* @param groupBy 分组Key算法
|
||||
* @param <K> 分组Key类型
|
||||
* @param <V> 行数据类型
|
||||
* @return 分组后的Map集合
|
||||
*/
|
||||
public static <K, V> Map<K, List<V>> groupBy(List<V> list, GroupBy<K, V> groupBy) {
|
||||
return groupBy((Collection<V>) list, groupBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* list 集合分组
|
||||
*
|
||||
* @param list 待分组集合
|
||||
* @param groupBy 分组Key算法
|
||||
* @param <K> 分组Key类型
|
||||
* @param <V> 行数据类型
|
||||
* @return 分组后的Map集合
|
||||
*/
|
||||
public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, GroupBy<K, V> groupBy) {
|
||||
Map<K, List<V>> resultMap = new LinkedHashMap<K, List<V>>();
|
||||
|
||||
for (V e : list) {
|
||||
|
||||
K k = groupBy.groupBy(e);
|
||||
if (resultMap.containsKey(k)) {
|
||||
resultMap.get(k).add(e);
|
||||
} else {
|
||||
List<V> tmp = new LinkedList<V>();
|
||||
tmp.add(e);
|
||||
resultMap.put(k, tmp);
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* List分组
|
||||
*
|
||||
* @param <K> 返回分组Key
|
||||
* @param <V> 分组行
|
||||
*/
|
||||
public interface GroupBy<K, V> {
|
||||
K groupBy(V row);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
* Map工具类
|
||||
*
|
||||
*/
|
||||
public class MapUtils extends HashMap<String, Object> {
|
||||
|
||||
@Override
|
||||
public MapUtils put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
*
|
||||
*/
|
||||
public class PageUtils implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private int totalCount;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int totalPage;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int currPage;
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> list;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param list 列表数据
|
||||
* @param totalCount 总记录数
|
||||
* @param pageSize 每页记录数
|
||||
* @param currPage 当前页数
|
||||
*/
|
||||
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||
this.list = list;
|
||||
this.totalCount = totalCount;
|
||||
this.pageSize = pageSize;
|
||||
this.currPage = currPage;
|
||||
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageUtils(IPage<?> page) {
|
||||
this.list = page.getRecords();
|
||||
this.totalCount = (int)page.getTotal();
|
||||
this.pageSize = (int)page.getSize();
|
||||
this.currPage = (int)page.getCurrent();
|
||||
this.totalPage = (int)page.getPages();
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public int getCurrPage() {
|
||||
return currPage;
|
||||
}
|
||||
|
||||
public void setCurrPage(int currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import cn.hutool.extra.qrcode.BufferedImageLuminanceSource;
|
||||
import com.google.zxing.*;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* 二维码生成解析工具类
|
||||
|
||||
* @date 2020/02/12 09:37
|
||||
*/
|
||||
public class QRCodeUtil {
|
||||
|
||||
//编码格式,采用utf-8
|
||||
private static final String UNICODE = "utf-8";
|
||||
//图片格式
|
||||
private static final String FORMAT = "JPG";
|
||||
//二维码宽度,单位:像素pixels
|
||||
private static final int QRCODE_WIDTH = 300;
|
||||
//二维码高度,单位:像素pixels
|
||||
private static final int QRCODE_HEIGHT = 300;
|
||||
//LOGO宽度,单位:像素pixels
|
||||
private static final int LOGO_WIDTH = 100;
|
||||
//LOGO高度,单位:像素pixels
|
||||
private static final int LOGO_HEIGHT = 100;
|
||||
|
||||
/**
|
||||
* 生成二维码图片
|
||||
* @param content 二维码内容
|
||||
* @param logoPath 图片地址
|
||||
* @param needCompress 是否压缩
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static BufferedImage createImage(String content, String logoPath, boolean needCompress) throws Exception {
|
||||
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, UNICODE);
|
||||
hints.put(EncodeHintType.MARGIN, 1);
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_WIDTH, QRCODE_HEIGHT,
|
||||
hints);
|
||||
int width = bitMatrix.getWidth();
|
||||
int height = bitMatrix.getHeight();
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
if (logoPath == null || "".equals(logoPath)) {
|
||||
return image;
|
||||
}
|
||||
// 插入图片
|
||||
QRCodeUtil.insertImage(image, logoPath, needCompress);
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入LOGO
|
||||
* @param source 二维码图片
|
||||
* @param logoPath LOGO图片地址
|
||||
* @param needCompress 是否压缩
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void insertImage(BufferedImage source, String logoPath, boolean needCompress) throws Exception {
|
||||
File file = new File(logoPath);
|
||||
if (!file.exists()) {
|
||||
throw new Exception("logo file not found.");
|
||||
}
|
||||
Image src = ImageIO.read(new File(logoPath));
|
||||
int width = src.getWidth(null);
|
||||
int height = src.getHeight(null);
|
||||
if (needCompress) { // 压缩LOGO
|
||||
if (width > LOGO_WIDTH) {
|
||||
width = LOGO_WIDTH;
|
||||
}
|
||||
if (height > LOGO_HEIGHT) {
|
||||
height = LOGO_HEIGHT;
|
||||
}
|
||||
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics g = tag.getGraphics();
|
||||
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
|
||||
g.dispose();
|
||||
src = image;
|
||||
}
|
||||
// 插入LOGO
|
||||
Graphics2D graph = source.createGraphics();
|
||||
int x = (QRCODE_WIDTH - width) / 2;
|
||||
int y = (QRCODE_HEIGHT - height) / 2;
|
||||
graph.drawImage(src, x, y, width, height, null);
|
||||
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
|
||||
graph.setStroke(new BasicStroke(3f));
|
||||
graph.draw(shape);
|
||||
graph.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码(内嵌LOGO)
|
||||
* 调用者指定二维码文件名
|
||||
* @param content 二维码的内容
|
||||
* @param logoPath 中间图片地址
|
||||
* @param destPath 存储路径
|
||||
* @param fileName 文件名称
|
||||
* @param needCompress 是否压缩
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encode(String content, String logoPath, String destPath, String fileName, boolean needCompress) throws Exception {
|
||||
BufferedImage image = QRCodeUtil.createImage(content, logoPath, needCompress);
|
||||
mkdirs(destPath);
|
||||
//文件名称通过传递
|
||||
fileName = fileName.substring(0, fileName.indexOf(".")>0?fileName.indexOf("."):fileName.length())
|
||||
+ "." + FORMAT.toLowerCase();
|
||||
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件夹, mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
|
||||
* @param destPath
|
||||
*/
|
||||
public static void mkdirs(String destPath) {
|
||||
File file = new File(destPath);
|
||||
if (!file.exists() && !file.isDirectory()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析二维码
|
||||
* @param path 二维码图片路径
|
||||
* @return String 二维码内容
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decode(String path) throws Exception {
|
||||
File file = new File(path);
|
||||
BufferedImage image = ImageIO.read(file);
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image);
|
||||
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||
Result result;
|
||||
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
|
||||
hints.put(DecodeHintType.CHARACTER_SET, UNICODE);
|
||||
result = new MultiFormatReader().decode(bitmap, hints);
|
||||
return result.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
String text = "http://47.105.101.72:8088";
|
||||
//不含Logo
|
||||
// QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true);
|
||||
//含Logo,指定二维码图片名
|
||||
QRCodeUtil.encode(text, "/Users/kyson/Downloads/宋康.jpg", "/Users/kyson/Downloads", "qrcode1", true);
|
||||
// System.out.println(QRCodeUtil.decode("d:\\cc\\qrcode1.jpg"));
|
||||
// System.out.println(QRCodeUtil.encode(text, null, "/Users/kyson/Downloads", "qrcode", true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.xss.SQLFilter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
*/
|
||||
public class Query<T> {
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params) {
|
||||
return this.getPage(params, null, false);
|
||||
}
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) {
|
||||
//分页参数
|
||||
long curPage = 1;
|
||||
long limit = 10;
|
||||
|
||||
if(params.get(Constant.PAGE) != null){
|
||||
curPage = Long.parseLong(String.valueOf(params.get(Constant.PAGE)));
|
||||
}
|
||||
if(params.get(Constant.LIMIT) != null){
|
||||
limit = Long.parseLong(String.valueOf(params.get(Constant.LIMIT)));
|
||||
}
|
||||
|
||||
//分页对象
|
||||
Page<T> page = new Page<>(curPage, limit);
|
||||
|
||||
//分页参数
|
||||
params.put(Constant.PAGE, page);
|
||||
|
||||
//排序字段
|
||||
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
|
||||
String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD));
|
||||
String order = (String)params.get(Constant.ORDER);
|
||||
|
||||
|
||||
//前端字段排序
|
||||
if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
|
||||
if(Constant.ASC.equalsIgnoreCase(order)) {
|
||||
return page.addOrder(OrderItem.asc(orderField));
|
||||
}else {
|
||||
return page.addOrder(OrderItem.desc(orderField));
|
||||
}
|
||||
}
|
||||
|
||||
//没有排序字段,则不排序
|
||||
if(StringUtils.isBlank(defaultOrderField)){
|
||||
return page;
|
||||
}
|
||||
|
||||
//默认排序
|
||||
if(isAsc) {
|
||||
page.addOrder(OrderItem.asc(defaultOrderField));
|
||||
}else {
|
||||
page.addOrder(OrderItem.desc(defaultOrderField));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
/**
|
||||
* Redis所有Keys
|
||||
*
|
||||
*/
|
||||
public class RedisKeys {
|
||||
|
||||
public static String getSysConfigKey(String key){
|
||||
return "sys:config:" + key;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Redis工具类
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class RedisUtils {
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
@Autowired
|
||||
private HashOperations<String, String, Object> hashOperations;
|
||||
@Autowired
|
||||
private ListOperations<String, Object> listOperations;
|
||||
@Autowired
|
||||
private SetOperations<String, Object> setOperations;
|
||||
@Autowired
|
||||
private ZSetOperations<String, Object> zSetOperations;
|
||||
/** 默认过期时长,单位:秒 */
|
||||
public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
|
||||
/** 不设置过期时长 */
|
||||
public final static long NOT_EXPIRE = -1;
|
||||
private final static Gson Gson = new Gson();
|
||||
|
||||
public void set(String key, Object value, long expire){
|
||||
valueOperations.set(key, toJson(value));
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(String key, Object value){
|
||||
set(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value == null ? null : fromJson(value, clazz);
|
||||
}
|
||||
|
||||
public <T> T get(String key, Class<T> clazz) {
|
||||
return get(key, clazz, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public String get(String key, long expire) {
|
||||
String value = valueOperations.get(key);
|
||||
if(expire != NOT_EXPIRE){
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return get(key, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public Set<String> keys(String key){
|
||||
return redisTemplate.keys(key);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Object转成JSON数据
|
||||
*/
|
||||
private String toJson(Object object){
|
||||
if(object instanceof Integer || object instanceof Long || object instanceof Float ||
|
||||
object instanceof Double || object instanceof Boolean || object instanceof String){
|
||||
return String.valueOf(object);
|
||||
}
|
||||
return Gson.toJson(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON数据,转成Object
|
||||
*/
|
||||
private <T> T fromJson(String json, Class<T> clazz){
|
||||
return Gson.fromJson(json, clazz);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
*/
|
||||
public class Result extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Result () {
|
||||
put("code", 0);
|
||||
put("msg", "success");
|
||||
}
|
||||
|
||||
public static Result error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static Result error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
public static Result error(int code, String msg) {
|
||||
Result r = new Result();
|
||||
r.put("code", code);
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success(String msg) {
|
||||
Result r = new Result();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success(Map<String, Object> map) {
|
||||
Result r = new Result();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result success() {
|
||||
return new Result();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
/**
|
||||
* Shiro工具类
|
||||
*
|
||||
*/
|
||||
public class ShiroUtils {
|
||||
|
||||
public static Session getSession() {
|
||||
return SecurityUtils.getSubject().getSession();
|
||||
}
|
||||
|
||||
public static Subject getSubject() {
|
||||
return SecurityUtils.getSubject();
|
||||
}
|
||||
|
||||
public static SysUserEntity getUserEntity() {
|
||||
return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
public static Long getUserId() {
|
||||
return getUserEntity().getUserId();
|
||||
}
|
||||
|
||||
public static void setSessionAttribute(Object key, Object value) {
|
||||
getSession().setAttribute(key, value);
|
||||
}
|
||||
|
||||
public static Object getSessionAttribute(Object key) {
|
||||
return getSession().getAttribute(key);
|
||||
}
|
||||
|
||||
public static boolean isLogin() {
|
||||
return SecurityUtils.getSubject().getPrincipal() != null;
|
||||
}
|
||||
|
||||
public static String getKaptcha(String key) {
|
||||
Object kaptcha = getSessionAttribute(key);
|
||||
if(kaptcha == null){
|
||||
throw new SqxException("验证码已失效");
|
||||
}
|
||||
getSession().removeAttribute(key);
|
||||
return kaptcha.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Spring Context 工具类
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SpringContextUtils implements ApplicationContextAware {
|
||||
public static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
SpringContextUtils.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static Object getBean(String name) {
|
||||
return applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> requiredType) {
|
||||
return applicationContext.getBean(name, requiredType);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return applicationContext.getBean(clazz);
|
||||
}
|
||||
|
||||
public static boolean containsBean(String name) {
|
||||
return applicationContext.containsBean(name);
|
||||
}
|
||||
|
||||
public static boolean isSingleton(String name) {
|
||||
return applicationContext.isSingleton(name);
|
||||
}
|
||||
|
||||
public static Class<? extends Object> getType(String name) {
|
||||
return applicationContext.getType(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.sqx.common.validator;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据校验
|
||||
*
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
public static void isBlank(String str, String message) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
throw new SqxException(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(Object object, String message) {
|
||||
if (object == null) {
|
||||
throw new SqxException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sqx.common.validator;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
|
||||
|
||||
|
||||
public class ValidatorUtils {
|
||||
|
||||
|
||||
public static void validateEntity(Object object, Class<?>... groups)
|
||||
throws SqxException {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 新增数据 Group
|
||||
*
|
||||
*/
|
||||
public interface AddGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 阿里云
|
||||
*
|
||||
*/
|
||||
public interface AliyunGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 腾讯云
|
||||
*
|
||||
*/
|
||||
public interface QcloudGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 七牛
|
||||
*
|
||||
*/
|
||||
public interface QiniuGroup {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.sqx.common.validator.group;
|
||||
|
||||
/**
|
||||
* 更新数据 Group
|
||||
*
|
||||
*/
|
||||
|
||||
public interface UpdateGroup {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.sqx.common.websocket;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @description:WebSocketMessage
|
||||
* @author:zc.
|
||||
* @createData:2024-1-10 下午 4:21
|
||||
* @projectName:anmo
|
||||
* @className:WebSocketMessage
|
||||
* @packageName:com.sqx.websocket
|
||||
*/
|
||||
@Data
|
||||
public class WebSocketMessage {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String fromId;
|
||||
|
||||
/**
|
||||
* 对方ID
|
||||
*/
|
||||
private String toOtherId;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
public Date date;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
package com.sqx.common.websocket;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.sqx.modules.artificer.dao.ArtificerDao;
|
||||
import com.sqx.modules.artificer.dao.UserRechargeDao;
|
||||
import com.sqx.modules.artificer.entity.Artificer;
|
||||
import com.sqx.modules.artificer.entity.UserRecharge;
|
||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* @description:WebSocketServer 操作类
|
||||
* @author:zc.
|
||||
* @createData:2024-1-10 下午 4:21
|
||||
* @projectName:anmo
|
||||
* @className:WebSocketServer
|
||||
* @packageName:com.sqx.websocket
|
||||
*/
|
||||
@ServerEndpoint("/ws/{userId}")
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WebSocketServer {
|
||||
|
||||
@Autowired
|
||||
private ArtificerDao artificerDao;
|
||||
@Autowired
|
||||
private UserRechargeDao userRechargeDao;
|
||||
@Autowired
|
||||
private CommonInfoDao commonInfoDao;
|
||||
//静态初始化
|
||||
public static WebSocketServer webSocketServer;
|
||||
|
||||
//保证Bean初始化前已经装配了属性
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
webSocketServer = this;
|
||||
}
|
||||
|
||||
// 与某个客户端的连接会话,需要通过它来给客户端发送数据
|
||||
private String userId;
|
||||
|
||||
|
||||
// session集合,存放对应的session
|
||||
private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
|
||||
// concurrent包的线程安全Set,用来存放每个客户端对应的WebSocket对象。
|
||||
private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<>();
|
||||
|
||||
/**
|
||||
* 建立WebSocket连接
|
||||
*
|
||||
* @param session
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam(value = "userId") String userId) {
|
||||
log.info("WebSocket建立连接中,连接用户ID:{}", userId);
|
||||
try {
|
||||
Session historySession = sessionPool.get(userId);
|
||||
// historySession不为空,说明已经有人登陆账号,应该删除登陆的WebSocket对象
|
||||
if (historySession != null) {
|
||||
webSocketSet.remove(historySession);
|
||||
historySession.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("重复登录异常,错误信息:" + e.getMessage(), e);
|
||||
}
|
||||
// 建立连接
|
||||
this.userId = userId;
|
||||
webSocketSet.add(this);
|
||||
sessionPool.put(userId, session);
|
||||
log.info("建立连接完成,当前在线人数为:{}", webSocketSet.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发生错误
|
||||
*
|
||||
* @param throwable e
|
||||
*/
|
||||
@OnError
|
||||
public void onError(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接关闭
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose() {
|
||||
turnOffTheGoLive(this.userId);
|
||||
webSocketSet.remove(this);
|
||||
sessionPool.remove(this.userId);
|
||||
log.info("连接断开,当前在线人数为:{}", webSocketSet.size());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 技师在线强制退出应用,改为离线状态
|
||||
*
|
||||
* @param userId 技师id
|
||||
*/
|
||||
public void turnOffTheGoLive(String userId) {
|
||||
Artificer artificer = webSocketServer.artificerDao.selectOne(Wrappers.<Artificer>lambdaUpdate().eq(Artificer::getUserId, userId));
|
||||
Artificer artificerUpd = new Artificer();
|
||||
artificerUpd.setStatus(2);
|
||||
artificerUpd.setArtificerId(artificer.getArtificerId());
|
||||
webSocketServer.artificerDao.updateById(artificerUpd);
|
||||
|
||||
Integer i = Integer.valueOf(webSocketServer.commonInfoDao.findOne(100000).getValue());
|
||||
Date upTime = artificer.getUpTime();
|
||||
long betweenDay = DateUtil.between(upTime, new Date(), DateUnit.MINUTE);
|
||||
int i1 = new Long(betweenDay).intValue();
|
||||
int count = i1 / i;
|
||||
for (int i2 = 0; i2 < count; i2++) {
|
||||
UserRecharge userRecharge = new UserRecharge();
|
||||
userRecharge.setArtificerId(artificer.getArtificerId().intValue());
|
||||
userRecharge.setUserRecharge(new BigDecimal("1"));
|
||||
userRecharge.setType("1");
|
||||
upTime = DateUtil.offsetMinute(upTime, i);
|
||||
userRecharge.setCreateTime(upTime.toString());
|
||||
webSocketServer.userRechargeDao.insert(userRecharge);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,526 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* HTML filtering utility for protecting against XSS (Cross Site Scripting).
|
||||
*
|
||||
* This code is licensed LGPLv3
|
||||
*
|
||||
* This code is a Java port of the original work in PHP by Cal Hendersen.
|
||||
* http://code.iamcal.com/php/lib_filter/
|
||||
*
|
||||
* The trickiest part of the translation was handling the differences in regex handling
|
||||
* between PHP and Java. These resources were helpful in the process:
|
||||
*
|
||||
* http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
|
||||
* http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php
|
||||
* http://www.regular-expressions.info/modifiers.html
|
||||
*
|
||||
* A note on naming conventions: instance variables are prefixed with a "v"; global
|
||||
* constants are in all caps.
|
||||
*
|
||||
* Sample use:
|
||||
* String input = ...
|
||||
* String clean = new HTMLFilter().filter( input );
|
||||
*
|
||||
* The class is not thread safe. Create a new instance if in doubt.
|
||||
*
|
||||
* If you find bugs or have suggestions on improvement (especially regarding
|
||||
* performance), please contact us. The latest version of this
|
||||
* source, and our contact details, can be found at http://xss-html-filter.sf.net
|
||||
*
|
||||
* @author Joseph O'Connell
|
||||
* @author Cal Hendersen
|
||||
* @author Michael Semb Wever
|
||||
*/
|
||||
public final class HTMLFilter {
|
||||
|
||||
/** regex flag union representing /si modifiers in php **/
|
||||
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
|
||||
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
|
||||
private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL);
|
||||
private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI);
|
||||
private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?");
|
||||
private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?");
|
||||
private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?");
|
||||
private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))");
|
||||
private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL);
|
||||
private static final Pattern P_END_ARROW = Pattern.compile("^>");
|
||||
private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)");
|
||||
private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)");
|
||||
private static final Pattern P_AMP = Pattern.compile("&");
|
||||
private static final Pattern P_QUOTE = Pattern.compile("<");
|
||||
private static final Pattern P_LEFT_ARROW = Pattern.compile("<");
|
||||
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
|
||||
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
|
||||
|
||||
// @xxx could grow large... maybe use sesat's ReferenceMap
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>();
|
||||
|
||||
/** set of allowed html elements, along with allowed attributes for each element **/
|
||||
private final Map<String, List<String>> vAllowed;
|
||||
/** counts of open tags for each (allowable) html element **/
|
||||
private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>();
|
||||
|
||||
/** html elements which must always be self-closing (e.g. "<img />") **/
|
||||
private final String[] vSelfClosingTags;
|
||||
/** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/
|
||||
private final String[] vNeedClosingTags;
|
||||
/** set of disallowed html elements **/
|
||||
private final String[] vDisallowed;
|
||||
/** attributes which should be checked for valid protocols **/
|
||||
private final String[] vProtocolAtts;
|
||||
/** allowed protocols **/
|
||||
private final String[] vAllowedProtocols;
|
||||
/** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/
|
||||
private final String[] vRemoveBlanks;
|
||||
/** entities allowed within html markup **/
|
||||
private final String[] vAllowedEntities;
|
||||
/** flag determining whether comments are allowed in input String. */
|
||||
private final boolean stripComment;
|
||||
private final boolean encodeQuotes;
|
||||
private boolean vDebug = false;
|
||||
/**
|
||||
* flag determining whether to try to make tags when presented with "unbalanced"
|
||||
* angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false,
|
||||
* unbalanced angle brackets will be html escaped.
|
||||
*/
|
||||
private final boolean alwaysMakeTags;
|
||||
|
||||
/** Default constructor.
|
||||
*
|
||||
*/
|
||||
public HTMLFilter() {
|
||||
vAllowed = new HashMap<>();
|
||||
|
||||
final ArrayList<String> a_atts = new ArrayList<String>();
|
||||
a_atts.add("href");
|
||||
a_atts.add("target");
|
||||
vAllowed.put("a", a_atts);
|
||||
|
||||
final ArrayList<String> img_atts = new ArrayList<String>();
|
||||
img_atts.add("src");
|
||||
img_atts.add("width");
|
||||
img_atts.add("height");
|
||||
img_atts.add("alt");
|
||||
vAllowed.put("img", img_atts);
|
||||
|
||||
final ArrayList<String> no_atts = new ArrayList<String>();
|
||||
vAllowed.put("b", no_atts);
|
||||
vAllowed.put("strong", no_atts);
|
||||
vAllowed.put("i", no_atts);
|
||||
vAllowed.put("em", no_atts);
|
||||
|
||||
vSelfClosingTags = new String[]{"img"};
|
||||
vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vDisallowed = new String[]{};
|
||||
vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
|
||||
vProtocolAtts = new String[]{"src", "href"};
|
||||
vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
|
||||
vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
|
||||
stripComment = true;
|
||||
encodeQuotes = true;
|
||||
alwaysMakeTags = true;
|
||||
}
|
||||
|
||||
/** Set debug flag to true. Otherwise use default settings. See the default constructor.
|
||||
*
|
||||
* @param debug turn debug on with a true argument
|
||||
*/
|
||||
public HTMLFilter(final boolean debug) {
|
||||
this();
|
||||
vDebug = debug;
|
||||
|
||||
}
|
||||
|
||||
/** Map-parameter configurable constructor.
|
||||
*
|
||||
* @param conf map containing configuration. keys match field names.
|
||||
*/
|
||||
public HTMLFilter(final Map<String,Object> conf) {
|
||||
|
||||
assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
|
||||
assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
|
||||
assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags";
|
||||
assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed";
|
||||
assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols";
|
||||
assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts";
|
||||
assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks";
|
||||
assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities";
|
||||
|
||||
vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed"));
|
||||
vSelfClosingTags = (String[]) conf.get("vSelfClosingTags");
|
||||
vNeedClosingTags = (String[]) conf.get("vNeedClosingTags");
|
||||
vDisallowed = (String[]) conf.get("vDisallowed");
|
||||
vAllowedProtocols = (String[]) conf.get("vAllowedProtocols");
|
||||
vProtocolAtts = (String[]) conf.get("vProtocolAtts");
|
||||
vRemoveBlanks = (String[]) conf.get("vRemoveBlanks");
|
||||
vAllowedEntities = (String[]) conf.get("vAllowedEntities");
|
||||
stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true;
|
||||
encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true;
|
||||
alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
vTagCounts.clear();
|
||||
}
|
||||
|
||||
private void debug(final String msg) {
|
||||
if (vDebug) {
|
||||
Logger.getAnonymousLogger().info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// my versions of some PHP library functions
|
||||
public static String chr(final int decimal) {
|
||||
return String.valueOf((char) decimal);
|
||||
}
|
||||
|
||||
public static String htmlSpecialChars(final String s) {
|
||||
String result = s;
|
||||
result = regexReplace(P_AMP, "&", result);
|
||||
result = regexReplace(P_QUOTE, """, result);
|
||||
result = regexReplace(P_LEFT_ARROW, "<", result);
|
||||
result = regexReplace(P_RIGHT_ARROW, ">", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
/**
|
||||
* given a user submitted input String, filter out any invalid or restricted
|
||||
* html.
|
||||
*
|
||||
* @param input text (i.e. submitted by a user) than may contain html
|
||||
* @return "clean" version of input, with only valid, whitelisted html elements allowed
|
||||
*/
|
||||
public String filter(final String input) {
|
||||
reset();
|
||||
String s = input;
|
||||
|
||||
debug("************************************************");
|
||||
debug(" INPUT: " + input);
|
||||
|
||||
s = escapeComments(s);
|
||||
debug(" escapeComments: " + s);
|
||||
|
||||
s = balanceHTML(s);
|
||||
debug(" balanceHTML: " + s);
|
||||
|
||||
s = checkTags(s);
|
||||
debug(" checkTags: " + s);
|
||||
|
||||
s = processRemoveBlanks(s);
|
||||
debug("processRemoveBlanks: " + s);
|
||||
|
||||
s = validateEntities(s);
|
||||
debug(" validateEntites: " + s);
|
||||
|
||||
debug("************************************************\n\n");
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean isAlwaysMakeTags(){
|
||||
return alwaysMakeTags;
|
||||
}
|
||||
|
||||
public boolean isStripComments(){
|
||||
return stripComment;
|
||||
}
|
||||
|
||||
private String escapeComments(final String s) {
|
||||
final Matcher m = P_COMMENTS.matcher(s);
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
if (m.find()) {
|
||||
final String match = m.group(1); //(.*?)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
private String balanceHTML(String s) {
|
||||
if (alwaysMakeTags) {
|
||||
//
|
||||
// try and form html
|
||||
//
|
||||
s = regexReplace(P_END_ARROW, "", s);
|
||||
s = regexReplace(P_BODY_TO_END, "<$1>", s);
|
||||
s = regexReplace(P_XML_CONTENT, "$1<$2", s);
|
||||
|
||||
} else {
|
||||
//
|
||||
// escape stray brackets
|
||||
//
|
||||
s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s);
|
||||
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s);
|
||||
|
||||
//
|
||||
// the last regexp causes '<>' entities to appear
|
||||
// (we need to do a lookahead assertion so that the last bracket can
|
||||
// be used in the next pass of the regexp)
|
||||
//
|
||||
s = regexReplace(P_BOTH_ARROWS, "", s);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String checkTags(String s) {
|
||||
Matcher m = P_TAGS.matcher(s);
|
||||
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
while (m.find()) {
|
||||
String replaceStr = m.group(1);
|
||||
replaceStr = processTag(replaceStr);
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
s = buf.toString();
|
||||
|
||||
// these get tallied in processTag
|
||||
// (remember to reset before subsequent calls to filter method)
|
||||
for (String key : vTagCounts.keySet()) {
|
||||
for (int ii = 0; ii < vTagCounts.get(key); ii++) {
|
||||
s += "</" + key + ">";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String processRemoveBlanks(final String s) {
|
||||
String result = s;
|
||||
for (String tag : vRemoveBlanks) {
|
||||
if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
|
||||
if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){
|
||||
P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
|
||||
}
|
||||
result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) {
|
||||
Matcher m = regex_pattern.matcher(s);
|
||||
return m.replaceAll(replacement);
|
||||
}
|
||||
|
||||
private String processTag(final String s) {
|
||||
// ending tags
|
||||
Matcher m = P_END_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
if (allowed(name)) {
|
||||
if (!inArray(name, vSelfClosingTags)) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) - 1);
|
||||
return "</" + name + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// starting tags
|
||||
m = P_START_TAG.matcher(s);
|
||||
if (m.find()) {
|
||||
final String name = m.group(1).toLowerCase();
|
||||
final String body = m.group(2);
|
||||
String ending = m.group(3);
|
||||
|
||||
//debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
|
||||
if (allowed(name)) {
|
||||
String params = "";
|
||||
|
||||
final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
|
||||
final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
|
||||
final List<String> paramNames = new ArrayList<String>();
|
||||
final List<String> paramValues = new ArrayList<String>();
|
||||
while (m2.find()) {
|
||||
paramNames.add(m2.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m2.group(3)); //(.*?)
|
||||
}
|
||||
while (m3.find()) {
|
||||
paramNames.add(m3.group(1)); //([a-z0-9]+)
|
||||
paramValues.add(m3.group(3)); //([^\"\\s']+)
|
||||
}
|
||||
|
||||
String paramName, paramValue;
|
||||
for (int ii = 0; ii < paramNames.size(); ii++) {
|
||||
paramName = paramNames.get(ii).toLowerCase();
|
||||
paramValue = paramValues.get(ii);
|
||||
|
||||
if (allowedAttribute(name, paramName)) {
|
||||
if (inArray(paramName, vProtocolAtts)) {
|
||||
paramValue = processParamProtocol(paramValue);
|
||||
}
|
||||
params += " " + paramName + "=\"" + paramValue + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (inArray(name, vSelfClosingTags)) {
|
||||
ending = " /";
|
||||
}
|
||||
|
||||
if (inArray(name, vNeedClosingTags)) {
|
||||
ending = "";
|
||||
}
|
||||
|
||||
if (ending == null || ending.length() < 1) {
|
||||
if (vTagCounts.containsKey(name)) {
|
||||
vTagCounts.put(name, vTagCounts.get(name) + 1);
|
||||
} else {
|
||||
vTagCounts.put(name, 1);
|
||||
}
|
||||
} else {
|
||||
ending = " /";
|
||||
}
|
||||
return "<" + name + params + ending + ">";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// comments
|
||||
m = P_COMMENT.matcher(s);
|
||||
if (!stripComment && m.find()) {
|
||||
return "<" + m.group() + ">";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private String processParamProtocol(String s) {
|
||||
s = decodeEntities(s);
|
||||
final Matcher m = P_PROTOCOL.matcher(s);
|
||||
if (m.find()) {
|
||||
final String protocol = m.group(1);
|
||||
if (!inArray(protocol, vAllowedProtocols)) {
|
||||
// bad protocol, turn into local anchor link instead
|
||||
s = "#" + s.substring(protocol.length() + 1, s.length());
|
||||
if (s.startsWith("#//")) {
|
||||
s = "#" + s.substring(3, s.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private String decodeEntities(String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
Matcher m = P_ENTITY.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.decode(match).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENTITY_UNICODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
buf = new StringBuffer();
|
||||
m = P_ENCODE.matcher(s);
|
||||
while (m.find()) {
|
||||
final String match = m.group(1);
|
||||
final int decimal = Integer.valueOf(match, 16).intValue();
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
s = buf.toString();
|
||||
|
||||
s = validateEntities(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private String validateEntities(final String s) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// validate entities throughout the string
|
||||
Matcher m = P_VALID_ENTITIES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //([^&;]*)
|
||||
final String two = m.group(2); //(?=(;|&|$))
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
|
||||
return encodeQuotes(buf.toString());
|
||||
}
|
||||
|
||||
private String encodeQuotes(final String s){
|
||||
if(encodeQuotes){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Matcher m = P_VALID_QUOTES.matcher(s);
|
||||
while (m.find()) {
|
||||
final String one = m.group(1); //(>|^)
|
||||
final String two = m.group(2); //([^<]+?)
|
||||
final String three = m.group(3); //(<|$)
|
||||
m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three));
|
||||
}
|
||||
m.appendTail(buf);
|
||||
return buf.toString();
|
||||
}else{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
private String checkEntity(final String preamble, final String term) {
|
||||
|
||||
return ";".equals(term) && isValidEntity(preamble)
|
||||
? '&' + preamble
|
||||
: "&" + preamble;
|
||||
}
|
||||
|
||||
private boolean isValidEntity(final String entity) {
|
||||
return inArray(entity, vAllowedEntities);
|
||||
}
|
||||
|
||||
private static boolean inArray(final String s, final String[] array) {
|
||||
for (String item : array) {
|
||||
if (item != null && item.equals(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allowed(final String name) {
|
||||
return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
|
||||
}
|
||||
|
||||
private boolean allowedAttribute(final String name, final String paramName) {
|
||||
return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* SQL过滤
|
||||
*
|
||||
*/
|
||||
public class SQLFilter {
|
||||
|
||||
/**
|
||||
* SQL注入过滤
|
||||
* @param str 待验证的字符串
|
||||
*/
|
||||
public static String sqlInject(String str){
|
||||
if(StringUtils.isBlank(str)){
|
||||
return null;
|
||||
}
|
||||
//去掉'|"|;|\字符
|
||||
str = StringUtils.replace(str, "'", "");
|
||||
str = StringUtils.replace(str, "\"", "");
|
||||
str = StringUtils.replace(str, ";", "");
|
||||
str = StringUtils.replace(str, "\\", "");
|
||||
|
||||
//转换成小写
|
||||
str = str.toLowerCase();
|
||||
|
||||
//非法字符
|
||||
String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"};
|
||||
|
||||
//判断是否包含非法字符
|
||||
for(String keyword : keywords){
|
||||
if(str.indexOf(keyword) != -1){
|
||||
throw new SqxException("包含非法字符");
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* XSS过滤
|
||||
*
|
||||
*/
|
||||
public class XssFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest hreq = (HttpServletRequest) request;
|
||||
HttpServletResponse hresp = (HttpServletResponse) response;
|
||||
|
||||
//跨域
|
||||
hresp.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
|
||||
//跨域 Header
|
||||
|
||||
hresp.setHeader("Access-Control-Allow-Methods", "*");
|
||||
|
||||
hresp.setHeader("Access-Control-Allow-Headers", "*");
|
||||
|
||||
// Filter 只是链式处理,请求依然转发到目的地址。
|
||||
|
||||
chain.doFilter(request, response);
|
||||
/*XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||
(HttpServletRequest) request);
|
||||
chain.doFilter(xssRequest, response);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.sqx.common.xss;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
*
|
||||
*/
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
//没被包装过的HttpServletRequest(特殊场景,需要自己过滤)
|
||||
HttpServletRequest orgRequest;
|
||||
//html过滤
|
||||
private final static HTMLFilter HtmlFilter = new HTMLFilter();
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
orgRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
//非json类型,直接返回
|
||||
if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//为空,直接返回
|
||||
String json = IOUtils.toString(super.getInputStream(), "utf-8");
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
//xss过滤
|
||||
json = xssEncode(json);
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String value = super.getParameter(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] parameters = super.getParameterValues(name);
|
||||
if (parameters == null || parameters.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
parameters[i] = xssEncode(parameters[i]);
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String[]> getParameterMap() {
|
||||
Map<String,String[]> map = new LinkedHashMap<>();
|
||||
Map<String,String[]> parameters = super.getParameterMap();
|
||||
for (String key : parameters.keySet()) {
|
||||
String[] values = parameters.get(key);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
values[i] = xssEncode(values[i]);
|
||||
}
|
||||
map.put(key, values);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
String value = super.getHeader(xssEncode(name));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
value = xssEncode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private String xssEncode(String input) {
|
||||
return HtmlFilter.filter(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public HttpServletRequest getOrgRequest() {
|
||||
return orgRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最原始的request
|
||||
*/
|
||||
public static HttpServletRequest getOrgRequest(HttpServletRequest request) {
|
||||
if (request instanceof XssHttpServletRequestWrapper) {
|
||||
return ((XssHttpServletRequestWrapper) request).getOrgRequest();
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
||||
/**
|
||||
* 跨域设置
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
/*private CorsConfiguration buildConfig() {
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
// 1允许任何域名使用
|
||||
corsConfiguration.addAllowedOrigin("*");
|
||||
// 2允许任何头
|
||||
corsConfiguration.addAllowedHeader("*");
|
||||
// 3允许任何方法(post、get等)
|
||||
corsConfiguration.addAllowedMethod("*");
|
||||
return corsConfiguration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", buildConfig());
|
||||
return new CorsFilter(source);
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.sqx.common.xss.XssFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
/**
|
||||
* Filter配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean shiroFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
|
||||
//该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理
|
||||
registration.addInitParameter("targetFilterLifecycle", "true");
|
||||
registration.setEnabled(true);
|
||||
registration.setOrder(Integer.MAX_VALUE - 1);
|
||||
registration.addUrlPatterns("/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean xssFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||
registration.setFilter(new XssFilter());
|
||||
registration.addUrlPatterns("/*");
|
||||
registration.setName("xssFilter");
|
||||
registration.setOrder(Integer.MAX_VALUE);
|
||||
return registration;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* 生成验证码配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class KaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha producer() {
|
||||
Properties properties = new Properties();
|
||||
properties.put("kaptcha.border", "no");
|
||||
properties.put("kaptcha.textproducer.font.color", "black");
|
||||
properties.put("kaptcha.textproducer.char.space", "5");
|
||||
properties.put("kaptcha.textproducer.font.names", "Arial,Courier,cmr10,宋体,楷体,微软雅黑");
|
||||
Config config = new Config(properties);
|
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* mybatis-plus配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Autowired
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new StringRedisSerializer());
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForHash();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
|
||||
return redisTemplate.opsForValue();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForList();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForSet();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||
return redisTemplate.opsForZSet();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.sqx.modules.sys.oauth2.OAuth2Filter;
|
||||
import com.sqx.modules.sys.oauth2.OAuth2Realm;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Shiro配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
@Bean("securityManager")
|
||||
public SecurityManager securityManager(OAuth2Realm oAuth2Realm) {
|
||||
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
|
||||
securityManager.setRealm(oAuth2Realm);
|
||||
securityManager.setRememberMeManager(null);
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
@Bean("shiroFilter")
|
||||
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
|
||||
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
|
||||
shiroFilter.setSecurityManager(securityManager);
|
||||
|
||||
//oauth过滤
|
||||
Map<String, Filter> filters = new HashMap<>();
|
||||
filters.put("oauth2", new OAuth2Filter());
|
||||
shiroFilter.setFilters(filters);
|
||||
|
||||
Map<String, String> filterMap = new LinkedHashMap<>();
|
||||
filterMap.put("/webjars/**", "anon");
|
||||
filterMap.put("/druid/**", "anon");
|
||||
|
||||
filterMap.put("/advert/list", "anon");
|
||||
filterMap.put("/goods/recommend", "anon");
|
||||
filterMap.put("/selfActivity/state", "anon");
|
||||
filterMap.put("/goods/homeGoods", "anon");
|
||||
filterMap.put("/goods/find", "anon");
|
||||
filterMap.put("/goods/selectGoods", "anon");
|
||||
filterMap.put("/selfActivity/list", "anon");
|
||||
filterMap.put("/pay/**", "anon");
|
||||
filterMap.put("/aliPay/**", "anon");
|
||||
filterMap.put("/order/**", "anon");
|
||||
filterMap.put("/pays/notifyPay", "anon");
|
||||
filterMap.put("/selfGoodsBrand/find", "anon");
|
||||
filterMap.put("/selfGoodsComment/list", "anon");
|
||||
filterMap.put("/selfGoodsComment/count", "anon");
|
||||
filterMap.put("/selfGoodsComment/findByOrderId", "anon");
|
||||
filterMap.put("/selfGoodsComment/find", "anon");
|
||||
filterMap.put("/goods/brandList", "anon");
|
||||
|
||||
|
||||
filterMap.put("/app/wxPay/notifyJsApi", "anon");
|
||||
filterMap.put("/app/wxPay/notifyMp", "anon");
|
||||
filterMap.put("/app/wxPay/notify", "anon");
|
||||
filterMap.put("/app/aliPay/notifyApp", "anon");
|
||||
filterMap.put("/app/**", "anon");
|
||||
filterMap.put("/activity/**", "anon");
|
||||
filterMap.put("/banner/**", "anon");
|
||||
filterMap.put("/courseClassification/selectCourseClassification", "anon");
|
||||
filterMap.put("/sys/login", "anon");
|
||||
filterMap.put("/swagger/**", "anon");
|
||||
filterMap.put("/v2/api-docs", "anon");
|
||||
filterMap.put("/swagger-ui.html", "anon");
|
||||
filterMap.put("/swagger-resources/**", "anon");
|
||||
filterMap.put("/captcha.jpg", "anon");
|
||||
filterMap.put("/chatSocket/**", "anon");
|
||||
filterMap.put("/websocket/**", "anon");
|
||||
filterMap.put("/mapWebsocket/**", "anon");
|
||||
filterMap.put("/monitorWebSocket/**", "anon");
|
||||
filterMap.put("/search/**", "anon");
|
||||
filterMap.put("/alioss/**","anon");
|
||||
filterMap.put("/ws/**","anon");
|
||||
filterMap.put("/doc.html/**","anon");
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
||||
return shiroFilter;
|
||||
}
|
||||
|
||||
@Bean("lifecycleBeanPostProcessor")
|
||||
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
|
||||
AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
|
||||
advisor.setSecurityManager(securityManager);
|
||||
return advisor;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableKnife4j
|
||||
public class SwaggerConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
//加了ApiOperation注解的类,才生成接口文档
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
//包下的类,才生成接口文档
|
||||
//.apis(RequestHandlerSelectors.basePackage("com.sqx.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(security());
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("")
|
||||
.description("sqx-fast文档")
|
||||
.termsOfServiceUrl("")
|
||||
.version("3.0.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<ApiKey> security() {
|
||||
return newArrayList(
|
||||
new ApiKey("token", "token", "header")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sqx.datasource.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 多数据源注解
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DataSource {
|
||||
String value() default "";
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.sqx.datasource.aspect;
|
||||
|
||||
|
||||
import com.sqx.datasource.annotation.DataSource;
|
||||
import com.sqx.datasource.config.DynamicContextHolder;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 多数据源,切面处理类
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class DataSourceAspect {
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Pointcut("@annotation(com.sqx.datasource.annotation.DataSource) " +
|
||||
"|| @within(com.sqx.datasource.annotation.DataSource)")
|
||||
public void dataSourcePointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("dataSourcePointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Class targetClass = point.getTarget().getClass();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
DataSource targetDataSource = (DataSource)targetClass.getAnnotation(DataSource.class);
|
||||
DataSource methodDataSource = method.getAnnotation(DataSource.class);
|
||||
if(targetDataSource != null || methodDataSource != null){
|
||||
String value;
|
||||
if(methodDataSource != null){
|
||||
value = methodDataSource.value();
|
||||
}else {
|
||||
value = targetDataSource.value();
|
||||
}
|
||||
|
||||
DynamicContextHolder.push(value);
|
||||
logger.debug("set datasource is {}", value);
|
||||
}
|
||||
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
DynamicContextHolder.poll();
|
||||
logger.debug("clean datasource");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
/**
|
||||
* 多数据源上下文
|
||||
*/
|
||||
public class DynamicContextHolder {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = new ThreadLocal() {
|
||||
@Override
|
||||
protected Object initialValue() {
|
||||
return new ArrayDeque();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获得当前线程数据源
|
||||
*
|
||||
* @return 数据源名称
|
||||
*/
|
||||
public static String peek() {
|
||||
return CONTEXT_HOLDER.get().peek();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前线程数据源
|
||||
*
|
||||
* @param dataSource 数据源名称
|
||||
*/
|
||||
public static void push(String dataSource) {
|
||||
CONTEXT_HOLDER.get().push(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空当前线程数据源
|
||||
*/
|
||||
public static void poll() {
|
||||
Deque<String> deque = CONTEXT_HOLDER.get();
|
||||
deque.poll();
|
||||
if (deque.isEmpty()) {
|
||||
CONTEXT_HOLDER.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||
|
||||
/**
|
||||
* 多数据源
|
||||
*/
|
||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
@Override
|
||||
protected Object determineCurrentLookupKey() {
|
||||
return DynamicContextHolder.peek();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.sqx.datasource.properties.DataSourceProperties;
|
||||
import com.sqx.datasource.properties.DynamicDataSourceProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置多数据源
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
|
||||
public class DynamicDataSourceConfig {
|
||||
@Autowired
|
||||
private DynamicDataSourceProperties properties;
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSourceProperties dataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) {
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
dynamicDataSource.setTargetDataSources(getDynamicDataSource());
|
||||
|
||||
//默认数据源
|
||||
DruidDataSource defaultDataSource = DynamicDataSourceFactory.buildDruidDataSource(dataSourceProperties);
|
||||
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
|
||||
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
private Map<Object, Object> getDynamicDataSource(){
|
||||
Map<String, DataSourceProperties> dataSourcePropertiesMap = properties.getDatasource();
|
||||
Map<Object, Object> targetDataSources = new HashMap<>(dataSourcePropertiesMap.size());
|
||||
dataSourcePropertiesMap.forEach((k, v) -> {
|
||||
DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v);
|
||||
targetDataSources.put(k, druidDataSource);
|
||||
});
|
||||
|
||||
return targetDataSources;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.sqx.datasource.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.sqx.datasource.properties.DataSourceProperties;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* DruidDataSource
|
||||
*
|
||||
*/
|
||||
public class DynamicDataSourceFactory {
|
||||
|
||||
public static DruidDataSource buildDruidDataSource(DataSourceProperties properties) {
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
druidDataSource.setDriverClassName(properties.getDriverClassName());
|
||||
druidDataSource.setUrl(properties.getUrl());
|
||||
druidDataSource.setUsername(properties.getUsername());
|
||||
druidDataSource.setPassword(properties.getPassword());
|
||||
|
||||
druidDataSource.setInitialSize(properties.getInitialSize());
|
||||
druidDataSource.setMaxActive(properties.getMaxActive());
|
||||
druidDataSource.setMinIdle(properties.getMinIdle());
|
||||
druidDataSource.setMaxWait(properties.getMaxWait());
|
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
|
||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
|
||||
druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis());
|
||||
druidDataSource.setValidationQuery(properties.getValidationQuery());
|
||||
druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
|
||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
|
||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn());
|
||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
|
||||
druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements());
|
||||
druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements());
|
||||
|
||||
try {
|
||||
druidDataSource.setFilters(properties.getFilters());
|
||||
druidDataSource.init();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
package com.sqx.datasource.properties;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*
|
||||
*/
|
||||
public class DataSourceProperties {
|
||||
private String driverClassName;
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Druid默认参数
|
||||
*/
|
||||
private int initialSize = 2;
|
||||
private int maxActive = 10;
|
||||
private int minIdle = -1;
|
||||
private long maxWait = 60 * 1000L;
|
||||
private long timeBetweenEvictionRunsMillis = 60 * 1000L;
|
||||
private long minEvictableIdleTimeMillis = 1000L * 60L * 30L;
|
||||
private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7;
|
||||
private String validationQuery = "select 1";
|
||||
private int validationQueryTimeout = -1;
|
||||
private boolean testOnBorrow = false;
|
||||
private boolean testOnReturn = false;
|
||||
private boolean testWhileIdle = true;
|
||||
private boolean poolPreparedStatements = false;
|
||||
private int maxOpenPreparedStatements = -1;
|
||||
private boolean sharePreparedStatements = false;
|
||||
private String filters = "stat,wall";
|
||||
|
||||
public String getDriverClassName() {
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getInitialSize() {
|
||||
return initialSize;
|
||||
}
|
||||
|
||||
public void setInitialSize(int initialSize) {
|
||||
this.initialSize = initialSize;
|
||||
}
|
||||
|
||||
public int getMaxActive() {
|
||||
return maxActive;
|
||||
}
|
||||
|
||||
public void setMaxActive(int maxActive) {
|
||||
this.maxActive = maxActive;
|
||||
}
|
||||
|
||||
public int getMinIdle() {
|
||||
return minIdle;
|
||||
}
|
||||
|
||||
public void setMinIdle(int minIdle) {
|
||||
this.minIdle = minIdle;
|
||||
}
|
||||
|
||||
public long getMaxWait() {
|
||||
return maxWait;
|
||||
}
|
||||
|
||||
public void setMaxWait(long maxWait) {
|
||||
this.maxWait = maxWait;
|
||||
}
|
||||
|
||||
public long getTimeBetweenEvictionRunsMillis() {
|
||||
return timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
|
||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
||||
}
|
||||
|
||||
public long getMinEvictableIdleTimeMillis() {
|
||||
return minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
|
||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public long getMaxEvictableIdleTimeMillis() {
|
||||
return maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
|
||||
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
|
||||
}
|
||||
|
||||
public String getValidationQuery() {
|
||||
return validationQuery;
|
||||
}
|
||||
|
||||
public void setValidationQuery(String validationQuery) {
|
||||
this.validationQuery = validationQuery;
|
||||
}
|
||||
|
||||
public int getValidationQueryTimeout() {
|
||||
return validationQueryTimeout;
|
||||
}
|
||||
|
||||
public void setValidationQueryTimeout(int validationQueryTimeout) {
|
||||
this.validationQueryTimeout = validationQueryTimeout;
|
||||
}
|
||||
|
||||
public boolean isTestOnBorrow() {
|
||||
return testOnBorrow;
|
||||
}
|
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||
this.testOnBorrow = testOnBorrow;
|
||||
}
|
||||
|
||||
public boolean isTestOnReturn() {
|
||||
return testOnReturn;
|
||||
}
|
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) {
|
||||
this.testOnReturn = testOnReturn;
|
||||
}
|
||||
|
||||
public boolean isTestWhileIdle() {
|
||||
return testWhileIdle;
|
||||
}
|
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||
this.testWhileIdle = testWhileIdle;
|
||||
}
|
||||
|
||||
public boolean isPoolPreparedStatements() {
|
||||
return poolPreparedStatements;
|
||||
}
|
||||
|
||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
|
||||
this.poolPreparedStatements = poolPreparedStatements;
|
||||
}
|
||||
|
||||
public int getMaxOpenPreparedStatements() {
|
||||
return maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
|
||||
this.maxOpenPreparedStatements = maxOpenPreparedStatements;
|
||||
}
|
||||
|
||||
public boolean isSharePreparedStatements() {
|
||||
return sharePreparedStatements;
|
||||
}
|
||||
|
||||
public void setSharePreparedStatements(boolean sharePreparedStatements) {
|
||||
this.sharePreparedStatements = sharePreparedStatements;
|
||||
}
|
||||
|
||||
public String getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(String filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.sqx.datasource.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 多数据源属性
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "dynamic")
|
||||
public class DynamicDataSourceProperties {
|
||||
private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
|
||||
|
||||
public Map<String, DataSourceProperties> getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(Map<String, DataSourceProperties> datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
package com.sqx.ffmpeg;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.RuntimeUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sound.sampled.*;
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FFmpeg {
|
||||
|
||||
@Value("${ffmpeg.core.executableFile}")
|
||||
public String ffmpegPath;
|
||||
|
||||
@Value("${business.audio.uploadPath}")
|
||||
public String baseAudioUploadPath;
|
||||
|
||||
|
||||
public void montageAudio(String inFilePath, String inFilePath2,String outPath){
|
||||
//montageAudioByJavaIo(inFilePath, inFilePath2, outPath);
|
||||
montageAudioByFFmpeg(inFilePath, inFilePath2, outPath);
|
||||
}
|
||||
public void montageAudioByJavaIo(String inFilePath, String inFilePath2,String outPath){
|
||||
List<File> audioFiles = Lists.newArrayList();
|
||||
audioFiles.add(new File(inFilePath));
|
||||
audioFiles.add(new File(inFilePath2));
|
||||
mergeAudioFiles(audioFiles, new File(outPath));
|
||||
}
|
||||
|
||||
public void mergeAudioFiles(List<File> audioFiles, File outputFile){
|
||||
if(audioFiles == null || audioFiles.isEmpty()){
|
||||
log.warn("待合并列表为空,不执行合并");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<AudioInputStream> audioInputStreamList = Lists.newArrayList();
|
||||
AudioFormat audioFormat = null;
|
||||
AudioInputStream audioInputStream = null;
|
||||
|
||||
//读取音频文件,读取格式和流
|
||||
for (File audioFile : audioFiles) {
|
||||
audioInputStream = AudioSystem.getAudioInputStream(audioFile);
|
||||
audioFormat = audioInputStream.getFormat();
|
||||
if (audioFormat.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
|
||||
audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
|
||||
audioFormat.getSampleRate(),
|
||||
16,
|
||||
audioFormat.getChannels(),
|
||||
audioFormat.getChannels() * 2,
|
||||
audioFormat.getSampleRate(),
|
||||
false);
|
||||
audioInputStream = AudioSystem.getAudioInputStream(audioFormat, audioInputStream);
|
||||
}
|
||||
audioInputStreamList.add(audioInputStream);
|
||||
}
|
||||
AudioFormat newAudioFormat = new AudioFormat(
|
||||
audioFormat.getEncoding(),
|
||||
audioFormat.getSampleRate(),
|
||||
audioFormat.getSampleSizeInBits(),
|
||||
audioFormat.getChannels(),
|
||||
audioFormat.getFrameSize(),
|
||||
audioFormat.getFrameRate(),
|
||||
audioFormat.isBigEndian()
|
||||
);
|
||||
// AudioInputStream mergedAudioStream = new AudioInputStream(
|
||||
// new SequenceInputStream(Collections.enumeration(audioInputStreamList)),
|
||||
// newAudioFormat,
|
||||
// audioInputStream.getFrameLength()
|
||||
// );
|
||||
|
||||
AudioInputStream mergedAudioStream = new AudioInputStream(
|
||||
new SequenceInputStream(Collections.enumeration(audioInputStreamList)),
|
||||
newAudioFormat,
|
||||
audioInputStream.getFrameLength()
|
||||
|
||||
);
|
||||
|
||||
//合并后扔到输出文件里
|
||||
AudioSystem.write(mergedAudioStream, AudioFileFormat.Type.WAVE, outputFile);
|
||||
//AudioSystem.write(mergedAudioStream, new AudioFileFormat.Type("MP3", "mp3"), outputFile);
|
||||
|
||||
//Conv c = new Converter();
|
||||
//AudioFileWriter writer = (AudioFileWriter)
|
||||
|
||||
//THeaderlessAudioFileWriter x = new THeaderlessAudioFileWriter();
|
||||
//MpegAudioFileWriter mpegAudioFileWriter = new MpegAudioFileWriter();
|
||||
//mpegAudioFileWriter.write(mergedAudioStream, MpegFileFormatType.MP3, outputFile);
|
||||
|
||||
//new THeaderlessAudioFileWriter(null,null,null).write(null,null,null,null);
|
||||
|
||||
//AudioSystem.write()
|
||||
|
||||
|
||||
//AudioSystem.write(mergedAudioStream, MpegFileFormatType.MP3, outputFile);
|
||||
//MpegFormatConversionProvider mpegFormatConversionProvider = new MpegFormatConversionProvider();
|
||||
//mpegFormatConversionProvider.
|
||||
for (AudioInputStream ais: audioInputStreamList){
|
||||
ais.close();
|
||||
}
|
||||
mergedAudioStream.close();
|
||||
} catch (IOException | UnsupportedAudioFileException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//合并音频
|
||||
public void montageAudioByFFmpeg(String inFilePath, String inFilePath2,String outPath){
|
||||
// //ffmpeg -i 1.mp3 -i 2.mp3 -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1[out]" -map "[out]" output.mp3
|
||||
List<String> command = Lists.newArrayList();
|
||||
command.add(ffmpegPath);
|
||||
command.add("-i");
|
||||
command.add(inFilePath);
|
||||
command.add("-i");
|
||||
command.add(inFilePath2);
|
||||
//command.add("-acodec copy");
|
||||
command.add("-filter_complex");
|
||||
command.add("[0:a][1:a]concat=n=2:v=0:a=1[out]");
|
||||
command.add("-map");
|
||||
command.add("[out]");
|
||||
command.add(outPath);
|
||||
command.add("-y");
|
||||
// String[] commands = command.toArray(new String[]{});
|
||||
//
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.append(ffmpegPath);
|
||||
// sb.append(" ");
|
||||
// sb.append("-i");
|
||||
// sb.append(" ");
|
||||
// sb.append(inFilePath);
|
||||
// sb.append(" ");
|
||||
// sb.append("-i");
|
||||
// sb.append(" ");
|
||||
// sb.append(inFilePath2);
|
||||
// sb.append(" ");
|
||||
// sb.append("-filter_complex");
|
||||
// sb.append(" ");
|
||||
// sb.append("\"[0:a][1:a]concat=n=2:v=0:a=1[out]\"");
|
||||
// sb.append(" ");
|
||||
// sb.append("-map");
|
||||
// sb.append(" ");
|
||||
// sb.append("\"[out]\"");
|
||||
// sb.append(" ");
|
||||
// sb.append(outPath);
|
||||
// sb.append(" -y");//强制覆盖
|
||||
log.info("执行此命令:{}",command);
|
||||
//String res = RuntimeUtil.execForStr(sb.toString());
|
||||
|
||||
//手写吧。。。
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
|
||||
|
||||
try {
|
||||
Process process = builder.start();
|
||||
// int exitCode = process.exitValue();
|
||||
int exitCode = process.waitFor();
|
||||
if(exitCode == 0){
|
||||
log.info("正常退出!");
|
||||
}else{
|
||||
log.info("非正常退出!{}",exitCode);
|
||||
}
|
||||
InputStream is = process.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null){
|
||||
log.info(line);
|
||||
}
|
||||
InputStream eis = process.getErrorStream();
|
||||
BufferedReader ereader = new BufferedReader(new InputStreamReader(eis));
|
||||
String eline;
|
||||
while ((eline = ereader.readLine()) != null){
|
||||
log.info(eline);
|
||||
}
|
||||
process.destroy();
|
||||
} catch (IOException e) {
|
||||
log.error("IO错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("中断错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
// log.info("执行结果:{}",res);
|
||||
}
|
||||
|
||||
public static String getOsName(){
|
||||
return System.getProperty("os.name").toLowerCase();
|
||||
}
|
||||
|
||||
public void mergeAllAudio(List<String> inFilePathList,String outPath) {
|
||||
if (inFilePathList == null || inFilePathList.isEmpty()) return;
|
||||
if (StringUtils.isBlank(outPath)) return;
|
||||
//ffmpeg -i "concat:01.mp3|02.mp3|03.mp3" -acodec copy testAll.mp3
|
||||
List<String> command = Lists.newArrayList();
|
||||
command.add(ffmpegPath);
|
||||
//多个
|
||||
for (String path : inFilePathList) {
|
||||
command.add("-i");
|
||||
command.add(path);
|
||||
}
|
||||
command.add("-filter_complex");//过滤器
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < inFilePathList.size(); i++) {
|
||||
sb.append("[");sb.append(i);sb.append(":a]");
|
||||
}
|
||||
sb.append("concat=n=");
|
||||
sb.append(inFilePathList.size());
|
||||
sb.append(":v=0:a=1[out]");
|
||||
//[0:0] [1:0] [2:0] concat=n=3:v=0:a=1 [a]
|
||||
//[0:0] [1:0] concat=n=${}:v=0:a=1 [a]
|
||||
command.add(sb.toString());
|
||||
command.add("-map");
|
||||
command.add("[out]");
|
||||
command.add(outPath);
|
||||
command.add("-y");
|
||||
log.info("执行此命令:{}",command);
|
||||
//String res = RuntimeUtil.execForStr(sb.toString());
|
||||
|
||||
//手写吧。。。
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
|
||||
try {
|
||||
Process process = builder.start();
|
||||
int exitCode = process.waitFor();
|
||||
if(exitCode == 0){
|
||||
log.info("正常退出!");
|
||||
}else{
|
||||
log.info("非正常退出!{}",exitCode);
|
||||
}
|
||||
InputStream is = process.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null){
|
||||
log.info(line);
|
||||
}
|
||||
InputStream eis = process.getErrorStream();
|
||||
BufferedReader ereader = new BufferedReader(new InputStreamReader(eis));
|
||||
String eline;
|
||||
while ((eline = ereader.readLine()) != null){
|
||||
log.info(eline);
|
||||
}
|
||||
process.destroy();
|
||||
} catch (IOException e) {
|
||||
log.error("IO错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("中断错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//因为"字符无法在linux中使用,win下正常
|
||||
public void mergeAllAudio2(List<String> inFilePathList,String outPath) {
|
||||
log.info("系统名称:{}", getOsName());
|
||||
log.info("是win?:{}", StringUtils.contains(getOsName(), "win"));
|
||||
log.info("是linux?:{}", StringUtils.contains(getOsName(), "linux"));
|
||||
if (inFilePathList == null || inFilePathList.isEmpty()) return;
|
||||
if (StringUtils.isBlank(outPath)) return;
|
||||
//ffmpeg -i "concat:01.mp3|02.mp3|03.mp3" -acodec copy testAll.mp3
|
||||
List<String> command = Lists.newArrayList();
|
||||
command.add(ffmpegPath);
|
||||
command.add("-i");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// if(StringUtils.contains(getOsName(), "linux")){
|
||||
// sb.append("\\\"");
|
||||
// }else{
|
||||
sb.append("\"");
|
||||
// }
|
||||
sb.append("concat:");
|
||||
// if(StringUtils.contains(getOsName(), "linux")) {
|
||||
// for (String path : inFilePathList) {
|
||||
// sb.append(path);
|
||||
// sb.append("\\|");
|
||||
// }
|
||||
// //去除最后的|
|
||||
// sb.deleteCharAt(sb.length() - 1);
|
||||
// sb.deleteCharAt(sb.length() - 1);
|
||||
// }else{
|
||||
for (String path : inFilePathList) {
|
||||
sb.append(path);
|
||||
sb.append("|");
|
||||
}
|
||||
//去除最后的|
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
// }
|
||||
// if(StringUtils.contains(getOsName(), "linux")){
|
||||
// sb.append("\\\"");
|
||||
// }else{
|
||||
sb.append("\"");
|
||||
// }
|
||||
command.add(sb.toString());
|
||||
command.add("-acodec");
|
||||
command.add("copy");
|
||||
command.add(outPath);
|
||||
command.add("-y");
|
||||
|
||||
// if(StringUtils.contains(getOsName(), "linux")){
|
||||
// command.add("\"");
|
||||
// }
|
||||
|
||||
log.info("执行此命令:{}",command);
|
||||
//手写吧。。。
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
|
||||
try {
|
||||
Process process = null;
|
||||
// Process process = builder.start();
|
||||
// Process process = RuntimeUtil.exec(command.toArray(new String[]{}));
|
||||
// if(StringUtils.contains(getOsName(), "linux")){
|
||||
//
|
||||
// //process = Runtime.getRuntime().exec("sh -c",command.toArray(new String[]{}));
|
||||
// process = Runtime.getRuntime().exec(new String[]{"/bin/sh","-c",ArrayUtil.join(command.toArray(new String[]{})," ")});
|
||||
|
||||
// String commandBase64 = Base64.encode(ArrayUtil.join(command.toArray(new String[]{})," "));
|
||||
// process = Runtime.getRuntime().exec(new String[]{"bash","-c","{echo," + commandBase64 + "}|{base64,-d}|{bash,-i}"});
|
||||
//
|
||||
//
|
||||
// log.info("执行此命令:{}","bash -c {echo," + commandBase64 + "}|{base64,-d}|{bash,-i}");
|
||||
|
||||
// }else{
|
||||
process = builder.start();
|
||||
// String commandBase64 = Base64.encode(ArrayUtil.join(command.toArray(new String[]{})," "));
|
||||
// process = Runtime.getRuntime().exec("bash -c {echo," + commandBase64 + "}|{base64,-d}|{bash,-i}");
|
||||
// }
|
||||
|
||||
// process.createCommandLine
|
||||
// int exitCode = process.exitValue();
|
||||
int exitCode = process.waitFor();
|
||||
if(exitCode == 0){
|
||||
log.info("正常退出!");
|
||||
}else{
|
||||
log.info("非正常退出!{}",exitCode);
|
||||
}
|
||||
InputStream is = process.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null){
|
||||
log.info(line);
|
||||
}
|
||||
InputStream eis = process.getErrorStream();
|
||||
BufferedReader ereader = new BufferedReader(new InputStreamReader(eis));
|
||||
String eline;
|
||||
while ((eline = ereader.readLine()) != null){
|
||||
log.info(eline);
|
||||
}
|
||||
process.destroy();
|
||||
} catch (IOException e) {
|
||||
log.error("IO错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("中断错误!");
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// for (int i = 0; i < 200; i++) {
|
||||
// //用原生合并的,,,只能合并出wav文件。文件特大。。。
|
||||
// new FFmpeg().montageAudioByJavaIo("F:\\temp\\000\\all.mp3","F:\\temp\\000\\01.mp3","F:\\temp\\000\\all.mp3");
|
||||
// }
|
||||
System.out.println(getOsName());
|
||||
FFmpeg fFmpeg = new FFmpeg();
|
||||
fFmpeg.ffmpegPath = "D:\\ProgramGreeFile\\ffmpeg\\bin\\ffmpeg.exe";
|
||||
|
||||
List<String> audioList = Lists.newArrayList();
|
||||
audioList.add("F:\\temp\\000\\01.mp3");
|
||||
audioList.add("F:\\temp\\000\\02.mp3");
|
||||
audioList.add("F:\\temp\\000\\03.mp3");
|
||||
fFmpeg.mergeAllAudio(audioList,"F:\\temp\\000\\all250.mp3");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,352 @@
|
|||
package com.sqx.map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.utils.SpringContextUtils;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//获取各种清空的地图api
|
||||
@Slf4j
|
||||
public class CommonMapUtils {
|
||||
|
||||
private static final CommonInfoService commonInfoService = SpringContextUtils.getBean(CommonInfoService.class);
|
||||
|
||||
/**
|
||||
* 地图枚举
|
||||
*/
|
||||
public enum MapEnum {
|
||||
TX/*腾讯地图*/, TDT/*天地图*/, GD/*高德地图*/, DEF/*默认值*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 从数据库里获取当前生效的地图接口
|
||||
* @return { @link com.sqx.map.CommonMapUtils.MapEnum }
|
||||
*/
|
||||
public static MapEnum getMapType(){
|
||||
String mapType = commonInfoService.findOne(414).getValue();
|
||||
switch (mapType){
|
||||
case "1": {
|
||||
return MapEnum.TX;
|
||||
}
|
||||
case "2": {
|
||||
return MapEnum.TDT;
|
||||
}
|
||||
case "3": {
|
||||
return MapEnum.GD;
|
||||
}
|
||||
default: {
|
||||
return MapEnum.DEF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//一个通用的接口请求器
|
||||
|
||||
/**
|
||||
* 使用Get方式请求数据并转成json对象
|
||||
* @param url URL地址
|
||||
* @param params 参数
|
||||
* @return { @link com.alibaba.fastjson.JSONObject } 对象的map
|
||||
*/
|
||||
public static JSONObject getHtmlToJson(String url, Map<String, String> params){
|
||||
String data = HttpClientUtil.doGet(url, params);
|
||||
return JSON.parseObject(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取【逆地理编码】接口
|
||||
* @param mapType
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject getReverseGeocoding(MapEnum mapType, String longitude, String latitude){
|
||||
JSONObject result = null;
|
||||
switch (mapType){
|
||||
case TX: {
|
||||
//腾讯地图API
|
||||
CommonInfo oneData = commonInfoService.findOne(217);
|
||||
String url = "https://apis.map.qq.com/ws/geocoder/v1/";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("location", latitude + "," + longitude);
|
||||
params.put("key", oneData.getValue());
|
||||
JSONObject jsonObject = getHtmlToJson(url, params);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("0".equals(status)) {
|
||||
result = jsonObject.getJSONObject("result");
|
||||
} else {
|
||||
log.error("转换失败!!!原因:" + jsonObject.getString("message"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GD: {
|
||||
//高德API
|
||||
CommonInfo oneData = commonInfoService.findOne(427);
|
||||
String url = "https://restapi.amap.com/v3/geocode/regeo";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("location", longitude + "," + latitude);
|
||||
params.put("key", oneData.getValue());
|
||||
JSONObject jsonObject = getHtmlToJson(url, params);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("1".equals(status)) {
|
||||
result = jsonObject.getJSONObject("regeocode");
|
||||
}else {
|
||||
log.error("转换失败!!!原因:" + jsonObject.getString("info"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TDT: {
|
||||
//天地图API
|
||||
String value = commonInfoService.findOne(415).getValue();
|
||||
String url="http://api.tianditu.gov.cn/geocoder";
|
||||
Map<String,String> params = new HashMap<>();
|
||||
JSONObject postStr=new JSONObject();
|
||||
postStr.put("lon",longitude);
|
||||
postStr.put("lat",latitude);
|
||||
postStr.put("ver","1");
|
||||
params.put("postStr",postStr.toJSONString());
|
||||
params.put("type","geocode");
|
||||
params.put("tk",value);
|
||||
JSONObject jsonObject = getHtmlToJson(url, params);
|
||||
String status = jsonObject.getString("status");
|
||||
if("0".equals(status)){
|
||||
result = jsonObject.getJSONObject("result");
|
||||
}
|
||||
log.error("转换失败!!!原因:" + jsonObject.getString("msg"));
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度获取实际地址
|
||||
* @param longitude 经度 116.307490
|
||||
* @param latitude 纬度 39.984154
|
||||
* @return 经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址
|
||||
*/
|
||||
public static String getLocationToAddress(String longitude, String latitude){
|
||||
String address = "";
|
||||
MapEnum mapType = getMapType();
|
||||
JSONObject result = getReverseGeocoding(mapType, longitude, latitude);
|
||||
if(result != null) {
|
||||
switch (mapType){
|
||||
case TX: {
|
||||
//腾讯地图API
|
||||
address = result.getString("address");
|
||||
break;
|
||||
}
|
||||
case GD: case TDT: {
|
||||
//高德API/天地图
|
||||
address = result.getString("formatted_address");
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按坐标获取行政区划信息
|
||||
* @param longitude 经度 116.307490
|
||||
* @param latitude 纬度 39.984154
|
||||
* @return province:省/直辖市,city:市/地级区 及同级行政区划,如果当前城市为省直辖县级区划,city与district字段均会返回此城市,district:区/县级市 及同级行政区划,address:经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址
|
||||
*/
|
||||
|
||||
public static JSONObject getLocationToAdInfo(String longitude, String latitude){
|
||||
MapEnum mapType = getMapType();
|
||||
JSONObject result = getReverseGeocoding(mapType, longitude, latitude);
|
||||
JSONObject resObject = null;
|
||||
if(result != null) {
|
||||
switch (mapType){
|
||||
case TX: {
|
||||
//腾讯地图API
|
||||
resObject = result.getJSONObject("ad_info");//行政区划信息
|
||||
String address = result.getString("address");
|
||||
resObject.put("address",address);
|
||||
log.info("最终返回的地址对象:{}",resObject);
|
||||
break;
|
||||
}
|
||||
case GD: case TDT: {
|
||||
//高德API/天地图
|
||||
JSONObject addressComponent = result.getJSONObject("addressComponent");
|
||||
String province = addressComponent.getString("province");
|
||||
String city = addressComponent.getString("city");
|
||||
String adcode = addressComponent.getString("adcode");
|
||||
|
||||
if(StringUtils.equals("[]",city)){
|
||||
city = "";
|
||||
}
|
||||
|
||||
String district = "";
|
||||
if(mapType == MapEnum.GD){
|
||||
district = addressComponent.getString("district");
|
||||
}else {
|
||||
district = addressComponent.getString("county");
|
||||
}
|
||||
String address = result.getString("formatted_address");
|
||||
resObject = new JSONObject();
|
||||
resObject.put("province",province);//省 / 直辖市
|
||||
resObject.put("city",city);//市 / 地级区 及同级行政区划,如果当前城市为省直辖县级区划,city与district字段均会返回此城市
|
||||
resObject.put("adcode", adcode);//市代码
|
||||
resObject.put("district",district);//区 / 县级市 及同级行政区划
|
||||
resObject.put("address",address);//经纬度所对应的文字地址 如【北京市东城区东华门街道天安门-城楼】以行政区划+道路+门牌号等信息组成的标准格式化地址
|
||||
log.info("最终返回的地址对象:{}",resObject);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return resObject;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据开始位置和结束位置根据出行方式获取米
|
||||
* @param mapType
|
||||
* @param tripWay
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @param toLongitude
|
||||
* @param toLatitude
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject calcTaxiMoney(MapEnum mapType,Integer tripWay, String longitude, String latitude, String toLongitude, String toLatitude, String city, String cityCode){
|
||||
JSONObject result = null;
|
||||
if(tripWay == null) tripWay = 1;
|
||||
if(tripWay != 1 && tripWay != 2) return null;
|
||||
switch (mapType){
|
||||
case TX: {
|
||||
//腾讯地图API
|
||||
CommonInfo oneData = commonInfoService.findOne(217);
|
||||
String url = "https://apis.map.qq.com/ws/direction/v1/transit/?";//公交(transit)路线规划
|
||||
if(tripWay == 2){
|
||||
url="https://apis.map.qq.com/ws/direction/v1/driving/?";//驾车(driving)路线规划
|
||||
}
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("from", latitude + "," + longitude);
|
||||
params.put("to", toLatitude + "," + toLongitude);
|
||||
if(tripWay == 2){
|
||||
params.put("no_step", "1");
|
||||
}
|
||||
params.put("key", oneData.getValue());
|
||||
JSONObject jsonObject = getHtmlToJson(url, params);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("0".equals(status)) {
|
||||
result = jsonObject.getJSONObject("result");
|
||||
} else {
|
||||
log.error("{}路线计算失败: {}",tripWay == 1?"公交":"驾车" , jsonObject.getString("message"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GD: {
|
||||
//高德API
|
||||
CommonInfo oneData = commonInfoService.findOne(427);
|
||||
String url = "https://restapi.amap.com/v5/direction/transit/integrated";//公交
|
||||
if(tripWay == 2){
|
||||
url="https://restapi.amap.com/v5/direction/driving";//驾车
|
||||
}
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("origin", longitude + "," + latitude);
|
||||
params.put("destination", toLongitude + "," + toLatitude);
|
||||
params.put("key", oneData.getValue());
|
||||
//默认是公交,需要加城市
|
||||
if(tripWay != 2){
|
||||
//城市
|
||||
params.put("city1", cityCode);
|
||||
params.put("city2", cityCode);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = getHtmlToJson(url, params);
|
||||
String status = jsonObject.getString("status");
|
||||
if ("1".equals(status)) {
|
||||
result = jsonObject.getJSONObject("route");
|
||||
}else {
|
||||
log.error("{}路线计算失败: {}",tripWay == 1?"公交":"驾车" , jsonObject.getString("message"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TDT: {
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据开始位置和结束位置根据出行方式获取米
|
||||
* @param tripWay
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
* @param toLongitude
|
||||
* @param toLatitude
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject calcTaxiMoneyInfo(Integer tripWay, String longitude, String latitude, String toLongitude, String toLatitude, String city, String cityCode){
|
||||
MapEnum mapType = getMapType();
|
||||
JSONObject result = calcTaxiMoney(mapType, tripWay, longitude, latitude, toLongitude, toLatitude, city, cityCode);
|
||||
JSONObject resObject = null;
|
||||
if(result != null) {
|
||||
switch (mapType){
|
||||
case TX: {
|
||||
//腾讯地图API
|
||||
JSONArray routes = result.getJSONArray("routes");
|
||||
if(!routes.isEmpty()){
|
||||
resObject = new JSONObject();
|
||||
String distance = routes.getJSONObject(0).getString("distance");
|
||||
resObject.put("distance",Integer.parseInt(distance));
|
||||
log.info("从n到n2距离 {} 米",distance);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GD: {
|
||||
//高德API
|
||||
if(tripWay == 2){
|
||||
//驾车
|
||||
JSONArray routes = result.getJSONArray("paths");
|
||||
if(!routes.isEmpty()){
|
||||
resObject = new JSONObject();
|
||||
String distance = routes.getJSONObject(0).getString("distance");
|
||||
resObject.put("distance",Integer.parseInt(distance));
|
||||
log.info("从n到n2距离 {} 米",distance);
|
||||
}else{
|
||||
resObject = new JSONObject();
|
||||
resObject.put("distance",0);
|
||||
}
|
||||
}else if(tripWay == 1){
|
||||
//公交
|
||||
JSONArray routes = result.getJSONArray("transits");
|
||||
if(!routes.isEmpty()){
|
||||
resObject = new JSONObject();
|
||||
String distance = routes.getJSONObject(0).getString("distance");
|
||||
resObject.put("distance",Integer.parseInt(distance));
|
||||
log.info("从n到n2距离 {} 米",distance);
|
||||
}else{
|
||||
resObject = new JSONObject();
|
||||
resObject.put("distance",0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TDT: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return resObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* app登录效验
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Login {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.sqx.modules.app.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 登录用户信息
|
||||
*
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LoginUser {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.sqx.modules.app.config;
|
||||
|
||||
import com.sqx.modules.app.interceptor.AuthorizationInterceptor;
|
||||
import com.sqx.modules.app.resolver.LoginUserHandlerMethodArgumentResolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* MVC配置
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
private AuthorizationInterceptor authorizationInterceptor;
|
||||
@Autowired
|
||||
private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.Address;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.AddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/address")
|
||||
@Api(value = "用户地址", tags = {"用户地址"})
|
||||
public class AddressController {
|
||||
|
||||
@Autowired
|
||||
private AddressService addressService;
|
||||
|
||||
@GetMapping("/selectAddressListById")
|
||||
@ApiOperation("获取我的所有地址")
|
||||
public Result selectAddressListById(Long userId,Integer page,Integer limit){
|
||||
IPage<Address> addressIPage = addressService.page(new Page<>(page, limit), new QueryWrapper<Address>().eq("user_id", userId));
|
||||
return Result.success().put("data",new PageUtils(addressIPage));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/appinfo")
|
||||
@Api(value = "APP升级管理", tags = {"APP升级管理"})
|
||||
public class AppUpgradeController {
|
||||
|
||||
@Autowired
|
||||
private AppService iAppService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result list(Integer page,Integer limit) {
|
||||
IPage<App> pages =new Page<>(page,limit);
|
||||
return Result.success().put("data",iAppService.page(pages));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result getBanner(@PathVariable Long id) {
|
||||
return Result.success().put("data",iAppService.selectAppById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
@ApiOperation("管理平台添加升级信息")
|
||||
@ResponseBody
|
||||
public Result addBanner(@RequestBody App app) {
|
||||
if(app.getId()!=null){
|
||||
iAppService.updateAppById(app);
|
||||
}else{
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
app.setCreateAt(sdf.format(new Date()));
|
||||
iAppService.insertApp(app);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@ApiOperation("管理平台删除升级信息")
|
||||
public Result deleteBanner(@PathVariable Long id) {
|
||||
iAppService.deleteAppById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.service.UserBrowseService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/userBrowse")
|
||||
@Api(value = "访客|浏览", tags = {"访客|浏览"})
|
||||
public class UserBrowseController {
|
||||
private UserBrowseService userBrowseService;
|
||||
|
||||
@ApiOperation("查询我的访客")
|
||||
@RequestMapping(value = "/myVisitor", method = RequestMethod.GET)
|
||||
public Result selectMyVisitor(@ApiParam("用户id") Long userId, @ApiParam("页") Long page, @ApiParam("行") Long limit) {
|
||||
return userBrowseService.selectMyVisitor(userId, page, limit);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/myBrowse", method = RequestMethod.GET)
|
||||
@ApiOperation("浏览足迹")
|
||||
public Result selectMyBrowse(Long userId, Long page, Long limit) {
|
||||
return userBrowseService.selectMyBrowse(userId, page, limit);
|
||||
}
|
||||
|
||||
@ApiOperation("删除我的访客")
|
||||
@RequestMapping(value = "/deleteMyVisitor", method = RequestMethod.POST)
|
||||
public Result deleteMyVisitor(Long id) {
|
||||
|
||||
return userBrowseService.deleteMyVisitor(id);
|
||||
}
|
||||
@ApiOperation(("删除足迹"))
|
||||
@RequestMapping(value = "/deleteMyBrowse", method = RequestMethod.POST)
|
||||
public Result deleteMyBrowse(Long id) {
|
||||
|
||||
return userBrowseService.deleteMyBrowse(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserCertification;
|
||||
import com.sqx.modules.app.service.UserCertificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/userCertification")
|
||||
@Api("实 名 认 证")
|
||||
public class UserCertificationController {
|
||||
private UserCertificationService userCertificationService;
|
||||
|
||||
|
||||
/**
|
||||
* 实名列表
|
||||
*/
|
||||
@RequestMapping("/queryCertification")
|
||||
@ApiOperation("实名列表")
|
||||
public Result queryCertification(Long page, Long limit, @ApiParam("状态") String status, @ApiParam("姓名") String name,Integer classify) {
|
||||
|
||||
return userCertificationService.queryCertification(page, limit, status, name,classify);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已经进行实名的用户
|
||||
*/
|
||||
@RequestMapping("/queryUserCertification")
|
||||
@ApiOperation("查询已经进行实名的用户")
|
||||
public Result queryUserCertification(Long page, Long limit, String name,String phone) {
|
||||
if (page == null || limit == null) {
|
||||
return Result.error("分页条件为空");
|
||||
} else {
|
||||
IPage<UserCertification> iPage = new Page<>(page, limit);
|
||||
|
||||
return userCertificationService.queryUserCertification(iPage,name,phone);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核实名认证
|
||||
*/
|
||||
@RequestMapping("/auditorUserCertification")
|
||||
@ApiOperation("审核实名认证")
|
||||
public Result auditorUserCertification(Long status, Long id, String remek) {
|
||||
return userCertificationService.auditorUserCertification(status, id, remek);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,632 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.UserMoneyDao;
|
||||
import com.sqx.modules.app.dao.UserVipDao;
|
||||
import com.sqx.modules.app.dao.VipDetailsDao;
|
||||
import com.sqx.modules.app.entity.*;
|
||||
import com.sqx.modules.app.response.HomeMessageResponse;
|
||||
import com.sqx.modules.app.response.UserMessageResponse;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.artificer.dao.OrdersDao;
|
||||
import com.sqx.modules.artificer.entity.Artificer;
|
||||
import com.sqx.modules.artificer.entity.Certification;
|
||||
import com.sqx.modules.artificer.service.ArtificerService;
|
||||
import com.sqx.modules.artificer.service.RealNameService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.message.service.MessageService;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.CashOutService;
|
||||
import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import jodd.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/30
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "用户管理", tags = {"用户管理"})
|
||||
@RequestMapping(value = "/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
@Autowired
|
||||
private PayDetailsService payDetailsService;
|
||||
@Autowired
|
||||
private ArtificerService artificerService;
|
||||
@Autowired
|
||||
private UserMoneyDao userMoneyDao;
|
||||
@Autowired
|
||||
private OrdersDao ordersDao;
|
||||
@Autowired
|
||||
private RealNameService realNameService;
|
||||
@Autowired
|
||||
private CashOutService cashOutService;
|
||||
@Autowired
|
||||
private VipDetailsDao vipDetailsDao;
|
||||
@Autowired
|
||||
private UserVipDao userVipDao;
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@GetMapping("/queryByInvitationCode")
|
||||
@ApiOperation("通过邀请码查询用户")
|
||||
public Result queryByInvitationCode(String invitationCode){
|
||||
UserEntity userEntity = userService.queryByInvitationCode(invitationCode);
|
||||
return Result.success().put("data",userEntity);
|
||||
}
|
||||
@GetMapping("/merchantPromotion")
|
||||
@ApiOperation("商家推广统计")
|
||||
public Result merchantPromotion(UserEntity userEntity,Integer page, Integer limit){
|
||||
IPage<UserEntity> ResultUserEntity = userService.merchantPromotion(userEntity,page,limit);
|
||||
return Result.success().put("data",ResultUserEntity);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/{userId}", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@ApiParam("用户id") @PathVariable Long userId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
UserEntity userEntity = userService.queryByUserId(userId);
|
||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
//查询用户钱包
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
//查询本月充值
|
||||
Double consume = payDetailsService.instantselectSumPay(date, userId);
|
||||
//查询本月提现
|
||||
Double income = cashOutService.sumMoneyMonthByUserId(date, userId);
|
||||
//查询邀请人数
|
||||
int count = userService.queryInviterCount(userEntity.getInvitationCode());
|
||||
//本月订单数
|
||||
int ordersCount = ordersDao.selectCountOrderByUserId(userId,null, date);
|
||||
Artificer artificer = artificerService.selectArtificerByUserId(userId);
|
||||
//本月收入
|
||||
BigDecimal ordersMoney=new BigDecimal("0.00");
|
||||
if(artificer!=null){
|
||||
ordersMoney = ordersDao.selectSumMoneyMonth(artificer.getArtificerId(), date);
|
||||
}
|
||||
UserVip userVip = userVipDao.selectById(userId);
|
||||
if(userVip!=null){
|
||||
userEntity.setMember(userVip.getIsVip().intValue());
|
||||
userEntity.setVipEndTime(userVip.getEndTime());
|
||||
}
|
||||
|
||||
map.put("artificer", artificer);
|
||||
map.put("userEntity", userEntity);
|
||||
map.put("money", userMoney);
|
||||
map.put("consume", consume);
|
||||
map.put("income", income);
|
||||
map.put("count", count);
|
||||
map.put("ordersCount", ordersCount);
|
||||
map.put("ordersMoney", ordersMoney);
|
||||
return Result.success().put("data", map);
|
||||
}
|
||||
|
||||
@PostMapping("/updateSafetyMoney")
|
||||
@ApiOperation("修改")
|
||||
public Result updateSafetyMoney(Long userId,Integer type, BigDecimal money){
|
||||
userMoneyDao.updateCashDeposit(type, userId, money.doubleValue());
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
userMoneyDetails.setClassify(1);
|
||||
userMoneyDetails.setUserId(userId);
|
||||
if(type==1){
|
||||
userMoneyDetails.setTitle("[保证金]增加保证金");
|
||||
userMoneyDetails.setContent("系统增加保证金");
|
||||
}else{
|
||||
userMoneyDetails.setTitle("[保证金]减少保证金");
|
||||
userMoneyDetails.setContent("系统减少保证金");
|
||||
}
|
||||
userMoneyDetails.setType(type);
|
||||
userMoneyDetails.setMoney(money);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
if(userMoney.getCashDeposit().doubleValue()>0){
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
userEntity.setIsCashDeposit(2);
|
||||
userService.updateById(userEntity);
|
||||
}else{
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
userEntity.setIsCashDeposit(1);
|
||||
userService.updateById(userEntity);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/addCannotMoney/{userId}/{money}/{type}", method = RequestMethod.POST)
|
||||
@ApiOperation("修改金额")
|
||||
@ResponseBody
|
||||
public Result addCannotMoney(@PathVariable("userId") Long userId,@PathVariable("money") Double money,@PathVariable("type") Integer type){
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String format = simpleDateFormat.format(new Date());
|
||||
if(type==1){
|
||||
userMoneyService.updateMoney(1,userId,money);
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
//查询用户当前余额
|
||||
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
//插入余额
|
||||
userMoneyDetails.setBalance(userNowMoney.getMoney());
|
||||
//插入操作类型为已操作用户余额
|
||||
userMoneyDetails.setManipulateType(2);
|
||||
userMoneyDetails.setMoney(BigDecimal.valueOf(money));
|
||||
userMoneyDetails.setUserId(userId);
|
||||
userMoneyDetails.setContent("管理端充值:"+money);
|
||||
userMoneyDetails.setTitle("管理端充值金额");
|
||||
userMoneyDetails.setType(1);
|
||||
userMoneyDetails.setCreateTime(format);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
PayDetails payDetails = new PayDetails();
|
||||
payDetails.setState(1);
|
||||
payDetails.setCreateTime(format);
|
||||
payDetails.setOrderId("系统充值金额");
|
||||
payDetails.setUserId(userId);
|
||||
payDetails.setMoney(money);
|
||||
payDetails.setClassify(5);
|
||||
payDetailsService.save(payDetails);
|
||||
}else{
|
||||
userMoneyService.updateMoney(2,userId,money);
|
||||
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
//查询用户当前余额
|
||||
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
//插入余额
|
||||
userMoneyDetails.setBalance(userNowMoney.getMoney());
|
||||
//插入操作类型为已操作用户余额
|
||||
userMoneyDetails.setManipulateType(2);
|
||||
userMoneyDetails.setMoney(BigDecimal.valueOf(money));
|
||||
userMoneyDetails.setUserId(userId);
|
||||
userMoneyDetails.setContent("管理端减少:"+money);
|
||||
userMoneyDetails.setTitle("管理端减少金额");
|
||||
userMoneyDetails.setType(2);
|
||||
userMoneyDetails.setCreateTime(format);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
PayDetails payDetails = new PayDetails();
|
||||
payDetails.setState(1);
|
||||
payDetails.setCreateTime(format);
|
||||
payDetails.setOrderId("系统减少金额");
|
||||
payDetails.setUserId(userId);
|
||||
payDetails.setMoney(money);
|
||||
payDetails.setClassify(5);
|
||||
payDetailsService.save(payDetails);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectUserList", method = RequestMethod.GET)
|
||||
@ApiOperation("查询所有用户列表")
|
||||
@ResponseBody
|
||||
public Result selectUserList(Integer page, Integer limit,
|
||||
@ApiParam("用户id 手机号 昵称 模糊搜索") String phone,
|
||||
@ApiParam("性别 1男 2女") Integer sex,
|
||||
@ApiParam("来源 ") String platform,
|
||||
@ApiParam("0全部 1用户 2技师 ") Integer isAuthentication,
|
||||
@ApiParam("手机终端") String sysPhone,
|
||||
@ApiParam("状态 1正常 2封禁") Integer status,
|
||||
String userName,String invitationCode,Integer member,
|
||||
Integer ordersUser,String inviterCode,Integer isAgency,
|
||||
Integer isShop,String artificerName) {
|
||||
return Result.success().put("data", userService.selectUserPage(page, limit, phone, sex, platform, isAuthentication,sysPhone,
|
||||
status,userName,invitationCode,inviterCode,member,ordersUser,isAgency,isShop,artificerName));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/deleteUserByUserId/{userId}", method = RequestMethod.POST)
|
||||
@ApiOperation("删除用户")
|
||||
@ResponseBody
|
||||
public Result deleteUserByUserId(@PathVariable("userId") Long userId) {
|
||||
userService.removeById(userId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserByUserId", method = RequestMethod.POST)
|
||||
@ApiOperation("修改用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(@RequestBody UserEntity userEntity) {
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateUserStatusByUserId", method = RequestMethod.GET)
|
||||
@ApiOperation("禁用或启用用户")
|
||||
@ResponseBody
|
||||
public Result updateUserByUserId(Long userId) {
|
||||
UserEntity byId = userService.getById(userId);
|
||||
if (byId.getStatus().equals(1)) {
|
||||
byId.setStatus(2);
|
||||
userService.sendMsg(byId.getPhone(),"fh");
|
||||
} else {
|
||||
byId.setStatus(1);
|
||||
}
|
||||
userService.updateById(byId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取openid
|
||||
*
|
||||
* @param code 微信code
|
||||
* @return openid
|
||||
*/
|
||||
@GetMapping("/openId/{code:.+}/{userId}")
|
||||
@ApiOperation("根据code获取openid")
|
||||
public Result getOpenid(@PathVariable("code") String code, @PathVariable("userId") Long userId) {
|
||||
return userService.getOpenId(code, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/homeMessage")
|
||||
@ApiOperation("信息分析")
|
||||
public Result homeMessage() {
|
||||
HomeMessageResponse homeMessageResponse = new HomeMessageResponse();
|
||||
// 0查总 1查天 2查月 3查年
|
||||
//设置总用户人数
|
||||
homeMessageResponse.setTotalUsers(userService.queryUserCount(0, null, null,null));
|
||||
//设置今日新增
|
||||
homeMessageResponse.setNewToday(userService.queryUserCount(1, null, null,null));
|
||||
//设置本月新增
|
||||
homeMessageResponse.setNewMonth(userService.queryUserCount(2, null, null,null));
|
||||
//设置本年新增
|
||||
homeMessageResponse.setNewYear(userService.queryUserCount(3, null, null,null));
|
||||
|
||||
//设置总收入
|
||||
homeMessageResponse.setTotalRevenue(userService.queryPayMoney(0));
|
||||
//设置今日收入
|
||||
homeMessageResponse.setTodayRevenue(userService.queryPayMoney(1));
|
||||
//设置本月收入
|
||||
homeMessageResponse.setMonthRevenue(userService.queryPayMoney(2));
|
||||
//设置本年收入
|
||||
homeMessageResponse.setYearRevenue(userService.queryPayMoney(3));
|
||||
|
||||
return Result.success().put("data", homeMessageResponse);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户统计
|
||||
*/
|
||||
@GetMapping("/selectUserMessage")
|
||||
@ApiOperation("用户统计")
|
||||
public Result selectUserMessage(String date, Integer type){
|
||||
//统计总用户、用户、技师、手机号用户
|
||||
int userCount = userService.queryUserCount(type, date,null,null);
|
||||
int puUserCount = userService.queryUserCount(type, date,1,null);
|
||||
int jiUserCount = userService.queryUserCount(type, date,2,null);
|
||||
int phoneUserCount = userService.queryUserCount(type, date,null,1);
|
||||
int appCount = userService.userPlatform("app", date, type);
|
||||
int wxCount = userService.userPlatform("小程序", date, type);
|
||||
int wapCount = userService.userPlatform("H5", date, type);
|
||||
Map<String,Integer> result=new HashMap<>();
|
||||
result.put("userCount",userCount);
|
||||
result.put("puUserCount",puUserCount);
|
||||
result.put("jiUserCount",jiUserCount);
|
||||
result.put("phoneUserCount",phoneUserCount);
|
||||
result.put("appCount",appCount);
|
||||
result.put("wxCount",wxCount);
|
||||
result.put("wapCount",wapCount);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务收益
|
||||
*/
|
||||
@GetMapping("/selectOrdersMoney")
|
||||
@ApiOperation("服务收益")
|
||||
public Result selectOrdersMoney(String date, Integer type){
|
||||
//总收入 1待支付 2进行中 3待评论 4已取消 5已完成
|
||||
BigDecimal sumMoney = ordersDao.selectOrdersMoney(date, type, 1);
|
||||
//进行中订单
|
||||
BigDecimal jinMoney = ordersDao.selectOrdersMoney(date, type, 2);
|
||||
//已完成订单
|
||||
BigDecimal wanMoney = ordersDao.selectOrdersMoney(date, type, 3);
|
||||
//平台收益
|
||||
BigDecimal pingMoney = ordersDao.selectOrdersMoney(date, type, 4);
|
||||
Map<String,BigDecimal> result=new HashMap<>();
|
||||
result.put("sumMoney",sumMoney.setScale(2,BigDecimal.ROUND_DOWN));
|
||||
result.put("jinMoney",jinMoney.setScale(2,BigDecimal.ROUND_DOWN));
|
||||
result.put("wanMoney",wanMoney.setScale(2,BigDecimal.ROUND_DOWN));
|
||||
result.put("pingMoney",pingMoney.setScale(2,BigDecimal.ROUND_DOWN));
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单统计
|
||||
*/
|
||||
@GetMapping("/selectCountOrders")
|
||||
@ApiOperation("订单统计")
|
||||
public Result selectCountOrders(String date, Integer type){
|
||||
//状态 1待支付 2待服务 3待评论 4已取消 5已完成 6进行中 7出发 8到达
|
||||
int ordersCount = ordersDao.selectCountOrders(date, type, null);
|
||||
int dzfCount = ordersDao.selectCountOrders(date, type, 1);
|
||||
int dfwCount = ordersDao.selectCountOrders(date, type, 2);
|
||||
int dplCount = ordersDao.selectCountOrders(date, type, 3);
|
||||
int yqxCount = ordersDao.selectCountOrders(date, type, 4);
|
||||
int ywcCount = ordersDao.selectCountOrders(date, type, 5);
|
||||
int jxzCount = ordersDao.selectCountOrders(date, type, 6);
|
||||
int cfCount = ordersDao.selectCountOrders(date, type, 7);
|
||||
int ddCount = ordersDao.selectCountOrders(date, type, 8);
|
||||
Map<String,Integer> result=new HashMap<>();
|
||||
result.put("ordersCount",ordersCount);
|
||||
result.put("dzfCount",dzfCount);
|
||||
result.put("dfwCount",dfwCount);
|
||||
result.put("dplCount",dplCount);
|
||||
result.put("yqxCount",yqxCount);
|
||||
result.put("ywcCount",ywcCount);
|
||||
result.put("jxzCount",jxzCount);
|
||||
result.put("cfCount",cfCount);
|
||||
result.put("ddCount",ddCount);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/selectMoneyCount")
|
||||
@ApiOperation("统计收益")
|
||||
public Result selectMoneyCount(String date,Integer type){
|
||||
//支付类型 1订单 2实名认证 3充值 4优惠券 5会员
|
||||
Double ordersMoney = payDetailsService.selectSumPayByType(date, type, 1);
|
||||
Double realMoney = payDetailsService.selectSumPayByType(date, type, 2);
|
||||
Double money = payDetailsService.selectSumPayByType(date, type, 3);
|
||||
Double couponMoney = payDetailsService.selectSumPayByType(date, type, 4);
|
||||
Double memberMoney = payDetailsService.selectSumPayByType(date, type, 5);
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
BigDecimal sumMoney = BigDecimal.valueOf(ordersMoney).add(BigDecimal.valueOf(realMoney));
|
||||
sumMoney = sumMoney.add(BigDecimal.valueOf(money));
|
||||
sumMoney = sumMoney.add(BigDecimal.valueOf(couponMoney));
|
||||
sumMoney = sumMoney.add(BigDecimal.valueOf(memberMoney));
|
||||
result.put("ordersMoney",ordersMoney);result.put("realMoney",realMoney);
|
||||
result.put("money",money);result.put("couponMoney",couponMoney);
|
||||
result.put("memberMoney",memberMoney);result.put("sumMoney",sumMoney);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接单分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/takingOrdersMessage")
|
||||
@ApiOperation("接单分析")
|
||||
public Result takingOrdersMessage(Long page, Long limit, String date, Long type) {
|
||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||
return userService.takingOrdersMessage(iPage, type, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户分析
|
||||
*/
|
||||
@GetMapping("/userMessage")
|
||||
@ApiOperation("用户分析")
|
||||
public Result userMessage(String date, int type) {
|
||||
UserMessageResponse userMessageResponse = new UserMessageResponse();
|
||||
userMessageResponse.setTotalNumber(userService.queryUserCount(type, date, null,null));
|
||||
userMessageResponse.setVipUserNumber(userService.userMessage(date, type));
|
||||
userMessageResponse.setUserNumber(userService.queryUserCount(type, date, null,null) - userService.userMessage(date, type));
|
||||
return Result.success().put("data", userMessageResponse);
|
||||
}
|
||||
|
||||
@PostMapping("/updateArtificer")
|
||||
@ApiOperation("修改用户为技师")
|
||||
public Result updateArtificer(@RequestBody Certification certification){
|
||||
if(certification.getStatus().equals(1)){
|
||||
UserEntity user = userService.getById(certification.getUserId());
|
||||
certification.setStatus(1);
|
||||
certification.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
user.setIsAuthentication(2);
|
||||
Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId());
|
||||
if(artificer==null){
|
||||
artificer=new Artificer();
|
||||
artificer.setStatus(2);
|
||||
artificer.setUserId(certification.getUserId());
|
||||
artificer.setArtificerSales(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
artificer.setCreateTime(sdf.format(new Date()));
|
||||
artificer.setCreditScore(BigDecimal.valueOf(100));
|
||||
artificer.setTripWay(1);
|
||||
artificer.setRate(new BigDecimal(commonInfoService.findOne(381).getValue()));
|
||||
}
|
||||
artificer.setArtificerName(certification.getName());
|
||||
artificer.setArtificerImg(certification.getAvatar());
|
||||
artificer.setLifePhoto(certification.getImagePhoto());
|
||||
artificer.setCertificate(certification.getCertification());
|
||||
artificer.setContent(certification.getIndividualResume());
|
||||
artificer.setClassifyId(certification.getClassifyId());
|
||||
if(artificer.getArtificerId()!=null){
|
||||
artificerService.updateById(artificer);
|
||||
}else{
|
||||
artificerService.save(artificer);
|
||||
}
|
||||
|
||||
|
||||
BigDecimal cashDeposit = certification.getMoney();
|
||||
Long userId = user.getUserId();
|
||||
userMoneyDao.updateCashDeposit(1, userId, cashDeposit.doubleValue());
|
||||
user.setIsCashDeposit(2);
|
||||
userService.updateById(user);
|
||||
}else{
|
||||
UserEntity user = userService.getById(certification.getUserId());
|
||||
Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId());
|
||||
if(artificer!=null){
|
||||
UserEntity userEntity = userService.selectUserById(artificer.getUserId());
|
||||
if(userEntity!=null){
|
||||
userEntity.setIsAuthentication(0);
|
||||
userService.updateById(userEntity);
|
||||
realNameService.remove(new QueryWrapper<Certification>().eq("user_id",userEntity.getUserId()));
|
||||
}
|
||||
artificerService.removeById(artificer.getArtificerId());
|
||||
}
|
||||
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateUserIsAgency")
|
||||
@ApiOperation("修改是否为推广员")
|
||||
public Result updateUserIsAgency(Long userId,Integer isAgency){
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setIsAgency(isAgency);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/selectAgencyOrdersMoneyList")
|
||||
@ApiOperation("查询推广员收益排行榜")
|
||||
public Result selectAgencyOrdersMoneyList(Integer page,Integer limit,String userName,String phone,String startTime,String endTime){
|
||||
return userService.selectAgencyOrdersMoneyList(page, limit, userName, phone, startTime, endTime);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/giveUserVip")
|
||||
@ApiOperation("赠送用户会员")
|
||||
public Result giveUserVip(Long userId,Integer day){
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
//查看用户是否是会员
|
||||
UserVip userVip = userVipDao.selectOne(new QueryWrapper<UserVip>().eq("user_id", userId));
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if(userVip!=null){
|
||||
Date endDate = null;
|
||||
try {
|
||||
endDate = sdf.parse(userVip.getEndTime());
|
||||
if (endDate != null && System.currentTimeMillis() < (endDate.getTime())) {
|
||||
cal.setTime(endDate);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}else{
|
||||
userVip=new UserVip();
|
||||
//设置会员类型
|
||||
userVip.setVipNameType(1);
|
||||
//设置开通会员的用户id
|
||||
userVip.setUserId(userId);
|
||||
//设置会员的购买时间
|
||||
userVip.setCreateTime(sdf.format(new Date()));
|
||||
userVip.setIsVip(1L);
|
||||
}
|
||||
BigDecimal money=BigDecimal.ZERO;
|
||||
MessageInfo messageInfo=new MessageInfo();
|
||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
||||
userMoneyDetails.setMoney(money);
|
||||
userMoneyDetails.setUserId(userId);
|
||||
|
||||
userMoneyDetails.setContent("系统赠送"+day+"天会员");
|
||||
messageInfo.setContent("系统赠送"+day+"天会员");
|
||||
cal.add(Calendar.DAY_OF_MONTH, day);
|
||||
|
||||
userVip.setEndTime(sdf.format(cal.getTime()));
|
||||
if(userVip.getVipId()!=null){
|
||||
userVipDao.updateById(userVip);
|
||||
}else{
|
||||
userVipDao.insert(userVip);
|
||||
}
|
||||
userMoneyDetails.setTitle("开通会员");
|
||||
userMoneyDetails.setType(2);
|
||||
userMoneyDetails.setCreateTime(sdf.format(new Date()));
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
messageInfo.setTitle("开通会员");
|
||||
messageInfo.setState(String.valueOf(4));
|
||||
messageInfo.setUserName(userEntity.getUserName());
|
||||
messageInfo.setUserId(String.valueOf(userEntity.getUserId()));
|
||||
messageInfo.setCreateAt(sdf.format(new Date()));
|
||||
messageInfo.setIsSee("0");
|
||||
messageService.saveBody(messageInfo);
|
||||
if(StringUtil.isNotBlank(userEntity.getClientid())){
|
||||
userService.pushToSingle(messageInfo.getTitle(),messageInfo.getContent(),userEntity.getClientid());
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/removeUserVip")
|
||||
@ApiOperation("取消用户会员")
|
||||
public Result removeUserVip(Long userId){
|
||||
UserVip userVip = userVipDao.selectOne(new QueryWrapper<UserVip>().eq("user_id", userId));
|
||||
if(userVip!=null){
|
||||
userVipDao.deleteById(userVip.getVipId());
|
||||
}
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
MessageInfo messageInfo=new MessageInfo();
|
||||
messageInfo.setTitle("取消会员");
|
||||
messageInfo.setContent("系统取消了你的会员");
|
||||
messageInfo.setState(String.valueOf(4));
|
||||
messageInfo.setUserName(userEntity.getUserName());
|
||||
messageInfo.setUserId(String.valueOf(userEntity.getUserId()));
|
||||
messageInfo.setCreateAt(DateUtils.format(new Date()));
|
||||
messageInfo.setIsSee("0");
|
||||
messageService.saveBody(messageInfo);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/selectUserCountStatisticsByTime")
|
||||
@ApiOperation("用户统计")
|
||||
public Result selectUserCountStatisticsByTime(String startTime,String endTime){
|
||||
List<Integer> userCountList=new ArrayList<>();
|
||||
List<String> year=new ArrayList<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
Date parse = null;
|
||||
try {
|
||||
parse = simpleDateFormat.parse(startTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
calendar.setTime(parse);
|
||||
while (true){
|
||||
String dateTime = simpleDateFormat.format(calendar.getTime());
|
||||
int i = userService.queryUserCount(1, dateTime,null,null);
|
||||
userCountList.add(i);
|
||||
year.add(dateTime);
|
||||
if(dateTime.equals(endTime)){
|
||||
break;
|
||||
}
|
||||
calendar.add(Calendar.DATE,1);
|
||||
}
|
||||
Map<String,Object> result=new HashMap<>();
|
||||
result.put("userCountList",userCountList);
|
||||
result.put("year",year);
|
||||
return Result.success().put("data",result);
|
||||
}
|
||||
|
||||
@PostMapping("/integral")
|
||||
@ApiOperation("积分")
|
||||
public Result integral(String type,Integer current,Integer size,String date,String artificerId) throws ParseException {
|
||||
return Result.success(userService.integral(type,current,size,date,artificerId));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserFollowService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/userFollow")
|
||||
@Api(value = "关注|粉丝", tags = {"关注|粉丝"})
|
||||
public class UserFollowController {
|
||||
private UserFollowService userFollowService;
|
||||
|
||||
|
||||
/**
|
||||
* 查看我的关注
|
||||
*/
|
||||
@GetMapping("/selectMyFollow")
|
||||
@ApiOperation("查看我的关注")
|
||||
public Result selectMyFollow(Long userId, Long page, Long limit) {
|
||||
return userFollowService.selectMyFollow(userId, page, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看我的粉丝
|
||||
*/
|
||||
@GetMapping("/selectFans")
|
||||
@ApiOperation("查看我的粉丝")
|
||||
public Result selectFans(Long userId, Long page, Long limit) {
|
||||
return userFollowService.selectFans(userId, page, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注 / 取消关注
|
||||
**/
|
||||
|
||||
@PostMapping("/insert")
|
||||
@ApiOperation("关注/取消关注")
|
||||
public Result insert(Long userId, Long followUserId) {
|
||||
return userFollowService.insert(userId, followUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyArtificer;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyArtificerService;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.artificer.entity.Artificer;
|
||||
import com.sqx.modules.artificer.entity.ArtificerTime;
|
||||
import com.sqx.modules.artificer.service.ArtificerService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/Details")
|
||||
@Api("钱包明细")
|
||||
public class UserMoneyDetailsController {
|
||||
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
@Autowired
|
||||
private UserMoneyArtificerService userMoneyArtificerService;
|
||||
@Autowired
|
||||
private ArtificerService artificerService;
|
||||
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
|
||||
@ApiOperation("钱包明细")
|
||||
@GetMapping("/queryUserMoneyDetails")
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId,Integer classify,Integer type,Long artificerId) {
|
||||
return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type,artificerId);
|
||||
}
|
||||
|
||||
@GetMapping("/selectUserMoneyArtificer")
|
||||
@ApiOperation("查询用户充值师傅钱包")
|
||||
public Result selectUserMoneyArtificer(Integer page,Integer limit,Long userId){
|
||||
return userMoneyDetailsService.selectUserMoneyArtificer(page, limit, userId,null,null);
|
||||
}
|
||||
|
||||
@PostMapping("/updateUserMoneyArtificer")
|
||||
@ApiOperation("修改用户充值师傅钱包")
|
||||
public Result updateUserMoneyArtificer(Long userId, Long artificerId, BigDecimal money,Integer type){
|
||||
UserMoneyArtificer userMoneyArtificer = userMoneyArtificerService.getOne(new QueryWrapper<UserMoneyArtificer>().eq("user_id", userId).eq("artificer_id", artificerId));
|
||||
if(userMoneyArtificer==null){
|
||||
userMoneyArtificer=new UserMoneyArtificer();
|
||||
userMoneyArtificer.setUserId(userId);
|
||||
userMoneyArtificer.setArtificerId(artificerId);
|
||||
userMoneyArtificer.setMoney(money);
|
||||
userMoneyArtificer.setCreateTime(DateUtils.format(new Date()));
|
||||
userMoneyArtificerService.save(userMoneyArtificer);
|
||||
}else{
|
||||
userMoneyArtificerService.updateMoney(type,userId,artificerId,money.doubleValue());
|
||||
}
|
||||
UserMoneyDetails userMoneyDetails =new UserMoneyDetails();
|
||||
userMoneyDetails.setClassify(8);
|
||||
userMoneyDetails.setMoney(money);
|
||||
userMoneyDetails.setUserId(userId);
|
||||
Artificer artificer = artificerService.getById(artificerId);
|
||||
if(type==null || type==1){
|
||||
userMoneyDetails.setTitle("系统充值");
|
||||
userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包系统充值:"+money);
|
||||
userMoneyDetails.setType(1);
|
||||
}else{
|
||||
userMoneyDetails.setTitle("系统扣除");
|
||||
userMoneyDetails.setContent("指定技师“"+artificer.getArtificerName()+"”钱包系统扣除:"+money);
|
||||
userMoneyDetails.setType(2);
|
||||
}
|
||||
userMoneyDetails.setCreateTime(DateUtils.format(new Date()));
|
||||
userMoneyDetails.setArtificerId(artificerId);
|
||||
//查询用户当前余额
|
||||
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
//插入余额
|
||||
userMoneyDetails.setBalance(userNowMoney.getMoney());
|
||||
//插入操作类型为已操作用户余额
|
||||
userMoneyDetails.setManipulateType(2);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Api(value = "会员管理", tags = {"会员管理"})
|
||||
@RequestMapping(value = "/vipDetails")
|
||||
public class VipDetailsController {
|
||||
|
||||
@Autowired
|
||||
private VipDetailsService vipDetailsService;
|
||||
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@PostMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
return vipDetailsService.insertVipDetails(vipDetails);
|
||||
}
|
||||
|
||||
|
||||
@ApiParam("修改会员的详情信息")
|
||||
@PostMapping("/updateVipDetails")
|
||||
public Result updateVipDetails(@RequestBody VipDetails vipDetails) {
|
||||
vipDetailsService.updateById(vipDetails);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("删除的详情信息")
|
||||
@PostMapping("/deleteVipDetails")
|
||||
public Result deleteVipDetails(Long id) {
|
||||
vipDetailsService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiParam("查询会员列表")
|
||||
@GetMapping("/selectVipDetailsList")
|
||||
public Result selectVipDetailsList(Integer page,Integer limit) {
|
||||
return Result.success().put("data",new PageUtils(vipDetailsService.page(new Page<>(page,limit))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.Address;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.AddressService;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/address")
|
||||
@Api(value = "用户地址", tags = {"用户地址"})
|
||||
public class AppAddressController {
|
||||
|
||||
@Autowired
|
||||
private AddressService addressService;
|
||||
|
||||
@Login
|
||||
@PostMapping("/insertAddress")
|
||||
@ApiOperation("添加地址")
|
||||
public Result insertAddress(@LoginUser UserEntity user,@RequestBody Address address){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
address.setCreateTime(sdf.format(new Date()));
|
||||
if(address.getIsDefault()==1){
|
||||
addressService.updateAddressIsDefault(user.getUserId());
|
||||
}
|
||||
address.setUserId(user.getUserId());
|
||||
addressService.save(address);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@PostMapping("/updateAddress")
|
||||
@ApiOperation("修改地址")
|
||||
public Result updateAddress(@LoginUser UserEntity user,@RequestBody Address address){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
address.setCreateTime(sdf.format(new Date()));
|
||||
if(address.getIsDefault()==1){
|
||||
addressService.updateAddressIsDefault(user.getUserId());
|
||||
}
|
||||
address.setUserId(user.getUserId());
|
||||
addressService.updateById(address);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@PostMapping("/deleteAddress")
|
||||
@ApiOperation("删除我的地址")
|
||||
public Result deleteAddress(Long addressId){
|
||||
addressService.removeById(addressId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectAddressListById")
|
||||
@ApiOperation("获取我的所有地址")
|
||||
public Result selectAddressListById(@LoginUser UserEntity user,Integer page,Integer limit){
|
||||
IPage<Address> addressIPage = addressService.page(new Page<>(page, limit), new QueryWrapper<Address>().eq("user_id", user.getUserId()));
|
||||
return Result.success().put("data",new PageUtils(addressIPage));
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectAddressById")
|
||||
@ApiOperation("获取我的默认地址")
|
||||
public Result selectAddressById(@LoginUser UserEntity user){
|
||||
Address one = addressService.getOne(new QueryWrapper<Address>().eq("user_id", user.getUserId()).orderByDesc("is_default").last(" limit 1"));
|
||||
return Result.success().put("data",one);
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@GetMapping("selectAddressByAddressId")
|
||||
@ApiOperation("根据地址id查询地址详细信息")
|
||||
public Result selectAddressByAddressId(Long addressId){
|
||||
return Result.success().put("data",addressService.getById(addressId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,256 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.dyplsapi20170525.models.BindAxnResponse;
|
||||
import com.aliyun.dyplsapi20170525.models.BindAxnResponseBody;
|
||||
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponse;
|
||||
import com.aliyun.dyplsapi20170525.models.UpdateSubscriptionResponseBody;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.dao.UserCertificationDao;
|
||||
import com.sqx.modules.app.entity.UserCertification;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.artificer.entity.Artificer;
|
||||
import com.sqx.modules.artificer.service.ArtificerService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.coupon.entity.CouponUser;
|
||||
import com.sqx.modules.coupon.service.CouponUserService;
|
||||
import com.sqx.modules.message.dao.MessageInfoDao;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.utils.MD5Util;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
@Api(value = "APP管理", tags = {"APP管理"})
|
||||
@Slf4j
|
||||
public class AppController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AppService appService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
@Autowired
|
||||
private MessageInfoDao messageInfoDao;
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
@Autowired
|
||||
private CouponUserService couponUserService;
|
||||
@Autowired
|
||||
private ArtificerService artificerService;
|
||||
|
||||
@Login
|
||||
@ApiOperation("生成虚拟号码")
|
||||
@GetMapping("/insertVirtualPhone")
|
||||
public Result insertVirtualPhone(String phoneA, String phoneB) {
|
||||
MessageInfo messageInfo1 = messageInfoDao.selectOne(new QueryWrapper<MessageInfo>().eq("user_name", phoneA).eq("by_user_name", phoneB));
|
||||
if (messageInfo1 == null) {
|
||||
messageInfo1 = messageInfoDao.selectOne(new QueryWrapper<MessageInfo>().eq("user_name", phoneB).eq("by_user_name", phoneA));
|
||||
}
|
||||
String accessKeyId = commonInfoService.findOne(386).getValue();
|
||||
String accessKeySecret = commonInfoService.findOne(387).getValue();
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,您的 AccessKey ID
|
||||
.setAccessKeyId(accessKeyId)
|
||||
// 必填,您的 AccessKey Secret
|
||||
.setAccessKeySecret(accessKeySecret);
|
||||
// 访问的域名
|
||||
config.endpoint = "dyplsapi.aliyuncs.com";
|
||||
try {
|
||||
String poolKey = commonInfoService.findOne(382).getValue();
|
||||
com.aliyun.dyplsapi20170525.Client client = new com.aliyun.dyplsapi20170525.Client(config);
|
||||
if (messageInfo1 != null) {
|
||||
com.aliyun.dyplsapi20170525.models.UpdateSubscriptionRequest updateSubscriptionRequest = new com.aliyun.dyplsapi20170525.models.UpdateSubscriptionRequest();
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
updateSubscriptionRequest.setPoolKey(poolKey);
|
||||
updateSubscriptionRequest.setSubsId(messageInfo1.getTitle());
|
||||
updateSubscriptionRequest.setPhoneNoX(messageInfo1.getContent());
|
||||
String value = commonInfoService.findOne(418).getValue();
|
||||
if("是".equals(value)){
|
||||
updateSubscriptionRequest.setIsRecordingEnabled(true);
|
||||
}
|
||||
Calendar calendar=Calendar.getInstance();
|
||||
calendar.add(Calendar.HOUR,1);
|
||||
updateSubscriptionRequest.setExpiration(DateUtils.format(calendar.getTime()));
|
||||
updateSubscriptionRequest.setOperateType("updateExpire");
|
||||
UpdateSubscriptionResponse updateSubscriptionResponse = client.updateSubscriptionWithOptions(updateSubscriptionRequest, runtime);
|
||||
UpdateSubscriptionResponseBody body = updateSubscriptionResponse.getBody();
|
||||
String code = body.getCode();
|
||||
if("OK".equals(code)){
|
||||
return Result.success().put("data", messageInfo1.getContent());
|
||||
}
|
||||
messageInfoDao.deleteById(messageInfo1.getId());
|
||||
}
|
||||
MessageInfo messageInfo = new MessageInfo();
|
||||
messageInfo.setState("18");
|
||||
messageInfo.setUserName(phoneA);
|
||||
messageInfo.setByUserName(phoneB);
|
||||
com.aliyun.dyplsapi20170525.models.BindAxnRequest bindAxnRequest = new com.aliyun.dyplsapi20170525.models.BindAxnRequest();
|
||||
bindAxnRequest.setPoolKey(poolKey);
|
||||
bindAxnRequest.setPhoneNoA(phoneA);
|
||||
bindAxnRequest.setPhoneNoB(phoneB);
|
||||
String value = commonInfoService.findOne(418).getValue();
|
||||
if("是".equals(value)){
|
||||
bindAxnRequest.setIsRecordingEnabled(true);
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.HOUR, 1);
|
||||
bindAxnRequest.setExpiration(DateUtils.format(calendar.getTime()));
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
BindAxnResponse bindAxnResponse = client.bindAxnWithOptions(bindAxnRequest, runtime);
|
||||
BindAxnResponseBody body = bindAxnResponse.getBody();
|
||||
String code = body.code;
|
||||
if (!"OK".equals(code)) {
|
||||
return Result.error("获取号码失败!" + body.getMessage());
|
||||
}
|
||||
BindAxnResponseBody.BindAxnResponseBodySecretBindDTO secretBindDTO = body.getSecretBindDTO();
|
||||
messageInfo.setContent(secretBindDTO.getSecretNo());
|
||||
messageInfo.setTitle(secretBindDTO.getSubsId());
|
||||
messageInfo.setCreateAt(DateUtils.format(new Date()));
|
||||
messageInfoDao.insert(messageInfo);
|
||||
return Result.success().put("data", secretBindDTO.getSecretNo());
|
||||
} catch (TeaException error) {
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
return Result.error("获取号码失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@ApiOperation("用户端修改密码")
|
||||
public Result updatePwd(@LoginUser UserEntity user, String pwd, String oldPwd) {
|
||||
if (!user.getPassword().equals(DigestUtils.sha256Hex(oldPwd))) {
|
||||
return Result.error("原始密码不正确!");
|
||||
}
|
||||
if (pwd.equals(oldPwd)) {
|
||||
return Result.error("新密码不能与旧密码相同!");
|
||||
}
|
||||
user.setPassword(DigestUtils.sha256Hex(pwd));
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updatePhone", method = RequestMethod.POST)
|
||||
@ApiOperation("用户端换绑手机号")
|
||||
@ResponseBody
|
||||
public Result updatePhone(@RequestAttribute("userId") Long userId, @RequestParam String phone, @RequestParam String msg) {
|
||||
return userService.updatePhone(phone, msg, userId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUser", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
public Result updateUser(@RequestBody UserEntity userEntity,@RequestAttribute("userId") Long userId) {
|
||||
userEntity.setUserId(userId);
|
||||
userService.updateById(userEntity);
|
||||
//更新artificer 技师主表
|
||||
UpdateWrapper<Artificer> uw = new UpdateWrapper<>();
|
||||
uw.set("artificer_img",userEntity.getAvatar());
|
||||
uw.eq("user_id",userId);
|
||||
artificerService.update(uw);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserImageUrl", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改头像")
|
||||
@ResponseBody
|
||||
public Result updateUserImageUrl(@LoginUser UserEntity user, String avatar) {
|
||||
user.setAvatar(avatar);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/updateUserName", method = RequestMethod.POST)
|
||||
@ApiOperation("用户修改昵称")
|
||||
@ResponseBody
|
||||
public Result updateUserName(@LoginUser UserEntity user, String userName) {
|
||||
user.setUserName(userName);
|
||||
userService.updateById(user);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping(value = "/selectUserById", method = RequestMethod.GET)
|
||||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@LoginUser UserEntity user) {
|
||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(user.getUserId());
|
||||
user.setMoney(userMoney.getMoney());
|
||||
|
||||
CouponUser couponUser = couponUserService.selectCountByUserId(user.getUserId());
|
||||
user.setMember(couponUser.getNum());
|
||||
|
||||
//获取地址及更新时间
|
||||
Artificer artificer = artificerService.selectArtificerByUserId(user.getUserId());
|
||||
if(artificer != null){
|
||||
user.setLoglattime(artificer.getUpdateTime());
|
||||
user.setLoglataddress(artificer.getAddress());
|
||||
}
|
||||
|
||||
|
||||
return Result.success().put("data", user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectNewApp", method = RequestMethod.GET)
|
||||
@ApiOperation("升级检测")
|
||||
@ResponseBody
|
||||
public Result selectNewApp(Integer classify) {
|
||||
return Result.success().put("data", appService.selectNewApp(classify));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/updateClientId", method = RequestMethod.POST)
|
||||
@ApiOperation("绑定ClientId")
|
||||
@ResponseBody
|
||||
public Result updateClientId(String clientId,Long userId,Integer sysPhone ) {
|
||||
userService.updateUserClientIdIsNull(clientId);
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setSysPhone(sysPhone);
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setClientid(clientId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.map.CommonMapUtils;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.utils.UserConstantInterface;
|
||||
import com.sqx.modules.app.utils.WxPhone;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
import com.sqx.modules.utils.MD5Util;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
import weixin.popular.bean.sns.SnsToken;
|
||||
import weixin.popular.bean.user.User;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app/Login")
|
||||
@Api("APP登录接口")
|
||||
@Slf4j
|
||||
public class AppLoginController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private IAppleService appleService;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
|
||||
@ApiOperation("微信小程序登陆")
|
||||
@RequestMapping(value = "/wxLogin", method = RequestMethod.GET)
|
||||
public Result wxLogin(@ApiParam("小程序code码") String code,Integer type){
|
||||
return userService.wxLogin(code,type);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("小程序登录新增或修改个人信息")
|
||||
@RequestMapping(value = "/insertWxUser", method = RequestMethod.POST)
|
||||
public Result insertWxUser(@RequestBody UserEntity userInfo){
|
||||
return userService.wxRegister(userInfo);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/appleLogin", method = RequestMethod.GET)
|
||||
@ApiOperation("苹果登陆获取appleUserId")
|
||||
public Result loginVerify(@RequestParam("identityToken") String identityToken) {
|
||||
try {
|
||||
log.info("苹果token:{}", identityToken);
|
||||
JSONObject jsonObject = JSON.parseObject(identityToken);
|
||||
JSONObject userInfo = jsonObject.getJSONObject("userInfo");
|
||||
String identityTokens = userInfo.getString("identityToken");
|
||||
return appleService.getAppleUserInfo(identityTokens);
|
||||
} catch (Exception e) {
|
||||
log.error("苹果token校验失败:{}", identityToken, e);
|
||||
return Result.error("苹果账号验证失败,请退出重试!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("苹果登录")
|
||||
@RequestMapping(value = "/insertAppleUser", method = RequestMethod.GET)
|
||||
public Result insertAppleUser(@RequestParam String appleId){
|
||||
return userService.iosRegister(appleId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/iosBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("苹果登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result iosBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String appleId,@RequestParam String platform,@RequestParam Integer sysPhone) {
|
||||
return userService.iosBindMobile(phone, code, appleId, platform, sysPhone);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxAppLogin", method = RequestMethod.POST)
|
||||
@ApiOperation("微信APP登录")
|
||||
@ResponseBody
|
||||
public Result wxAppLogin(@RequestParam String wxOpenId,@RequestParam String token) {
|
||||
return userService.wxAppLogin(wxOpenId,token);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/wxBindMobile", method = RequestMethod.POST)
|
||||
@ApiOperation("微信登录绑定手机号")
|
||||
@ResponseBody
|
||||
public Result wxBindMobile(@RequestParam String phone,@RequestParam String code,@RequestParam String wxOpenId,@RequestParam String token,@RequestParam String platform,@RequestParam Integer sysPhone) {
|
||||
return userService.wxBindMobile(phone, code, wxOpenId, token, platform, sysPhone);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端openid登录呢")
|
||||
@RequestMapping(value = "/openid/login", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result loginByOpenId(@RequestParam String openId) {
|
||||
return userService.loginByOpenId(openId);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/registerCode", method = RequestMethod.POST)
|
||||
@ApiOperation("app或h5注册或登录")
|
||||
@ResponseBody
|
||||
public Result registerCode( String phone, String msg,String platform, Integer sysPhone,String openId,String inviterCode,String password,String userName,String avatar,String scanningChannel) {
|
||||
return userService.registerCode(phone,msg,platform,sysPhone,openId,inviterCode,password,userName,avatar,scanningChannel);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端发送验证码")
|
||||
@RequestMapping(value = "/sendMsg/{phone}/{state}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result sendMsg(@PathVariable String phone, @PathVariable String state) {
|
||||
return userService.sendMsg(phone, state);
|
||||
}
|
||||
|
||||
@ApiOperation("解密手机号")
|
||||
@RequestMapping(value = "/selectPhone",method = RequestMethod.POST)
|
||||
public Result getPhoneNumberBeanS5(@RequestBody WxPhone wxPhone) {
|
||||
return UserConstantInterface.decryptS5(wxPhone.getDecryptData(), wxPhone.getKey(), wxPhone.getIv());
|
||||
}
|
||||
@ApiParam("登录app")
|
||||
@RequestMapping(value = "/loginApp",method = RequestMethod.POST)
|
||||
public Result loginApp(@RequestParam String phone,@RequestParam String password){
|
||||
return userService.loginApp(phone,password);
|
||||
}
|
||||
@CrossOrigin
|
||||
@ApiParam("注册app")
|
||||
@RequestMapping(value = "/registApp",method = RequestMethod.POST)
|
||||
public Result registApp(@RequestParam String userName,@RequestParam String phone,@RequestParam String password,String msg,@RequestParam String platform,String invitation){
|
||||
return userService.registApp(userName,phone,password,msg,platform,invitation);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端忘记密码")
|
||||
@RequestMapping(value = "/forgetPwd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result forgetPwd(String pwd, String phone, String msg) {
|
||||
return userService.forgetPwd(pwd, phone, msg);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/selectCity")
|
||||
@ApiOperation("根据经纬度获取城市")
|
||||
public Result selectCity(String lat, String lng) {
|
||||
JSONObject adInfo = CommonMapUtils.getLocationToAdInfo(lng, lat);//根据坐标获取行政区划信息
|
||||
if(adInfo == null) return Result.error("获取定位失败!");
|
||||
return Result.success().put("data", adInfo);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getOpenId")
|
||||
@ApiOperation("公众号根据code换取openId")
|
||||
public Result getOpenId(String code,Long userId) {
|
||||
try {
|
||||
//微信appid
|
||||
CommonInfo one = commonInfoService.findOne(5);
|
||||
//微信秘钥
|
||||
CommonInfo two = commonInfoService.findOne(21);
|
||||
SnsToken snsToken = SnsAPI.oauth2AccessToken(one.getValue(), two.getValue(), code);
|
||||
|
||||
String openid = snsToken.getOpenid();
|
||||
User user = SnsAPI.userinfo(snsToken.getAccess_token(), openid, "zh_CN");
|
||||
return Result.success().put("data",user);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("GET_OPENID_FAIL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/bindOpenId")
|
||||
@ApiOperation("用户绑定公众号openId")
|
||||
public Result bindOpenId(Long userId,String openId){
|
||||
UserEntity userEntity=new UserEntity();
|
||||
userEntity.setUserId(userId);
|
||||
userEntity.setOpenId(openId);
|
||||
userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/daySub")
|
||||
@ApiOperation("两个日期之间的差值")
|
||||
public Result daySub(String startTime,String endTime) throws ParseException {
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(sdf.parse(startTime));
|
||||
long time1 = cal.getTimeInMillis();
|
||||
cal.setTime(sdf.parse(endTime));
|
||||
long time2 = cal.getTimeInMillis();
|
||||
long between_days=(time2-time1)/(1000*3600*24);
|
||||
return Result.success().put("data",Integer.parseInt(String.valueOf(between_days))+1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserBrowse;
|
||||
import com.sqx.modules.app.service.UserBrowseService;
|
||||
import com.sqx.modules.app.service.UserFollowService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/app/userBrowse")
|
||||
@Api(value = "app 访问 | 浏览 ", tags = {"app 访问 | 浏览 "})
|
||||
public class AppUserBrowseController {
|
||||
private UserBrowseService userBrowseService;
|
||||
|
||||
@ApiOperation("查询我的访客")
|
||||
@Login
|
||||
@RequestMapping("/myVisitor")
|
||||
public Result selectMyVisitor(@RequestAttribute Long userId, Long page, Long limit) {
|
||||
return userBrowseService.selectMyVisitor(userId, page, limit);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping("/myBrowse")
|
||||
@ApiOperation("浏览足迹")
|
||||
public Result selectMyBrowse(@RequestAttribute Long userId, Long page, Long limit) {
|
||||
return userBrowseService.selectMyBrowse(userId, page, limit);
|
||||
}
|
||||
|
||||
@Login
|
||||
@RequestMapping("/selectAmount")
|
||||
@ApiOperation("粉丝量 关注量 访客量 足迹量")
|
||||
public Result selectAmount(@RequestAttribute Long userId) {
|
||||
return userBrowseService.selectAmount(userId);
|
||||
}
|
||||
|
||||
@ApiOperation("删除我的访客")
|
||||
@RequestMapping(value = "/deleteMyVisitor", method = RequestMethod.POST)
|
||||
public Result deleteMyVisitor(Long id) {
|
||||
return userBrowseService.deleteMyVisitor(id);
|
||||
}
|
||||
|
||||
@ApiOperation(("删除我的足迹"))
|
||||
@RequestMapping(value = "/deleteMyBrowse", method = RequestMethod.POST)
|
||||
public Result deleteMyBrowse(Long id) {
|
||||
|
||||
return userBrowseService.deleteMyBrowse(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserCertification;
|
||||
import com.sqx.modules.app.service.UserCertificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/app/userCertification")
|
||||
@Api("app实 名 认 证")
|
||||
public class AppUserCertificationController {
|
||||
|
||||
private UserCertificationService userCertificationService;
|
||||
|
||||
/**
|
||||
* 实名认证
|
||||
**/
|
||||
@RequestMapping("/insert")
|
||||
@Login
|
||||
@ApiOperation("实名认证")
|
||||
public Result insert(@RequestAttribute Long userId, @ApiParam("真实姓名") String name,
|
||||
@ApiParam("身份证号") String idNumber, @ApiParam("正面") String front,
|
||||
@ApiParam("反面") String back,Integer classify,String phone,String address,
|
||||
Integer sex,String infantImg,String infantImgs,String birthdate) {
|
||||
return userCertificationService.insert(userId, name, idNumber, front, back,classify,phone,address,sex,infantImg,infantImgs,birthdate,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否进行实名
|
||||
*/
|
||||
@RequestMapping("/isInsert")
|
||||
@Login
|
||||
@ApiOperation("是否进行实名")
|
||||
public Result isInsert(@RequestAttribute Long userId) {
|
||||
return userCertificationService.isInsert(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自己的实名信息
|
||||
*/
|
||||
@RequestMapping("/queryInsert")
|
||||
@Login
|
||||
@ApiOperation("查询自己的实名信息")
|
||||
public Result queryInsert(@RequestAttribute Long userId,Integer classify) {
|
||||
|
||||
return userCertificationService.queryInsert(userId,classify);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/exitMoney")
|
||||
@ApiOperation("退保证金")
|
||||
@Login
|
||||
public Result exitMoney(@RequestAttribute Long userId){
|
||||
return userCertificationService.exitMoney(userId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserFollow;
|
||||
import com.sqx.modules.app.service.UserFollowService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/app/userFollow")
|
||||
@Api("app 关注")
|
||||
public class AppUserFollowController {
|
||||
private UserFollowService userFollowService;
|
||||
|
||||
/**
|
||||
* 关注 / 取消关注
|
||||
**/
|
||||
|
||||
@RequestMapping("/insert")
|
||||
@Login
|
||||
public Result insert(@RequestAttribute Long userId, Long followUserId) {
|
||||
return userFollowService.insert(userId, followUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看我的关注
|
||||
*/
|
||||
@RequestMapping("/selectMyFollow")
|
||||
@Login
|
||||
public Result selectMyFollow(@RequestAttribute Long userId,Long page,Long limit) {
|
||||
return userFollowService.selectMyFollow(userId,page,limit);
|
||||
}
|
||||
/**
|
||||
* 查看我的粉丝
|
||||
*/
|
||||
@RequestMapping("/selectFans")
|
||||
@Login
|
||||
public Result selectFans(@RequestAttribute Long userId,Long page,Long limit) {
|
||||
return userFollowService.selectFans(userId,page,limit);
|
||||
}
|
||||
/**
|
||||
* 查看我是否关注
|
||||
*/
|
||||
@RequestMapping("/selectFollowUser")
|
||||
@Login
|
||||
public Result selectFollowUser(@RequestAttribute Long userId,Long followUserId) {
|
||||
return userFollowService.selectFollowUser(userId,followUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyArtificer;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.entity.UserMoneyResult;
|
||||
import com.sqx.modules.app.service.UserMoneyArtificerService;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.artificer.entity.Period;
|
||||
import com.sqx.modules.artificer.service.ArtificerService;
|
||||
import com.sqx.modules.utils.PeriodUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/app/userMoney")
|
||||
@Api("app 钱包 ")
|
||||
public class AppUserMoneyController {
|
||||
|
||||
private UserMoneyService userMoneyService;
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
private UserMoneyArtificerService userMoneyArtificerService;
|
||||
private UserService userService;
|
||||
private ArtificerService artificerService;
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectUserMoneyArtificer")
|
||||
@ApiOperation("查询用户充值师傅钱包")
|
||||
public Result selectUserMoneyArtificer(Integer page,Integer limit,Long artificerId,@RequestAttribute Long userId){
|
||||
return userMoneyDetailsService.selectUserMoneyArtificer(page, limit, userId,artificerId,1);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectUserMoneyArtificers")
|
||||
@ApiOperation("查询用户充值师傅钱包")
|
||||
public Result selectUserMoneyArtificers(Integer page,Integer limit,Long artificerId){
|
||||
IPage<UserMoneyArtificer> page1 = userMoneyArtificerService.page(new Page<>(page, limit), new QueryWrapper<UserMoneyArtificer>().eq(artificerId != null, "artificer_id", artificerId));
|
||||
List<UserMoneyArtificer> records = page1.getRecords();
|
||||
for(UserMoneyArtificer userMoneyArtificer:records){
|
||||
userMoneyArtificer.setUserEntity(userService.getById(userMoneyArtificer.getUserId()));
|
||||
userMoneyArtificer.setArtificer(artificerService.selectArtificerById(null,userMoneyArtificer.getArtificerId(),null,null));
|
||||
}
|
||||
|
||||
return Result.success().put("data",new PageUtils(page1));
|
||||
}
|
||||
|
||||
@Login
|
||||
@PostMapping("/payUserMoneyArtificer")
|
||||
@ApiOperation("钱包充值 用户指定师傅钱包")
|
||||
public Result payUserMoneyArtificer(@RequestAttribute Long userId,Long artificerId,BigDecimal money){
|
||||
return userMoneyService.payUserMoneyArtificer(userId, artificerId, money);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/selectMyMoney")
|
||||
@Login
|
||||
@ApiOperation("我的钱包余额")
|
||||
public Result selectMyMoney(@RequestAttribute Long userId) {
|
||||
UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(userId);
|
||||
UserMoneyResult userMoneyResult = new UserMoneyResult();
|
||||
userMoneyResult.setUserId(userMoney.getUserId());
|
||||
userMoneyResult.setMoney(userMoney.getMoney());
|
||||
userMoneyResult.setCashDeposit(userMoney.getCashDeposit());
|
||||
userMoneyResult.setId(userMoney.getId());
|
||||
//获取当前时间
|
||||
Date CurrentPeriod = new Date();
|
||||
//获取当前时间周期的上一个周期
|
||||
Period periodDate= PeriodUtil.previousIssue(CurrentPeriod);
|
||||
Period period = new Period();
|
||||
period.setArtificerId(String.valueOf(userId));
|
||||
period.setDetailsType(1);
|
||||
//获取上一周期的最后一天
|
||||
period.setStartFundData(periodDate.getStartFundData());
|
||||
period.setEndFundData(CurrentPeriod);
|
||||
List<UserMoneyDetails> filteredPersons = userMoneyDetailsService.selectIncome(period);
|
||||
//进账
|
||||
Long incomeLong= filteredPersons.stream()
|
||||
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 1)
|
||||
.mapToLong(UserMoneyDetails -> UserMoneyDetails.getMoney().longValue())
|
||||
.sum();
|
||||
//出账
|
||||
Long outgoingLong= filteredPersons.stream()
|
||||
.filter(UserMoneyDetails -> UserMoneyDetails.getType() == 2)
|
||||
.mapToLong(UserMoneyDetails -> UserMoneyDetails.getMoney().longValue())
|
||||
.sum();
|
||||
BigDecimal income = new BigDecimal(incomeLong);
|
||||
BigDecimal outgoing = new BigDecimal(outgoingLong);
|
||||
BigDecimal balance = income.subtract(outgoing);
|
||||
//插入可提现金额
|
||||
userMoneyResult.setWithdrawableAmount(userMoney.getMoney().subtract(balance));
|
||||
return Result.success().put("data",userMoneyResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的收益
|
||||
*/
|
||||
@GetMapping("/selectMyProfit")
|
||||
@Login
|
||||
@ApiOperation("我的收益")
|
||||
public Result selectMyProfit(@RequestAttribute Long userId) {
|
||||
return Result.success().put("data", userMoneyService.selectMyProfit(userId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 余额明细
|
||||
*/
|
||||
@GetMapping("/balanceDetailed")
|
||||
@Login
|
||||
@ApiOperation("余额明细")
|
||||
public Result balanceDetailed(@RequestAttribute Long userId, Long page, Long limit) {
|
||||
Page<UserMoneyDetails> pages = new Page<>(page, limit);
|
||||
return Result.success().put("data", userMoneyService.balanceDetailed(userId, pages));
|
||||
}
|
||||
|
||||
@Login
|
||||
@ApiOperation("钱包明细")
|
||||
@GetMapping("/queryUserMoneyDetails")
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit,@RequestAttribute Long userId,Integer classify,Integer type,Long artificerId) {
|
||||
|
||||
return userMoneyDetailsService.queryUserMoneyDetails(page, limit, userId,classify,type,artificerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收益明细
|
||||
*/
|
||||
@GetMapping("/profitDetailed")
|
||||
@Login
|
||||
@ApiOperation("收益明细")
|
||||
public Result profitDetailed(@RequestAttribute Long userId, Long page, Long limit) {
|
||||
if (page != null || limit != null) {
|
||||
return Result.error("分页条件为空");
|
||||
} else {
|
||||
IPage ipage = new Page(page, limit);
|
||||
return Result.success().put("data", userMoneyService.profitDetailed(userId, ipage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(value = "app 用户会员信息", tags = {"app 用户会员信息"})
|
||||
@RequestMapping(value = "/app/UserVip")
|
||||
public class AppUserVipController extends AbstractController {
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectUserVip")
|
||||
@ApiOperation("查询用户会员信息")
|
||||
public Result selectUserVip(@RequestAttribute Long userId) {
|
||||
return Result.success().put("data", userVipService.selectUserVipByUserId(userId));
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/isUserVip")
|
||||
@ApiOperation("查询用户是否是会员")
|
||||
public Result isUserVip(@RequestAttribute Long userId) {
|
||||
return userVipService.isUserVip(userId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.service.VipDetailsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/VipDetails")
|
||||
@AllArgsConstructor
|
||||
@Api("app 会员详情信息")
|
||||
public class AppVipDetailsController {
|
||||
private VipDetailsService appVipDetailsService;
|
||||
/**
|
||||
* 查询会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("查询会员的详情信息")
|
||||
@GetMapping("/selectVipDetails")
|
||||
public Result selectVipDetails() {
|
||||
return appVipDetailsService.selectVipDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员的详情信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Login
|
||||
@ApiParam("添加会员的详情信息")
|
||||
@GetMapping("/insertVipDetails")
|
||||
public Result insertVipDetails(VipDetails vipDetails) {
|
||||
return appVipDetailsService.insertVipDetails(vipDetails);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.Address;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface AddressDao extends BaseMapper<Address> {
|
||||
|
||||
int updateAddressIsDefault(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.App;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户升级
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppDao extends BaseMapper<App> {
|
||||
|
||||
List<App> selectNewApp(Integer classify);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.Msg;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsgDao extends BaseMapper<Msg> {
|
||||
|
||||
Msg findByPhone(String phone);
|
||||
|
||||
Msg findByPhoneAndCode(String phone, String msg);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserBrowse;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserBrowseDao extends BaseMapper<UserBrowse> {
|
||||
|
||||
IPage<Map<String, Object>> selectMyBrowse(IPage iPage, Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyVisitor1(Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyBrowse1(Long userId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserCertification;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserCertificationDao extends BaseMapper<UserCertification> {
|
||||
|
||||
IPage<Map<String, Object>> queryCertification(IPage iPage, @Param("status") String status, @Param("name") String name,@Param("classify") Integer classify);
|
||||
|
||||
IPage<Map<String, Object>> queryUserCertification(IPage iPage, @Param("name") String name,@Param("phone")String phone);
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.artificer.vo.UserArtificerVO;
|
||||
import com.sqx.modules.material.entity.Material;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserDao extends BaseMapper<UserEntity> {
|
||||
|
||||
|
||||
IPage<UserEntity> selectUserPage(Page<UserEntity> page, String search, Integer sex, String platform,
|
||||
Integer isAuthentication, String sysPhone, Integer status,
|
||||
String userName,String invitationCode,String inviterCode,
|
||||
Integer member,Integer ordersCount,Integer isAgency,Integer isShop,String artificerName);
|
||||
|
||||
int queryInviterCount(@Param("inviterCode") String inviterCode);
|
||||
|
||||
int queryUserCount(@Param("type") int type, @Param("date") String date,@Param("isAuthentication") Integer isAuthentication,@Param("phone") Integer phone);
|
||||
|
||||
Double queryPayMoney(@Param("type") int type, @Param("date") String date);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page iPage, @Param("type") int type, @Param("date") String date);
|
||||
|
||||
int userMessage(String date, int type);
|
||||
|
||||
int insertUser(UserEntity userEntity);
|
||||
|
||||
IPage<Map<String, Object>> takingOrdersMessage(Page<Map<String, Object>> iPage, @Param("type") Long type, @Param("date") String date);
|
||||
|
||||
int updateUserClientIdIsNull(String clientid);
|
||||
|
||||
int updateUserConsortiaIdIsNull(Long userId);
|
||||
|
||||
int updateUserClientIdIsNullByClientId(Long consortiaId);
|
||||
|
||||
int userPlatform(String platform,String date,Integer type);
|
||||
|
||||
IPage<Map<String,Object>> selectAgencyOrdersMoneyList(Page<Map<String,Object>> page,String userName,String phone,String startTime,String endTime);
|
||||
|
||||
|
||||
List<UserArtificerVO> getArtificerInfo();
|
||||
|
||||
IPage<UserEntity> merchantPromotion(IPage<UserEntity> pages,@Param("userEntity")UserEntity userEntity);
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserFollow;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserFollowDao extends BaseMapper<UserFollow> {
|
||||
|
||||
IPage<Map<String, Object>> selectMyFollow(IPage iPage, Long userId);
|
||||
|
||||
IPage<Map<String, Object>> selectFans(IPage iPage, Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyFollow1(Long userId);
|
||||
|
||||
List<UserFollowResponse> selectFans1(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyArtificer;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyArtificerDao extends BaseMapper<UserMoneyArtificer> {
|
||||
|
||||
int updateMoney(@Param("type") Integer type, @Param("userId") Long userId,@Param("artificerId") Long artificerId,@Param("money") Double money);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDao extends BaseMapper<UserMoney> {
|
||||
|
||||
void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money);
|
||||
|
||||
void updateCashDeposit(@Param("type") Integer type, @Param("userId") Long userId,@Param("cashDeposit") Double cashDeposit);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
|
||||
Double monthIncome(@Param("date") String date,@Param("userId") Long userId);
|
||||
Double selectMyProfit(Long userId);
|
||||
|
||||
BigDecimal selectSumRefund(Long userId,String startTime,String endTime);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserVipDao extends BaseMapper<UserVip> {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sqx.modules.app.entity.UserVisitor;
|
||||
import com.sqx.modules.app.response.UserFollowResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface UserVisitorDao extends BaseMapper<UserVisitor> {
|
||||
IPage<Map<String, Object>> selectMyVisitor(IPage iPage, Long userId);
|
||||
|
||||
List<UserFollowResponse> selectMyVisitor1(Long userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VipDetailsDao extends BaseMapper<VipDetails> {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.entity.VipDiscount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VipDiscountDao extends BaseMapper<VipDiscount> {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description address
|
||||
* @author fang
|
||||
* @date 2021-11-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("address")
|
||||
public class Address implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* 地址id
|
||||
*/
|
||||
private Integer addressId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String district;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String detailsAddress;
|
||||
|
||||
/**
|
||||
* 是否是默认地址
|
||||
*/
|
||||
private Integer isDefault;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String longitude;
|
||||
|
||||
private String latitude;
|
||||
|
||||
public Address() {}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue