项目初始化 添加缓存和权限配置
This commit is contained in:
commit
f1c3d209f7
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/mvnw text eol=lf
|
||||
*.cmd text eol=crlf
|
||||
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/
|
||||
19
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
19
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# 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.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
||||
259
mvnw
vendored
Normal file
259
mvnw
vendored
Normal file
@ -0,0 +1,259 @@
|
||||
#!/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.2
|
||||
#
|
||||
# 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:]'
|
||||
}
|
||||
|
||||
# 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 <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.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${0##*/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
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
149
mvnw.cmd
vendored
Normal file
149
mvnw.cmd
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
<# : 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.2
|
||||
@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) { "/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_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
|
||||
}
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::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
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -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"
|
||||
179
pom.xml
Normal file
179
pom.xml
Normal file
@ -0,0 +1,179 @@
|
||||
<?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>3.3.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>cn.aqroid</groupId>
|
||||
<artifactId>gang_qiang_data_process</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<name>gang_qiang_data_process</name>
|
||||
<description>gang_qiang_data_process</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv -->
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv</artifactId>
|
||||
<version>1.5.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.bytedeco/ffmpeg-platform -->
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>ffmpeg-platform</artifactId>
|
||||
<version>7.1-1.5.11</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.41</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
<version>1.2.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.penggle</groupId>
|
||||
<artifactId>kaptcha</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.3.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons IO (用于文件操作) -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DataProcessApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataProcessApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.aqroid.dataprocess.auth.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 标记 CustomUserDetails 对应dto的userName
|
||||
* @author wangke
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Username {
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.aqroid.dataprocess.auth.controller;
|
||||
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
/**
|
||||
* 将用户注入到 req Model 里面方便在controller里面直接注入
|
||||
* @author dost
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class AuthenticationAdvice {
|
||||
|
||||
@ModelAttribute
|
||||
public KmSystemStaffDto staff() {
|
||||
return handleStaff();
|
||||
}
|
||||
|
||||
public static KmSystemStaffDto handleStaff() {
|
||||
return (KmSystemStaffDto) (SecurityContextHolder.getContext().getAuthentication() == null
|
||||
|| SecurityContextHolder.getContext().getAuthentication().getPrincipal() == null
|
||||
|| (SecurityContextHolder.getContext().getAuthentication().getPrincipal() instanceof String)
|
||||
? null : SecurityContextHolder.getContext().getAuthentication().getPrincipal());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.aqroid.dataprocess.auth.controller;
|
||||
|
||||
import com.aqroid.dataprocess.auth.controller.req.KmSystemStaffReq;
|
||||
import com.aqroid.dataprocess.auth.service.impl.LoginService;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.aqroid.dataprocess.utils.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by 31092$ on 2024/8/3
|
||||
*/
|
||||
@RestController
|
||||
public class PasswordLoginController {
|
||||
@Autowired
|
||||
private LoginService loginService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public CommonResult<String> loginByPassword(@RequestBody KmSystemStaffReq req){
|
||||
Assert.notNull(req.getUserName(),"用户不能为空");
|
||||
Assert.notNull(req.getPassword(),"密码不能为空");
|
||||
Assert.notNull(req.getDcode(),"验证码不能为空");
|
||||
|
||||
return CommonResult.successResult(loginService.loginByPassword(req));
|
||||
}
|
||||
@GetMapping("/getInfo")
|
||||
public CommonResult<KmSystemStaffDto> getUserinfo(@ModelAttribute KmSystemStaffDto handleStaff){
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
return CommonResult.successResult((KmSystemStaffDto) authentication.getPrincipal());
|
||||
}
|
||||
|
||||
@GetMapping("/login/getDcode")
|
||||
public CommonResult<Map> getDcode(@ModelAttribute KmSystemStaffDto handleStaff){
|
||||
return CommonResult.successResult(loginService.generateDcode());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.aqroid.dataprocess.auth.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmSystemStaffReq {
|
||||
private String userName;
|
||||
private String password;
|
||||
private String dcodeId;
|
||||
private String dcode;
|
||||
}
|
||||
62
src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java
Normal file
62
src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.aqroid.dataprocess.auth.dto;
|
||||
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by 31092$ on 2024/8/3
|
||||
*/
|
||||
@Data
|
||||
public class LoginUser implements UserDetails {
|
||||
|
||||
private KmSystemStaffDto user;
|
||||
|
||||
public LoginUser(KmSystemStaffDto userinfo){
|
||||
this.user = userinfo;
|
||||
}
|
||||
|
||||
@Setter
|
||||
private List<SimpleGrantedAuthority> authority;
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return authority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.getUserName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.aqroid.dataprocess.auth.filter;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 无凭证进入
|
||||
* @author wangke
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
|
||||
log.error("JwtAuthenticationEntryPoint:", authException);
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "没有凭证");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.aqroid.dataprocess.auth.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aqroid.dataprocess.exception.BusinessException;
|
||||
import com.aqroid.dataprocess.exception.ExceptionEnum;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmSystemStaffRoleMapper;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.aqroid.dataprocess.utils.JwtTokenUtils;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Component
|
||||
public class TokenFilter extends OncePerRequestFilter {
|
||||
|
||||
@Autowired
|
||||
private LoadingCache caffeineCache;
|
||||
|
||||
@Autowired
|
||||
private KmSystemStaffRoleMapper roleMapper;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
String token = request.getHeader("x-user-token");
|
||||
String requestURI = request.getRequestURI();
|
||||
if (Strings.isNotEmpty(token) && !requestURI.equals("/login") && !requestURI.equals("/login/getDcode")) {
|
||||
String trueToken = (String) caffeineCache.get(token);
|
||||
Assert.hasText(trueToken, "登陆失效,请重新登陆");
|
||||
Claims claims = null;
|
||||
try {
|
||||
claims = JwtTokenUtils.getAllClaimsFromToken(trueToken);
|
||||
}catch (ExpiredJwtException e){
|
||||
throw new BusinessException(ExceptionEnum.TokenExpired);
|
||||
}
|
||||
|
||||
Date expirationDate = claims.get(Claims.EXPIRATION, Date.class);
|
||||
if (!expirationDate.after(new Date())) {
|
||||
throw new BusinessException(ExceptionEnum.TokenExpired);
|
||||
}
|
||||
Class<?> dtoClass = null;
|
||||
try {
|
||||
dtoClass = Class.forName(claims.get(JwtTokenUtils.KEY_DTO_CLASS, String.class));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
KmSystemStaffDto userDto = (KmSystemStaffDto) JSONObject.parseObject(claims.get(JwtTokenUtils.KEY_DTO, String.class), dtoClass);
|
||||
List<SimpleGrantedAuthority> authorities = JSONObject.parseArray(claims.get(JwtTokenUtils.KEY_AUTHORITIES, String.class), SimpleGrantedAuthority.class);
|
||||
|
||||
|
||||
//将校验信息放到上下文中
|
||||
SecurityContextHolder.getContext().setAuthentication(
|
||||
new UsernamePasswordAuthenticationToken(
|
||||
userDto,
|
||||
null,
|
||||
authorities
|
||||
));
|
||||
}
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package com.aqroid.dataprocess.auth.service.impl;
|
||||
|
||||
import com.aqroid.dataprocess.auth.controller.req.KmSystemStaffReq;
|
||||
import com.aqroid.dataprocess.auth.dto.LoginUser;
|
||||
import com.aqroid.dataprocess.cache.RedisCacheOperator;
|
||||
import com.aqroid.dataprocess.utils.DcodeUtils;
|
||||
import com.aqroid.dataprocess.utils.IDUtils;
|
||||
import com.aqroid.dataprocess.utils.JwtTokenUtils;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import org.apache.tomcat.util.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class LoginService {
|
||||
|
||||
@Autowired
|
||||
AuthenticationManager authenticationManager;
|
||||
@Autowired
|
||||
private LoadingCache caffeineCache;
|
||||
@Autowired
|
||||
private RedisCacheOperator redisCacheOperator;
|
||||
@Autowired
|
||||
private DefaultKaptcha kaptcha;
|
||||
|
||||
|
||||
|
||||
public String loginByPassword(KmSystemStaffReq userinfo) {
|
||||
//校验dcode
|
||||
String dcode = (String) redisCacheOperator.get(userinfo.getDcodeId());
|
||||
Assert.hasText(dcode,"验证码已过期,请刷新页面重试。");
|
||||
Assert.isTrue(DcodeUtils.validateCaptcha(userinfo.getDcode(),dcode),"验证码错误,请重新输入");
|
||||
|
||||
//2 封装authentication对象
|
||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userinfo.getUserName(),userinfo.getPassword());
|
||||
|
||||
//3 校验
|
||||
Authentication authenticate = authenticationManager.authenticate(token);
|
||||
Assert.notNull(authenticate,"账号密码校验失败!");
|
||||
LoginUser info = (LoginUser) authenticate.getPrincipal();
|
||||
String jwtToken = JwtTokenUtils.generateToken(info);
|
||||
String md5Token = DigestUtils.md5DigestAsHex(jwtToken.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
caffeineCache.put(md5Token,jwtToken);
|
||||
return md5Token;
|
||||
}
|
||||
|
||||
public Map<String,String> generateDcode() {
|
||||
String uuid = IDUtils.createUUID();
|
||||
String value = DcodeUtils.generateAlphanumericCaptcha(4);
|
||||
redisCacheOperator.set(uuid,value,5 * 60);
|
||||
BufferedImage image = kaptcha.createImage(value);
|
||||
|
||||
String base64Code = "";
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "jpg", outputStream);
|
||||
base64Code = Base64.encodeBase64String(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
System.out.println("verificationCode exception: "+e);
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("verificationCode outputStream close exception: "+e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> kaptchaVoMap = new HashMap<>();
|
||||
kaptchaVoMap.put("uuid", uuid);
|
||||
kaptchaVoMap.put("code", "data:image/png;base64," + base64Code);
|
||||
return kaptchaVoMap;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.aqroid.dataprocess.auth.service.impl;
|
||||
|
||||
import com.aqroid.dataprocess.auth.dto.LoginUser;
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaff;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmSystemStaffMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmSystemStaffService;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.converter.KmSystemStaffConverter;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by 31092$ on 2024/8/3
|
||||
*/
|
||||
@Service
|
||||
public class UserDetailServiceImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private KmSystemStaffMapper mapper;
|
||||
@Autowired
|
||||
private KmSystemStaffConverter systemStaffConverter;
|
||||
@Autowired
|
||||
private KmSystemStaffService staffService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
LambdaQueryWrapper<KmSystemStaff> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(KmSystemStaff::getUserName,username);
|
||||
KmSystemStaff kmSystemStaff = mapper.selectOne(wrapper);
|
||||
Assert.notNull(kmSystemStaff,"用户不存在");
|
||||
KmSystemStaffDto dto = systemStaffConverter.getDTO(kmSystemStaff);
|
||||
|
||||
//添加权限信息
|
||||
LoginUser loginUser = new LoginUser(dto);
|
||||
List<SimpleGrantedAuthority> authorities = staffService.getAuthorities(dto);
|
||||
loginUser.setAuthority(authorities);
|
||||
return loginUser;
|
||||
}
|
||||
}
|
||||
118
src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java
vendored
Normal file
118
src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
package com.aqroid.dataprocess.cache;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Component
|
||||
public class RedisCacheOperator {
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/** 默认过期时长为24小时,单位:秒 */
|
||||
public final static long DEFAULT_EXPIRE = 60 * 60 * 24L;
|
||||
/** 过期时长为1小时,单位:秒 */
|
||||
public final static long HOUR_ONE_EXPIRE = 60 * 60 * 1L;
|
||||
|
||||
public final static long FIVE_MINUTES_EXPIRE = 60 * 5L;
|
||||
/** 过期时长为6小时,单位:秒 */
|
||||
public final static long HOUR_SIX_EXPIRE = 60 * 60 * 6L;
|
||||
/** 不设置过期时长 */
|
||||
public final static long NOT_EXPIRE = -1L;
|
||||
|
||||
public void set(String key, Object value, long expire) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(String key, Object value) {
|
||||
set(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public Object get(String key, long expire) {
|
||||
Object value = redisTemplate.opsForValue().get(key);
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object get(String key) {
|
||||
return get(key, NOT_EXPIRE);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
public void delete(Collection<String> keys) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
|
||||
public Object hGet(String key, String field) {
|
||||
return redisTemplate.opsForHash().get(key, field);
|
||||
}
|
||||
|
||||
public Map<String, Object> hGetAll(String key) {
|
||||
HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash();
|
||||
return hashOperations.entries(key);
|
||||
}
|
||||
|
||||
public void hMSet(String key, Map<String, Object> map) {
|
||||
hMSet(key, map, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public void hMSet(String key, Map<String, Object> map, long expire) {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
}
|
||||
|
||||
public void hSet(String key, String field, Object value) {
|
||||
hSet(key, field, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public void hSet(String key, String field, Object value, long expire) {
|
||||
redisTemplate.opsForHash().put(key, field, value);
|
||||
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
}
|
||||
|
||||
public void expire(String key, long expire) {
|
||||
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void hDel(String key, Object... fields) {
|
||||
redisTemplate.opsForHash().delete(key, fields);
|
||||
}
|
||||
|
||||
public void leftPush(String key, Object value) {
|
||||
leftPush(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public void leftPush(String key, Object value, long expire) {
|
||||
redisTemplate.opsForList().leftPush(key, value);
|
||||
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
}
|
||||
|
||||
public Object rightPop(String key) {
|
||||
return redisTemplate.opsForList().rightPop(key);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
import com.aqroid.dataprocess.auth.filter.JwtAuthenticationEntryPoint;
|
||||
import com.aqroid.dataprocess.auth.filter.TokenFilter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
||||
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
/**
|
||||
* Created by 31092$ on 2024/8/1
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class AppSecurityConfig implements WebSecurityConfigurer<WebSecurity> {
|
||||
|
||||
@Autowired
|
||||
TokenFilter tokenFilter;
|
||||
|
||||
@Autowired
|
||||
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
|
||||
|
||||
@Override
|
||||
public void init(WebSecurity builder) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity builder) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
|
||||
httpSecurity.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint);
|
||||
httpSecurity.
|
||||
authorizeHttpRequests(manage ->{
|
||||
manage.requestMatchers("/login/**","/*/login","/message/insert","/druid/**").permitAll().
|
||||
anyRequest().authenticated();
|
||||
});
|
||||
httpSecurity.csrf(AbstractHttpConfigurer::disable);
|
||||
|
||||
httpSecurity.addFilterBefore(tokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
return httpSecurity.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManage(AuthenticationConfiguration config) throws Exception{
|
||||
return config.getAuthenticationManager();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.CacheWriter;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.RemovalCause;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 缓存配置类
|
||||
*
|
||||
* @author wangke
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "cache", name = "caffeine", havingValue = "enabled", matchIfMissing = true)
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class CacheConfiguration {
|
||||
|
||||
@Bean("caffeineCache")
|
||||
public LoadingCache caffeineCache() {
|
||||
LoadingCache<String, Object> loadingCache = Caffeine.newBuilder()
|
||||
//初始大小
|
||||
.initialCapacity(100)
|
||||
//最大容量
|
||||
.maximumSize(1000)
|
||||
//缓存写入/删除监控
|
||||
.writer(new CacheWriter<Object, Object>() {
|
||||
@Override
|
||||
public void write(Object key, Object value) { //此方法是同步阻塞的
|
||||
log.info("caffeine写入:key={},value={}", key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object key, Object value, RemovalCause cause) {
|
||||
log.info("caffeine删除「{}」:key={}", cause.name(), key);
|
||||
}
|
||||
})
|
||||
//过期时间
|
||||
.expireAfterWrite(1, TimeUnit.HOURS)
|
||||
.build((String key) -> "");
|
||||
return loadingCache;
|
||||
}
|
||||
|
||||
@Bean("smsCodeCache")
|
||||
public LoadingCache smsCodeCache() {
|
||||
LoadingCache<String, Object> loadingCache = Caffeine.newBuilder()
|
||||
//初始大小
|
||||
.initialCapacity(100)
|
||||
//最大容量
|
||||
.maximumSize(1000)
|
||||
//缓存写入/删除监控
|
||||
.writer(new CacheWriter<Object, Object>() {
|
||||
@Override
|
||||
public void write(Object key, Object value) { //此方法是同步阻塞的
|
||||
log.info("caffeine写入:key={},value={}", key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object key, Object value, RemovalCause cause) {
|
||||
log.info("caffeine删除「{}」:key={}", cause.name(), key);
|
||||
}
|
||||
})
|
||||
//过期时间
|
||||
.expireAfterWrite(3, TimeUnit.MINUTES)
|
||||
.build((String key) -> "");
|
||||
return loadingCache;
|
||||
}
|
||||
|
||||
@Bean("dynamicCodeCache")
|
||||
public LoadingCache dynamicCodeCache() {
|
||||
LoadingCache<String, ?> loadingCache = Caffeine.newBuilder()
|
||||
//初始大小
|
||||
.initialCapacity(100)
|
||||
//最大容量
|
||||
.maximumSize(1000)
|
||||
//缓存写入/删除监控
|
||||
.writer(new CacheWriter<Object, Object>() {
|
||||
@Override
|
||||
public void write(Object key, Object value) { //此方法是同步阻塞的
|
||||
log.info("caffeine写入:key={},value={}", key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object key, Object value, RemovalCause cause) {
|
||||
log.info("caffeine删除「{}」:key={}", cause.name(), key);
|
||||
}
|
||||
})
|
||||
//过期时间
|
||||
.expireAfterWrite(3, TimeUnit.MINUTES)
|
||||
.build((String key) -> "");
|
||||
return loadingCache;
|
||||
}
|
||||
@Bean("dingTokenCache")
|
||||
public LoadingCache dingTokenCache() {
|
||||
LoadingCache<String, ?> loadingCache = Caffeine.newBuilder()
|
||||
//初始大小
|
||||
.initialCapacity(100)
|
||||
//最大容量
|
||||
.maximumSize(1000)
|
||||
//缓存写入/删除监控
|
||||
.writer(new CacheWriter<Object, Object>() {
|
||||
@Override
|
||||
public void write(Object key, Object value) { //此方法是同步阻塞的
|
||||
log.info("caffeine写入:key={},value={}", key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object key, Object value, RemovalCause cause) {
|
||||
log.info("caffeine删除「{}」:key={}", cause.name(), key);
|
||||
}
|
||||
})
|
||||
//过期时间
|
||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
||||
.build((String key) -> "");
|
||||
return loadingCache;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 验证码配置
|
||||
*/
|
||||
@Configuration
|
||||
public class KaptchaConfig {
|
||||
|
||||
@Bean
|
||||
public DefaultKaptcha getDefaultKaptcha(){
|
||||
DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
|
||||
Properties properties=new Properties();
|
||||
properties.setProperty("kaptcha.border", "no");
|
||||
properties.setProperty("kaptcha.border.color", "34,114,200");
|
||||
properties.setProperty("kaptcha.image.width", "190");
|
||||
properties.setProperty("kaptcha.image.height", "40");
|
||||
//properties.setProperty("kaptcha.textproducer.char.string", "0123456789");
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
||||
properties.setProperty("kaptcha.textproducer.char.space", "3");
|
||||
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
|
||||
properties.setProperty("kaptcha.textproducer.font.size", "38");
|
||||
|
||||
properties.setProperty("kaptcha.background.clear.from", "white");
|
||||
properties.setProperty("kaptcha.background.clear.to", "white");
|
||||
|
||||
Config config=new Config(properties);
|
||||
defaultKaptcha.setConfig(config);
|
||||
return defaultKaptcha;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Configuration
|
||||
//@MapperScan("com.aq.xy_translate.dto.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
||||
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
47
src/main/java/com/aqroid/dataprocess/config/RedisConfig.java
Normal file
47
src/main/java/com/aqroid/dataprocess/config/RedisConfig.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Resource
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer(){
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// 创建 Jackson2JsonRedisSerializer 对象,并设置 ObjectMapper
|
||||
return new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
// 设置序列化器
|
||||
redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer());
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer());
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer());
|
||||
// 设置连接工厂
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
20
src/main/java/com/aqroid/dataprocess/config/WebConfig.java
Normal file
20
src/main/java/com/aqroid/dataprocess/config/WebConfig.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.aqroid.dataprocess.config;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE","OPTIONS")
|
||||
.allowedHeaders("*");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.aqroid.dataprocess.constants;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.aqroid.dataprocess.constants.Module.*;
|
||||
import static com.aqroid.dataprocess.constants.ModuleAction.*;
|
||||
|
||||
|
||||
/**
|
||||
* 内置权限组
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum BuildInRoleGroup {
|
||||
superManager("超级管理员", Maps.immutableEnumMap(new HashMap() {{
|
||||
put(STAFF, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(ROLE, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(ARTICLE, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(COMMENTS, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
}})),
|
||||
|
||||
manage("管理员", Maps.immutableEnumMap(new HashMap() {{
|
||||
put(STAFF, Arrays.asList(QUERY));
|
||||
put(ROLE, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(ARTICLE, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(COMMENTS, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
}})),
|
||||
|
||||
user("用户", Maps.immutableEnumMap(new HashMap() {{
|
||||
put(ARTICLE, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
put(COMMENTS, Arrays.asList(ADD,UPDATE,QUERY,DELETE));
|
||||
}})),
|
||||
|
||||
;
|
||||
|
||||
public String desc;
|
||||
public String name;
|
||||
public Map<Module, List<ModuleAction>> roleMap;
|
||||
|
||||
BuildInRoleGroup(String desc, Map<Module, List<ModuleAction>> roleMap) {
|
||||
this.desc = desc;
|
||||
this.name = name();
|
||||
this.roleMap = roleMap;
|
||||
}
|
||||
|
||||
public static BuildInRoleGroup getByName(String name) {
|
||||
for (BuildInRoleGroup value : values()) {
|
||||
if (StringUtils.equals(name, value.name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/com/aqroid/dataprocess/constants/Module.java
Normal file
41
src/main/java/com/aqroid/dataprocess/constants/Module.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.aqroid.dataprocess.constants;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import static com.aqroid.dataprocess.constants.ModuleAction.*;
|
||||
|
||||
|
||||
/**
|
||||
* 系统内置模块
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum Module {
|
||||
STAFF("100", "人员", ADD, UPDATE, QUERY,DELETE),
|
||||
ROLE("200", "角色", ADD, UPDATE, QUERY, DELETE),
|
||||
ARTICLE("300","文章",ADD,UPDATE,QUERY,DELETE),
|
||||
COMMENTS("400","评论",ADD,UPDATE,QUERY,DELETE),
|
||||
;
|
||||
|
||||
|
||||
public String code;
|
||||
public String desc;
|
||||
public String name;
|
||||
public ModuleAction[] actions;
|
||||
|
||||
Module(String code, String desc, ModuleAction... actions) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
this.actions = actions;
|
||||
this.name = name();
|
||||
}
|
||||
|
||||
public static Module getByCode(String code) {
|
||||
for (Module module : Module.values()) {
|
||||
if (StringUtils.equals(code, module.code)) {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.aqroid.dataprocess.constants;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 模块动作
|
||||
* 新增「add」修改「update」删除「delete」查询「query」
|
||||
*/
|
||||
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
||||
public enum ModuleAction {
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
ADD("1000", "新增"),
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
DELETE("3000", "删除"),
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
QUERY("4000", "查询"),
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
UPDATE("2000", "修改");
|
||||
public String code;
|
||||
public String desc;
|
||||
public String name;
|
||||
|
||||
ModuleAction(String code, String desc) {
|
||||
this.desc = desc;
|
||||
this.code = code;
|
||||
this.name=name();
|
||||
}
|
||||
|
||||
public static ModuleAction getByCode(String code) {
|
||||
for (ModuleAction action : ModuleAction.values()) {
|
||||
if (StringUtils.equals(action.code, code)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package com.aqroid.dataprocess.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@RestController
|
||||
public class ArticleCommentController {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.aqroid.dataprocess.controller;
|
||||
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmArticleDto;
|
||||
import com.aqroid.dataprocess.utils.CommonResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/article")
|
||||
public class ArticleController {
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@PreAuthorize("hasAuthority('ARTICLE|ADD')")
|
||||
@PostMapping("add")
|
||||
public CommonResult articleAdd(@RequestBody KmArticleDto kmArticleDto){
|
||||
System.out.println(kmArticleDto);
|
||||
return CommonResult.successResult("123");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.aqroid.dataprocess.controller;
|
||||
|
||||
import com.aqroid.dataprocess.utils.IDUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
|
||||
@RestController
|
||||
public class FileUploadController {
|
||||
|
||||
// 定义文件存储的基础路径,这里假设存储在项目根目录下的uploads文件夹,实际可根据需求调整
|
||||
private static final String UPLOAD_DIR = System.getProperty("user.dir") + "/uploads";
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ResponseEntity<?> uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
if (file.isEmpty()) {
|
||||
return new ResponseEntity<>("请选择要上传的文件", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取原始文件名
|
||||
String originalFileName = file.getOriginalFilename();
|
||||
// 生成一个唯一的文件名,避免重名问题,这里简单使用UUID来生成
|
||||
String uniqueFileName = IDUtils.createUUID() + "_" + originalFileName;
|
||||
// 构建文件存储的完整路径
|
||||
Path uploadPath = Paths.get(UPLOAD_DIR, uniqueFileName);
|
||||
// 创建文件所在的目录(如果不存在)
|
||||
Files.createDirectories(uploadPath.getParent());
|
||||
// 将上传的文件保存到指定路径
|
||||
file.transferTo(new File(uploadPath.toString()));
|
||||
|
||||
// 返回文件的访问路径等相关信息给前端,这里简单返回文件名,实际可能需要更完整的URL等
|
||||
return new ResponseEntity<>(uniqueFileName, HttpStatus.OK);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>("文件上传失败", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.aqroid.dataprocess.controller;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
public class SystemStaffController {
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.aqroid.dataprocess.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@RestController
|
||||
public class TestController {
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.aqroid.dataprocess.exception;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* <p>业务异常</p>
|
||||
* <p>业务处理时,出现异常,可以抛出该异常</p>
|
||||
*/
|
||||
@Getter
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
private final ExceptionEnum exceptionEnum;
|
||||
|
||||
public BusinessException(ExceptionEnum exceptionEnum) {
|
||||
super(exceptionEnum.getMessage());
|
||||
this.exceptionEnum = exceptionEnum;
|
||||
}
|
||||
|
||||
public BusinessException(ExceptionEnum exceptionEnum, Throwable throwable) {
|
||||
super(exceptionEnum.getMessage(), throwable);
|
||||
this.exceptionEnum = exceptionEnum;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
package com.aqroid.dataprocess.exception;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 异常结果枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ExceptionEnum {
|
||||
|
||||
/**
|
||||
* 用户未找到
|
||||
*/
|
||||
UserNotFound("4010001", "用户未找到"),
|
||||
|
||||
/**
|
||||
* 密码错误
|
||||
*/
|
||||
PasswordWrong("4010002", "密码错误"),
|
||||
|
||||
/**
|
||||
* 短信验证码错误
|
||||
*/
|
||||
SmsCodeWrong("4010003", "短信验证码错误"),
|
||||
|
||||
/**
|
||||
* 没有对应url访问权限
|
||||
*/
|
||||
URLUnauthorized("4010004", "没有对应url访问权限"),
|
||||
/**
|
||||
* token已过期
|
||||
*/
|
||||
TokenExpired("4010005", "token已过期"),
|
||||
|
||||
/**
|
||||
* 用户类型不支持
|
||||
*/
|
||||
ErrorUserType("4010006", "用户类型不支持"),
|
||||
|
||||
/**
|
||||
* 参数错误
|
||||
*/
|
||||
ErrorParams("4010007", "参数错误"),
|
||||
|
||||
|
||||
/**
|
||||
* file upload
|
||||
* code prefix 4011
|
||||
*/
|
||||
FileTypeNotSupported("4011001", "文件类型不支持"),
|
||||
FileTypeValidationFail("4011002", "文件类型校验失败"),
|
||||
ImageReWriteFail("4011003", "图片重写失败,请上传真实的图片信息"),
|
||||
FileReadFail("4011004", "文件读取失败"),
|
||||
/**
|
||||
* file read fail
|
||||
* code prefix 4011
|
||||
*/
|
||||
FileAnalysisProcessorNotFind("4011005", "文件处理器找不到"),
|
||||
/**
|
||||
* file upload null
|
||||
* code prefix 4011
|
||||
*/
|
||||
FileIsNull("4011006", "没有上传文件"),
|
||||
FileNoExist("4011007", "等待下载的文件不存在"),
|
||||
|
||||
/**
|
||||
* code prefix 4012
|
||||
*/
|
||||
SMSSendFail("4012001","发送失败,请重试!"),
|
||||
|
||||
|
||||
SMSCodeEffective("4012002","刚才的验证码依然有效,请使用刚才收到的验证码登录"),
|
||||
GENERATE_DYNAMIC_CODE_FAIL("4013001","动态验证码生成失败,请重试。"),
|
||||
DYNAMIC_CODE_ERROR("4013002","动态验证码错误或已过期,请重试。"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
final String errorCode;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
final String message;
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package com.aqroid.dataprocess.exception;
|
||||
|
||||
import com.aqroid.dataprocess.utils.CommonResult;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
|
||||
/**
|
||||
* @author ytqzd
|
||||
* @date 2023/12/7 11:24
|
||||
*
|
||||
* 全局异常处理类
|
||||
*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private void setExceptionResponseHeader(HttpServletResponse response, String msg){
|
||||
response.setHeader("content-exception", URLEncoder.encode(msg, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public CommonResult handlerIllegalArgument(IllegalArgumentException ex, HttpServletResponse response) {
|
||||
CommonResult commonResult = CommonResult.failResult(500, "500", ex.getMessage());
|
||||
// commonResult.setData(ex.getStackTrace());
|
||||
setExceptionResponseHeader(response,ex.getMessage());
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public CommonResult handlerHttpMessageNotReadableException(HttpMessageNotReadableException ex, HttpServletResponse response) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
CommonResult commonResult = CommonResult.failResult(500, "500", ex.getMessage());
|
||||
// commonResult.setData(ex.getStackTrace());
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
setExceptionResponseHeader(response,ex.getMessage());
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public CommonResult handleException(BusinessException ex, HttpServletRequest request, HttpServletResponse response) {
|
||||
CommonResult commonResult = CommonResult.failResult(ex);
|
||||
//ex.printStackTrace();
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
setExceptionResponseHeader(response,ex.getExceptionEnum().getMessage());
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
public CommonResult handlerAccessDeniedException(HttpServletRequest request, HttpServletResponse response) {
|
||||
CommonResult commonResult = CommonResult.failResult(
|
||||
new BusinessException(ExceptionEnum.URLUnauthorized)
|
||||
);
|
||||
commonResult.setData(request.getRequestURI());
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
setExceptionResponseHeader(response,commonResult.getMessage());
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public CommonResult handlerRuntimeException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
|
||||
CommonResult commonResult = CommonResult.failResult(500, "500",
|
||||
"处理失败,请联系管理员:" +
|
||||
(ex.getMessage().length() > 30 ? ex.getMessage().substring(0, 30) : ex.getMessage()) + "...");
|
||||
// commonResult.setData(ex.getStackTrace());
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
log.error("服务内部错误", ex);
|
||||
setExceptionResponseHeader(response,ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
public CommonResult handlerDuplicateKeyException(DuplicateKeyException ex, HttpServletRequest request, HttpServletResponse response) {
|
||||
// Duplicate entry '' for key 'user.UNI_PHONE'
|
||||
String msg = ex.getCause().getMessage();
|
||||
String[] strings = msg.split("'");
|
||||
msg = strings.length >= 3 ? strings[1] : msg;
|
||||
CommonResult commonResult = CommonResult.failResult(500, "500", "处理失败:" + msg + ",重复!");
|
||||
// commonResult.setData(ex.getStackTrace());
|
||||
response.setStatus(commonResult.getStateCode());
|
||||
log.error("服务内部错误", ex);
|
||||
setExceptionResponseHeader(response,commonResult.getMessage());
|
||||
ex.printStackTrace();
|
||||
return commonResult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_article
|
||||
*/
|
||||
@TableName(value ="km_article")
|
||||
@Data
|
||||
public class KmArticle implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 文章标题
|
||||
*/
|
||||
private String articleTitle;
|
||||
|
||||
/**
|
||||
* 文章介绍
|
||||
*/
|
||||
private String articleIntroduce;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String articleAuthor;
|
||||
|
||||
/**
|
||||
* 文章图片
|
||||
*/
|
||||
private String articlePicture;
|
||||
|
||||
/**
|
||||
* 正文
|
||||
*/
|
||||
private String articleText;
|
||||
|
||||
/**
|
||||
* 0为置顶,1为普通
|
||||
*/
|
||||
private Integer isFirst;
|
||||
|
||||
/**
|
||||
* 0为隐藏,1为普通
|
||||
*/
|
||||
private Integer isHide;
|
||||
|
||||
/**
|
||||
* 按区分类
|
||||
*/
|
||||
private String regionalClassification;
|
||||
|
||||
/**
|
||||
* 按口味分类
|
||||
*/
|
||||
private String foodClassification;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmArticle other = (KmArticle) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getArticleId() == null ? other.getArticleId() == null : this.getArticleId().equals(other.getArticleId()))
|
||||
&& (this.getArticleTitle() == null ? other.getArticleTitle() == null : this.getArticleTitle().equals(other.getArticleTitle()))
|
||||
&& (this.getArticleIntroduce() == null ? other.getArticleIntroduce() == null : this.getArticleIntroduce().equals(other.getArticleIntroduce()))
|
||||
&& (this.getArticleAuthor() == null ? other.getArticleAuthor() == null : this.getArticleAuthor().equals(other.getArticleAuthor()))
|
||||
&& (this.getArticlePicture() == null ? other.getArticlePicture() == null : this.getArticlePicture().equals(other.getArticlePicture()))
|
||||
&& (this.getArticleText() == null ? other.getArticleText() == null : this.getArticleText().equals(other.getArticleText()))
|
||||
&& (this.getIsFirst() == null ? other.getIsFirst() == null : this.getIsFirst().equals(other.getIsFirst()))
|
||||
&& (this.getIsHide() == null ? other.getIsHide() == null : this.getIsHide().equals(other.getIsHide()))
|
||||
&& (this.getRegionalClassification() == null ? other.getRegionalClassification() == null : this.getRegionalClassification().equals(other.getRegionalClassification()))
|
||||
&& (this.getFoodClassification() == null ? other.getFoodClassification() == null : this.getFoodClassification().equals(other.getFoodClassification()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getArticleId() == null) ? 0 : getArticleId().hashCode());
|
||||
result = prime * result + ((getArticleTitle() == null) ? 0 : getArticleTitle().hashCode());
|
||||
result = prime * result + ((getArticleIntroduce() == null) ? 0 : getArticleIntroduce().hashCode());
|
||||
result = prime * result + ((getArticleAuthor() == null) ? 0 : getArticleAuthor().hashCode());
|
||||
result = prime * result + ((getArticlePicture() == null) ? 0 : getArticlePicture().hashCode());
|
||||
result = prime * result + ((getArticleText() == null) ? 0 : getArticleText().hashCode());
|
||||
result = prime * result + ((getIsFirst() == null) ? 0 : getIsFirst().hashCode());
|
||||
result = prime * result + ((getIsHide() == null) ? 0 : getIsHide().hashCode());
|
||||
result = prime * result + ((getRegionalClassification() == null) ? 0 : getRegionalClassification().hashCode());
|
||||
result = prime * result + ((getFoodClassification() == null) ? 0 : getFoodClassification().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", articleId=").append(articleId);
|
||||
sb.append(", articleTitle=").append(articleTitle);
|
||||
sb.append(", articleIntroduce=").append(articleIntroduce);
|
||||
sb.append(", articleAuthor=").append(articleAuthor);
|
||||
sb.append(", articlePicture=").append(articlePicture);
|
||||
sb.append(", articleText=").append(articleText);
|
||||
sb.append(", isFirst=").append(isFirst);
|
||||
sb.append(", isHide=").append(isHide);
|
||||
sb.append(", regionalClassification=").append(regionalClassification);
|
||||
sb.append(", foodClassification=").append(foodClassification);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,157 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_article_comment
|
||||
*/
|
||||
@TableName(value ="km_article_comment")
|
||||
@Data
|
||||
public class KmArticleComment implements Serializable {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 粉丝ID
|
||||
*/
|
||||
private String fansId;
|
||||
|
||||
/**
|
||||
* 评论ID
|
||||
*/
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 作者ID
|
||||
*/
|
||||
private String authorId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String commentText;
|
||||
|
||||
/**
|
||||
* 打分
|
||||
*/
|
||||
private Double point;
|
||||
|
||||
/**
|
||||
* 0为置顶,1为普通
|
||||
*/
|
||||
private Integer isFirst;
|
||||
|
||||
/**
|
||||
* 0为隐藏,1为普通
|
||||
*/
|
||||
private Integer isHide;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmArticleComment other = (KmArticleComment) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getFansId() == null ? other.getFansId() == null : this.getFansId().equals(other.getFansId()))
|
||||
&& (this.getCommentId() == null ? other.getCommentId() == null : this.getCommentId().equals(other.getCommentId()))
|
||||
&& (this.getArticleId() == null ? other.getArticleId() == null : this.getArticleId().equals(other.getArticleId()))
|
||||
&& (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId()))
|
||||
&& (this.getCommentText() == null ? other.getCommentText() == null : this.getCommentText().equals(other.getCommentText()))
|
||||
&& (this.getPoint() == null ? other.getPoint() == null : this.getPoint().equals(other.getPoint()))
|
||||
&& (this.getIsFirst() == null ? other.getIsFirst() == null : this.getIsFirst().equals(other.getIsFirst()))
|
||||
&& (this.getIsHide() == null ? other.getIsHide() == null : this.getIsHide().equals(other.getIsHide()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getFansId() == null) ? 0 : getFansId().hashCode());
|
||||
result = prime * result + ((getCommentId() == null) ? 0 : getCommentId().hashCode());
|
||||
result = prime * result + ((getArticleId() == null) ? 0 : getArticleId().hashCode());
|
||||
result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode());
|
||||
result = prime * result + ((getCommentText() == null) ? 0 : getCommentText().hashCode());
|
||||
result = prime * result + ((getPoint() == null) ? 0 : getPoint().hashCode());
|
||||
result = prime * result + ((getIsFirst() == null) ? 0 : getIsFirst().hashCode());
|
||||
result = prime * result + ((getIsHide() == null) ? 0 : getIsHide().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", fansId=").append(fansId);
|
||||
sb.append(", commentId=").append(commentId);
|
||||
sb.append(", articleId=").append(articleId);
|
||||
sb.append(", authorId=").append(authorId);
|
||||
sb.append(", commentText=").append(commentText);
|
||||
sb.append(", point=").append(point);
|
||||
sb.append(", isFirst=").append(isFirst);
|
||||
sb.append(", isHide=").append(isHide);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,157 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_article_details
|
||||
*/
|
||||
@TableName(value ="km_article_details")
|
||||
@Data
|
||||
public class KmArticleDetails implements Serializable {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 文章细节ID
|
||||
*/
|
||||
private Integer articleDetailsId;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private Integer articleId;
|
||||
|
||||
/**
|
||||
* 餐饮信息
|
||||
*/
|
||||
private String foodName;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 餐厅名称
|
||||
*/
|
||||
private String restaurant;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 营业时间
|
||||
*/
|
||||
private String businessHours;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmArticleDetails other = (KmArticleDetails) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getArticleDetailsId() == null ? other.getArticleDetailsId() == null : this.getArticleDetailsId().equals(other.getArticleDetailsId()))
|
||||
&& (this.getArticleId() == null ? other.getArticleId() == null : this.getArticleId().equals(other.getArticleId()))
|
||||
&& (this.getFoodName() == null ? other.getFoodName() == null : this.getFoodName().equals(other.getFoodName()))
|
||||
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
|
||||
&& (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress()))
|
||||
&& (this.getRestaurant() == null ? other.getRestaurant() == null : this.getRestaurant().equals(other.getRestaurant()))
|
||||
&& (this.getPhoneNumber() == null ? other.getPhoneNumber() == null : this.getPhoneNumber().equals(other.getPhoneNumber()))
|
||||
&& (this.getBusinessHours() == null ? other.getBusinessHours() == null : this.getBusinessHours().equals(other.getBusinessHours()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getArticleDetailsId() == null) ? 0 : getArticleDetailsId().hashCode());
|
||||
result = prime * result + ((getArticleId() == null) ? 0 : getArticleId().hashCode());
|
||||
result = prime * result + ((getFoodName() == null) ? 0 : getFoodName().hashCode());
|
||||
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
|
||||
result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode());
|
||||
result = prime * result + ((getRestaurant() == null) ? 0 : getRestaurant().hashCode());
|
||||
result = prime * result + ((getPhoneNumber() == null) ? 0 : getPhoneNumber().hashCode());
|
||||
result = prime * result + ((getBusinessHours() == null) ? 0 : getBusinessHours().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", articleDetailsId=").append(articleDetailsId);
|
||||
sb.append(", articleId=").append(articleId);
|
||||
sb.append(", foodName=").append(foodName);
|
||||
sb.append(", price=").append(price);
|
||||
sb.append(", address=").append(address);
|
||||
sb.append(", restaurant=").append(restaurant);
|
||||
sb.append(", phoneNumber=").append(phoneNumber);
|
||||
sb.append(", businessHours=").append(businessHours);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,125 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_fans
|
||||
*/
|
||||
@TableName(value ="km_fans")
|
||||
@Data
|
||||
public class KmFans implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxUsername;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxPicture;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmFans other = (KmFans) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getWxId() == null ? other.getWxId() == null : this.getWxId().equals(other.getWxId()))
|
||||
&& (this.getWxUsername() == null ? other.getWxUsername() == null : this.getWxUsername().equals(other.getWxUsername()))
|
||||
&& (this.getWxPicture() == null ? other.getWxPicture() == null : this.getWxPicture().equals(other.getWxPicture()))
|
||||
&& (this.getWxAddress() == null ? other.getWxAddress() == null : this.getWxAddress().equals(other.getWxAddress()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getWxId() == null) ? 0 : getWxId().hashCode());
|
||||
result = prime * result + ((getWxUsername() == null) ? 0 : getWxUsername().hashCode());
|
||||
result = prime * result + ((getWxPicture() == null) ? 0 : getWxPicture().hashCode());
|
||||
result = prime * result + ((getWxAddress() == null) ? 0 : getWxAddress().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", wxId=").append(wxId);
|
||||
sb.append(", wxUsername=").append(wxUsername);
|
||||
sb.append(", wxPicture=").append(wxPicture);
|
||||
sb.append(", wxAddress=").append(wxAddress);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,135 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.aqroid.dataprocess.auth.annotation.Username;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_system_staff
|
||||
*/
|
||||
@TableName(value ="km_system_staff")
|
||||
@Data
|
||||
public class KmSystemStaff implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Username
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charactar;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmSystemStaff other = (KmSystemStaff) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getUserName() == null ? other.getUserName() == null : this.getUserName().equals(other.getUserName()))
|
||||
&& (this.getPhoneNumber() == null ? other.getPhoneNumber() == null : this.getPhoneNumber().equals(other.getPhoneNumber()))
|
||||
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
|
||||
&& (this.getCharactar() == null ? other.getCharactar() == null : this.getCharactar().equals(other.getCharactar()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode());
|
||||
result = prime * result + ((getPhoneNumber() == null) ? 0 : getPhoneNumber().hashCode());
|
||||
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
||||
result = prime * result + ((getCharactar() == null) ? 0 : getCharactar().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", userName=").append(userName);
|
||||
sb.append(", phoneNumber=").append(phoneNumber);
|
||||
sb.append(", password=").append(password);
|
||||
sb.append(", charactar=").append(charactar);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,117 @@
|
||||
package com.aqroid.dataprocess.generator.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName km_system_staff_role
|
||||
*/
|
||||
@TableName(value ="km_system_staff_role")
|
||||
@Data
|
||||
public class KmSystemStaffRole implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charactarId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charactarName;
|
||||
|
||||
/**
|
||||
* 0为使用
|
||||
*/
|
||||
private Integer hasUsed;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
KmSystemStaffRole other = (KmSystemStaffRole) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getCharactarId() == null ? other.getCharactarId() == null : this.getCharactarId().equals(other.getCharactarId()))
|
||||
&& (this.getCharactarName() == null ? other.getCharactarName() == null : this.getCharactarName().equals(other.getCharactarName()))
|
||||
&& (this.getHasUsed() == null ? other.getHasUsed() == null : this.getHasUsed().equals(other.getHasUsed()))
|
||||
&& (this.getCreatedTime() == null ? other.getCreatedTime() == null : this.getCreatedTime().equals(other.getCreatedTime()))
|
||||
&& (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
|
||||
&& (this.getUpdatedTime() == null ? other.getUpdatedTime() == null : this.getUpdatedTime().equals(other.getUpdatedTime()))
|
||||
&& (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getCharactarId() == null) ? 0 : getCharactarId().hashCode());
|
||||
result = prime * result + ((getCharactarName() == null) ? 0 : getCharactarName().hashCode());
|
||||
result = prime * result + ((getHasUsed() == null) ? 0 : getHasUsed().hashCode());
|
||||
result = prime * result + ((getCreatedTime() == null) ? 0 : getCreatedTime().hashCode());
|
||||
result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
|
||||
result = prime * result + ((getUpdatedTime() == null) ? 0 : getUpdatedTime().hashCode());
|
||||
result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", charactarId=").append(charactarId);
|
||||
sb.append(", charactarName=").append(charactarName);
|
||||
sb.append(", hasUsed=").append(hasUsed);
|
||||
sb.append(", createdTime=").append(createdTime);
|
||||
sb.append(", createdBy=").append(createdBy);
|
||||
sb.append(", updatedTime=").append(updatedTime);
|
||||
sb.append(", updatedBy=").append(updatedBy);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleComment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_comment】的数据库操作Mapper
|
||||
* @createDate 2024-11-14 11:12:56
|
||||
* @Entity generator.domain.KmArticleComment
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmArticleCommentMapper extends BaseMapper<KmArticleComment> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleDetails;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_details】的数据库操作Mapper
|
||||
* @createDate 2024-11-14 11:12:49
|
||||
* @Entity generator.domain.KmArticleDetails
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmArticleDetailsMapper extends BaseMapper<KmArticleDetails> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticle;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article】的数据库操作Mapper
|
||||
* @createDate 2024-11-14 11:13:04
|
||||
* @Entity generator.domain.KmArticle
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmArticleMapper extends BaseMapper<KmArticle> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmFans;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_fans】的数据库操作Mapper
|
||||
* @createDate 2024-11-14 11:12:41
|
||||
* @Entity generator.domain.KmFans
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmFansMapper extends BaseMapper<KmFans> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaff;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff】的数据库操作Mapper
|
||||
* @createDate 2024-11-14 11:12:12
|
||||
* @Entity generator.domain.KmSystemStaff
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmSystemStaffMapper extends BaseMapper<KmSystemStaff> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.mapper;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaffRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff_role】的数据库操作Mapper
|
||||
* @createDate 2024-11-18 11:02:00
|
||||
* @Entity generator.domain.KmSystemStaffRole
|
||||
*/
|
||||
@Mapper
|
||||
public interface KmSystemStaffRoleMapper extends BaseMapper<KmSystemStaffRole> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleComment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_comment】的数据库操作Service
|
||||
* @createDate 2024-11-14 11:12:56
|
||||
*/
|
||||
public interface KmArticleCommentService extends IService<KmArticleComment> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleDetails;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_details】的数据库操作Service
|
||||
* @createDate 2024-11-14 11:12:49
|
||||
*/
|
||||
public interface KmArticleDetailsService extends IService<KmArticleDetails> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticle;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article】的数据库操作Service
|
||||
* @createDate 2024-11-14 11:13:04
|
||||
*/
|
||||
public interface KmArticleService extends IService<KmArticle> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmFans;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_fans】的数据库操作Service
|
||||
* @createDate 2024-11-14 11:12:41
|
||||
*/
|
||||
public interface KmFansService extends IService<KmFans> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaffRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff_role】的数据库操作Service
|
||||
* @createDate 2024-11-18 11:02:00
|
||||
*/
|
||||
public interface KmSystemStaffRoleService extends IService<KmSystemStaffRole> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.aqroid.dataprocess.generator.service;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaff;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff】的数据库操作Service
|
||||
* @createDate 2024-11-14 11:12:12
|
||||
*/
|
||||
public interface KmSystemStaffService extends IService<KmSystemStaff> {
|
||||
|
||||
List<SimpleGrantedAuthority> getAuthorities(KmSystemStaffDto dto);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleComment;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmArticleCommentMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmArticleCommentService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_comment】的数据库操作Service实现
|
||||
* @createDate 2024-11-14 11:12:56
|
||||
*/
|
||||
@Service
|
||||
public class KmArticleCommentServiceImpl extends ServiceImpl<KmArticleCommentMapper, KmArticleComment>
|
||||
implements KmArticleCommentService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticleDetails;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmArticleDetailsMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmArticleDetailsService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article_details】的数据库操作Service实现
|
||||
* @createDate 2024-11-14 11:12:49
|
||||
*/
|
||||
@Service
|
||||
public class KmArticleDetailsServiceImpl extends ServiceImpl<KmArticleDetailsMapper, KmArticleDetails>
|
||||
implements KmArticleDetailsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmArticle;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmArticleMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmArticleService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_article】的数据库操作Service实现
|
||||
* @createDate 2024-11-14 11:13:04
|
||||
*/
|
||||
@Service
|
||||
public class KmArticleServiceImpl extends ServiceImpl<KmArticleMapper, KmArticle>
|
||||
implements KmArticleService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmFans;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmFansMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmFansService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_fans】的数据库操作Service实现
|
||||
* @createDate 2024-11-14 11:12:41
|
||||
*/
|
||||
@Service
|
||||
public class KmFansServiceImpl extends ServiceImpl<KmFansMapper, KmFans>
|
||||
implements KmFansService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaffRole;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmSystemStaffRoleMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmSystemStaffRoleService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff_role】的数据库操作Service实现
|
||||
* @createDate 2024-11-18 11:02:00
|
||||
*/
|
||||
@Service
|
||||
public class KmSystemStaffRoleServiceImpl extends ServiceImpl<KmSystemStaffRoleMapper, KmSystemStaffRole>
|
||||
implements KmSystemStaffRoleService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
package com.aqroid.dataprocess.generator.service.impl;
|
||||
|
||||
import com.aqroid.dataprocess.constants.BuildInRoleGroup;
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaff;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmSystemStaffMapper;
|
||||
import com.aqroid.dataprocess.generator.service.KmSystemStaffService;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 31092
|
||||
* @description 针对表【km_system_staff】的数据库操作Service实现
|
||||
* @createDate 2024-11-14 11:12:12
|
||||
*/
|
||||
@Service
|
||||
public class KmSystemStaffServiceImpl extends ServiceImpl<KmSystemStaffMapper, KmSystemStaff>
|
||||
implements KmSystemStaffService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<SimpleGrantedAuthority> getAuthorities(KmSystemStaffDto dto) {
|
||||
BuildInRoleGroup roleGroup = BuildInRoleGroup.getByName(dto.getCharactar().getCharactarName());
|
||||
|
||||
ArrayList<SimpleGrantedAuthority> list = new ArrayList<>();
|
||||
roleGroup.roleMap.forEach((key, value) -> {
|
||||
value.forEach(moduleAction -> {
|
||||
list.add(new SimpleGrantedAuthority(key.name+"|"+moduleAction.name));
|
||||
});
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
/**
|
||||
* 对象转换器
|
||||
*
|
||||
* @param <D> do
|
||||
* @param <T> dto
|
||||
*/
|
||||
public abstract class POJOConverter<D, T> {
|
||||
|
||||
Class<D> dClass = (Class<D>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
Class<T> tClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[1];
|
||||
|
||||
private D getNewDoInstence() throws IllegalAccessException, InstantiationException {
|
||||
return dClass.newInstance();
|
||||
}
|
||||
|
||||
private T getNewDtoInstence() throws IllegalAccessException, InstantiationException {
|
||||
return tClass.newInstance();
|
||||
}
|
||||
|
||||
public D getDO(T dto) {
|
||||
if (dto == null) return null;
|
||||
D newDoInstence;
|
||||
try {
|
||||
newDoInstence = getNewDoInstence();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(dClass.toString() + "没有无参构造器...");
|
||||
}
|
||||
return initDo(newDoInstence, dto);
|
||||
}
|
||||
|
||||
public T getDTO(D dataObject) {
|
||||
if (dataObject == null) {
|
||||
return null;
|
||||
}
|
||||
T newDtoInstence;
|
||||
try {
|
||||
newDtoInstence = getNewDtoInstence();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(tClass.toString() + "没有无参构造器...");
|
||||
}
|
||||
return initDTO(dataObject, newDtoInstence);
|
||||
}
|
||||
|
||||
protected abstract D initDo(D dataObject, T dto);
|
||||
|
||||
protected abstract T initDTO(D dataObject, T dto);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmArticleCommentDto {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 粉丝ID
|
||||
*/
|
||||
private String fansId;
|
||||
|
||||
/**
|
||||
* 评论ID
|
||||
*/
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 作者ID
|
||||
*/
|
||||
private String authorId;
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String commentText;
|
||||
|
||||
/**
|
||||
* 打分
|
||||
*/
|
||||
private Double point;
|
||||
|
||||
/**
|
||||
* 0为置顶,1为普通
|
||||
*/
|
||||
private Integer isFirst;
|
||||
|
||||
/**
|
||||
* 0为隐藏,1为普通
|
||||
*/
|
||||
private Integer isHide;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmArticleDetailsDto {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 文章细节ID
|
||||
*/
|
||||
private Integer articleDetailsId;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private Integer articleId;
|
||||
|
||||
/**
|
||||
* 餐饮信息
|
||||
*/
|
||||
private String foodName;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 餐厅名称
|
||||
*/
|
||||
private String restaurant;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 营业时间
|
||||
*/
|
||||
private String businessHours;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmArticleDto {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 文章ID
|
||||
*/
|
||||
private String articleId;
|
||||
|
||||
/**
|
||||
* 文章标题
|
||||
*/
|
||||
private String articleTitle;
|
||||
|
||||
/**
|
||||
* 文章介绍
|
||||
*/
|
||||
private String articleIntroduce;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String articleAuthor;
|
||||
|
||||
/**
|
||||
* 文章图片
|
||||
*/
|
||||
private String articlePicture;
|
||||
|
||||
/**
|
||||
* 正文
|
||||
*/
|
||||
private String articleText;
|
||||
|
||||
/**
|
||||
* 0为置顶,1为普通
|
||||
*/
|
||||
private Integer isFirst;
|
||||
|
||||
/**
|
||||
* 0为隐藏,1为普通
|
||||
*/
|
||||
private Integer isHide;
|
||||
|
||||
/**
|
||||
* 按区分类
|
||||
*/
|
||||
private String regionalClassification;
|
||||
|
||||
/**
|
||||
* 按口味分类
|
||||
*/
|
||||
private String foodClassification;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
private KmArticleDetailsDto detailsDto;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmFansDto {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxUsername;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxPicture;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String wxAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import com.aqroid.dataprocess.auth.annotation.Username;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmSystemStaffDto {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Username
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private KmSystemStaffRoleDto charactar;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Data
|
||||
public class KmSystemStaffRoleDto {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charactarId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String charactarName;
|
||||
|
||||
/**
|
||||
* 0为使用
|
||||
*/
|
||||
private Integer hasUsed;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
private List<SimpleGrantedAuthority> authorityList;
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto.converter;
|
||||
|
||||
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaff;
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaffRole;
|
||||
import com.aqroid.dataprocess.generator.mapper.KmSystemStaffRoleMapper;
|
||||
import com.aqroid.dataprocess.mybatisPlus.POJOConverter;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffDto;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Component
|
||||
public class KmSystemStaffConverter extends POJOConverter<KmSystemStaff, KmSystemStaffDto> {
|
||||
|
||||
@Autowired
|
||||
private KmSystemStaffRoleMapper staffRoleMapper;
|
||||
@Autowired
|
||||
private KmSystemStaffRoleConverter roleConverter;
|
||||
|
||||
@Override
|
||||
protected KmSystemStaff initDo(KmSystemStaff dataObject, KmSystemStaffDto dto) {
|
||||
dataObject.setId(dto.getId());
|
||||
dataObject.setUserId(dto.getUserId());
|
||||
dataObject.setUserName(dto.getUserName());
|
||||
dataObject.setPhoneNumber(dto.getPhoneNumber());
|
||||
dataObject.setPassword(dto.getPassword());
|
||||
dataObject.setCharactar(dto.getCharactar().getCharactarId());
|
||||
if (StringUtils.isNotEmpty(dto.getCreatedBy())) {
|
||||
dataObject.setCreatedBy(dto.getCreatedBy());
|
||||
}
|
||||
dataObject.setCreatedTime(dto.getCreatedTime());
|
||||
if (StringUtils.isNotEmpty(dto.getUpdatedBy())) {
|
||||
dataObject.setUpdatedBy(dto.getUpdatedBy());
|
||||
}
|
||||
dataObject.setUpdatedTime(dto.getUpdatedTime());
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KmSystemStaffDto initDTO(KmSystemStaff dataObject, KmSystemStaffDto dto) {
|
||||
dto.setId(dataObject.getId());
|
||||
dto.setUserId(dataObject.getUserId());
|
||||
dto.setUserName(dataObject.getUserName());
|
||||
dto.setPhoneNumber(dataObject.getPhoneNumber());
|
||||
dto.setPassword(dataObject.getPassword());
|
||||
LambdaQueryWrapper<KmSystemStaffRole> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(KmSystemStaffRole::getId,dataObject.getCharactar());
|
||||
dto.setCharactar(roleConverter.getDTO(staffRoleMapper.selectOne(wrapper)));
|
||||
|
||||
dto.setCreatedTime(dataObject.getCreatedTime());
|
||||
dto.setUpdatedTime(dataObject.getUpdatedTime());
|
||||
if (StringUtils.isNotEmpty(dataObject.getUpdatedBy())) {
|
||||
dto.setUpdatedBy(dto.getUpdatedBy());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dataObject.getUpdatedBy())) {
|
||||
dto.setUpdatedBy(dto.getUpdatedBy());
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.aqroid.dataprocess.mybatisPlus.dto.converter;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.aqroid.dataprocess.generator.domain.KmSystemStaffRole;
|
||||
import com.aqroid.dataprocess.mybatisPlus.POJOConverter;
|
||||
import com.aqroid.dataprocess.mybatisPlus.dto.KmSystemStaffRoleDto;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
@Component
|
||||
public class KmSystemStaffRoleConverter extends POJOConverter<KmSystemStaffRole, KmSystemStaffRoleDto> {
|
||||
@Override
|
||||
protected KmSystemStaffRole initDo(KmSystemStaffRole dataObject, KmSystemStaffRoleDto dto) {
|
||||
dataObject.setId(dto.getId());
|
||||
dataObject.setCharactarId(dto.getCharactarId());
|
||||
dataObject.setCharactarName(dto.getCharactarName());
|
||||
dataObject.setHasUsed(dto.getHasUsed());
|
||||
if (StringUtils.isNotEmpty(dto.getCreatedBy())) {
|
||||
dataObject.setCreatedBy(dto.getCreatedBy());
|
||||
}
|
||||
dataObject.setCreatedTime(dto.getCreatedTime());
|
||||
if (StringUtils.isNotEmpty(dto.getUpdatedBy())) {
|
||||
dataObject.setUpdatedBy(dto.getUpdatedBy());
|
||||
}
|
||||
dataObject.setUpdatedTime(dto.getUpdatedTime());
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KmSystemStaffRoleDto initDTO(KmSystemStaffRole dataObject, KmSystemStaffRoleDto dto) {
|
||||
BeanUtil.copyProperties(dataObject,dto);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.aqroid.dataprocess.token;
|
||||
|
||||
import com.aqroid.dataprocess.token.codec.TokenCodec;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 默认token编码解码器「直接return」
|
||||
*
|
||||
* @author wangke
|
||||
*/
|
||||
@ConditionalOnMissingBean(LoadingCache.class)
|
||||
@Component
|
||||
public class DefaultTokenCodec implements TokenCodec {
|
||||
@Override
|
||||
public String encode(String token) {
|
||||
return token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refreshEncode(String token, String oldToken) {
|
||||
return oldToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String subToken) {
|
||||
return subToken;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.aqroid.dataprocess.token.codec;
|
||||
|
||||
/**
|
||||
* token 编码解码器
|
||||
*
|
||||
* @author wangke
|
||||
*/
|
||||
public interface TokenCodec {
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* @param token 完整token
|
||||
* @return 短tokenHash
|
||||
*/
|
||||
String encode(String token);
|
||||
String refreshEncode(String token,String oldToken);
|
||||
|
||||
/**
|
||||
* 解码
|
||||
*
|
||||
* @param subToken 短tokenHash
|
||||
* @return 完整token
|
||||
*/
|
||||
String decode(String subToken);
|
||||
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.aqroid.dataprocess.token.impl;
|
||||
|
||||
import com.aqroid.dataprocess.token.codec.TokenCodec;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* 基于hashMap的token编码解码器
|
||||
*
|
||||
* @author wangke
|
||||
*/
|
||||
@Slf4j
|
||||
@ConditionalOnBean(LoadingCache.class)
|
||||
@Component
|
||||
public class CaffeineTokenCodec implements TokenCodec {
|
||||
|
||||
public static final String TOKEN_PREFIX = "token_";
|
||||
|
||||
@Autowired
|
||||
private LoadingCache caffeineCache;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String encode(String token) {
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
MessageDigest md51 = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md51.digest(token.getBytes("UTF-8"));
|
||||
String md5String = bytesToHex(digest);
|
||||
caffeineCache.put(TOKEN_PREFIX + md5String, token);
|
||||
return md5String;
|
||||
|
||||
}
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String refreshEncode(String token,String oldToken) {
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
caffeineCache.put(TOKEN_PREFIX + oldToken, token);
|
||||
return oldToken;
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void testMD5() {
|
||||
|
||||
String token = "3456789odkjnfbghjnbh";
|
||||
|
||||
MessageDigest md51 = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md51.digest(token.getBytes("UTF-8"));
|
||||
String s = bytesToHex(digest);
|
||||
log.info(s);
|
||||
}
|
||||
|
||||
// 二进制转十六进制
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
StringBuffer hexStr = new StringBuffer();
|
||||
int num;
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
num = bytes[i];
|
||||
if (num < 0) {
|
||||
num += 256;
|
||||
}
|
||||
if (num < 16) {
|
||||
hexStr.append("0");
|
||||
}
|
||||
hexStr.append(Integer.toHexString(num));
|
||||
}
|
||||
return hexStr.toString().toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String subToken) {
|
||||
if (StringUtils.isBlank(subToken)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (String) caffeineCache.get(TOKEN_PREFIX + subToken);
|
||||
}
|
||||
}
|
||||
51
src/main/java/com/aqroid/dataprocess/utils/CommonResult.java
Normal file
51
src/main/java/com/aqroid/dataprocess/utils/CommonResult.java
Normal file
@ -0,0 +1,51 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import com.aqroid.dataprocess.exception.BusinessException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author ytqzd
|
||||
* @date 2023/11/7 15:19
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public class CommonResult<T> {
|
||||
|
||||
private int stateCode = 200;
|
||||
private String errorCode = "0";
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*
|
||||
* @param data 成功返回数据
|
||||
*/
|
||||
public static <T> CommonResult<T> successResult(T data) {
|
||||
return new CommonResult<>(200, "0", "", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回
|
||||
*
|
||||
* @param stateCode http状态码
|
||||
* @param errorCode 业务失败码
|
||||
* @param message 错误信息
|
||||
*/
|
||||
public static CommonResult<Void> failResult(int stateCode, String errorCode, String message) {
|
||||
return new CommonResult<>(stateCode, errorCode, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回重写-AuthenticationException
|
||||
*
|
||||
* @param exception 权限错误
|
||||
*/
|
||||
public static CommonResult<Void> failResult(BusinessException exception) {
|
||||
return new CommonResult<>(401, exception.getExceptionEnum().getErrorCode(), exception.getExceptionEnum().getMessage(), null);
|
||||
}
|
||||
|
||||
}
|
||||
52
src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java
Normal file
52
src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 转换工具类
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
public class ConvertUtils {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class);
|
||||
|
||||
public static <T> T sourceToTarget(Object source, Class<T> target){
|
||||
if(source == null){
|
||||
return null;
|
||||
}
|
||||
T targetObject = null;
|
||||
try {
|
||||
targetObject = target.newInstance();
|
||||
BeanUtils.copyProperties(source, targetObject);
|
||||
} catch (Exception e) {
|
||||
logger.error("convert error ", e);
|
||||
}
|
||||
|
||||
return targetObject;
|
||||
}
|
||||
|
||||
public static <T> List<T> sourceToTarget(Collection<?> sourceList, Class<T> target){
|
||||
if(sourceList == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
List targetList = new ArrayList<>(sourceList.size());
|
||||
try {
|
||||
for(Object source : sourceList){
|
||||
T targetObject = target.newInstance();
|
||||
BeanUtils.copyProperties(source, targetObject);
|
||||
targetList.add(targetObject);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("convert error ", e);
|
||||
}
|
||||
|
||||
return targetList;
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/aqroid/dataprocess/utils/DateUtils.java
Normal file
18
src/main/java/com/aqroid/dataprocess/utils/DateUtils.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
public static String getCurrentYYYMMDDHHMM(){
|
||||
return ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm")).get().format(new Date());
|
||||
}
|
||||
|
||||
public static String getCurrentDetails(){
|
||||
return ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).get().format(new Date());
|
||||
}
|
||||
}
|
||||
64
src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java
Normal file
64
src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java
Normal file
@ -0,0 +1,64 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
import java.util.Random;
|
||||
/**
|
||||
* ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ
|
||||
*/
|
||||
public class DcodeUtils {
|
||||
private static final String NUMBERS_AND_LETTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
/**
|
||||
* 生成指定长度的数字验证码
|
||||
*
|
||||
* @param length 验证码长度
|
||||
* @return 数字验证码
|
||||
*/
|
||||
public static String generateNumericCaptcha(int length) {
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(RANDOM.nextInt(10));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定长度的字母和数字组合的验证码
|
||||
*
|
||||
* @param length 验证码长度
|
||||
* @return 字母和数字组合的验证码
|
||||
*/
|
||||
public static String generateAlphanumericCaptcha(int length) {
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = RANDOM.nextInt(NUMBERS_AND_LETTERS.length());
|
||||
sb.append(NUMBERS_AND_LETTERS.charAt(index));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户输入的验证码是否正确
|
||||
*
|
||||
* @param userCaptcha 用户输入的验证码
|
||||
* @param generatedCaptcha 生成的验证码
|
||||
* @return 验证结果
|
||||
*/
|
||||
public static boolean validateCaptcha(String userCaptcha, String generatedCaptcha) {
|
||||
return userCaptcha != null && userCaptcha.equalsIgnoreCase(generatedCaptcha);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 生成一个6位数字验证码
|
||||
String numericCaptcha = generateNumericCaptcha(6);
|
||||
System.out.println("Generated Numeric Captcha: " + numericCaptcha);
|
||||
|
||||
// 生成一个6位字母和数字组合的验证码
|
||||
String alphanumericCaptcha = generateAlphanumericCaptcha(6);
|
||||
System.out.println("Generated Alphanumeric Captcha: " + alphanumericCaptcha);
|
||||
|
||||
// 验证用户输入的验证码
|
||||
String userCaptcha = "123456";
|
||||
boolean isValid = validateCaptcha(userCaptcha, numericCaptcha);
|
||||
System.out.println("Is the user captcha valid? " + isValid);
|
||||
}
|
||||
}
|
||||
9
src/main/java/com/aqroid/dataprocess/utils/IDUtils.java
Normal file
9
src/main/java/com/aqroid/dataprocess/utils/IDUtils.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class IDUtils {
|
||||
public static String createUUID() {
|
||||
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||
}
|
||||
}
|
||||
133
src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java
Normal file
133
src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java
Normal file
@ -0,0 +1,133 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aqroid.dataprocess.auth.annotation.Username;
|
||||
import com.aqroid.dataprocess.auth.dto.LoginUser;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.JwtBuilder;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* jwt工具类
|
||||
*/
|
||||
@Component
|
||||
public class JwtTokenUtils {
|
||||
|
||||
public static final String KEY_DTO = "dto";
|
||||
|
||||
public static final String KEY_DTO_CLASS = "dtoClass";
|
||||
|
||||
public static final String KEY_AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* token 默认过期时间一小时
|
||||
*/
|
||||
public static Long expiration = 60 * 60 * 1000L;
|
||||
/**
|
||||
* token默认刷新时间半小时
|
||||
*/
|
||||
public static Long refresh = 30 * 60 * 1000L;
|
||||
|
||||
/**
|
||||
* jwt_secret
|
||||
*/
|
||||
public static String jwt_secret = "safety-case";
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
*/
|
||||
|
||||
@SneakyThrows
|
||||
public static <T> String generateToken(LoginUser customUserDetails) {
|
||||
HashMap<String, Object> claims = new HashMap<>(2, 1);
|
||||
claims.put(KEY_DTO, JSONObject.toJSONString(customUserDetails.getUser()));
|
||||
claims.put(KEY_DTO_CLASS, customUserDetails.getUser().getClass());
|
||||
claims.put(KEY_AUTHORITIES, JSONObject.toJSONString(customUserDetails.getAuthorities()));
|
||||
|
||||
return doGenerateToken(claims, getUserName(customUserDetails.getUser()),false);
|
||||
|
||||
}
|
||||
public static String doGenerateToken(Map<String, Object> claims, String subject,Boolean refresh) {
|
||||
final Date createdDate = new Date();
|
||||
final Date expirationDate = calculateExpirationDate(createdDate);
|
||||
final Date refreshDate = calculateRefreshExpirationDate(createdDate);
|
||||
|
||||
JwtBuilder jwtBuilder = Jwts.builder()
|
||||
.setClaims(claims)
|
||||
.setSubject(subject)
|
||||
.setIssuedAt(createdDate);//颁发时间
|
||||
if (!refresh){
|
||||
jwtBuilder.setExpiration(expirationDate);//过期时间
|
||||
}else {
|
||||
jwtBuilder.setExpiration(refreshDate);
|
||||
}
|
||||
return jwtBuilder.signWith(SignatureAlgorithm.HS256, jwt_secret).compact();//秘钥
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static <T> String getUserName(T dto) {
|
||||
for (Field declaredField : dto.getClass().getDeclaredFields()) {
|
||||
if (declaredField.isAnnotationPresent(Username.class)) {
|
||||
declaredField.setAccessible(true);
|
||||
return (String) declaredField.get(dto);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("要生成token的" + dto.getClass() + "类的username字段需要添加@Username注解");
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算过期时间
|
||||
*
|
||||
* @param createdDate
|
||||
* @return
|
||||
*/
|
||||
public static Date calculateExpirationDate(Date createdDate) {
|
||||
return new Date(createdDate.getTime() + expiration);
|
||||
}
|
||||
public static Date calculateRefreshExpirationDate(Date createdDate) {
|
||||
return new Date(createdDate.getTime() + refresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据token解析用户信息
|
||||
*/
|
||||
public static String getUsernameFromToken(String token) {
|
||||
return getClaimFromToken(token, Claims::getSubject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定claim对象
|
||||
*
|
||||
* @param token
|
||||
* @param claimsResolver
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T getClaimFromToken(String token, Function<Claims, T> claimsResolver) {
|
||||
final Claims claims = getAllClaimsFromToken(token);
|
||||
return claimsResolver.apply(claims);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有claims
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Claims getAllClaimsFromToken(String token) {
|
||||
return Jwts.parser()
|
||||
.setSigningKey(jwt_secret)
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
103
src/main/java/com/aqroid/dataprocess/utils/RadioFile.java
Normal file
103
src/main/java/com/aqroid/dataprocess/utils/RadioFile.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.aqroid.dataprocess.utils;
|
||||
|
||||
import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
import org.bytedeco.javacv.FFmpegFrameRecorder;
|
||||
import org.bytedeco.javacv.Frame;
|
||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class RadioFile {
|
||||
|
||||
public static void addWatermarkToVideo(String inputVideoPath, String watermarkImagePath, String outputVideoPath) throws IOException {
|
||||
File inputFile = new File(inputVideoPath);
|
||||
if (!inputFile.exists()) {
|
||||
System.out.println("视频文件不存在,请检查路径!");
|
||||
return;
|
||||
}
|
||||
|
||||
// File videoFile = new File("D:\\radio\\fire.mp4");
|
||||
// try {
|
||||
// FileInputStream fis = new FileInputStream(videoFile);
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int bytesRead = fis.read(buffer);
|
||||
// if (bytesRead!= -1) {
|
||||
// System.out.println("文件读取成功,已读取 " + bytesRead + " 字节数据。");
|
||||
// } else {
|
||||
// System.out.println("文件可能为空或者读取出现问题。");
|
||||
// }
|
||||
// fis.close();
|
||||
// } catch (IOException e) {
|
||||
// System.out.println("读取文件时出现异常,可能文件不存在或者无读取权限等,异常信息: " + e.getMessage());
|
||||
// }
|
||||
|
||||
|
||||
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputVideoPath);
|
||||
grabber.start();
|
||||
|
||||
System.out.println("视频宽度: " + grabber.getImageWidth());
|
||||
System.out.println("视频高度: " + grabber.getImageHeight());
|
||||
System.out.println("视频帧率: " + grabber.getFrameRate());
|
||||
System.out.println("视频编码格式: " + grabber.getVideoCodecName());
|
||||
System.out.println("音轨: " + grabber.getAudioChannels());
|
||||
|
||||
FFmpegFrameRecorder recorder = getfFmpegFrameRecorder(outputVideoPath, grabber);
|
||||
|
||||
Java2DFrameConverter converter = new Java2DFrameConverter();
|
||||
BufferedImage watermark = ImageIO.read(new File(watermarkImagePath));
|
||||
|
||||
int watermarkWidth = watermark.getWidth();
|
||||
int watermarkHeight = watermark.getHeight();
|
||||
|
||||
while (true) {
|
||||
Frame frame = grabber.grabFrame();
|
||||
if (frame == null) {
|
||||
break;
|
||||
}
|
||||
if (frame.imageHeight != 0) {
|
||||
BufferedImage image = converter.convert(frame);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
g2d.drawImage(watermark, 10, 10, watermarkWidth, watermarkHeight, null);
|
||||
g2d.dispose();
|
||||
recorder.record(converter.convert(image));
|
||||
}
|
||||
|
||||
if (frame.samples!= null) {
|
||||
recorder.record(frame);
|
||||
}
|
||||
}
|
||||
|
||||
grabber.stop();
|
||||
recorder.stop();
|
||||
}
|
||||
|
||||
private static FFmpegFrameRecorder getfFmpegFrameRecorder(String outputVideoPath, FFmpegFrameGrabber grabber) throws FFmpegFrameRecorder.Exception {
|
||||
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputVideoPath, grabber.getImageWidth(), grabber.getImageHeight());
|
||||
recorder.setVideoCodec(grabber.getVideoCodec());
|
||||
recorder.setVideoBitrate(grabber.getVideoBitrate());
|
||||
recorder.setFormat(grabber.getFormat());
|
||||
recorder.setFrameRate(grabber.getFrameRate());
|
||||
// 设置音频参数,使其与原始视频相同
|
||||
recorder.setAudioChannels(grabber.getAudioChannels());
|
||||
recorder.setAudioCodec(grabber.getAudioCodec());
|
||||
recorder.setSampleRate(grabber.getSampleRate());
|
||||
recorder.start();
|
||||
|
||||
return recorder;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
addWatermarkToVideo("D:\\radio\\fire.mp4","D:\\radio\\water1.JPG","D:\\radio\\w1.mp4");
|
||||
}catch (Exception e){
|
||||
System.out.println(e);
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("代码执行时间为:" + (endTime - startTime)/1000 + "秒");
|
||||
}
|
||||
}
|
||||
83
src/main/resources/application.yaml
Normal file
83
src/main/resources/application.yaml
Normal file
@ -0,0 +1,83 @@
|
||||
server:
|
||||
port: 8081
|
||||
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
# 设置单个文件大小
|
||||
max-file-size: 10MB
|
||||
# 设置总请求的最大大小
|
||||
max-request-size: 10MB
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
url: jdbc:mysql://45.207.192.237/kunming_cheap_food?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
||||
username: root
|
||||
password: mysql_4DBzGc
|
||||
# druid 连接池管理
|
||||
druid:
|
||||
# 初始化时建立物理连接的个数
|
||||
initial-size: 5
|
||||
# 连接池的最小空闲数量
|
||||
min-idle: 5
|
||||
# 连接池最大连接数量
|
||||
max-active: 20
|
||||
# 获取连接时最大等待时间,单位毫秒
|
||||
max-wait: 60000
|
||||
# 申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
|
||||
test-while-idle: true
|
||||
# 既作为检测的间隔时间又作为testWhileIdel执行的依据
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 销毁线程时检测当前连接的最后活动时间和当前时间差大于该值时,关闭当前连接(配置连接在池中的最小生存时间)
|
||||
min-evictable-idle-time-millis: 30000
|
||||
# 用来检测数据库连接是否有效的sql 必须是一个查询语句(oracle中为 select 1 from dual)
|
||||
validation-query: select 'x'
|
||||
# 申请连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为true
|
||||
test-on-borrow: false
|
||||
# 归还连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为true
|
||||
test-on-return: false
|
||||
# 是否缓存preparedStatement, 也就是PSCache,PSCache对支持游标的数据库性能提升巨大,比如说oracle,在mysql下建议关闭。
|
||||
pool-prepared-statements: false
|
||||
# 置监控统计拦截的filters,去掉后监控界面sql无法统计,stat: 监控统计、Slf4j:日志记录、waLL: 防御sqL注入
|
||||
filters: stat,wall,slf4j
|
||||
# 要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100
|
||||
max-pool-prepared-statement-per-connection-size: -1
|
||||
# 合并多个DruidDataSource的监控数据
|
||||
use-global-data-source-stat: true
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
web-stat-filter:
|
||||
# 是否启用StatFilter默认值true
|
||||
enabled: true
|
||||
# 添加过滤规则
|
||||
url-pattern: /*
|
||||
# 忽略过滤的格式
|
||||
exclusions: /druid/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico
|
||||
|
||||
stat-view-servlet:
|
||||
# 是否启用StatViewServlet默认值true
|
||||
enabled: true
|
||||
# 访问路径为/druid时,跳转到StatViewServlet
|
||||
url-pattern: /druid/*
|
||||
# 是否能够重置数据
|
||||
reset-enable: false
|
||||
# 需要账号密码才能访问控制台,默认为root
|
||||
login-username: druid
|
||||
login-password: druid
|
||||
# IP白名单
|
||||
allow: 127.0.0.1
|
||||
# IP黑名单(共同存在时,deny优先于allow)
|
||||
deny:
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
data:
|
||||
redis:
|
||||
host: 45.207.192.237
|
||||
port: 56987
|
||||
password: redis_EC6pCs
|
||||
timeout: 30000 #连接超时时间(毫秒)
|
||||
jedis:
|
||||
pool:
|
||||
max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
|
||||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
max-idle: 10 # 连接池中的最大空闲连接
|
||||
min-idle: 0 # 连接池中的最小空闲连接
|
||||
30
src/main/resources/mapper/KmArticleCommentMapper.xml
Normal file
30
src/main/resources/mapper/KmArticleCommentMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmArticleCommentMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmArticleComment">
|
||||
<id property="id" column="ID" jdbcType="VARCHAR"/>
|
||||
<result property="fansId" column="FANS_ID" jdbcType="VARCHAR"/>
|
||||
<result property="commentId" column="COMMENT_ID" jdbcType="VARCHAR"/>
|
||||
<result property="articleId" column="ARTICLE_ID" jdbcType="VARCHAR"/>
|
||||
<result property="authorId" column="AUTHOR_ID" jdbcType="VARCHAR"/>
|
||||
<result property="commentText" column="COMMENT_TEXT" jdbcType="VARCHAR"/>
|
||||
<result property="point" column="POINT" jdbcType="FLOAT"/>
|
||||
<result property="isFirst" column="IS_FIRST" jdbcType="TINYINT"/>
|
||||
<result property="isHide" column="IS_HIDE" jdbcType="TINYINT"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,FANS_ID,COMMENT_ID,
|
||||
ARTICLE_ID,AUTHOR_ID,COMMENT_TEXT,
|
||||
POINT,IS_FIRST,IS_HIDE,
|
||||
CREATED_BY,CREATED_TIME,UPDATED_BY,
|
||||
UPDATED_TIME
|
||||
</sql>
|
||||
</mapper>
|
||||
30
src/main/resources/mapper/KmArticleDetailsMapper.xml
Normal file
30
src/main/resources/mapper/KmArticleDetailsMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmArticleDetailsMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmArticleDetails">
|
||||
<id property="id" column="ID" jdbcType="INTEGER"/>
|
||||
<result property="articleDetailsId" column="ARTICLE_DETAILS_ID" jdbcType="INTEGER"/>
|
||||
<result property="articleId" column="ARTICLE_ID" jdbcType="INTEGER"/>
|
||||
<result property="foodName" column="FOOD_NAME" jdbcType="VARCHAR"/>
|
||||
<result property="price" column="PRICE" jdbcType="FLOAT"/>
|
||||
<result property="address" column="ADDRESS" jdbcType="VARCHAR"/>
|
||||
<result property="restaurant" column="RESTAURANT" jdbcType="VARCHAR"/>
|
||||
<result property="phoneNumber" column="PHONE_NUMBER" jdbcType="VARCHAR"/>
|
||||
<result property="businessHours" column="BUSINESS_HOURS" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,ARTICLE_DETAILS_ID,ARTICLE_ID,
|
||||
FOOD_NAME,PRICE,ADDRESS,
|
||||
RESTAURANT,PHONE_NUMBER,BUSINESS_HOURS,
|
||||
CREATED_TIME,CREATED_BY,UPDATED_TIME,
|
||||
UPDATED_BY
|
||||
</sql>
|
||||
</mapper>
|
||||
32
src/main/resources/mapper/KmArticleMapper.xml
Normal file
32
src/main/resources/mapper/KmArticleMapper.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmArticleMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmArticle">
|
||||
<id property="id" column="ID" jdbcType="VARCHAR"/>
|
||||
<result property="articleId" column="ARTICLE_ID" jdbcType="VARCHAR"/>
|
||||
<result property="articleTitle" column="ARTICLE_TITLE" jdbcType="VARCHAR"/>
|
||||
<result property="articleIntroduce" column="ARTICLE_INTRODUCE" jdbcType="VARCHAR"/>
|
||||
<result property="articleAuthor" column="ARTICLE_AUTHOR" jdbcType="VARCHAR"/>
|
||||
<result property="articlePicture" column="ARTICLE_PICTURE" jdbcType="VARCHAR"/>
|
||||
<result property="articleText" column="ARTICLE_TEXT" jdbcType="VARCHAR"/>
|
||||
<result property="isFirst" column="IS_FIRST" jdbcType="TINYINT"/>
|
||||
<result property="isHide" column="IS_HIDE" jdbcType="TINYINT"/>
|
||||
<result property="regionalClassification" column="REGIONAL_CLASSIFICATION" jdbcType="VARCHAR"/>
|
||||
<result property="foodClassification" column="FOOD_CLASSIFICATION" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,ARTICLE_ID,ARTICLE_TITLE,
|
||||
ARTICLE_INTRODUCE,ARTICLE_AUTHOR,ARTICLE_PICTURE,
|
||||
ARTICLE_TEXT,IS_FIRST,IS_HIDE,
|
||||
REGIONAL_CLASSIFICATION,FOOD_CLASSIFICATION,CREATED_TIME,
|
||||
CREATED_BY,UPDATED_TIME,UPDATED_BY
|
||||
</sql>
|
||||
</mapper>
|
||||
24
src/main/resources/mapper/KmFansMapper.xml
Normal file
24
src/main/resources/mapper/KmFansMapper.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmFansMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmFans">
|
||||
<id property="id" column="ID" jdbcType="INTEGER"/>
|
||||
<result property="wxId" column="WX_ID" jdbcType="INTEGER"/>
|
||||
<result property="wxUsername" column="WX_USERNAME" jdbcType="VARCHAR"/>
|
||||
<result property="wxPicture" column="WX_PICTURE" jdbcType="VARCHAR"/>
|
||||
<result property="wxAddress" column="WX_ADDRESS" jdbcType="VARCHAR"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,WX_ID,WX_USERNAME,
|
||||
WX_PICTURE,WX_ADDRESS,CREATED_BY,
|
||||
CREATED_TIME,UPDATED_BY,UPDATED_TIME
|
||||
</sql>
|
||||
</mapper>
|
||||
26
src/main/resources/mapper/KmSystemStaffMapper.xml
Normal file
26
src/main/resources/mapper/KmSystemStaffMapper.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmSystemStaffMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmSystemStaff">
|
||||
<id property="id" column="ID" jdbcType="VARCHAR"/>
|
||||
<result property="userId" column="USER_ID" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="USER_NAME" jdbcType="VARCHAR"/>
|
||||
<result property="phoneNumber" column="PHONE_NUMBER" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="PASSWORD" jdbcType="VARCHAR"/>
|
||||
<result property="charactar" column="CHARACTAR" jdbcType="VARCHAR"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,USER_ID,USER_NAME,
|
||||
PHONE_NUMBER,PASSWORD,CHARACTAR,
|
||||
CREATED_BY,CREATED_TIME,UPDATED_BY,
|
||||
UPDATED_TIME
|
||||
</sql>
|
||||
</mapper>
|
||||
23
src/main/resources/mapper/KmSystemStaffRoleMapper.xml
Normal file
23
src/main/resources/mapper/KmSystemStaffRoleMapper.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?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.aqroid.dataprocess.generator.mapper.KmSystemStaffRoleMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.aqroid.dataprocess.generator.domain.KmSystemStaffRole">
|
||||
<id property="id" column="ID" jdbcType="VARCHAR"/>
|
||||
<result property="charactarId" column="CHARACTAR_ID" jdbcType="VARCHAR"/>
|
||||
<result property="charactarName" column="CHARACTAR_NAME" jdbcType="VARCHAR"/>
|
||||
<result property="hasUsed" column="HAS_USED" jdbcType="TINYINT"/>
|
||||
<result property="createdTime" column="CREATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="createdBy" column="CREATED_BY" jdbcType="VARCHAR"/>
|
||||
<result property="updatedTime" column="UPDATED_TIME" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedBy" column="UPDATED_BY" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
ID,CHARACTAR_ID,CHARACTAR_NAME,
|
||||
HAS_USED,CREATED_TIME,CREATED_BY,
|
||||
UPDATED_TIME,UPDATED_BY
|
||||
</sql>
|
||||
</mapper>
|
||||
@ -0,0 +1,13 @@
|
||||
package com.aqroid.dataprocess;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DataProcessApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user