初始化项目
This commit is contained in:
commit
3ac594565e
|
@ -0,0 +1,33 @@
|
|||
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/
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
|
|
@ -0,0 +1,5 @@
|
|||
FROM bellsoft/liberica-openjdk-alpine:8u345-1
|
||||
VOLUME /tmp
|
||||
COPY target/*.jar app.jar
|
||||
EXPOSE 8282
|
||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
|
@ -0,0 +1,75 @@
|
|||
[CmdletBinding()]
|
||||
param (
|
||||
[Alias('target')]
|
||||
[string]$BuildTarget = '',
|
||||
[string]$MavenOutputDir = "./target",
|
||||
[string]$DockerImgName = "usvisartrackapi",
|
||||
[string]$DockerServerName = "usvisartrackapi",
|
||||
[string]$CodeServerPort = "8282",
|
||||
[string]$PublishServerPort = "8383",
|
||||
[string]$BuildVerison = "0.0.1-snapshot"
|
||||
)
|
||||
|
||||
function build {
|
||||
ExecuteShellText "mvn clean package" "源码Maven编译打包"
|
||||
|
||||
publishDockImage
|
||||
|
||||
runDockerContainer
|
||||
}
|
||||
|
||||
function publishDockImage()
|
||||
{
|
||||
BuildDockerImageToLocal "Dockerfile"
|
||||
}
|
||||
|
||||
function runDockerContainer()
|
||||
{
|
||||
$split = ":"
|
||||
ExecuteShellText "docker stop $DockerServerName" "停止Docker容器"
|
||||
ExecuteShellText "docker rm $DockerServerName" "删除Docker容器"
|
||||
$fullImageName = BuildDockerFullImageName $DockerImgName $BuildVerison
|
||||
ExecuteShellText "docker run -p $PublishServerPort$split$CodeServerPort --name $DockerServerName -d $fullImageName " "启动Docker容器"
|
||||
}
|
||||
|
||||
function BuildDockerImageToLocal() {
|
||||
ExecuteShellText "docker image prune -f" "清理本地无用镜像"
|
||||
$fullImageName = BuildDockerFullImageName $DockerImgName $BuildVerison
|
||||
ExecuteShellText "docker build -f Dockerfile -t=""$fullImageName"" --label ""$DockerImgName"" --label ""$BuildVerison"" ." "编译镜像 $fullImageName"
|
||||
}
|
||||
|
||||
function BuildDockerFullImageName($imageName,$buildImageVersionName)
|
||||
{
|
||||
return "$imageName`:$buildImageVersionName"
|
||||
}
|
||||
|
||||
function buildDockerFile()
|
||||
{
|
||||
write-host ("执行 buildDockerFile")
|
||||
$dockerFile = Join-Path $MavenOutputDir "Dockerfile"
|
||||
$dockerFileContent = 'FROM bellsoft/liberica-openjdk-alpine:8u345-1' + "`n"
|
||||
$dockerFileContent += 'VOLUME /tmp' + "`n"
|
||||
$dockerFileContent += 'COPY target/*.jar app.jar' + "`n"
|
||||
$dockerFileContent += 'EXPOSE 8282' + "`n"
|
||||
$dockerFileContent += '# ENTRYPOINT ["java","-jar","/app.jar"]' + "`n"
|
||||
write-host ("写入 Dockerfile 内容到 $dockerFile")
|
||||
echo $dockerFileContent > $dockerFile
|
||||
}
|
||||
|
||||
# 执行文本命令
|
||||
function ExecuteShellText($shellText,$shellMsg)
|
||||
{
|
||||
write-host ("$shellMsg 执行脚本:$shellText")
|
||||
Invoke-Expression "& $shellText"
|
||||
}
|
||||
|
||||
|
||||
if($BuildTarget -eq '')
|
||||
{
|
||||
write-host ("未发现发现编译目标:$BuildTarget,操作跳过。")
|
||||
}
|
||||
else
|
||||
{
|
||||
& $BuildTarget
|
||||
}
|
||||
|
|
@ -0,0 +1,316 @@
|
|||
#!/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 /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
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="`\\unset -f command; \\command -v 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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$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 \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -0,0 +1,188 @@
|
|||
@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 "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
||||
|
||||
FOR /F "usebackq 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%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\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%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
|
@ -0,0 +1,115 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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.7.4</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.northtecom.visatrack</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Visa track api</name>
|
||||
<description>Visa track API project for North Tecom</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>1.6.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- hibernate enhancement -->
|
||||
<dependency>
|
||||
<groupId>com.vladmihalcea</groupId>
|
||||
<artifactId>hibernate-types-55</artifactId>
|
||||
<version>2.19.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DATABASE Client -->
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>3.0.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- 没有该配置,devtools 不生效 -->
|
||||
<fork>true</fork>
|
||||
<addResources>true</addResources>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.northtecom.visatrack.api;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class VisaTrackApiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(VisaTrackApiApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.northtecom.visatrack.api.base.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.vladmihalcea.hibernate.type.array.IntArrayType;
|
||||
import com.vladmihalcea.hibernate.type.array.StringArrayType;
|
||||
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
|
||||
import com.vladmihalcea.hibernate.type.json.JsonStringType;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.TypeDef;
|
||||
import org.hibernate.annotations.TypeDefs;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* 基础实体
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2022/09/19
|
||||
*/
|
||||
@Data
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
|
||||
@TypeDefs({
|
||||
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
|
||||
@TypeDef(name = "int-array", typeClass = IntArrayType.class),
|
||||
@TypeDef(name = "json", typeClass = JsonStringType.class),
|
||||
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
|
||||
})
|
||||
public abstract class BaseEntity<ID> implements Serializable {
|
||||
/**
|
||||
* Auto increment long id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected ID id;
|
||||
/**
|
||||
* Created time
|
||||
*/
|
||||
@CreatedDate
|
||||
@Column(name = "createTime", columnDefinition = "DATETIME NOT NULL COMMENT 'Created time'")
|
||||
protected LocalDateTime createTime;
|
||||
/**
|
||||
* Last modified time
|
||||
*/
|
||||
@LastModifiedDate
|
||||
@Column(name = "modifiedTime", columnDefinition = "DATETIME COMMENT 'Last modified time'")
|
||||
protected LocalDateTime modifiedTime;
|
||||
/**
|
||||
* Data version
|
||||
*/
|
||||
@Version
|
||||
@Column(name = "version", nullable = false, columnDefinition = "bigint COMMENT 'Data version'")
|
||||
protected Long version = 0L;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.northtecom.visatrack.api.base.exception;
|
||||
|
||||
|
||||
import com.northtecom.visatrack.api.base.web.Status;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Base exception for rest api
|
||||
* </p>
|
||||
*
|
||||
* @author Xie yang
|
||||
* @date Created in 2018-12-07 14:57
|
||||
*/
|
||||
public class BaseException extends RuntimeException {
|
||||
private Integer code;
|
||||
private String message;
|
||||
private Object data;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BaseException that = (BaseException) o;
|
||||
return Objects.equals(code, that.code) && Objects.equals(message, that.message) && Objects.equals(data, that.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, message, data);
|
||||
}
|
||||
|
||||
public BaseException(Status status) {
|
||||
super(status.getMessage());
|
||||
this.code = status.getCode();
|
||||
this.message = status.getMessage();
|
||||
}
|
||||
|
||||
public BaseException(Status status, Object data) {
|
||||
this(status);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public BaseException(Integer code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public BaseException(Integer code, String message, Object data) {
|
||||
this(code, message);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.northtecom.visatrack.api.base.exception;
|
||||
|
||||
|
||||
import com.northtecom.visatrack.api.base.web.Status;
|
||||
|
||||
|
||||
public class SecurityException extends BaseException {
|
||||
public SecurityException(Status status) {
|
||||
super(status);
|
||||
}
|
||||
|
||||
public SecurityException(Status status, Object data) {
|
||||
super(status, data);
|
||||
}
|
||||
|
||||
public SecurityException(Integer code, String message) {
|
||||
super(code, message);
|
||||
}
|
||||
|
||||
public SecurityException(Integer code, String message, Object data) {
|
||||
super(code, message, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
} else if (!(o instanceof SecurityException)) {
|
||||
return false;
|
||||
} else {
|
||||
SecurityException other = (SecurityException)o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canEqual(Object other) {
|
||||
return other instanceof SecurityException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SecurityException()";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.northtecom.visatrack.api.base.exception.handler;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.northtecom.visatrack.api.base.exception.BaseException;
|
||||
import com.northtecom.visatrack.api.base.web.ApiResponse;
|
||||
import com.northtecom.visatrack.api.base.web.Status;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public ApiResponse handlerException(Exception e) {
|
||||
if (e instanceof NoHandlerFoundException) {
|
||||
log.error("[Global Exception Handler]NoHandlerFoundException: Method {}, Path {}", ((NoHandlerFoundException) e).getRequestURL(), ((NoHandlerFoundException) e).getHttpMethod());
|
||||
return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND);
|
||||
} else if (e instanceof HttpRequestMethodNotSupportedException) {
|
||||
log.error("[Global Exception Handler]HttpRequestMethodNotSupportedException: Method {}, Support Method {}", ((HttpRequestMethodNotSupportedException) e).getMethod(), JSONUtil.toJsonStr(((HttpRequestMethodNotSupportedException) e).getSupportedHttpMethods()));
|
||||
return ApiResponse.ofStatus(Status.HTTP_BAD_METHOD);
|
||||
} else if (e instanceof MethodArgumentNotValidException) {
|
||||
log.error("[Global Exception Handler]MethodArgumentNotValidException", e);
|
||||
return ApiResponse.of(Status.BAD_REQUEST.getCode(), ((MethodArgumentNotValidException) e).getBindingResult().getAllErrors().get(0).getDefaultMessage(), null);
|
||||
} else if (e instanceof ConstraintViolationException) {
|
||||
log.error("[Global Exception Handler]ConstraintViolationException",e.getMessage());
|
||||
return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage(), null);
|
||||
} else if (e instanceof MethodArgumentTypeMismatchException) {
|
||||
log.error("[Global Exception Handler]MethodArgumentTypeMismatchException: Param name: {}, Error info: {}", ((MethodArgumentTypeMismatchException) e).getName(), ((MethodArgumentTypeMismatchException) e).getMessage());
|
||||
return ApiResponse.ofStatus(Status.PARAM_NOT_MATCH);
|
||||
} else if (e instanceof HttpMessageNotReadableException) {
|
||||
log.error("[Global Exception Handler]HttpMessageNotReadableException: Error info: {}", ((HttpMessageNotReadableException) e).getMessage());
|
||||
return ApiResponse.ofStatus(Status.PARAM_NOT_NULL);
|
||||
// } else if (e instanceof BadCredentialsException) {
|
||||
// log.error("[Global Exception Handler]BadCredentialsException: Error info: {}", e.getMessage());
|
||||
// return ApiResponse.ofStatus(Status.USERNAME_PASSWORD_ERROR);
|
||||
// } else if (e instanceof DisabledException) {
|
||||
// log.error("[Global Exception Handler]BadCredentialsException: Error info: {}", e.getMessage());
|
||||
// return ApiResponse.ofStatus(Status.USER_DISABLED);
|
||||
} else if (e instanceof BaseException) {
|
||||
log.error("[Global Exception Handler]DataManagerException: Status code: {}, Error info: {}", ((BaseException) e).getCode(), e.getMessage());
|
||||
return ApiResponse.ofException((BaseException) e);
|
||||
}
|
||||
|
||||
log.error("[Global Exception Handler]: Error info: {} ", e.getMessage());
|
||||
return ApiResponse.ofStatus(Status.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.northtecom.visatrack.api.base.web;
|
||||
|
||||
import com.northtecom.visatrack.api.base.exception.BaseException;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
public class ApiResponse<T> implements Serializable {
|
||||
private static final long serialVersionUID = 8993485788201922830L;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 返回内容
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
|
||||
/**
|
||||
* 接口请求时间
|
||||
*/
|
||||
private long timestamp;
|
||||
|
||||
|
||||
/**
|
||||
* 无参构造函数
|
||||
*/
|
||||
public ApiResponse() {
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全参构造函数
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回内容
|
||||
* @param data 返回数据
|
||||
*/
|
||||
public ApiResponse(Integer code, String message, T data) {
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造一个自定义的API返回
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param message 返回内容
|
||||
* @param data 返回数据
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static <U> ApiResponse<U> of(Integer code, String message, U data) {
|
||||
return new ApiResponse<>(code, message, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个成功且不带数据的API返回
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static ApiResponse ofSuccess() {
|
||||
return ofSuccess(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个成功且带数据的API返回
|
||||
*
|
||||
* @param data 返回数据
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static <U> ApiResponse<U> ofSuccess(U data) {
|
||||
return ofStatus(Status.SUCCESS, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个成功且自定义消息的API返回
|
||||
*
|
||||
* @param message 返回内容
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static ApiResponse ofMessage(String message) {
|
||||
return of(Status.SUCCESS.getCode(), message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个有状态的API返回
|
||||
*
|
||||
* @param status 状态 {@link Status}
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static ApiResponse ofStatus(Status status) {
|
||||
return ofStatus(status, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个有状态且带数据的API返回
|
||||
*
|
||||
* @param status 状态 {@link IStatus}
|
||||
* @param data 返回数据
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static <U> ApiResponse<U> ofStatus(IStatus status, U data) {
|
||||
return of(status.getCode(), status.getMessage(), data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个异常的API返回
|
||||
*
|
||||
* @param t 异常
|
||||
* @param <T> {@link BaseException} 的子类
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public static <T extends BaseException> ApiResponse ofException(T t) {
|
||||
return of(t.getCode(), t.getMessage(), t.getData());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.northtecom.visatrack.api.base.web;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
|
||||
/**
|
||||
* 自动api响应主体建议
|
||||
*
|
||||
* @author Xie Yang
|
||||
* @date 2022/10/02
|
||||
*/
|
||||
@RestControllerAdvice(basePackages = {"com.northtecom.visatrack.api.controller.api", "com.northtecom.visatrack.api.controller"})
|
||||
public class AutoApiResponseBodyAdvice implements ResponseBodyAdvice {
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter returnType, Class converterType) {
|
||||
// 如果接口返回的类型本身就是 ApiResponse 那就没有必要进行额外的操作,返回false
|
||||
return !returnType.getParameterType().equals(ApiResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
|
||||
if (body instanceof String) {
|
||||
// 如果Controller直接返回String的话,SpringBoot是直接返回,故我们需要手动转换成json。
|
||||
try {
|
||||
return objectMapper.writeValueAsString(ApiResponse.ofSuccess(body.toString()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (body instanceof ApiResponse) {
|
||||
// 如果返回的结果是ResultData对象,直接返回即可。
|
||||
return body;
|
||||
}
|
||||
return ApiResponse.ofSuccess(body);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.northtecom.visatrack.api.base.web;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 常量池
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen
|
||||
* @date Created in 2018-12-10 15:03
|
||||
*/
|
||||
public interface Consts {
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
Integer ENABLE = 1;
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
Integer DISABLE = 0;
|
||||
|
||||
/**
|
||||
* JWT 在 Redis 中保存的key前缀
|
||||
*/
|
||||
String REDIS_JWT_KEY_PREFIX = "security:jwt:";
|
||||
|
||||
/**
|
||||
* 星号
|
||||
*/
|
||||
String SYMBOL_STAR = "*";
|
||||
|
||||
/**
|
||||
* 邮箱符号
|
||||
*/
|
||||
String SYMBOL_EMAIL = "@";
|
||||
|
||||
/**
|
||||
* 默认当前页码
|
||||
*/
|
||||
Integer DEFAULT_CURRENT_PAGE = 1;
|
||||
|
||||
/**
|
||||
* 默认每页条数
|
||||
*/
|
||||
Integer DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 匿名用户 用户名
|
||||
*/
|
||||
String ANONYMOUS_NAME = "匿名用户";
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.northtecom.visatrack.api.base.web;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 错误码接口
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen
|
||||
* @date Created in 2018-12-07 14:35
|
||||
*/
|
||||
public interface IStatus {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*
|
||||
* @return 状态码
|
||||
*/
|
||||
Integer getCode();
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*
|
||||
* @return 返回信息
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.northtecom.visatrack.api.base.web;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 通用状态码
|
||||
* </p>
|
||||
*
|
||||
* @author yangkai.shen
|
||||
* @date Created in 2018-12-07 14:31
|
||||
*/
|
||||
public enum Status implements IStatus {
|
||||
/**
|
||||
* 操作成功!
|
||||
*/
|
||||
SUCCESS(200, "Successful operation!"),
|
||||
|
||||
/**
|
||||
* 操作异常!
|
||||
*/
|
||||
ERROR(500, "Abnormal operation!"),
|
||||
|
||||
/**
|
||||
* 退出成功!
|
||||
*/
|
||||
LOGOUT(200, "Exit successfully!"),
|
||||
|
||||
/**
|
||||
* 请先登录!
|
||||
*/
|
||||
UNAUTHORIZED(401, "please login first!"),
|
||||
|
||||
/**
|
||||
* 暂无权限访问!
|
||||
*/
|
||||
ACCESS_DENIED(403, "Insufficient permissions!"),
|
||||
|
||||
/**
|
||||
* 请求不存在!
|
||||
*/
|
||||
REQUEST_NOT_FOUND(404, "The request address does not exist!"),
|
||||
|
||||
/**
|
||||
* 请求方式不支持!
|
||||
*/
|
||||
HTTP_BAD_METHOD(405, "The request method is not supported!"),
|
||||
|
||||
/**
|
||||
* 请求异常!
|
||||
*/
|
||||
BAD_REQUEST(400, "Request exception!"),
|
||||
|
||||
/**
|
||||
* 参数不匹配!
|
||||
*/
|
||||
PARAM_NOT_MATCH(400, "Parameters do not match!"),
|
||||
|
||||
/**
|
||||
* 参数不能为空!
|
||||
*/
|
||||
PARAM_NOT_NULL(400, "Parameters cannot be empty!"),
|
||||
|
||||
/**
|
||||
* 当前用户已被锁定,请联系管理员解锁!
|
||||
*/
|
||||
USER_DISABLED(403, "The current user has been locked, please contact the administrator to unlock!"),
|
||||
|
||||
/**
|
||||
* 用户名或密码错误!
|
||||
*/
|
||||
USERNAME_PASSWORD_ERROR(5001, "Wrong user name or password!"),
|
||||
|
||||
/**
|
||||
* token 已过期,请重新登录!
|
||||
*/
|
||||
TOKEN_EXPIRED(5002, "The token has expired, please log in again!"),
|
||||
|
||||
/**
|
||||
* token 解析失败,请尝试重新登录!
|
||||
*/
|
||||
TOKEN_PARSE_ERROR(5002, "Token parsing failed, please try to login again!"),
|
||||
|
||||
/**
|
||||
* 当前用户已在别处登录,请尝试更改密码或重新登录!
|
||||
*/
|
||||
TOKEN_OUT_OF_CTRL(5003, "The current user is logged in elsewhere, please try changing the password or logging in again!"),
|
||||
|
||||
/**
|
||||
* 无法手动踢出自己,请尝试退出登录操作!
|
||||
*/
|
||||
KICKOUT_SELF(5004, "Unable to manually kick yourself, try logging out!");
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 返回信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
Status(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static Status fromCode(Integer code) {
|
||||
Status[] statuses = Status.values();
|
||||
for (Status status : statuses) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(" Status:{code=%s, message=%s} ", getCode(), getMessage());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.northtecom.visatrack.api.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/22:24
|
||||
* @Description:
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Configuration
|
||||
@EntityScan(basePackages = "com.northtecom.visatrack.api.data.entity", basePackageClasses = {Jsr310JpaConverters.class})
|
||||
@EnableJpaAuditing
|
||||
public class SpringDataJpaConfig {
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.northtecom.visatrack.api.config;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* spring doc Swagger UI configuration
|
||||
*/
|
||||
@Configuration
|
||||
public class SpringDocConfig {
|
||||
|
||||
@Bean
|
||||
public OpenAPI springOpenAPI() {
|
||||
|
||||
//鉴权组件(随便起名的) 加入Jwt Token输入锁头
|
||||
Components components = new Components()
|
||||
.addSecuritySchemes("bearer-jwt", new SecurityScheme()
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.scheme("bearer")
|
||||
.bearerFormat("JWT")
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.name("Authorization"));
|
||||
|
||||
//鉴权限制要求 要求API鉴权
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement()
|
||||
.addList("bearer-jwt", Arrays.asList("read", "write"));
|
||||
|
||||
|
||||
return new OpenAPI().components(components)
|
||||
.info(new Info()
|
||||
.title("Us Visa Track API")
|
||||
.description("Us Visa Track API")
|
||||
.version("v1.0.0")
|
||||
.license(new License().name("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("Us Visa Track API Documentation")
|
||||
.url("https://about.gitlab.com/"))
|
||||
.addSecurityItem(securityRequirement);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.northtecom.visatrack.api.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.northtecom.visatrack.api.controller.vo.UserLoginRequest;
|
||||
import com.northtecom.visatrack.api.controller.vo.UserLoginResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/15:59
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
public AuthController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@ResponseBody
|
||||
public UserLoginResponse customLogin(@RequestBody @Valid UserLoginRequest userLoginRequest) throws JsonProcessingException {
|
||||
log.debug("Login Request: {}", this.objectMapper.writeValueAsString(userLoginRequest));
|
||||
|
||||
|
||||
|
||||
UserLoginResponse userLoginResponse = new UserLoginResponse();
|
||||
// userLoginResponse.setUserName(userDetail.getSurname());
|
||||
// userLoginResponse.setUserId(userDetail.getId());
|
||||
// userLoginResponse.setEmail(userDetail.getUsername());
|
||||
userLoginResponse.setLoginDateTime(new Date());
|
||||
// userLoginResponse.setToken(token);
|
||||
|
||||
return userLoginResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.northtecom.visatrack.api.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/13:30
|
||||
* @Description:
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/home")
|
||||
public class HomeController {
|
||||
|
||||
@GetMapping("/index")
|
||||
public String index() {
|
||||
log.info("call index");
|
||||
return "Hello World 121221!"+System.currentTimeMillis();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.northtecom.visatrack.api.controller.api;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/16:01
|
||||
* @Description:
|
||||
*/
|
||||
public class CrawController {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.northtecom.visatrack.api.controller.api;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/08/16:01
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
public class VisaController {
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.northtecom.visatrack.api.controller.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/01/17:15
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserLoginRequest {
|
||||
@NotBlank(message = "User login email can not be empty!")
|
||||
private String userEmail;
|
||||
@NotBlank(message = "Password can not be empty!")
|
||||
private String password;
|
||||
private Boolean rememberMe;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.northtecom.visatrack.api.controller.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/02/8:45
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class UserLoginResponse {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String email;
|
||||
private String token;
|
||||
private Date loginDateTime;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Blog Entity Obj
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "blog")
|
||||
@org.hibernate.annotations.Table(appliesTo = "blog", comment = "Blog")
|
||||
public class Blog extends BaseEntity<Long> {
|
||||
@Column(name = "author_name", columnDefinition = "varchar(255) COMMENT 'Author name'")
|
||||
private String authorName;
|
||||
@Column(name = "title", columnDefinition = "varchar(255) COMMENT 'Title'")
|
||||
private String blogTitle;
|
||||
@Column(name = "content", columnDefinition = "TEXT COMMENT 'Content'")
|
||||
private String blogCover;
|
||||
@Column(name = "cover", columnDefinition = "varchar(255) COMMENT 'Cover'")
|
||||
private String blogSummary;
|
||||
@Column(name = "summary", columnDefinition = "LONGTEXT COMMENT 'Summary'")
|
||||
private String blogContent;
|
||||
@Type(type = "json")
|
||||
@Column(columnDefinition = "json")
|
||||
private List<String> keywords;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import com.northtecom.visatrack.api.service.enums.UserStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "user",uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames={"user_name"}),
|
||||
@UniqueConstraint(columnNames={"user_email"})
|
||||
})
|
||||
@org.hibernate.annotations.Table(appliesTo = "user", comment = "Customer user for us visa track")
|
||||
public class User extends BaseEntity<Long> {
|
||||
|
||||
/**
|
||||
* User name
|
||||
*/
|
||||
@Column(name = "user_name", columnDefinition = "varchar(255) COMMENT 'User name'")
|
||||
private String userName;
|
||||
/**
|
||||
* User password
|
||||
*/
|
||||
@Column(name = "user_password", columnDefinition = "varchar(255) COMMENT 'User password'")
|
||||
private String userPassword;
|
||||
/**
|
||||
* User email
|
||||
*/
|
||||
@Column(name = "user_email", columnDefinition = "varchar(255) COMMENT 'User email'")
|
||||
private String userEmail;
|
||||
/**
|
||||
* User email verified code
|
||||
*/
|
||||
@Column(name = "user_email_verified_code", columnDefinition = "varchar(255) COMMENT 'User email verified code'")
|
||||
private String emailVerifiedCode;
|
||||
/**
|
||||
* User email verified
|
||||
*/
|
||||
@Column(name = "is_email_verified", columnDefinition = "BIT(1) DEFAULT(0) COMMENT 'User email verified'")
|
||||
private Boolean isEmailVerified;
|
||||
/**
|
||||
* User status
|
||||
*/
|
||||
@Column(name = "user_status", columnDefinition = "INT COMMENT 'User status'")
|
||||
@Enumerated(value = EnumType.ORDINAL)
|
||||
private UserStatus userStatus;
|
||||
/**
|
||||
* User register time
|
||||
*/
|
||||
@Column(name = "date_registered", columnDefinition = "DATE COMMENT 'User register time'")
|
||||
private LocalDateTime dateRegistered;
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import com.northtecom.visatrack.api.service.enums.VisaEntry;
|
||||
import com.northtecom.visatrack.api.service.enums.VisaStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
* Xie yang changed 2018-11-20
|
||||
* 移除外键关联,改成直接存储字符串的形式弱关联
|
||||
* 支持用户匿名提交数据,简化用户注册流程以及代码复杂度
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "visa_case")
|
||||
@org.hibernate.annotations.Table(appliesTo = "visa_case", comment = "Visa case")
|
||||
public class VisaCase extends BaseEntity<Long> {
|
||||
/**
|
||||
* ds160 code
|
||||
* The DS-160, Online Nonimmigrant Visa Application form, is for temporary travel to the United States, and for K (fiancé(e)) visas. Form DS-160 is submitted electronically to the Department of State
|
||||
* website via the Internet. Consular Officers use the information entered on the DS-160 to process the visa application and, combined with a personal interview, determine an applicant’s eligibility
|
||||
* for a nonimmigrant visa.
|
||||
*/
|
||||
@Column(name = "ds160_code", columnDefinition = "varchar(255) COMMENT 'ds160 code'")
|
||||
private String ds160Code;
|
||||
/**
|
||||
* User name
|
||||
*/
|
||||
@Column(name = "user_name", columnDefinition = "varchar(255) COMMENT 'User name'")
|
||||
private String userName;
|
||||
/**
|
||||
* User email
|
||||
*/
|
||||
@Column(name = "user_email", columnDefinition = "varchar(255) COMMENT 'User email'")
|
||||
private String userEmail;
|
||||
/**
|
||||
* Visa category
|
||||
*/
|
||||
@Column(name = "visa_category", columnDefinition = "varchar(255) COMMENT 'visa category'")
|
||||
private String visaCategory;
|
||||
/**
|
||||
* Embassy consulate
|
||||
*/
|
||||
@Column(name = "embassy_consulate", columnDefinition = "varchar(255) COMMENT 'embassy consulate'")
|
||||
private String embassyConsulate;
|
||||
|
||||
/**
|
||||
* Visa status
|
||||
*/
|
||||
@Column(name = "visa_status", columnDefinition = "INT COMMENT 'Visa status'")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private VisaStatus visaStatus;
|
||||
/**
|
||||
* Visa entry
|
||||
*/
|
||||
@Column(name = "visa_entry", columnDefinition = "INT COMMENT 'Visa entry'")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private VisaEntry visaEntry;
|
||||
/**
|
||||
* College major
|
||||
*/
|
||||
@Column(name = "major", columnDefinition = "varchar(255) COMMENT 'college major'")
|
||||
private String major;
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
@Column(name = "description", columnDefinition = "varchar(2000) COMMENT 'description'")
|
||||
private String description;
|
||||
/**
|
||||
* Visa interview date
|
||||
*/
|
||||
@Column(name = "date_visa_interview", columnDefinition = "datetime COMMENT 'visa interview date'")
|
||||
private LocalDate dateVisaInterview;
|
||||
/**
|
||||
* Visa check completed date
|
||||
*/
|
||||
@Column(name = "date_visa_check_completed", columnDefinition = "datetime COMMENT 'visa check completed date'")
|
||||
private LocalDate dateVisaCheckCompleted;
|
||||
/**
|
||||
* Visa issued date
|
||||
*/
|
||||
@Column(name = "date_visa_issued", columnDefinition = "datetime COMMENT 'visa issued date'")
|
||||
private LocalDate dateVisaIssued;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/05/20:00
|
||||
* @Description:
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "visa_checkee_crawl_data",uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames={"case_num"})
|
||||
})
|
||||
public class VisaCheckeeCrawlData extends BaseEntity<Long> {
|
||||
|
||||
@Column(name = "case_num", columnDefinition = "varchar(50) COMMENT 'case number'")
|
||||
private String caseNum;
|
||||
@Column(name = "user_id", columnDefinition = "varchar(50) COMMENT 'user id'")
|
||||
private String userId;
|
||||
@Column(name = "check_date", columnDefinition = "Date COMMENT 'check date'")
|
||||
private java.util.Date checkDate;
|
||||
@Column(name = "visa_type", columnDefinition = "varchar(50) COMMENT 'visa type'")
|
||||
private String visaType;
|
||||
@Column(name = "visa_entry", columnDefinition = "varchar(50) COMMENT 'visa entry'")
|
||||
private String visaEntry;
|
||||
@Column(name = "consulate", columnDefinition = "varchar(50) COMMENT 'consulate'")
|
||||
private String consulate;
|
||||
@Column(name = "major", columnDefinition = "varchar(50) COMMENT 'major'")
|
||||
private String major;
|
||||
@Column(name = "status", columnDefinition = "varchar(50) COMMENT 'status'")
|
||||
private String status;
|
||||
@Column(name = "complete_date", columnDefinition = "Date COMMENT 'complete date'")
|
||||
private java.util.Date completeDate;
|
||||
@Column(name = "note", columnDefinition = "varchar(2000) COMMENT 'note'")
|
||||
private String note;
|
||||
@Column(name = "last_name", columnDefinition = "varchar(50) COMMENT 'last name'")
|
||||
private String lastName;
|
||||
@Column(name = "first_name", columnDefinition = "varchar(50) COMMENT 'first name'")
|
||||
private String firstName;
|
||||
@Column(name = "university", columnDefinition = "varchar(50) COMMENT 'university'")
|
||||
private String university;
|
||||
@Column(name = "degree", columnDefinition = "varchar(50) COMMENT 'degree'")
|
||||
private String degree;
|
||||
@Column(name = "employer", columnDefinition = "varchar(50) COMMENT 'employer'")
|
||||
private String employer;
|
||||
@Column(name = "job_title", columnDefinition = "varchar(50) COMMENT 'job title'")
|
||||
private String jobTitle;
|
||||
@Column(name = "years_in_usa", columnDefinition = "varchar(50) COMMENT 'years in usa'")
|
||||
private String yearsInUsa;
|
||||
@Column(name = "country", columnDefinition = "varchar(50) COMMENT 'country'")
|
||||
private String country;
|
||||
@Column(name = "part_email", columnDefinition = "varchar(50) COMMENT 'part email'")
|
||||
private String partEmail;
|
||||
@Column(name = "save_to_visa_case_id", columnDefinition = "LONG COMMENT 'Save to visa case id'")
|
||||
private Long saveToVisaCaseId;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/04/20:00
|
||||
* @Description:
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "visa_checkee_crawl_html",uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames={"crawl_key"})
|
||||
})
|
||||
@org.hibernate.annotations.Table(appliesTo = "visa_checkee_crawl_html", comment = "Visa case checkee crawl html")
|
||||
public class VisaCheckeeCrawlHtml extends BaseEntity<Long> {
|
||||
|
||||
public static final String CRAWL_KEY_REPORT_LIST = "report_list";
|
||||
public static final String CRAWL_KEY_REPORT_DETAIL_LIST = "report_detail_list";
|
||||
public static final String CRAWL_KEY_VISA_DETAIL = "visa_detail";
|
||||
public static final String CRAWL_KEY_VISA_UPDATE = "visa_update";
|
||||
/**
|
||||
* Crawl key
|
||||
*/
|
||||
@Column(name = "crawl_key", columnDefinition = "varchar(255) comment 'crawl key'")
|
||||
private String crawlKey;
|
||||
/**
|
||||
* Crawl date
|
||||
*/
|
||||
@Column(name = "crawl_date", columnDefinition = "datetime comment 'crawl date'")
|
||||
private Date crawlDate;
|
||||
/**
|
||||
* Crawl html content
|
||||
*/
|
||||
@Column(name = "content", columnDefinition = "LONGTEXT comment 'crawl html content'")
|
||||
private String content;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.northtecom.visatrack.api.data.entity;
|
||||
|
||||
import com.northtecom.visatrack.api.base.data.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/04/19:59
|
||||
* @Description:
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "visa_report_checkee_crawl_data",uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames={"month"})
|
||||
})
|
||||
@org.hibernate.annotations.Table(appliesTo = "visa_report_checkee_crawl_data", comment = "Visa case report checkee crawl data")
|
||||
public class VisaReportCheckeeCrawlData extends BaseEntity<Long> {
|
||||
/**
|
||||
* report month
|
||||
* eg: 2021-10
|
||||
*/
|
||||
@Column(name = "month",nullable = false, columnDefinition = "varchar(10) comment 'report month'")
|
||||
private String month;
|
||||
|
||||
/**
|
||||
* Pending case count
|
||||
*/
|
||||
@Column(name = "pending_case_count", columnDefinition = "INT COMMENT 'Pending case count'")
|
||||
private Integer pendingCaseCount;
|
||||
|
||||
/**
|
||||
* Clear case count
|
||||
*/
|
||||
@Column(name = "clear_case_count", columnDefinition = "INT COMMENT 'Clear case count'")
|
||||
private Integer clearCaseCount;
|
||||
|
||||
/**
|
||||
* Reject case count
|
||||
*/
|
||||
@Column(name = "reject_case_count", columnDefinition = "INT COMMENT 'Reject case count'")
|
||||
private Integer rejectCaseCount;
|
||||
|
||||
/**
|
||||
* Total case count
|
||||
*/
|
||||
@Column(name = "total_case_count", columnDefinition = "INT COMMENT 'Total case count'")
|
||||
private Integer totalCaseCount;
|
||||
|
||||
/**
|
||||
* Ave. Waiting Days for Complete Cases
|
||||
*/
|
||||
@Column(name = "ave_waiting_days_for_complete_cases", columnDefinition = "INT COMMENT 'Ave. Waiting Days for Complete Cases'")
|
||||
private Integer AveWaitingDaysForCompleteCases;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.northtecom.visatrack.api.data.repository;
|
||||
|
||||
import com.northtecom.visatrack.api.data.entity.VisaCheckeeCrawlData;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/05/20:13
|
||||
* @Description:
|
||||
*/
|
||||
public interface VisaCheckeeCrawlDataRepository extends JpaRepository<VisaCheckeeCrawlData, Long> {
|
||||
Optional<VisaCheckeeCrawlData> findByCaseNum(String caseNum);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.northtecom.visatrack.api.data.repository;
|
||||
|
||||
import com.northtecom.visatrack.api.data.entity.VisaCheckeeCrawlHtml;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/04/20:05
|
||||
* @Description:
|
||||
*/
|
||||
public interface VisaCheckeeCrawlHtmlRepository extends JpaRepository<VisaCheckeeCrawlHtml, Long> {
|
||||
@Query("select vh from VisaCheckeeCrawlHtml vh where vh.crawlKey = :crawlKey order by vh.crawlDate desc")
|
||||
Optional<VisaCheckeeCrawlHtml> findLatestCrawlHtml(@Param("crawlKey") String crawlKey);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.northtecom.visatrack.api.data.repository;
|
||||
|
||||
import com.northtecom.visatrack.api.data.entity.VisaReportCheckeeCrawlData;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Author: XieYang
|
||||
* @Date: 2022/10/04/20:12
|
||||
* @Description:
|
||||
*/
|
||||
public interface VisaReportCheckeeCrawlDataRepository extends JpaRepository<VisaReportCheckeeCrawlData, Long> {
|
||||
Optional<VisaReportCheckeeCrawlData> findByMonth(String month);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.northtecom.visatrack.api.service.enums;
|
||||
|
||||
/**
|
||||
* EmbassyConsulatesType
|
||||
*/
|
||||
public enum EmbassyConsulatesType {
|
||||
EMBASSY, CONSULATES
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.northtecom.visatrack.api.service.enums;
|
||||
|
||||
/**
|
||||
* VisaStatus Enum
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public enum UserStatus {
|
||||
ACTIVATED, NEEDVERIFY
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.northtecom.visatrack.api.service.enums;
|
||||
|
||||
/**
|
||||
* VisaEntry Enum
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public enum VisaEntry {
|
||||
NEW, RENEWAL
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.northtecom.visatrack.api.service.enums;
|
||||
|
||||
/**
|
||||
* VisaStatus Enum
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*
|
||||
*/
|
||||
public enum VisaStatus {
|
||||
NOSTATUS, READY, ADMINISTRATIVE_PROCESSING, CLEAR, ISSUED, REFUSED
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
server:
|
||||
port: 8282
|
||||
spring:
|
||||
application:
|
||||
name: usvisatrack
|
||||
datasource:
|
||||
username: root
|
||||
password: asdf@123
|
||||
url: jdbc:mariadb://localhost:3316/northtecom.usvisatrack?serverTimezone=EST&useUnicode=true&characterEncoding=UTF8MB64&autoReconnect=true
|
||||
driver-class-name: org.mariadb.jdbc.Driver
|
||||
jpa:
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
open-in-view: false
|
|
@ -0,0 +1,13 @@
|
|||
package com.northtecom.visatrack.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class VisaTrackApiApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue