From 2da3ac05ca99eb54ed54a02e7f11f1e57e7c7afd Mon Sep 17 00:00:00 2001
From: 苗权威 <1160292058@qq.com>
Date: Fri, 1 Nov 2019 20:31:26 +0800
Subject: [PATCH] 11.1
---
.idea/workspace.xml | 1469 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
third_party_load/pom.xml | 33 ++++++++++-----------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/ThirdPartyLoadApplication.java | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationFailureHandler.java | 47 -----------------------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationSuccessHandler.java | 41 -----------------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/BaseHolder.java | 29 +++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/Code.java | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/DataSourceConfig.java | 41 +++++++++++++++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/PrimaryConfig.java | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/SecondaryConfig.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AbstractChannelSecurityConfig.java | 29 -----------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AuthorizationServerConfig.java | 94 ----------------------------------------------------------------------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/OAuth2ResourceServer.java | 22 ----------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityConfig.java | 39 ---------------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityCoreConfig.java | 22 ----------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/BrowserSecurityController.java | 59 -----------------------------------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/UserController.java | 27 ---------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/game/GameProjectPO.java | 28 ++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/xiaodu/XiaoduHistoryTB.java | 37 +++++++++++++++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/handler/XiaoDuLoginSuccessHandler.java | 28 ----------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/pojo/UserProfile.java | 6 ++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserProperties.java | 33 ---------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserSecurityConfig.java | 34 ----------------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/LoginType.java | 9 ---------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2ClientProperties.java | 26 --------------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2Properties.java | 19 -------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityConstants.java | 18 ------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityProperties.java | 22 ----------------------
third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/game/GameProjectTBRepository.java | 24 ++++++++++++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/xiaodu/XiaoDuTBRepository.java | 15 +++++++++++++++
third_party_load/src/main/java/ai/qiwu/com/third_party_load/service/BootUserDetailService.java | 21 ---------------------
third_party_load/src/main/resources/application.yml | 32 ++++++++++++++++++++++++--------
tts_service/document/intro/interface.md | 37 +++++++++++++++++++++++++++++++++----
tts_service/document/intro/tts_ls.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tts_service/readme.md | 36 ++++++++++++++++++++++++++++++++----
tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java | 2 +-
tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java | 55 ++++++++++++++++++++++++++++++++-----------------------
tts_service/src/main/java/ai/qiwu/com/tts_service/common/SpecialCharURLConfig.java | 15 +++++++++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTServiceUtil.java | 14 ++++++++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java | 10 +++++++++-
tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java | 1 +
tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsAudio.java | 19 +++++++++++++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsResponse.java | 21 +++++++++++++++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsType.java | 9 +++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java | 81 +++++++++++++++++++--------------------------------------------------------------
tts_service/src/main/resources/application.yml | 7 +++++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java | 37 +++++++++++++++++++++----------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java | 47 -----------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 1 -
xiaoduhome/src/main/resources/application.yml | 4 +++-
51 files changed, 1438 insertions(+), 1889 deletions(-)
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationFailureHandler.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationSuccessHandler.java
create mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/BaseHolder.java
create mode 100644 third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/Code.java
create mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/DataSourceConfig.java
create mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/PrimaryConfig.java
create mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/SecondaryConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AbstractChannelSecurityConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AuthorizationServerConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/OAuth2ResourceServer.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityCoreConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/BrowserSecurityController.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/UserController.java
create mode 100644 third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/game/GameProjectPO.java
create mode 100644 third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/xiaodu/XiaoduHistoryTB.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/handler/XiaoDuLoginSuccessHandler.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserProperties.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserSecurityConfig.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/LoginType.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2ClientProperties.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2Properties.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityConstants.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityProperties.java
create mode 100644 third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/game/GameProjectTBRepository.java
create mode 100644 third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/xiaodu/XiaoDuTBRepository.java
delete mode 100755 third_party_load/src/main/java/ai/qiwu/com/third_party_load/service/BootUserDetailService.java
create mode 100644 tts_service/document/intro/tts_ls.md
create mode 100644 tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsAudio.java
create mode 100644 tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsResponse.java
create mode 100644 tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsType.java
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index cdf38ab..afdcbfb 100755
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,812 +4,49 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -853,66 +90,52 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
@@ -931,12 +154,6 @@
- Task
- setAlignItems
- TestTB
- Example
- Repository
- gameProjectTbRepository
projectLabelRepository
allOnProductInfoRepository
xiaoDuHistoryTBRepository
@@ -945,7 +162,6 @@
562358308
6569120969
4151097686
- zipFolder
ASIDE_IMG_URL
aliyun-hz1.chewrobot.com
aliyun-hz1.chewrobot.com/xiaoduhome
@@ -961,6 +177,13 @@
PERSON_INFO_ONLINE
9395788731
log.error
+ isNotBlank
+ setCookie
+ response.body()
+ filename
+ fileName
+ zipFolder
+ j
OPENID_CACHE
@@ -977,57 +200,57 @@
@@ -1045,6 +268,15 @@
+
+
+
+
+
+
+
+
+
@@ -1059,10 +291,10 @@
-
-
-
-
+
+
+
+
@@ -1073,6 +305,7 @@
+
@@ -1120,24 +353,74 @@
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -1152,7 +435,7 @@
-
+
@@ -1164,25 +447,25 @@
+
+
+
-
-
-
+
-
+
+
-
-
@@ -1204,13 +487,13 @@
-
-
-
-
+
+
+
+
-
+
@@ -1231,12 +514,12 @@
-
-
-
+
+
+
-
+
@@ -1244,12 +527,12 @@
-
-
-
+
+
+
-
+
@@ -1257,12 +540,12 @@
-
-
-
+
+
+
-
+
@@ -1579,11 +862,10 @@
-
-
+
@@ -1604,14 +886,15 @@
+
-
+
+
+
-
-
@@ -1747,7 +1030,14 @@
-
+
+
+
+
+
+
+
+
@@ -1757,7 +1047,7 @@
-
+
@@ -1769,7 +1059,7 @@
-
+
@@ -1779,17 +1069,17 @@
-
-
+
+
-
+
-
+
-
+
@@ -1800,7 +1090,7 @@
-
+
@@ -1856,386 +1146,401 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
+
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
diff --git a/third_party_load/pom.xml b/third_party_load/pom.xml
index 35c6307..4341069 100755
--- a/third_party_load/pom.xml
+++ b/third_party_load/pom.xml
@@ -34,16 +34,20 @@
test
- org.springframework.cloud
- spring-cloud-starter-oauth2
- 2.1.3.RELEASE
-
-
org.projectlombok
lombok
1.18.8
provided
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
org.apache.commons
@@ -63,22 +67,9 @@
1.9.3
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
mysql
mysql-connector-java
-
- org.mybatis.spring.boot
- mybatis-spring-boot-starter
- 1.3.2
-
@@ -92,14 +83,10 @@
system
${project.basedir}/src/main/resources/static/bot-sdk-1.2.0.jar
-
- org.mybatis
- mybatis
- 3.4.0
-
+ testTool
org.springframework.boot
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/ThirdPartyLoadApplication.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/ThirdPartyLoadApplication.java
index 8ea5465..90ae329 100755
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/ThirdPartyLoadApplication.java
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/ThirdPartyLoadApplication.java
@@ -1,20 +1,86 @@
package ai.qiwu.com.third_party_load;
+import ai.qiwu.com.third_party_load.common.BaseHolder;
+import ai.qiwu.com.third_party_load.entity.game.GameProjectPO;
+import ai.qiwu.com.third_party_load.repository.game.GameProjectTBRepository;
+import ai.qiwu.com.third_party_load.repository.xiaodu.XiaoDuTBRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
@SpringBootApplication
+@EnableJpaAuditing
+@Slf4j
public class ThirdPartyLoadApplication implements CommandLineRunner {
+ @Autowired
+ private GameProjectTBRepository gameProjectTBRepository;
+
public static void main(String[] args) {
SpringApplication.run(ThirdPartyLoadApplication.class, args);
}
+ @Transactional
@Override
public void run(String... args) throws Exception {
+// GameProjectTBRepository gameProjectTBRepository = BaseHolder.getBean("gameProjectTBRepository");
+// List games = gameProjectTBRepository.getAll();
+// int i = 0;
+// for (GameProjectPO game: games) {
+// String name = game.getName();
+// List nicknames = Arrays.asList(game.getNickname().split(","));
+// for (int j = i+1; j < games.size(); j++) {
+// GameProjectPO other = games.get(j);
+// if (other.getOwnerId().equals(game.getOwnerId())) {
+// continue;
+// }
+// if (other.getName().equals(name)) {
+// log.info("name equal:{},id:{} -> {}, ownerId:{} -> {}, username:{} -> {}", name, game.getId(),
+// other.getId(), game.getOwnerId(), other.getOwnerId(), game.getUserNickname(), other.getUserNickname());
+// }
+// List otherNicknames = Arrays.asList(other.getNickname().split(","));
+// if (!CollectionUtils.isEmpty(otherNicknames)) {
+// boolean originNickListIsEmpty = CollectionUtils.isEmpty(nicknames);
+// for (String nickName: otherNicknames) {
+// if (StringUtils.isBlank(nickName)) continue;
+// if (name.equals(nickName)) {
+// log.info("name equal other nickname:{},id:{} -> {}; ownerId:{} -> {}, username:{} -> {}",
+// name, game.getId(), other.getId(), game.getOwnerId(), other.getOwnerId(),
+// game.getUserNickname(), other.getUserNickname());
+// }
+// if (!originNickListIsEmpty && nicknames.contains(nickName)) {
+// log.info("nickname equal:{}, id:{} -> {}, ownerId:{} -> {}, username:{} -> {}",
+// nickName, game.getId(), other.getId(), game.getOwnerId(), other.getOwnerId(),
+// game.getUserNickname(), other.getUserNickname());
+// }
+// }
+// }
+// }
+// i++;
+// }
+ new Thread(() -> {
+ GameProjectPO projectPO = gameProjectTBRepository.getById(823L);
+ projectPO.setNickname("ceshi");
+ gameProjectTBRepository.save(projectPO);
+ }).start();
+ new Thread(() -> {
+ GameProjectPO projectPO = gameProjectTBRepository.getById(823L);
+ projectPO.setUserNickname("ceshigegui");
+ gameProjectTBRepository.save(projectPO);
+ int a = 1/0;
+ }).start();
}
+
}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationFailureHandler.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationFailureHandler.java
deleted file mode 100755
index 2cf58cb..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationFailureHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package ai.qiwu.com.third_party_load.browser.handler;
-
-import ai.qiwu.com.third_party_load.pojo.SimpleResponse;
-import ai.qiwu.com.third_party_load.properties.LoginType;
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午10:38
- */
-@Component
-@Slf4j
-public class MqwAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
- @Autowired
- private ObjectMapper objectMapper;
-
- @Autowired
- private SecurityProperties securityProperties;
-
- @Override
- public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
- AuthenticationException exception) throws IOException, ServletException {
- log.info("登录失败");
- if (LoginType.JSON.equals(securityProperties.getBrowser().getLoginType())) {
- response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
- response.setContentType("application/json;charset=UTF-8");
- //将authentication这个对象转成json格式的字符串
- response.getWriter().write(objectMapper.writeValueAsString(new SimpleResponse(exception.getMessage())));
- } else {
- super.onAuthenticationFailure(request, response, exception);
- }
-
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationSuccessHandler.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationSuccessHandler.java
deleted file mode 100755
index 997a6f5..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/browser/handler/MqwAuthenticationSuccessHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package ai.qiwu.com.third_party_load.browser.handler;
-
-import ai.qiwu.com.third_party_load.properties.LoginType;
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午9:46
- */
-@Component
-@Slf4j
-public class MqwAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
-
- @Autowired
- private ObjectMapper objectMapper;
-
- @Autowired
- private SecurityProperties securityProperties;
-
- @Override
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
- log.info("登录成功");
- if (LoginType.JSON.equals(securityProperties.getBrowser().getLoginType())) {
- response.setContentType("application/json;charset=UTF-8");
- response.getWriter().write(objectMapper.writeValueAsString(authentication));
- } else {
- super.onAuthenticationSuccess(request, response, authentication);
- }
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/BaseHolder.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/BaseHolder.java
new file mode 100755
index 0000000..ede5ad8
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/BaseHolder.java
@@ -0,0 +1,29 @@
+package ai.qiwu.com.third_party_load.common;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-21 下午8:42
+ */
+@Component
+public class BaseHolder implements ApplicationContextAware {
+
+ private static ApplicationContext applicationContext;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ BaseHolder.applicationContext = applicationContext;
+ }
+
+ public static ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public static T getBean(String beanName) {
+ return (T) applicationContext.getBean(beanName);
+ }
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/Code.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/Code.java
new file mode 100644
index 0000000..a27d485
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/Code.java
@@ -0,0 +1,136 @@
+package ai.qiwu.com.third_party_load.common;
+
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Collections;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-11-1 上午10:09
+ */
+public class Code {
+
+ // 41
+ private static int firstMissingPso1(int[] arr) {
+ if (arr == null || arr.length == 0) return 1;
+ int minPos = 2, maxPos = 0;
+ for (int i1 : arr) {
+ if (i1 > 0) {
+ if (i1 < minPos) minPos = i1;
+ else if (i1 > maxPos) maxPos = i1;
+ }
+ }
+ if (minPos == 2) return 1;
+ if (maxPos == 0) return 2;
+ int result = recur(arr, minPos, maxPos, true);
+ if (result == -1) result = maxPos+1;
+ return result;
+ }
+
+ private static int recur(int[] arr, int lo, int hi, boolean allExist) {
+ int mid = (hi-lo)/2+lo;
+ if (mid == lo) {
+ if (allExist) return -1;
+ else return mid+1;
+ }
+ boolean midExist = doesTheNumExist(arr, mid);
+ if (midExist) {
+ int result = recur(arr, lo, mid, true);
+ if (result != -1) return result;
+ return recur(arr, mid, hi, allExist);
+ }
+ return recur(arr, lo, mid, false);
+ }
+
+ private static boolean doesTheNumExist(int[] arr, int num) {
+ for (int i: arr) {
+ if (i == num) return true;
+ }
+ return false;
+ }
+
+ // 相比上面一种解法,相同的空间复杂度,更快的执行速度
+ private static int firstMissingPso(int[] nums) {
+ int i = 0, n = nums.length;
+ while (i < nums.length) {
+ if(nums[i] > n || nums[i] <= 0) {
+ i++;
+ continue;
+ }
+ if(nums[i] - 1 == i || nums[nums[i] - 1] == nums[i]) {
+ i++;
+ continue;
+ }
+
+ int temp = nums[nums[i] - 1];
+ nums[nums[i] - 1] = nums[i];
+ nums[i] = temp;
+ }
+ for (i = 0; i < n; i++) {
+ if(nums[i] != i + 1)
+ return i + 1;
+ }
+ return n + 1;
+ }
+
+ //44
+ public static boolean isMatch(String s, String p) {
+ if (s == null && p == null) return true;
+ else if (s == null || p == null) return false;
+ ArrayDeque sq = new ArrayDeque<>();
+ ArrayDeque pq = new ArrayDeque<>();
+ for (char sc: s.toCharArray()) sq.addLast(sc);
+ for (char pc: p.toCharArray()) pq.addLast(pc);
+
+ return recur(sq, pq);
+ }
+
+ private static boolean recur(ArrayDeque sq, ArrayDeque pq) {
+ boolean sqEmpty = sq.isEmpty();
+ boolean pqEmpty = pq.isEmpty();
+ if (sqEmpty && pqEmpty) return true;
+ else if (pqEmpty) return false;
+ else if (sqEmpty){
+ for (char c: pq) {
+ if (c != '*') return false;
+ }
+ return true;
+ }
+ char sc = sq.pollFirst();
+ char pc = pq.pollFirst();
+ if (sc == pc || pc == '?') return recur(sq, pq);
+ else if (pc != '*') return false;
+ else {
+ while (!pq.isEmpty() && pq.peekFirst() == '*') pq.pollFirst();
+ sq.addFirst(sc);
+ while (!sq.isEmpty()) {
+ if (!recur(new ArrayDeque<>(sq), new ArrayDeque<>(pq))) {
+ sq.pollFirst();
+ } else {
+ return true;
+ }
+ }
+ return recur(sq, pq);
+ }
+ }
+
+ public static void main(String[] args) {
+// // test 41
+// System.out.println(firstMissingPso(new int[]{3, 4, -1, 1}));
+// System.out.println(firstMissingPso(new int[]{1,2,0}));
+// System.out.println(firstMissingPso(new int[]{7,8,9,11,12}));
+// System.out.println(firstMissingPso(new int[]{1}));
+// System.out.println(firstMissingPso(new int[]{-1,4,2,1,9,10}));
+// System.out.println(firstMissingPso(new int[]{-1,3,4,2,1,5,6,7,9,10}));
+
+ // test 44
+// System.out.println(isMatch("aa", "a"));
+// System.out.println(isMatch("aa", "*"));
+// System.out.println(isMatch("cb", "?a"));
+// System.out.println(isMatch("adceb", "*a*b"));
+// System.out.println(isMatch("acdcb", "a*c?b"));
+// System.out.println(isMatch("aaabbbaabaaaaababaabaaabbabbbbbbbbaabababbabbbaaaaba", "a*******b"));
+ System.out.println(isMatch("babbbbaabababaabbababaababaabbaabababbaaababbababaaaaaabbabaaaabababbabbababbbaaaababbbabbbbbbbbbbaabbb",
+ "b**bb**a**bba*b**a*bbb**aba***babbb*aa****aabb*bbb***a"));
+ }
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/DataSourceConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/DataSourceConfig.java
new file mode 100755
index 0000000..4055508
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/DataSourceConfig.java
@@ -0,0 +1,41 @@
+package ai.qiwu.com.third_party_load.common.config;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-22 下午2:23
+ */
+@Configuration
+public class DataSourceConfig {
+
+// @Primary
+// @Bean(name = "primaryDatasourceProperties")
+// @Qualifier("primaryDatasourceProperties")
+// @ConfigurationProperties(prefix = "spring.datasource.primary")
+// public DataSourceProperties primaryDatasourceProperties() {
+// return new DataSourceProperties();
+// }
+
+ @Bean("primaryDataSource")
+ @Primary
+ @Qualifier("primaryDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource.primary")
+ public DataSource primaryDataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+ @Bean("secondaryDataSource")
+ @Qualifier("secondaryDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource.secondary")
+ public DataSource secondaryDataSource() {
+ return DataSourceBuilder.create().build();
+ }
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/PrimaryConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/PrimaryConfig.java
new file mode 100755
index 0000000..19bce66
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/PrimaryConfig.java
@@ -0,0 +1,64 @@
+package ai.qiwu.com.third_party_load.common.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.persistence.EntityManager;
+import javax.sql.DataSource;
+import java.util.Map;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-22 下午2:30
+ */
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactoryPrimary",
+ transactionManagerRef = "transactionManagerPrimary",
+ basePackages = {"ai.qiwu.com.third_party_load.repository.game"})
+public class PrimaryConfig {
+ @Autowired
+ @Qualifier("primaryDataSource")
+ private DataSource primaryDataSource;
+
+ @Primary
+ @Bean(name = "entityManagerFactoryPrimary")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties,
+ HibernateProperties hibernateProperties) {
+ Map properties = hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(),
+ new HibernateSettings());
+ return builder
+ .dataSource(primaryDataSource)
+ .properties(properties)
+ .packages("ai.qiwu.com.third_party_load.entity.game")
+ .persistenceUnit("primaryPersistenceUnit")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "entityManagerPrimary")
+ public EntityManager entityManager(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties,HibernateProperties hibernateProperties) {
+ return entityManagerFactoryPrimary(builder, jpaProperties,hibernateProperties).getObject().createEntityManager();
+ }
+
+ @Primary
+ @Bean(name = "transactionManagerPrimary")
+ public PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties,HibernateProperties hibernateProperties) {
+ return new JpaTransactionManager(entityManagerFactoryPrimary(builder, jpaProperties, hibernateProperties).getObject());
+ }
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/SecondaryConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/SecondaryConfig.java
new file mode 100755
index 0000000..0b24abf
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/common/config/SecondaryConfig.java
@@ -0,0 +1,60 @@
+package ai.qiwu.com.third_party_load.common.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import javax.persistence.EntityManager;
+import javax.sql.DataSource;
+import java.util.Map;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-22 下午3:21
+ */
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactorySecondary",
+ transactionManagerRef = "transactionManagerSecondary",
+ basePackages = {"ai.qiwu.com.third_party_load.repository.xiaodu"})
+public class SecondaryConfig {
+ @Autowired
+ @Qualifier("secondaryDataSource")
+ private DataSource secondaryDataSource;
+
+ @Bean(name = "entityManagerFactorySecondary")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties,
+ HibernateProperties hibernateProperties) {
+ Map properties = hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(),
+ new HibernateSettings());
+ return builder
+ .dataSource(secondaryDataSource)
+ .properties(properties)
+ .packages("ai.qiwu.com.third_party_load.entity.xiaodu")
+ .persistenceUnit("secondaryPersistenceUnit")
+ .build();
+ }
+
+ @Bean(name = "entityManagerSecondary")
+ public EntityManager entityManager(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties, HibernateProperties hibernateProperties) {
+ return entityManagerFactoryPrimary(builder, jpaProperties,hibernateProperties).getObject().createEntityManager();
+ }
+
+ @Bean(name = "transactionManagerSecondary")
+ public PlatformTransactionManager transactionManager(EntityManagerFactoryBuilder builder,
+ JpaProperties jpaProperties, HibernateProperties hibernateProperties) {
+ return new JpaTransactionManager(entityManagerFactoryPrimary(builder, jpaProperties, hibernateProperties).getObject());
+ }
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AbstractChannelSecurityConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AbstractChannelSecurityConfig.java
deleted file mode 100755
index 50eda9f..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AbstractChannelSecurityConfig.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package ai.qiwu.com.third_party_load.config;
-
-import ai.qiwu.com.third_party_load.properties.SecurityConstants;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.web.authentication.AuthenticationFailureHandler;
-import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午10:01
- */
-public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {
-
- @Autowired
- private AuthenticationSuccessHandler mqwAuthenticationSuccessHandler;
-
- @Autowired
- private AuthenticationFailureHandler mqwAuthenticationFailureHandler;
-
- protected void applyPasswordAuthenticationConfig(HttpSecurity httpSecurity) throws Exception {
- httpSecurity.formLogin()
- .loginPage(SecurityConstants.DEFAULT_LOGIN_PROCESSING_URL_FORM)
- .loginProcessingUrl(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
- .successHandler(mqwAuthenticationSuccessHandler)
- .failureHandler(mqwAuthenticationFailureHandler);
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AuthorizationServerConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AuthorizationServerConfig.java
deleted file mode 100755
index 40194ec..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/AuthorizationServerConfig.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package ai.qiwu.com.third_party_load.config;
-
-import ai.qiwu.com.third_party_load.properties.OAuth2ClientProperties;
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import org.apache.commons.lang3.ArrayUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.oauth2.config.annotation.builders.InMemoryClientDetailsServiceBuilder;
-import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
-import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
-import org.springframework.security.oauth2.provider.token.TokenEnhancer;
-import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author 苗权威
- * @dateTime 19-7-15 上午10:40
- */
-@Configuration
-@EnableAuthorizationServer
-public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
- @Autowired
- private AuthenticationManager authenticationManager;
-
- @Autowired
- private UserDetailsService userDetailsService;
-
- @Autowired
- private SecurityProperties securityProperties;
-
- @Autowired
- private TokenStore tokenStore;
-
- @Autowired(required = false)
- private JwtAccessTokenConverter jwtAccessTokenConverter;
-
- @Autowired(required = false)
- private TokenEnhancer jwtTokenEnhancer;
-
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
- endpoints
- .tokenStore(tokenStore)
- .authenticationManager(authenticationManager)
- .userDetailsService(userDetailsService);
- if (jwtAccessTokenConverter != null && jwtTokenEnhancer != null) {
- TokenEnhancerChain enhancerChain = new TokenEnhancerChain();
- List enhancers = new ArrayList<>();
- enhancers.add(jwtTokenEnhancer);
- enhancers.add(jwtAccessTokenConverter);
- enhancerChain.setTokenEnhancers(enhancers);
-
- endpoints.tokenEnhancer(enhancerChain)
- .accessTokenConverter(jwtAccessTokenConverter);
- }
- }
-
- @Override
- public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
- security.tokenKeyAccess("permitAll()");
- }
-
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- InMemoryClientDetailsServiceBuilder builder = clients.inMemory();
-
- if (ArrayUtils.isNotEmpty(securityProperties.getOauth2().getClients())) {
- for (OAuth2ClientProperties config : securityProperties.getOauth2().getClients()) {
- builder.withClient(config.getClientId())
- .secret(config.getClientSecret())
- .authorizedGrantTypes("refresh_token","password","authorization_code")
- .refreshTokenValiditySeconds(2592000)
- .scopes("all","read","write");
- }
- }
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/OAuth2ResourceServer.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/OAuth2ResourceServer.java
deleted file mode 100755
index e98e911..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/OAuth2ResourceServer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ai.qiwu.com.third_party_load.config;
-
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-15 下午6:05
- */
-@Configuration
-@EnableResourceServer
-public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
- @Override
- public void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().anyRequest().authenticated()
- .and().requestMatchers().antMatchers("/api/**");
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityConfig.java
deleted file mode 100755
index f742d6a..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package ai.qiwu.com.third_party_load.config;
-
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.annotation.Order;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.NoOpPasswordEncoder;
-
-
-/**
- * @author 苗权威
- * @dateTime 19-7-15 上午10:34
- */
-//@Order(1)
-public class SecurityConfig extends WebSecurityConfigurerAdapter {
-
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication().withUser("user")
- .password("123456").roles("USER").and().passwordEncoder(passwordEncoder());
- }
-
- @Bean
- public static BCryptPasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests().anyRequest().authenticated().and().formLogin().permitAll();
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityCoreConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityCoreConfig.java
deleted file mode 100755
index 145a4a7..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/config/SecurityCoreConfig.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ai.qiwu.com.third_party_load.config;
-
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午9:41
- */
-@Configuration
-@EnableConfigurationProperties(SecurityProperties.class)
-public class SecurityCoreConfig {
-
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/BrowserSecurityController.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/BrowserSecurityController.java
deleted file mode 100755
index c5c4b75..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/BrowserSecurityController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package ai.qiwu.com.third_party_load.controller;
-
-import ai.qiwu.com.third_party_load.pojo.SimpleResponse;
-import ai.qiwu.com.third_party_load.properties.SecurityConstants;
-import ai.qiwu.com.third_party_load.properties.SecurityProperties;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.security.web.DefaultRedirectStrategy;
-import org.springframework.security.web.RedirectStrategy;
-import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
-import org.springframework.security.web.savedrequest.RequestCache;
-import org.springframework.security.web.savedrequest.SavedRequest;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午10:47
- */
-@RestController
-@Slf4j
-public class BrowserSecurityController {
-
- private RequestCache requestCache = new HttpSessionRequestCache();
-
- private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
-
- @Autowired
- private SecurityProperties securityProperties;
-
- /**
- * 当需要身份认证时,跳转到这里
- * @param request
- * @param response
- * @return
- */
- @RequestMapping(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
- @ResponseStatus(code = HttpStatus.UNAUTHORIZED) //401
- public SimpleResponse requireAuthentication(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- SavedRequest savedRequest = requestCache.getRequest(request, response);
- if (savedRequest != null) {
- String target = savedRequest.getRedirectUrl();
- log.info("引发跳转的请求是:{}", target);
- if (StringUtils.endsWithIgnoreCase(target, ".html")) {
- redirectStrategy.sendRedirect(request, response, securityProperties.getBrowser().getLoginPage());
- }
- }
-
- return new SimpleResponse("访问的服务需要身份认证,引导用户到登录页");
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/UserController.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/UserController.java
deleted file mode 100755
index aecdf83..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/controller/UserController.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package ai.qiwu.com.third_party_load.controller;
-
-import ai.qiwu.com.third_party_load.pojo.UserProfile;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-15 下午6:00
- */
-@RestController
-public class UserController {
-
- @RequestMapping("/api/profile")
- public ResponseEntity profile() {
- User user = (User) SecurityContextHolder.getContext()
- .getAuthentication().getPrincipal();
- String email = user.getUsername() + "@email.com";
- UserProfile profile = new UserProfile();
- profile.setName(user.getUsername());
- profile.setEmail(email);
- return ResponseEntity.ok(profile);
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/game/GameProjectPO.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/game/GameProjectPO.java
new file mode 100644
index 0000000..88dc07b
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/game/GameProjectPO.java
@@ -0,0 +1,28 @@
+package ai.qiwu.com.third_party_load.entity.game;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "game_project_tb")
+@Getter
+@Setter
+public class GameProjectPO {
+ @Id
+ @GeneratedValue
+ private Long id;
+ @Column
+ private String name;
+ @Column
+ private String nickname;
+ @Column(name = "bot_account")
+ private String botAccount;
+ @Column
+ private String username;
+ @Column(name = "user_nickname")
+ private String userNickname;
+ @Column(name = "owner_id")
+ private Long ownerId;
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/xiaodu/XiaoduHistoryTB.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/xiaodu/XiaoduHistoryTB.java
new file mode 100644
index 0000000..78c3cd4
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/entity/xiaodu/XiaoduHistoryTB.java
@@ -0,0 +1,37 @@
+package ai.qiwu.com.third_party_load.entity.xiaodu;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.sql.Timestamp;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-31 上午10:15
+ */
+@Getter
+@Setter
+@Entity
+@Table(name = "xiaodu_history_tb")
+@EntityListeners(AuditingEntityListener.class)
+public class XiaoduHistoryTB {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+ @Column(name = "bot_id")
+ private String botId;
+ @Column(name = "xiaodu_user_id")
+ private String xiaoduUserId;
+ @Column(name = "last_time")
+ private Long lastTime;
+ @CreatedDate
+ @Column(name = "create_time", updatable = false, nullable = false)
+ private Timestamp createTime;
+ @LastModifiedDate
+ @Column(name = "update_time")
+ private Timestamp updateTime;
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/handler/XiaoDuLoginSuccessHandler.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/handler/XiaoDuLoginSuccessHandler.java
deleted file mode 100755
index 1706fd3..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/handler/XiaoDuLoginSuccessHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package ai.qiwu.com.third_party_load.handler;
-
-import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException;
-import org.springframework.security.oauth2.provider.OAuth2Request;
-import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-15 下午1:59
- */
-public class XiaoDuLoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
-
- @Override
- public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
- String header = request.getHeader("Authorization");
- String name = authentication.getName();
- if (header == null || !header.startsWith("Basic ")) {
- throw new UnapprovedClientAuthenticationException("请求头中无client信息");
- }
-
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/pojo/UserProfile.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/pojo/UserProfile.java
index 1bd92a4..9378f8c 100755
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/pojo/UserProfile.java
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/pojo/UserProfile.java
@@ -2,6 +2,7 @@ package ai.qiwu.com.third_party_load.pojo;
import lombok.Getter;
import lombok.Setter;
+import org.apache.commons.lang3.math.NumberUtils;
/**
* @author 苗权威
@@ -12,4 +13,9 @@ import lombok.Setter;
public class UserProfile {
private String email;
private String name;
+ private Integer test;
+
+ public static void main(String[] args) {
+ System.out.println(NumberUtils.INTEGER_TWO.equals(new UserProfile().getTest()));;
+ }
}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserProperties.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserProperties.java
deleted file mode 100755
index 67cc863..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserProperties.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午10:30
- */
-@Getter
-@Setter
-public class BrowserProperties {
- /**
- * 登录页面,当引发登录行为的url以html结尾时,会跳到这里配置的url上
- */
- private String loginPage = SecurityConstants.DEFAULT_LOGIN_PROCESSING_URL_FORM;
-
- /**
- * 退出成功时跳转的url,如果配置了,则跳到指定的url,如果没配置,则返回json数据
- */
- private String signOutUrl;
-
- /**
- * 登录响应的方式,默认是json
- */
- private LoginType loginType = LoginType.JSON;
-
- /**
- * 登录成功后跳转的地址,如果设置了此属性,则登录成功后总是会跳到这个地址上。
- * 只在signInResponseType为REDIRECT时生效
- */
- private String signInSuccessUrl;
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserSecurityConfig.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserSecurityConfig.java
deleted file mode 100755
index 3a32655..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/BrowserSecurityConfig.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-import ai.qiwu.com.third_party_load.config.AbstractChannelSecurityConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.core.userdetails.UserDetailsService;
-
-import javax.sql.DataSource;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午9:51
- */
-@Configuration
-public class BrowserSecurityConfig extends AbstractChannelSecurityConfig {
-
- @Autowired
- private SecurityProperties securityProperties;
-
- @Autowired
- private DataSource dataSource;
-
- @Autowired
- private UserDetailsService userDetailsService;
-
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- //这是密码登录相关的配置
- applyPasswordAuthenticationConfig(http);
- super.configure(http);
- }
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/LoginType.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/LoginType.java
deleted file mode 100755
index 146fa6c..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/LoginType.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午9:49
- */
-public enum LoginType {
- REDIRECT, JSON
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2ClientProperties.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2ClientProperties.java
deleted file mode 100755
index 7cb8624..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2ClientProperties.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-16 上午10:43
- */
-@Getter
-@Setter
-public class OAuth2ClientProperties {
-
- private String clientId;
-
- private String clientSecret;
-
- private String redirectUris;
-
- /**
- * 针对此应用发出的token的有效时间
- */
- private int accessTokenValiditySeconds = 7200;
-
- private int refreshAccessTokenValidateSeconds = 2592000;
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2Properties.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2Properties.java
deleted file mode 100755
index eb72491..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/OAuth2Properties.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-16 上午10:41
- */
-@Getter
-@Setter
-public class OAuth2Properties {
-
- private String jwtStringKey = "qiwu";
-
- private OAuth2ClientProperties[] clients = {};
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityConstants.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityConstants.java
deleted file mode 100755
index f1fad7c..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityConstants.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-17 上午10:06
- */
-public interface SecurityConstants {
-
- /**
- * 当请求需要身份认证时,默认跳转的url
- *
- */
- String DEFAULT_UNAUTHENTICATION_URL = "/authentication/require";
- /**
- * 默认的用户名密码登录请求处理url
- */
- String DEFAULT_LOGIN_PROCESSING_URL_FORM = "/authentication/form";
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityProperties.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityProperties.java
deleted file mode 100755
index 19e029f..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/properties/SecurityProperties.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ai.qiwu.com.third_party_load.properties;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-16 上午10:39
- */
-@Component
-@ConfigurationProperties(prefix = "qiwu.security")
-@Getter
-@Setter
-public class SecurityProperties {
-
- private OAuth2Properties oauth2 = new OAuth2Properties();
-
- private BrowserProperties browser = new BrowserProperties();
-}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/game/GameProjectTBRepository.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/game/GameProjectTBRepository.java
new file mode 100644
index 0000000..261e217
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/game/GameProjectTBRepository.java
@@ -0,0 +1,24 @@
+package ai.qiwu.com.third_party_load.repository.game;
+
+import ai.qiwu.com.third_party_load.entity.game.GameProjectPO;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-30 下午2:10
+ */
+@Repository
+public interface GameProjectTBRepository extends JpaRepository {
+
+ @Query(value = "select id,name,nickname,bot_account,user_nickname,owner_id,username from game_project_tb", nativeQuery = true)
+ List getAll();
+
+ GameProjectPO getById(Long id);
+
+ @Override
+ S save(S s);
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/xiaodu/XiaoDuTBRepository.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/xiaodu/XiaoDuTBRepository.java
new file mode 100644
index 0000000..7afaf8d
--- /dev/null
+++ b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/repository/xiaodu/XiaoDuTBRepository.java
@@ -0,0 +1,15 @@
+package ai.qiwu.com.third_party_load.repository.xiaodu;
+
+import ai.qiwu.com.third_party_load.entity.xiaodu.XiaoduHistoryTB;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-31 上午11:13
+ */
+@Repository
+public interface XiaoDuTBRepository extends JpaRepository {
+ @Override
+ S save(S s);
+}
diff --git a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/service/BootUserDetailService.java b/third_party_load/src/main/java/ai/qiwu/com/third_party_load/service/BootUserDetailService.java
deleted file mode 100755
index ad9f79f..0000000
--- a/third_party_load/src/main/java/ai/qiwu/com/third_party_load/service/BootUserDetailService.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package ai.qiwu.com.third_party_load.service;
-
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.factory.PasswordEncoderFactories;
-import org.springframework.security.provisioning.InMemoryUserDetailsManager;
-
-/**
- * @author 苗权威
- * @dateTime 19-7-16 下午2:31
- */
-public class BootUserDetailService implements UserDetailsService {
-
-
- @Override
- public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
- return null;
- }
-}
diff --git a/third_party_load/src/main/resources/application.yml b/third_party_load/src/main/resources/application.yml
index 7ac8069..618cf12 100755
--- a/third_party_load/src/main/resources/application.yml
+++ b/third_party_load/src/main/resources/application.yml
@@ -1,9 +1,25 @@
-#server:
-# port: 9090
-# servlet:
-# context-path: /security
+server:
+ port: 8989
-security:
- user:
- name: user
- password: 123456
\ No newline at end of file
+spring:
+ datasource:
+ primary:
+# url: jdbc:mysql://localhost:3306/game_editor_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
+ jdbc-url: jdbc:mysql://aliyun-hz1.chewrobot.com:3306/game_editor_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
+ username: root
+ password: 3g9^pWQs#ft7
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ secondary:
+ jdbc-url: jdbc:mysql://aliyun-hz1.chewrobot.com:3306/interface_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Hongkong&useSSL=false
+ username: root
+ password: 3g9^pWQs#ft7
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ jpa:
+ database: mysql
+ #控制台显示SQL
+ show-sql: true
+ hibernate:
+ ddl-auto: none
+ output:
+ ansi:
+ enabled: detect
\ No newline at end of file
diff --git a/tts_service/document/intro/interface.md b/tts_service/document/intro/interface.md
index 45751a4..61636d1 100755
--- a/tts_service/document/intro/interface.md
+++ b/tts_service/document/intro/interface.md
@@ -126,7 +126,7 @@
|参数 |必选 |类型 |说明 |默认值 |参考值 |
|---- |---- |---- |---- |---- |---- |
- |_type | false |string |获取b64文件名列表| - | filename |
+ |_type | false |string |获取b64文件名列表| - | 见下面注释 |
|botname| false |string|作品标识| 中控 | - |
|platform| false |string| npc名称 | - | - |
|text_info_ls | true |arr| 请求信息列表 | -|-|
@@ -137,16 +137,45 @@
|speed|false|double|语速|1|-|
|volume|false|double|音量|0|-|
|npcName|false|string|代表优先寻找人工语音文件|-|-|
+
+ 注释:
+ - filename:文件名列表;
+ - url:mp3请求地址列表;
+ - b64:b64文件数据列表;
+ - urlFile:mp3请求地址和文件名列表;
+ - urlB64:mp3请求地址和b64文件数据列表;
+ - fileB64:b64文件名和其数据列表
#### Response
- ResponseBody:
-```{"status":200,"message":"成功","audio":"音频文件URL"}```
-- 返回字段说明:若plateform为xiaoai则返回合并后的文件的请求URL;否则根据_type来选择返回的是b64文件内容列表或是b64文件名列表
+正确返回:
+```
+{
+ "status": 200,
+ "audio": [
+ {
+ "filename": "xxx",
+ "b64": "xxx",
+ "url": "xxx",
+ "text": "xxx"
+ },
+ {}
+ ]
+}
+```
+错误返回:
+```$xslt
+{
+ "status": 404,
+ "message": "xxx"
+}
+```
+- 返回字段说明:若plateform为xiaoai则返回合并后的文件的请求URL;否则根据_type来选择返回内容
|返回字段 |必有 |类型 | 说明 |
|---- |---- |---- |---- |
|status | true | int |返回状态|
|message | false |string|返回信息|
- |audio|false|string|音频文件URL|
+ |audio|false|object|返回内容|
diff --git a/tts_service/document/intro/tts_ls.md b/tts_service/document/intro/tts_ls.md
new file mode 100644
index 0000000..965fb3b
--- /dev/null
+++ b/tts_service/document/intro/tts_ls.md
@@ -0,0 +1,77 @@
+### 请求多个音频文件
+#### Request
+- URL:```/api/tts_ls```
+- METHOD:**POST**
+- URL Parameters|TYPE: JSON
+```
+{
+ "_type": "filename",
+ "platform": "xiaoai",
+ "botname": "miao",
+ "text_info_ls": [
+ {
+ "person": "A12_offline",
+ "tone": "正常",
+ "text": "用来进行测试的碰碰车不是小孩努力学习皮皮再将它皮皮 。",
+ "pitch": 0,
+ "speed": 1.3,
+ "volume": 0,
+ "npcName": "xiaoming"
+ }
+ ]
+}
+```
+- 参数说明:
+
+ |参数 |必选 |类型 |说明 |默认值 |参考值 |
+ |---- |---- |---- |---- |---- |---- |
+ |_type | false |string |获取b64文件名列表| - | 见下面注释 |
+ |botname| false |string|作品标识| 中控 | - |
+ |platform| false |string| npc名称 | - | - |
+ |text_info_ls | true |arr| 请求信息列表 | -|-|
+ |person|false|string|语音人物标识|正常|-|
+ |tone|false|string|情绪|正常|-|
+ |text|true|string|文本内容|-|-|
+ |pitch|false|double|语调|0|-|
+ |speed|false|double|语速|1|-|
+ |volume|false|double|音量|0|-|
+ |npcName|false|string|代表优先寻找人工语音文件|-|-|
+
+ 注释:
+ - filename:文件名列表;
+ - url:mp3请求地址列表;
+ - b64:b64文件数据列表;
+ - urlFile:mp3请求地址和文件名列表;
+ - urlB64:mp3请求地址和b64文件数据列表;
+ - fileB64:b64文件名和其数据列表
+#### Response
+- ResponseBody:
+正确返回:
+```
+{
+ "status": 200,
+ "audio": [
+ {
+ "filename": "xxx",
+ "b64": "xxx",
+ "url": "xxx",
+ "text": "xxx"
+ },
+ {}
+ ]
+}
+```
+错误返回:
+```$xslt
+{
+ "status": 404,
+ "message": "xxx"
+}
+```
+- 返回字段说明:若plateform为xiaoai则返回合并后的文件的请求URL;否则根据_type来选择返回内容
+
+ |返回字段 |必有 |类型 | 说明 |
+ |---- |---- |---- |---- |
+ |status | true | int |返回状态|
+ |message | false |string|返回信息|
+ |audio|false|object|返回内容|
\ No newline at end of file
diff --git a/tts_service/readme.md b/tts_service/readme.md
index e2a51de..5136520 100755
--- a/tts_service/readme.md
+++ b/tts_service/readme.md
@@ -134,7 +134,7 @@
|参数 |必选 |类型 |说明 |默认值 |参考值 |
|---- |---- |---- |---- |---- |---- |
- |_type | false |string |获取b64文件名列表| - | filename |
+ |_type | false |string |获取b64文件名列表| - | 见下面注释 |
|botname| false |string|作品标识| 中控 | - |
|platform| false |string| npc名称 | - | - |
|text_info_ls | true |arr| 请求信息列表 | -|-|
@@ -145,16 +145,44 @@
|speed|false|double|语速|1|-|
|volume|false|double|音量|0|-|
|npcName|false|string|代表优先寻找人工语音文件|-|-|
+
+ 注释:
+ - filename:文件名列表;
+ - url:mp3请求地址列表;
+ - b64:b64文件数据列表;
+ - urlFile:mp3请求地址和文件名列表;
+ - urlB64:mp3请求地址和b64文件数据列表;
+ - fileB64:b64文件名和其数据列表
#### Response
- ResponseBody:
-```{"status":200,"message":"成功","audio":"音频文件URL"}```
-- 返回字段说明:若plateform为xiaoai则返回合并后的文件的请求URL;否则根据_type来选择返回的是b64文件内容列表或是b64文件名列表
+正确返回:
+```
+ {
+ "status": 200,
+ "audio": {
+ "filename": [],
+ "url": [],
+ "b64": [],
+ "urlFile": [],
+ "urlB64": [],
+ "fileB64": []
+ }
+ }
+```
+错误返回:
+```$xslt
+{
+ "status": 404,
+ "message": "xxx"
+}
+```
+- 返回字段说明:若plateform为xiaoai则返回合并后的文件的请求URL;否则根据_type来选择返回内容
|返回字段 |必有 |类型 | 说明 |
|---- |---- |---- |---- |
|status | true | int |返回状态|
|message | false |string|返回信息|
- |audio|false|string|音频文件URL|
+ |audio|false|object|返回内容|
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
index 1b37eba..07661b3 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
@@ -20,7 +20,7 @@ public class CallPython {
/**
* python解释器位置
*/
- private static String INTERPRETER = "/root/.local/share/virtualenvs/tts-D3FZ1eZ4/bin/python";
+ private static String INTERPRETER = "/root/.local/share/virtualenvs/TTS-service-Fv_rYXsK/bin/python";
/**
* 生成sox命令,命令行执行
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
index c8bc6c2..5f86816 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
@@ -81,8 +81,9 @@ public class OkHttp3Utils {
paramsIterator.forEachRemaining(e -> urlBuild.addQueryParameter(e.getKey(), e.getValue()));
builder.url(urlBuild.build()).headers(headerBuilder.build());
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -107,12 +108,13 @@ public class OkHttp3Utils {
paramsIterator.forEachRemaining(e -> urlBuild.addQueryParameter(e.getKey(), e.getValue()));
builder.url(urlBuild.build()).headers(headerBuilder.build());
- try (Response response = client.newCall(builder.build()).execute()){
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
String contentType = response.header("Content-Type");
if ("audio/pcm".equals(contentType)) {
- return response.body().bytes();
+ return body.bytes();
}else {
- log.error("猎狐返回的response中Content-Type不是audio/pcm,是{}, json数据:{}", contentType, response.body().string());
+ log.error("猎狐返回的response中Content-Type不是audio/pcm,是{}, json数据:{}", contentType, body.string());
}
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
@@ -174,8 +176,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
client.dispatcher().cancelAll();
@@ -200,9 +203,10 @@ public class OkHttp3Utils {
headBuilder.add("Content-Type","application/json; charset=utf-8");
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
int code = response.code();
- response.body().string();
+ body.string();
return code;
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
@@ -241,18 +245,19 @@ public class OkHttp3Utils {
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
ResponseCodeWithData codeWithData = null;
- try (Response response = timeoutClient.newCall(builder.build()).execute()){
+ Response response = timeoutClient.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
//log.info("doPostTimeout请求返回:{}", response.code());
// log.info("response3333333 :{}",response.header("usetime"));
int code = response.code();
if (code == 200) {
if (file != null) {
try (BufferedSink sink = Okio.buffer(Okio.sink(file))){
- sink.writeAll(Objects.requireNonNull(response.body()).source());
+ sink.writeAll(Objects.requireNonNull(body).source());
codeWithData = new ResponseCodeWithData(code);
}
} else {
- codeWithData = new ResponseCodeWithData(code, response.body().string());
+ codeWithData = new ResponseCodeWithData(code, body.string());
}
return codeWithData;
}
@@ -293,9 +298,9 @@ public class OkHttp3Utils {
RequestBody.create(MediaType.parse("application/octet-stream"), file));
}
builder.headers(headBuilder.build()).post(requestBuilder.build());
-
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -356,9 +361,9 @@ public class OkHttp3Utils {
RequestBody.create(MediaType.parse("application/octet-stream"), fileByte));
}
builder.headers(headBuilder.build()).post(requestBuilder.build());
-
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -380,8 +385,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).put(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -403,8 +409,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).delete(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -426,7 +433,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).delete(RequestBody.create(MediaType.parse("application/json;charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute();ResponseBody body = response.body()){
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ body.string();
return response.code();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/SpecialCharURLConfig.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/SpecialCharURLConfig.java
index 0d1fd07..d9d6855 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/SpecialCharURLConfig.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/SpecialCharURLConfig.java
@@ -1,6 +1,10 @@
package ai.qiwu.com.tts_service.common;
+import org.apache.tomcat.util.http.LegacyCookieProcessor;
+import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,4 +23,15 @@ public class SpecialCharURLConfig {
factory.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
return factory;
}
+
+ /**
+ * 从Tomcat 8,Cookie的解析已经符合RFC 6265。
+ * 由于RFC 6265不再接受以前允许的逗号分隔符(例如RFC 2109)
+ * "Cookie:KEY 1 = VAL 1,KEY 2 = VAL 2"的格式被视为非法
+ * @return
+ */
+ @Bean
+ public WebServerFactoryCustomizer cookieProcessorCustomizer() {
+ return factory -> factory.addContextCustomizers(context -> context.setCookieProcessor(new LegacyCookieProcessor()));
+ }
}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTServiceUtil.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTServiceUtil.java
index b088988..a9e76c4 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTServiceUtil.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTServiceUtil.java
@@ -3,6 +3,7 @@ package ai.qiwu.com.tts_service.common;
import ai.qiwu.com.tts_service.pojo.MP3Response;
import ai.qiwu.com.tts_service.pojo.ResponseStatusWithList;
import ai.qiwu.com.tts_service.pojo.TTSResponse;
+import ai.qiwu.com.tts_service.pojo.TtsLsResponse;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.ClientAbortException;
@@ -117,6 +118,19 @@ public class TTServiceUtil {
}
}
+ public static void buildNewTtsLsResponse(HttpServletResponse response, TtsLsResponse ttsLsResponse, int status) {
+ String ttsResJsonStr = JSON.toJSONString(ttsLsResponse);
+ response.setStatus(status);
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application/json;charset=utf-8");
+ try (PrintWriter out = response.getWriter()){
+ out.append(ttsResJsonStr);
+ out.flush();
+ } catch (Exception e) {
+ log.error("buildNewTtsLsResponse()出错:{}",e.toString());
+ }
+ }
+
/**
* 构建tts接口请求的响应信息
* @param servletResponse HttpServletResponse对象
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
index 5711220..c345b42 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
@@ -5,6 +5,7 @@ import ai.qiwu.com.tts_service.pojo.upload.UploadOneSenData;
import ai.qiwu.com.tts_service.service.Initialize;
import ai.qiwu.com.tts_service.service.TTService;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -108,7 +109,14 @@ public class TTSController {
*/
@PostMapping("/api/tts_ls")
public void tts_ls(@RequestBody TTSLSRequest request, HttpServletResponse response) {
- ttService.tts_ls(request, response);
+// long start = System.currentTimeMillis();
+ try {
+ ttService.tts_ls(request, response);
+ } catch (Exception e) {
+ response.setStatus(500);
+ log.error(ExceptionUtils.getStackTrace(e));
+ }
+// log.info("tts_ls耗时:{}", System.currentTimeMillis()-start);
}
/**
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
index ead0b7d..194518c 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
@@ -26,6 +26,7 @@ public class GeneralMP3Data {
private String format;
private String npcName;
+ private String tmpName;
public GeneralMP3Data(String server, String text, String person, String tone, String botname,
Boolean cache, Double volume, Double speed, Double pitch) {
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsAudio.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsAudio.java
new file mode 100644
index 0000000..463c587
--- /dev/null
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsAudio.java
@@ -0,0 +1,19 @@
+package ai.qiwu.com.tts_service.pojo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-29 上午11:33
+ */
+@Getter
+@Setter
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class TtsLsAudio {
+ private String filename;
+ private String b64;
+ private String url;
+ private String text;
+}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsResponse.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsResponse.java
new file mode 100644
index 0000000..3f34ce0
--- /dev/null
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsResponse.java
@@ -0,0 +1,21 @@
+package ai.qiwu.com.tts_service.pojo;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-29 上午11:32
+ */
+@Getter
+@Setter
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class TtsLsResponse {
+ private Integer status;
+ private String message;
+ private List audio = new ArrayList<>();
+}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsType.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsType.java
new file mode 100644
index 0000000..684df1e
--- /dev/null
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/TtsLsType.java
@@ -0,0 +1,9 @@
+package ai.qiwu.com.tts_service.pojo;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-10-29 上午11:20
+ */
+public enum TtsLsType {
+ filename,url,b64,urlFile,urlB64,fileB64
+}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
index dd6e2e6..7c6547f 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
@@ -163,6 +163,7 @@ public class TTService {
*/
public void mp3(String dirs, String filename, String _type, HttpServletResponse response) {
// 修正dirs的格式
+ boolean tmp = false;
if (dirs != null) {
try {
dirs = URLDecoder.decode(dirs, "UTF-8");
@@ -187,6 +188,7 @@ public class TTService {
null, 400, false);
return;
}
+ tmp = "tmp".equals(dir_ls.get(0));
dirs = StringUtils.join(dir_ls, "/");
}
//去除 \\ / ..
@@ -196,15 +198,21 @@ public class TTService {
if (filename != null && StringUtils.endsWith(filename,".mp3")) {
StringBuilder builder = new StringBuilder(Initialize.getAudioDir()).append(File.separator);
if (StringUtils.isNotBlank(dirs)) builder.append(dirs).append(File.separator);
- filename = builder.append(filename).toString();
- //log.info("mp3():本次请求要获取的请求的文件:{}",filename);
- if (TTSUtils.doesFileExist(filename)) {
+// filename = builder.append(filename).toString();
+ final String filepath = builder.append(filename).toString();
+ //log.info("mp3():本次请求要获取的请求的文件:{}",filepath);
+ if (TTSUtils.doesFileExist(filepath)) {
if ("file".equals(_type)) {
// 请求头中添加 Content-Disposition = attachment 可下载
- TTServiceUtil.buildMp3Response(response, null, filename, 200, true);
+ TTServiceUtil.buildMp3Response(response, null, filepath, 200, true);
return;
}
- TTServiceUtil.buildMp3Response(response, null, filename, 200, false);
+ TTServiceUtil.buildMp3Response(response, null, filepath, 200, false);
+ if (tmp) {
+ POOL.submit(() -> {
+ if (!new File(filepath).delete()) log.info("删除tmp文件失败:{}",filepath);
+ });
+ }
return;
}
}
@@ -427,26 +435,179 @@ public class TTService {
}
}
}
- if ("filename".equals(_type)) {
- TTServiceUtil.buildTTS_lsResponse(response, null, file_ls, 200);
- return;
- }
- List contents = new ArrayList<>();
- for (String filename : file_ls) {
- if (filename.equals(Initialize.getThirdParty())) {
- contents.add(filename);
- continue;
+ TtsLsResponse ttsLsResponse = new TtsLsResponse();
+ try {
+ switch (TtsLsType.valueOf(_type)) {
+ case filename: {
+ ttsLsResponse.setStatus(200);
+ for (String name: file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ audio.setFilename(name);
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ case b64: {
+ ttsLsResponse.setStatus(200);
+ for (String filename : file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (filename.equals(Initialize.getThirdParty())) {
+ audio.setB64(filename);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ filename = filename+".b64";
+ try {
+ audio.setB64(TTSUtils.readAllFile(filename));
+ } catch (Exception e) {
+ log.error("读取文件{}内容出错:{}", filename, e.toString());
+ audio.setB64("");
+ }
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ case url: {
+ ttsLsResponse.setStatus(200);
+ String pre = Initialize.getServerUrl()+"/api/tts/get_audio?filename=";
+ for (String path: file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (path.equals(Initialize.getThirdParty())) {
+ audio.setUrl(path);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ path = path.substring(Initialize.getAudioDir().length()+1);
+ audio.setUrl(pre+path);
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ case urlB64: {
+ ttsLsResponse.setStatus(200);
+ String pre = Initialize.getServerUrl()+"/api/tts/get_audio?filename=";
+ for (String path: file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (path.equals(Initialize.getThirdParty())) {
+ audio.setUrl(path);
+ audio.setB64(path);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ audio.setUrl(pre+path.substring(Initialize.getAudioDir().length()+1));
+ path = path+".b64";
+ try {
+ audio.setB64(TTSUtils.readAllFile(path));
+ } catch (Exception e) {
+ log.error("读取文件{}内容出错:{}", path, e.toString());
+ audio.setB64("");
+ }
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ case fileB64: {
+ ttsLsResponse.setStatus(200);
+ for (String path: file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (path.equals(Initialize.getThirdParty())) {
+ audio.setFilename(path);
+ audio.setB64(path);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ path = path+".b64";
+ audio.setFilename(path);
+ try {
+ audio.setB64(TTSUtils.readAllFile(path));
+ } catch (Exception e) {
+ log.error("读取文件{}内容出错:{}", path, e.toString());
+ audio.setB64("");
+ }
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ case urlFile: {
+ ttsLsResponse.setStatus(200);
+ String pre = Initialize.getServerUrl()+"/api/tts/get_audio?filename=";
+ for (String path: file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (path.equals(Initialize.getThirdParty())) {
+ audio.setUrl(path);
+ audio.setFilename(path);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ audio.setUrl(pre+path.substring(Initialize.getAudioDir().length()+1));
+ audio.setFilename(path+".b64");
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
+ default: {
+ ttsLsResponse.setStatus(200);
+ for (String filename : file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (filename.equals(Initialize.getThirdParty())) {
+ audio.setB64(filename);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ filename = filename+".b64";
+ try {
+ audio.setB64(TTSUtils.readAllFile(filename));
+ } catch (Exception e) {
+ log.error("读取文件{}内容出错:{}", filename, e.toString());
+ audio.setB64("");
+ }
+ ttsLsResponse.getAudio().add(audio);
+ }
+ break;
+ }
}
- filename = filename+".b64";
- try {
- contents.add(TTSUtils.readAllFile(filename));
- } catch (Exception e) {
- log.error("读取文件{}内容出错:{}", filename, e.toString());
+ } catch (Exception e) {
+ log.error("tts_ls的switch出错:{},_type:{}",e.toString(), _type);
+ ttsLsResponse.setStatus(200);
+ for (String filename : file_ls) {
+ TtsLsAudio audio = new TtsLsAudio();
+ if (filename.equals(Initialize.getThirdParty())) {
+ audio.setB64(filename);
+ ttsLsResponse.getAudio().add(audio);
+ continue;
+ }
+ filename = filename+".b64";
+ try {
+ audio.setB64(TTSUtils.readAllFile(filename));
+ } catch (Exception e1) {
+ log.error("读取文件{}内容出错:{}", filename, e1.toString());
+ audio.setB64("");
+ }
+ ttsLsResponse.getAudio().add(audio);
}
}
- TTServiceUtil.buildTTS_lsResponse(response, null, contents, 200);
+ TTServiceUtil.buildNewTtsLsResponse(response, ttsLsResponse, 200);
+
+// if ("filename".equals(_type)) {
+// TTServiceUtil.buildTTS_lsResponse(response, null, file_ls, 200);
+// return;
+// }
+// List contents = new ArrayList<>();
+// for (String filename : file_ls) {
+// if (filename.equals(Initialize.getThirdParty())) {
+// contents.add(filename);
+// continue;
+// }
+// filename = filename+".b64";
+// try {
+// contents.add(TTSUtils.readAllFile(filename));
+// } catch (Exception e) {
+// log.error("读取文件{}内容出错:{}", filename, e.toString());
+// }
+// }
+// TTServiceUtil.buildTTS_lsResponse(response, null, contents, 200);
}
- }else {
+ } else {
TTServiceUtil.buildTTS_lsResponse(response, new TTSResponse(400, "text_info_ls字段不能为空"), null, 400);
}
}
@@ -523,8 +684,10 @@ public class TTService {
// botname为空则赋予tmp
String botName = ttsRequest.getBotname();
+ boolean tmpRequest = false;
if (StringUtils.isBlank(botName)) {
botName = "tmp";
+ tmpRequest = true;
}
String npcName = ttsRequest.getNpcName();
@@ -561,6 +724,9 @@ public class TTService {
//http://(server_url)/api/tts/get_audio?dirs=[botname+person,mood]&filename=xxx.mp3
try {
dirs = URLEncoder.encode(dirs, "UTF-8"); // 编码URL中的中文
+ if (tmpRequest) {
+ fileName = new StringBuilder(RandomStringUtils.randomAlphabetic(3)).append(System.currentTimeMillis()).append(".mp3").toString();
+ }
String audio = String.format("%s/api/tts/get_audio?dirs=%s&filename=%s", Initialize.getServerUrl(),
dirs, fileName);
response = new TTSResponse(audio,200);
@@ -574,6 +740,7 @@ public class TTService {
GeneralMP3Data data = new GeneralMP3Data(Initialize.getServerName(), ttsRequest.getText(),
person, mood, botName, true, volume, speed, pitch);
data.setNpcName(npcName);
+ if (tmpRequest) data.setTmpName(fileName);
ResponseCodeWithData codeWithData = generalMP3(moodUrl, data, filePath, requestMethod, getOnline);
if (codeWithData.getCode() != 200) {
if (codeWithData.getCode() == 404) {
@@ -584,6 +751,7 @@ public class TTService {
TTServiceUtil.buildServletResponse(servletResponse, new TTSResponse(codeWithData.getCode()), null, codeWithData.getCode());
return;
}
+
}
if (response == null) {
TTServiceUtil.buildServletResponse(servletResponse, null, new File(filePath), 200);
@@ -645,6 +813,7 @@ public class TTService {
if (fileExist) {
new File(filePath).delete();
}
+ if (data.getTmpName() != null) filePath = filePath.substring(0, filePath.lastIndexOf(File.separator)+1)+data.getTmpName();
res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath);
} else if (!fileExist) {
if (offlineService.equals(url)) {
@@ -923,9 +1092,10 @@ public class TTService {
// 实际使用的是sox命令来生成mp3的
// executeResult = CallPython.changeSound(wavFilename, volume, speed,
// pitch, mp3FilePath);
-
+// long start = System.currentTimeMillis();
executeResult = CallPython.changeSoundByPython(wavFilename, String.valueOf(volume), String.valueOf(speed),
String.valueOf(pitch), mp3FilePath);
+// log.info("CallPython.changeSoundByPython 耗时:{}",System.currentTimeMillis()-start);
if (!TTSUtils.doesFileExist(mp3FilePath)) {
log.error("python代码出错,mp3文件没有创建成功");
res = new ResponseCodeWithData(555);
@@ -1055,7 +1225,13 @@ public class TTService {
boolean result;
// 去除所有{/../}
text = text.replaceAll("\\{/.*?/}", "").trim();
+ if (StringUtils.isBlank(text)) {
+ log.error("第三方请求内容为空");
+ return new ResponseCodeWithData(500, "第三方请求内容为空");
+ }
+// long start = System.currentTimeMillis();
result = ThirdPartyService.thirdPartyCall(text, Initialize.theThirdPartysPer(person), filepath, person);
+// log.info("ThirdPartyService.thirdPartyCall耗时:{}", System.currentTimeMillis()-start);
if (result) {
return new ResponseCodeWithData(200, "创建第三方wav文件成功");
}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
index dba2213..7366302 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
@@ -1,7 +1,11 @@
package ai.qiwu.com.tts_service.service;
import ai.qiwu.com.tts_service.common.TTSUtils;
+import ai.qiwu.com.tts_service.pojo.TtsLsAudio;
+import ai.qiwu.com.tts_service.pojo.TtsLsResponse;
+import ai.qiwu.com.tts_service.pojo.TtsLsType;
import ai.qiwu.com.tts_service.pojo.upload.UploadOneSenData;
+import com.alibaba.fastjson.JSON;
import com.csvreader.CsvReader;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -9,6 +13,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
import java.io.*;
+import java.math.BigInteger;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.text.ParseException;
@@ -17,6 +22,8 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static ai.qiwu.com.tts_service.pojo.TtsLsType.*;
+
/**
* @author 苗权威
* @dateTime 19-9-27 下午1:56
@@ -215,67 +222,17 @@ public class Test {
}
public static void main(String[] args) throws IOException, ParseException {
-// long start = System.currentTimeMillis();
-// uploadOneNpc(null);
-// System.out.println(System.currentTimeMillis()-start);
-
-// String folder = "/home/yf01/下载/tts/test/齐齐";
-// File file = new File(folder);
-// int i = 0;
-// for (File f: file.listFiles()) {
-// if (f.getName().length() <= 8) {
-// i++;
-// System.out.println(f.getName()+" ");
-// }
-// }
-// System.out.println(i);
-
- //test4();
- //test6();
-// String ss = "哈{/ha/}哈{/ha/}哈{/ha4/}哈{/ha4/},好久没有如此畅快了!再{/zai4/}来{/lai2/}!红叶香山挂满枝,尘嚣欲留雨洗池。过风迷眼人踪处,客换却道知不知? 此招题目是什么?!";
-// String t = "哈{/ha/}哈{/ha/}哈{/ha4/}哈{/ha4/},好久没有如此畅快了!再{/zai4/}来{/lai2/}!红叶香山挂满枝,尘嚣欲留雨洗池。过风迷眼人踪处,客换却道知不知??此招题目是什么?!";
-// String bukong = "哈{/ha/}哈{/ha/}哈{/ha4/}哈{/ha4/},好久没有如此畅快了!再{/zai4/}来{/lai2/}!红叶香山挂满枝,尘嚣欲留雨洗池。过风迷眼人踪处,客换却道知不知? 此招题目是什么?!";
-// String kong = "哈{/ha/}哈{/ha/}哈{/ha4/}哈{/ha4/},好久没有如此畅快了!再{/zai4/}来{/lai2/}!红叶香山挂满枝,尘嚣欲留雨洗池。过风迷眼人踪处,客换却道知不知? 此招题目是什么?! ";
-//
-// String sss = "回答错误,正确答案为 :疑是地上霜。 当前体力值为 ";
-// System.out.println(TTSUtils.buildMP3Filename(sss));
-// SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", java.util.Locale.US);
-// Date date = sdf.parse("Sat Sep 28 20:51:14 CST 2019");
-//
-// String tt = ":";
-// tt = tt.replaceAll("\\p{P}", "");
-// System.out.println(StringUtils.isBlank(tt));
-//
-// String ss3 = "你当{/dang1/}前分{/fen1/}数{/shu4/}是\uD83C\uDD70\uD83C\uDD71。";
-// String ss4 = "挑战旁白:你当{/dang1/}前分{/fen1/}数{/shu4/}是\uD83C\uDD7010\uD83C\uDD71";
-// System.out.println(TTSUtils.buildMP3Filename(ss3));
-// System.out.println(TTSUtils.buildMP3Filename(ss4));
-//
-// System.out.println("=======================");
-// String tt1 = "\uD83C\uDD702424\uD83C\uDD71sgag\uD83C\uDD70657\uD83C\uDD71agasgh";
-// TreeMap combineMp3Text2FilePath = new TreeMap<>(Comparator.comparingInt(tt1::indexOf));
-// Pattern pattern = Pattern.compile(TTSUtils.getAbRegex());
-// Matcher matcher = pattern.matcher(tt1);
-// while (matcher.find()) {
-// combineMp3Text2FilePath.put(matcher.group(1), matcher.group(1));
-// }
-// String[] arr = pattern.split(tt1);
-// System.out.println(Arrays.toString(arr));
-// for (String s: arr) {
-// combineMp3Text2FilePath.put(s, s);
-// }
-// System.out.println(combineMp3Text2FilePath.values());
-//
-// System.out.println("=======================");
-//
-// String mr = "igaijgoj©️ge要不断he";
-// System.out.println(mr.replaceAll("\\p{P}", ""));
-// System.out.println(mr.replaceAll("\\W", ""));
-//
-// String ssss = "你当{/dang1/}前分{/fen1/}数{/shu4/}是\uD83C\uDD700\uD83C\uDD71。";
-// System.out.println(ssss.indexOf("\uD83C\uDD70"));
-
- String tts = "其实进炼气期之后给的储物袋里有介绍这个的玉简。我们这些没有什么特长的也就接着体力活混点资源,如果会炼丹炼器这些,贡献点增长可就快了。";
- System.out.println(TTSUtils.buildMP3Filename(tts));
+ Date date = new Date(1572522571234L);
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ System.out.println(format.format(date));
+// BigInteger bigInteger = new BigInteger("1572522571");
+// BigInteger[] mas = bigInteger.divideAndRemainder(new BigInteger("60"));
+// BigInteger second = mas[1];
+// BigInteger[] ham = mas[0].divideAndRemainder((new BigInteger("60")));
+// BigInteger minute = ham[1];
+// BigInteger hour = ham[0].remainder(new BigInteger("24"));
+// System.out.println(hour+":"+minute+":"+second);
+ System.out.println(TTSUtils.buildMP3Filename("你看向铁塔,发现一个男人正站在斜塔的高处,手里拿着一大一小两个铁球,而你身边的人也在不断的议论纷纷,一个身穿褐色长袍的男人愤愤的说,"));
+ System.out.println(TTSUtils.buildMP3Filename("你看向铁塔,发现一个男人正站在斜塔的高处,手里拿着一大一小两个铁球,而你身边的人也在不断的议论纷纷,一个穿褐色长袍的男人愤愤的说,"));
}
}
diff --git a/tts_service/src/main/resources/application.yml b/tts_service/src/main/resources/application.yml
index 5d19ded..d450597 100755
--- a/tts_service/src/main/resources/application.yml
+++ b/tts_service/src/main/resources/application.yml
@@ -25,6 +25,8 @@ logging:
# path: /root/GameEditor/mqw/project/ttsTest/logs
level:
root: info
+ okhttp3:
+ OkHttpClient: FINE
server:
port: 9663
# port: 8188
@@ -33,5 +35,6 @@ server:
enabled: true
pattern: '%h %l %u %t "%r" %s %b bytes %D ms'
directory: /home/ubuntu/project/tts/tomcat
-# directory: /root/GameEditor/mqw/project/ttsTest/tomcat
- connection-timeout: 240000
+ max-threads: 1024
+ # directory: /root/GameEditor/mqw/project/ttsTest/tomcat
+ connection-timeout: 2000
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
index dcc1bab..05c7a5c 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
@@ -44,8 +44,9 @@ public class OkHttp3Utils {
paramsIterator.forEachRemaining(e -> urlBuild.addQueryParameter(e.getKey(), e.getValue()));
builder.url(urlBuild.build()).headers(headerBuilder.build());
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()) {
+ return body.string();
}
}
@@ -72,8 +73,9 @@ public class OkHttp3Utils {
// headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
client.dispatcher().cancelAll();
@@ -92,8 +94,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
client.dispatcher().cancelAll();
@@ -144,9 +147,9 @@ public class OkHttp3Utils {
RequestBody.create(MediaType.parse("application/octet-stream"), file));
}
builder.headers(headBuilder.build()).post(requestBuilder.build());
-
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -171,9 +174,9 @@ public class OkHttp3Utils {
RequestBody.create(MediaType.parse("application/octet-stream"), fileByte));
}
builder.headers(headBuilder.build()).post(requestBuilder.build());
-
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -187,8 +190,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).put(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
@@ -202,8 +206,9 @@ public class OkHttp3Utils {
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).delete(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
- return response.body().string();
+ Response response = client.newCall(builder.build()).execute();
+ try (ResponseBody body = response.body()){
+ return body.string();
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java
index 11ba3c7..74e0a27 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java
@@ -1,11 +1,5 @@
package ai.qiwu.com.xiaoduhome.common;
-import com.alibaba.fastjson.JSON;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
/**
* @author 苗权威
@@ -13,47 +7,6 @@ import java.util.Map;
*/
public class Test {
public static void main(String[] args) {
- String old = "105463045 225830125 3377841230 5676775731 6701820674 844142256\n" +
- "1270260186 2317741281 3451399937 5680433720 679786552 8443780996\n" +
- "129554816 236055939 3953909652 573677395 6823941516 8512764381\n" +
- "1319246985 2382677892 3977898978 5741775745 6828091493 8666831550\n" +
- "147614308 24024206 400828730 576085455 6854303973 8907881060\n" +
- "1483080963 2428131253 4010431623 5842366428 7051119238 895119889\n" +
- "1606067284 249646023 4077876805 5935461946 7094375730 9086594830\n" +
- "1619186778 2501460915 4151097686 602060014 7206220924 909823100\n" +
- "1800148835 251440645 425569307 6035298742 7237124566 9159908109\n" +
- "1814141710 259741977 4366487183 6080626246 7248854152 927936967\n" +
- "1845949389 2675579304 4436643416 608322788 7355973668 9346692436\n" +
- "191786926 2815623868 4707303948 6259213309 7414315062 9386970292\n" +
- "197591333 281647119 4758925745 6342520523 775958237 9395788731\n" +
- "2072955971 2850282206 4775675552 6350303840 80449325 946062731\n" +
- "2078508735 2866985233 5059399282 6468672492 8048230081 948644704\n" +
- "2090828382 289568194 5134779537 6506984096 816254767 977180886\n" +
- "2117067137 2958839358 528743718 6587660996 82899304 9965361790\n" +
- "2131112347 318451742 556138651 6641799260 8343905461 miao\n" +
- "2178577413 323374327 560117740 666266085 8357861424 tmp\n" +
- "2198001446 334045489 562358308 6698994869 8409603662";
-
- String fresh2 = "105463045 302351783 560117740 666266085 746248650 928403654\n" +
- "129554816 323374327 562358308 6732814591 775958237 9395788731\n" +
- "1704438748 336928756 5741775745 679786552 8048230081 946062731\n" +
- "1845949389 4077876805 576085455 6823941516 823307669 948644704\n" +
- "2078508735 4151097686 5903691804 6854303973 82899304 977180886\n" +
- "2382677892 4779893096 59494295 703543985 8343905461 980770230\n" +
- "249646023 494372549 602060014 7206220924 839091027 miao\n" +
- "275290675 5059399282 608322788 7414315062 8512764381 tmp\n" +
- "297326874 556138651 665686051 743677363 910965323";
-
- fresh2 = fresh2.replaceAll("\\s+", ",");
- old = old.replaceAll("\\s+", ",");
-
- System.out.println(fresh2);
-// List oldArr = new ArrayList<>(Arrays.asList(old.split(",")));
-// List freshArr2 = new ArrayList<>(Arrays.asList(fresh2.split(",")));
-// oldArr.removeAll(freshArr2);
-// System.out.println(oldArr);
-// System.out.println(fresh);
-// System.out.println(old);
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
index 47a07a7..0ed25ea 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
@@ -248,7 +248,6 @@ public class ScheduleService implements InitializingBean {
deleteUnPayedOrder();
tian();
getAsideImg();
- Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
}
private void tian(){
diff --git a/xiaoduhome/src/main/resources/application.yml b/xiaoduhome/src/main/resources/application.yml
index 335b523..f4318b4 100755
--- a/xiaoduhome/src/main/resources/application.yml
+++ b/xiaoduhome/src/main/resources/application.yml
@@ -25,4 +25,6 @@ spring:
logging:
path: /home/dc2-user/projects/audiobox/duai/logs
level:
- root: info
\ No newline at end of file
+ root: info
+ okhttp3:
+ OkHttpClient: FINE
\ No newline at end of file
--
libgit2 0.27.1