From f1c3d209f7e1e2b891aa4151a978b2670bf17e59 Mon Sep 17 00:00:00 2001 From: ni ziyi <310925901@qq.com> Date: Fri, 4 Apr 2025 14:15:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98=E5=92=8C=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 + .gitignore | 33 +++ .mvn/wrapper/maven-wrapper.properties | 19 ++ mvnw | 259 ++++++++++++++++++ mvnw.cmd | 149 ++++++++++ pom.xml | 179 ++++++++++++ .../dataprocess/DataProcessApplication.java | 13 + .../dataprocess/auth/annotation/Username.java | 15 + .../auth/controller/AuthenticationAdvice.java | 28 ++ .../controller/PasswordLoginController.java | 41 +++ .../auth/controller/req/KmSystemStaffReq.java | 14 + .../dataprocess/auth/dto/LoginUser.java | 62 +++++ .../filter/JwtAuthenticationEntryPoint.java | 26 ++ .../dataprocess/auth/filter/TokenFilter.java | 79 ++++++ .../auth/service/impl/LoginService.java | 93 +++++++ .../service/impl/UserDetailServiceImpl.java | 47 ++++ .../dataprocess/cache/RedisCacheOperator.java | 118 ++++++++ .../dataprocess/config/AppSecurityConfig.java | 67 +++++ .../config/CacheConfiguration.java | 122 +++++++++ .../dataprocess/config/KaptchaConfig.java | 41 +++ .../dataprocess/config/MybatisPlusConfig.java | 26 ++ .../dataprocess/config/RedisConfig.java | 47 ++++ .../aqroid/dataprocess/config/WebConfig.java | 20 ++ .../constants/BuildInRoleGroup.java | 61 +++++ .../aqroid/dataprocess/constants/Module.java | 41 +++ .../dataprocess/constants/ModuleAction.java | 48 ++++ .../controller/ArticleCommentController.java | 17 ++ .../controller/ArticleController.java | 28 ++ .../controller/FileUploadController.java | 52 ++++ .../controller/SystemStaffController.java | 7 + .../controller/TestController.java | 10 + .../exception/BusinessException.java | 24 ++ .../dataprocess/exception/ExceptionEnum.java | 88 ++++++ .../exception/GlobalExceptionHandler.java | 100 +++++++ .../generator/domain/KmArticle.java | 173 ++++++++++++ .../generator/domain/KmArticleComment.java | 157 +++++++++++ .../generator/domain/KmArticleDetails.java | 157 +++++++++++ .../dataprocess/generator/domain/KmFans.java | 125 +++++++++ .../generator/domain/KmSystemStaff.java | 135 +++++++++ .../generator/domain/KmSystemStaffRole.java | 117 ++++++++ .../mapper/KmArticleCommentMapper.java | 21 ++ .../mapper/KmArticleDetailsMapper.java | 21 ++ .../generator/mapper/KmArticleMapper.java | 21 ++ .../generator/mapper/KmFansMapper.java | 21 ++ .../generator/mapper/KmSystemStaffMapper.java | 21 ++ .../mapper/KmSystemStaffRoleMapper.java | 21 ++ .../service/KmArticleCommentService.java | 13 + .../service/KmArticleDetailsService.java | 13 + .../generator/service/KmArticleService.java | 13 + .../generator/service/KmFansService.java | 13 + .../service/KmSystemStaffRoleService.java | 13 + .../service/KmSystemStaffService.java | 21 ++ .../impl/KmArticleCommentServiceImpl.java | 23 ++ .../impl/KmArticleDetailsServiceImpl.java | 23 ++ .../service/impl/KmArticleServiceImpl.java | 23 ++ .../service/impl/KmFansServiceImpl.java | 23 ++ .../impl/KmSystemStaffRoleServiceImpl.java | 23 ++ .../impl/KmSystemStaffServiceImpl.java | 41 +++ .../mybatisPlus/POJOConverter.java | 52 ++++ .../mybatisPlus/dto/KmArticleCommentDto.java | 74 +++++ .../mybatisPlus/dto/KmArticleDetailsDto.java | 74 +++++ .../mybatisPlus/dto/KmArticleDto.java | 85 ++++++ .../mybatisPlus/dto/KmFansDto.java | 53 ++++ .../mybatisPlus/dto/KmSystemStaffDto.java | 63 +++++ .../mybatisPlus/dto/KmSystemStaffRoleDto.java | 52 ++++ .../dto/converter/KmSystemStaffConverter.java | 67 +++++ .../converter/KmSystemStaffRoleConverter.java | 39 +++ .../dataprocess/token/DefaultTokenCodec.java | 30 ++ .../dataprocess/token/codec/TokenCodec.java | 27 ++ .../token/impl/CaffeineTokenCodec.java | 90 ++++++ .../dataprocess/utils/CommonResult.java | 51 ++++ .../dataprocess/utils/ConvertUtils.java | 52 ++++ .../aqroid/dataprocess/utils/DateUtils.java | 18 ++ .../aqroid/dataprocess/utils/DcodeUtils.java | 64 +++++ .../com/aqroid/dataprocess/utils/IDUtils.java | 9 + .../dataprocess/utils/JwtTokenUtils.java | 133 +++++++++ .../aqroid/dataprocess/utils/RadioFile.java | 103 +++++++ src/main/resources/application.yaml | 83 ++++++ .../mapper/KmArticleCommentMapper.xml | 30 ++ .../mapper/KmArticleDetailsMapper.xml | 30 ++ src/main/resources/mapper/KmArticleMapper.xml | 32 +++ src/main/resources/mapper/KmFansMapper.xml | 24 ++ .../resources/mapper/KmSystemStaffMapper.xml | 26 ++ .../mapper/KmSystemStaffRoleMapper.xml | 23 ++ .../DataProcessApplicationTests.java | 13 + 85 files changed, 4605 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/aqroid/dataprocess/DataProcessApplication.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/annotation/Username.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/controller/AuthenticationAdvice.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/controller/PasswordLoginController.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/controller/req/KmSystemStaffReq.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/filter/JwtAuthenticationEntryPoint.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/filter/TokenFilter.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/service/impl/LoginService.java create mode 100644 src/main/java/com/aqroid/dataprocess/auth/service/impl/UserDetailServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/AppSecurityConfig.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/CacheConfiguration.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/KaptchaConfig.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/MybatisPlusConfig.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/RedisConfig.java create mode 100644 src/main/java/com/aqroid/dataprocess/config/WebConfig.java create mode 100644 src/main/java/com/aqroid/dataprocess/constants/BuildInRoleGroup.java create mode 100644 src/main/java/com/aqroid/dataprocess/constants/Module.java create mode 100644 src/main/java/com/aqroid/dataprocess/constants/ModuleAction.java create mode 100644 src/main/java/com/aqroid/dataprocess/controller/ArticleCommentController.java create mode 100644 src/main/java/com/aqroid/dataprocess/controller/ArticleController.java create mode 100644 src/main/java/com/aqroid/dataprocess/controller/FileUploadController.java create mode 100644 src/main/java/com/aqroid/dataprocess/controller/SystemStaffController.java create mode 100644 src/main/java/com/aqroid/dataprocess/controller/TestController.java create mode 100644 src/main/java/com/aqroid/dataprocess/exception/BusinessException.java create mode 100644 src/main/java/com/aqroid/dataprocess/exception/ExceptionEnum.java create mode 100644 src/main/java/com/aqroid/dataprocess/exception/GlobalExceptionHandler.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmArticle.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleComment.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleDetails.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmFans.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaff.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaffRole.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleCommentMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleDetailsMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmFansMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffRoleMapper.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmArticleCommentService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmArticleDetailsService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmArticleService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmFansService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffRoleService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffService.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleCommentServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleDetailsServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmFansServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffRoleServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffServiceImpl.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/POJOConverter.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleCommentDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDetailsDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmFansDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffRoleDto.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffConverter.java create mode 100644 src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffRoleConverter.java create mode 100644 src/main/java/com/aqroid/dataprocess/token/DefaultTokenCodec.java create mode 100644 src/main/java/com/aqroid/dataprocess/token/codec/TokenCodec.java create mode 100644 src/main/java/com/aqroid/dataprocess/token/impl/CaffeineTokenCodec.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/CommonResult.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/DateUtils.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/IDUtils.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java create mode 100644 src/main/java/com/aqroid/dataprocess/utils/RadioFile.java create mode 100644 src/main/resources/application.yaml create mode 100644 src/main/resources/mapper/KmArticleCommentMapper.xml create mode 100644 src/main/resources/mapper/KmArticleDetailsMapper.xml create mode 100644 src/main/resources/mapper/KmArticleMapper.xml create mode 100644 src/main/resources/mapper/KmFansMapper.xml create mode 100644 src/main/resources/mapper/KmSystemStaffMapper.xml create mode 100644 src/main/resources/mapper/KmSystemStaffRoleMapper.xml create mode 100644 src/test/java/com/aqroid/dataprocess/DataProcessApplicationTests.java diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d58dfb7 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -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 diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/mvnw @@ -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-,maven-mvnd--}/ +[ -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 "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..249bdf3 --- /dev/null +++ b/mvnw.cmd @@ -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-,maven-mvnd--}/ +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" diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3fdc3a9 --- /dev/null +++ b/pom.xml @@ -0,0 +1,179 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.5 + + + cn.aqroid + gang_qiang_data_process + 0.0.1 + gang_qiang_data_process + gang_qiang_data_process + + + + + + + + + + + + + + + 17 + + + + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + + + + + org.bytedeco + javacv + 1.5.11 + + + + + org.bytedeco + ffmpeg-platform + 7.1-1.5.11 + + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + + com.alibaba + fastjson + 2.0.41 + + + + com.alibaba + druid-spring-boot-3-starter + 1.2.20 + + + + com.github.penggle + kaptcha + 2.3.2 + + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + + + + io.jsonwebtoken + jjwt + 0.9.1 + + + + + cn.hutool + hutool-all + 5.8.25 + + + + + + com.google.guava + guava + 33.3.1-jre + + + + + commons-io + commons-io + 2.8.0 + + + + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.7 + + + + + com.github.ben-manes.caffeine + caffeine + 2.9.2 + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/com/aqroid/dataprocess/DataProcessApplication.java b/src/main/java/com/aqroid/dataprocess/DataProcessApplication.java new file mode 100644 index 0000000..ded9935 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/DataProcessApplication.java @@ -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); + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/annotation/Username.java b/src/main/java/com/aqroid/dataprocess/auth/annotation/Username.java new file mode 100644 index 0000000..da61c93 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/annotation/Username.java @@ -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 { +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/controller/AuthenticationAdvice.java b/src/main/java/com/aqroid/dataprocess/auth/controller/AuthenticationAdvice.java new file mode 100644 index 0000000..5dd6263 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/controller/AuthenticationAdvice.java @@ -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()); + + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/controller/PasswordLoginController.java b/src/main/java/com/aqroid/dataprocess/auth/controller/PasswordLoginController.java new file mode 100644 index 0000000..90f66fa --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/controller/PasswordLoginController.java @@ -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 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 getUserinfo(@ModelAttribute KmSystemStaffDto handleStaff){ + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + return CommonResult.successResult((KmSystemStaffDto) authentication.getPrincipal()); + } + + @GetMapping("/login/getDcode") + public CommonResult getDcode(@ModelAttribute KmSystemStaffDto handleStaff){ + return CommonResult.successResult(loginService.generateDcode()); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/controller/req/KmSystemStaffReq.java b/src/main/java/com/aqroid/dataprocess/auth/controller/req/KmSystemStaffReq.java new file mode 100644 index 0000000..81c0c61 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/controller/req/KmSystemStaffReq.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java b/src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java new file mode 100644 index 0000000..3b58b17 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/dto/LoginUser.java @@ -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 authority; + + @Override + public Collection 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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/filter/JwtAuthenticationEntryPoint.java b/src/main/java/com/aqroid/dataprocess/auth/filter/JwtAuthenticationEntryPoint.java new file mode 100644 index 0000000..7d1ec66 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/filter/JwtAuthenticationEntryPoint.java @@ -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, "没有凭证"); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/filter/TokenFilter.java b/src/main/java/com/aqroid/dataprocess/auth/filter/TokenFilter.java new file mode 100644 index 0000000..aa3c3ab --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/filter/TokenFilter.java @@ -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 authorities = JSONObject.parseArray(claims.get(JwtTokenUtils.KEY_AUTHORITIES, String.class), SimpleGrantedAuthority.class); + + + //将校验信息放到上下文中 + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken( + userDto, + null, + authorities + )); + } + filterChain.doFilter(request, response); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/service/impl/LoginService.java b/src/main/java/com/aqroid/dataprocess/auth/service/impl/LoginService.java new file mode 100644 index 0000000..498515e --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/service/impl/LoginService.java @@ -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 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 kaptchaVoMap = new HashMap<>(); + kaptchaVoMap.put("uuid", uuid); + kaptchaVoMap.put("code", "data:image/png;base64," + base64Code); + return kaptchaVoMap; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/auth/service/impl/UserDetailServiceImpl.java b/src/main/java/com/aqroid/dataprocess/auth/service/impl/UserDetailServiceImpl.java new file mode 100644 index 0000000..1ab3eb7 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/auth/service/impl/UserDetailServiceImpl.java @@ -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 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 authorities = staffService.getAuthorities(dto); + loginUser.setAuthority(authorities); + return loginUser; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java b/src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java new file mode 100644 index 0000000..af607c5 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/cache/RedisCacheOperator.java @@ -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 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 keys) { + redisTemplate.delete(keys); + } + + public Object hGet(String key, String field) { + return redisTemplate.opsForHash().get(key, field); + } + + public Map hGetAll(String key) { + HashOperations hashOperations = redisTemplate.opsForHash(); + return hashOperations.entries(key); + } + + public void hMSet(String key, Map map) { + hMSet(key, map, DEFAULT_EXPIRE); + } + + public void hMSet(String key, Map 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); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/config/AppSecurityConfig.java b/src/main/java/com/aqroid/dataprocess/config/AppSecurityConfig.java new file mode 100644 index 0000000..c6b604f --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/AppSecurityConfig.java @@ -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 { + + @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(); + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/config/CacheConfiguration.java b/src/main/java/com/aqroid/dataprocess/config/CacheConfiguration.java new file mode 100644 index 0000000..632e758 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/CacheConfiguration.java @@ -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 loadingCache = Caffeine.newBuilder() + //初始大小 + .initialCapacity(100) + //最大容量 + .maximumSize(1000) + //缓存写入/删除监控 + .writer(new CacheWriter() { + @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 loadingCache = Caffeine.newBuilder() + //初始大小 + .initialCapacity(100) + //最大容量 + .maximumSize(1000) + //缓存写入/删除监控 + .writer(new CacheWriter() { + @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 loadingCache = Caffeine.newBuilder() + //初始大小 + .initialCapacity(100) + //最大容量 + .maximumSize(1000) + //缓存写入/删除监控 + .writer(new CacheWriter() { + @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 loadingCache = Caffeine.newBuilder() + //初始大小 + .initialCapacity(100) + //最大容量 + .maximumSize(1000) + //缓存写入/删除监控 + .writer(new CacheWriter() { + @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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/config/KaptchaConfig.java b/src/main/java/com/aqroid/dataprocess/config/KaptchaConfig.java new file mode 100644 index 0000000..b168557 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/KaptchaConfig.java @@ -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; + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/config/MybatisPlusConfig.java b/src/main/java/com/aqroid/dataprocess/config/MybatisPlusConfig.java new file mode 100644 index 0000000..6d7cfe5 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/MybatisPlusConfig.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/config/RedisConfig.java b/src/main/java/com/aqroid/dataprocess/config/RedisConfig.java new file mode 100644 index 0000000..c51617b --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/RedisConfig.java @@ -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 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 redisTemplate() { + RedisTemplate 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; + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/config/WebConfig.java b/src/main/java/com/aqroid/dataprocess/config/WebConfig.java new file mode 100644 index 0000000..8c0babe --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/config/WebConfig.java @@ -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("*"); + } +} + diff --git a/src/main/java/com/aqroid/dataprocess/constants/BuildInRoleGroup.java b/src/main/java/com/aqroid/dataprocess/constants/BuildInRoleGroup.java new file mode 100644 index 0000000..f0ef7e0 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/constants/BuildInRoleGroup.java @@ -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> roleMap; + + BuildInRoleGroup(String desc, Map> 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; + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/constants/Module.java b/src/main/java/com/aqroid/dataprocess/constants/Module.java new file mode 100644 index 0000000..22df4ea --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/constants/Module.java @@ -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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/constants/ModuleAction.java b/src/main/java/com/aqroid/dataprocess/constants/ModuleAction.java new file mode 100644 index 0000000..2c6adf4 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/constants/ModuleAction.java @@ -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; + } +} + + diff --git a/src/main/java/com/aqroid/dataprocess/controller/ArticleCommentController.java b/src/main/java/com/aqroid/dataprocess/controller/ArticleCommentController.java new file mode 100644 index 0000000..de57a6a --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/controller/ArticleCommentController.java @@ -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; + + +} diff --git a/src/main/java/com/aqroid/dataprocess/controller/ArticleController.java b/src/main/java/com/aqroid/dataprocess/controller/ArticleController.java new file mode 100644 index 0000000..43c9fa6 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/controller/ArticleController.java @@ -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"); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/controller/FileUploadController.java b/src/main/java/com/aqroid/dataprocess/controller/FileUploadController.java new file mode 100644 index 0000000..5e93f62 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/controller/FileUploadController.java @@ -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); + } + } +} diff --git a/src/main/java/com/aqroid/dataprocess/controller/SystemStaffController.java b/src/main/java/com/aqroid/dataprocess/controller/SystemStaffController.java new file mode 100644 index 0000000..3e64014 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/controller/SystemStaffController.java @@ -0,0 +1,7 @@ +package com.aqroid.dataprocess.controller; + +/** + * ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ + */ +public class SystemStaffController { +} diff --git a/src/main/java/com/aqroid/dataprocess/controller/TestController.java b/src/main/java/com/aqroid/dataprocess/controller/TestController.java new file mode 100644 index 0000000..d6ae189 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/controller/TestController.java @@ -0,0 +1,10 @@ +package com.aqroid.dataprocess.controller; + +import org.springframework.web.bind.annotation.RestController; + +/** + * ฅ(๑ ̀ㅅ ́๑)ฅ这里是阿强ฅ(๑ ̀ㅅ ́๑)ฅ + */ +@RestController +public class TestController { +} diff --git a/src/main/java/com/aqroid/dataprocess/exception/BusinessException.java b/src/main/java/com/aqroid/dataprocess/exception/BusinessException.java new file mode 100644 index 0000000..3002c16 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/exception/BusinessException.java @@ -0,0 +1,24 @@ +package com.aqroid.dataprocess.exception; + + +import lombok.Getter; + +/** + *

业务异常

+ *

业务处理时,出现异常,可以抛出该异常

+ */ +@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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/exception/ExceptionEnum.java b/src/main/java/com/aqroid/dataprocess/exception/ExceptionEnum.java new file mode 100644 index 0000000..5481e6d --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/exception/ExceptionEnum.java @@ -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; + +} diff --git a/src/main/java/com/aqroid/dataprocess/exception/GlobalExceptionHandler.java b/src/main/java/com/aqroid/dataprocess/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..83e1c40 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/exception/GlobalExceptionHandler.java @@ -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; + } + + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticle.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticle.java new file mode 100644 index 0000000..218407c --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticle.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleComment.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleComment.java new file mode 100644 index 0000000..7c80770 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleComment.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleDetails.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleDetails.java new file mode 100644 index 0000000..7a0ecb1 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmArticleDetails.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmFans.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmFans.java new file mode 100644 index 0000000..77c119b --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmFans.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaff.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaff.java new file mode 100644 index 0000000..6e8d141 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaff.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaffRole.java b/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaffRole.java new file mode 100644 index 0000000..96764cb --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/domain/KmSystemStaffRole.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleCommentMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleCommentMapper.java new file mode 100644 index 0000000..c11558f --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleCommentMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleDetailsMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleDetailsMapper.java new file mode 100644 index 0000000..6f411b6 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleDetailsMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleMapper.java new file mode 100644 index 0000000..f31b2c7 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmArticleMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmFansMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmFansMapper.java new file mode 100644 index 0000000..568ac91 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmFansMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffMapper.java new file mode 100644 index 0000000..7cd6561 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffRoleMapper.java b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffRoleMapper.java new file mode 100644 index 0000000..e401741 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/mapper/KmSystemStaffRoleMapper.java @@ -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 { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleCommentService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleCommentService.java new file mode 100644 index 0000000..6652189 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleCommentService.java @@ -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 { + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleDetailsService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleDetailsService.java new file mode 100644 index 0000000..0b6c845 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleDetailsService.java @@ -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 { + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleService.java new file mode 100644 index 0000000..8769840 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmArticleService.java @@ -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 { + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmFansService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmFansService.java new file mode 100644 index 0000000..270dda2 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmFansService.java @@ -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 { + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffRoleService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffRoleService.java new file mode 100644 index 0000000..2951f1f --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffRoleService.java @@ -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 { + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffService.java b/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffService.java new file mode 100644 index 0000000..87af92c --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/KmSystemStaffService.java @@ -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 { + + List getAuthorities(KmSystemStaffDto dto); + + +} diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleCommentServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleCommentServiceImpl.java new file mode 100644 index 0000000..a393f18 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleCommentServiceImpl.java @@ -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 + implements KmArticleCommentService { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleDetailsServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleDetailsServiceImpl.java new file mode 100644 index 0000000..b9d973f --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleDetailsServiceImpl.java @@ -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 + implements KmArticleDetailsService { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleServiceImpl.java new file mode 100644 index 0000000..0403dfa --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmArticleServiceImpl.java @@ -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 + implements KmArticleService { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmFansServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmFansServiceImpl.java new file mode 100644 index 0000000..8c6451d --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmFansServiceImpl.java @@ -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 + implements KmFansService { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffRoleServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffRoleServiceImpl.java new file mode 100644 index 0000000..6a67138 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffRoleServiceImpl.java @@ -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 + implements KmSystemStaffRoleService { + +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffServiceImpl.java b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffServiceImpl.java new file mode 100644 index 0000000..c811196 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/generator/service/impl/KmSystemStaffServiceImpl.java @@ -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 + implements KmSystemStaffService { + + + @Override + public List getAuthorities(KmSystemStaffDto dto) { + BuildInRoleGroup roleGroup = BuildInRoleGroup.getByName(dto.getCharactar().getCharactarName()); + + ArrayList list = new ArrayList<>(); + roleGroup.roleMap.forEach((key, value) -> { + value.forEach(moduleAction -> { + list.add(new SimpleGrantedAuthority(key.name+"|"+moduleAction.name)); + }); + }); + return list; + } +} + + + + diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/POJOConverter.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/POJOConverter.java new file mode 100644 index 0000000..391ed82 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/POJOConverter.java @@ -0,0 +1,52 @@ +package com.aqroid.dataprocess.mybatisPlus; + +import java.lang.reflect.ParameterizedType; + +/** + * 对象转换器 + * + * @param do + * @param dto + */ +public abstract class POJOConverter { + + Class dClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; + Class tClass = (Class) ((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); + +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleCommentDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleCommentDto.java new file mode 100644 index 0000000..9be1223 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleCommentDto.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDetailsDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDetailsDto.java new file mode 100644 index 0000000..d436e63 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDetailsDto.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDto.java new file mode 100644 index 0000000..cfc6a93 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmArticleDto.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmFansDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmFansDto.java new file mode 100644 index 0000000..8e5c5a9 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmFansDto.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffDto.java new file mode 100644 index 0000000..c9837e3 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffDto.java @@ -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; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffRoleDto.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffRoleDto.java new file mode 100644 index 0000000..a013676 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/KmSystemStaffRoleDto.java @@ -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 authorityList; +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffConverter.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffConverter.java new file mode 100644 index 0000000..c8a8722 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffConverter.java @@ -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 { + + @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 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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffRoleConverter.java b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffRoleConverter.java new file mode 100644 index 0000000..6304d70 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/mybatisPlus/dto/converter/KmSystemStaffRoleConverter.java @@ -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 { + @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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/token/DefaultTokenCodec.java b/src/main/java/com/aqroid/dataprocess/token/DefaultTokenCodec.java new file mode 100644 index 0000000..a205113 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/token/DefaultTokenCodec.java @@ -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; + } +} diff --git a/src/main/java/com/aqroid/dataprocess/token/codec/TokenCodec.java b/src/main/java/com/aqroid/dataprocess/token/codec/TokenCodec.java new file mode 100644 index 0000000..2d8e5cb --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/token/codec/TokenCodec.java @@ -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); + +} diff --git a/src/main/java/com/aqroid/dataprocess/token/impl/CaffeineTokenCodec.java b/src/main/java/com/aqroid/dataprocess/token/impl/CaffeineTokenCodec.java new file mode 100644 index 0000000..8bc49c5 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/token/impl/CaffeineTokenCodec.java @@ -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); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/CommonResult.java b/src/main/java/com/aqroid/dataprocess/utils/CommonResult.java new file mode 100644 index 0000000..d39ded0 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/CommonResult.java @@ -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 { + + private int stateCode = 200; + private String errorCode = "0"; + private String message; + private T data; + + /** + * 成功 + * + * @param data 成功返回数据 + */ + public static CommonResult successResult(T data) { + return new CommonResult<>(200, "0", "", data); + } + + /** + * 失败返回 + * + * @param stateCode http状态码 + * @param errorCode 业务失败码 + * @param message 错误信息 + */ + public static CommonResult failResult(int stateCode, String errorCode, String message) { + return new CommonResult<>(stateCode, errorCode, message, null); + } + + /** + * 失败返回重写-AuthenticationException + * + * @param exception 权限错误 + */ + public static CommonResult failResult(BusinessException exception) { + return new CommonResult<>(401, exception.getExceptionEnum().getErrorCode(), exception.getExceptionEnum().getMessage(), null); + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java b/src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java new file mode 100644 index 0000000..36874e9 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/ConvertUtils.java @@ -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 sourceToTarget(Object source, Class 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 List sourceToTarget(Collection sourceList, Class 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; + } +} \ No newline at end of file diff --git a/src/main/java/com/aqroid/dataprocess/utils/DateUtils.java b/src/main/java/com/aqroid/dataprocess/utils/DateUtils.java new file mode 100644 index 0000000..37bb4f0 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/DateUtils.java @@ -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()); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java b/src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java new file mode 100644 index 0000000..b0e03ea --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/DcodeUtils.java @@ -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); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/IDUtils.java b/src/main/java/com/aqroid/dataprocess/utils/IDUtils.java new file mode 100644 index 0000000..1e8865e --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/IDUtils.java @@ -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("-", ""); + } +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java b/src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java new file mode 100644 index 0000000..cea183e --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/JwtTokenUtils.java @@ -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 String generateToken(LoginUser customUserDetails) { + HashMap 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 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 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 + * @return + */ + public static T getClaimFromToken(String token, Function 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(); + } + +} diff --git a/src/main/java/com/aqroid/dataprocess/utils/RadioFile.java b/src/main/java/com/aqroid/dataprocess/utils/RadioFile.java new file mode 100644 index 0000000..fded944 --- /dev/null +++ b/src/main/java/com/aqroid/dataprocess/utils/RadioFile.java @@ -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 + "秒"); + } +} \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..eef24af --- /dev/null +++ b/src/main/resources/application.yaml @@ -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 # 连接池中的最小空闲连接 diff --git a/src/main/resources/mapper/KmArticleCommentMapper.xml b/src/main/resources/mapper/KmArticleCommentMapper.xml new file mode 100644 index 0000000..673329d --- /dev/null +++ b/src/main/resources/mapper/KmArticleCommentMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + ID,FANS_ID,COMMENT_ID, + ARTICLE_ID,AUTHOR_ID,COMMENT_TEXT, + POINT,IS_FIRST,IS_HIDE, + CREATED_BY,CREATED_TIME,UPDATED_BY, + UPDATED_TIME + + diff --git a/src/main/resources/mapper/KmArticleDetailsMapper.xml b/src/main/resources/mapper/KmArticleDetailsMapper.xml new file mode 100644 index 0000000..72158dd --- /dev/null +++ b/src/main/resources/mapper/KmArticleDetailsMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + ID,ARTICLE_DETAILS_ID,ARTICLE_ID, + FOOD_NAME,PRICE,ADDRESS, + RESTAURANT,PHONE_NUMBER,BUSINESS_HOURS, + CREATED_TIME,CREATED_BY,UPDATED_TIME, + UPDATED_BY + + diff --git a/src/main/resources/mapper/KmArticleMapper.xml b/src/main/resources/mapper/KmArticleMapper.xml new file mode 100644 index 0000000..d7fd109 --- /dev/null +++ b/src/main/resources/mapper/KmArticleMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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 + + diff --git a/src/main/resources/mapper/KmFansMapper.xml b/src/main/resources/mapper/KmFansMapper.xml new file mode 100644 index 0000000..bfa4706 --- /dev/null +++ b/src/main/resources/mapper/KmFansMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + ID,WX_ID,WX_USERNAME, + WX_PICTURE,WX_ADDRESS,CREATED_BY, + CREATED_TIME,UPDATED_BY,UPDATED_TIME + + diff --git a/src/main/resources/mapper/KmSystemStaffMapper.xml b/src/main/resources/mapper/KmSystemStaffMapper.xml new file mode 100644 index 0000000..9761042 --- /dev/null +++ b/src/main/resources/mapper/KmSystemStaffMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + ID,USER_ID,USER_NAME, + PHONE_NUMBER,PASSWORD,CHARACTAR, + CREATED_BY,CREATED_TIME,UPDATED_BY, + UPDATED_TIME + + diff --git a/src/main/resources/mapper/KmSystemStaffRoleMapper.xml b/src/main/resources/mapper/KmSystemStaffRoleMapper.xml new file mode 100644 index 0000000..8c3a2c4 --- /dev/null +++ b/src/main/resources/mapper/KmSystemStaffRoleMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + ID,CHARACTAR_ID,CHARACTAR_NAME, + HAS_USED,CREATED_TIME,CREATED_BY, + UPDATED_TIME,UPDATED_BY + + diff --git a/src/test/java/com/aqroid/dataprocess/DataProcessApplicationTests.java b/src/test/java/com/aqroid/dataprocess/DataProcessApplicationTests.java new file mode 100644 index 0000000..d3aa513 --- /dev/null +++ b/src/test/java/com/aqroid/dataprocess/DataProcessApplicationTests.java @@ -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() { + } + +}