aaa
This commit is contained in:
2
server/.gitattributes
vendored
Normal file
2
server/.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/mvnw text eol=lf
|
||||
*.cmd text eol=crlf
|
||||
33
server/.gitignore
vendored
Normal file
33
server/.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/
|
||||
3
server/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
3
server/.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
|
||||
BIN
server/data/app.db
Normal file
BIN
server/data/app.db
Normal file
Binary file not shown.
295
server/mvnw
vendored
Normal file
295
server/mvnw
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -euf
|
||||
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||
|
||||
# OS specific support.
|
||||
native_path() { printf %s\\n "$1"; }
|
||||
case "$(uname)" in
|
||||
CYGWIN* | MINGW*)
|
||||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||
native_path() { cygpath --path --windows "$1"; }
|
||||
;;
|
||||
esac
|
||||
|
||||
# set JAVACMD and JAVACCMD
|
||||
set_java_home() {
|
||||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||
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"
|
||||
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||
|
||||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v java
|
||||
)" || :
|
||||
JAVACCMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v javac
|
||||
)" || :
|
||||
|
||||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# hash string like Java String::hashCode
|
||||
hash_string() {
|
||||
str="${1:-}" h=0
|
||||
while [ -n "$str" ]; do
|
||||
char="${str%"${str#?}"}"
|
||||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||
str="${str#?}"
|
||||
done
|
||||
printf %x\\n $h
|
||||
}
|
||||
|
||||
verbose() { :; }
|
||||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||
|
||||
die() {
|
||||
printf %s\\n "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
# MWRAPPER-139:
|
||||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||
# Needed for removing poorly interpreted newline sequences when running in more
|
||||
# exotic environments such as mingw bash on Windows.
|
||||
printf "%s" "${1}" | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
scriptDir="$(dirname "$0")"
|
||||
scriptName="$(basename "$0")"
|
||||
|
||||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||
while IFS="=" read -r key value; do
|
||||
case "${key-}" in
|
||||
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||
esac
|
||||
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
|
||||
case "${distributionUrl##*/}" in
|
||||
maven-mvnd-*bin.*)
|
||||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||
*)
|
||||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||
distributionPlatform=linux-amd64
|
||||
;;
|
||||
esac
|
||||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||
;;
|
||||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||
|
||||
exec_maven() {
|
||||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||
}
|
||||
|
||||
if [ -d "$MAVEN_HOME" ]; then
|
||||
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
exec_maven "$@"
|
||||
fi
|
||||
|
||||
case "${distributionUrl-}" in
|
||||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||
esac
|
||||
|
||||
# prepare tmp dir
|
||||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||
trap clean HUP INT TERM EXIT
|
||||
else
|
||||
die "cannot create temp dir"
|
||||
fi
|
||||
|
||||
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||
|
||||
# Download and Install Apache Maven
|
||||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
verbose "Downloading from: $distributionUrl"
|
||||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
# verbose opt
|
||||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||
|
||||
# normalize http auth
|
||||
case "${MVNW_PASSWORD:+has-password}" in
|
||||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
esac
|
||||
|
||||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||
verbose "Found wget ... using wget"
|
||||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||
verbose "Found curl ... using curl"
|
||||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||
elif set_java_home; then
|
||||
verbose "Falling back to use Java to download"
|
||||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
cat >"$javaSource" <<-END
|
||||
public class Downloader extends java.net.Authenticator
|
||||
{
|
||||
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||
}
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
setDefault( new Downloader() );
|
||||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||
}
|
||||
}
|
||||
END
|
||||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||
verbose " - Compiling Downloader.java ..."
|
||||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||
verbose " - Running Downloader.java ..."
|
||||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||
fi
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
if [ -n "${distributionSha256Sum-}" ]; then
|
||||
distributionSha256Result=false
|
||||
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
elif command -v sha256sum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
elif command -v shasum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $distributionSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip and move
|
||||
if command -v unzip >/dev/null; then
|
||||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||
else
|
||||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||
fi
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
actualDistributionDir=""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$distributionUrlNameMain"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
# enable globbing to iterate over items
|
||||
set +f
|
||||
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$(basename "$dir")"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
set -f
|
||||
fi
|
||||
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||
die "Could not find Maven distribution directory in extracted archive"
|
||||
fi
|
||||
|
||||
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
189
server/mvnw.cmd
vendored
Normal file
189
server/mvnw.cmd
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
<# : batch portion
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||
@SET __MVNW_CMD__=
|
||||
@SET __MVNW_ERROR__=
|
||||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||
@SET PSModulePath=
|
||||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||
)
|
||||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||
@SET __MVNW_PSMODULEP_SAVE=
|
||||
@SET __MVNW_ARG0_NAME__=
|
||||
@SET MVNW_USERNAME=
|
||||
@SET MVNW_PASSWORD=
|
||||
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||
@GOTO :EOF
|
||||
: end batch / begin powershell #>
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($env:MVNW_VERBOSE -eq "true") {
|
||||
$VerbosePreference = "Continue"
|
||||
}
|
||||
|
||||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||
if (!$distributionUrl) {
|
||||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
}
|
||||
|
||||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||
"maven-mvnd-*" {
|
||||
$USE_MVND = $true
|
||||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||
$MVN_CMD = "mvnd.cmd"
|
||||
break
|
||||
}
|
||||
default {
|
||||
$USE_MVND = $false
|
||||
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||
}
|
||||
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||
|
||||
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$MAVEN_WRAPPER_DISTS = $null
|
||||
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||
} else {
|
||||
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||
}
|
||||
|
||||
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||
|
||||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
exit $?
|
||||
}
|
||||
|
||||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||
}
|
||||
|
||||
# prepare tmp dir
|
||||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||
trap {
|
||||
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||
|
||||
# Download and Install Apache Maven
|
||||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
Write-Verbose "Downloading from: $distributionUrl"
|
||||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||
if ($distributionSha256Sum) {
|
||||
if ($USE_MVND) {
|
||||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||
}
|
||||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||
}
|
||||
}
|
||||
|
||||
# unzip and move
|
||||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
$actualDistributionDir = ""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||
$actualDistributionDir = $distributionUrlNameMain
|
||||
}
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if (!$actualDistributionDir) {
|
||||
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||
$actualDistributionDir = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$actualDistributionDir) {
|
||||
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||
}
|
||||
|
||||
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||
try {
|
||||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||
} catch {
|
||||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||
Write-Error "fail to move MAVEN_HOME"
|
||||
}
|
||||
} finally {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
86
server/pom.xml
Normal file
86
server/pom.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.18</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.reg</groupId>
|
||||
<artifactId>server</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>server</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.46.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.42</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter-test</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
16
server/src/main/java/com/reg/server/ServerApplication.java
Normal file
16
server/src/main/java/com/reg/server/ServerApplication.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.reg.server;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.reg.server.registration")
|
||||
public class ServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServerApplication.class, args);
|
||||
System.out.println("启动成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.reg.server.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.sqlite.SQLiteDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Configuration
|
||||
public class DatabaseConfig {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
Path baseDir = resolveBaseDir();
|
||||
Path dataDir = baseDir.resolve("data");
|
||||
Path dbFile = dataDir.resolve("app.db");
|
||||
try {
|
||||
Files.createDirectories(dataDir);
|
||||
} catch (Exception ignored) {
|
||||
// rely on SQLite to fail loudly if directory is not writable
|
||||
}
|
||||
|
||||
SQLiteDataSource ds = new SQLiteDataSource();
|
||||
ds.setUrl("jdbc:sqlite:" + dbFile.toString());
|
||||
return ds;
|
||||
}
|
||||
|
||||
private Path resolveBaseDir() {
|
||||
try {
|
||||
// When running from JAR, location points to the JAR file; from IDE, to classes directory.
|
||||
java.net.URL location = DatabaseConfig.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation();
|
||||
String path = location.getPath();
|
||||
// Handle JAR path: jar:file:/path/to/app.jar!/BOOT-INF/classes!/
|
||||
if (path.contains(".jar")) {
|
||||
// Extract the JAR file path
|
||||
int jarIndex = path.indexOf(".jar");
|
||||
path = path.substring(0, jarIndex + 4);
|
||||
// Remove "file:" prefix if present
|
||||
if (path.startsWith("file:")) {
|
||||
path = path.substring(5);
|
||||
}
|
||||
// On Windows, remove leading slash before drive letter (e.g., /D:/...)
|
||||
if (path.length() > 2 && path.charAt(0) == '/' && path.charAt(2) == ':') {
|
||||
path = path.substring(1);
|
||||
}
|
||||
// Decode URL encoding
|
||||
path = java.net.URLDecoder.decode(path, "UTF-8");
|
||||
Path jarPath = Paths.get(path);
|
||||
Path parent = jarPath.getParent();
|
||||
if (parent != null) {
|
||||
return parent;
|
||||
}
|
||||
} else {
|
||||
// Running from IDE/classes directory
|
||||
Path classesPath = Paths.get(location.toURI());
|
||||
Path parent = classesPath.getParent();
|
||||
if (parent != null) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// fall back
|
||||
}
|
||||
return Paths.get(System.getProperty("user.dir", "."));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.reg.server.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.resource.PathResourceResolver;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Configuration
|
||||
public class PdfResourceConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value("${app.pdf.external-dir:}")
|
||||
private String externalDir;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String[] locations = resolveLocations();
|
||||
registry.addResourceHandler("/pdf/**")
|
||||
.addResourceLocations(locations)
|
||||
.resourceChain(true)
|
||||
.addResolver(new PathResourceResolver());
|
||||
}
|
||||
|
||||
private String[] resolveLocations() {
|
||||
if (!StringUtils.hasText(externalDir)) {
|
||||
return new String[]{"classpath:/pdf/"};
|
||||
}
|
||||
|
||||
String externalLocation = toExternalLocation(externalDir);
|
||||
return new String[]{externalLocation, "classpath:/pdf/"};
|
||||
}
|
||||
|
||||
private static String toExternalLocation(String directory) {
|
||||
Path path = Paths.get(directory).toAbsolutePath().normalize();
|
||||
String uri = path.toUri().toString();
|
||||
return uri.endsWith("/") ? uri : (uri + "/");
|
||||
}
|
||||
}
|
||||
120
server/src/main/java/com/reg/server/pdf/PdfController.java
Normal file
120
server/src/main/java/com/reg/server/pdf/PdfController.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.reg.server.pdf;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class PdfController {
|
||||
private final ResourcePatternResolver resolver;
|
||||
|
||||
@Value("${app.pdf.external-dir:}")
|
||||
private String externalDir;
|
||||
|
||||
public PdfController(ResourcePatternResolver resolver) {
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
||||
@GetMapping("/api/pdfs")
|
||||
public List<PdfFile> listPdfs() throws IOException {
|
||||
Map<String, PdfFile> filesByName = new LinkedHashMap<>();
|
||||
|
||||
for (String name : listClasspathPdfs()) {
|
||||
filesByName.putIfAbsent(name, toPdfFile(name));
|
||||
}
|
||||
for (String name : listExternalPdfs()) {
|
||||
filesByName.putIfAbsent(name, toPdfFile(name));
|
||||
}
|
||||
|
||||
return filesByName.values().stream()
|
||||
.sorted(Comparator.comparing(PdfFile::getName, String.CASE_INSENSITIVE_ORDER))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<String> listClasspathPdfs() throws IOException {
|
||||
Resource[] resources = resolver.getResources("classpath*:/pdf/*.pdf");
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Resource resource : resources) {
|
||||
String filename = resource.getFilename();
|
||||
if (filename != null && filename.toLowerCase().endsWith(".pdf")) {
|
||||
names.add(filename);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private List<String> listExternalPdfs() {
|
||||
if (!StringUtils.hasText(externalDir)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Path dir = Paths.get(externalDir).toAbsolutePath().normalize();
|
||||
if (!Files.isDirectory(dir)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try (Stream<Path> stream = Files.list(dir)) {
|
||||
return stream
|
||||
.filter(Files::isRegularFile)
|
||||
.map(path -> path.getFileName().toString())
|
||||
.filter(name -> name.toLowerCase().endsWith(".pdf"))
|
||||
.sorted(String.CASE_INSENSITIVE_ORDER)
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception ignored) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private static PdfFile toPdfFile(String name) {
|
||||
String encoded = UriUtils.encodePathSegment(name, StandardCharsets.UTF_8);
|
||||
return new PdfFile(name, "/pdf/" + encoded);
|
||||
}
|
||||
|
||||
public static class PdfFile {
|
||||
private String name;
|
||||
private String url;
|
||||
|
||||
public PdfFile() {
|
||||
}
|
||||
|
||||
public PdfFile(String name, String url) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.reg.server.registration;
|
||||
|
||||
public class Registration {
|
||||
private Long id;
|
||||
private String registerTime;
|
||||
private String customerName;
|
||||
private String contact;
|
||||
private String serviceType;
|
||||
private String powerType;
|
||||
private String note;
|
||||
private String status;
|
||||
/**
|
||||
* 文件访问链接
|
||||
*/
|
||||
private String urlPath;
|
||||
|
||||
public String getUrlPath() {
|
||||
return urlPath;
|
||||
}
|
||||
|
||||
public void setUrlPath(String urlPath) {
|
||||
this.urlPath = urlPath;
|
||||
}
|
||||
|
||||
private String fileName;
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRegisterTime() {
|
||||
return registerTime;
|
||||
}
|
||||
|
||||
public void setRegisterTime(String registerTime) {
|
||||
this.registerTime = registerTime;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(String contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public String getServiceType() {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
public void setServiceType(String serviceType) {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public String getPowerType() {
|
||||
return powerType;
|
||||
}
|
||||
|
||||
public void setPowerType(String powerType) {
|
||||
this.powerType = powerType;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.reg.server.registration;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/registrations")
|
||||
@CrossOrigin
|
||||
public class RegistrationController {
|
||||
private final RegistrationService service;
|
||||
|
||||
/**
|
||||
* <b>description</b> :
|
||||
* <p>使用凭据初始化账号Client</p>
|
||||
*
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
public static com.aliyun.dysmsapi20170525.Client createClient() throws Exception {
|
||||
// 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||
com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
.setCredential(credential);
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
|
||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
||||
config.setAccessKeyId("LTAI5tSqZrdsoC54tgWTrdYB");
|
||||
config.setAccessKeySecret("I1nu7T6DJuvhribphaWh53RRw8TdC7");
|
||||
return new com.aliyun.dysmsapi20170525.Client(config);
|
||||
}
|
||||
|
||||
public RegistrationController(RegistrationService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<Registration> list() {
|
||||
return service.list();
|
||||
}
|
||||
|
||||
@GetMapping("/search")
|
||||
public List<Registration> search(
|
||||
@RequestParam(required = false) String customerName,
|
||||
@RequestParam(required = false) String contact,
|
||||
@RequestParam(required = false) String serviceType,
|
||||
@RequestParam(required = false) String powerType,
|
||||
@RequestParam(required = false) String status) {
|
||||
Registration condition = new Registration();
|
||||
condition.setCustomerName(customerName);
|
||||
condition.setContact(contact);
|
||||
condition.setServiceType(serviceType);
|
||||
condition.setPowerType(powerType);
|
||||
condition.setStatus(status);
|
||||
RandomUtil.randomString(8);
|
||||
return service.search(condition);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Registration> get(@PathVariable Long id) {
|
||||
return service.get(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Registration> create(@RequestBody Registration registration) {
|
||||
Registration saved = service.create(registration);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(saved);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Void> update(@PathVariable Long id, @RequestBody Registration registration) {
|
||||
String urlPath = null;
|
||||
if ("已登记".equals(registration.getStatus().trim()) && registration.getFileName() != null) {
|
||||
urlPath = RandomUtil.randomString(5);
|
||||
registration.setUrlPath(urlPath);
|
||||
}
|
||||
boolean updated = service.update(id, registration);
|
||||
return updated ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
boolean deleted = service.delete(id);
|
||||
return deleted ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getPdfPath/{urlPath}")
|
||||
public ResponseEntity<String> getPdfPath(@PathVariable String urlPath) {
|
||||
List<Registration> search = service.search(new Registration() {{
|
||||
setUrlPath(urlPath);
|
||||
}});
|
||||
if (search == null || search.isEmpty()) {
|
||||
return ResponseEntity.ok("");
|
||||
}
|
||||
return ResponseEntity.ok(search.get(0).getFileName());
|
||||
}
|
||||
|
||||
|
||||
// @GetMapping("sendSms/{id}")
|
||||
// public ResponseEntity sendSms (@PathVariable Long id) throws Exception {
|
||||
// com.aliyun.dysmsapi20170525.Client client = this.createClient();
|
||||
// com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
||||
// Registration registration = service.get(id)
|
||||
// .orElseThrow(() -> new IllegalStateException("数据不可能为空,id=" + id));
|
||||
// sendSmsRequest.setPhoneNumbers(registration.getContact());
|
||||
// sendSmsRequest.setSignName("顷琦");
|
||||
// sendSmsRequest.setTemplateCode("SMS_499300449");
|
||||
// com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
// try {
|
||||
// com.aliyun.dysmsapi20170525.models.SendSmsResponse resp = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
// System.out.println(new com.google.gson.Gson().toJson(resp));
|
||||
// } catch (TeaException error) {
|
||||
// System.out.println(error.getMessage());
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// } catch (Exception _error) {
|
||||
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// System.out.println(error.getMessage());
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
//
|
||||
// }
|
||||
// return ResponseEntity.status(HttpStatus.OK).body("发送短信成功");
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.reg.server.registration;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapper
|
||||
public interface RegistrationMapper {
|
||||
|
||||
int insert(Registration registration);
|
||||
|
||||
Optional<Registration> findById(Long id);
|
||||
|
||||
List<Registration> findAll();
|
||||
|
||||
int update(Registration registration);
|
||||
|
||||
int delete(Long id);
|
||||
|
||||
List<Registration> findByCondition(Registration condition);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.reg.server.registration;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class RegistrationService {
|
||||
private final RegistrationMapper mapper;
|
||||
|
||||
public RegistrationService(RegistrationMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public List<Registration> list() {
|
||||
return mapper.findAll();
|
||||
}
|
||||
|
||||
public Optional<Registration> get(Long id) {
|
||||
return mapper.findById(id);
|
||||
}
|
||||
|
||||
public Registration create(Registration registration) {
|
||||
registration.setRegisterTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
defaultStatus(registration);
|
||||
mapper.insert(registration);
|
||||
return registration;
|
||||
}
|
||||
|
||||
public boolean update(Long id, Registration registration) {
|
||||
registration.setId(id);
|
||||
defaultStatus(registration);
|
||||
return mapper.update(registration) > 0;
|
||||
}
|
||||
|
||||
public boolean delete(Long id) {
|
||||
return mapper.delete(id) > 0;
|
||||
}
|
||||
|
||||
public List<Registration> search(Registration condition) {
|
||||
return mapper.findByCondition(condition);
|
||||
}
|
||||
|
||||
private void defaultStatus(Registration registration) {
|
||||
if (!StringUtils.hasText(registration.getStatus())) {
|
||||
registration.setStatus("待登记");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
server/src/main/resources/application.yaml
Normal file
19
server/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
spring:
|
||||
application:
|
||||
name: server
|
||||
sql:
|
||||
init:
|
||||
platform: sqlite
|
||||
mode: never
|
||||
mybatis:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
server:
|
||||
port: 7946
|
||||
|
||||
app:
|
||||
pdf:
|
||||
# Optional: serve PDFs from a local folder (preferred first), e.g. ./resources/pdf
|
||||
external-dir: ""
|
||||
11
server/src/main/resources/data-sqlite.sql
Normal file
11
server/src/main/resources/data-sqlite.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DELETE FROM registrations;
|
||||
|
||||
INSERT INTO registrations (register_time, customer_name, contact, service_type, power_type, note, status) VALUES
|
||||
('2025-12-16 09:30:00', '张三', '13800138001', '新装', '单相', '住宅用电申请', '已完成'),
|
||||
('2025-12-16 10:15:00', '李四', '13900139002', '增容', '三相', '工厂扩产需增加容量', '处理中'),
|
||||
('2025-12-15 14:20:00', '王五', '13700137003', '过户', '单相', '', '已完成'),
|
||||
('2025-12-15 16:45:00', '赵六', '13600136004', '新装', '三相', '商铺开业用电', '待处理'),
|
||||
('2025-12-14 11:00:00', '钱七', '13500135005', '改类', '单相', '居民改为商业用电', '处理中'),
|
||||
('2025-12-14 08:30:00', '孙八', '13400134006', '新装', '单相', '', '已完成'),
|
||||
('2025-12-13 15:10:00', '周九', '13300133007', '增容', '三相', '设备升级需要更大功率', '待处理'),
|
||||
('2025-12-13 09:00:00', '吴十', '13200132008', '过户', '单相', '房屋买卖过户', '已取消');
|
||||
78
server/src/main/resources/mapper/RegistrationMapper.xml
Normal file
78
server/src/main/resources/mapper/RegistrationMapper.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.reg.server.registration.RegistrationMapper">
|
||||
|
||||
<resultMap id="registrationResultMap" type="com.reg.server.registration.Registration">
|
||||
<id property="id" column="id"/>
|
||||
<result property="registerTime" column="register_time"/>
|
||||
<result property="customerName" column="customer_name"/>
|
||||
<result property="contact" column="contact"/>
|
||||
<result property="serviceType" column="service_type"/>
|
||||
<result property="powerType" column="power_type"/>
|
||||
<result property="note" column="note"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="fileName" column="file_name"/>
|
||||
<result property="urlPath" column="url_path" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO registrations (register_time, customer_name, contact, service_type, power_type, note, status)
|
||||
VALUES (#{registerTime}, #{customerName}, #{contact}, #{serviceType}, #{powerType}, #{note}, #{status})
|
||||
</insert>
|
||||
|
||||
<select id="findById" resultMap="registrationResultMap">
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
|
||||
FROM registrations WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="registrationResultMap">
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
|
||||
FROM registrations ORDER BY register_time DESC
|
||||
</select>
|
||||
|
||||
<update id="update">
|
||||
UPDATE registrations
|
||||
SET register_time = #{registerTime},
|
||||
customer_name = #{customerName},
|
||||
contact = #{contact},
|
||||
service_type = #{serviceType},
|
||||
power_type = #{powerType},
|
||||
note = #{note},
|
||||
status = #{status},
|
||||
file_name = #{fileName},
|
||||
url_path = #{urlPath}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
DELETE FROM registrations WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="findByCondition" resultMap="registrationResultMap">
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name
|
||||
FROM registrations
|
||||
<where>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
AND customer_name LIKE CONCAT('%', #{customerName}, '%')
|
||||
</if>
|
||||
<if test="contact != null and contact != ''">
|
||||
AND contact LIKE CONCAT('%', #{contact}, '%')
|
||||
</if>
|
||||
<if test="serviceType != null and serviceType != ''">
|
||||
AND service_type = #{serviceType}
|
||||
</if>
|
||||
<if test="powerType != null and powerType != ''">
|
||||
AND power_type = #{powerType}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="urlPath != null and urlPath != ''">
|
||||
AND url_path = #{urlPath}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY register_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Binary file not shown.
Binary file not shown.
25158
server/src/main/resources/pdf/(2025年7月1日起实施)用电业务办理告知书(低压居民新装、增容).pdf
Normal file
25158
server/src/main/resources/pdf/(2025年7月1日起实施)用电业务办理告知书(低压居民新装、增容).pdf
Normal file
File diff suppressed because one or more lines are too long
BIN
server/src/main/resources/pdf/用电业务办理告知书 (增值税变更 ).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书 (增值税变更 ).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书 (容量-需量变更).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书 (容量-需量变更).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书 (电能表校验).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书 (电能表校验).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(个人电动汽车充电桩).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(个人电动汽车充电桩).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(低压公共电动汽车充电桩业务).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(低压公共电动汽车充电桩业务).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(其他变更).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(其他变更).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(减容恢复).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(减容恢复).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(减容).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(减容).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(分布式电源并网).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(分布式电源并网).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(复装、暂拆).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(复装、暂拆).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(小区配套新装).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(小区配套新装).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(批量新装).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(批量新装).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(改压).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(改压).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(改类-居民峰谷变更).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(改类-居民峰谷变更).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(改类-调需量值).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(改类-调需量值).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(新户通电).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(新户通电).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(暂换).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(暂换).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(更名).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(更名).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(电动自行车集中充电设施).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(电动自行车集中充电设施).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(移表).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(移表).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(过户).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(过户).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(销户).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(销户).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(高压用电业务办理办理告知书).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(高压用电业务办理办理告知书).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理告知书(高压电动汽车充电桩业务办理告知书).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理告知书(高压电动汽车充电桩业务办理告知书).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理指南(临时用电延期).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理指南(临时用电延期).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理指南(分户).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理指南(分户).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理指南(并户).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理指南(并户).pdf
Normal file
Binary file not shown.
BIN
server/src/main/resources/pdf/用电业务办理指南(迁址).pdf
Normal file
BIN
server/src/main/resources/pdf/用电业务办理指南(迁址).pdf
Normal file
Binary file not shown.
10
server/src/main/resources/schema-sqlite.sql
Normal file
10
server/src/main/resources/schema-sqlite.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS registrations (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
register_time TEXT NOT NULL,
|
||||
customer_name TEXT NOT NULL,
|
||||
contact TEXT,
|
||||
service_type TEXT,
|
||||
power_type TEXT,
|
||||
note TEXT,
|
||||
status TEXT DEFAULT 'NEW'
|
||||
);
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.reg.server;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class ServerApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void servesPdfFromClasspath() throws Exception {
|
||||
mockMvc.perform(get("/pdf/test.pdf"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_PDF));
|
||||
}
|
||||
}
|
||||
29
server/src/test/resources/pdf/test.pdf
Normal file
29
server/src/test/resources/pdf/test.pdf
Normal file
@@ -0,0 +1,29 @@
|
||||
%PDF-1.4
|
||||
1 0 obj
|
||||
<< /Type /Catalog /Pages 2 0 R >>
|
||||
endobj
|
||||
2 0 obj
|
||||
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
|
||||
endobj
|
||||
3 0 obj
|
||||
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 200] /Contents 4 0 R >>
|
||||
endobj
|
||||
4 0 obj
|
||||
<< /Length 44 >>
|
||||
stream
|
||||
BT /F1 12 Tf 72 120 Td (test) Tj ET
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 5
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000000060 00000 n
|
||||
0000000117 00000 n
|
||||
0000000204 00000 n
|
||||
trailer
|
||||
<< /Size 5 /Root 1 0 R >>
|
||||
startxref
|
||||
298
|
||||
%%EOF
|
||||
|
||||
Reference in New Issue
Block a user