From a1fd2b1aadf53ef8cb20f08d6269fc52d188ef70 Mon Sep 17 00:00:00 2001 From: 苗权威 <1160292058@qq.com> Date: Sat, 29 Jun 2019 19:03:21 +0800 Subject: [PATCH] Push --- .idea/compiler.xml | 29 +++++++++++++++++++++++++++++ .idea/encodings.xml | 11 +++++++++++ .idea/inspectionProfiles/Project_Default.xml | 6 ++++++ .idea/misc.xml | 20 ++++++++++++++++++++ .idea/uiDesigner.xml | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .idea/vcs.xml | 6 ++++++ .idea/workspace.xml | 858 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/.gitignore | 31 +++++++++++++++++++++++++++++++ dingdong/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes dingdong/.mvn/wrapper/maven-wrapper.properties | 1 + dingdong/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/pom.xml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java | 13 +++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java | 39 +++++++++++++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java | 15 +++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java | 9 +++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java | 37 +++++++++++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java | 31 +++++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java | 18 ++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java | 20 ++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java | 19 +++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java | 29 +++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java | 19 +++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java | 18 ++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java | 17 +++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dingdong/src/main/resources/application.properties | 1 + dingdong/src/test/java/ai/qiwu/dong/dingdong/DingdongApplicationTests.java | 16 ++++++++++++++++ pom.xml | 12 ++++++++++++ ruoqi/.gitignore | 31 +++++++++++++++++++++++++++++++ ruoqi/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ruoqi/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes ruoqi/.mvn/wrapper/maven-wrapper.properties | 1 + ruoqi/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ruoqi/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ruoqi/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ ruoqi/src/main/java/ai/qiwu/rokid/ruoqi/RuoqiApplication.java | 13 +++++++++++++ ruoqi/src/main/resources/application.properties | 1 + ruoqi/src/test/java/ai/qiwu/rokid/ruoqi/RuoqiApplicationTests.java | 16 ++++++++++++++++ smartbox.iml | 2 ++ spirit/.gitignore | 31 +++++++++++++++++++++++++++++++ spirit/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spirit/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes spirit/.mvn/wrapper/maven-wrapper.properties | 1 + spirit/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spirit/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spirit/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java | 13 +++++++++++++ spirit/src/main/resources/application.properties | 1 + spirit/src/test/java/ai/qiwu/tmall/spirit/SpiritApplicationTests.java | 16 ++++++++++++++++ xiaoai/.gitignore | 31 +++++++++++++++++++++++++++++++ xiaoai/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoai/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes xiaoai/.mvn/wrapper/maven-wrapper.properties | 1 + xiaoai/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoai/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoai/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java | 13 +++++++++++++ xiaoai/src/main/resources/application.properties | 1 + xiaoai/src/test/java/ai/qiwu/mi/xiaoai/XiaoaiApplicationTests.java | 16 ++++++++++++++++ xiaodu/.gitignore | 31 +++++++++++++++++++++++++++++++ xiaodu/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes xiaodu/.mvn/wrapper/maven-wrapper.properties | 1 + xiaodu/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/pom.xml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java | 13 +++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java | 32 ++++++++++++++++++++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java | 34 ++++++++++++++++++++++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java | 34 ++++++++++++++++++++++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java | 15 +++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaodu/src/main/resources/application.properties | 1 + xiaodu/src/test/java/ai/qiwu/baidu/xiaodu/XiaoduApplicationTests.java | 16 ++++++++++++++++ xiaoya/.gitignore | 31 +++++++++++++++++++++++++++++++ xiaoya/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoya/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes xiaoya/.mvn/wrapper/maven-wrapper.properties | 1 + xiaoya/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoya/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoya/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java | 13 +++++++++++++ xiaoya/src/main/resources/application.properties | 1 + xiaoya/src/test/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplicationTests.java | 16 ++++++++++++++++ 89 files changed, 6167 insertions(+) create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 dingdong/.gitignore create mode 100644 dingdong/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 dingdong/.mvn/wrapper/maven-wrapper.jar create mode 100644 dingdong/.mvn/wrapper/maven-wrapper.properties create mode 100755 dingdong/mvnw create mode 100644 dingdong/mvnw.cmd create mode 100644 dingdong/pom.xml create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java create mode 100644 dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java create mode 100644 dingdong/src/main/resources/application.properties create mode 100644 dingdong/src/test/java/ai/qiwu/dong/dingdong/DingdongApplicationTests.java create mode 100644 pom.xml create mode 100644 ruoqi/.gitignore create mode 100644 ruoqi/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 ruoqi/.mvn/wrapper/maven-wrapper.jar create mode 100644 ruoqi/.mvn/wrapper/maven-wrapper.properties create mode 100755 ruoqi/mvnw create mode 100644 ruoqi/mvnw.cmd create mode 100644 ruoqi/pom.xml create mode 100644 ruoqi/src/main/java/ai/qiwu/rokid/ruoqi/RuoqiApplication.java create mode 100644 ruoqi/src/main/resources/application.properties create mode 100644 ruoqi/src/test/java/ai/qiwu/rokid/ruoqi/RuoqiApplicationTests.java create mode 100644 smartbox.iml create mode 100644 spirit/.gitignore create mode 100644 spirit/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 spirit/.mvn/wrapper/maven-wrapper.jar create mode 100644 spirit/.mvn/wrapper/maven-wrapper.properties create mode 100755 spirit/mvnw create mode 100644 spirit/mvnw.cmd create mode 100644 spirit/pom.xml create mode 100644 spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java create mode 100644 spirit/src/main/resources/application.properties create mode 100644 spirit/src/test/java/ai/qiwu/tmall/spirit/SpiritApplicationTests.java create mode 100644 xiaoai/.gitignore create mode 100644 xiaoai/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 xiaoai/.mvn/wrapper/maven-wrapper.jar create mode 100644 xiaoai/.mvn/wrapper/maven-wrapper.properties create mode 100755 xiaoai/mvnw create mode 100644 xiaoai/mvnw.cmd create mode 100644 xiaoai/pom.xml create mode 100644 xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java create mode 100644 xiaoai/src/main/resources/application.properties create mode 100644 xiaoai/src/test/java/ai/qiwu/mi/xiaoai/XiaoaiApplicationTests.java create mode 100644 xiaodu/.gitignore create mode 100644 xiaodu/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 xiaodu/.mvn/wrapper/maven-wrapper.jar create mode 100644 xiaodu/.mvn/wrapper/maven-wrapper.properties create mode 100755 xiaodu/mvnw create mode 100644 xiaodu/mvnw.cmd create mode 100644 xiaodu/pom.xml create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java create mode 100644 xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java create mode 100644 xiaodu/src/main/resources/application.properties create mode 100644 xiaodu/src/test/java/ai/qiwu/baidu/xiaodu/XiaoduApplicationTests.java create mode 100644 xiaoya/.gitignore create mode 100644 xiaoya/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 xiaoya/.mvn/wrapper/maven-wrapper.jar create mode 100644 xiaoya/.mvn/wrapper/maven-wrapper.properties create mode 100755 xiaoya/mvnw create mode 100644 xiaoya/mvnw.cmd create mode 100644 xiaoya/pom.xml create mode 100644 xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java create mode 100644 xiaoya/src/main/resources/application.properties create mode 100644 xiaoya/src/test/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplicationTests.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..a6f6f49 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..70dc759 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..60c6d36 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6496e7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,20 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8dce11d --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,858 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1561553648378 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/dingdong/.gitignore b/dingdong/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/dingdong/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/dingdong/.mvn/wrapper/MavenWrapperDownloader.java b/dingdong/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/dingdong/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/dingdong/.mvn/wrapper/maven-wrapper.jar b/dingdong/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/dingdong/.mvn/wrapper/maven-wrapper.jar differ diff --git a/dingdong/.mvn/wrapper/maven-wrapper.properties b/dingdong/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/dingdong/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/dingdong/mvnw b/dingdong/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/dingdong/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/dingdong/mvnw.cmd b/dingdong/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/dingdong/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/dingdong/pom.xml b/dingdong/pom.xml new file mode 100644 index 0000000..3a07b64 --- /dev/null +++ b/dingdong/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.dong + dingdong + 0.0.1-SNAPSHOT + dingdong + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.apache.httpcomponents + httpclient + 4.5.8 + + + com.alibaba + fastjson + 1.2.58 + + + + org.projectlombok + lombok + 1.18.8 + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java new file mode 100644 index 0000000..b4c3faa --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.dong.dingdong; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DingdongApplication { + + public static void main(String[] args) { + SpringApplication.run(DingdongApplication.class, args); + } + +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java new file mode 100644 index 0000000..d148754 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java @@ -0,0 +1,39 @@ +package ai.qiwu.dong.dingdong.common; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:15 + */ +public interface Constants { + String QI_WU_INTERFACE = "http://aliyun-hz1.chewrobot.com:8070/api/chat"; + String SERVICE_NAME = "DINGDONG"; + String USER_END = "USER_END"; + String SESSION_TIMEOUT = "SESSION_TIMEOUT"; + String SESSION_ALLTIMES_OUT = "SESSION_ALLTIMES_OUT"; + String SESSION_CURTIMES_OUT = "SESSION_CURTIMES_OUT"; + String OPEN_PLATFORM_ERROR = "OPEN_PLATFORM_ERROR"; + String SERVICE_INVOKER_TIMEOUT = "SERVICE_INVOKER_TIMEOUT"; + String SERVICE_INVOKER_ERROR = "SERVICE_INVOKER_ERROR"; + + String USER_INTPUT_NOREC = "USER_INTPUT_NOREC"; + String USER_NOREC_TIMES_OUT = "USER_NOREC_TIMES_OUT"; + String DEV_RESP_PACK_TOO_LONG = "DEV_RESP_PACK_TOO_LONG"; + String DEV_SERVICE_VISIT_TIME_OUT = "DEV_SERVICE_VISIT_TIME_OUT"; + String DEV_SERVICE_RESP_PACK_ERROR = "DEV_SERVICE_RESP_PACK_ERROR"; + String NOTICE_OPEN_PLATFORM_ERROR = "OPEN_PLATFORM_ERROR"; + + interface Intent { + String XIAO_WU = "xiaowu"; + String RECOMMEND = "recommend"; + String START_BY_ANSWER = "startByAnswer"; + String END_BY_END = "endByEnd"; + } + + interface Status { + String LAUNCH = "LAUNCH"; + String NOTICE = "NOTICE"; + String END = "END"; + String INTENT = "INTENT"; + } + +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java new file mode 100644 index 0000000..1c33de1 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java @@ -0,0 +1,15 @@ +package ai.qiwu.dong.dingdong.common; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author 苗权威 + * @dateTime 19-6-28 下午2:11 + */ +@Getter +@Setter +public class LastResponseTimeAndAudio { + private volatile Long timeStamp; + private volatile String url; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java new file mode 100644 index 0000000..c32e651 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java @@ -0,0 +1,9 @@ +package ai.qiwu.dong.dingdong.common; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午8:26 + */ +public class SnowFlake { + +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java new file mode 100644 index 0000000..7833bcc --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java @@ -0,0 +1,37 @@ +package ai.qiwu.dong.dingdong.controller; + +import ai.qiwu.dong.dingdong.model.request.DingDongRequest; +import ai.qiwu.dong.dingdong.model.response.DingDongResponse; +import ai.qiwu.dong.dingdong.service.ParseService; +import ai.qiwu.dong.dingdong.service.ParseServiceCompromise; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:35 + */ +@RestController +public class DingDongController { + + private static final Logger logger = LoggerFactory.getLogger(ParseService.class); + +// @Autowired +// private ParseServiceCompromise compromise; + + @Autowired + private ParseService parseService; + + @RequestMapping("/ding") + public @ResponseBody DingDongResponse dingdong(@RequestBody DingDongRequest request) { + logger.info("Request params : "+ request); + return parseService.getResponse(request); + } + + @RequestMapping("/ding/callback") + public void dingdongCallback(@RequestParam String state) { + logger.info("Callback response : "+ state); + } +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java new file mode 100644 index 0000000..7e7ee19 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java @@ -0,0 +1,31 @@ +package ai.qiwu.dong.dingdong.model.request; + +import ai.qiwu.dong.dingdong.model.request.applicationInfo.ApplicationInfo; +import ai.qiwu.dong.dingdong.model.request.session.Session; +import ai.qiwu.dong.dingdong.model.request.user.User; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午12:55 + */ +@Getter +@Setter +@ToString +public class DingDongRequest { + private String versionid; + private String status; + private String sequence; + private Long timestamp; + private String input_text; + private Map slots; + private String ended_reason; + private String notice_type; + private ApplicationInfo application_info; + private Session session; + private User user; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java new file mode 100644 index 0000000..ee29c40 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java @@ -0,0 +1,18 @@ +package ai.qiwu.dong.dingdong.model.request.applicationInfo; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午12:59 + */ +@Getter +@Setter +@ToString +public class ApplicationInfo { + private String application_name; + private String application_id; + private String application_version; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java new file mode 100644 index 0000000..aa711d8 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java @@ -0,0 +1,20 @@ +package ai.qiwu.dong.dingdong.model.request.session; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:00 + */ +@Getter +@Setter +@ToString +public class Session { + private String is_new; + private String session_id; + private Map attributes; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java new file mode 100644 index 0000000..ae38bbb --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java @@ -0,0 +1,19 @@ +package ai.qiwu.dong.dingdong.model.request.user; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:01 + */ +@Getter +@Setter +@ToString +public class User { + private String user_id; + private Map attributes; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java new file mode 100644 index 0000000..d3702e3 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java @@ -0,0 +1,29 @@ +package ai.qiwu.dong.dingdong.model.response; + +import ai.qiwu.dong.dingdong.model.response.card.Card; +import ai.qiwu.dong.dingdong.model.response.directive.Directive; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:03 + */ +@Getter +@Setter +@ToString +public class DingDongResponse { + private String versionid; + private Boolean is_end; + private String sequence; + private Long timestamp; + private String need_slot; + private Map extend; + private Directive directive; + private Card push_to_app; + private Directive repeat_directive; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java new file mode 100644 index 0000000..de3b30b --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java @@ -0,0 +1,19 @@ +package ai.qiwu.dong.dingdong.model.response.card; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:11 + */ +@Getter +@Setter +@ToString +public class Card { + private String title; + private String type; + private String text; + private String url; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java new file mode 100644 index 0000000..3d6a9da --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java @@ -0,0 +1,18 @@ +package ai.qiwu.dong.dingdong.model.response.directive; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:06 + */ +@Getter +@Setter +@ToString +public class Directive { + private List directive_items; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java new file mode 100644 index 0000000..1bd1e3d --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java @@ -0,0 +1,17 @@ +package ai.qiwu.dong.dingdong.model.response.directive; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:10 + */ +@Getter +@Setter +@ToString +public class DirectiveItem { + private String type; + private String content; +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java new file mode 100644 index 0000000..5c4b0f0 --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java @@ -0,0 +1,252 @@ +package ai.qiwu.dong.dingdong.service; + +import ai.qiwu.dong.dingdong.common.Constants; +import ai.qiwu.dong.dingdong.common.LastResponseTimeAndAudio; +import ai.qiwu.dong.dingdong.model.request.DingDongRequest; +import ai.qiwu.dong.dingdong.model.request.user.User; +import ai.qiwu.dong.dingdong.model.response.DingDongResponse; +import ai.qiwu.dong.dingdong.model.response.directive.Directive; +import ai.qiwu.dong.dingdong.model.response.directive.DirectiveItem; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author 苗权威 + * @dateTime 19-6-27 下午1:13 + */ +@Service("parseService") +public class ParseService { + + private static final Logger logger = LoggerFactory.getLogger(ParseService.class); + + private static final ConcurrentHashMap REQUEST_TIMESTAMP_INTERVAL= new ConcurrentHashMap<>(); + + private static final ConcurrentHashMap SESSION_ID_WITH_REPEAT_COUNT= new ConcurrentHashMap<>(); + + + public DingDongResponse getResponse(DingDongRequest request) { + String userId = null; + User user = request.getUser(); + if (user != null && user.getUser_id() != null) { + userId = request.getUser().getUser_id(); + }else { + if (request.getApplication_info() != null) { + userId = request.getApplication_info().getApplication_id(); + } + if (userId == null) { + //文档保证session字段一定不为空,将其id当作该种情况下的用户id + // 一次会话从开始到结束,sessionId不变,一次会话指的是从用户进入到我们的技能到其退出为止 + userId = request.getSession().getSession_id(); + } + + } + + if ("NOTICE".equals(request.getStatus())) { + DingDongResponse noticeResponse = dealWithNoticeStatus(request); + Integer removedRepeatCount = SESSION_ID_WITH_REPEAT_COUNT.remove(userId); + if (removedRepeatCount != null) { + logger.info("删除之前的重复次数:"+removedRepeatCount); + } + return noticeResponse; + }else if ("END".equals(request.getStatus())) { + DingDongResponse endResponse = dealWithEndStatus(request); + Integer removedRepeatCount = SESSION_ID_WITH_REPEAT_COUNT.remove(userId); + if (removedRepeatCount != null) { + logger.info("删除之前的重复次数:"+removedRepeatCount); + } + return endResponse; + } + + + String userWord = request.getInput_text(); + String requestVersion = request.getVersionid(); + String requestSequence = request.getSequence(); + + LastResponseTimeAndAudio lastResponseContent = REQUEST_TIMESTAMP_INTERVAL.get(userId); + if (lastResponseContent != null && request.getTimestamp() <= lastResponseContent.getTimeStamp() + 5000) { + Integer previousCount = SESSION_ID_WITH_REPEAT_COUNT.putIfAbsent(userId, 0); + if (previousCount == null || previousCount < 2) { + int currentCount = previousCount == null ? 1 : previousCount+1; + logger.info("两次请求过于短暂,可能是叮咚识别了自己的话,播放前一次的语音,重复次数: "+ currentCount); + SESSION_ID_WITH_REPEAT_COUNT.put(userId, currentCount); + if (lastResponseContent.getUrl() == null) { + return buildErrorResponse(requestVersion, requestSequence, userId); + }else { + DingDongResponse response = buildResponse(requestVersion, requestSequence, userId); + response.getDirective().getDirective_items().get(0).setContent(lastResponseContent.getUrl()); + return response; + } + } + logger.info("重复次数超过两次,不再重复"); + } + + // slots={focus=Story} +// if (request.getSlots() == null || request.getSlots().size() == 1) { +// logger.info("收到了未在意图中的单字,可能是用户说的或是叮咚受到了自己播放的影响,处理方法:提示用户说的详细一些,这个单字是: "+userWord); +// DingDongResponse uncatchSlot = buildErrorResponse(requestVersion, requestSequence, userId); +// uncatchSlot.getDirective().getDirective_items().get(0).setContent("请说详细一些吧"); +// SESSION_ID_WITH_REPEAT_COUNT.remove(userId); +// return uncatchSlot; +//// if (lastResponseContent != null && lastResponseContent.getUrl() != null) { +//// logger.info("未在意图中的单字情况:播放上次音频链接"); +//// DingDongResponse response = buildResponse(requestVersion, requestSequence, userId); +//// response.getDirective().getDirective_items().get(0).setContent(lastResponseContent.getUrl()); +//// return response; +//// }else { +//// logger.info("未在意图中的单字情况:由于没有音频链接缓存,所以读文字"); +//// DingDongResponse uncatchSlot = buildErrorResponse(requestVersion, requestSequence, userId); +//// uncatchSlot.getDirective().getDirective_items().get(0).setContent("请说详细一些吧"); +//// return uncatchSlot; +//// } +// } + + if (userWord == null) { + Integer removedRepeatCount = SESSION_ID_WITH_REPEAT_COUNT.remove(userId); + if (removedRepeatCount != null) { + logger.info("删除之前的重复次数:"+removedRepeatCount); + } + return buildErrorResponse(requestVersion, requestSequence, userId); + } + + DingDongResponse response = requestQiWuInterface(userId, userWord, requestVersion, requestSequence); + logger.info("RESPONSE : "+response); + Integer removedRepeatCount = SESSION_ID_WITH_REPEAT_COUNT.remove(userId); + if (removedRepeatCount != null) { + logger.info("删除之前的重复次数:"+removedRepeatCount); + } + return response; + } + + private DingDongResponse requestQiWuInterface(String userId, String userWord, String version, String sequence) { + String audioUrl = ""; + String textContent = "请说推荐作品"; + CloseableHttpClient httpClient = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClientBuilder.create().build(); + HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE); + + HashMap params = new HashMap<>(); + params.put("user_id", String.valueOf(userId)); + params.put("text", userWord); + params.put("access",Constants.SERVICE_NAME); + + String paramsJsonFormat = JSON.toJSONString(params); + StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8"); + post.setHeader("Content-Type", "application/json;charset=utf-8"); + post.setEntity(body); + + httpResponse = httpClient.execute(post); + HttpEntity responseBody = httpResponse.getEntity(); + if (responseBody != null) { + String responseContent = EntityUtils.toString(responseBody); + logger.info("齐悟接口返回: "+ responseContent); + JSONObject responseJsonFormat = JSONObject.parseObject(responseContent); + audioUrl = (String) responseJsonFormat.get("audio"); + textContent = (String) responseJsonFormat.get("text"); + } + } catch (IOException e) { + logger.error("请求齐悟接口出错:"+e.toString()); + return buildErrorResponse(version, sequence, userId); + } finally { + try { + if (httpClient != null) httpClient.close(); + if (httpResponse != null) httpResponse.close(); + } catch (IOException e) { + logger.error("关闭与齐悟接口时出错:"+e.toString()); + } + } + return addUrlAndTextToResponse(audioUrl, textContent, version, sequence, userId); + } + + private DingDongResponse addUrlAndTextToResponse(String audioUrl, String text, String version, String sequence, String userId) { + DingDongResponse response = buildResponse(version, sequence, userId); + response.getDirective().getDirective_items().get(0).setContent(audioUrl); + response.getDirective().getDirective_items().get(0).setContent(text); + REQUEST_TIMESTAMP_INTERVAL.get(userId).setUrl(audioUrl); + return response; + } + + private DingDongResponse buildResponse(String versionId, String sequence, String userId) { + DingDongResponse response = new DingDongResponse(); + response.setVersionid(versionId); + response.setIs_end(false); + + LastResponseTimeAndAudio responseContent = REQUEST_TIMESTAMP_INTERVAL.get(userId); + if (responseContent == null) { + responseContent = new LastResponseTimeAndAudio(); + REQUEST_TIMESTAMP_INTERVAL.put(userId, responseContent); + } + Long timeMillis = System.currentTimeMillis(); + responseContent.setTimeStamp(timeMillis); + + response.setTimestamp(timeMillis); + response.setSequence(sequence); + + DirectiveItem item = new DirectiveItem(); + item.setType("2"); + //item.setType("1"); + List directiveItems = new ArrayList<>(); + directiveItems.add(item); + Directive directive = new Directive(); + directive.setDirective_items(directiveItems); + response.setDirective(directive); + + return response; + } + + private DingDongResponse buildErrorResponse(String version, String sequence, String userId) { + DingDongResponse responseError = buildResponse(version, sequence, userId); + responseError.getDirective().getDirective_items().get(0).setType("1"); + responseError.getDirective().getDirective_items().get(0).setContent("请重新说一遍吧"); + return responseError; + } + + private DingDongResponse dealWithNoticeStatus(DingDongRequest request) { + String noticeType = request.getNotice_type(); + switch (noticeType) { + case Constants.USER_INTPUT_NOREC: logger.info("status为NOTICE:用户输入的内容语义结果为拒识情况"); break; + case Constants.USER_NOREC_TIMES_OUT: logger.info("status为NOTICE:用户拒识次数超出最大值,默认最大值为2次");break; + case Constants.DEV_RESP_PACK_TOO_LONG: logger.info("status为NOTICE:开发者服务回包数据过长,长度最大为2Kb");break; + case Constants.DEV_SERVICE_VISIT_TIME_OUT: logger.info("status为NOTICE:开发者服务访问超时,默认超时时间为5秒");break; + case Constants.DEV_SERVICE_RESP_PACK_ERROR: logger.info("status为NOTICE:开发者服务回包数据错误");break; + case Constants.NOTICE_OPEN_PLATFORM_ERROR: logger.info("status为NOTICE:开放平台系统异常");break; + } + DingDongResponse response = buildErrorResponse(request.getVersionid(), request.getSequence(), request.getUser().getUser_id()); + response.getDirective().getDirective_items().get(0).setContent(""); + return response; + } + + private DingDongResponse dealWithEndStatus(DingDongRequest request) { + String endReason = request.getEnded_reason(); + if (endReason != null && !endReason.isEmpty()) { + switch (endReason) { + case Constants.USER_END : logger.info("用户主动结束"); break; + case Constants.SESSION_TIMEOUT: logger.info("会话超时平台结束"); break; + case Constants.SESSION_ALLTIMES_OUT: logger.info("会话总次数超出平台结束"); break; + case Constants.SESSION_CURTIMES_OUT: logger.info("会话当前次数超出平台结束"); break; + case Constants.OPEN_PLATFORM_ERROR: logger.info("开放平台处理异常"); break; + case Constants.SERVICE_INVOKER_TIMEOUT: logger.info("服务调用超时"); break; + case Constants.SERVICE_INVOKER_ERROR: logger.info("服务应答结果异常"); break; + } + } + DingDongResponse response = buildErrorResponse(request.getVersionid(), request.getSequence(), request.getUser().getUser_id()); + response.getDirective().getDirective_items().get(0).setContent("我们的作品库在不断扩充,欢迎下次再来玩"); + logger.info("退出前删除缓存,缓存删除结果:"+(REQUEST_TIMESTAMP_INTERVAL.remove(request.getUser().getUser_id()) != null)); + return response; + } +} diff --git a/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java b/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java new file mode 100644 index 0000000..78683bc --- /dev/null +++ b/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java @@ -0,0 +1,253 @@ +package ai.qiwu.dong.dingdong.service; + +import ai.qiwu.dong.dingdong.common.Constants; +import ai.qiwu.dong.dingdong.common.Constants.Intent; +import ai.qiwu.dong.dingdong.common.Constants.Status; +import ai.qiwu.dong.dingdong.model.request.DingDongRequest; +import ai.qiwu.dong.dingdong.model.request.user.User; +import ai.qiwu.dong.dingdong.model.response.DingDongResponse; +import ai.qiwu.dong.dingdong.model.response.directive.Directive; +import ai.qiwu.dong.dingdong.model.response.directive.DirectiveItem; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.*; + +/** + * @author 苗权威 + * @dateTime 19-6-29 上午9:37 + */ +@Service("compromise") +public class ParseServiceCompromise { + + private final static Logger logger = LoggerFactory.getLogger(ParseServiceCompromise.class); + + public DingDongResponse getResponse(DingDongRequest request) { + String userId = null; + User user = request.getUser(); + if (user != null && user.getUser_id() != null) { + userId = request.getUser().getUser_id(); + }else { + if (request.getApplication_info() != null) { + userId = request.getApplication_info().getApplication_id(); + } + if (userId == null) { + //文档保证session字段一定不为空,将其id当作该种情况下的用户id + // 一次会话从开始到结束,sessionId不变,一次会话指的是从用户进入到我们的技能到其退出为止 + userId = request.getSession().getSession_id(); + } + } + + String status = request.getStatus(); + if (!Status.INTENT.equals(status)) { + if (Status.LAUNCH.equals(status)) { + return dealLaunchIntent(request, userId); + } + else if (Status.NOTICE.equals(request.getStatus())) { + return dealWithNoticeStatus(request, userId); + } + else if (Status.END.equals(request.getStatus())) { + return dealWithEndStatus(request, userId); + } + } + return dealWithIntent(request, userId); + } + + private DingDongResponse requestQiWuInterface(String userId, DingDongRequest request) { + String audioUrl = ""; + String textContent = "请说推荐作品"; + CloseableHttpClient httpClient = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClientBuilder.create().build(); + HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE); + + HashMap params = new HashMap<>(); + params.put("user_id", String.valueOf(userId)); + params.put("text", request.getInput_text()); + params.put("access",Constants.SERVICE_NAME); + + String paramsJsonFormat = JSON.toJSONString(params); + StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8"); + post.setHeader("Content-Type", "application/json;charset=utf-8"); + post.setEntity(body); + + httpResponse = httpClient.execute(post); + HttpEntity responseBody = httpResponse.getEntity(); + if (responseBody != null) { + String responseContent = EntityUtils.toString(responseBody); + logger.info("齐悟接口返回: "+ responseContent); + JSONObject responseJsonFormat = JSONObject.parseObject(responseContent); + audioUrl = (String) responseJsonFormat.get("audio"); + textContent = (String) responseJsonFormat.get("text"); + } + } catch (IOException e) { + logger.error("请求齐悟接口出错:"+e.toString()); + return buildErrorResponse(request, userId); + } finally { + try { + if (httpClient != null) httpClient.close(); + if (httpResponse != null) httpResponse.close(); + } catch (IOException e) { + logger.error("关闭与齐悟接口时出错:"+e.toString()); + } + } + return addUrlAndTextToResponse(audioUrl, textContent, request, userId); + } + + private DingDongResponse dealWithIntent(DingDongRequest request, String userId) { + Map slots = request.getSlots(); + if (slots == null) { + logger.info("slots为空,没有映射到任何意图"); + return buildErrorResponse(request, userId); + } + else if (slots.size() == 2) { + String intentKey = null; + for (String key: slots.keySet() + ) { + if(!key.equals("focus")) { + intentKey = key; + break; + } + } + if (intentKey == null || intentKey.isEmpty()) { + logger.info("意图个数为2,但是出现意料之外的情况,slots map : "+slots); + return buildErrorResponse(request, userId); + } + + switch (intentKey) { + case Intent.END_BY_END : return parseWordInItsIntent(request, false, true, userId); + case Intent.XIAO_WU : return parseWordInItsIntent(request, true, true, userId); + case Intent.START_BY_ANSWER : return parseWordInItsIntent(request, true, true, userId); + case Intent.RECOMMEND : return parseWordInItsIntent(request, false, false, userId); + default: { + logger.info("没有匹配到任何已有意图,本次请求的意图名:"+intentKey); + return buildErrorResponse(request, userId); + } + } + } + // {focus:story} + else if (slots.size() <= 1) { + logger.info("slots不为null,但是没有映射到任何意图"); + return buildErrorResponse(request, userId); + } else { + logger.info("Intent请求slots大小>=3,预料之外"); + return buildErrorResponse(request, userId); + } + } + + private DingDongResponse parseWordInItsIntent(DingDongRequest request, boolean font, boolean needToCut, String userId) { + String word = request.getInput_text(); + DingDongResponse response; + if (needToCut) { + if (font) { + try { + logger.info("成功匹配到意图:"+word.substring(0,2)); + } catch (Exception e) { + logger.info("日志本想打印出前置意图下用户所说的前两个字:小悟/回答,但是用户的话少于两个,这是不正常"); + } + if (word.length() > 2) { + word = word.substring(2); + } + }else { + try { + logger.info("成功匹配到意图:"+word.substring(word.length()-2)); + } catch (Exception e) { + logger.info("日志本想打印出后置意图下用户所说的最后两个字:完毕,但是用户的话少于两个,这是不正常的"); + } + if (word.length() > 2) { + word = word.substring(0, word.length()-2); + } + } + } + logger.info("此次解析得到的用户的话是:"+word); + response = requestQiWuInterface(userId, request); + return response; + } + + private DingDongResponse addUrlAndTextToResponse(String audioUrl, String text, DingDongRequest request, String userId) { + DingDongResponse response = buildResponse(request, userId); + response.getDirective().getDirective_items().get(0).setContent(audioUrl); + //response.getDirective().getDirective_items().get(0).setContent(text); + return response; + } + + private DingDongResponse buildResponse(DingDongRequest request, String userId) { + DingDongResponse response = new DingDongResponse(); + response.setVersionid(request.getVersionid()); + response.setIs_end(false); + response.setTimestamp(System.currentTimeMillis()); + response.setSequence(request.getSequence()); + + DirectiveItem item = new DirectiveItem(); + item.setType("2"); + //item.setType("1"); + List directiveItems = new ArrayList<>(); + directiveItems.add(item); + Directive directive = new Directive(); + directive.setDirective_items(directiveItems); + response.setDirective(directive); + + return response; + } + + private DingDongResponse buildErrorResponse(DingDongRequest request, String userId) { + DingDongResponse responseError = buildResponse(request, userId); + responseError.getDirective().getDirective_items().get(0).setType("1"); + responseError.getDirective().getDirective_items().get(0).setContent("请重新说一遍吧"); + return responseError; + } + + private DingDongResponse dealLaunchIntent(DingDongRequest request, String userId) { + Map slots = request.getSlots(); + if (slots.containsKey(Intent.RECOMMEND)) { + request.setInput_text("推荐作品"); + return requestQiWuInterface(userId, request); + } + DingDongResponse launchResponse = buildErrorResponse(request, userId); + launchResponse.getDirective().getDirective_items().get(0).setContent("欢迎,这里有海量的作品,希望您玩的开心"); + return launchResponse; + } + + private DingDongResponse dealWithNoticeStatus(DingDongRequest request, String userId) { + String noticeType = request.getNotice_type(); + switch (noticeType) { + case Constants.USER_INTPUT_NOREC: logger.info("status为NOTICE:用户输入的内容语义结果为拒识情况"); break; + case Constants.USER_NOREC_TIMES_OUT: logger.info("status为NOTICE:用户拒识次数超出最大值,默认最大值为2次");break; + case Constants.DEV_RESP_PACK_TOO_LONG: logger.info("status为NOTICE:开发者服务回包数据过长,长度最大为2Kb");break; + case Constants.DEV_SERVICE_VISIT_TIME_OUT: logger.info("status为NOTICE:开发者服务访问超时,默认超时时间为5秒");break; + case Constants.DEV_SERVICE_RESP_PACK_ERROR: logger.info("status为NOTICE:开发者服务回包数据错误");break; + case Constants.NOTICE_OPEN_PLATFORM_ERROR: logger.info("status为NOTICE:开放平台系统异常");break; + } + return buildErrorResponse(request, userId); + } + + private DingDongResponse dealWithEndStatus(DingDongRequest request, String userId) { + String endReason = request.getEnded_reason(); + if (endReason != null && !endReason.isEmpty()) { + switch (endReason) { + case Constants.USER_END : logger.info("用户主动结束"); break; + case Constants.SESSION_TIMEOUT: logger.info("会话超时平台结束"); break; + case Constants.SESSION_ALLTIMES_OUT: logger.info("会话总次数超出平台结束"); break; + case Constants.SESSION_CURTIMES_OUT: logger.info("会话当前次数超出平台结束"); break; + case Constants.OPEN_PLATFORM_ERROR: logger.info("开放平台处理异常"); break; + case Constants.SERVICE_INVOKER_TIMEOUT: logger.info("服务调用超时"); break; + case Constants.SERVICE_INVOKER_ERROR: logger.info("服务应答结果异常"); break; + } + } + DingDongResponse response = buildErrorResponse(request, userId); + response.getDirective().getDirective_items().get(0).setContent("我们的作品库在不断扩充,欢迎下次再来玩"); + return response; + } +} diff --git a/dingdong/src/main/resources/application.properties b/dingdong/src/main/resources/application.properties new file mode 100644 index 0000000..14933cd --- /dev/null +++ b/dingdong/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8383 diff --git a/dingdong/src/test/java/ai/qiwu/dong/dingdong/DingdongApplicationTests.java b/dingdong/src/test/java/ai/qiwu/dong/dingdong/DingdongApplicationTests.java new file mode 100644 index 0000000..44d6ce0 --- /dev/null +++ b/dingdong/src/test/java/ai/qiwu/dong/dingdong/DingdongApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.dong.dingdong; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class DingdongApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1b62323 --- /dev/null +++ b/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + ai.qiwu + smartbox + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/ruoqi/.gitignore b/ruoqi/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/ruoqi/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/ruoqi/.mvn/wrapper/MavenWrapperDownloader.java b/ruoqi/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/ruoqi/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/ruoqi/.mvn/wrapper/maven-wrapper.jar b/ruoqi/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/ruoqi/.mvn/wrapper/maven-wrapper.jar differ diff --git a/ruoqi/.mvn/wrapper/maven-wrapper.properties b/ruoqi/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/ruoqi/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/ruoqi/mvnw b/ruoqi/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/ruoqi/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/ruoqi/mvnw.cmd b/ruoqi/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/ruoqi/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/ruoqi/pom.xml b/ruoqi/pom.xml new file mode 100644 index 0000000..97bacb8 --- /dev/null +++ b/ruoqi/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.rokid + ruoqi + 0.0.1-SNAPSHOT + ruoqi + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/ruoqi/src/main/java/ai/qiwu/rokid/ruoqi/RuoqiApplication.java b/ruoqi/src/main/java/ai/qiwu/rokid/ruoqi/RuoqiApplication.java new file mode 100644 index 0000000..701efe3 --- /dev/null +++ b/ruoqi/src/main/java/ai/qiwu/rokid/ruoqi/RuoqiApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.rokid.ruoqi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RuoqiApplication { + + public static void main(String[] args) { + SpringApplication.run(RuoqiApplication.class, args); + } + +} diff --git a/ruoqi/src/main/resources/application.properties b/ruoqi/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ruoqi/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/ruoqi/src/test/java/ai/qiwu/rokid/ruoqi/RuoqiApplicationTests.java b/ruoqi/src/test/java/ai/qiwu/rokid/ruoqi/RuoqiApplicationTests.java new file mode 100644 index 0000000..8ce26d7 --- /dev/null +++ b/ruoqi/src/test/java/ai/qiwu/rokid/ruoqi/RuoqiApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.rokid.ruoqi; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class RuoqiApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/smartbox.iml b/smartbox.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/smartbox.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/spirit/.gitignore b/spirit/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/spirit/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/spirit/.mvn/wrapper/MavenWrapperDownloader.java b/spirit/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/spirit/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/spirit/.mvn/wrapper/maven-wrapper.jar b/spirit/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/spirit/.mvn/wrapper/maven-wrapper.jar differ diff --git a/spirit/.mvn/wrapper/maven-wrapper.properties b/spirit/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/spirit/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/spirit/mvnw b/spirit/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/spirit/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/spirit/mvnw.cmd b/spirit/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/spirit/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/spirit/pom.xml b/spirit/pom.xml new file mode 100644 index 0000000..aa29ff8 --- /dev/null +++ b/spirit/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.tmall + spirit + 0.0.1-SNAPSHOT + spirit + Tmall spirit project + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java b/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java new file mode 100644 index 0000000..c3ad2bd --- /dev/null +++ b/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.tmall.spirit; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpiritApplication { + + public static void main(String[] args) { + SpringApplication.run(SpiritApplication.class, args); + } + +} diff --git a/spirit/src/main/resources/application.properties b/spirit/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/spirit/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/spirit/src/test/java/ai/qiwu/tmall/spirit/SpiritApplicationTests.java b/spirit/src/test/java/ai/qiwu/tmall/spirit/SpiritApplicationTests.java new file mode 100644 index 0000000..cfb5b55 --- /dev/null +++ b/spirit/src/test/java/ai/qiwu/tmall/spirit/SpiritApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.tmall.spirit; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpiritApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/xiaoai/.gitignore b/xiaoai/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/xiaoai/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/xiaoai/.mvn/wrapper/MavenWrapperDownloader.java b/xiaoai/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/xiaoai/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/xiaoai/.mvn/wrapper/maven-wrapper.jar b/xiaoai/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/xiaoai/.mvn/wrapper/maven-wrapper.jar differ diff --git a/xiaoai/.mvn/wrapper/maven-wrapper.properties b/xiaoai/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/xiaoai/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/xiaoai/mvnw b/xiaoai/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/xiaoai/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/xiaoai/mvnw.cmd b/xiaoai/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/xiaoai/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/xiaoai/pom.xml b/xiaoai/pom.xml new file mode 100644 index 0000000..1e2771c --- /dev/null +++ b/xiaoai/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.mi + xiaoai + 0.0.1-SNAPSHOT + xiaoai + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java new file mode 100644 index 0000000..9a4f025 --- /dev/null +++ b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.mi.xiaoai; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class XiaoaiApplication { + + public static void main(String[] args) { + SpringApplication.run(XiaoaiApplication.class, args); + } + +} diff --git a/xiaoai/src/main/resources/application.properties b/xiaoai/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/xiaoai/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/xiaoai/src/test/java/ai/qiwu/mi/xiaoai/XiaoaiApplicationTests.java b/xiaoai/src/test/java/ai/qiwu/mi/xiaoai/XiaoaiApplicationTests.java new file mode 100644 index 0000000..de95b76 --- /dev/null +++ b/xiaoai/src/test/java/ai/qiwu/mi/xiaoai/XiaoaiApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.mi.xiaoai; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class XiaoaiApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/xiaodu/.gitignore b/xiaodu/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/xiaodu/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/xiaodu/.mvn/wrapper/MavenWrapperDownloader.java b/xiaodu/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/xiaodu/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/xiaodu/.mvn/wrapper/maven-wrapper.jar b/xiaodu/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/xiaodu/.mvn/wrapper/maven-wrapper.jar differ diff --git a/xiaodu/.mvn/wrapper/maven-wrapper.properties b/xiaodu/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/xiaodu/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/xiaodu/mvnw b/xiaodu/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/xiaodu/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/xiaodu/mvnw.cmd b/xiaodu/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/xiaodu/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/xiaodu/pom.xml b/xiaodu/pom.xml new file mode 100644 index 0000000..f9ca0de --- /dev/null +++ b/xiaodu/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.baidu + xiaodu + 0.0.1-SNAPSHOT + xiaodu + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.baidu.dueros + bot-sdk + 1.1.9 + + + com.alibaba + fastjson + 1.2.58 + compile + + + + org.projectlombok + lombok + 1.18.8 + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java new file mode 100644 index 0000000..ee87320 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.baidu.xiaodu; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class XiaoduApplication { + + public static void main(String[] args) { + SpringApplication.run(XiaoduApplication.class, args); + } + +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java new file mode 100644 index 0000000..a365570 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java @@ -0,0 +1,32 @@ +package ai.qiwu.baidu.xiaodu.common; + +/** + * @author 苗权威 + * @dateTime 19-6-29 下午3:06 + */ +public interface Constants { + + String QI_WU_INTERFACE = "http://aliyun-hz1.chewrobot.com:8070/api/chat"; + String SERVICE_NAME = "BAIDU"; + + interface WelcomeWord { + String WELCOME = "在这里你就是主角,开始你的星辰大海吧"; + String BEGIN_NO_RESPONSE = "咋还没开始就停住了,我们这里可有很多好玩的作品哦"; + } + + interface EndMsg { + String BYE_BYE = "我们的作品库在不断的扩充,下次会有更大的惊喜哦"; + String CAN_NOT_UNDERSTAND = "用户无输入或多次输入无法理解"; + String USER_SAY_CANCEL = "用户直接说退出"; + } + + interface ErrorMsg { + String SORRY_UNCATCH = "我好意思我没听清,请再说一遍吧"; + String INTERNAL_ERROR = "其他DuerOS系统错误"; + String INVALID_RESPONSE = "技能返回了无效的响应,可能技能响应数据量超过24KB,或是技能在request的dialogState为COMPLETED时仍然发送Dialog.Delegate指令等"; + String DEVICE_COMMUNICATION_ERROR = "DuerOS与端通信异常"; + + String INTERFACE_ERROR = "终端接口请求出错"; + String HTTP_CONNECTION_CLOSE_FAILED = "与终端的链接关闭错误"; + } +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java new file mode 100644 index 0000000..6296216 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java @@ -0,0 +1,34 @@ +package ai.qiwu.baidu.xiaodu.common; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; + +/** + * @author 苗权威 + * @dateTime 19-6-29 下午5:11 + */ +public class Utils { + + public static HttpServletRequest getHttpServletRequest() { + return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder + .getRequestAttributes())).getRequest(); + } + + public static String useIPAsItsID() { + HttpServletRequest request = getHttpServletRequest(); + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java new file mode 100644 index 0000000..a32eba1 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java @@ -0,0 +1,34 @@ +package ai.qiwu.baidu.xiaodu.controller; + +import ai.qiwu.baidu.xiaodu.common.Utils; +import ai.qiwu.baidu.xiaodu.service.ResponseEncapsulation; +import com.baidu.dueros.bot.BaseBot; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; + +/** + * @author 苗权威 + * @dateTime 19-6-29 下午5:32 + */ +@RestController +public class XiaoDuController { + + private static final Logger logger = LoggerFactory.getLogger(XiaoDuController.class); + + @RequestMapping("/xiaodu") + public String chat() { + try { + ResponseEncapsulation response = new ResponseEncapsulation(Utils.getHttpServletRequest()); + response.enableVerify(); + return response.run(); + } catch (Exception e) { + logger.info("出现错误 "+e.toString()); + } + return null; + } +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java new file mode 100644 index 0000000..3a3ed38 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java @@ -0,0 +1,15 @@ +package ai.qiwu.baidu.xiaodu.pojo; + +import lombok.Getter; +import lombok.Setter; + +/** + * @author 苗权威 + * @dateTime 19-6-29 下午4:32 + */ +@Getter +@Setter +public class AudioUrlAndText { + private String audioUrl; + private String text; +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java new file mode 100644 index 0000000..58d831e --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java @@ -0,0 +1,72 @@ +package ai.qiwu.baidu.xiaodu.service; + +import ai.qiwu.baidu.xiaodu.common.Constants; +import ai.qiwu.baidu.xiaodu.pojo.AudioUrlAndText; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; + +/** + * @author 苗权威 + * @dateTime 19-6-29 下午3:49 + */ +class RequestTerminal { + + private static final Logger logger = LoggerFactory.getLogger(RequestTerminal.class); + + static AudioUrlAndText requestTerminate(String word, String userId) { + AudioUrlAndText store = new AudioUrlAndText(); + String audioUrl = ""; + String textContent = "请说推荐作品"; + CloseableHttpClient httpClient = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClientBuilder.create().build(); + HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE); + + HashMap params = new HashMap<>(); + params.put("user_id", String.valueOf(userId)); + params.put("text", word); + params.put("access",Constants.SERVICE_NAME); + + String paramsJsonFormat = JSON.toJSONString(params); + StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8"); + post.setHeader("Content-Type", "application/json;charset=utf-8"); + post.setEntity(body); + + httpResponse = httpClient.execute(post); + HttpEntity responseBody = httpResponse.getEntity(); + if (responseBody != null) { + String responseContent = EntityUtils.toString(responseBody); + logger.info("齐悟接口返回: "+ responseContent); + JSONObject responseJsonFormat = JSONObject.parseObject(responseContent); + audioUrl = (String) responseJsonFormat.get("audio"); + textContent = (String) responseJsonFormat.get("text"); + } + } catch (IOException e) { + logger.error("请求齐悟接口出错:"+e.toString()); + return null; + } finally { + try { + if (httpClient != null) httpClient.close(); + if (httpResponse != null) httpResponse.close(); + } catch (IOException e) { + logger.error("关闭与齐悟接口时出错:"+e.toString()); + } + } + store.setAudioUrl(audioUrl); + store.setText(textContent); + return store; + } +} diff --git a/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java new file mode 100644 index 0000000..b289421 --- /dev/null +++ b/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java @@ -0,0 +1,104 @@ +package ai.qiwu.baidu.xiaodu.service; + +import ai.qiwu.baidu.xiaodu.common.Constants.ErrorMsg; +import ai.qiwu.baidu.xiaodu.common.Constants.EndMsg; +import ai.qiwu.baidu.xiaodu.common.Constants.WelcomeWord; +import ai.qiwu.baidu.xiaodu.common.Utils; +import ai.qiwu.baidu.xiaodu.pojo.AudioUrlAndText; +import com.baidu.dueros.bot.AudioPlayer; +import com.baidu.dueros.data.request.IntentRequest; +import com.baidu.dueros.data.request.LaunchRequest; +import com.baidu.dueros.data.request.Query; +import com.baidu.dueros.data.request.SessionEndedRequest; +import com.baidu.dueros.data.response.OutputSpeech; +import com.baidu.dueros.data.response.Reprompt; +import com.baidu.dueros.data.response.directive.audioplayer.AudioPlayerDirective; +import com.baidu.dueros.data.response.directive.audioplayer.Play; +import com.baidu.dueros.model.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * @author 苗权威 + * @dateTime 19-6-28 下午8:22 + */ +@Service("service") +public class ResponseEncapsulation extends AudioPlayer { + + private static final Logger logger = LoggerFactory.getLogger(ResponseEncapsulation.class); + + private String userId; + + public ResponseEncapsulation(HttpServletRequest request) throws IOException { + super(request); + } + + @Override + public Response onInent(IntentRequest intentRequest) { + Query query = intentRequest.getQuery(); + String userWord = null; + if (query != null) { + userWord = query.getOriginal(); + } + if (userWord == null){ + logger.info("小度没有传来任何话语"); + return buildErrorResponse(ErrorMsg.SORRY_UNCATCH); + } + if (userId == null) { + userId = Utils.useIPAsItsID(); + } + AudioUrlAndText data = RequestTerminal.requestTerminate(userWord, userId); + if (data == null) { + return buildErrorResponse(ErrorMsg.SORRY_UNCATCH); + } + addDirective(buildPlayDirectice(data.getAudioUrl())); + // shouldEndSession字段和expectSpeech字段同时为false,技能还在会话中, + // 但是不需要用户进行回复,设备端会关闭麦克风,此时可以返回AudioPlayer.Play指令, + // 目的是为了防止设备读取自己正在播放的内容 + endDialog(); + setExpectSpeech(false); + return new Response(); + } + + @Override + public Response onLaunch(LaunchRequest launchRequest) { + userId = getDeviceId(); + OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, WelcomeWord.WELCOME); + Reprompt reprompt = new Reprompt(new OutputSpeech(OutputSpeech.SpeechType.PlainText, WelcomeWord.BEGIN_NO_RESPONSE)); + return new Response(outputSpeech, null, reprompt); + } + + @Override + public Response onSessionEnded(SessionEndedRequest sessionEndedRequest) { + switch (sessionEndedRequest.getReason()) { + case ERROR: dealWithError(sessionEndedRequest); break; + case USER_INITIATED: logger.info(EndMsg.USER_SAY_CANCEL); break; + case EXCEEDED_MAX_REPROMPTS: logger.info(EndMsg.CAN_NOT_UNDERSTAND);break; + } + // 向终端发送“退出” + OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, EndMsg.BYE_BYE); + return new Response(outputSpeech); + } + + private void dealWithError(SessionEndedRequest request) { + switch (request.getError().getType()) { + case INTERNAL_ERROR: logger.info(ErrorMsg.INTERNAL_ERROR); break; + case INVALID_RESPONSE: logger.info(ErrorMsg.INVALID_RESPONSE); break; + case DEVICE_COMMUNICATION_ERROR: logger.info(ErrorMsg.DEVICE_COMMUNICATION_ERROR); break; + } + logger.info("错误信息 : "+ request.getError().getMessage()); + } + + private Response buildErrorResponse(String errorMsg) { + OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, errorMsg); + return new Response(outputSpeech); + } + + private Play buildPlayDirectice(String audioUrl) { + return new Play(AudioPlayerDirective.PlayBehaviorType.REPLACE_ALL, audioUrl, 0); + } +} diff --git a/xiaodu/src/main/resources/application.properties b/xiaodu/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/xiaodu/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/xiaodu/src/test/java/ai/qiwu/baidu/xiaodu/XiaoduApplicationTests.java b/xiaodu/src/test/java/ai/qiwu/baidu/xiaodu/XiaoduApplicationTests.java new file mode 100644 index 0000000..35164b5 --- /dev/null +++ b/xiaodu/src/test/java/ai/qiwu/baidu/xiaodu/XiaoduApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.baidu.xiaodu; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class XiaoduApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/xiaoya/.gitignore b/xiaoya/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/xiaoya/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/xiaoya/.mvn/wrapper/MavenWrapperDownloader.java b/xiaoya/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..7f91a56 --- /dev/null +++ b/xiaoya/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/xiaoya/.mvn/wrapper/maven-wrapper.jar b/xiaoya/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..01e6799 Binary files /dev/null and b/xiaoya/.mvn/wrapper/maven-wrapper.jar differ diff --git a/xiaoya/.mvn/wrapper/maven-wrapper.properties b/xiaoya/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..cd0d451 --- /dev/null +++ b/xiaoya/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/xiaoya/mvnw b/xiaoya/mvnw new file mode 100755 index 0000000..8b9da3b --- /dev/null +++ b/xiaoya/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/xiaoya/mvnw.cmd b/xiaoya/mvnw.cmd new file mode 100644 index 0000000..fef5a8f --- /dev/null +++ b/xiaoya/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/xiaoya/pom.xml b/xiaoya/pom.xml new file mode 100644 index 0000000..f39fccc --- /dev/null +++ b/xiaoya/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + ai.qiwu.xiaoya + xiaoya + 0.0.1-SNAPSHOT + xiaoya + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java b/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java new file mode 100644 index 0000000..189499f --- /dev/null +++ b/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java @@ -0,0 +1,13 @@ +package ai.qiwu.xiaoya.xiaoya; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class XiaoyaApplication { + + public static void main(String[] args) { + SpringApplication.run(XiaoyaApplication.class, args); + } + +} diff --git a/xiaoya/src/main/resources/application.properties b/xiaoya/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/xiaoya/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/xiaoya/src/test/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplicationTests.java b/xiaoya/src/test/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplicationTests.java new file mode 100644 index 0000000..5aa28d8 --- /dev/null +++ b/xiaoya/src/test/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplicationTests.java @@ -0,0 +1,16 @@ +package ai.qiwu.xiaoya.xiaoya; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class XiaoyaApplicationTests { + + @Test + public void contextLoads() { + } + +} -- libgit2 0.27.1