init
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
FROM frolvlad/alpine-oraclejdk8:slim
|
||||
MAINTAINER xiunai78 <154707516@qq.com>
|
||||
|
||||
# Add the service itself
|
||||
ARG JAR_FILE
|
||||
ADD ${JAR_FILE} /usr/local/adminapi/myapp.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/usr/bin/java", "-jar", "/usr/local/adminapi/myapp.jar"]
|
||||
+5753
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,225 @@
|
||||
#!/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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@@ -0,0 +1,143 @@
|
||||
@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 http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%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%
|
||||
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.gzzn.omms</groupId>
|
||||
<artifactId>admin-api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>admin-api</name>
|
||||
<description>Admin Api project for CdAirPort </description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.17.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
|
||||
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>11.2.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>5.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<compilerArgs>
|
||||
<arg>-verbose</arg>
|
||||
<arg>-Xlint:unchecked</arg>
|
||||
<arg>-Xlint:deprecation</arg>
|
||||
<arg>-bootclasspath</arg>
|
||||
<arg>${env.JAVA_HOME}/jre/lib/rt.jar</arg>
|
||||
<arg>-extdirs</arg>
|
||||
<arg>${project.basedir}/lib</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
||||
<version>1.4.4</version>
|
||||
<configuration>
|
||||
<username>gzzn</username>
|
||||
<password>Gzzn@2018</password>
|
||||
<!-- 镜像tag -->
|
||||
<tag>${project.version}</tag>
|
||||
|
||||
<!--useMavenSettingsForAuth>true</useMavenSettingsForAuth -->
|
||||
<!-- 禁止使用谷歌商店认证 -->
|
||||
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
|
||||
|
||||
<repository>130.120.3.193/${project.groupId}/${project.artifactId}</repository>
|
||||
<buildArgs>
|
||||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>lib</directory>
|
||||
<targetPath>BOOT-INF/lib</targetPath>
|
||||
<includes>
|
||||
<include>**/*.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gzzn.omms.adminapi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@SpringBootApplication
|
||||
public class AdminApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApiApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.gzzn.omms.adminapi.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
@Bean(name = "primaryDataSource")
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix="spring.datasource.primary")
|
||||
public DataSource primaryDataSource()
|
||||
{
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "secondaryDataSource")
|
||||
@ConfigurationProperties(prefix="spring.datasource.secondary")
|
||||
public DataSource secondaryDataSource()
|
||||
{
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.gzzn.omms.adminapi.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaRepositories(
|
||||
entityManagerFactoryRef="entityManagerFactoryPrimary",
|
||||
transactionManagerRef="transactionManagerPrimary",
|
||||
basePackages= { "com.gzzn.omms.adminapi.domain.primary.dao" }
|
||||
) //设置Repository所在位置
|
||||
public class PrimaryConfig
|
||||
{
|
||||
|
||||
@Autowired @Qualifier("primaryDataSource")
|
||||
private DataSource primaryDataSource;
|
||||
|
||||
@Primary
|
||||
@Bean(name = "entityManagerPrimary")
|
||||
public EntityManager entityManager(EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return entityManagerFactoryPrimary(builder).getObject().createEntityManager();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "entityManagerFactoryPrimary")
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary (EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return builder
|
||||
.dataSource(primaryDataSource)
|
||||
.properties(getVendorProperties(primaryDataSource))
|
||||
.packages("com.gzzn.omms.adminapi.domain.primary.entity") //设置实体类所在位置
|
||||
.persistenceUnit("primaryPersistenceUnit")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Autowired private JpaProperties jpaProperties;
|
||||
private Map<String, String> getVendorProperties(DataSource dataSource)
|
||||
{
|
||||
return jpaProperties.getHibernateProperties(dataSource);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "transactionManagerPrimary")
|
||||
public PlatformTransactionManager transactionManagerPrimary(EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return new JpaTransactionManager(entityManagerFactoryPrimary(builder).getObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gzzn.omms.adminapi.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaRepositories(
|
||||
entityManagerFactoryRef="entityManagerFactorySecondary",
|
||||
transactionManagerRef="transactionManagerSecondary",
|
||||
basePackages= { "com.gzzn.omms.adminapi.domain.secondary.dao" }
|
||||
) //设置Repository所在位置
|
||||
|
||||
public class SecondaryConfig
|
||||
{
|
||||
@Autowired
|
||||
@Qualifier("secondaryDataSource")
|
||||
private DataSource secondaryDataSource;
|
||||
|
||||
@Bean(name = "entityManagerSecondary")
|
||||
public EntityManager entityManager(EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
|
||||
}
|
||||
|
||||
@Bean(name = "entityManagerFactorySecondary")
|
||||
public LocalContainerEntityManagerFactoryBean
|
||||
entityManagerFactorySecondary (EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return builder
|
||||
.dataSource(secondaryDataSource)
|
||||
.properties(getVendorProperties(secondaryDataSource))
|
||||
.packages("com.gzzn.omms.adminapi.domain.secondary.entity") //设置实体类所在位置
|
||||
.persistenceUnit("secondaryPersistenceUnit")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private JpaProperties jpaProperties;
|
||||
private Map<String, String> getVendorProperties(DataSource dataSource)
|
||||
{
|
||||
return jpaProperties.getHibernateProperties(dataSource);
|
||||
}
|
||||
|
||||
@Bean(name = "transactionManagerSecondary")
|
||||
PlatformTransactionManager transactionManagerSecondary(EntityManagerFactoryBuilder builder)
|
||||
{
|
||||
return new JpaTransactionManager(entityManagerFactorySecondary(builder).getObject());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gzzn.omms.adminapi.controller.basicdata;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.gzzn.omms.adminapi.domain.secondary.dao.basicdata.IABCDao;
|
||||
import com.gzzn.omms.adminapi.domain.secondary.dao.basicdata.ICheckinGroupDao;
|
||||
import com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata.ABC;
|
||||
import com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata.CheckinGroup;
|
||||
import com.gzzn.omms.adminapi.dto.ResponseDto;
|
||||
|
||||
/**
|
||||
* 值机岛
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
public class CheckinGroupController {
|
||||
|
||||
@Autowired
|
||||
private ICheckinGroupDao checkinGroupDao;
|
||||
|
||||
@Autowired
|
||||
private IABCDao ABCDao;
|
||||
|
||||
@GetMapping(value="/basicdata/checkinGroup")
|
||||
public ResponseDto getCheckinGroup() {
|
||||
|
||||
ABC abc = ABCDao.findOne("1");
|
||||
|
||||
return ResponseDto.success(abc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.gzzn.omms.adminapi.domain;
|
||||
|
||||
public interface BaseEntity {
|
||||
public void load();
|
||||
public void save();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gzzn.omms.adminapi.domain.secondary.dao.basicdata;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata.ABC;
|
||||
|
||||
public interface IABCDao extends CrudRepository<ABC,String>{
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.gzzn.omms.adminapi.domain.secondary.dao.basicdata;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata.CheckinGroup;
|
||||
|
||||
public interface ICheckinGroupDao extends CrudRepository<CheckinGroup,String> {
|
||||
|
||||
public CheckinGroup findByCheckinGroupCode(String code);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="ABC")
|
||||
public class ABC {
|
||||
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private String id;
|
||||
|
||||
@Column(name = "NAME")
|
||||
private String name;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.gzzn.omms.adminapi.domain.secondary.entity.baiscdata;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.gzzn.omms.adminapi.domain.BaseEntity;
|
||||
import com.gzzn.omms.adminapi.domain.secondary.dao.basicdata.ICheckinGroupDao;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 值机岛
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="ORMS_CHECKIN_GROUP")
|
||||
public class CheckinGroup {
|
||||
@Id
|
||||
@Column(name = "CHECKIN_GROUP_CODE")
|
||||
private String checkinGroupCode;
|
||||
|
||||
|
||||
|
||||
@Column(name = "CHECKIN_GROUP_NAME")
|
||||
private String checkinGroupName;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gzzn.omms.adminapi.dto;
|
||||
|
||||
import com.gzzn.omms.adminapi.enums.ResultCode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xiunai
|
||||
*
|
||||
* @date 2018年5月16日
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ResponseDto {
|
||||
private Boolean is_success;
|
||||
private Integer err_code;
|
||||
private String err_msg;
|
||||
|
||||
private Object body;
|
||||
|
||||
public ResponseDto() {}
|
||||
|
||||
public ResponseDto(Integer code, String msg) {
|
||||
this.setIs_success(false);
|
||||
this.setErr_code(code);
|
||||
this.setErr_msg(msg);
|
||||
}
|
||||
|
||||
public static ResponseDto success() {
|
||||
ResponseDto result = new ResponseDto();
|
||||
result.setIs_success(true);
|
||||
result.setResultCode(ResultCode.SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResponseDto success(Object data) {
|
||||
ResponseDto result = new ResponseDto();
|
||||
result.setIs_success(true);
|
||||
result.setResultCode(ResultCode.SUCCESS);
|
||||
result.setBody(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResponseDto failure(ResultCode resultCode) {
|
||||
ResponseDto result = new ResponseDto();
|
||||
result.setIs_success(false);
|
||||
result.setResultCode(resultCode);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResponseDto failure(ResultCode resultCode, Object data) {
|
||||
ResponseDto result = new ResponseDto();
|
||||
result.setIs_success(false);
|
||||
result.setResultCode(resultCode);
|
||||
result.setBody(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResultCode(ResultCode code) {
|
||||
this.setErr_code(code.code());
|
||||
this.setErr_msg(code.message());
|
||||
}
|
||||
|
||||
public Object getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(Object body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Boolean getIs_success() {
|
||||
return is_success;
|
||||
}
|
||||
|
||||
public void setIs_success(Boolean is_success) {
|
||||
this.is_success = is_success;
|
||||
}
|
||||
|
||||
public Integer getErr_code() {
|
||||
return err_code;
|
||||
}
|
||||
|
||||
public void setErr_code(Integer err_code) {
|
||||
this.err_code = err_code;
|
||||
}
|
||||
|
||||
public String getErr_msg() {
|
||||
return err_msg;
|
||||
}
|
||||
|
||||
public void setErr_msg(String err_msg) {
|
||||
this.err_msg = err_msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.gzzn.omms.adminapi.enums;
|
||||
|
||||
public enum ResultCode {
|
||||
/* 成功状态码 */
|
||||
SUCCESS(1, "成功"),
|
||||
Failure(0,"失败"),
|
||||
|
||||
/* 参数错误:10001-19999 */
|
||||
PARAM_IS_INVALID(10001, "参数无效"),
|
||||
PARAM_IS_BLANK(10002, "参数为空"),
|
||||
PARAM_TYPE_BIND_ERROR(10003, "参数类型错误"),
|
||||
PARAM_NOT_COMPLETE(10004, "参数缺失"),
|
||||
|
||||
/* 用户错误:20001-29999*/
|
||||
USER_NOT_LOGGED_IN(20001, "用户未登录"),
|
||||
USER_LOGIN_ERROR(20002, "账号不存在或密码错误"),
|
||||
USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"),
|
||||
USER_NOT_EXIST(20004, "用户不存在"),
|
||||
USER_HAS_EXISTED(20005, "用户已存在"),
|
||||
|
||||
/* 业务错误:30001-39999 */
|
||||
SPECIFIED_QUESTIONED_USER_NOT_EXIST(30001, "某业务出现问题"),
|
||||
SPECIFIED_ASSETSCATALOG_NOT_FOUND(31001, "资源目录分类不存在"),
|
||||
SPECIFIED_RESOURCELIST_NOT_FOUND(31002, "资源目录不存在"),
|
||||
SPECIFIED_MAINDATAMODEL_NOT_FOUND(32001, "主数据模型不存在"),
|
||||
SPECIFIED_MAINDATAMODEL_TABLE_EXISTED(32002, "主数据模型存储表已存在"),
|
||||
|
||||
/* 系统错误:40001-49999 */
|
||||
SYSTEM_INNER_ERROR(40001, "系统繁忙,请稍后重试"),
|
||||
|
||||
/* 数据错误:50001-599999 */
|
||||
RESULE_DATA_NONE(50001, "数据未找到"),
|
||||
DATA_IS_WRONG(50002, "数据有误"),
|
||||
DATA_ALREADY_EXISTED(50003, "数据已存在"),
|
||||
|
||||
/* 接口错误:60001-69999 */
|
||||
INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"),
|
||||
INTERFACE_OUTTER_INVOKE_ERROR(60002, "外部系统接口调用异常"),
|
||||
INTERFACE_FORBID_VISIT(60003, "该接口禁止访问"),
|
||||
INTERFACE_ADDRESS_INVALID(60004, "接口地址无效"),
|
||||
INTERFACE_REQUEST_TIMEOUT(60005, "接口请求超时"),
|
||||
INTERFACE_EXCEED_LOAD(60006, "接口负载过高"),
|
||||
INTERFACE_NOT_IMPLEMENT(60007, "接口暂未实现"),
|
||||
|
||||
/* 权限错误:70001-79999 */
|
||||
PERMISSION_NO_ACCESS(70001, "无访问权限");
|
||||
|
||||
|
||||
private Integer code;
|
||||
private String message;
|
||||
|
||||
ResultCode(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer code() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String message() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public static String getMessage(String name) {
|
||||
for (ResultCode item : ResultCode.values()) {
|
||||
if (item.name().equals(name)) {
|
||||
return item.message;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static Integer getCode(String name) {
|
||||
for (ResultCode item : ResultCode.values()) {
|
||||
if (item.name().equals(name)) {
|
||||
return item.code;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.gzzn.omms.adminapi.exception.handler;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.jboss.logging.MDC;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.gzzn.omms.adminapi.utils.JsonUtil;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class ExceptionAspect {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ExceptionAspect.class);
|
||||
|
||||
@Pointcut("execution(public * com.gzzn.zdgov.controller.*.*(..))")
|
||||
public void log(){
|
||||
|
||||
}
|
||||
|
||||
@Before("log()")
|
||||
public void doBefore(JoinPoint joinPoint){
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
|
||||
ContentCachingRequestWrapper wrapperRequest = new ContentCachingRequestWrapper(request);
|
||||
|
||||
MDC.clear();
|
||||
MDC.put("request_id", getRequestId(request));
|
||||
|
||||
//url
|
||||
try {
|
||||
logger.info("request={url={},method={},content_type={},body={},params={},remoteip={}}",
|
||||
request.getRequestURL(),
|
||||
request.getMethod(),
|
||||
request.getContentType(),
|
||||
JsonUtil.getString(joinPoint.getArgs()),
|
||||
getRequestParams(wrapperRequest),
|
||||
request.getRemoteAddr()
|
||||
);
|
||||
} catch (JsonProcessingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AfterReturning(pointcut = "log()",returning = "object")//打印输出结果
|
||||
public void doAfterReturing(Object object){
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonStr;
|
||||
try
|
||||
{
|
||||
jsonStr = objectMapper.writeValueAsString(object);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
jsonStr = "[unknown]";
|
||||
}
|
||||
|
||||
logger.info("response={}",jsonStr);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
private String getResponseBody(ContentCachingResponseWrapper response) {
|
||||
ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
|
||||
if(wrapper != null) {
|
||||
byte[] buf = wrapper.getContentAsByteArray();
|
||||
if(buf.length > 0) {
|
||||
String payload;
|
||||
try {
|
||||
payload = new String(buf, 0, buf.length, wrapper.getCharacterEncoding());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
payload = "[unknown]";
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印请求参数
|
||||
* @param request
|
||||
*/
|
||||
private String getRequestBody(ContentCachingRequestWrapper request) {
|
||||
ContentCachingRequestWrapper wrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
|
||||
if(wrapper != null) {
|
||||
byte[] buf = wrapper.getContentAsByteArray();
|
||||
if(buf.length > 0) {
|
||||
String payload;
|
||||
try {
|
||||
payload = new String(buf, 0, buf.length, wrapper.getCharacterEncoding());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
payload = "[unknown]";
|
||||
}
|
||||
return payload.replaceAll("\\n","");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取请求地址上的参数
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getRequestParams(HttpServletRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Enumeration<String> enu = request.getParameterNames();
|
||||
//获取请求参数
|
||||
while (enu.hasMoreElements()) {
|
||||
String name = enu.nextElement();
|
||||
sb.append(name + "=").append(request.getParameter(name));
|
||||
if(enu.hasMoreElements()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
private String getRequestId(HttpServletRequest request)
|
||||
{
|
||||
String requestId = null;
|
||||
String parameterRequestId = request.getParameter("requestId");
|
||||
String headerRequestId = request.getHeader("requestId");
|
||||
if (parameterRequestId == null && headerRequestId == null)
|
||||
{
|
||||
requestId = UUID.randomUUID().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
requestId = parameterRequestId != null ? parameterRequestId : headerRequestId;
|
||||
}
|
||||
|
||||
return requestId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gzzn.omms.adminapi.exception.handler;
|
||||
|
||||
import org.jboss.logging.MDC;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.gzzn.omms.adminapi.dto.ResponseDto;
|
||||
import com.gzzn.omms.adminapi.enums.ResultCode;
|
||||
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandle {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通用未知异常捕获处理
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public ResponseDto exceptionHandle(Exception e)
|
||||
{
|
||||
logger.error("[未知系统异常]",e);
|
||||
|
||||
String reponseErrMsg = "";
|
||||
String requestId = (String) MDC.get("request_id");
|
||||
String errorMessage = e.getMessage();
|
||||
if(errorMessage!=null)
|
||||
{
|
||||
reponseErrMsg = "requestId:"+requestId + ",errorMsg:" + errorMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
reponseErrMsg = "requestId:"+requestId + ",errorMsg:null";
|
||||
}
|
||||
|
||||
return ResponseDto.failure(ResultCode.SYSTEM_INNER_ERROR,reponseErrMsg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gzzn.omms.adminapi.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
|
||||
public class JsonUtil {
|
||||
public static String getString(Object object) throws JsonProcessingException
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
|
||||
java.lang.String jsonStr = ow.writeValueAsString(object);
|
||||
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
|
||||
public static <T> T getObject(String str,Class<T> valueType) throws JsonParseException, JsonMappingException, IOException
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
T obj = mapper.readValue(str, valueType);
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
spring:
|
||||
datasource:
|
||||
primary:
|
||||
username: zmsm
|
||||
password: 123456
|
||||
url: jdbc:mysql://130.120.3.158:3306/zmsm?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
|
||||
tomcat:
|
||||
max-active: 30
|
||||
test-on-borrow: true
|
||||
initial-size: 3
|
||||
|
||||
third:
|
||||
username: ommsxc
|
||||
password: ommsxc
|
||||
url: jdbc:oracle:thin:@130.120.2.105:1521/orcl
|
||||
driver: oracle.jdbc.driver.OracleDriver
|
||||
tomcat:
|
||||
max-active: 30
|
||||
test-on-borrow: true
|
||||
initial-size: 3
|
||||
|
||||
secondary:
|
||||
username: dc0305
|
||||
password: 123456
|
||||
url: jdbc:oracle:thin:@130.120.2.219:1521/orcl
|
||||
driver: oracle.jdbc.driver.OracleDriver
|
||||
tomcat:
|
||||
max-active: 30
|
||||
test-on-borrow: true
|
||||
initial-size: 3
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
show_sql: true
|
||||
@@ -0,0 +1,48 @@
|
||||
<configuration>
|
||||
<springProperty scope="context" name="loggingLevelRoot" source="logging.level.root"
|
||||
defaultValue="info"/>
|
||||
<springProperty scope="context" name="loggingFile" source="logging.file"
|
||||
defaultValue="logs/adminapi.log" />
|
||||
|
||||
<springProperty scope="context" name="elkHost" source="elkHost"
|
||||
defaultValue="localhost:4569" />
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${loggingFile}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${loggingFile}.%i-%d{yyyy-MM-dd}</fileNamePattern>
|
||||
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>60</maxHistory>
|
||||
<totalSizeCap>20GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="SOCKET"
|
||||
class="net.logstash.logback.appender.LogstashTcpSocketAppender">
|
||||
<destination>${elkHost}</destination>
|
||||
|
||||
<!-- encoder is required -->
|
||||
<encoder class="net.logstash.logback.encoder.LogstashEncoder" >
|
||||
<customFields>{"app_name":"xnsj","model_name":"adminapi"}</customFields>
|
||||
</encoder>
|
||||
|
||||
</appender>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="${loggingLevelRoot}">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="SOCKET" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gzzn.omms.adminapi;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class AdminApiApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user