init
This commit is contained in:
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -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/
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
#FROM eclipse-temurin:17.0.6_10-jre-alpine
|
||||
FROM public.ecr.aws/docker/library/eclipse-temurin:17.0.16_8-jre-alpine-3.22
|
||||
ARG JAR_FILE=target/*.jar
|
||||
COPY ${JAR_FILE} app.jar
|
||||
COPY target/classes/kafka_client.p12 kafka_client.p12
|
||||
COPY target/classes/kafka_client.pem kafka_client.pem
|
||||
ENTRYPOINT ["java", "-jar", "--add-opens", "java.base/java.io=ALL-UNNAMED", "/app.jar"]
|
||||
316
mvnw
vendored
Normal file
316
mvnw
vendored
Normal file
@@ -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 "$@"
|
||||
188
mvnw.cmd
vendored
Normal file
188
mvnw.cmd
vendored
Normal file
@@ -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%
|
||||
289
pom.xml
Normal file
289
pom.xml
Normal file
@@ -0,0 +1,289 @@
|
||||
<?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>3.1.12</version>-->
|
||||
<version>3.3.13</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>MDMDS-PROD-BS</artifactId>
|
||||
<version>0.0.6</version>
|
||||
<name>MDMDS-PROD-BS</name>
|
||||
<description>MDMDS-PROD-BS</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<keycloak.version>10.0.0</keycloak.version>
|
||||
<protobuf.version>4.31.0</protobuf.version>
|
||||
<!-- <tomcat.version>10.1.35</tomcat.version>-->
|
||||
<tomcat.version>10.1.45</tomcat.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-tracing-bridge-brave</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>42.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>6.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.26</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>8.0.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-apt</artifactId>
|
||||
<classifier>jakarta</classifier>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<classifier>jakarta</classifier>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 这个包是专门给rest service用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
<version>9.37.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.14.0-rc2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.0.1-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>${protobuf.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.8.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun-maven</id>
|
||||
<name>阿里云公共仓库</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.volkswagen.mdmds;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableAsync
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class MdmdsProdBsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MdmdsProdBsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
104
src/main/java/com/volkswagen/mdmds/aop/RequestSecurity.java
Normal file
104
src/main/java/com/volkswagen/mdmds/aop/RequestSecurity.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.volkswagen.mdmds.aop;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volkswagen.mdmds.model.dto.AuditDTO;
|
||||
import com.volkswagen.mdmds.service.AuditService;
|
||||
import com.volkswagen.mdmds.utils.IPUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(-10)
|
||||
public class RequestSecurity {
|
||||
|
||||
@Resource
|
||||
private AuditService auditService;
|
||||
|
||||
private static final Integer LOG_MESSAGE_SIZE = 1024;
|
||||
|
||||
@Pointcut("execution(* com.volkswagen.mdmds.controller..*.*(..)) ")
|
||||
private void requestLog() {
|
||||
|
||||
}
|
||||
|
||||
@Around("requestLog()")
|
||||
private Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
Object result = null;
|
||||
// 请求
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if(attributes == null) {
|
||||
return null;
|
||||
}
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
String reqURI = request.getRequestURI();
|
||||
String reqMethod = request.getMethod();
|
||||
// 请求方法名
|
||||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = methodSignature.getMethod();
|
||||
String reqMethodName = method.getName();
|
||||
// 请求参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
// 封装日志对象
|
||||
AuditDTO auditDTO = new AuditDTO();
|
||||
auditDTO.setReqIP(IPUtil.getIpAddress(request));
|
||||
auditDTO.setReqURI(reqURI);
|
||||
auditDTO.setReqMethod(reqMethod);
|
||||
auditDTO.setReqMethodName(reqMethodName);
|
||||
String reqParams = getJsonString(args);
|
||||
auditDTO.setReqParams(reqParams.length() > LOG_MESSAGE_SIZE ? reqParams.substring(0, LOG_MESSAGE_SIZE) : reqParams);
|
||||
// 执行请求
|
||||
Instant startTime = Instant.now();
|
||||
auditDTO.setStartTime(Date.from(startTime));
|
||||
try {
|
||||
result = joinPoint.proceed();
|
||||
Instant endTime = Instant.now();
|
||||
auditDTO.setEndTime(Date.from(endTime));
|
||||
auditService.insertOne(auditDTO);
|
||||
} catch (Throwable throwable) {
|
||||
String log = throwable.getMessage();
|
||||
if(log != null) {
|
||||
auditDTO.setLog(log.length() > LOG_MESSAGE_SIZE ? log.substring(0, LOG_MESSAGE_SIZE) : log);
|
||||
} else {
|
||||
auditDTO.setLog("");
|
||||
}
|
||||
Instant endTime = Instant.now();
|
||||
auditDTO.setEndTime(Date.from(endTime));
|
||||
auditService.insertOne(auditDTO);
|
||||
throw throwable;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getJsonString(Object[] args) {
|
||||
Gson gson = new Gson();
|
||||
//遍历所有参数,判断参数的对象是不是包内的和基础对象,不是的话就不用序列化了
|
||||
List<Object> list = new ArrayList<>();
|
||||
for (Object arg : args) {
|
||||
if (arg != null && StringUtils.startsWithAny(arg.getClass().getName(),"com.volkswagen.mdmds","java.lang")) {
|
||||
list.add(arg);
|
||||
} else {
|
||||
list.add(null);
|
||||
}
|
||||
}
|
||||
return gson.toJson(list);
|
||||
}
|
||||
|
||||
}
|
||||
27
src/main/java/com/volkswagen/mdmds/config/BeanConfig.java
Normal file
27
src/main/java/com/volkswagen/mdmds/config/BeanConfig.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@Configuration
|
||||
public class BeanConfig {
|
||||
|
||||
@Bean
|
||||
public ModelMapper modelMapper() {
|
||||
return new ModelMapper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ExecutorService httpFixedExecutors() {
|
||||
return Executors.newFixedThreadPool(5);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/7
|
||||
*/
|
||||
@Component("myAuthenticationEntryPoint")
|
||||
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
OutputStream responseStream = response.getOutputStream();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", HttpStatus.UNAUTHORIZED.value());
|
||||
result.put("message", HttpStatus.UNAUTHORIZED.getReasonPhrase());
|
||||
mapper.writeValue(responseStream, result);
|
||||
responseStream.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import com.nimbusds.jose.Payload;
|
||||
import com.nimbusds.jwt.SignedJWT;
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException;
|
||||
import org.springframework.security.oauth2.server.resource.web.BearerTokenResolver;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Base64;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CustomBearerTokenResolver implements BearerTokenResolver {
|
||||
|
||||
private final JwtAuthConverterProperties properties;
|
||||
|
||||
@Override
|
||||
public String resolve(HttpServletRequest request) {
|
||||
// 从请求头中获取 Authorization 头
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if(authorization==null){
|
||||
return null;
|
||||
}
|
||||
String tokenValue = new String(Base64.getDecoder().decode(authorization));
|
||||
|
||||
if (tokenValue.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 检查是否以 "Bearer" 开头
|
||||
if (tokenValue.startsWith("Bearer ")) {
|
||||
return tokenValue.substring(7); // 去掉 "Bearer " 前缀
|
||||
}
|
||||
|
||||
throw new InvalidBearerTokenException("Invalid Bearer token format");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/22
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "dt-api")
|
||||
public class DTConfiguration {
|
||||
private String url;
|
||||
private String oauthUrl;
|
||||
private String authType;
|
||||
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String scope;
|
||||
private String grantType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "hw-api")
|
||||
public class HWConfiguration {
|
||||
|
||||
private String url;
|
||||
private String oauthUrl;
|
||||
|
||||
private Integer clientId;
|
||||
private String clientSecret;
|
||||
private String grantType;
|
||||
private String scopes;
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
src/main/java/com/volkswagen/mdmds/config/JapConfig.java
Normal file
21
src/main/java/com/volkswagen/mdmds/config/JapConfig.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import com.volkswagen.mdmds.utils.AuditorAwareImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/8
|
||||
*/
|
||||
@Configuration
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
public class JapConfig {
|
||||
|
||||
@Bean
|
||||
public AuditorAware<String> auditorAware() {
|
||||
return new AuditorAwareImpl();
|
||||
}
|
||||
}
|
||||
140
src/main/java/com/volkswagen/mdmds/config/JwtAuthConverter.java
Normal file
140
src/main/java/com/volkswagen/mdmds/config/JwtAuthConverter.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
|
||||
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.constant.CommonField;
|
||||
import com.volkswagen.mdmds.model.entity.DicResource;
|
||||
import com.volkswagen.mdmds.model.entity.RoleInfo;
|
||||
import com.volkswagen.mdmds.repos.RoleInfoRepository;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.oauth2.jwt.JwtClaimNames;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/3
|
||||
*/
|
||||
@Component
|
||||
public class JwtAuthConverter implements Converter<Jwt, AbstractAuthenticationToken> {
|
||||
private final JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
|
||||
private final JwtAuthConverterProperties properties;
|
||||
|
||||
@Resource
|
||||
private RoleInfoRepository roleInfoRepository;
|
||||
|
||||
public JwtAuthConverter(JwtAuthConverterProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractAuthenticationToken convert(Jwt jwt) {
|
||||
Collection<GrantedAuthority> grantedAuthorities = jwtGrantedAuthoritiesConverter.convert(jwt);
|
||||
if(grantedAuthorities == null) {
|
||||
throw new MdmdsException(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
Collection<GrantedAuthority> authorities = Stream.concat(
|
||||
grantedAuthorities.stream(),
|
||||
extractResourceRoles(jwt).stream()).collect(Collectors.toSet());
|
||||
return new JwtAuthenticationToken(jwt, authorities, getPrincipalClaimName(jwt));
|
||||
}
|
||||
|
||||
private String getPrincipalClaimName(Jwt jwt) {
|
||||
String claimName = JwtClaimNames.SUB;
|
||||
if (properties.getPrincipalAttribute() != null) {
|
||||
claimName = properties.getPrincipalAttribute();
|
||||
}
|
||||
return jwt.getClaim(claimName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用来从JWT中提取角色信息
|
||||
* @param jwt
|
||||
* @return
|
||||
*/
|
||||
private Collection<? extends GrantedAuthority> extractResourceRoles(Jwt jwt) {
|
||||
//idp用的realm角色
|
||||
/**
|
||||
* "realm_access": {
|
||||
* "roles": [
|
||||
* "CLOUDIDP_EHR_ADMIN"
|
||||
* ]
|
||||
*/
|
||||
Set<SimpleGrantedAuthority> roleGrant = new HashSet<>();
|
||||
if(jwt.hasClaim("resource_access")) {
|
||||
// 公司内部测试认证平台
|
||||
// addRoleGrantInner(jwt, roleGrant);
|
||||
// 个人测试认证平台
|
||||
addRoleGrantIDP(jwt, roleGrant);
|
||||
} else {
|
||||
// IDP认证平台
|
||||
addRoleGrantIDP(jwt, roleGrant);
|
||||
}
|
||||
return roleGrant;
|
||||
}
|
||||
|
||||
private void addRoleGrantInner(Jwt jwt, Set<SimpleGrantedAuthority> roleGrant) {
|
||||
Map<String, Object> resourceAccess = jwt.getClaim("resource_access");
|
||||
if (resourceAccess != null && resourceAccess.containsKey(properties.getResourceId())) {
|
||||
Map<String, Object> resource = (Map<String, Object>) resourceAccess.get(properties.getResourceId());
|
||||
if(resource != null) {
|
||||
List<String> resourceRoles = (List<String>) resource.get(CommonField.RES_ROLES);
|
||||
// 查询IDP角色对应的系统角色
|
||||
Set<String> innerRoleSet = assembleInnerRoleName(resourceRoles);
|
||||
if(!innerRoleSet.isEmpty()) {
|
||||
Set<SimpleGrantedAuthority> collect = innerRoleSet.stream().map(role -> new SimpleGrantedAuthority(CommonField.ROLE_PREFIX + role)).collect(Collectors.toSet());
|
||||
roleGrant.addAll(collect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> assembleInnerRoleName(List<String> roleNameList) {
|
||||
Set<String> innerRoleSet = new HashSet<>();
|
||||
// List<Optional<RoleInfo>> roleInfoList = roleInfoRepository.findByRoleNameIn(roleNameList);
|
||||
List<Map<String,Object>> resources = roleInfoRepository.findResourceInRoleName(roleNameList);
|
||||
for(Map<String, Object> item : resources) {
|
||||
if(CommonField.VIEW_MENU.containsKey(item.get("resname"))) {
|
||||
innerRoleSet.add(CommonField.VIEW_MENU.get(item.get("resname")));
|
||||
}
|
||||
}
|
||||
// for(Optional<RoleInfo> optionalRoleInfo : roleInfoList) {
|
||||
// if(!optionalRoleInfo.isEmpty()) {
|
||||
// String innerRole = optionalRoleInfo.get().getInnerRole();
|
||||
// if(!innerRole.isEmpty()) {
|
||||
// innerRoleSet.addAll(Arrays.asList(innerRole.split(",")));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return innerRoleSet;
|
||||
}
|
||||
|
||||
private void addRoleGrantIDP(Jwt jwt, Set<SimpleGrantedAuthority> roleGrant) {
|
||||
if(jwt.hasClaim("realm_access")) {
|
||||
Map<String, Object> realmAccess = jwt.getClaim("realm_access");
|
||||
if (realmAccess != null && realmAccess.containsKey(CommonField.RES_ROLES)) {
|
||||
List<String> realmRoles = (List<String>) realmAccess.get(CommonField.RES_ROLES);
|
||||
if (realmRoles != null) {
|
||||
// 查询IDP角色对应的系统角色
|
||||
Set<String> innerRoleSet = assembleInnerRoleName(realmRoles);
|
||||
if(!innerRoleSet.isEmpty()) {
|
||||
Set<SimpleGrantedAuthority> collect = innerRoleSet.stream().map(role -> new SimpleGrantedAuthority(CommonField.ROLE_PREFIX + role)).collect(Collectors.toSet());
|
||||
roleGrant.addAll(collect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/3
|
||||
*/
|
||||
@Data
|
||||
@Validated
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "jwt.auth.converter")
|
||||
public class JwtAuthConverterProperties {
|
||||
private String resourceId;
|
||||
private String principalAttribute;
|
||||
private String uniqueAttribute;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import com.nimbusds.jose.JWSHeader;
|
||||
import com.nimbusds.jose.Payload;
|
||||
import com.nimbusds.jwt.SignedJWT;
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.controller.api.PermissionApi;
|
||||
import com.volkswagen.mdmds.model.dto.UserSessionDTO;
|
||||
//import com.volkswagen.mdmds.service.UserService;
|
||||
//import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
// @Resource
|
||||
// private UserService userService;
|
||||
|
||||
private final JwtAuthConverterProperties properties;
|
||||
|
||||
|
||||
private static Set<String> URL_FILTER_SET = new HashSet<>();
|
||||
|
||||
static {
|
||||
URL_FILTER_SET.add(PermissionApi.Constants.USER_PATH + "/login");
|
||||
URL_FILTER_SET.add(PermissionApi.Constants.USER_PATH + "/sameUserOnline");
|
||||
URL_FILTER_SET.add(PermissionApi.Constants.USER_PATH + "/logout");
|
||||
URL_FILTER_SET.add(PermissionApi.Constants.USER_PATH + "/forceLogin");
|
||||
URL_FILTER_SET.add(PermissionApi.Constants.USER_PATH + "/invalidToken");
|
||||
}
|
||||
|
||||
// token 黑名单
|
||||
public static Map<String, Instant> blackTokenMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static Map<String, UserSessionDTO> userSessionMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
|
||||
throws ServletException, IOException {
|
||||
String requestURI = request.getRequestURI();
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if(null==authorization){
|
||||
//没登录,放掉
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
String deviceId = request.getHeader(properties.getUniqueAttribute());
|
||||
if (StringUtils.isEmpty(deviceId)) {
|
||||
throw new MdmdsException("deviceId not found", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
String tokenValue = new String(Base64.getDecoder().decode(authorization)).replace("Bearer ","");
|
||||
if (blackTokenMap.containsKey(tokenValue) && blackTokenMap.get(tokenValue).isAfter(Instant.now())) {
|
||||
throw new MdmdsException("token is invalid", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
try {
|
||||
SignedJWT signedJWT = SignedJWT.parse(tokenValue);
|
||||
JWSHeader header = signedJWT.getHeader();
|
||||
Map<String, Object> headerJSONObject = header.toJSONObject();
|
||||
|
||||
Payload payload = signedJWT.getPayload();
|
||||
Map<String, Object> payloadJSONObject = payload.toJSONObject();
|
||||
Instant issuedAt = Instant.ofEpochSecond((long)payloadJSONObject.get("iat"));
|
||||
Instant expiresAt = Instant.ofEpochSecond((long) payloadJSONObject.get("exp"));
|
||||
payloadJSONObject.put(properties.getUniqueAttribute(), deviceId);
|
||||
String username = (String) payloadJSONObject.get(properties.getPrincipalAttribute());
|
||||
Instant now = Instant.now();
|
||||
// 如果不包含该用户,或者该用户已过期,则添加该用户
|
||||
if (!URL_FILTER_SET.contains(requestURI)) {
|
||||
if (!userSessionMap.containsKey(username) || userSessionMap.get(username).getExp().isBefore(now)) {
|
||||
UserSessionDTO userSessionDTO = new UserSessionDTO(username, deviceId, expiresAt);
|
||||
userSessionMap.put(username,userSessionDTO);
|
||||
} else {// 判断是否为同一设备
|
||||
if (!userSessionMap.get(username).getDeviceId().equals(deviceId)) {
|
||||
throw new MdmdsException("The same user is online. Procedure", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
log.error("token conversion failure:{}", e.getMessage());
|
||||
throw new MdmdsException("token conversion failure:{}", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/22
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "ms-api")
|
||||
public class MSConfiguration {
|
||||
private String url;
|
||||
private String oauthUrl;
|
||||
private String authType;
|
||||
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String scope;
|
||||
private String grantType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import org.hibernate.dialect.MariaDBDialect;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/17
|
||||
*/
|
||||
public class MyMariaCustomDialect extends MariaDBDialect {
|
||||
}
|
||||
45
src/main/java/com/volkswagen/mdmds/config/OpenApiConfig.java
Normal file
45
src/main/java/com/volkswagen/mdmds/config/OpenApiConfig.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
|
||||
import io.swagger.v3.oas.annotations.info.Contact;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityScheme;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@Configuration
|
||||
@SecurityScheme(
|
||||
name = "Bearer Authentication",
|
||||
type = SecuritySchemeType.HTTP,
|
||||
bearerFormat = "JWT",
|
||||
scheme = "bearer"
|
||||
)
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "MDMDS API",
|
||||
version = "${api.version}",
|
||||
contact = @Contact(
|
||||
name = "Ding,Shuo", email = "shuo.ding@t-systems.com", url = "https://xx.com"
|
||||
),
|
||||
termsOfService = "${tos.uri}",
|
||||
description = "${api.description}"
|
||||
)
|
||||
)
|
||||
public class OpenApiConfig {
|
||||
@Bean
|
||||
// @Profile("!prod")
|
||||
public GroupedOpenApi publicApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("MDMDS")
|
||||
.packagesToScan("com.volkswagen.mdmds.controller")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/22
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "vwac-api")
|
||||
public class VWACConfiguration {
|
||||
private String url;
|
||||
private String oauthUrl;
|
||||
private String authType;
|
||||
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String scope;
|
||||
private String grantType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.volkswagen.mdmds.config;
|
||||
|
||||
import com.volkswagen.mdmds.constant.CommonField;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/6
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class WebSecurityConfig {
|
||||
public static final String ADMIN = "MDMDS_OPS";
|
||||
public static final String USER = "user";
|
||||
private final JwtAuthConverter jwtAuthConverter;
|
||||
|
||||
private final CustomBearerTokenResolver customBearerTokenResolver;
|
||||
private final JwtAuthenticationFilter jwtAuthenticationFilter;
|
||||
|
||||
@Resource
|
||||
@Qualifier("myAuthenticationEntryPoint")
|
||||
private AuthenticationEntryPoint authEntryPoint;
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.addFilterAfter(jwtAuthenticationFilter, BearerTokenAuthenticationFilter.class);
|
||||
http.csrf().disable();
|
||||
http.authorizeHttpRequests(a -> {
|
||||
a.requestMatchers("/test/anonymous", "/test/anonymous/**").permitAll();
|
||||
a.requestMatchers("/test/admin", "/test/admin/**").hasRole(CommonField.IDP_ROLE_ADMIN);
|
||||
a.requestMatchers("/test/user").hasAnyRole(ADMIN, USER, CommonField.IDP_ROLE_ADMIN, CommonField.IDP_ROLE_USER);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/permission/user/login").permitAll();
|
||||
a.requestMatchers("/mdmds/v1/permission/user/sameUserOnline").permitAll();
|
||||
a.requestMatchers("/mdmds/v1/permission/user/logout").permitAll();
|
||||
a.requestMatchers("/mdmds/v1/permission/user/forceLogin").permitAll();
|
||||
a.requestMatchers("/mdmds/v1/permission/user/invalidToken").permitAll();
|
||||
|
||||
a.requestMatchers("/mdmds/v1/group", "/mdmds/v1/group/**", "/mdmds/v1/group/attribute/kv").hasRole(CommonField.INNER_GROUP);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/ticket", "/mdmds/v1/ticket/**").hasAnyRole(CommonField.INNER_TICKET);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/vehicle", "/mdmds/v1/vehicle/**").hasAnyRole(CommonField.INNER_GROUP, CommonField.INNER_TICKET, CommonField.INNER_CONFIGURATION);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/policy", "/mdmds/v1/policy/**").hasAnyRole(CommonField.INNER_CONFIGURATION);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/permission", "/mdmds/v1/permission/**").hasAnyRole(CommonField.INNER_PERMISSION);
|
||||
|
||||
a.requestMatchers("/mdmds/v1/attribute", "/mdmds/v1/attribute/**").hasAnyRole(CommonField.INNER_DATASOURCE);
|
||||
|
||||
|
||||
a.requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll();
|
||||
});
|
||||
http.oauth2ResourceServer()
|
||||
.bearerTokenResolver(customBearerTokenResolver)
|
||||
.jwt()
|
||||
.jwtAuthenticationConverter(jwtAuthConverter);
|
||||
//如果JWT校验失败,则会返回指定格式的信息
|
||||
http.oauth2ResourceServer().authenticationEntryPoint(authEntryPoint);
|
||||
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||
return http.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.volkswagen.mdmds.config.exception;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.ResponseDTO;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class MdmdsControllerAdvice {
|
||||
|
||||
@ExceptionHandler(NullPointerException.class)
|
||||
public ResponseEntity<ResponseDTO> handleNullPointerException(Exception ex){
|
||||
HttpStatus status=HttpStatus.NOT_FOUND;
|
||||
return ResponseEntity.status(status).body(new ResponseDTO(status, ex.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<ResponseDTO> handleValidException(Exception e){
|
||||
HttpStatus httpStatus=HttpStatus.BAD_REQUEST;
|
||||
// StringBuilder sb=new StringBuilder();
|
||||
// ((MethodArgumentNotValidException) e).getBindingResult().getAllErrors()
|
||||
// .forEach(x->sb.append(x.getDefaultMessage()+";"));
|
||||
// return ResponseEntity.status(httpStatus).body(new ResponseDTO(httpStatus, sb.toString()));
|
||||
return ResponseEntity.status(httpStatus).body(new ResponseDTO(httpStatus, "Request argument error, please check request data"));
|
||||
}
|
||||
|
||||
@ExceptionHandler( HttpMessageNotReadableException.class )
|
||||
public ResponseEntity<ResponseDTO> handleMessageNotReadableException(Exception e){
|
||||
HttpStatus httpStatus=HttpStatus.BAD_REQUEST;
|
||||
return ResponseEntity.status(httpStatus).body(new ResponseDTO(httpStatus, "Request profile error, please check request data"));
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ResponseDTO> handleException(Exception e){
|
||||
HttpStatus httpStatus=HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
|
||||
// StringWriter stringWriter=new StringWriter();
|
||||
// PrintWriter printWriter=new PrintWriter(stringWriter);
|
||||
// e.printStackTrace(printWriter);
|
||||
|
||||
// String stackTrace=stringWriter.toString();
|
||||
return ResponseEntity.status(httpStatus)
|
||||
.body(new ResponseDTO(httpStatus,e.getMessage()));
|
||||
}
|
||||
|
||||
@ExceptionHandler(MdmdsException.class)
|
||||
public ResponseEntity<ResponseDTO> handleMdmdsException(MdmdsException e){
|
||||
// StringWriter stringWriter=new StringWriter();
|
||||
// PrintWriter printWriter=new PrintWriter(stringWriter);
|
||||
// e.printStackTrace(printWriter);
|
||||
|
||||
// String stackTrace=stringWriter.toString();
|
||||
return ResponseEntity.status(e.getHttpStatus())
|
||||
.body(new ResponseDTO(e.getHttpStatus(),e.getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volkswagen.mdmds.config.exception;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/7
|
||||
*/
|
||||
@Getter
|
||||
public class MdmdsException extends RuntimeException{
|
||||
|
||||
private final HttpStatus httpStatus;
|
||||
|
||||
public MdmdsException(String message, HttpStatus httpStatus) {
|
||||
super(message);
|
||||
this.httpStatus = httpStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volkswagen.mdmds.constant;
|
||||
|
||||
public enum CommonEnum {
|
||||
DT_TOKEN;
|
||||
}
|
||||
61
src/main/java/com/volkswagen/mdmds/constant/CommonField.java
Normal file
61
src/main/java/com/volkswagen/mdmds/constant/CommonField.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.volkswagen.mdmds.constant;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommonField {
|
||||
|
||||
private CommonField() {
|
||||
|
||||
}
|
||||
|
||||
public static final String DT_TOKEN = "DTToken";
|
||||
public static final String VWAC_TOKEN = "VWACToken";
|
||||
public static final String HW_TOKEN = "HWToken";
|
||||
public static final String MS_TOKEN = "MSToken";
|
||||
|
||||
public static final String RES_ROLES = "roles";
|
||||
public static final String ROLE_PREFIX = "ROLE_";
|
||||
|
||||
public static final String IDP_ROLE_ADMIN = "CLOUDIDP_EHR_ADMIN";
|
||||
public static final String IDP_ROLE_USER = "CLOUDIDP_EHR_USER";
|
||||
|
||||
public static final String ADS_VERSION_FIELD = "ADS Version";
|
||||
public static final List<String> VEHICLE_BASE_FIELDS = Arrays.asList(ADS_VERSION_FIELD, "Brand Code", "Brand Name", "Model Code", "Model Family", "Model Name", "Model Year", "Platform Name", "Platform Variant");
|
||||
|
||||
public static final String INNER_GROUP = "INNER_GROUP";
|
||||
public static final String INNER_TICKET = "INNER_TICKET";
|
||||
public static final String INNER_CONFIGURATION = "INNER_CONFIGURATION";
|
||||
public static final String INNER_PERMISSION = "INNER_PERMISSION";
|
||||
public static final String INNER_DATASOURCE = "INNER_DATASOURCE";
|
||||
|
||||
public static final String VIEW_GROUP = "Group Management";
|
||||
public static final String VIEW_TICKET = "Ticket Management";
|
||||
public static final String VIEW_CONFIGURATION = "Configuration Management";
|
||||
public static final String VIEW_PERMISSION = "Permission Management";
|
||||
public static final String VIEW_DATASOURCE = "Data Source Management";
|
||||
|
||||
public static final List<String> COMMON_RESOURCE = Arrays.asList(INNER_GROUP, INNER_TICKET, INNER_CONFIGURATION, INNER_DATASOURCE);
|
||||
|
||||
public static final Map<String, String> INNER_MENU = new HashMap<>();
|
||||
static {
|
||||
INNER_MENU.put(INNER_GROUP, VIEW_GROUP);
|
||||
INNER_MENU.put(INNER_TICKET, VIEW_TICKET);
|
||||
INNER_MENU.put(INNER_CONFIGURATION, VIEW_CONFIGURATION);
|
||||
INNER_MENU.put(INNER_PERMISSION, VIEW_PERMISSION);
|
||||
INNER_MENU.put(INNER_DATASOURCE, VIEW_DATASOURCE);
|
||||
}
|
||||
public static final Map<String, String> VIEW_MENU = new HashMap<>();
|
||||
static {
|
||||
VIEW_MENU.put(VIEW_GROUP, INNER_GROUP);
|
||||
VIEW_MENU.put(VIEW_TICKET, INNER_TICKET);
|
||||
VIEW_MENU.put(VIEW_CONFIGURATION, INNER_CONFIGURATION);
|
||||
VIEW_MENU.put(VIEW_PERMISSION, INNER_PERMISSION);
|
||||
VIEW_MENU.put(VIEW_DATASOURCE, INNER_DATASOURCE);
|
||||
}
|
||||
|
||||
public static final String VIN_ERROR = "VIN code error";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.volkswagen.mdmds.consumer;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.volkswagen.mdmds.model.entity.DicVehicleAttrAdapter;
|
||||
import com.volkswagen.mdmds.repos.DicVehicleAttrAdapterRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class VersionDataConsumer {
|
||||
|
||||
public static final String SPLIT = "_";
|
||||
|
||||
private static final String ENUM_FORMAT = "%s(%s)";
|
||||
|
||||
public static final String ATTR_NAME = "ecus/8103/sw_version";
|
||||
|
||||
private final DicVehicleAttrAdapterRepository dicVehicleAttrAdapterRepository;
|
||||
|
||||
@KafkaListener(topics = "${spring.kafka.topics.version-topic}",
|
||||
groupId = "${spring.kafka.groups.version-group}")
|
||||
public void listen(ConsumerRecord<String, String> record) {
|
||||
|
||||
String payloadValue = (String) JSONPath.eval(record.value(), "$.payload.value");
|
||||
byte[] valueBytes = Base64.getDecoder().decode(payloadValue);
|
||||
if (valueBytes.length > 2) {
|
||||
String hex = bytesToHex(valueBytes[0]) + bytesToHex(valueBytes[1]);
|
||||
char msgTypeChar = hex.charAt(3);
|
||||
if (msgTypeChar == '2') {
|
||||
log.info("Received message: key = {}, value = {}, partition = {}",
|
||||
record.key(), record.value(), record.partition());
|
||||
byte[] protobufData = new byte[valueBytes.length - 2];
|
||||
System.arraycopy(valueBytes, 2, protobufData, 0, protobufData.length);
|
||||
try {
|
||||
VersionOuterClass.Version version = VersionOuterClass.Version.parseFrom(protobufData);
|
||||
|
||||
String adsVersion = version.getAdsVersion();
|
||||
if (adsVersion.contains(SPLIT)) {
|
||||
adsVersion = adsVersion.split(SPLIT)[0];
|
||||
}
|
||||
String vwVersion = version.getVwVersion();
|
||||
String adapterMapping = String.format(ENUM_FORMAT, adsVersion, vwVersion);
|
||||
DicVehicleAttrAdapter attrAdapterMapping = dicVehicleAttrAdapterRepository.findByAdapterMapping(adapterMapping);
|
||||
if (Objects.isNull(attrAdapterMapping)) {
|
||||
DicVehicleAttrAdapter dicVehicleAttrAdapter = new DicVehicleAttrAdapter();
|
||||
dicVehicleAttrAdapter.setAttrName(ATTR_NAME);
|
||||
dicVehicleAttrAdapter.setAdapterValue(vwVersion);
|
||||
dicVehicleAttrAdapter.setAdapterKey(adsVersion);
|
||||
dicVehicleAttrAdapter.setAdapterMapping(adapterMapping);
|
||||
dicVehicleAttrAdapterRepository.save(dicVehicleAttrAdapter);
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte b) {
|
||||
char[] hexChars = new char[2];
|
||||
hexChars[0] = Character.forDigit((b >> 4) & 0xF, 16);
|
||||
hexChars[1] = Character.forDigit(b & 0xF, 16);
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,865 @@
|
||||
package com.volkswagen.mdmds.consumer;// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// NO CHECKED-IN PROTOBUF GENCODE
|
||||
// source: version.proto
|
||||
// Protobuf Java Version: 4.31.0
|
||||
|
||||
@com.google.protobuf.Generated
|
||||
public final class VersionOuterClass {
|
||||
private VersionOuterClass() {}
|
||||
static {
|
||||
com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
|
||||
com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
|
||||
/* major= */ 4,
|
||||
/* minor= */ 31,
|
||||
/* patch= */ 0,
|
||||
/* suffix= */ "",
|
||||
VersionOuterClass.class.getName());
|
||||
}
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistryLite registry) {
|
||||
}
|
||||
|
||||
public static void registerAllExtensions(
|
||||
com.google.protobuf.ExtensionRegistry registry) {
|
||||
registerAllExtensions(
|
||||
(com.google.protobuf.ExtensionRegistryLite) registry);
|
||||
}
|
||||
public interface VersionOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:Version)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The adsVersion.
|
||||
*/
|
||||
String getAdsVersion();
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The bytes for adsVersion.
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getAdsVersionBytes();
|
||||
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The shadowVersion.
|
||||
*/
|
||||
String getShadowVersion();
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The bytes for shadowVersion.
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getShadowVersionBytes();
|
||||
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The vwVersion.
|
||||
*/
|
||||
String getVwVersion();
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The bytes for vwVersion.
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getVwVersionBytes();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code Version}
|
||||
*/
|
||||
public static final class Version extends
|
||||
com.google.protobuf.GeneratedMessage implements
|
||||
// @@protoc_insertion_point(message_implements:Version)
|
||||
VersionOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
static {
|
||||
com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
|
||||
com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
|
||||
/* major= */ 4,
|
||||
/* minor= */ 31,
|
||||
/* patch= */ 0,
|
||||
/* suffix= */ "",
|
||||
Version.class.getName());
|
||||
}
|
||||
// Use Version.newBuilder() to construct.
|
||||
private Version(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
private Version() {
|
||||
adsVersion_ = "";
|
||||
shadowVersion_ = "";
|
||||
vwVersion_ = "";
|
||||
}
|
||||
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return VersionOuterClass.internal_static_Version_descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return VersionOuterClass.internal_static_Version_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
Version.class, Builder.class);
|
||||
}
|
||||
|
||||
public static final int ADSVERSION_FIELD_NUMBER = 1;
|
||||
@SuppressWarnings("serial")
|
||||
private volatile Object adsVersion_ = "";
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The adsVersion.
|
||||
*/
|
||||
@Override
|
||||
public String getAdsVersion() {
|
||||
Object ref = adsVersion_;
|
||||
if (ref instanceof String) {
|
||||
return (String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
adsVersion_ = s;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The bytes for adsVersion.
|
||||
*/
|
||||
@Override
|
||||
public com.google.protobuf.ByteString
|
||||
getAdsVersionBytes() {
|
||||
Object ref = adsVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
adsVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
public static final int SHADOWVERSION_FIELD_NUMBER = 2;
|
||||
@SuppressWarnings("serial")
|
||||
private volatile Object shadowVersion_ = "";
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The shadowVersion.
|
||||
*/
|
||||
@Override
|
||||
public String getShadowVersion() {
|
||||
Object ref = shadowVersion_;
|
||||
if (ref instanceof String) {
|
||||
return (String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
shadowVersion_ = s;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The bytes for shadowVersion.
|
||||
*/
|
||||
@Override
|
||||
public com.google.protobuf.ByteString
|
||||
getShadowVersionBytes() {
|
||||
Object ref = shadowVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
shadowVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
public static final int VWVERSION_FIELD_NUMBER = 3;
|
||||
@SuppressWarnings("serial")
|
||||
private volatile Object vwVersion_ = "";
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The vwVersion.
|
||||
*/
|
||||
@Override
|
||||
public String getVwVersion() {
|
||||
Object ref = vwVersion_;
|
||||
if (ref instanceof String) {
|
||||
return (String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
vwVersion_ = s;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The bytes for vwVersion.
|
||||
*/
|
||||
@Override
|
||||
public com.google.protobuf.ByteString
|
||||
getVwVersionBytes() {
|
||||
Object ref = vwVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
vwVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
@Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output)
|
||||
throws java.io.IOException {
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(adsVersion_)) {
|
||||
com.google.protobuf.GeneratedMessage.writeString(output, 1, adsVersion_);
|
||||
}
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(shadowVersion_)) {
|
||||
com.google.protobuf.GeneratedMessage.writeString(output, 2, shadowVersion_);
|
||||
}
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(vwVersion_)) {
|
||||
com.google.protobuf.GeneratedMessage.writeString(output, 3, vwVersion_);
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(adsVersion_)) {
|
||||
size += com.google.protobuf.GeneratedMessage.computeStringSize(1, adsVersion_);
|
||||
}
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(shadowVersion_)) {
|
||||
size += com.google.protobuf.GeneratedMessage.computeStringSize(2, shadowVersion_);
|
||||
}
|
||||
if (!com.google.protobuf.GeneratedMessage.isStringEmpty(vwVersion_)) {
|
||||
size += com.google.protobuf.GeneratedMessage.computeStringSize(3, vwVersion_);
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Version)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
Version other = (Version) obj;
|
||||
|
||||
if (!getAdsVersion()
|
||||
.equals(other.getAdsVersion())) return false;
|
||||
if (!getShadowVersion()
|
||||
.equals(other.getShadowVersion())) return false;
|
||||
if (!getVwVersion()
|
||||
.equals(other.getVwVersion())) return false;
|
||||
if (!getUnknownFields().equals(other.getUnknownFields())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
hash = (37 * hash) + ADSVERSION_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getAdsVersion().hashCode();
|
||||
hash = (37 * hash) + SHADOWVERSION_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getShadowVersion().hashCode();
|
||||
hash = (37 * hash) + VWVERSION_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getVwVersion().hashCode();
|
||||
hash = (29 * hash) + getUnknownFields().hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static Version parseFrom(
|
||||
java.nio.ByteBuffer data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
java.nio.ByteBuffer data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static Version parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
byte[] data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
public static Version parseFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static Version parseDelimitedFrom(java.io.InputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
|
||||
public static Version parseDelimitedFrom(
|
||||
java.io.InputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
com.google.protobuf.CodedInputStream input)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseWithIOException(PARSER, input);
|
||||
}
|
||||
public static Version parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessage
|
||||
.parseWithIOException(PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder newBuilderForType() { return newBuilder(); }
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
public static Builder newBuilder(Version prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE
|
||||
? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code Version}
|
||||
*/
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessage.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:Version)
|
||||
VersionOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return VersionOuterClass.internal_static_Version_descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return VersionOuterClass.internal_static_Version_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
Version.class, Builder.class);
|
||||
}
|
||||
|
||||
// Construct using VersionOuterClass.Version.newBuilder()
|
||||
private Builder() {
|
||||
|
||||
}
|
||||
|
||||
private Builder(
|
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) {
|
||||
super(parent);
|
||||
|
||||
}
|
||||
@Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
bitField0_ = 0;
|
||||
adsVersion_ = "";
|
||||
shadowVersion_ = "";
|
||||
vwVersion_ = "";
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return VersionOuterClass.internal_static_Version_descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getDefaultInstanceForType() {
|
||||
return Version.getDefaultInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version build() {
|
||||
Version result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version buildPartial() {
|
||||
Version result = new Version(this);
|
||||
if (bitField0_ != 0) { buildPartial0(result); }
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void buildPartial0(Version result) {
|
||||
int from_bitField0_ = bitField0_;
|
||||
if (((from_bitField0_ & 0x00000001) != 0)) {
|
||||
result.adsVersion_ = adsVersion_;
|
||||
}
|
||||
if (((from_bitField0_ & 0x00000002) != 0)) {
|
||||
result.shadowVersion_ = shadowVersion_;
|
||||
}
|
||||
if (((from_bitField0_ & 0x00000004) != 0)) {
|
||||
result.vwVersion_ = vwVersion_;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof Version) {
|
||||
return mergeFrom((Version)other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(Version other) {
|
||||
if (other == Version.getDefaultInstance()) return this;
|
||||
if (!other.getAdsVersion().isEmpty()) {
|
||||
adsVersion_ = other.adsVersion_;
|
||||
bitField0_ |= 0x00000001;
|
||||
onChanged();
|
||||
}
|
||||
if (!other.getShadowVersion().isEmpty()) {
|
||||
shadowVersion_ = other.shadowVersion_;
|
||||
bitField0_ |= 0x00000002;
|
||||
onChanged();
|
||||
}
|
||||
if (!other.getVwVersion().isEmpty()) {
|
||||
vwVersion_ = other.vwVersion_;
|
||||
bitField0_ |= 0x00000004;
|
||||
onChanged();
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
if (extensionRegistry == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10: {
|
||||
adsVersion_ = input.readStringRequireUtf8();
|
||||
bitField0_ |= 0x00000001;
|
||||
break;
|
||||
} // case 10
|
||||
case 18: {
|
||||
shadowVersion_ = input.readStringRequireUtf8();
|
||||
bitField0_ |= 0x00000002;
|
||||
break;
|
||||
} // case 18
|
||||
case 26: {
|
||||
vwVersion_ = input.readStringRequireUtf8();
|
||||
bitField0_ |= 0x00000004;
|
||||
break;
|
||||
} // case 26
|
||||
default: {
|
||||
if (!super.parseUnknownField(input, extensionRegistry, tag)) {
|
||||
done = true; // was an endgroup tag
|
||||
}
|
||||
break;
|
||||
} // default:
|
||||
} // switch (tag)
|
||||
} // while (!done)
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
onChanged();
|
||||
} // finally
|
||||
return this;
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private Object adsVersion_ = "";
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The adsVersion.
|
||||
*/
|
||||
public String getAdsVersion() {
|
||||
Object ref = adsVersion_;
|
||||
if (!(ref instanceof String)) {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
adsVersion_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return The bytes for adsVersion.
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getAdsVersionBytes() {
|
||||
Object ref = adsVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
adsVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @param value The adsVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setAdsVersion(
|
||||
String value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
adsVersion_ = value;
|
||||
bitField0_ |= 0x00000001;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder clearAdsVersion() {
|
||||
adsVersion_ = getDefaultInstance().getAdsVersion();
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string adsVersion = 1;</code>
|
||||
* @param value The bytes for adsVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setAdsVersionBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
checkByteStringIsUtf8(value);
|
||||
adsVersion_ = value;
|
||||
bitField0_ |= 0x00000001;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
private Object shadowVersion_ = "";
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The shadowVersion.
|
||||
*/
|
||||
public String getShadowVersion() {
|
||||
Object ref = shadowVersion_;
|
||||
if (!(ref instanceof String)) {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
shadowVersion_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return The bytes for shadowVersion.
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getShadowVersionBytes() {
|
||||
Object ref = shadowVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
shadowVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @param value The shadowVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setShadowVersion(
|
||||
String value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
shadowVersion_ = value;
|
||||
bitField0_ |= 0x00000002;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder clearShadowVersion() {
|
||||
shadowVersion_ = getDefaultInstance().getShadowVersion();
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string shadowVersion = 2;</code>
|
||||
* @param value The bytes for shadowVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setShadowVersionBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
checkByteStringIsUtf8(value);
|
||||
shadowVersion_ = value;
|
||||
bitField0_ |= 0x00000002;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
private Object vwVersion_ = "";
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The vwVersion.
|
||||
*/
|
||||
public String getVwVersion() {
|
||||
Object ref = vwVersion_;
|
||||
if (!(ref instanceof String)) {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
String s = bs.toStringUtf8();
|
||||
vwVersion_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return The bytes for vwVersion.
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getVwVersionBytes() {
|
||||
Object ref = vwVersion_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(String) ref);
|
||||
vwVersion_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @param value The vwVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setVwVersion(
|
||||
String value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
vwVersion_ = value;
|
||||
bitField0_ |= 0x00000004;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder clearVwVersion() {
|
||||
vwVersion_ = getDefaultInstance().getVwVersion();
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>string vwVersion = 3;</code>
|
||||
* @param value The bytes for vwVersion to set.
|
||||
* @return This builder for chaining.
|
||||
*/
|
||||
public Builder setVwVersionBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) { throw new NullPointerException(); }
|
||||
checkByteStringIsUtf8(value);
|
||||
vwVersion_ = value;
|
||||
bitField0_ |= 0x00000004;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:Version)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:Version)
|
||||
private static final Version DEFAULT_INSTANCE;
|
||||
static {
|
||||
DEFAULT_INSTANCE = new Version();
|
||||
}
|
||||
|
||||
public static Version getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<Version>
|
||||
PARSER = new com.google.protobuf.AbstractParser<Version>() {
|
||||
@Override
|
||||
public Version parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
Builder builder = newBuilder();
|
||||
try {
|
||||
builder.mergeFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(builder.buildPartial());
|
||||
} catch (com.google.protobuf.UninitializedMessageException e) {
|
||||
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(e)
|
||||
.setUnfinishedMessage(builder.buildPartial());
|
||||
}
|
||||
return builder.buildPartial();
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<Version> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.protobuf.Parser<Version> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_Version_descriptor;
|
||||
private static final
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable
|
||||
internal_static_Version_fieldAccessorTable;
|
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor
|
||||
getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
private static com.google.protobuf.Descriptors.FileDescriptor
|
||||
descriptor;
|
||||
static {
|
||||
String[] descriptorData = {
|
||||
"\n\rversion.proto\"G\n\007Version\022\022\n\nadsVersion" +
|
||||
"\030\001 \001(\t\022\025\n\rshadowVersion\030\002 \001(\t\022\021\n\tvwVersi" +
|
||||
"on\030\003 \001(\tb\006proto3"
|
||||
};
|
||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
new com.google.protobuf.Descriptors.FileDescriptor[] {
|
||||
});
|
||||
internal_static_Version_descriptor =
|
||||
getDescriptor().getMessageTypes().get(0);
|
||||
internal_static_Version_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_Version_descriptor,
|
||||
new String[] { "AdsVersion", "ShadowVersion", "VwVersion", });
|
||||
descriptor.resolveAllFeaturesImmutable();
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.controller.api.AttributeApi;
|
||||
import com.volkswagen.mdmds.model.dto.AttrWithValuesDTO;
|
||||
import com.volkswagen.mdmds.model.dto.AttributeDTO;
|
||||
import com.volkswagen.mdmds.model.dto.UploadDataDTO;
|
||||
import com.volkswagen.mdmds.model.entity.DicVehicleAttr;
|
||||
import com.volkswagen.mdmds.model.excel.VehicleAttributeField;
|
||||
import com.volkswagen.mdmds.service.AttributeService;
|
||||
import com.volkswagen.mdmds.utils.ExcelUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@RestController
|
||||
public class AttributeMgmtController implements AttributeApi {
|
||||
private final AttributeService attributeService;
|
||||
|
||||
public AttributeMgmtController(AttributeService attributeService) {
|
||||
this.attributeService = attributeService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<AttributeDTO>> getAllAttrs() {
|
||||
List<AttributeDTO> allAttrs = attributeService.getAllAttrs();
|
||||
return ResponseEntity.of(Optional.ofNullable(allAttrs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<AttributeDTO>> getAttrViews(AttributeDTO attributeDTO) {
|
||||
List<AttributeDTO> allAttrs = attributeService.getAttrViews(attributeDTO);
|
||||
return ResponseEntity.of(Optional.ofNullable(allAttrs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<AttributeDTO> addAttribute(AttributeDTO attributeDTO) {
|
||||
DicVehicleAttr dicVehicleAttr = attributeService.addNewAttr(attributeDTO);
|
||||
BeanUtils.copyProperties(dicVehicleAttr, attributeDTO);
|
||||
return ResponseEntity.ok(attributeDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<AttributeDTO> changeAttributeStatus(UUID id, AttributeDTO dto) {
|
||||
DicVehicleAttr dicVehicleAttr = attributeService.changeAttributeStatus(id, dto);
|
||||
BeanUtils.copyProperties(dicVehicleAttr, dto);
|
||||
return ResponseEntity.ok(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> deleteAttributeById(UUID id) {
|
||||
DicVehicleAttr dicVehicleAttr = attributeService.deleteAttributeById(id);
|
||||
if (dicVehicleAttr.getId() != null) {
|
||||
return ResponseEntity.ok().build();
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<AttributeDTO> updateVehicleAttr(UUID id, AttributeDTO attributeDTO) {
|
||||
DicVehicleAttr dicVehicleAttr = attributeService.updateVehicleAttr(id, attributeDTO);
|
||||
if (dicVehicleAttr.getId() != null) {
|
||||
BeanUtils.copyProperties(dicVehicleAttr, attributeDTO);
|
||||
return ResponseEntity.ok(attributeDTO);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> clearTable() {
|
||||
try {
|
||||
attributeService.clearTable();
|
||||
} catch (Exception e) {
|
||||
throw new MdmdsException("SQL error", HttpStatus.CONFLICT);
|
||||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> verification() {
|
||||
try {
|
||||
attributeService.verification();
|
||||
} catch (Exception ex) {
|
||||
throw new MdmdsException(ex.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> verificationAttrName(AttributeDTO attributeDTO) {
|
||||
return ResponseEntity.ok(attributeService.verificationAttrName(attributeDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> getAttrValue() {
|
||||
attributeService.getAttrValue();
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<AttrWithValuesDTO>> getAllAttrValueMap() {
|
||||
return ResponseEntity.ok(attributeService.getAllAttrValueMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity uploadExcel(MultipartFile file) {
|
||||
attributeService.uploadAttributeFiled(file);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> uploadExcelCheck(MultipartFile file) {
|
||||
return attributeService.uploadAttributeFieldCheckData(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> uploadExcelData(UploadDataDTO uploadDataDTO) {
|
||||
attributeService.uploadAttribute(uploadDataDTO);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity downloadExcelTemplate(HttpServletResponse response) {
|
||||
try {
|
||||
ExcelUtil.createExcelTemplate(response, VehicleAttributeField.class, "VehicleAttributeField.xlsx",null);
|
||||
} catch (Exception e) {
|
||||
throw new MdmdsException("Excel template download error", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity updateVehicleKeyAndValue(HttpServletResponse response) {
|
||||
attributeService.syncVehicleKeyAndValue();
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.controller.api.GroupApi;
|
||||
import com.volkswagen.mdmds.model.dto.*;
|
||||
import com.volkswagen.mdmds.model.entity.GroupSpecification;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import com.volkswagen.mdmds.model.entity.VehicleGroup;
|
||||
import com.volkswagen.mdmds.model.param.GroupCreateParam;
|
||||
import com.volkswagen.mdmds.model.param.VehicleGroupParam;
|
||||
import com.volkswagen.mdmds.model.pojo.GroupVehicleInfoPojo;
|
||||
import com.volkswagen.mdmds.model.vo.VehicleGroupVo;
|
||||
import com.volkswagen.mdmds.out.dto.Vehicle;
|
||||
import com.volkswagen.mdmds.repos.GroupSpecificationRepository;
|
||||
import com.volkswagen.mdmds.repos.VehicleGroupRepository;
|
||||
import com.volkswagen.mdmds.service.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@RestController
|
||||
public class GroupMgmtController implements GroupApi {
|
||||
|
||||
protected Logger log = LoggerFactory.getLogger(GroupMgmtController.class);
|
||||
|
||||
private static final String RES_VEHICLE_VALUE = "value";
|
||||
|
||||
|
||||
@Resource
|
||||
private VehicleGroupRepository vehicleGroupRepository;
|
||||
@Resource
|
||||
private GroupSpecificationRepository groupSpecRepository;
|
||||
|
||||
@Resource
|
||||
private LinkDTService linkDTService;
|
||||
|
||||
private final GroupService groupService;
|
||||
private final TicketService ticketService;
|
||||
|
||||
public GroupMgmtController(GroupService groupService, TicketService ticketService) {
|
||||
this.groupService = groupService;
|
||||
this.ticketService = ticketService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<GroupBriefInfoDTO> createGroup(GroupCreateParam groupBriefInfoDTO) {
|
||||
UUID newGroupID = groupService.createNewGroupByName(groupBriefInfoDTO.getGroupName());
|
||||
GroupBriefInfoDTO build = GroupBriefInfoDTO.builder().id(newGroupID).build();
|
||||
return ResponseEntity.ok(build);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<VehicleGroupVo>> getPageableGroup(VehicleGroupParam param) {
|
||||
Page<VehicleGroupVo> vehicleGroupVoPage = groupService.pageableGroup(param.getPageNo(), param.getPageSize(), param);
|
||||
return ResponseEntity.ok(vehicleGroupVoPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<GroupDetailInfoDTO> deleteGroupById(UUID id) {
|
||||
groupService.deleteGroupById(id);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> deletedGroupByIds(GroupParamsDTO dto) {
|
||||
groupService.deletedGroupByIds(dto.getIdList());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<GroupDetailInfoDTO> getGroupDetailInfo(UUID id) {
|
||||
GroupDetailInfoDTO groupDetailInfoDTO = groupService.getGroupDetailInfo(id);
|
||||
return ResponseEntity.ok(groupDetailInfoDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity updateGroupCriteria(UUID id, GroupDetailInfoDTO dto) {
|
||||
if (null == dto.getSpecificationJson() || dto.getSpecificationJson().length() == 0) {
|
||||
throw new MdmdsException("Vehicle query criteria must be filled in", HttpStatus.LOCKED);
|
||||
}
|
||||
//dto里必须有id
|
||||
VehicleGroup vehicleGroup = vehicleGroupRepository.findOneByIdAndIsDeleted(dto.getId(), 0);
|
||||
if (null == vehicleGroup) {
|
||||
throw new MdmdsException("Vehicle group does not exist", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 分组关联车辆查询条件和标签(每个分组可以设置"事故车","G50高速"等标签)
|
||||
GroupSpecification groupSpecification = vehicleGroup.getGroupSpecification();
|
||||
if (groupSpecification != null && groupSpecification.isContainSpec()) {
|
||||
throw new MdmdsException("Vehicle group has been created", HttpStatus.LOCKED);
|
||||
}
|
||||
// 获取查询条件的车辆VID
|
||||
List<String> vidList;
|
||||
try {
|
||||
StringBuilder conditionSb = new StringBuilder();
|
||||
JSONObject conditionJSONObject = JSON.parseObject(dto.getSpecificationJson());
|
||||
JSONArray conditionJSONArray = conditionJSONObject.getJSONArray("and");
|
||||
for(int index = 0; index < conditionJSONArray.size(); index++){
|
||||
JSONObject itemJSONObject = conditionJSONArray.getJSONObject(index);
|
||||
Set<String> keySet = itemJSONObject.keySet();
|
||||
for(String key : keySet) {
|
||||
conditionSb.append("(key").append("=").append("\"").append(key).append("\"").append(" and ")
|
||||
.append(RES_VEHICLE_VALUE).append("=").append("\"").append(itemJSONObject.getString(key)).append("\")").append(" and ");
|
||||
}
|
||||
}
|
||||
String condition = conditionSb.substring(0, conditionSb.length() - 5);
|
||||
Object result = linkDTService.getVehicleIdByCondition(condition);
|
||||
Vehicle vehicle = JSON.parseObject(result.toString(), Vehicle.class);
|
||||
vidList = vehicle.getVehicleList();
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException | ExecutionException e) {
|
||||
throw new MdmdsException(e.getMessage(), HttpStatus.CONFLICT);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new MdmdsException(ie.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
if (vidList.isEmpty()) {
|
||||
throw new MdmdsException("Vehicle grouping condition does not have a VID", HttpStatus.CONFLICT);
|
||||
}
|
||||
vehicleGroup.setMold(1);// 分组创建关联VID(按车辆字段条件查询获取VID)
|
||||
vehicleGroup.setStatus(ItemStatus.RUN);
|
||||
// 分组关联车辆查询条件和标签(每个分组可以设置"事故车","G50高速"等标签)
|
||||
groupSpecification = vehicleGroup.getGroupSpecification();
|
||||
if (groupSpecification == null) {
|
||||
groupSpecification = new GroupSpecification();
|
||||
}
|
||||
groupSpecification.setSpecificationJson(dto.getSpecificationJson());
|
||||
if (null != dto.getTags() && !dto.getTags().isEmpty()) {
|
||||
groupSpecification.setTags(dto.getTags().stream().distinct().collect(Collectors.joining(";")));
|
||||
} else {
|
||||
groupSpecification.setTags("");
|
||||
}
|
||||
groupSpecRepository.save(groupSpecification);
|
||||
vehicleGroup.setGroupSpecification(groupSpecification);
|
||||
// 分组关联车辆
|
||||
groupService.updateGroupVehicleByCriteria(vidList, vehicleGroup, dto);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity updateGroupVin(UUID id, GroupParamsDTO dto) {
|
||||
VehicleGroup vehicleGroup = vehicleGroupRepository.findOneByIdAndIsDeleted(id, 0);
|
||||
if (null == vehicleGroup) {
|
||||
throw new MdmdsException("Vehicle group does not exist", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 分组创建中
|
||||
vehicleGroup.setMold(2);// 分组创建关联VID(按车辆VIN查询获取VID)
|
||||
vehicleGroup.setStatus(ItemStatus.RUN);
|
||||
GroupSpecification groupSpecification = vehicleGroup.getGroupSpecification();
|
||||
if (groupSpecification == null) {
|
||||
groupSpecification = new GroupSpecification();
|
||||
}
|
||||
if (null != dto.getTags() && !dto.getTags().isEmpty()) {
|
||||
groupSpecification.setTags(dto.getTags().stream().collect(Collectors.joining(";")));
|
||||
} else {
|
||||
groupSpecification.setTags("");
|
||||
}
|
||||
groupSpecRepository.save(groupSpecification);
|
||||
vehicleGroup.setGroupSpecification(groupSpecification);
|
||||
vehicleGroupRepository.save(vehicleGroup);
|
||||
// 异步执行:分组关联车辆
|
||||
groupService.updateGroupVehicleByVIN(vehicleGroup, dto);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> updateGroupConfiguration(UUID groupId, UUID dccId) {
|
||||
groupService.updateGroupConfiguration(groupId, dccId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> unbindGroupConfiguration(UUID groupId) {
|
||||
groupService.unbindGroupConfiguration(groupId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> getVehicleIds(UUID id, GroupDetailInfoDTO groupDetailInfoDTO) {
|
||||
groupService.getVehicleIds(id, groupDetailInfoDTO);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<String>> getAllVIDs(UUID id, GroupParamsDTO dto) {
|
||||
List<String> vehicleIds = groupService.getAllVIDs(id, dto);
|
||||
return ResponseEntity.ok(vehicleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<GroupVehicleInfoPojo>> getVehicleInfos(GroupVehicleDTO groupVehicleDTO) {
|
||||
int pageNo = groupVehicleDTO.getPageNo();
|
||||
int pageSize = groupVehicleDTO.getPageSize();
|
||||
UUID groupId = groupVehicleDTO.getId();
|
||||
return ResponseEntity.ok(groupService.pageableVehicleInfo(PageRequest.of(pageNo - 1, pageSize), groupId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<GroupVehicleResultDTO>> getVehicleViews(UUID id, GroupParamsDTO dto) {
|
||||
return ResponseEntity.ok(groupService.getVehicleViews(id, dto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> createNewTicket(UUID id, TicketParamsDTO dto) {
|
||||
|
||||
String ticketName = dto.getTicketName();
|
||||
List<VehicleInfoDTO> vehicleInfoDTOS = dto.getVehicles();
|
||||
ticketService.batchVehicleInsertToTicket(ticketName, vehicleInfoDTOS);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AttributeService attributeService;
|
||||
@Override
|
||||
public ResponseEntity<List<AttrWithValuesDTO>> getAllAttrValueMap() {
|
||||
return ResponseEntity.ok(attributeService.getAllAttrValueMap());
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<List<AttributeDTO>> getAllAttrs() {
|
||||
List<AttributeDTO> allAttrs = attributeService.getAllAttrs();
|
||||
return ResponseEntity.of(Optional.ofNullable(allAttrs));
|
||||
}
|
||||
|
||||
@Resource
|
||||
private PolicyService policyService;
|
||||
@Override
|
||||
public ResponseEntity<PolicyBriefInfoDTO> getPolicyInfo(UUID id) {
|
||||
PolicyBriefInfoDTO policyBriefInfoDTO = policyService.getPolicyInfo(id);
|
||||
return ResponseEntity.ok(policyBriefInfoDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<PolicyBriefInfoDTO>> getPolicyViews(PolicyParamsDTO dto) {
|
||||
List<PolicyBriefInfoDTO> policyBriefInfoDTOS = policyService.getPolicyViews(dto);
|
||||
return ResponseEntity.ok(policyBriefInfoDTOS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.volkswagen.mdmds.config.JwtAuthConverterProperties;
|
||||
import com.volkswagen.mdmds.constant.CommonField;
|
||||
import com.volkswagen.mdmds.controller.api.PermissionApi;
|
||||
import com.volkswagen.mdmds.model.dto.*;
|
||||
import com.volkswagen.mdmds.model.param.RoleCreateParam;
|
||||
import com.volkswagen.mdmds.model.param.UserStatusParam;
|
||||
import com.volkswagen.mdmds.model.vo.RoleResourceTreeVo;
|
||||
import com.volkswagen.mdmds.service.UserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
import static com.volkswagen.mdmds.config.JwtAuthenticationFilter.*;
|
||||
|
||||
|
||||
@RestController
|
||||
public class PermissionMgmtController implements PermissionApi {
|
||||
|
||||
private final JwtAuthConverterProperties properties;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
public PermissionMgmtController(JwtAuthConverterProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析Token获取用户信息(用户基本信息、角色信息),同步更新关联用户信息
|
||||
* @param principal
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<UserInfoDTO> initUser(Principal principal) {
|
||||
JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
Jwt jwt = (Jwt) token.getPrincipal();
|
||||
Map<String,Object> claims = jwt.getClaims() ;
|
||||
String userName = (String) claims.get(properties.getPrincipalAttribute());
|
||||
String email = (String) claims.get("email");
|
||||
|
||||
List<String> roles = new ArrayList<>();
|
||||
if(jwt.hasClaim("resource_access")) {
|
||||
// TSystem
|
||||
initRolesInTSystem(jwt, roles);
|
||||
} else {
|
||||
// IDP
|
||||
initRolesInIDP(jwt, roles);
|
||||
}
|
||||
|
||||
Collection<GrantedAuthority> collect = token.getAuthorities();
|
||||
List<String> innerRoles = new ArrayList<>();
|
||||
for(GrantedAuthority item : collect) {
|
||||
if(item.getAuthority().contains("ROLE_")) {
|
||||
innerRoles.add(item.getAuthority().replace("ROLE_", ""));
|
||||
}
|
||||
}
|
||||
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(userName);
|
||||
userInfoDTO.setEmail(email);
|
||||
|
||||
List<RoleInfoDTO> roleInfoDTOList = roles.stream().map(roleName -> {
|
||||
RoleInfoDTO roleInfoDTO = new RoleInfoDTO();
|
||||
roleInfoDTO.setRoleName(roleName);
|
||||
return roleInfoDTO;
|
||||
}).toList();
|
||||
userInfoDTO.setRoleList(roleInfoDTOList);
|
||||
|
||||
userInfoDTO = userService.initInfo(userInfoDTO);
|
||||
|
||||
List<Map<String, Object>> resource = new ArrayList<>();
|
||||
for(String roleInnerName : innerRoles) {
|
||||
Map<String, Object> resourceObj = new HashMap<>();
|
||||
resourceObj.put("resname", CommonField.INNER_MENU.get(roleInnerName));
|
||||
resource.add(resourceObj);
|
||||
}
|
||||
userInfoDTO.setResources(resource);
|
||||
|
||||
return ResponseEntity.ok(userInfoDTO);
|
||||
}
|
||||
|
||||
public ResponseEntity<Object> logout(HttpServletRequest request,Principal principal) {
|
||||
JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
Jwt jwt = (Jwt) token.getPrincipal();
|
||||
Map<String,Object> claims =jwt.getClaims() ;
|
||||
String userName = (String) claims.get(properties.getPrincipalAttribute());
|
||||
String deviceId = request.getHeader(properties.getUniqueAttribute());
|
||||
if (userSessionMap.containsKey(userName) && userSessionMap.get(userName).getDeviceId().equals(deviceId)) {
|
||||
userSessionMap.remove(userName);
|
||||
}
|
||||
Instant expiresAt = (Instant) claims.get("exp");
|
||||
blackTokenMap.put(jwt.getTokenValue(),expiresAt);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", HttpStatus.OK.value());
|
||||
jsonObject.put("message","logout success");
|
||||
return ResponseEntity.ok(jsonObject);
|
||||
}
|
||||
|
||||
public ResponseEntity<Object> invalidToken(JSONObject token) {
|
||||
// JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
// Jwt jwt = (Jwt) token.getPrincipal();
|
||||
// Map<String,Object> claims =jwt.getClaims() ;
|
||||
// Instant expiresAt = (Instant) claims.get("exp");
|
||||
// blackTokenMap.put(jwt.getTokenValue(),expiresAt);
|
||||
blackTokenMap.put(token.getString("token"), Instant.now().plusSeconds(60 * 60L));
|
||||
return ResponseEntity.ok(new ResponseDTO(HttpStatus.OK,"token invalid success"));
|
||||
}
|
||||
|
||||
public ResponseEntity<Object> sameUserOnline(HttpServletRequest request,Principal principal) {
|
||||
JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
Jwt jwt = (Jwt) token.getPrincipal();
|
||||
Map<String,Object> claims =jwt.getClaims() ;
|
||||
String userName = (String) claims.get(properties.getPrincipalAttribute());
|
||||
String deviceId = request.getHeader(properties.getUniqueAttribute());
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (userSessionMap.containsKey(userName) && !userSessionMap.get(userName).getDeviceId().equals(deviceId)) {
|
||||
jsonObject.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
jsonObject.put("sameUserOnline",true);
|
||||
jsonObject.put("message","The same user is online. Procedure");
|
||||
} else {
|
||||
jsonObject.put("code", HttpStatus.OK.value());
|
||||
jsonObject.put("sameUserOnline",false);
|
||||
jsonObject.put("message","No user is online. Procedure");
|
||||
}
|
||||
return ResponseEntity.ok(jsonObject);
|
||||
}
|
||||
|
||||
public ResponseEntity<Object> forceLogin(HttpServletRequest request,Principal principal) {
|
||||
JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
Jwt jwt = (Jwt) token.getPrincipal();
|
||||
Map<String,Object> claims =jwt.getClaims() ;
|
||||
String userName = (String) claims.get(properties.getPrincipalAttribute());
|
||||
String deviceId = request.getHeader(properties.getUniqueAttribute());
|
||||
Instant expiresAt = (Instant) claims.get("exp");
|
||||
userSessionMap.put(userName, new UserSessionDTO(userName,deviceId,expiresAt));
|
||||
return ResponseEntity.ok(new ResponseDTO(HttpStatus.OK,"force login success"));
|
||||
}
|
||||
|
||||
private void initRolesInTSystem(Jwt jwt, List<String> roles) {
|
||||
Map<String, Object> resourceAccess = jwt.getClaim("resource_access");
|
||||
if(resourceAccess != null && resourceAccess.containsKey(properties.getResourceId())) {
|
||||
Map<String, Object> resource = (Map<String, Object>) resourceAccess.get(properties.getResourceId());
|
||||
List<String> resourceRoles = (List<String>) resource.get(CommonField.RES_ROLES);
|
||||
if(!resourceRoles.isEmpty()) {
|
||||
roles.addAll(resourceRoles);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void initRolesInIDP(Jwt jwt, List<String> roles) {
|
||||
Map<String, Object> realmAccess = jwt.getClaim("realm_access");
|
||||
if(null != realmAccess && realmAccess.containsKey(CommonField.RES_ROLES)) {
|
||||
List<String> realmRoles = (List<String>) realmAccess.get(CommonField.RES_ROLES);
|
||||
if (realmRoles != null) {
|
||||
roles.addAll(realmRoles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<Page<UserInfoDTO>> getUserInfos(int pageNo, int pageSize) {
|
||||
Page<UserInfoDTO> userInfoDTOS = userService.pageableUserInfos(PageRequest.of(pageNo - 1, pageSize));
|
||||
return ResponseEntity.ok(userInfoDTOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户状态
|
||||
* @param id
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<Object> alterUserStatus(UUID id, UserStatusParam param) {
|
||||
userService.alterUserStatus(id, param);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统角色列表
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<Page<RoleInfoDTO>> getRoleInfos(int pageNo, int pageSize) {
|
||||
Page<RoleInfoDTO> roleInfoDTOS = userService.pageableRoleInfos(PageRequest.of(pageNo - 1, pageSize));
|
||||
return ResponseEntity.ok(roleInfoDTOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity deleteRoleById(UUID id) {
|
||||
userService.deleteRoleById(id);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统资源列表
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity<Page<ResourceInfoDTO>> getResourceInfos(int pageNo, int pageSize) {
|
||||
Page<ResourceInfoDTO> resourceInfoDTOS = userService.pageableResourceInfos(PageRequest.of(pageNo - 1, pageSize));
|
||||
return ResponseEntity.ok(resourceInfoDTOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<Map<String, String>>> getResourceViews() {
|
||||
List<Map<String, String>> resourceViews = userService.getAllResourceView();
|
||||
List<Map<String, String>> resourceViewsTarget = new ArrayList<>();
|
||||
for (Map<String, String> map : resourceViews) {
|
||||
Map<String, String> mapNew = new HashMap<>();
|
||||
mapNew.put("roleId", map.get("roleId"));
|
||||
mapNew.put("roleName", map.get("roleName"));
|
||||
mapNew.put("resId", map.get("resId"));
|
||||
mapNew.put("resName", map.get("resName"));
|
||||
mapNew.put("resUrl", map.get("resUrl"));
|
||||
resourceViewsTarget.add(mapNew);
|
||||
}
|
||||
return ResponseEntity.ok(resourceViewsTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色下拉选项
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity getRoleItem() {
|
||||
List<RoleInfoDTO> roleInfoDTOS = userService.getRoleItem();
|
||||
return ResponseEntity.ok(roleInfoDTOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源下拉选项
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity getResourceItem() {
|
||||
List<DicResourceDTO> dicResourceDTOS = userService.getResourceItem();
|
||||
return ResponseEntity.ok(dicResourceDTOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> getTreeItem() {
|
||||
List<RoleResourceTreeVo> roleResourceTreeVos = userService.getTreeItem();
|
||||
return ResponseEntity.ok(roleResourceTreeVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配角色权限
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ResponseEntity addResourceInfos(RoleResourceDetailDTO dto) {
|
||||
userService.setRoleResource(dto);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> addRole(RoleCreateParam dto) {
|
||||
userService.addRole(dto);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.volkswagen.mdmds.controller.api.PolicyApi;
|
||||
import com.volkswagen.mdmds.model.dto.PolicyBriefInfoDTO;
|
||||
import com.volkswagen.mdmds.model.dto.PolicyParamsDTO;
|
||||
import com.volkswagen.mdmds.model.entity.DicVehicleAttrAdapter;
|
||||
import com.volkswagen.mdmds.model.param.PolicyCreateParam;
|
||||
import com.volkswagen.mdmds.model.param.PolicyDeleteParam;
|
||||
import com.volkswagen.mdmds.model.param.PolicyParam;
|
||||
import com.volkswagen.mdmds.model.param.PolicySearchParam;
|
||||
import com.volkswagen.mdmds.repos.DicVehicleAttrAdapterRepository;
|
||||
import com.volkswagen.mdmds.service.LinkHWService;
|
||||
import com.volkswagen.mdmds.service.PolicyService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/28
|
||||
*/
|
||||
@RestController
|
||||
public class PolicyMgmtController implements PolicyApi {
|
||||
|
||||
private final PolicyService policyService;
|
||||
private final DicVehicleAttrAdapterRepository dicVehicleAttrAdapterRepository;
|
||||
|
||||
|
||||
@Resource
|
||||
private LinkHWService linkHWService;
|
||||
|
||||
public PolicyMgmtController(PolicyService policyService, DicVehicleAttrAdapterRepository dicVehicleAttrAdapterRepository) {
|
||||
this.policyService = policyService;
|
||||
this.dicVehicleAttrAdapterRepository = dicVehicleAttrAdapterRepository;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ResponseEntity receiveDcc(DccDTO dto) {
|
||||
// DataCollectionConfig dataCollectionConfig = policyService.upsertOneDCC(dto);
|
||||
// if (null != dataCollectionConfig.getId()) {
|
||||
// return ResponseEntity.ok(dataCollectionConfig);
|
||||
// } else {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public ResponseEntity<Page<PolicyBriefInfoDTO>> getPolicyInfos(int pageNo, int pageSize) {
|
||||
// Page<PolicyBriefInfoDTO> policyBriefInfoDTOS = policyService.pageableBriefPolicy(PageRequest.of(pageNo-1, pageSize));
|
||||
// return ResponseEntity.ok(policyBriefInfoDTOS);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<PolicyBriefInfoDTO>> getPolicySearch(PolicySearchParam param) {
|
||||
Page<PolicyBriefInfoDTO> policyBriefInfoDTOS = policyService.searchPolicyPage(param);
|
||||
return ResponseEntity.ok(policyBriefInfoDTOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity deleteConfiguration(@RequestBody PolicyDeleteParam param) {
|
||||
policyService.deleteConfigurationByIds(param.getIdList());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<PolicyBriefInfoDTO> getPolicyInfo(UUID id) {
|
||||
PolicyBriefInfoDTO policyBriefInfoDTO = policyService.getPolicyInfo(id);
|
||||
return ResponseEntity.ok(policyBriefInfoDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<PolicyBriefInfoDTO>> getPolicyViews(PolicyParamsDTO dto) {
|
||||
List<PolicyBriefInfoDTO> policyBriefInfoDTOS = policyService.getPolicyViews(dto);
|
||||
return ResponseEntity.ok(policyBriefInfoDTOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity getPolicyEventList(PolicyParam param) {
|
||||
// 映射表查询adsVersion值
|
||||
DicVehicleAttrAdapter dicVehicleAttrAdapter = dicVehicleAttrAdapterRepository.findByAdapterMapping(param.getAdsVersion());
|
||||
String adsVersion = null;
|
||||
if (dicVehicleAttrAdapter != null && StringUtils.hasText(dicVehicleAttrAdapter.getAdapterKey())) {
|
||||
adsVersion = dicVehicleAttrAdapter.getAdapterKey();
|
||||
}
|
||||
return ResponseEntity.ok(linkHWService.getEventListByAdsVersion(adsVersion));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ResponseEntity getPolicyConfiguration(@Parameter(description = "查询条件") @RequestBody PolicyParam param) {
|
||||
// return ResponseEntity.ok(linkHWService.getPolicyByAdsVersionAndEvent(param));
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public ResponseEntity save(PolicySaveParam param) {
|
||||
// policyService.save(param);
|
||||
// return ResponseEntity.ok().build();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ResponseEntity create(@RequestBody PolicyCreateParam param) {
|
||||
DicVehicleAttrAdapter dicVehicleAttrAdapter = dicVehicleAttrAdapterRepository.findByAdapterMapping(param.getAdsVersion());
|
||||
String adsVersion = null;
|
||||
if (dicVehicleAttrAdapter != null && StringUtils.hasText(dicVehicleAttrAdapter.getAdapterKey())) {
|
||||
adsVersion = dicVehicleAttrAdapter.getAdapterKey();
|
||||
}
|
||||
param.setAdsVersion(adsVersion);
|
||||
policyService.create(param);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.RoleInfoDTO;
|
||||
import com.volkswagen.mdmds.model.dto.UserInfoDTO;
|
||||
import com.volkswagen.mdmds.service.AuditService;
|
||||
import com.volkswagen.mdmds.service.UserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/6
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class TestController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private AuditService auditService;
|
||||
|
||||
@GetMapping("/anonymous")
|
||||
public ResponseEntity<String> getAnonymous(Principal principal) {
|
||||
int abc = auditService.countByCondition("ABC");
|
||||
if(abc>=0){
|
||||
return ResponseEntity.ok("Hello Anonymous 0803");
|
||||
}else{
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/admin")
|
||||
public ResponseEntity<String> getAdmin(Principal principal) {
|
||||
return ResponseEntity.ok("Hello Admin ");
|
||||
}
|
||||
|
||||
@GetMapping("/user")
|
||||
public ResponseEntity<String> getUser(Principal principal) {
|
||||
JwtAuthenticationToken token = (JwtAuthenticationToken) principal;
|
||||
String userName = (String) token.getTokenAttributes().get("name");
|
||||
String email = (String) token.getTokenAttributes().get("email");
|
||||
Map<String, List<String>> roleObject = (Map<String, List<String>>) token.getTokenAttributes().get("realm_access");
|
||||
List<String> roles = roleObject.get("roles");
|
||||
|
||||
UserInfoDTO userInfoDTO = new UserInfoDTO();
|
||||
userInfoDTO.setUserName(userName);
|
||||
userInfoDTO.setEmail(email);
|
||||
|
||||
List<RoleInfoDTO> roleInfoDTOList = roles.stream().map(x -> {
|
||||
RoleInfoDTO roleInfoDTO = new RoleInfoDTO();
|
||||
roleInfoDTO.setRoleName(x);
|
||||
return roleInfoDTO;
|
||||
}).toList();
|
||||
userInfoDTO.setRoleList(roleInfoDTOList);
|
||||
|
||||
userService.initInfo(userInfoDTO);
|
||||
|
||||
return ResponseEntity.ok("Hello User \nUser Name : " + userName + "\nUser Email : " + email + "\nRoles : " + roles.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.controller.api.TicketApi;
|
||||
import com.volkswagen.mdmds.model.dto.*;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import com.volkswagen.mdmds.model.entity.Ticket;
|
||||
import com.volkswagen.mdmds.model.param.TicketParam;
|
||||
import com.volkswagen.mdmds.model.param.TicketUpdateParam;
|
||||
import com.volkswagen.mdmds.model.pojo.TicketVehicleInfoPojo;
|
||||
import com.volkswagen.mdmds.model.vo.TicketVo;
|
||||
import com.volkswagen.mdmds.repos.TicketRepository;
|
||||
import com.volkswagen.mdmds.service.TicketService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@RestController
|
||||
public class TicketMgmtController implements TicketApi {
|
||||
|
||||
@Resource
|
||||
private TicketRepository ticketRepository;
|
||||
|
||||
private final TicketService ticketService;
|
||||
|
||||
public TicketMgmtController(TicketService ticketService) {
|
||||
this.ticketService = ticketService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity createTicket(TicketBriefInfoDTO dto) {
|
||||
dto.setStatus(ItemStatus.NONE);
|
||||
Ticket ticket = ticketService.createTicket(dto);
|
||||
if (ticket.getId() != null) {
|
||||
return ResponseEntity.ok(ticket);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity addVinToTicket(UUID id, String vin) {
|
||||
Ticket ticket = ticketService.addVinToTicket(id, vin);
|
||||
if (ticket.getId() != null) {
|
||||
return ResponseEntity.ok(ticket);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<TicketVo>> getPageableTicket(TicketParam param) {
|
||||
Page<TicketVo> ticketVoPage = ticketService.pageableTicket(param.getPageNo(), param.getPageSize(), param);
|
||||
return ResponseEntity.ok(ticketVoPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateTicketDescription(UUID id, TicketUpdateParam dto) {
|
||||
Ticket ticket = ticketService.updateTicketDescription(id, dto);
|
||||
if (ticket.getId() != null) {
|
||||
return ResponseEntity.ok(ticket);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity updateGroupVin(UUID id, TicketParamsDTO dto) {
|
||||
List<String> vinList = dto.getVinList();
|
||||
for(String vin : vinList) {
|
||||
if(vin.length() != 17) {
|
||||
throw new MdmdsException("VIN code error", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
Ticket ticket = ticketRepository.findOneByIdAndIsDeleted(id, 0);
|
||||
if (null == ticket) {
|
||||
throw new MdmdsException("The ticket does not exist", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
if (!ticket.getStatus().equals(ItemStatus.NONE)) {
|
||||
throw new MdmdsException("The ticket status is incorrect", HttpStatus.LOCKED);
|
||||
}
|
||||
ticket.setStatus(ItemStatus.RUN);
|
||||
ticketRepository.save(ticket);
|
||||
// 后台异步执行:工单关联VIN
|
||||
ticketService.updateGroupVinAndInfo(ticket, dto);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity changeTicketStatus(UUID id, TicketBriefInfoDTO dto) {
|
||||
Ticket ticket = ticketService.changeTicketStatus(id, dto);
|
||||
if (ticket.getId() != null) {
|
||||
return ResponseEntity.ok(ticket);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity deleteTicket(UUID id) {
|
||||
List<UUID> idList = new ArrayList<>();
|
||||
idList.add(id);
|
||||
ticketService.deleteTicketByIds(idList);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity deleteTicketByIds(TicketParamsDTO dto) {
|
||||
ticketService.deleteTicketByIds(dto.getIdList());
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<TicketDetailDTO> getTicketDetail(UUID id) {
|
||||
TicketDetailDTO ticketDetailDTO = ticketService.getTicketDetail(id);
|
||||
if (ticketDetailDTO.getId() != null) {
|
||||
return ResponseEntity.ok(ticketDetailDTO);
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<TicketVehicleResultDTO>> getVehicleViews(UUID id, TicketParamsDTO dto) {
|
||||
return ResponseEntity.ok(ticketService.getVehicleViews(id, dto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Page<TicketVehicleInfoPojo>> getVehicleInfos(TicketVehicleDTO dto) {
|
||||
int pageNo = dto.getPageNo();
|
||||
int pageSize = dto.getPageSize();
|
||||
UUID ticketId = dto.getId();
|
||||
return ResponseEntity.ok(ticketService.pageableVehicleInfo(PageRequest.of(pageNo - 1, pageSize), ticketId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.volkswagen.mdmds.controller;
|
||||
|
||||
import com.volkswagen.mdmds.config.exception.MdmdsException;
|
||||
import com.volkswagen.mdmds.constant.CommonField;
|
||||
import com.volkswagen.mdmds.controller.api.VehicleApi;
|
||||
import com.volkswagen.mdmds.model.dto.VehicleParamsDTO;
|
||||
import com.volkswagen.mdmds.model.dto.VehicleReturnDTO;
|
||||
import com.volkswagen.mdmds.service.VehicleService;
|
||||
import com.volkswagen.mdmds.utils.AntStrUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@RestController
|
||||
public class VehicleController implements VehicleApi {
|
||||
|
||||
@Resource
|
||||
private VehicleService vehicleService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<VehicleReturnDTO>> getVidByVin(VehicleParamsDTO dto) {
|
||||
List<String> vinList = dto.getVinList();
|
||||
for(String vin : vinList) {
|
||||
if(!AntStrUtil.isVIN(vin)) {
|
||||
throw new MdmdsException(CommonField.VIN_ERROR, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
List<VehicleReturnDTO> list = vehicleService.getVidList(dto);
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<VehicleReturnDTO>> getVinByVID(VehicleParamsDTO dto) {
|
||||
List<VehicleReturnDTO> list = vehicleService.getVinList(dto);
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<VehicleReturnDTO>> getVehicleInfoByVid(VehicleParamsDTO dto) {
|
||||
List<VehicleReturnDTO> list = vehicleService.getVehicleInfoList(dto);
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> getVehicleFieldValue(String name) {
|
||||
String result = vehicleService.getVehicleFieldValuesByName(name);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.AttrWithValuesDTO;
|
||||
import com.volkswagen.mdmds.model.dto.AttributeDTO;
|
||||
import com.volkswagen.mdmds.model.dto.UploadDataDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 车辆属性API
|
||||
*
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@Tag(name = AttributeApi.Constants.API_NAME,description = "车辆属性API")
|
||||
public interface AttributeApi {
|
||||
|
||||
@PostMapping(value = Constants.BASE_PATH)
|
||||
@Operation(summary = "添加一个新的车辆属性", description = "根据车辆属性名称,映射关系,状态新建一个车辆属性,创建属性默认状态是ENABLE")
|
||||
default ResponseEntity<AttributeDTO> addAttribute(@Parameter(description = "车辆属性",required = true)@Valid @RequestBody AttributeDTO attributeDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = Constants.BASE_PATH + "/all")
|
||||
@Operation(summary = "查看已有的车辆属性")
|
||||
default ResponseEntity<List<AttributeDTO>> getAllAttrs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = Constants.BASE_PATH + "/views")
|
||||
@Operation(summary = "根据条件查询车辆属性字段",
|
||||
description = "车辆属性字段不多(同DT接口同步校验),不使用分页(status为ENABLE或DISABLE,为null时查询所有数据)")
|
||||
default ResponseEntity<List<AttributeDTO>> getAttrViews(@Parameter(description = "车辆属性",required = true) @RequestBody AttributeDTO attributeDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = Constants.BASE_PATH + "/{id}" + "/status")
|
||||
@Operation(summary = "更新车辆属性状态", description = "根据车辆属性id更新状态(ENABLE,DISABLE)")
|
||||
default ResponseEntity<AttributeDTO> changeAttributeStatus(
|
||||
@PathVariable(value = "id") @Parameter(description = "属性的唯一ID") UUID id,
|
||||
@Parameter(description = "只需要传status,只有两个选项(ENABLE,DISABLE)") @RequestBody AttributeDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DeleteMapping(value = Constants.BASE_PATH + "/delete" + "/{id}")
|
||||
@Operation(summary = "删除车辆属性字段", description = "通过车辆属性字段ID删除")
|
||||
default ResponseEntity<Object> deleteAttributeById(@PathVariable(value = "id") @Parameter(description = "车型属性的唯一ID") UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DeleteMapping(value = Constants.BASE_PATH + "/clear")
|
||||
@Operation(summary = "一键删除所有车辆属性")
|
||||
default ResponseEntity<String> clearTable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = Constants.BASE_PATH + "/verification")
|
||||
@Operation(summary = "校验数据车辆属性字段与DT的属性字段", description = "比对数据库与DT的属性字段名称,更新结果")
|
||||
default ResponseEntity<String> verification() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = Constants.BASE_PATH + "/values")
|
||||
@Operation(summary = "同步车辆属性字段的值", description = "根据数据库车辆属性字段名称同步DT接口返回的值")
|
||||
default ResponseEntity<String> getAttrValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = Constants.BASE_PATH + "/{id}")
|
||||
@Operation(summary = "更新或创建指定ID的车辆属性")
|
||||
default ResponseEntity<AttributeDTO> updateVehicleAttr(
|
||||
@PathVariable(value = "id") @Parameter(description = "属性ID",required = true,example = "1234") UUID id,
|
||||
@RequestBody @Parameter(description = "车辆属性信息",required = true)AttributeDTO attributeDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = Constants.BASE_PATH + "/checkedAttr")
|
||||
@Operation(summary = "校验车辆属性字段名称是否与DT一致", description = "根据车辆属性字段名称(attrName)校验是否在DT存在")
|
||||
default ResponseEntity<String> verificationAttrName(@Parameter(description = "车辆属性",required = true)@Valid @RequestBody AttributeDTO attributeDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = Constants.BASE_PATH + "/kv")
|
||||
@Operation(summary = "获取车辆属性的键值对",description = "系统会定时聚合可能存在的属性-值组合,用于界面的下拉选项")
|
||||
default ResponseEntity<List<AttrWithValuesDTO>> getAllAttrValueMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = Constants.BASE_PATH + "/excel/upload")
|
||||
@Operation(summary = "上传车辆字段", description = "车辆字段作为查询车辆VID的条件,创建分组时需要根据车辆字段查询VID")
|
||||
default ResponseEntity<Object> uploadExcel(@RequestParam MultipartFile file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = Constants.BASE_PATH + "/excel/upload/check")
|
||||
@Operation(summary = "校验上传的车辆字段", description = "车辆字段作为查询车辆VID的条件,创建分组时需要根据车辆字段查询VID")
|
||||
default ResponseEntity<Object> uploadExcelCheck(@RequestParam MultipartFile file) {
|
||||
return null;
|
||||
}
|
||||
@PostMapping(value = Constants.BASE_PATH + "/excel/upload/data")
|
||||
@Operation(summary = "上传校验后的车辆字段", description = "车辆字段作为查询车辆VID的条件,创建分组时需要根据车辆字段查询VID")
|
||||
default ResponseEntity<Object> uploadExcelData(@Valid @RequestBody UploadDataDTO uploadDataDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = Constants.BASE_PATH + "/excel/downloadTemplate")
|
||||
@Operation(summary = "下载车辆字段模板", description = "车辆字段作为查询车辆VID的条件,创建分组时需要根据车辆字段查询VID")
|
||||
default ResponseEntity<Object> downloadExcelTemplate(HttpServletResponse response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = Constants.BASE_PATH + "/update/vehicle")
|
||||
@Operation(summary = "同步DT的车辆字段更新入库", description = "")
|
||||
default ResponseEntity<Object> updateVehicleKeyAndValue(HttpServletResponse response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
final class Constants {
|
||||
public static final String API_NAME = "attribute";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
174
src/main/java/com/volkswagen/mdmds/controller/api/GroupApi.java
Normal file
174
src/main/java/com/volkswagen/mdmds/controller/api/GroupApi.java
Normal file
@@ -0,0 +1,174 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.*;
|
||||
import com.volkswagen.mdmds.model.param.GroupCreateParam;
|
||||
import com.volkswagen.mdmds.model.param.VehicleGroupParam;
|
||||
import com.volkswagen.mdmds.model.pojo.GroupVehicleInfoPojo;
|
||||
import com.volkswagen.mdmds.model.vo.VehicleGroupVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 车辆分组管理API
|
||||
*
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Tag(name = GroupApi.Constants.API_NAME, description = "车辆分组管理API")
|
||||
@Validated
|
||||
public interface GroupApi {
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH)
|
||||
@Operation(summary = "创建车辆分组", description = "只需要输入组名,具体内容使用更新接口,只需要填写组名,其他都可不填")
|
||||
default ResponseEntity<GroupBriefInfoDTO> createGroup(
|
||||
@Parameter(description = "车辆分组名称,只需要填写组名,其他都可不填")
|
||||
@RequestBody @Valid GroupCreateParam groupBriefInfoDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DeleteMapping(value = GroupApi.Constants.BASE_PATH + "/{id}")
|
||||
@Operation(summary = "删除分组", description = "根据ID删除分组")
|
||||
default ResponseEntity<GroupDetailInfoDTO> deleteGroupById(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/delete")
|
||||
@Operation(summary = "删除分组-批量", description = "根据批量ID删除分组")
|
||||
default ResponseEntity<String> deletedGroupByIds(
|
||||
@RequestBody(required = true) @Parameter(description = "输入批量分组ID('idList')") @Valid GroupParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/page")
|
||||
@Operation(summary = "查询所有车辆分组的简要信息", description = "根据分页条件,展示车辆分组基础信息")
|
||||
default ResponseEntity<Page<VehicleGroupVo>> getPageableGroup(@RequestBody @Valid VehicleGroupParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/{id}")
|
||||
@Operation(summary = "查询车辆分组的详细信息", description = "主要包含动态的分组信息和分组元数据,车辆信息不在这个接口返回")
|
||||
default ResponseEntity<GroupDetailInfoDTO> getGroupDetailInfo(
|
||||
@PathVariable(value = "id") @Parameter(description = "车辆分组唯一ID", required = true) UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = GroupApi.Constants.BASE_PATH + "/{id}")
|
||||
@Operation(summary = "更新车辆分组的条件", description = "分组条件是动态的,需要用打平的json字符串传输")
|
||||
default ResponseEntity<GroupDetailInfoDTO> updateGroupCriteria(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@RequestBody(required = true) @Parameter(description = "车辆分组是动态的,界面可以下拉选择,也可以输入") @Valid GroupDetailInfoDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = GroupApi.Constants.BASE_PATH + "/vin/{id}")
|
||||
@Operation(summary = "更新车辆分组的VIN", description = "分组关联多辆车,车通过vin关联。入参需要tags, vinList, version")
|
||||
default ResponseEntity<GroupDetailInfoDTO> updateGroupVin(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@RequestBody(required = true) GroupParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = GroupApi.Constants.BASE_PATH + "/configuration")
|
||||
@Operation(summary = "更新车辆分组的配置", description = "关联车辆分组ID和配置ID")
|
||||
default ResponseEntity<String> updateGroupConfiguration(
|
||||
@RequestParam(name = "groupId") @Parameter(description = "车辆分组ID", required = true) UUID groupId,
|
||||
@RequestParam(name = "dccId") @Parameter(description = "配置项ID", required = false) UUID dccId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = GroupApi.Constants.BASE_PATH + "/configuration/unbind")
|
||||
@Operation(summary = "解除车辆分组的配置", description = "解除车辆分组ID和配置ID")
|
||||
default ResponseEntity<String> unbindGroupConfiguration(
|
||||
@RequestParam(name = "groupId") @Parameter(description = "车辆分组ID", required = true) UUID groupId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/vehicle/getVIDs/{id}")
|
||||
@Operation(summary = "X查询车辆ID更新分组关联的车辆ID", description = "根据条件从DT接口获取VIDs")
|
||||
default ResponseEntity<String> getVehicleIds(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@Parameter(description = "车辆分组条件,只需要填写分组条件,其他都可不填")
|
||||
@RequestBody GroupDetailInfoDTO groupDetailInfoDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/vehicle/getAllVIDs/{id}")
|
||||
@Operation(summary = "根据车辆字段条件查询车辆VID", description = "根据车辆字段条件从DT接口获取VIDs用于前端展示,入参Body部分需要specificationJson")
|
||||
default ResponseEntity<List<String>> getAllVIDs(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@Parameter(description = "车辆查询条件,只需要填写'specificationJson'", example = "{\"and\":[{\"color\":\"blue\"},{\"brand_name\":\"Audi\"}]}")
|
||||
@RequestBody GroupParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/vehicle/getInfos")
|
||||
@Operation(summary = "根据分组查询关联的车辆列表", description = "根据条件创建的分组通过VID获取车辆信息,根据VIN创建的分组通过VIN获取车辆信息。需要入参id为分组id,其他字段不需要")
|
||||
default ResponseEntity<Page<GroupVehicleInfoPojo>> getVehicleInfos(@RequestBody GroupVehicleDTO groupVehicleDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/vehicle/views/{id}")
|
||||
@Operation(summary = "根据车辆VID查询车辆信息", description = "根据车辆VID查询车辆信息,需要入参vidList为多个车辆VID")
|
||||
default ResponseEntity<List<GroupVehicleResultDTO>> getVehicleViews(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@Parameter(description = "车辆信息查询,只需要填写'vidList'")
|
||||
@RequestBody GroupParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/ticket/create/{id}")
|
||||
@Operation(summary = "根据分组车辆创建工单")
|
||||
default ResponseEntity<String> createNewTicket(
|
||||
@PathVariable @Parameter(description = "车辆分组唯一ID", required = true) UUID id,
|
||||
@Parameter(description = "批量车辆关联创建的工单")
|
||||
@RequestBody TicketParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = GroupApi.Constants.BASE_PATH + "/attribute/all")
|
||||
@Operation(summary = "查看已有的车辆属性")
|
||||
default ResponseEntity<List<AttributeDTO>> getAllAttrs() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = GroupApi.Constants.BASE_PATH + "/attribute/kv")
|
||||
@Operation(summary = "获取车辆属性的键值对",description = "系统会定时聚合可能存在的属性-值组合,用于界面的下拉选项")
|
||||
default ResponseEntity<List<AttrWithValuesDTO>> getAllAttrValueMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = GroupApi.Constants.BASE_PATH + "/policy/detail/{id}")
|
||||
@Operation(summary = "查询配置信息", description = "根据配置ID查询配置详细信息")
|
||||
default ResponseEntity<PolicyBriefInfoDTO> getPolicyInfo(
|
||||
@PathVariable @Parameter(description = "配置唯一ID", required = true) UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = GroupApi.Constants.BASE_PATH + "/policy/view")
|
||||
@Operation(summary = "根据版本查询所有配置", description = "查询结果用于根据车辆版本关联可选的配置版本")
|
||||
default ResponseEntity<List<PolicyBriefInfoDTO>> getPolicyViews(@Parameter(description = "查询条件") @RequestBody PolicyParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
final class Constants {
|
||||
public static final String API_NAME = "group";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.volkswagen.mdmds.model.dto.*;
|
||||
import com.volkswagen.mdmds.model.param.RoleCreateParam;
|
||||
import com.volkswagen.mdmds.model.param.UserStatusParam;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = PermissionApi.Constants.API_NAME, description = "权限管理API")
|
||||
@Validated
|
||||
public interface PermissionApi {
|
||||
|
||||
final class Constants {
|
||||
public static final String API_NAME = "permission";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String USER_PATH = BASE_PATH + "/user";
|
||||
public static final String ROLE_PATH = BASE_PATH + "/role";
|
||||
public static final String RESOURCE_PATH = BASE_PATH + "/resource";
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.USER_PATH + "/login")
|
||||
@Operation(summary = "初始化用户信息", description = "解析Token获取用户关联的角色权限信息")
|
||||
default ResponseEntity<UserInfoDTO> initUser(
|
||||
@Parameter(description = "解析token获取用户信息,token必填") Principal principal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.USER_PATH + "/sameUserOnline")
|
||||
@Operation(summary = "当前已有相同用户在线", description = "当前已有相同用户在线")
|
||||
default ResponseEntity<Object> sameUserOnline(HttpServletRequest request,@Parameter(description = "解析token获取用户信息,token必填") Principal principal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.USER_PATH + "/logout")
|
||||
@Operation(summary = "退出登录", description = "退出登录")
|
||||
default ResponseEntity<Object> logout(HttpServletRequest request,@Parameter(description = "解析token获取用户信息,token必填") Principal principal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = PermissionApi.Constants.USER_PATH + "/invalidToken")
|
||||
@Operation(summary = "token失效", description = "token失效")
|
||||
default ResponseEntity<Object> invalidToken(@RequestBody JSONObject token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.USER_PATH + "/forceLogin")
|
||||
@Operation(summary = "强制登录", description = "强制登录")
|
||||
default ResponseEntity<Object> forceLogin(HttpServletRequest request, @Parameter(description = "解析token获取用户信息,token必填") Principal principal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.USER_PATH + "/list")
|
||||
@Operation(summary = "分页查询所有用户信息",description = "根据分页条件,展示用户的基础信息")
|
||||
default ResponseEntity<Page<UserInfoDTO>> getUserInfos(
|
||||
@RequestParam(name = "pageNo",defaultValue = "1") @Parameter(description = "页码",required = true) int pageNo,
|
||||
@RequestParam(name = "pageSize",defaultValue = "10") @Parameter(description = "每页显示的数量",required = false)int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = PermissionApi.Constants.USER_PATH + "/{id}" + "/status")
|
||||
@Operation(summary = "禁用用户", description = "根据用户id更新状态(ENABLE,DISABLE)")
|
||||
default ResponseEntity<Object> alterUserStatus(
|
||||
@PathVariable(value = "id") @Parameter(description = "属性的唯一ID") UUID id,
|
||||
@Parameter(description = "只需要传status,只有两个选项(ENABLE,DISABLE)") @RequestBody UserStatusParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.ROLE_PATH + "/list")
|
||||
@Operation(summary = "分页查询所有角色信息",description = "根据分页条件,展示角色的基础信息")
|
||||
default ResponseEntity<Page<RoleInfoDTO>> getRoleInfos(
|
||||
@RequestParam(name = "pageNo",defaultValue = "1") @Parameter(description = "页码",required = true) int pageNo,
|
||||
@RequestParam(name = "pageSize",defaultValue = "10") @Parameter(description = "每页显示的数量",required = false)int pageSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DeleteMapping(value = PermissionApi.Constants.ROLE_PATH + "/{id}")
|
||||
@Operation(summary = "删除角色",description = "根据ID删除角色")
|
||||
default ResponseEntity<Object> deleteRoleById(@PathVariable @Parameter(description = "角色唯一ID", required = true) UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.RESOURCE_PATH + "/list")
|
||||
@Operation(summary = "查询所有资源信息",description = "根据分页条件,展示资源的基础信息")
|
||||
default ResponseEntity<Page<ResourceInfoDTO>> getResourceInfos(
|
||||
@RequestParam(name = "pageNo",defaultValue = "1") @Parameter(description = "页码",required = true) int pageNo,
|
||||
@RequestParam(name = "pageSize",defaultValue = "10") @Parameter(description = "每页显示的数量",required = false)int pageSize) {
|
||||
return null;
|
||||
}
|
||||
@GetMapping(value = PermissionApi.Constants.RESOURCE_PATH + "/view")
|
||||
@Operation(summary = "查询所有资源信息",description = "展示资源的基础信息")
|
||||
default ResponseEntity<List<Map<String, String>>> getResourceViews() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.ROLE_PATH + "/item")
|
||||
@Operation(summary = "查询所有角色ID及名称",description = "查询角色选项")
|
||||
default ResponseEntity<Object> getRoleItem() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.RESOURCE_PATH + "/item")
|
||||
@Operation(summary = "查询所有资源ID及名称",description = "查询资源选项")
|
||||
default ResponseEntity<Object> getResourceItem() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = PermissionApi.Constants.ROLE_PATH + "/tree")
|
||||
@Operation(summary = "查询角色菜单结构", description = "查询角色菜单结构选项")
|
||||
default ResponseEntity<Object> getTreeItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = PermissionApi.Constants.RESOURCE_PATH + "/add")
|
||||
@Operation(summary = "创建角色资源", description = "添加资源并分配给角色")
|
||||
default ResponseEntity<Object> addResourceInfos(@Parameter(description = "分配角色权限") @RequestBody @Valid RoleResourceDetailDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = Constants.ROLE_PATH + "/add")
|
||||
@Operation(summary = "创建角色", description = "创建角色")
|
||||
default ResponseEntity<Object> addRole(@Parameter(description = "创建角色") @RequestBody @Valid RoleCreateParam dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
111
src/main/java/com/volkswagen/mdmds/controller/api/PolicyApi.java
Normal file
111
src/main/java/com/volkswagen/mdmds/controller/api/PolicyApi.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.DccDTO;
|
||||
import com.volkswagen.mdmds.model.dto.PolicyBriefInfoDTO;
|
||||
import com.volkswagen.mdmds.model.dto.PolicyParamsDTO;
|
||||
import com.volkswagen.mdmds.model.param.*;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/28
|
||||
*/
|
||||
@Tag(name = PolicyApi.Constants.API_NAME,description = "车辆分组管理API")
|
||||
public interface PolicyApi {
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
final class Constants {
|
||||
public static final String API_NAME = "policy";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @GetMapping(value = PolicyApi.Constants.BASE_PATH)
|
||||
// @Operation(summary = "查询所有策略的简要信息",description = "根据分页条件,展示策略的基础信息")
|
||||
// default ResponseEntity<Page<PolicyBriefInfoDTO>> getPolicyInfos(
|
||||
// @RequestParam(name = "pageNo",defaultValue = "1") @Parameter(description = "页码") int pageNo,
|
||||
// @RequestParam(name = "pageSize",defaultValue = "10") @Parameter(description = "每页显示的数量",required = false)
|
||||
// @Positive(message = "每页数量必须是正数") int pageSize) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@PostMapping(value = PolicyApi.Constants.BASE_PATH + "/search")
|
||||
@Operation(summary = "查询所有策略的简要信息",description = "根据分页条件,展示策略的基础信息")
|
||||
default ResponseEntity<Page<PolicyBriefInfoDTO>> getPolicySearch(
|
||||
@RequestBody PolicySearchParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = PolicyApi.Constants.BASE_PATH + "/delete")
|
||||
@Operation(summary = "删除配置", description = "根据配置ID删除")
|
||||
default ResponseEntity<Object> deleteConfiguration(@RequestBody PolicyDeleteParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @PostMapping(value = PolicyApi.Constants.BASE_PATH)
|
||||
// @Operation(summary = "接收配置信息",description = "接收来自于EHRM的配置信息,只能接收EHRM的调用!")
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200",description = "成功"),
|
||||
// @ApiResponse(responseCode = "500",description = "未知错误"),
|
||||
// @ApiResponse(responseCode = "409",description = "配置项已经存在")
|
||||
// })
|
||||
// @SecurityRequirement(name = "Bearer Authentication")
|
||||
// default ResponseEntity<Object> receiveDcc(@Parameter(description = "数据收集策略") @RequestBody DccDTO dto) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@GetMapping(value = PolicyApi.Constants.BASE_PATH + "/detail/{id}")
|
||||
@Operation(summary = "查询配置信息", description = "根据配置ID查询配置详细信息")
|
||||
default ResponseEntity<PolicyBriefInfoDTO> getPolicyInfo(
|
||||
@PathVariable @Parameter(description = "配置唯一ID", required = true) UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = PolicyApi.Constants.BASE_PATH + "/view")
|
||||
@Operation(summary = "根据版本查询所有配置", description = "查询结果用于根据车辆版本关联可选的配置版本")
|
||||
default ResponseEntity<List<PolicyBriefInfoDTO>> getPolicyViews(@Parameter(description = "查询条件") @RequestBody PolicyParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = PolicyApi.Constants.BASE_PATH + "/event/list")
|
||||
@Operation(summary = "根据版本查询EventList", description = "")
|
||||
default ResponseEntity<Object> getPolicyEventList(@Parameter(description = "查询条件") @RequestBody PolicyParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @PostMapping(value = PolicyApi.Constants.BASE_PATH + "/configuration")
|
||||
// @Operation(summary = "根据版本和EventList查询Configuration", description = "")
|
||||
// default ResponseEntity<Object> getPolicyConfiguration(@Parameter(description = "查询条件") @RequestBody PolicyParam param) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// @PostMapping(value = PolicyApi.Constants.BASE_PATH + "/save")
|
||||
// @Operation(summary = "创建Configuration", description = "")
|
||||
// default ResponseEntity<Object> save(@RequestBody PolicySaveParam param) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@PostMapping(value = PolicyApi.Constants.BASE_PATH + "/create")
|
||||
@Operation(summary = "创建Configuration", description = "")
|
||||
default ResponseEntity<Object> create(@RequestBody @Valid PolicyCreateParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
127
src/main/java/com/volkswagen/mdmds/controller/api/TicketApi.java
Normal file
127
src/main/java/com/volkswagen/mdmds/controller/api/TicketApi.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.TicketBriefInfoDTO;
|
||||
import com.volkswagen.mdmds.model.dto.TicketDetailDTO;
|
||||
import com.volkswagen.mdmds.model.dto.TicketParamsDTO;
|
||||
import com.volkswagen.mdmds.model.dto.TicketVehicleDTO;
|
||||
import com.volkswagen.mdmds.model.dto.TicketVehicleResultDTO;
|
||||
import com.volkswagen.mdmds.model.param.TicketParam;
|
||||
import com.volkswagen.mdmds.model.param.TicketUpdateParam;
|
||||
import com.volkswagen.mdmds.model.pojo.TicketVehicleInfoPojo;
|
||||
import com.volkswagen.mdmds.model.vo.TicketVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 车辆异常工单管理API
|
||||
*
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Tag(name = TicketApi.Constants.API_NAME,description = "车辆分组管理API")
|
||||
public interface TicketApi {
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
final class Constants {
|
||||
public static final String API_NAME = "ticket";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = TicketApi.Constants.BASE_PATH)
|
||||
@Operation(summary = "创建新工单",description = "根据名称生成新的工单,具体信息使用更新接口,工单名称必填,其他无用")
|
||||
default ResponseEntity<TicketBriefInfoDTO> createTicket(@Parameter(description = "工单名称必填,其他无用") @Valid @RequestBody TicketBriefInfoDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = TicketApi.Constants.BASE_PATH + "/page")
|
||||
@Operation(summary = "查询所有异常工单的简要信息",description = "根据分页条件,展示异常工单的基础信息")
|
||||
default ResponseEntity<Page<TicketVo>> getPageableTicket(@RequestBody @Valid TicketParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = TicketApi.Constants.BASE_PATH + "/des" + "/{id}")
|
||||
@Operation(summary = "更新工单描述",description = "只需要传描述字段<ticketDetail>,其余无用")
|
||||
default ResponseEntity<Object> updateTicketDescription(
|
||||
@PathVariable(value = "id") @Parameter(description = "工单的唯一ID") UUID id,
|
||||
@Parameter(description = "工单的描述") @RequestBody @Valid TicketUpdateParam dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = TicketApi.Constants.BASE_PATH + "/vin/{id}")
|
||||
@Operation(summary = "工单添加异常车辆信息(批量)", description = "工单关联多个车辆VIN,入参只传vinList")
|
||||
default ResponseEntity<TicketDetailDTO> updateGroupVin(
|
||||
@PathVariable @Parameter(description = "工单唯一ID", required = true) UUID id,
|
||||
@RequestBody(required = true) TicketParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@PutMapping(value = TicketApi.Constants.BASE_PATH + "/vin" + "/{id}" + "/{vin}")
|
||||
@Operation(summary = "X工单添加异常车辆信息(停用)",
|
||||
description = "只需要传vin,系统收到vin后会去db或digital twin要车辆的信息,然后存到本地,和ticket进行关联")
|
||||
default ResponseEntity<Object> addVinToTicket(
|
||||
@PathVariable(value = "id") @Parameter(description = "工单的唯一ID") UUID id,
|
||||
@PathVariable(value = "vin")String vin) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@PutMapping(value = TicketApi.Constants.BASE_PATH + "/{id}" + "/status")
|
||||
@Operation(summary = "改变工单状态",description = "只需要传status,只有两个选项HOLD,DONE。其他选项会报错")
|
||||
default ResponseEntity<Object> changeTicketStatus(@PathVariable(value = "id") @Parameter(description = "工单的唯一ID") UUID id,
|
||||
@Parameter(description = "状态") @RequestBody TicketBriefInfoDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DeleteMapping(value = TicketApi.Constants.BASE_PATH + "/delete" + "/{id}")
|
||||
@Operation(summary = "删除工单", description = "根据工单ID删除")
|
||||
default ResponseEntity<Object> deleteTicket(@PathVariable(value = "id") @Parameter(description = "工单的唯一ID") UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = TicketApi.Constants.BASE_PATH + "/delete")
|
||||
@Operation(summary = "删除工单-批量", description = "根据工单ID删除")
|
||||
default ResponseEntity<Object> deleteTicketByIds(@RequestBody(required = true) @Parameter(description = "输入批量工单ID('idList')") @Valid TicketParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = TicketApi.Constants.BASE_PATH + "/detail" + "/{id}")
|
||||
@Operation(summary = "查询工单详细信息", description = "根据id获取工单关联的车辆信息")
|
||||
default ResponseEntity<TicketDetailDTO> getTicketDetail(@PathVariable(value = "id") @Parameter(description = "工单的唯一ID") UUID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = TicketApi.Constants.BASE_PATH + "/vehicle/views/{id}")
|
||||
@Operation(summary = "根据车辆VID查询车辆信息", description = "根据车辆VID查询车辆信息,需要入参vidList为多个车辆VID")
|
||||
default ResponseEntity<List<TicketVehicleResultDTO>> getVehicleViews(
|
||||
@PathVariable @Parameter(description = "工单唯一ID", required = true) UUID id,
|
||||
@Parameter(description = "车辆信息查询,只需要填写'vidList'")
|
||||
@RequestBody TicketParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = TicketApi.Constants.BASE_PATH + "/vehicle/getInfos")
|
||||
@Operation(summary = "根据工单查询关联的车辆列表",
|
||||
description = "工单ID查询关联的VID,再根据VID查询车辆信息。需要入参id为工单id,其他字段不需要")
|
||||
default ResponseEntity<Page<TicketVehicleInfoPojo>> getVehicleInfos(@RequestBody TicketVehicleDTO ticketVehicleDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.volkswagen.mdmds.controller.api;
|
||||
|
||||
import com.volkswagen.mdmds.model.dto.VehicleParamsDTO;
|
||||
import com.volkswagen.mdmds.model.dto.VehicleReturnDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = VehicleApi.Constants.API_NAME, description = "车辆管理API")
|
||||
public interface VehicleApi {
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
final class Constants {
|
||||
public static final String API_NAME = "vehicle";
|
||||
public static final String BASE_PATH = "/mdmds" + "/v1/" + API_NAME;
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
private Constants() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = VehicleApi.Constants.BASE_PATH + "/getVIDs")
|
||||
@Operation(summary = "根据车辆VIN查询VID",
|
||||
description = "根据车辆VIN查询车辆VID:传参vinList;返回statusCode代表VWAC接口错误码(正常为null),返回message代表错误信息")
|
||||
default ResponseEntity<List<VehicleReturnDTO>> getVidByVin(@RequestBody(required = true) VehicleParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = VehicleApi.Constants.BASE_PATH + "/getVINs")
|
||||
@Operation(summary = "根据车辆VID查询VIN",
|
||||
description = "根据车辆VIN查询车辆VID:传参vidList;返回statusCode代表VWAC接口错误码(正常为null),返回message代表错误信息")
|
||||
default ResponseEntity<List<VehicleReturnDTO>> getVinByVID(@RequestBody(required = true) VehicleParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping(value = VehicleApi.Constants.BASE_PATH + "/getVehicleInfo")
|
||||
@Operation(summary = "根据车辆VID查询车辆信息",
|
||||
description = "根据车辆VID查询车辆信息(处理DT接口返回的Json数据):传参vidList")
|
||||
default ResponseEntity<List<VehicleReturnDTO>> getVehicleInfoByVid(@RequestBody(required = true) VehicleParamsDTO dto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GetMapping(value = VehicleApi.Constants.BASE_PATH + "/field/values/{name}")
|
||||
@Operation(summary = "获取车辆字段的数据", description = "例如:根据ads_version获取车辆的ADS Version")
|
||||
default ResponseEntity<String> getVehicleFieldValue(@PathVariable(value = "name") String name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Data
|
||||
public class AttrWithValuesDTO {
|
||||
private String attrName;
|
||||
private JSONArray values;
|
||||
|
||||
private String mappingName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@Data
|
||||
public class AttributeDTO{
|
||||
private UUID id;
|
||||
|
||||
@NotEmpty(message = "车辆属性名称是必填项")
|
||||
private String attrName;
|
||||
private String mappingName;
|
||||
private ItemStatus status;
|
||||
|
||||
private String remark;
|
||||
|
||||
}
|
||||
29
src/main/java/com/volkswagen/mdmds/model/dto/AuditDTO.java
Normal file
29
src/main/java/com/volkswagen/mdmds/model/dto/AuditDTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class AuditDTO {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String log;
|
||||
|
||||
private String reqIP;
|
||||
|
||||
private String reqURI;
|
||||
|
||||
private String reqMethod;
|
||||
|
||||
private String reqMethodName;
|
||||
|
||||
private String reqParams;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
}
|
||||
50
src/main/java/com/volkswagen/mdmds/model/dto/DccDTO.java
Normal file
50
src/main/java/com/volkswagen/mdmds/model/dto/DccDTO.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/28
|
||||
* <p>
|
||||
* Data Collection Configuration
|
||||
* <p>
|
||||
* {
|
||||
* "comments":"policy1“
|
||||
* "subscription": "policy1",
|
||||
* "adsVersion": "ADSV 1.0.0-A0000001.B001",
|
||||
* "configuration": "c2hhMjU2IG9mIGNvbmZpZ3VyYXRpb24ncyBiYXNlNjQgc3RyaW5n",
|
||||
* "sha256": "71568f9eb4ee7d3711c3f1d0e31c8b6b9b7086bec70e1487e279367bf243fe8e",
|
||||
* "events":[{
|
||||
* "eventId": "10000",
|
||||
* "eventName": "Matual handler",
|
||||
* "eventDesc": "Matual handler",
|
||||
* "eventType": "trigger",
|
||||
* "eventScope": [-15, 5]
|
||||
* },{
|
||||
* "eventId": "99999",
|
||||
* "eventName": "Vehicle Status",
|
||||
* "eventDesc": "Vehicle Status",
|
||||
* "eventType": "periodic",
|
||||
* "eventScope": null
|
||||
* }]
|
||||
* }
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DccDTO {
|
||||
private String comments;
|
||||
@NotEmpty(message = "subscription是必填项")
|
||||
private String subscription;
|
||||
@NotEmpty(message = "adsVersion是必填项")
|
||||
private String adsVersion;
|
||||
@NotEmpty(message = "configuration是必填项")
|
||||
private String configuration;
|
||||
private String sha256;
|
||||
private List<EventDTO> events;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class DicResourceDTO {
|
||||
|
||||
private UUID resId;
|
||||
|
||||
private String resName;
|
||||
|
||||
private String resUrl;
|
||||
|
||||
}
|
||||
20
src/main/java/com/volkswagen/mdmds/model/dto/EventDTO.java
Normal file
20
src/main/java/com/volkswagen/mdmds/model/dto/EventDTO.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/28
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class EventDTO {
|
||||
private String eventId;
|
||||
private String eventName;
|
||||
private String eventDesc;
|
||||
private String eventType;
|
||||
private List<List<Integer>> eventScope;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class GroupBriefInfoDTO {
|
||||
protected UUID id;
|
||||
|
||||
@NotEmpty(message = "Group Name is required")
|
||||
// @Pattern(regexp = "^[a-z0-9A-Z\u4e00-\u9fa5]+$")
|
||||
private String groupName;
|
||||
|
||||
private String status;
|
||||
private String specificationJson;
|
||||
private String tags;
|
||||
private Integer mold;
|
||||
|
||||
public GroupBriefInfoDTO(UUID id, String groupName, String status, String specificationJson, String tags, Integer mold) {
|
||||
this.id = id;
|
||||
this.groupName = groupName;
|
||||
this.status = status;
|
||||
this.specificationJson = specificationJson;
|
||||
this.tags = tags;
|
||||
this.mold = mold;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class GroupDetailInfoDTO {
|
||||
protected UUID id;
|
||||
private String groupName;
|
||||
private ItemStatus status;
|
||||
@NotEmpty
|
||||
private String specificationJson;
|
||||
private List<String> tags;
|
||||
private List<VehicleInfoDTO> vehicles;
|
||||
//从EHR-M收到的数据接收策略的名字
|
||||
private String dccName;
|
||||
private UUID dccId;
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class GroupParamsDTO {
|
||||
|
||||
private String specificationJson;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
private List<String> vidList;
|
||||
|
||||
private List<String> vinList;
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private List<UUID> idList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class GroupReturnDTO {
|
||||
|
||||
protected UUID id;
|
||||
private String groupName;
|
||||
private ItemStatus status;
|
||||
private String statusDes;
|
||||
private Integer mold;
|
||||
private Integer total;
|
||||
|
||||
protected String createBy;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
protected Date creationDate;
|
||||
protected String lastModifiedBy;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
protected Date lastModifiedDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class GroupVehicleDTO {
|
||||
|
||||
@NotBlank(message = "车辆分组ID不能为空")
|
||||
private UUID id;
|
||||
|
||||
@NotEmpty(message = "车辆字段查询条件不能为空,并且是Json字符串({\"and\":[{\"color\":\"blue\"},{\"brand_name\":\"Audi\"}]})")
|
||||
private String specificationJson;
|
||||
|
||||
@Min(value = 1, message = "页码必须大于1")
|
||||
private int pageNo;
|
||||
|
||||
@Min(value = 5, message = "每页最少显示5条数据")
|
||||
private int pageSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GroupVehicleResultDTO {
|
||||
|
||||
private String vid;
|
||||
|
||||
private String infos;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MappingAllFieldDTO
|
||||
*
|
||||
* @author Chen Li
|
||||
* @since 4/11/2025
|
||||
*/
|
||||
@Data
|
||||
public class MappingAllFieldDTO {
|
||||
|
||||
private MappingFieldDTO data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* MappingFieldDTO
|
||||
*
|
||||
* @author Chen Li
|
||||
* @since 4/11/2025
|
||||
*/
|
||||
@Data
|
||||
public class MappingFieldDTO {
|
||||
|
||||
private String ADSVersion;
|
||||
|
||||
private String MDCVersion;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.volkswagen.mdmds.model.param.PolicyCreateParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PolicyBaseDTO {
|
||||
|
||||
private String adsVersion;
|
||||
private List<PolicyCreateParam.EventParam> events;
|
||||
|
||||
private String sha256;
|
||||
private String configuration;
|
||||
|
||||
private String taskId;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/3/2
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PolicyBriefInfoDTO {
|
||||
|
||||
private UUID id;
|
||||
private String adsVersion;
|
||||
private String eventList;
|
||||
private String dccDetail;
|
||||
|
||||
private String description;
|
||||
private String subscription;
|
||||
|
||||
protected String createBy;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
protected Date creationDate;
|
||||
protected String lastModifiedBy;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
protected Date lastModifiedDate;
|
||||
|
||||
private String groupName;
|
||||
|
||||
private String apiForm;
|
||||
private String taskId;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PolicyParamsDTO {
|
||||
|
||||
private String adsVersion;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class ResourceInfoDTO {
|
||||
|
||||
private String resName;
|
||||
private String resUrl;
|
||||
|
||||
private UUID roleId;
|
||||
private UUID resId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ResponseDTO {
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd hh:mm:ss")
|
||||
private Date timestamp;
|
||||
private int code;
|
||||
private String status;
|
||||
private String message;
|
||||
private String stackTrace;
|
||||
private Object data;
|
||||
|
||||
public ResponseDTO() {
|
||||
this.timestamp=new Date();
|
||||
}
|
||||
|
||||
public ResponseDTO(HttpStatus httpStatus, String message) {
|
||||
this();
|
||||
this.code=httpStatus.value();
|
||||
this.status=httpStatus.name();
|
||||
this.message=message;
|
||||
}
|
||||
|
||||
public ResponseDTO(HttpStatus httpStatus, String message, String stackTrace) {
|
||||
this(httpStatus,message);
|
||||
this.stackTrace=stackTrace;
|
||||
}
|
||||
|
||||
public ResponseDTO(HttpStatus httpStatus, String message, String stackTrace, Object data) {
|
||||
this(httpStatus, message, stackTrace);
|
||||
this.data=data;
|
||||
}
|
||||
|
||||
public ResponseDTO(HttpStatus httpStatus,Object data) {
|
||||
this(httpStatus, "");
|
||||
this.data=data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class RoleInfoDTO {
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String resName;
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String createBy;
|
||||
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date creationDate;
|
||||
|
||||
private String lastModifiedBy;
|
||||
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class RoleResourceDetailDTO {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private Set<DicResourceDTO> resource;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/21
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class TicketBriefInfoDTO {
|
||||
|
||||
protected UUID id;
|
||||
|
||||
@NotEmpty(message = "Ticket Name is required")
|
||||
@Length(max = 20, message = "Character length cannot exceed 20")
|
||||
private String ticketName;
|
||||
|
||||
private String ticketDetail;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastModifiedDate;
|
||||
private ItemStatus status;
|
||||
private String statusDes;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import com.volkswagen.mdmds.model.entity.VehicleInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class TicketDetailDTO {
|
||||
|
||||
protected UUID id;
|
||||
private String ticketName;
|
||||
private String ticketDetail;
|
||||
private ItemStatus status;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date creationDate;
|
||||
private String lastModifiedBy;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
private Set<VehicleInfo> vehicleInfoes = new LinkedHashSet<>();
|
||||
|
||||
private List<VehicleInfoDTO> vehicles;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class TicketParamsDTO {
|
||||
|
||||
private String ticketName;
|
||||
|
||||
private List<VehicleInfoDTO> vehicles;
|
||||
|
||||
private List<UUID> idList;
|
||||
|
||||
private List<String> vidList;
|
||||
|
||||
private List<String> vinList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class TicketVehicleDTO {
|
||||
|
||||
@NotBlank(message = "工单ID不能为空")
|
||||
private UUID id;
|
||||
|
||||
@Min(value = 1, message = "页码必须大于1")
|
||||
private int pageNo;
|
||||
|
||||
@Min(value = 5, message = "每页最少显示5条数据")
|
||||
private int pageSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TicketVehicleResultDTO {
|
||||
|
||||
private String vid;
|
||||
|
||||
private String infos;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.volkswagen.mdmds.model.param.DataSourceAdapterParam;
|
||||
import com.volkswagen.mdmds.model.param.DataSourceParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 上传参数
|
||||
*
|
||||
* @author Chen Li
|
||||
* @since 4/23/2025
|
||||
*/
|
||||
@Data
|
||||
public class UploadDataDTO {
|
||||
|
||||
private List<DataSourceParam> list;
|
||||
|
||||
private List<DataSourceAdapterParam> adapterlist;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.volkswagen.mdmds.model.entity.ItemStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class UserInfoDTO {
|
||||
|
||||
private String userName;
|
||||
|
||||
private String email;
|
||||
|
||||
private List<RoleInfoDTO> roleList;
|
||||
|
||||
private String roles;
|
||||
|
||||
private List<String> realRoles;
|
||||
|
||||
private List<Map<String, Object>> resources;
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern="MM/dd/yyyy HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
private ItemStatus status;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserSessionDTO {
|
||||
|
||||
private String username;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private Instant exp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VehicleInfoDTO {
|
||||
|
||||
private String vin;
|
||||
|
||||
private String vid;
|
||||
|
||||
private String infos;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
public class VehicleParamsDTO {
|
||||
|
||||
private List<String> vinList;
|
||||
|
||||
private List<String> vidList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volkswagen.mdmds.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VehicleReturnDTO {
|
||||
|
||||
private String vin;
|
||||
|
||||
private String vid;
|
||||
|
||||
private String infos;
|
||||
private String result;
|
||||
|
||||
private String statusCode;
|
||||
private String message;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "audit_log")
|
||||
public class AuditLog extends BaseEntity<String> {
|
||||
|
||||
@Column(name = "log", columnDefinition = "text")
|
||||
private String log;
|
||||
|
||||
@Column(name = "req_ip", columnDefinition = "Varchar(50)")
|
||||
private String reqIP;
|
||||
|
||||
@Column(name = "req_uri", columnDefinition = "Varchar(100)")
|
||||
private String reqURI;
|
||||
|
||||
@Column(name = "req_method", columnDefinition = "Varchar(50)")
|
||||
private String reqMethod;
|
||||
|
||||
@Column(name = "req_method_name", columnDefinition = "Varchar(50)")
|
||||
private String reqMethodName;
|
||||
|
||||
@Column(name = "req_params", columnDefinition = "text")
|
||||
private String reqParams;
|
||||
|
||||
@Column(name = "start_time", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date startTime;
|
||||
|
||||
@Column(name = "end_time", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date endTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public abstract class BaseEntity<U> {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
protected UUID id;
|
||||
|
||||
@CreatedBy
|
||||
protected U createBy;
|
||||
|
||||
//带时区的时间戳
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@CreatedDate
|
||||
@Column(columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
protected Date creationDate;
|
||||
|
||||
@LastModifiedBy
|
||||
protected U lastModifiedBy;
|
||||
|
||||
@LastModifiedDate
|
||||
@Column(columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
protected Date lastModifiedDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "data_collection_config")
|
||||
public class DataCollectionConfig extends BaseEntity<String> {
|
||||
|
||||
private String adsVersion;
|
||||
private String eventList;
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String dccDetail;
|
||||
private String uniqueMd5;
|
||||
private String contentMd5;
|
||||
private String description;
|
||||
private String subscription;
|
||||
|
||||
/**
|
||||
* 删除状态:0-正常 1-删除
|
||||
*/
|
||||
@Column(name = "is_deleted", columnDefinition = "int not null default 0")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 接口类型:HW-API1,HW-API2
|
||||
*/
|
||||
@Column(name = "api_form", columnDefinition = "Varchar(50)")
|
||||
private String apiForm;
|
||||
|
||||
@Column(name = "task_id", columnDefinition = "Varchar(50)")
|
||||
private String taskId;
|
||||
|
||||
@Column(name = "start_time", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date startTime;
|
||||
|
||||
@Column(name = "end_time", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date endTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "dic_attr_value_eumn")
|
||||
public class DicAttrValueEnum {
|
||||
@Id
|
||||
private String attrName;
|
||||
|
||||
@Column(name = "attr_val", columnDefinition = "text")
|
||||
private String attrVal;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "dic_resource")
|
||||
public class DicResource {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
protected UUID id;
|
||||
private String resName;
|
||||
private String resUrl;
|
||||
@CreatedBy
|
||||
private String createBy;
|
||||
|
||||
@Column(name = "creation_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date creationDate;
|
||||
|
||||
private String lastModifiedBy;
|
||||
|
||||
@Column(name = "last_modified_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "dic_vehicle_attr")
|
||||
public class DicVehicleAttr extends BaseEntity<String> {
|
||||
private String attrName;
|
||||
private String mappingName;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(length=16)
|
||||
private ItemStatus status;
|
||||
|
||||
@Column(name = "remark", columnDefinition = "text")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "dic_vehicle_attr_adapter")
|
||||
public class DicVehicleAttrAdapter extends BaseEntity<String> {
|
||||
|
||||
private String attrName;
|
||||
|
||||
@Column(unique = true)
|
||||
private String adapterMapping;
|
||||
|
||||
private String adapterKey;
|
||||
|
||||
private String adapterValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "group_configuration")
|
||||
public class GroupConfiguration extends BaseEntity<String> {
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "group_id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID groupId;
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "dcc_id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID dccId;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.groupId == null) {
|
||||
this.groupId = UUID.randomUUID();
|
||||
}
|
||||
if (this.dccId == null) {
|
||||
this.dccId = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "group_dcc_record")
|
||||
public class GroupDccRecord extends BaseEntity<String> {
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "group_id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID groupId;
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "dcc_id")
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID dccId;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.groupId == null) {
|
||||
this.groupId = UUID.randomUUID();
|
||||
}
|
||||
if (this.dccId == null) {
|
||||
this.dccId = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "group_specification")
|
||||
public class GroupSpecification extends BaseEntity<String> {
|
||||
|
||||
@Column(columnDefinition = "text")
|
||||
private String specificationJson;
|
||||
|
||||
//标签,使用';'分割
|
||||
@Column(columnDefinition = "text")
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
* 判断是否已经设置过分组条件或者是标签
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Boolean isContainSpec() {
|
||||
return !(StringUtils.isEmpty(this.specificationJson) && StringUtils.isEmpty(this.tags));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "group_vehicle")
|
||||
public class GroupVehicle extends BaseEntity<String> {
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "group_id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID groupId;
|
||||
|
||||
@Column(name = "vid")
|
||||
private String vid;
|
||||
|
||||
@Column(name = "vin")
|
||||
private String vin;
|
||||
|
||||
@Column(name = "infos", columnDefinition = "json")
|
||||
private String infos;
|
||||
|
||||
@Column(name = "result", columnDefinition = "json")
|
||||
private String result;
|
||||
|
||||
@Column(name = "status_code")
|
||||
private String statusCode;
|
||||
@Column(name = "message", columnDefinition="text")
|
||||
private String message;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.groupId == null) {
|
||||
this.groupId = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
/**
|
||||
* 数据条目的状态
|
||||
*
|
||||
* @author Shuo Ding
|
||||
* @since 2023/2/20
|
||||
*/
|
||||
public enum ItemStatus {
|
||||
ENABLE,DISABLE,NONE,RUN,HOLD,DONE,ALL
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "role_info")
|
||||
public class RoleInfo extends BaseEntity<String> {
|
||||
private String roleName;
|
||||
|
||||
private String innerRole;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "role_info_dic_resources",
|
||||
joinColumns = @JoinColumn(name = "role_info_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "dic_resources_id"))
|
||||
private Set<DicResource> dicResources = new LinkedHashSet<>();
|
||||
}
|
||||
35
src/main/java/com/volkswagen/mdmds/model/entity/Ticket.java
Normal file
35
src/main/java/com/volkswagen/mdmds/model/entity/Ticket.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "ticket")
|
||||
public class Ticket extends BaseEntity<String> {
|
||||
|
||||
private String ticketName;
|
||||
private String ticketDetail;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(length = 16)
|
||||
private ItemStatus status;
|
||||
|
||||
/**
|
||||
* 删除状态:0-正常 1-删除
|
||||
*/
|
||||
@Column(name = "is_deleted", columnDefinition = "int not null default 0")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* Ticket关联的车数量
|
||||
*/
|
||||
@Column(name = "total", columnDefinition = "int NOT NULL DEFAULT 0 ")
|
||||
private Integer total;
|
||||
|
||||
@Column(name = "vines", columnDefinition = "TEXT")
|
||||
private String vines;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "ticket_vehicle")
|
||||
public class TicketVehicle extends BaseEntity<String> {
|
||||
|
||||
// @GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "ticket_id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
private UUID ticketId;
|
||||
|
||||
@Column(name = "vid")
|
||||
private String vid;
|
||||
|
||||
@Column(name = "vin")
|
||||
private String vin;
|
||||
|
||||
@Column(name = "infos", columnDefinition = "json")
|
||||
private String infos;
|
||||
|
||||
@Column(name = "result", columnDefinition = "json")
|
||||
private String result;
|
||||
|
||||
@Column(name = "status_code")
|
||||
private String statusCode;
|
||||
@Column(name = "message", columnDefinition="text")
|
||||
private String message;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.ticketId == null) {
|
||||
this.ticketId = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "user_info")
|
||||
public class UserInfo {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
@Column(name = "id", nullable = false)
|
||||
@JdbcTypeCode(value = SqlTypes.CHAR)
|
||||
protected UUID id;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "user_info_role_infoes",
|
||||
joinColumns = @JoinColumn(name = "user_info_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "role_infoes_id"))
|
||||
private Set<RoleInfo> roleInfoes = new LinkedHashSet<>();
|
||||
|
||||
@Column(name = "user_name", columnDefinition = "Varchar(50)")
|
||||
private String userName;
|
||||
|
||||
@Column(name = "email", columnDefinition = "Varchar(50)")
|
||||
private String email;
|
||||
|
||||
@Column(name = "roles", columnDefinition = "text")
|
||||
private String roles;
|
||||
|
||||
@CreatedBy
|
||||
private String createBy;
|
||||
|
||||
@Column(name = "creation_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date creationDate;
|
||||
|
||||
private String lastModifiedBy;
|
||||
|
||||
@Column(name = "last_modified_date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
|
||||
private Date lastModifiedDate;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", columnDefinition = "varchar(16) NOT NULL DEFAULT 'ENABLE'")
|
||||
private ItemStatus status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "vehicle_group")
|
||||
@Data
|
||||
public class VehicleGroup extends BaseEntity<String> {
|
||||
|
||||
private String groupName;
|
||||
private ItemStatus status;
|
||||
|
||||
@OneToOne(orphanRemoval = true)
|
||||
@JoinColumn(name = "group_specification_id")
|
||||
private GroupSpecification groupSpecification;
|
||||
|
||||
/**
|
||||
* '删除状态:0-正常 1-删除'
|
||||
*/
|
||||
@Column(name = "is_deleted", columnDefinition = "int NOT NULL DEFAULT 0 ")
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* '删除状态:0-分组无条件 1-字段查询条件 2-VIN查询条件'
|
||||
*/
|
||||
@Column(name = "mold", columnDefinition = "int NOT NULL DEFAULT 0 ")
|
||||
private Integer mold;
|
||||
|
||||
/**
|
||||
* Group关联的车数量
|
||||
*/
|
||||
@Column(name = "total", columnDefinition = "int NOT NULL DEFAULT 0 ")
|
||||
private Integer total;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volkswagen.mdmds.model.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "vehicle_info")
|
||||
public class VehicleInfo extends BaseEntity<String> {
|
||||
|
||||
@Column(unique = true)
|
||||
private String vid;
|
||||
|
||||
@Column(name = "vin")
|
||||
private String vin;
|
||||
|
||||
@Column(columnDefinition = "json")
|
||||
private String infos;
|
||||
|
||||
@Column(columnDefinition = "json")
|
||||
private String result;
|
||||
|
||||
@Column(name = "status_code")
|
||||
private String statusCode;
|
||||
@Column(columnDefinition = "json")
|
||||
private String message;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
VehicleInfo that = (VehicleInfo) o;
|
||||
return vin != null && Objects.equals(vin, that.vin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volkswagen.mdmds.model.excel;
|
||||
|
||||
import com.volkswagen.mdmds.utils.annotation.ExcelField;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VehicleAttributeAdapterField {
|
||||
|
||||
@ExcelField(name = "Attribute Name", order = 1)
|
||||
private String attrName;
|
||||
|
||||
@ExcelField(name = "Key", order = 2)
|
||||
private String adapterKey;
|
||||
|
||||
@ExcelField(name = "Value", order = 3)
|
||||
private String adapterValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.volkswagen.mdmds.model.excel;
|
||||
|
||||
import com.volkswagen.mdmds.utils.annotation.ExcelField;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class VehicleAttributeField {
|
||||
|
||||
@ExcelField(name = "Attribute Name", order = 1)
|
||||
private String attrName;
|
||||
|
||||
@ExcelField(name = "Mapping Name", order = 2)
|
||||
private String mappingName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DataSourceAdapterParam {
|
||||
|
||||
private String attrName;
|
||||
private String adapterKey;
|
||||
private String adapterValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DataSourceParam {
|
||||
|
||||
private String attrName;
|
||||
private String mappingName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class GroupCreateParam {
|
||||
|
||||
@NotEmpty(message = "Group Name is required")
|
||||
@Length(max = 20, message = "Group Name length cannot exceed 20")
|
||||
private String groupName;
|
||||
|
||||
public GroupCreateParam(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PolicyCreateParam {
|
||||
|
||||
@Length(max = 200, message = "Comments length cannot exceed 200")
|
||||
private String comments;
|
||||
|
||||
@NotEmpty(message = "Subscription is required")
|
||||
@Length(max = 200, message = "Comments length cannot exceed 200")
|
||||
private String subscription;
|
||||
|
||||
@NotEmpty(message = "adsVersion is required")
|
||||
private String adsVersion;
|
||||
|
||||
private List<EventParam> events;
|
||||
|
||||
@NotEmpty(message = "apiForm is required")
|
||||
private String apiForm;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
||||
private List<Long> timeSlot;
|
||||
|
||||
@Data
|
||||
public static class EventParam {
|
||||
private String eventId;
|
||||
private String eventName;
|
||||
private String eventDesc;
|
||||
private String eventType;
|
||||
private List<List<Integer>> eventScope;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
public class PolicyDeleteParam {
|
||||
|
||||
private List<UUID> idList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PolicyParam {
|
||||
|
||||
private String adsVersion;
|
||||
|
||||
private List<String> events;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PolicyReqParam {
|
||||
|
||||
private String adsVersion;
|
||||
|
||||
private List<String> events;
|
||||
|
||||
private String taskId;
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.volkswagen.mdmds.model.param;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PolicySaveParam {
|
||||
|
||||
private String comments;
|
||||
|
||||
@NotEmpty(message = "subscription是必填项")
|
||||
private String subscription;
|
||||
|
||||
@NotEmpty(message = "adsVersion是必填项")
|
||||
private String adsVersion;
|
||||
|
||||
private String configuration;
|
||||
|
||||
private String sha256;
|
||||
private List<EventParam> events;
|
||||
|
||||
@Data
|
||||
public static class EventParam {
|
||||
private String eventId;
|
||||
private String eventName;
|
||||
private String eventDesc;
|
||||
private String eventType;
|
||||
private List<List<Integer>> eventScope;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user