Commit 394ba74f authored by zhangxuehan's avatar zhangxuehan

Initial commit

parent a247ee62
Pipeline #286 canceled with stages
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* 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/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".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 directory '" + 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 {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
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();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
#!/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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven 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
))"
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
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
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 $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget >/dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl >/dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=$(cygpath --path --windows "$javaClass")
fi
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
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
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 "$@"
@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 Maven 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 keystroke 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 by 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.5.6/maven-wrapper-0.5.6.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% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%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%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.thirdgateway</groupId>
<artifactId>thirdgateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>thirdgateway</name>
<description>对接第三方-天思</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- logs -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.1</version>
</dependency>
<!-- aliyun -->
<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>ons-client</artifactId>
<version>1.7.9.Final</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<!-- Guava Retryer -->
<dependency>
<groupId>com.github.rholder</groupId>
<artifactId>guava-retrying</artifactId>
<version>2.0.0</version>
</dependency>
<!-- xxl-job -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<!--配置文件的位置-->
<configurationFile>src/main/resources/mybatis/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<phase>deploy</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
package com.thirdgateway.tiansi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication//排除自动配置
public class ThirdgatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ThirdgatewayApplication.class, args);
}
}
package com.thirdgateway.tiansi.common;
/**
* @program: asgard
* @description:
* @author: zq
* @create: 2020-05-09 16:14
**/
public enum BizCodeEnum {
//系统错误
SYSTEM_ERROR("3010000", "SYSTEM_ERROR", "系统异常,请稍后再试"),
CLIENT_CREDIT_NO_FOUND("3010001", "CLIENT_CREDIT_NO_FOUND", "未查到授信记录"),
CLIENT_NO_FOUND("3010002", "CLIENT_NO_FOUND", "未查到用户实名记录"),
CREDIT_AMT_NOT_ENOUGH("3010003", "CREDIT_AMT_NOT_ENOUGH", "授信额度不足"),
HAVE_LOAN_NOW("3010004", "HAVE_LOAN_NOW", "存在未结清的单子,不允许提现!"),
CLIENT_ORDER_NO_FOUND("3010005", "CLIENT_ORDER_NO_FOUND", "客户授信记录不存在"),
LOAN_NOT_FOUND("3010006", "LOAN_NOT_FOUND", "借款不存在或已经结清"),
DEBTCORE_LOAN_RECORD("3010007", "DEBTCORE_LOAN_RECORD", "未查到数据"),
LOAN_FAIL("3010008", "LOAN_FAIL", "借款失败"),
CARD_NOT_FOUNT("3010009", "CARD_NOT_FOUNT", "未查到绑卡信息"),
THIRD_BACKED_EXIST("3010010", "THIRD_BACKED_EXIST", "第三方扣款单存在"),
LOAN_STATUS_ERROR("3010011", "LOAN_STATUS_ERROR", "借款单状态错误"),
LOAN_PLAN_STATUS_ERROR("3010012", "LOAN_PLAN_STATUS_ERROR", "还款计划状态错误"),
BANK_CARD_NOT_SUPPORT("3010013", "BANK_CARD_NOT_SUPPORT", "银行卡不支持"),
SETTLE_ERROR("3010014", "SETTLE_ERROR", "获取结清数据失败,请联系客服人员"),
NOT_ALLOW_SETTLE_ERROR("3010015", "NOT_ALLOW_SETTLE_ERROR", "无法结清,请联系客服人员"),
//外部调用错误码 306* 命名以REMOTE开头
REMOTE_ERROR("3060001", "REMOTE_ERROR", "远程调用失败"),
REMOTE_SYSTEM_ERROR("3060002", "REMOTE_SYSTEM_ERROR", "系统异常,请稍后再试"),
//数据异常
;
/**
* 枚举编号
*/
private String code;
/**
* 枚举信息
*/
private String message;
/**
* 枚举详情 中文信息
*/
private String messageCN;
private BizCodeEnum(String code, String message, String messageCN) {
this.code = code;
this.message = message;
this.messageCN = messageCN;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessageCN() {
return messageCN;
}
public void setMessageCN(String messageCN) {
this.messageCN = messageCN;
}
}
package com.thirdgateway.tiansi.common;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.util.Enumeration;
public class GrabMachineIpUtil {
public static InetAddress getLocalHostLANAddress() throws UnknownHostException {
try {
InetAddress candidateAddress = null;
// 遍历所有的网络接口
for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces.hasMoreElements();) {
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
// 在所有的接口下再遍历IP
for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
InetAddress inetAddr = (InetAddress) inetAddrs.nextElement();
if (!inetAddr.isLoopbackAddress()) {// 排除loopback类型地址
if (inetAddr.isSiteLocalAddress()) {
// 如果是site-local地址,就是它了
return inetAddr;
} else if (candidateAddress == null) {
// site-local类型的地址未被发现,先记录候选地址
candidateAddress = inetAddr;
}
}
}
}
if (candidateAddress != null) {
return candidateAddress;
}
// 如果没有发现 non-loopback地址.只能用最次选的方案
InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
if (jdkSuppliedAddress == null) {
throw new UnknownHostException("The JDK InetAddress.getLocalHost() method unexpectedly returned null.");
}
return jdkSuppliedAddress;
} catch (Exception e) {
UnknownHostException unknownHostException = new UnknownHostException(
"Failed to determine LAN address: " + e);
unknownHostException.initCause(e);
throw unknownHostException;
}
}
}
/**
* kevinGD.com Inc.
* Copyright (c) 2015-2016-2016 All Rights Reserved.
*/
package com.thirdgateway.tiansi.common;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 为对外发http请求连接可复用作处理
* 采用PoolingHttpClientConnectionManager来管理client对象
*
* 详情参见{@link http://www.yeetrack.com/?p=782}
*
* @author jiadong.yejd
* @version $Id: HttpClientPools.java, v 0.1 2016年10月27日 下午5:17:31 jiadong.yejd Exp $
*/
public class HttpClientPools {
/**logger*/
private static final Logger logger = LoggerFactory
.getLogger(HttpClientPools.class);
private static PoolingHttpClientConnectionManager cm = null;
/**
* ConnectTimeout服务器请求超时
* ConnectionRequestTimeout 建立请求超时
* SocketTimeout 服务器响应超时
*
*/
protected static RequestConfig requestConfig = RequestConfig
.custom()
.setConnectTimeout(7000)
.setConnectionRequestTimeout(
7000)
.setSocketTimeout(10000)
.build();
static {
ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>
create().
register("http", plainsf).
register("https", sslsf).
build();
cm = new PoolingHttpClientConnectionManager(registry);
// 将最大连接数增加到200
cm.setMaxTotal(200);
// 将每个路由基础的连接增加到200
cm.setDefaultMaxPerRoute(200);
//连接池管理
IdleConnMonitorTask idleConnMonitorTask = new IdleConnMonitorTask();
Timer timer = new Timer(true);
//1分钟执行一次
timer.schedule(idleConnMonitorTask, 30 * 1000, 60 * 1000);
}
/**
* 它管理着连接池,可以同时为很多线程提供http连接请求
* 如果连接池有有可用的持久连接,连接管理器就会使用其中的一个,而不是再创建一个新的连接。
* PoolingClientConnectionManager会根据它的配置来分配请求连接,如果连接池中的所有连接都被占用了,那么后续的请求就会被阻塞,直到有连接被释放回连接池中
* @return
*/
public static CloseableHttpClient getHttpClient() {
//请求重试处理
HttpRequestRetryHandler httpRequestRetryHandler = new RetryHandler();
CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm)
.setRetryHandler(httpRequestRetryHandler).build();
return httpClient;
}
/**
* 构建Get请求方法
*
* @param url 请求地址
* @param paramMap 参数
* @param charSet 编码
* @return
* @throws Exception
*/
public static HttpGet buildGet(String url, Map<String, String> paramMap, String charSet)
throws Exception {
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
List<NameValuePair> params = new ArrayList<NameValuePair>();
Set<String> keySet = paramMap.keySet();
for (Iterator<String> it = keySet.iterator(); it.hasNext();) {
String next = it.next();
params.add(new BasicNameValuePair(next, paramMap.get(next)));
}
String str = EntityUtils.toString(new UrlEncodedFormEntity(params, charSet));
httpGet.setURI(new URI(url + "?" + str));
return httpGet;
}
/**
* 构建Post请求方法
*
* @param url 请求地址
* @param paramMap 参数
* @param charSet 编码
* @return
* @throws UnsupportedEncodingException
*/
public static HttpPost buildPost(String url, Map<String, String> paramMap, String charSet,String partnerCode)
throws UnsupportedEncodingException {
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
httpPost.addHeader("Content-Type", "application/json;");
httpPost.addHeader("charset=", charSet);
List<NameValuePair> valuePairs = new ArrayList<NameValuePair>();
for (String key : paramMap.keySet()) {
valuePairs.add(new BasicNameValuePair(key, (String) paramMap.get(key)));
}
httpPost.setEntity(new UrlEncodedFormEntity(valuePairs, charSet));
return httpPost;
}
/**
* 对失败的处理
*
* @author jiadong.yejd
* @version $Id: HttpClientPools.java, v 0.1 2016年10月27日 下午5:53:25 jiadong.yejd Exp $
*/
static class RetryHandler implements HttpRequestRetryHandler {
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
if (executionCount >= 3) {// 如果已经重试了3次,就放弃
return false;
}
if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
return false;
}
if (exception instanceof InterruptedIOException) {// 超时
return false;
}
if (exception instanceof UnknownHostException) {// 目标服务器不可达
return false;
}
if (exception instanceof ConnectTimeoutException) {// 连接被拒绝
return false;
}
if (exception instanceof SSLException) {// ssl握手异常
return false;
}
HttpClientContext clientContext = HttpClientContext.adapt(context);
HttpRequest request = clientContext.getRequest();
// 如果请求是幂等的,就再次尝试
if (!(request instanceof HttpEntityEnclosingRequest)) {
return true;
}
return false;
}
}
/**
*
* @author liudehong
* @version $Id: HttpClientPools.java, v 0.1 2017年7月31日 下午4:48:48 liudehong Exp $
*/
private static class IdleConnMonitorTask extends TimerTask {
public IdleConnMonitorTask() {
System.err.println("IdleConnMonitorTask...");
}
@Override
public void run() {
try {
// 关闭过期的连接
//cm.closeExpiredConnections();
//关闭3分钟内不活动的连接
cm.closeIdleConnections(3, TimeUnit.MINUTES);
logger.warn("http pool连接池回收成功,连接池的当前状态:" + cm.getTotalStats());
} catch (Throwable ex) {
logger.error("http连接池管理异常", ex);
}
}
}
}
package com.thirdgateway.tiansi.common;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.*;
/**
* http工具类
*
* @author shaohai.zhao
* @version : HttpUtil.java, v 0.1 2018-08-08 19:30 shaohai.zhao Exp $
*/
public class HttpUtil extends HttpClientPools {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
/**
* 发送 POST 请求(HTTP),不带输入数据
*
* @param apiUrl
* @return
*/
public static String doPost(String apiUrl) {
return doPost(apiUrl, new HashMap<String, Object>());
}
/**
* 发送 POST 请求(HTTP),K-V形式
*
* @param apiUrl API接口URL
* @param params 参数map
* @return
*/
public static String doPost(String apiUrl, Map<String, String> params) {
CloseableHttpClient httpClient = HttpClients.createDefault();
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<NameValuePair>(params.size());
for (Map.Entry<String, String> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue());
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求(HTTP),JSON形式
*
* @param apiUrl
* @param json json对象
* @return
*/
public static String doPost(String apiUrl, Object json) {
CloseableHttpClient httpClient = HttpClients.createDefault();
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json.toString(), "UTF-8");//解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
public static String doGet(String url) {
String httpStr = null;
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
httpGet.addHeader("Content-Type", "UTF-8");
CloseableHttpResponse response = null;
httpGet.setURI(new URI(url));
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
if (response != null) {
EntityUtils.consume(response.getEntity());
}
} catch (Exception e) {
logger.error("HttpUtil:doGet报错:{}",e.getMessage(),e);
}
return httpStr;
}
public static String doGet(String url, Map<String, String> paramMap) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
String httpStr = null;
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
httpGet.addHeader("Content-Type", "UTF-8");
CloseableHttpResponse response = null;
List<NameValuePair> params = new ArrayList<NameValuePair>();
Set<String> keySet = paramMap.keySet();
for (Iterator<String> it = keySet.iterator(); it.hasNext(); ) {
String next = it.next();
params.add(new BasicNameValuePair(next, paramMap.get(next)));
}
String str = EntityUtils.toString(new UrlEncodedFormEntity(params, "UTF-8"));
httpGet.setURI(new URI(url + "?" + str));
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
return httpStr;
}
/**
* 发送 SSL POST 请求(HTTPS),K-V形式
*
* @param apiUrl API接口URL
* @param params 参数map
* @return
*/
public static String doPostSSL(String apiUrl, Map<String, String> params) {
CloseableHttpClient httpClient = getHttpClient();
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
String httpStr = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<NameValuePair>(params.size());
for (Map.Entry<String, String> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue());
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("utf-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "utf-8");
} catch (Exception e) {
logger.error("请求通联服务异常", e);
} finally {
HttpClientUtils.closeQuietly(response);
}
return httpStr;
}
/**
* 路由提交方法
*
* @return
*/
public static String doPostAll(String apiUrl, Map<String, String> params) {
if (apiUrl == null) {
return null;
}
if (apiUrl.indexOf("https:") != -1) {
return doPostSSL(apiUrl, params);
}
return doPost(apiUrl, params);
}
/**
* 银杏认证POST\application/json
*
* @param url
* @param json
* @param partnerCode
* @return
*/
public static JSONObject doPostYX(String url, JSONObject json, String partnerCode) {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
JSONObject response = null;
try {
StringEntity stringEntity = new StringEntity(json.toString(), "UTF-8");
stringEntity.setContentType("application/json");//发送json数据需要设置contentType
httpPost.setEntity(stringEntity);
httpPost.setHeader("partner_code", partnerCode);
httpPost.setConfig(requestConfig);
HttpResponse res = httpClient.execute(httpPost);
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = EntityUtils.toString(res.getEntity());// 返回json格式:
response = JSONObject.parseObject(result);
}
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
/**
* 银杏认证GET
*
* @param url
* @param paramMap
* @param encode
* @return
* @throws Exception
*/
public static String doGetYX(String url, Map<String, String> paramMap, String encode) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
String httpStr = null;
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
httpGet.addHeader("Content-Type", encode);
CloseableHttpResponse response = null;
List<NameValuePair> params = new ArrayList<NameValuePair>();
Set<String> keySet = paramMap.keySet();
for (Iterator<String> it = keySet.iterator(); it.hasNext(); ) {
String next = it.next();
params.add(new BasicNameValuePair(next, paramMap.get(next)));
}
String str = EntityUtils.toString(new UrlEncodedFormEntity(params, "UTF-8"));
httpGet.setURI(new URI(url + "?" + str));
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
return httpStr;
}
public static String getUrlYX(String url, Map<String, String> paramMap, String encode) throws Exception {
String pathUrl = null;
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
httpGet.addHeader("Content-Type", encode);
List<NameValuePair> params = new ArrayList<NameValuePair>();
Set<String> keySet = paramMap.keySet();
for (Iterator<String> it = keySet.iterator(); it.hasNext(); ) {
String next = it.next();
params.add(new BasicNameValuePair(next, paramMap.get(next)));
}
String str = EntityUtils.toString(new UrlEncodedFormEntity(params, "UTF-8"));
URI uri = new URI(url + "?" + str);
pathUrl = uri.toString();
return pathUrl;
}
// 静态方法,类名可直接调用
public static String doPostYh(String url, Map<String, Object> paramsMap) {
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
//配置连接超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.setSocketTimeout(5000)
.setRedirectsEnabled(true)
.build();
HttpPost httpPost = new HttpPost(url);
//设置超时时间
httpPost.setConfig(requestConfig);
//装配post请求参数
List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
for (String key : paramsMap.keySet()) {
list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key))));
}
try {
//将参数进行编码为合适的格式,如将键值对编码为param1=value1&param2=value2
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "utf-8");
httpPost.setEntity(urlEncodedFormEntity);
//执行 post请求
CloseableHttpResponse closeableHttpResponse = closeableHttpClient.execute(httpPost);
String strRequest = "";
if (null != closeableHttpResponse && !"".equals(closeableHttpResponse)) {
System.out.println(closeableHttpResponse.getStatusLine().getStatusCode());
if (closeableHttpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity httpEntity = closeableHttpResponse.getEntity();
strRequest = EntityUtils.toString(httpEntity);
} else {
strRequest = "Error Response" + closeableHttpResponse.getStatusLine().getStatusCode();
}
}
return strRequest;
} catch (ClientProtocolException e) {
logger.error("URL: {} ClientProtocolException: {}",url,e);
return "协议异常";
} catch (IOException e) {
logger.error(" URL: {} IOException: {}",url,e);
return "IO异常";
} catch (Exception e){
logger.error(" URL: {} Exception: {}",url,e);
return "系统异常";
}
finally {
try {
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
logger.error(" URL: {} IOException: {}",url,e);
}
}
}
}
package com.thirdgateway.tiansi.common;
/**
* @Author: yexiaodong
* @Date:2018/9/8 11:16
*/
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
@ApiModel(
value = "JsonResult",
description = "通用返回结果模型"
)
public class JsonResult<T> implements Serializable {
private static final long serialVersionUID = 1475348231900998033L;
@ApiModelProperty("状态码")
private String code;
@ApiModelProperty("请求成功与否,true:成功,false:失败")
private Boolean success;
@ApiModelProperty("提示信息")
private String message;
@ApiModelProperty("返回业务数据")
private T result;
public JsonResult() {
}
public JsonResult(boolean isSuccess, String code, String message) {
this.success = isSuccess;
this.code = code;
this.message = message;
}
public static JsonResult success() {
return new JsonResult(true, "200", "操作成功!");
}
public static JsonResult success(Object data) {
JsonResult result = new JsonResult(true, "200", "操作成功!");
result.setResult(data);
return result;
}
public static JsonResult error(String message) {
JsonResult result = new JsonResult(false, "500", message);
return result;
}
public static JsonResult rpcError() {
JsonResult result = new JsonResult(false, "500", "rpc error!");
return result;
}
public static JsonResult rpcError(String message) {
JsonResult result = new JsonResult(false, "500", message);
return result;
}
public static JsonResult error(String message, String code) {
JsonResult result = new JsonResult(false, code, message);
result.setCode(code);
return result;
}
public static JsonResult error(BizCodeEnum bizCodeEnum) {
JsonResult result = new JsonResult(false, bizCodeEnum.getCode(), bizCodeEnum.getMessageCN());
result.setCode(bizCodeEnum.getCode());
return result;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public boolean isSuccess() {
return this.success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public T getResult() {
return this.result;
}
public void setResult(T result) {
this.result = result;
}
public String toString() {
return "JsonResult{code=" + this.code + ", success=" + this.success + ", message='" + this.message + '\'' + ", result=" + this.result + '}';
}
}
package com.thirdgateway.tiansi.common;
/**
* 雪花算法
*
* @author zhoulongsheng
* @version $Id: SnowFlake.java, v 0.1 2018年3月28日 下午4:46:28 zhoulongsheng Exp $
*/
public class SnowFlake {
/**
* 起始的时间戳
*/
private final static long START_TIMESTAMP = 1514736000000L;//2018-01-01 00:00:00
/**
* 每一部分占用的位数
*/
private final static long SEQUENCE_BIT = 10; //序列号占用的位数
private final static long MACHINE_BIT = 5; //机器标识占用的位数
private final static long DATA_CENTER_BIT = 3;//数据中心占用的位数
/**
* 每一部分的最大值
*/
public final static long MAX_DATA_CENTER_NUM = -1L ^ (-1L << DATA_CENTER_BIT);
public final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
public final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
/**
* 每一部分向左的位移
*/
private final static long MACHINE_LEFT = SEQUENCE_BIT;
private final static long DATA_CENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
private final static long TIMESTAMP_LEFT = DATA_CENTER_LEFT + DATA_CENTER_BIT;
private long dataCenterId; //数据中心
private long machineId; //机器标识
private long sequence = 0L; //序列号
private long lastTimestamp = -1L;//上一次时间戳
public SnowFlake(long dataCenterId, long machineId) {
if (dataCenterId > MAX_DATA_CENTER_NUM || dataCenterId < 0) {
throw new IllegalArgumentException("dataCenterId can't be greater than MAX_DATACENTER_NUM or less than 0");
}
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0");
}
this.dataCenterId = dataCenterId;
this.machineId = machineId;
}
/**
* 产生下一个ID
*
* @return
*/
public synchronized long nextId() {
long currTimestamp = getNewTimestamp();
if (currTimestamp < lastTimestamp) {
throw new RuntimeException("Clock moved backwards. Refusing to generate id");
}
if (currTimestamp == lastTimestamp) {
//相同毫秒内,序列号自增
sequence = (sequence + 1) & MAX_SEQUENCE;
//同一毫秒的序列数已经达到最大
if (sequence == 0L) {
currTimestamp = getNextMill();
}
} else {
//不同毫秒内,序列号置为0
sequence = 0L;
}
lastTimestamp = currTimestamp;
return (currTimestamp - START_TIMESTAMP) << TIMESTAMP_LEFT //时间戳部分
| dataCenterId << DATA_CENTER_LEFT //数据中心部分
| machineId << MACHINE_LEFT //机器标识部分
| sequence; //序列号部分
}
private long getNextMill() {
long mill = getNewTimestamp();
while (mill <= lastTimestamp) {
mill = getNewTimestamp();
}
return mill;
}
private long getNewTimestamp() {
return System.currentTimeMillis();
}
public static void main(String[] args) {
try {
for (int i=0; i<100; i++){
Thread.sleep(1);
SnowFlake sf = new SnowFlake(1,1);
System.out.println(sf.nextId());
System.out.println(String.valueOf(sf.nextId()).length());
}
} catch (Exception e) {
}
}
}
package com.thirdgateway.tiansi.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.net.UnknownHostException;
/**
* 雪花算法唯一序号生成工具
*
* @version $Id: SnowSequenceHelper.java, v 0.1 2018年3月28日 下午4:46:41 zhoulongsheng Exp $
*/
@Component
public class SnowSequenceHelper {
public final static String THIRD = "THIRD";
private static SnowFlake instance = null;
private static final Logger logger = LoggerFactory.getLogger(SnowSequenceHelper.class);
/**
* 生成规则:16位长度雪花算法序列号
*
* @return
*/
public static long nextSequence() {
return instance.nextId();
}
/**
* 生成规则:4位前缀编号 + 16位雪花算法序列号
*
* 前缀编号:@link SnowSequenceHelper.PREFIX_*
*
* @param prefix 指定前缀
* @return
*/
public static String nextSequence(String prefix) {
return prefix + instance.nextId();
}
/**
* 初始化雪花算法序列号生成器
*
* @throws UnknownHostException
*/
@PostConstruct
private synchronized void init() throws UnknownHostException {
if (instance != null) {
logger.info("------------- Snow Flake Sequence has initialized --------------");
return;
}
try {
String[] ipArray = GrabMachineIpUtil.getLocalHostLANAddress().getHostAddress().split("\\.");
long addr_t = Long.valueOf(ipArray[2]).longValue();
long addr_f = Long.valueOf(ipArray[3]).longValue();
long machineId = getScopeId(addr_t, SnowFlake.MAX_MACHINE_NUM);
long dataCenterId = getScopeId(addr_f, SnowFlake.MAX_DATA_CENTER_NUM);
instance = new SnowFlake(dataCenterId, machineId);
logger.info("------------- Snow Flake Sequence initialize success --------------, dataCenterId:{}, machineId:{}", dataCenterId, machineId);
} catch (UnknownHostException ue) {
logger.error("------------- Snow Flake Sequence initialize failed --------------", ue);
throw ue;
}
}
private static long getScopeId(long addr, long maxId) throws UnknownHostException {
long r = addr;
if (addr >= 0L && addr <= maxId) {
return addr;
} else {
do {
do {
r >>= 2;
} while(r < 0L);
} while(r > maxId);
return r;
}
}
}
package com.thirdgateway.tiansi.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@MapperScan(value = { "com.thirdgateway.tiansi.repository.mapper" })
public class MapperConfig {
}
package com.thirdgateway.tiansi.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author 张钟
* @date 2018/3/6
*/
@Configuration
@EnableSwagger2
//@Profile({"local", "daily", "DRdaily"})
public class Swagger2Config {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("zhanhaijingji.black")
.apiInfo(apiInfo())
.select()
// 扫描的包所在位置
.apis(RequestHandlerSelectors.basePackage("com.thirdgateway.tiansi.controller"))
// 扫描的 URL 规则
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
// 联系信息
return new ApiInfoBuilder()
// 大标题
.title("工薪贷业务核心")
// 描述
.description("工薪贷业务核心")
// 服务条款 URL
// .termsOfServiceUrl("http://hellowood.com.cn")
// .contact(contact)
// 版本
.version("0.0.1-SNAPSHOT")
.build();
}
}
package com.thirdgateway.tiansi.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author BlackJokerCJ
* @Date 2019/8/12
*/
@Configuration
public class XxlJobConfig {
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}
package com.thirdgateway.tiansi.controller;
import com.alibaba.fastjson.JSONObject;
import com.thirdgateway.tiansi.common.HttpUtil;
import com.thirdgateway.tiansi.common.JsonResult;
import com.thirdgateway.tiansi.service.IThirdRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("tiansi")
@Api(value = "天思服务集合", tags = {"天思服务接口"})
public class TiansiController {
private static final Logger logger = LoggerFactory.getLogger(TiansiController.class);
@Resource
private IThirdRecordService recordService;
@ApiOperation(value = "接收天思请求向Angel推送", tags = {"接收天思请求接口"}, notes = "接收天思请求向yellow推送")
@PostMapping("/tiansiToAngel")
public JsonResult<String> tiansiToYellow(@RequestBody JSONObject json) {
logger.info("tiansi传参json={}",json.toString());
try {
String result =recordService.httpDoPost(json);//调用第三方数据,获取返回信息
recordService.insertYellowRecord(json,result);//保存过境数据
}catch (Exception e) {
logger.error("{错误异常:{}",e.getMessage());
}finally {
}
return JsonResult.success("发送成功");
}
@ApiOperation(value = "接收Angel新增提前结清数据请求向天思推送", tags = {"接收Angel新增提前结清数据接口"}, notes = "接收Angel新增提前结清数据请求向天思推送")
@PostMapping("/yellowToTiansi")
public JsonResult<String> yellowToTiansi(@RequestBody JSONObject json) {
logger.info("Angel传参json={}",json.toString());
try {
String result =recordService.httpDoPost(json);//调用第三方数据,获取返回信息
recordService.insertYellowRecord(json,result);//保存过境数据
}catch (Exception e) {
logger.error("{错误异常:{}",e.getMessage());
}finally {
}
return JsonResult.success("发送成功");
}
public static void main(String[] args) {
Map<String, String> params =new HashMap<>();
// params.put("orderNo","1");
// params.put("collectionNo","2");
// params.put("amount","2");
String sjson="{\"memo\":\"500\",\"state\":\"500\",\"actualAmt\":1,\"handleMsg\":\"500\",\"intentionId\":1}";
// String result = HttpUtil.doPost("http://192.168.0.64:8188"+"/tiansi/pay",params); //
String result = HttpUtil.doPost("http://101.37.157.85:7010"+"/public/repaymentIntention/sync",JSONObject.parseObject(sjson));
JSONObject resultJson = JSONObject.parseObject(result);
Boolean success=resultJson.getBoolean("success");
Integer code=resultJson.getInteger("code");
System.out.println(result);
}
}
package com.thirdgateway.tiansi.repository.entity;
import java.util.Date;
public class ThirdRecord {
private String code;
private String status;
private String loanNo;
private String channelNo;
private String accessType;
private Date createTime;
private Date updateTime;
private String msg;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public String getLoanNo() {
return loanNo;
}
public void setLoanNo(String loanNo) {
this.loanNo = loanNo == null ? null : loanNo.trim();
}
public String getChannelNo() {
return channelNo;
}
public void setChannelNo(String channelNo) {
this.channelNo = channelNo == null ? null : channelNo.trim();
}
public String getAccessType() {
return accessType;
}
public void setAccessType(String accessType) {
this.accessType = accessType == null ? null : accessType.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg == null ? null : msg.trim();
}
}
\ No newline at end of file
package com.thirdgateway.tiansi.repository.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ThirdRecordExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ThirdRecordExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(String value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(String value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(String value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(String value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(String value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(String value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLike(String value) {
addCriterion("`status` like", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotLike(String value) {
addCriterion("`status` not like", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<String> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<String> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(String value1, String value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(String value1, String value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andLoanNoIsNull() {
addCriterion("loan_no is null");
return (Criteria) this;
}
public Criteria andLoanNoIsNotNull() {
addCriterion("loan_no is not null");
return (Criteria) this;
}
public Criteria andLoanNoEqualTo(String value) {
addCriterion("loan_no =", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoNotEqualTo(String value) {
addCriterion("loan_no <>", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoGreaterThan(String value) {
addCriterion("loan_no >", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoGreaterThanOrEqualTo(String value) {
addCriterion("loan_no >=", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoLessThan(String value) {
addCriterion("loan_no <", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoLessThanOrEqualTo(String value) {
addCriterion("loan_no <=", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoLike(String value) {
addCriterion("loan_no like", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoNotLike(String value) {
addCriterion("loan_no not like", value, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoIn(List<String> values) {
addCriterion("loan_no in", values, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoNotIn(List<String> values) {
addCriterion("loan_no not in", values, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoBetween(String value1, String value2) {
addCriterion("loan_no between", value1, value2, "loanNo");
return (Criteria) this;
}
public Criteria andLoanNoNotBetween(String value1, String value2) {
addCriterion("loan_no not between", value1, value2, "loanNo");
return (Criteria) this;
}
public Criteria andChannelNoIsNull() {
addCriterion("channel_no is null");
return (Criteria) this;
}
public Criteria andChannelNoIsNotNull() {
addCriterion("channel_no is not null");
return (Criteria) this;
}
public Criteria andChannelNoEqualTo(String value) {
addCriterion("channel_no =", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoNotEqualTo(String value) {
addCriterion("channel_no <>", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoGreaterThan(String value) {
addCriterion("channel_no >", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoGreaterThanOrEqualTo(String value) {
addCriterion("channel_no >=", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoLessThan(String value) {
addCriterion("channel_no <", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoLessThanOrEqualTo(String value) {
addCriterion("channel_no <=", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoLike(String value) {
addCriterion("channel_no like", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoNotLike(String value) {
addCriterion("channel_no not like", value, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoIn(List<String> values) {
addCriterion("channel_no in", values, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoNotIn(List<String> values) {
addCriterion("channel_no not in", values, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoBetween(String value1, String value2) {
addCriterion("channel_no between", value1, value2, "channelNo");
return (Criteria) this;
}
public Criteria andChannelNoNotBetween(String value1, String value2) {
addCriterion("channel_no not between", value1, value2, "channelNo");
return (Criteria) this;
}
public Criteria andAccessTypeIsNull() {
addCriterion("access_type is null");
return (Criteria) this;
}
public Criteria andAccessTypeIsNotNull() {
addCriterion("access_type is not null");
return (Criteria) this;
}
public Criteria andAccessTypeEqualTo(String value) {
addCriterion("access_type =", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeNotEqualTo(String value) {
addCriterion("access_type <>", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeGreaterThan(String value) {
addCriterion("access_type >", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeGreaterThanOrEqualTo(String value) {
addCriterion("access_type >=", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeLessThan(String value) {
addCriterion("access_type <", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeLessThanOrEqualTo(String value) {
addCriterion("access_type <=", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeLike(String value) {
addCriterion("access_type like", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeNotLike(String value) {
addCriterion("access_type not like", value, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeIn(List<String> values) {
addCriterion("access_type in", values, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeNotIn(List<String> values) {
addCriterion("access_type not in", values, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeBetween(String value1, String value2) {
addCriterion("access_type between", value1, value2, "accessType");
return (Criteria) this;
}
public Criteria andAccessTypeNotBetween(String value1, String value2) {
addCriterion("access_type not between", value1, value2, "accessType");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
\ No newline at end of file
package com.thirdgateway.tiansi.repository.mapper;
import com.thirdgateway.tiansi.repository.entity.ThirdRecord;
import com.thirdgateway.tiansi.repository.entity.ThirdRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ThirdRecordMapper {
int countByExample(ThirdRecordExample example);
int deleteByExample(ThirdRecordExample example);
int deleteByPrimaryKey(String code);
int insert(ThirdRecord record);
int insertSelective(ThirdRecord record);
List<ThirdRecord> selectByExampleWithBLOBs(ThirdRecordExample example);
List<ThirdRecord> selectByExample(ThirdRecordExample example);
ThirdRecord selectByPrimaryKey(String code);
int updateByExampleSelective(@Param("record") ThirdRecord record, @Param("example") ThirdRecordExample example);
int updateByExampleWithBLOBs(@Param("record") ThirdRecord record, @Param("example") ThirdRecordExample example);
int updateByExample(@Param("record") ThirdRecord record, @Param("example") ThirdRecordExample example);
int updateByPrimaryKeySelective(ThirdRecord record);
int updateByPrimaryKeyWithBLOBs(ThirdRecord record);
int updateByPrimaryKey(ThirdRecord record);
}
\ No newline at end of file
package com.thirdgateway.tiansi.service;
import com.alibaba.fastjson.JSONObject;
import com.thirdgateway.tiansi.repository.entity.ThirdRecord;
import java.io.IOException;
import java.util.List;
public interface IThirdRecordService {
/**
* 记录通过请求信息
* loanBackModel
*/
void insertYellowRecord(JSONObject json, String result) throws IOException ;
/**
* 更新信息
* @param json
* @param result
*/
void updateByExampleSelective(JSONObject json, String result) throws IOException ;
/**
* 查询所有状态失败的数据(status=1)
* @return
*/
List<ThirdRecord> getThirdRecordList() throws IOException;
/**
* 发起http请求
* @param json
* @return
*/
String httpDoPost(JSONObject json) throws IOException ;
}
package com.thirdgateway.tiansi.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.thirdgateway.tiansi.common.HttpUtil;
import com.thirdgateway.tiansi.common.SnowSequenceHelper;
import com.thirdgateway.tiansi.repository.entity.ThirdRecord;
import com.thirdgateway.tiansi.repository.entity.ThirdRecordExample;
import com.thirdgateway.tiansi.repository.mapper.ThirdRecordMapper;
import com.thirdgateway.tiansi.service.IThirdRecordService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class ThirdRecordServiceImpl implements IThirdRecordService {
private static final Logger logger = LoggerFactory.getLogger(ThirdRecordServiceImpl.class);
@Resource
private ThirdRecordMapper mapper;
@Value("yellow-server")
private String yellowServer;
@Value("tiansi-server")
private String tiansiServer;
@Override
public void insertYellowRecord(JSONObject reqBodyJson,String result) throws IOException{
JSONObject resultJson = JSONObject.parseObject(result);//解析返回的结果{"code": "string","message": "string","result": {},"success": false}
boolean success=resultJson.getBoolean("success");//获取本程序调用第三方返回的状态
Integer code=resultJson.getInteger("code");
String channelNo=reqBodyJson.getString("channelNo");//获取请求方的渠道编号
String accessType=reqBodyJson.getString("accessType");//获取请求方的访问类型
String orderNo=reqBodyJson.getString("orderNo");//获取请求方的订单编号
String thirdCode= SnowSequenceHelper.nextSequence(SnowSequenceHelper.THIRD);//生成唯一编号
ThirdRecord record=new ThirdRecord();
record.setCode(thirdCode);
record.setCreateTime(new Date());
record.setMsg(reqBodyJson.toString());
record.setAccessType(accessType);
record.setChannelNo(channelNo);
record.setLoanNo(orderNo);
if(true==success &&200==code){
record.setStatus("0");//成功
}else{
record.setStatus("1");//失败
}
mapper.insertSelective(record);
logger.info("保存数据完成,object={}",record.toString());
}
@Override
public void updateByExampleSelective(JSONObject reqBodyJson, String result) throws IOException {
JSONObject resultJson = JSONObject.parseObject(result);//解析返回的结果{"code": "string","message": "string","result": {},"success": false}
boolean success=resultJson.getBoolean("success");//获取本程序调用第三方返回的状态
Integer code=resultJson.getInteger("code");
if(true==success &&200==code){
ThirdRecord record=new ThirdRecord();
record.setUpdateTime(new Date());
record.setStatus("0");//成功状态
String channelNo=reqBodyJson.getString("channelNo");//获取请求方的渠道编号
String accessType=reqBodyJson.getString("accessType");//获取请求方的访问类型
String orderNo=reqBodyJson.getString("orderNo");//获取请求方的订单编号
ThirdRecordExample example=new ThirdRecordExample();
ThirdRecordExample.Criteria criteria = example.createCriteria();
criteria.andChannelNoEqualTo(channelNo);
criteria.andAccessTypeEqualTo(accessType);
criteria.andLoanNoEqualTo(orderNo);
criteria.andStatusEqualTo("1");//失败状态
mapper.updateByExampleSelective(record,example);
logger.info("更新数据完成,object={}",record.toString());
}else{
logger.info("未更新数据,result={},日志时间={}",result,new Date());
}
}
@Override
public List<ThirdRecord> getThirdRecordList( ) throws IOException {
ThirdRecordExample example=new ThirdRecordExample();
ThirdRecordExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo("1");//失败状态
return mapper.selectByExample(example);
}
@Override
public String httpDoPost(JSONObject json) throws IOException {
String result=new String();
String channelNo=json.getString("channelNo");//获取请求方的渠道编号
String accessType=json.getString("accessType");//获取请求方的访问类型
System.out.println(tiansiServer+"============"+yellowServer);
if("angel".equals(channelNo)){
if("caseAdd".equals(accessType)){
result = HttpUtil.doPost(tiansiServer+"/public/case/add",json);
}else if("repaymentIntentionSync".equals(accessType)){
result = HttpUtil.doPost(tiansiServer+"/public/repaymentIntention/sync",json);
}else if("repayRecordAdd".equals(accessType)){
result = HttpUtil.doPost(tiansiServer+"/public/repayRecord/add",json);
}else if("synAdvanceSettleAdd".equals(accessType)){
result = HttpUtil.doPost(tiansiServer+"/public/synAdvanceSettle/add",json);
}else if("caseOverdueSync".equals(accessType)){
result = HttpUtil.doPost(tiansiServer+"/public/caseOverdue/sync",json);
}
logger.info("thirdgateway-->tiansi,result={},请求时间={}",result,new Date());
}else if("tiansi".equals(channelNo)){
if("pay".equals(accessType)){
result = HttpUtil.doPost(yellowServer+"/tiansi/pay",json);
}
logger.info("thirdgateway-->angel,result={},请求时间={}",result,new Date());
}
return result;
}
}
package com.thirdgateway.tiansi.task;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author BlackJokerCJ
* @Date 2019/8/12
*/
@Slf4j
public abstract class AbstractJobHandler extends IJobHandler {
@Override
public ReturnT<String> execute(String param) throws Exception {
LocalDateTime executeStartTime = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
Long li1 = System.currentTimeMillis();
XxlJobLogger.log("任务开始时间-[{}]", executeStartTime.format(formatter));
log.info("任务开始时间-[{}]", executeStartTime.format(formatter));
ReturnT<String> result = run(param);
Long li2 = System.currentTimeMillis();
XxlJobLogger.log("任务结束时间-[{}]", executeStartTime.format(formatter));
log.info("任务结束时间-[{}],执行-[{}]", executeStartTime.format(formatter), li2 - li1);
return result;
}
/**
* 子类实现此方法
*/
public abstract ReturnT<String> run(String param);
}
package com.thirdgateway.tiansi.task;
import com.alibaba.fastjson.JSONObject;
import com.thirdgateway.tiansi.repository.entity.ThirdRecord;
import com.thirdgateway.tiansi.service.IThirdRecordService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* 对当前失败数据再次发起请求
*/
@Component
@JobHandler("thirdRecordJobHandler")
public class ThirdRecordTask extends AbstractJobHandler {
private static final Logger logger = LoggerFactory.getLogger(ThirdRecordTask.class);
@Autowired
private IThirdRecordService iThirdRecordService;
@Override
public ReturnT<String> run(String param) {
this.thriedgateway();
return new ReturnT(200, "对当前失败数据再次发起请求");
}
private void thriedgateway() {
logger.info("当前失败数据定时处理。。。");
//查询
try {
List<ThirdRecord> lists= iThirdRecordService.getThirdRecordList();
logger.info("当前失败数据数量:{}", lists.size());
if (CollectionUtils.isEmpty(lists)) {
return;
}
for (ThirdRecord record : lists) {
logger.info("定时任务:当前对象信息:{}", record.toString());
String result= iThirdRecordService.httpDoPost(JSONObject.parseObject(record.getMsg()));
iThirdRecordService.updateByExampleSelective(JSONObject.parseObject(record.getMsg()),result);
}
}catch (Exception e) {
logger.error("{错误异常:{}",e.getMessage());
}finally {
}
logger.info("当前失败数据处理结束....");
}
}
server.port=8081
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://rm-bp1lh81jx8z299f7h3o.mysql.rds.aliyuncs.com/thirdgateway?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=dev123
spring.datasource.password=dev123$%^
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
spring.redis.database=5
spring.redis.host=r-bp18rzxiuwldgudwdspd.redis.rds.aliyuncs.com
spring.redis.port=6379
spring.redis.password=Ny123$%^
tiansi-server=http://101.37.157.85:7010
yellow-server=http://192.168.0.64:8188
xxl.job.admin.addresses=http://118.31.125.50:8550/xxl-job-admin
xxl.job.executor.appname=thirdgateway-service-daily
xxl.job.executor.port=9982
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
xxl.job.executor.logretentiondays=-1
xxl.job.executor.ip=
xxl.job.accessToken=
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--mysql 连接数据库jar 这里选择自己本地位置-->
<classPathEntry location="D:\Program Files\mysql-connector-java-8.0.20.jar"/>
<context id="testTables" targetRuntime="MyBatis3">
<property name="autoDelimitKeywords" value="true"/>
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://rm-bp1lh81jx8z299f7h3o.mysql.rds.aliyuncs.com:3306/thirdgateway"
userId="dev123"
password="dev123$%^">
</jdbcConnection>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="true"/>
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.thirdgateway.tiansi.repository.entity"
targetProject="src/main/java">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false"/>
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置
如果maven工程只是单独的一个工程,targetProject="src/main/java"
若果maven工程是分模块的工程,targetProject="所属模块的名称",例如:
targetProject="ecps-manager-mapper",下同-->
<sqlMapGenerator targetPackage="mybatis.mapper"
targetProject="src/main/resources">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.thirdgateway.tiansi.repository.mapper"
targetProject="src/main/java">
<!-- enableSubP ackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- 指定数据库表 -->
<table schema="" tableName="third_record">
<!--<property name="useActualColumnNames" value="true"/>-->
</table>
</context>
</generatorConfiguration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.thirdgateway.tiansi.repository.mapper.ThirdRecordMapper" >
<resultMap id="BaseResultMap" type="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
<id column="code" property="code" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="VARCHAR" />
<result column="loan_no" property="loanNo" jdbcType="VARCHAR" />
<result column="channel_no" property="channelNo" jdbcType="VARCHAR" />
<result column="access_type" property="accessType" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.thirdgateway.tiansi.repository.entity.ThirdRecord" extends="BaseResultMap" >
<result column="msg" property="msg" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
code, `status`, loan_no, channel_no, access_type, create_time, update_time
</sql>
<sql id="Blob_Column_List" >
msg
</sql>
<select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecordExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from third_record
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecordExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from third_record
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from third_record
where code = #{code,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from third_record
where code = #{code,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecordExample" >
delete from third_record
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
insert into third_record (code, `status`, loan_no,
channel_no, access_type, create_time,
update_time, msg)
values (#{code,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{loanNo,jdbcType=VARCHAR},
#{channelNo,jdbcType=VARCHAR}, #{accessType,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{msg,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
insert into third_record
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="code != null" >
code,
</if>
<if test="status != null" >
`status`,
</if>
<if test="loanNo != null" >
loan_no,
</if>
<if test="channelNo != null" >
channel_no,
</if>
<if test="accessType != null" >
access_type,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="msg != null" >
msg,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="code != null" >
#{code,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=VARCHAR},
</if>
<if test="loanNo != null" >
#{loanNo,jdbcType=VARCHAR},
</if>
<if test="channelNo != null" >
#{channelNo,jdbcType=VARCHAR},
</if>
<if test="accessType != null" >
#{accessType,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="msg != null" >
#{msg,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecordExample" resultType="java.lang.Integer" >
select count(*) from third_record
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update third_record
<set >
<if test="record.code != null" >
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.status != null" >
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.loanNo != null" >
loan_no = #{record.loanNo,jdbcType=VARCHAR},
</if>
<if test="record.channelNo != null" >
channel_no = #{record.channelNo,jdbcType=VARCHAR},
</if>
<if test="record.accessType != null" >
access_type = #{record.accessType,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null" >
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null" >
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.msg != null" >
msg = #{record.msg,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map" >
update third_record
set code = #{record.code,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
loan_no = #{record.loanNo,jdbcType=VARCHAR},
channel_no = #{record.channelNo,jdbcType=VARCHAR},
access_type = #{record.accessType,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
msg = #{record.msg,jdbcType=LONGVARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update third_record
set code = #{record.code,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
loan_no = #{record.loanNo,jdbcType=VARCHAR},
channel_no = #{record.channelNo,jdbcType=VARCHAR},
access_type = #{record.accessType,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
update third_record
<set >
<if test="status != null" >
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="loanNo != null" >
loan_no = #{loanNo,jdbcType=VARCHAR},
</if>
<if test="channelNo != null" >
channel_no = #{channelNo,jdbcType=VARCHAR},
</if>
<if test="accessType != null" >
access_type = #{accessType,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="msg != null" >
msg = #{msg,jdbcType=LONGVARCHAR},
</if>
</set>
where code = #{code,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
update third_record
set `status` = #{status,jdbcType=VARCHAR},
loan_no = #{loanNo,jdbcType=VARCHAR},
channel_no = #{channelNo,jdbcType=VARCHAR},
access_type = #{accessType,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
msg = #{msg,jdbcType=LONGVARCHAR}
where code = #{code,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.thirdgateway.tiansi.repository.entity.ThirdRecord" >
update third_record
set `status` = #{status,jdbcType=VARCHAR},
loan_no = #{loanNo,jdbcType=VARCHAR},
channel_no = #{channelNo,jdbcType=VARCHAR},
access_type = #{accessType,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where code = #{code,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>tiansi</title>
</head>
<body>
come on!!!
</body>
</html>
\ No newline at end of file
package com.thirdgateway.tiansi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ThirdgatewayApplicationTests {
@Test
void contextLoads() {
}
}
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAnk0vcAqqqrH/PSuvTRABlO09A2WRpCSE/eaPFIeMDVGnVI4b+pza
Oh+EbFjGCOWV+H2YYvGZ0GyV75gt897KVb4uJr4GJH3njUSzxsjvzLWrrZ1NaCzXtI6vu5
mUENzZZuJcSffneuHQvpJQF8Ssn+TVZ9Dqv9XNgFThNcJFJHgviXsWZkdip4877DmzeWCz
NefJ9lA5gUkeHkJ9oNZHr7+OFedD9SgKNxLmQ2p+BBto9IxDGLoL9uBKdaiv1VlAeUWRor
GSfShx2kv8bdZaS0XZ4A9izdojDv5HgQASfccG5C48f1YVDgnCFwT7/eR7ysJQ2nhBLYgg
XyG3EUMe2nIbKXZ/rH6DZm/9ggIj+fi9WO61r9a/Fo6zL8pGYwHJ7J0ex9CJWEq8uyDlDc
Io4wBpgmVWWHbI6n+/JpvqRZoV5wZKS5hj1hj6FyV3WFT3j6cg7wK09qQVKJyopwbvP2h9
IlPbmze1Yro8B9YO+DrelcUMlislfcITvfeOYqfxAAAFiCltwsIpbcLCAAAAB3NzaC1yc2
EAAAGBAJ5NL3AKqqqx/z0rr00QAZTtPQNlkaQkhP3mjxSHjA1Rp1SOG/qc2jofhGxYxgjl
lfh9mGLxmdBsle+YLfPeylW+Lia+BiR9541Es8bI78y1q62dTWgs17SOr7uZlBDc2WbiXE
n353rh0L6SUBfErJ/k1WfQ6r/VzYBU4TXCRSR4L4l7FmZHYqePO+w5s3lgszXnyfZQOYFJ
Hh5CfaDWR6+/jhXnQ/UoCjcS5kNqfgQbaPSMQxi6C/bgSnWor9VZQHlFkaKxkn0ocdpL/G
3WWktF2eAPYs3aIw7+R4EAEn3HBuQuPH9WFQ4JwhcE+/3ke8rCUNp4QS2IIF8htxFDHtpy
Gyl2f6x+g2Zv/YICI/n4vVjuta/WvxaOsy/KRmMByeydHsfQiVhKvLsg5Q3CKOMAaYJlVl
h2yOp/vyab6kWaFecGSkuYY9YY+hcld1hU94+nIO8CtPakFSicqKcG7z9ofSJT25s3tWK6
PAfWDvg63pXFDJYrJX3CE733jmKn8QAAAAMBAAEAAAGAL0ju+pC1GffBPgxmeKZnUozqxL
D6KAWglBbidkdm1jOlv+QTB3EC3om7jIGX5eBuQ6OAeU2hnFhTERZr44SQ+7urHXd1bkEN
gW0cJiyvNH6voVRzYsLCS/SzGV5uk/rkFY9X8eBTDKmXKNWbhv4AcmJwPGpzNIowsDyqaN
x2usYLrQ1PS43XMiXeyFkT+xWfcmKiOSkNhEjK7k7+J6TaFO0rC+/gpMIpCvpiPZD5w1BM
sX+UKzanjD7C/xI8M4ZM+43kQ1RdfPva3B8M2RGlntz1FqQ1QyDUG4JvIYbk9DAbdcRwtB
mkmYKuaorgTS3VWuycFtKJyxeieCQGCzDTUaphK7NoP0L9PHn1NmLUNTB+2EXdxtyRRJ72
5I9OcDXKoC/iYbYZ/HaCCavgwN2FlGykRMhCM4A3dWRCcXPr0u4O5LWgpht7Unmr+U8K7L
yGtQePr3fKkREb2fTQcILocvlQpIY8yU6Rf7yoM6B5IubeRWzDC/EYGdHTkbhCRO5hAAAA
wHl0Bk1QNgkBC6/xB9ptAPY1Hvjy0PqHkm8kwwWxGjM+TRUvjt39uTSLSveMxhMsA82+O5
aIzONc/x02vCWUksIff1Rh8ZcZ8eG2JLhBTfOr8NbJM5Pkj5jBO7gkfWFCGu6Iab3Qjg7g
HbbiHSRiS1y2GSNUKwpbRjaN5FBscsBYUIHm4iBqegcIwoBKo8+8N/5PGXGC4zsy5Y02Co
F88jSqNME//Z3S38TI6+ayk66Gp1fFMt3jRGJDpK+UyjTZoQAAAMEA0eoYg92OtshdpaNj
RS7gaefLVsT/1vnRNqLSnDIWZelK3qQhL4pGVSgKWPL1VJfqA1s+kueWF2EVvC9LHaav9q
L0B/nlKMmOjWeyDMqnLoXJq4dr0SZEGlBSQ5iNquyL2zagb/mlmwP1GAa4fJqsWS7LPOWw
Lik4ftUzqddvdU0ZBlqNU61s4oAVKZptSDsdgq/7dYIDMK8llLTvDM0cIQjI+Mp/m/oqhi
Jd1SI5cGHevijiC+fqtf0bt4pSAAhrAAAAwQDBDkR7TVxeXhfeHVbUWhNz50OHzxh8LzYr
VpwS3MF3hnzcN3qBxdXLg1p1qG3rIM5Xv+enuhbE80mekp2M/uXpl+CkuOqd7HMg6loZki
hDYl6WOKeLslyhbqqHDWFDzBPUKoONm1BMmLca6sAe7x4lxmpB/K5GujkzVUiP1FAKPAQP
YD0TlmopnpBbj8ve1UgxZSSLtovJJuD+66tOBTB3K97f5nPAUjhXH/oF0ATGGGHq7Lc98S
gEAQ29P6zIGBMAAAASeHVlaGFuXzg4OEAxNjMuY29tAQ==
-----END OPENSSH PRIVATE KEY-----
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCeTS9wCqqqsf89K69NEAGU7T0DZZGkJIT95o8Uh4wNUadUjhv6nNo6H4RsWMYI5ZX4fZhi8ZnQbJXvmC3z3spVvi4mvgYkfeeNRLPGyO/MtautnU1oLNe0jq+7mZQQ3Nlm4lxJ9+d64dC+klAXxKyf5NVn0Oq/1c2AVOE1wkUkeC+JexZmR2KnjzvsObN5YLM158n2UDmBSR4eQn2g1kevv44V50P1KAo3EuZDan4EG2j0jEMYugv24Ep1qK/VWUB5RZGisZJ9KHHaS/xt1lpLRdngD2LN2iMO/keBABJ9xwbkLjx/VhUOCcIXBPv95HvKwlDaeEEtiCBfIbcRQx7achspdn+sfoNmb/2CAiP5+L1Y7rWv1r8WjrMvykZjAcnsnR7H0IlYSry7IOUNwijjAGmCZVZYdsjqf78mm+pFmhXnBkpLmGPWGPoXJXdYVPePpyDvArT2pBUonKinBu8/aH0iU9ubN7ViujwH1g74Ot6VxQyWKyV9whO9945ip/E= xuehan_888@163.com
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment