From b5c832cd948246ef456bbe2594a88c1e2cbd0810 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Mon, 8 Apr 2024 16:26:51 +0800 Subject: [PATCH 01/59] =?UTF-8?q?ADD:=20=E9=A1=B9=E7=9B=AE=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/.gitignore | 33 ++ .../Share-X/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 62547 bytes .../.mvn/wrapper/maven-wrapper.properties | 2 + back-end/Share-X/mvnw | 308 ++++++++++++++++++ back-end/Share-X/mvnw.cmd | 205 ++++++++++++ back-end/Share-X/pom.xml | 74 +++++ .../web/project/sharex/ShareXApplication.java | 13 + .../src/main/resources/application.yml | 10 + .../sharex/ShareXApplicationTests.java | 13 + 9 files changed, 658 insertions(+) create mode 100644 back-end/Share-X/.gitignore create mode 100644 back-end/Share-X/.mvn/wrapper/maven-wrapper.jar create mode 100644 back-end/Share-X/.mvn/wrapper/maven-wrapper.properties create mode 100644 back-end/Share-X/mvnw create mode 100644 back-end/Share-X/mvnw.cmd create mode 100644 back-end/Share-X/pom.xml create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/ShareXApplication.java create mode 100644 back-end/Share-X/src/main/resources/application.yml create mode 100644 back-end/Share-X/src/test/java/web/project/sharex/ShareXApplicationTests.java diff --git a/back-end/Share-X/.gitignore b/back-end/Share-X/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/back-end/Share-X/.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/back-end/Share-X/.mvn/wrapper/maven-wrapper.jar b/back-end/Share-X/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..cb28b0e37c7d206feb564310fdeec0927af4123a GIT binary patch literal 62547 zcmb5V1CS=sk~Z9!wr$(CZEL#U=Co~N+O}=mwr$(Cds^S@-Tij=#=rmlVk@E|Dyp8$ z$UKz?`Q$l@GN3=8fq)=^fVx`E)Pern1@-q?PE1vZPD);!LGdpP^)C$aAFx&{CzjH` zpQV9;fd0PyFPNN=yp*_@iYmRFcvOrKbU!1a*o)t$0ex(~3z5?bw11HQYW_uDngyer za60w&wz^`W&Z!0XSH^cLNR&k>%)Vr|$}(wfBzmSbuK^)dy#xr@_NZVszJASn12dw; z-KbI5yz=2awY0>OUF)&crfPu&tVl|!>g*#ur@K=$@8N05<_Mldg}X`N6O<~3|Dpk3 zRWb!e7z<{Mr96 z^C{%ROigEIapRGbFA5g4XoQAe_Y1ii3Ci!KV`?$ zZ2Hy1VP#hVp>OOqe~m|lo@^276Ik<~*6eRSOe;$wn_0@St#cJy}qI#RP= zHVMXyFYYX%T_k3MNbtOX{<*_6Htq*o|7~MkS|A|A|8AqKl!%zTirAJGz;R<3&F7_N z)uC9$9K1M-)g0#}tnM(lO2k~W&4xT7gshgZ1-y2Yo-q9Li7%zguh7W#kGfnjo7Cl6 z!^wTtP392HU0aVB!$cPHjdK}yi7xNMp+KVZy3_u}+lBCloJ&C?#NE@y$_{Uv83*iV zhDOcv`=|CiyQ5)C4fghUmxmwBP0fvuR>aV`bZ3{Q4&6-(M@5sHt0M(}WetqItGB1C zCU-)_n-VD;(6T1%0(@6%U`UgUwgJCCdXvI#f%79Elbg4^yucgfW1^ zNF!|C39SaXsqU9kIimX0vZ`U29)>O|Kfs*hXBXC;Cs9_Zos3%8lu)JGm~c19+j8Va z)~kFfHouwMbfRH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/.mvn/wrapper/maven-wrapper.properties b/back-end/Share-X/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..5f0536e --- /dev/null +++ b/back-end/Share-X/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/back-end/Share-X/mvnw b/back-end/Share-X/mvnw new file mode 100644 index 0000000..66df285 --- /dev/null +++ b/back-end/Share-X/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/back-end/Share-X/mvnw.cmd b/back-end/Share-X/mvnw.cmd new file mode 100644 index 0000000..95ba6f5 --- /dev/null +++ b/back-end/Share-X/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml new file mode 100644 index 0000000..71265d9 --- /dev/null +++ b/back-end/Share-X/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.4 + + + web.project + Share-X + 0.0.1-SNAPSHOT + Share-X + Share-X + + 17 + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/back-end/Share-X/src/main/java/web/project/sharex/ShareXApplication.java b/back-end/Share-X/src/main/java/web/project/sharex/ShareXApplication.java new file mode 100644 index 0000000..d8ce127 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/ShareXApplication.java @@ -0,0 +1,13 @@ +package web.project.sharex; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ShareXApplication { + + public static void main(String[] args) { + SpringApplication.run(ShareXApplication.class, args); + } + +} diff --git a/back-end/Share-X/src/main/resources/application.yml b/back-end/Share-X/src/main/resources/application.yml new file mode 100644 index 0000000..312a7c3 --- /dev/null +++ b/back-end/Share-X/src/main/resources/application.yml @@ -0,0 +1,10 @@ + +spring: + application: + name: Share-X + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://8.130.23.148:3306/web_project + username: fsy + password: 300227QWEqwe! \ No newline at end of file diff --git a/back-end/Share-X/src/test/java/web/project/sharex/ShareXApplicationTests.java b/back-end/Share-X/src/test/java/web/project/sharex/ShareXApplicationTests.java new file mode 100644 index 0000000..489d26b --- /dev/null +++ b/back-end/Share-X/src/test/java/web/project/sharex/ShareXApplicationTests.java @@ -0,0 +1,13 @@ +package web.project.sharex; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ShareXApplicationTests { + + @Test + void contextLoads() { + } + +} -- Gitee From 2bf57c3762551f9f49a306406e4296072378930b Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Mon, 8 Apr 2024 16:47:38 +0800 Subject: [PATCH 02/59] ADD: UniversalResponse --- back-end/Share-X/pom.xml | 5 ++++ .../util/response/UniversalResponse.java | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/response/UniversalResponse.java diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml index 71265d9..5d896b7 100644 --- a/back-end/Share-X/pom.xml +++ b/back-end/Share-X/pom.xml @@ -52,6 +52,11 @@ spring-boot-starter-test test + + com.auth0 + java-jwt + 3.14.0 + diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/response/UniversalResponse.java b/back-end/Share-X/src/main/java/web/project/sharex/util/response/UniversalResponse.java new file mode 100644 index 0000000..43ca16c --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/response/UniversalResponse.java @@ -0,0 +1,30 @@ +package web.project.sharex.util.response; + +import lombok.Data; + +@Data +public class UniversalResponse { + + + private Integer code; + + private String msg; + + private T data; + + public UniversalResponse() { + + } + + public UniversalResponse(Integer code, String msg) { + this.code = code; + this.msg = msg; + this.data = null; + } + + public UniversalResponse(Integer code, String msg, T data) { + this.code = code; + this.msg = msg; + this.data = data; + } +} \ No newline at end of file -- Gitee From 5fa011f050d8c45ce57c17853cd8e9096ea3d4bc Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Mon, 8 Apr 2024 16:52:36 +0800 Subject: [PATCH 03/59] =?UTF-8?q?ADD:=20JWT=E5=9F=BA=E6=9C=AC=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/annotation/IgnoreToken.java | 11 ++++ .../sharex/config/InterceptorConfig.java | 24 ++++++++ .../sharex/controller/indexController.java | 19 ++++++ .../sharex/interceptor/JWTInterceptor.java | 58 +++++++++++++++++++ .../java/web/project/sharex/util/JWTUtil.java | 55 ++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/annotation/IgnoreToken.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/config/InterceptorConfig.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/interceptor/JWTInterceptor.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/annotation/IgnoreToken.java b/back-end/Share-X/src/main/java/web/project/sharex/annotation/IgnoreToken.java new file mode 100644 index 0000000..a2db99d --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/annotation/IgnoreToken.java @@ -0,0 +1,11 @@ +package web.project.sharex.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(value = {ElementType.METHOD, ElementType.TYPE}) +public @interface IgnoreToken { +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/config/InterceptorConfig.java b/back-end/Share-X/src/main/java/web/project/sharex/config/InterceptorConfig.java new file mode 100644 index 0000000..7d5fed6 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/config/InterceptorConfig.java @@ -0,0 +1,24 @@ +package web.project.sharex.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import web.project.sharex.interceptor.JWTInterceptor; + +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(this.jwtInterceptor()) +// .addPathPatterns("/user/test") // 其他接口token验证 +// .excludePathPatterns("/user/login"); // 所有用户都放行 + .addPathPatterns("/**"); + } + + @Bean + public JWTInterceptor jwtInterceptor() { + return new JWTInterceptor(); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java new file mode 100644 index 0000000..92460e4 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java @@ -0,0 +1,19 @@ +package web.project.sharex.controller; + + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.util.response.UniversalResponse; + +@RestController +@RequestMapping("/test") +public class indexController { + + @IgnoreToken + @GetMapping("/hello") + UniversalResponse hello() { + return new UniversalResponse<>(1000, "success"); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/interceptor/JWTInterceptor.java b/back-end/Share-X/src/main/java/web/project/sharex/interceptor/JWTInterceptor.java new file mode 100644 index 0000000..f6dc65e --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/interceptor/JWTInterceptor.java @@ -0,0 +1,58 @@ +package web.project.sharex.interceptor; + +import com.auth0.jwt.exceptions.AlgorithmMismatchException; +import com.auth0.jwt.exceptions.SignatureVerificationException; +import com.auth0.jwt.exceptions.TokenExpiredException; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; +import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.util.JWTUtil; + +import java.util.HashMap; +import java.util.Map; + +public class JWTInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + if(handler instanceof HandlerMethod) + { + HandlerMethod handlerMethod = (HandlerMethod) handler; + // 检验是否有注解 + if (handlerMethod.hasMethodAnnotation(IgnoreToken.class)) { + return true; // 放行 + } + } + + Map map = new HashMap<>(); + // 获取请求头中令牌 + String token = request.getHeader("token"); + try { + // 验证令牌 + JWTUtil.verify(token); + return true; // 放行请求 + + } catch (SignatureVerificationException e) { + e.printStackTrace(); + map.put("msg","无效签名!"); + }catch (TokenExpiredException e){ + e.printStackTrace(); + map.put("msg","token过期"); + }catch (AlgorithmMismatchException e){ + e.printStackTrace(); + map.put("msg","算法不一致"); + }catch (Exception e){ + e.printStackTrace(); + map.put("msg","token无效!"); + } + map.put("state",false); // 设置状态 + // 将map以json的形式响应到前台 map --> json (jackson) + String json = new ObjectMapper().writeValueAsString(map); + response.setContentType("application/json;charset=UTF-8"); + response.getWriter().println(json); + return false; + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java new file mode 100644 index 0000000..9477014 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java @@ -0,0 +1,55 @@ +package web.project.sharex.util; + + +import org.springframework.stereotype.Component; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.auth0.jwt.algorithms.Algorithm; + +import java.util.Calendar; +import java.util.Map; + +@Component +public class JWTUtil { + +// @Resource +// private AdminMapper adminMapper; +// +// private static AdminMapper staticAdminMapper; +// +// @PostConstruct +// private void InitStaticAdminDao() { +// staticAdminMapper = adminMapper; +// } + + private static final String SING = "XIAOSHUANG"; + + public static String getToken(Map map) { + + Calendar instance = Calendar.getInstance(); + // 默认1天过期 + instance.add(Calendar.DATE, 1); + + //创建jwt builder + JWTCreator.Builder builder = JWT.create(); + + // payload + map.forEach(builder::withClaim); + return builder.withExpiresAt(instance.getTime()) //指定令牌过期时间 + .sign(Algorithm.HMAC256(SING)); + } + + public static DecodedJWT verify(String token) { + return JWT.require(Algorithm.HMAC256(SING)).build().verify(token); + } + +// public static Admin getCurrentAdmin() { +// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); +// String token = request.getHeader("token"); +// if (Strings.isNotBlank(token)) { +// return staticAdminMapper.getAdminById(JWT.decode(token).getClaim("id").asString()); +// } +// throw new RuntimeException("token error"); +// } +} \ No newline at end of file -- Gitee From 2773f7db8c0ff7a0653fd262f772aa9150ca73e4 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Mon, 8 Apr 2024 17:30:50 +0800 Subject: [PATCH 04/59] =?UTF-8?q?ADD:=20=E9=83=A8=E5=88=86=E4=B8=BB?= =?UTF-8?q?=E8=A6=81=E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=8Emapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/pom.xml | 16 ++++++ .../project/sharex/mapper/ArticleMapper.java | 16 ++++++ .../project/sharex/mapper/PhotoMapper.java | 16 ++++++ .../web/project/sharex/mapper/TagMapper.java | 16 ++++++ .../web/project/sharex/mapper/UserMapper.java | 16 ++++++ .../project/sharex/pojo/entity/Article.java | 57 +++++++++++++++++++ .../web/project/sharex/pojo/entity/Photo.java | 44 ++++++++++++++ .../web/project/sharex/pojo/entity/Tag.java | 41 +++++++++++++ .../web/project/sharex/pojo/entity/User.java | 56 ++++++++++++++++++ .../main/resources/mapper/ArticleMapper.xml | 5 ++ .../src/main/resources/mapper/PhotoMapper.xml | 5 ++ .../src/main/resources/mapper/TagMapper.xml | 5 ++ .../src/main/resources/mapper/UserMapper.xml | 5 ++ 13 files changed, 298 insertions(+) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Article.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Tag.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/User.java create mode 100644 back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml create mode 100644 back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml create mode 100644 back-end/Share-X/src/main/resources/mapper/TagMapper.xml create mode 100644 back-end/Share-X/src/main/resources/mapper/UserMapper.xml diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml index 5d896b7..ffbe788 100644 --- a/back-end/Share-X/pom.xml +++ b/back-end/Share-X/pom.xml @@ -57,6 +57,22 @@ java-jwt 3.14.0 + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java new file mode 100644 index 0000000..f575ad4 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -0,0 +1,16 @@ +package web.project.sharex.mapper; + +import web.project.sharex.pojo.entity.Article; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 文章信息表 Mapper 接口 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +public interface ArticleMapper extends BaseMapper
{ + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java new file mode 100644 index 0000000..fd2df88 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java @@ -0,0 +1,16 @@ +package web.project.sharex.mapper; + +import web.project.sharex.pojo.entity.Photo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 图片信息表 Mapper 接口 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +public interface PhotoMapper extends BaseMapper { + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java new file mode 100644 index 0000000..5bd4692 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java @@ -0,0 +1,16 @@ +package web.project.sharex.mapper; + +import web.project.sharex.pojo.entity.Tag; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * tag信息表 Mapper 接口 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +public interface TagMapper extends BaseMapper { + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java new file mode 100644 index 0000000..b105901 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -0,0 +1,16 @@ +package web.project.sharex.mapper; + +import web.project.sharex.pojo.entity.User; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 用户信息表 Mapper 接口 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +public interface UserMapper extends BaseMapper { + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Article.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Article.java new file mode 100644 index 0000000..2bbf19f --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Article.java @@ -0,0 +1,57 @@ +package web.project.sharex.pojo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; + +import java.io.Serial; +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 文章信息表 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("tb_article") +@ApiModel(value="TbArticle对象", description="文章信息表") +public class Article implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "文章id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "作者id") + private Integer author; + + @ApiModelProperty(value = "文章标题") + private String title; + + @ApiModelProperty(value = "文章正文") + private String text; + + @ApiModelProperty(value = "文章状态") + private Integer status; + + @ApiModelProperty(value = "文章发表时间") + private LocalDateTime publishTime; + + @ApiModelProperty(value = "审批时的额外信息") + private String additionalInfo; + + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java new file mode 100644 index 0000000..50e3d1e --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java @@ -0,0 +1,44 @@ +package web.project.sharex.pojo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; + +import java.io.Serial; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 图片信息表 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("tb_photo") +@ApiModel(value="TbPhoto对象", description="图片信息表") +public class Photo implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "图片id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "图片路径") + private String path; + + @ApiModelProperty(value = "引用文章编号") + private Integer reference; + + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Tag.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Tag.java new file mode 100644 index 0000000..b527e8d --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Tag.java @@ -0,0 +1,41 @@ +package web.project.sharex.pojo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; + +import java.io.Serial; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * tag信息表 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("tb_tag") +@ApiModel(value="TbTag对象", description="tag信息表") +public class Tag implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "tag id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "tag名称") + private String name; + + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/User.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/User.java new file mode 100644 index 0000000..14f467b --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/User.java @@ -0,0 +1,56 @@ +package web.project.sharex.pojo.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; + +import java.io.Serial; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 用户信息表 + *

+ * + * @author XenoWYC121 + * @since 2024-04-08 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("tb_user") +@ApiModel(value="TbUser对象", description="用户信息表") +public class User implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "用户账号") + private String account; + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户密码") + private String password; + + @ApiModelProperty(value = "用户邮箱") + private String email; + + @ApiModelProperty(value = "用户类型") + private Integer type; + + @ApiModelProperty(value = "用户头像路径") + private String profilePhoto; + + +} diff --git a/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml b/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml new file mode 100644 index 0000000..a31993e --- /dev/null +++ b/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml b/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml new file mode 100644 index 0000000..25fa49c --- /dev/null +++ b/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/back-end/Share-X/src/main/resources/mapper/TagMapper.xml b/back-end/Share-X/src/main/resources/mapper/TagMapper.xml new file mode 100644 index 0000000..9d23a46 --- /dev/null +++ b/back-end/Share-X/src/main/resources/mapper/TagMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/back-end/Share-X/src/main/resources/mapper/UserMapper.xml b/back-end/Share-X/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..b76a225 --- /dev/null +++ b/back-end/Share-X/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,5 @@ + + + + + -- Gitee From 91b4019d868513b446daa4bdb2a9a7b425175cda Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 10 Apr 2024 21:04:45 +0800 Subject: [PATCH 05/59] =?UTF-8?q?ADD:=E5=9F=BA=E6=9C=AC=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/pom.xml | 9 ++++- .../sharex/controller/indexController.java | 20 ++++++++-- .../web/project/sharex/mapper/UserMapper.java | 6 +++ .../project/sharex/service/IndexService.java | 8 ++++ .../sharex/service/impl/IndexServiceImpl.java | 37 +++++++++++++++++++ .../sharex/util/enums/ResponseEnum.java | 24 ++++++++++++ .../sharex/util/enums/UserTypeEnum.java | 18 +++++++++ .../main/resources/mapper/ArticleMapper.xml | 5 --- .../src/main/resources/mapper/PhotoMapper.xml | 5 --- .../src/main/resources/mapper/TagMapper.xml | 5 --- .../src/main/resources/mapper/UserMapper.xml | 5 --- 11 files changed, 116 insertions(+), 26 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/enums/UserTypeEnum.java delete mode 100644 back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml delete mode 100644 back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml delete mode 100644 back-end/Share-X/src/main/resources/mapper/TagMapper.xml delete mode 100644 back-end/Share-X/src/main/resources/mapper/UserMapper.xml diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml index ffbe788..d4b83d5 100644 --- a/back-end/Share-X/pom.xml +++ b/back-end/Share-X/pom.xml @@ -57,6 +57,11 @@ java-jwt 3.14.0 + + org.mybatis + mybatis-spring + 3.0.3 + com.baomidou mybatis-plus-boot-starter @@ -65,12 +70,12 @@ io.springfox springfox-swagger2 - 2.9.2 + 2.10.5 io.springfox springfox-swagger-ui - 2.9.2 + 2.10.5 diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java index 92460e4..f661c91 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java @@ -1,19 +1,31 @@ package web.project.sharex.controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.*; import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.service.IndexService; import web.project.sharex.util.response.UniversalResponse; @RestController -@RequestMapping("/test") +@RequestMapping("/") public class indexController { + @Resource + IndexService indexService; + @IgnoreToken @GetMapping("/hello") UniversalResponse hello() { return new UniversalResponse<>(1000, "success"); } + + @IgnoreToken + @PostMapping("/user/sign_up") + UniversalResponse signUp(@RequestParam String nickname, + @RequestParam String account, + @RequestParam String password, + @RequestParam String email) { + return indexService.signUp(nickname, account, password, email); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index b105901..d13ecca 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -1,5 +1,7 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -11,6 +13,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author XenoWYC121 * @since 2024-04-08 */ +@Mapper public interface UserMapper extends BaseMapper { + @Select("select * from tb_user where account = '${account}'") + User getUserByAccount(String account); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java new file mode 100644 index 0000000..ebe3939 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java @@ -0,0 +1,8 @@ +package web.project.sharex.service; + +import web.project.sharex.util.response.UniversalResponse; + +public interface IndexService { + UniversalResponse signUp(String nickName, String account, String password, String email); + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java new file mode 100644 index 0000000..b3d0974 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java @@ -0,0 +1,37 @@ +package web.project.sharex.service.impl; + +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.User; +import web.project.sharex.service.IndexService; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.enums.UserTypeEnum; +import web.project.sharex.util.response.UniversalResponse; + +@Service +public class IndexServiceImpl implements IndexService { + + @Resource + UserMapper userMapper; + + @Override + public UniversalResponse signUp(String nickName, String account, String password, String email) { + User user = userMapper.getUserByAccount(account); + if (user != null) { + ResponseEnum res = ResponseEnum.USER_ALREADY_EXISTS; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + User newUser = new User(); + newUser.setAccount(account); + newUser.setNickname(nickName); + newUser.setPassword(password); + newUser.setEmail(email); + newUser.setType(UserTypeEnum.REGULAR_USER.getTypeCode()); + //等待之后修改路径 + newUser.setProfilePhoto("/default/path"); + userMapper.insert(newUser); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java new file mode 100644 index 0000000..a6e739f --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -0,0 +1,24 @@ +package web.project.sharex.util.enums; + +import lombok.Getter; + +@Getter +public enum ResponseEnum { + + SUCCESS(1000, "success"), + FAILED(1001, "错误"), + + + //注册相关错误 + + USER_ALREADY_EXISTS(2001, "用户已存在"); + + private final Integer code; + private final String msg; + + ResponseEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/UserTypeEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/UserTypeEnum.java new file mode 100644 index 0000000..235f544 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/UserTypeEnum.java @@ -0,0 +1,18 @@ +package web.project.sharex.util.enums; + +public enum UserTypeEnum { + + ADMIN(1), + REGULAR_USER(2); + + + private final Integer type; + + UserTypeEnum(Integer value) { + type = value; + } + + public Integer getTypeCode() { + return type; + } +} diff --git a/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml b/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml deleted file mode 100644 index a31993e..0000000 --- a/back-end/Share-X/src/main/resources/mapper/ArticleMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml b/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml deleted file mode 100644 index 25fa49c..0000000 --- a/back-end/Share-X/src/main/resources/mapper/PhotoMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/back-end/Share-X/src/main/resources/mapper/TagMapper.xml b/back-end/Share-X/src/main/resources/mapper/TagMapper.xml deleted file mode 100644 index 9d23a46..0000000 --- a/back-end/Share-X/src/main/resources/mapper/TagMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/back-end/Share-X/src/main/resources/mapper/UserMapper.xml b/back-end/Share-X/src/main/resources/mapper/UserMapper.xml deleted file mode 100644 index b76a225..0000000 --- a/back-end/Share-X/src/main/resources/mapper/UserMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - -- Gitee From 266650c6e04f3e037894764e7c30234ad9e41396 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 10 Apr 2024 21:32:26 +0800 Subject: [PATCH 06/59] =?UTF-8?q?ADD:=E5=9F=BA=E6=9C=AC=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/indexController.java | 8 ++++ .../web/project/sharex/pojo/res/TokenRes.java | 17 ++++++++ .../project/sharex/service/IndexService.java | 3 ++ .../sharex/service/impl/IndexServiceImpl.java | 28 +++++++++++++ .../java/web/project/sharex/util/JWTUtil.java | 42 +++++++++++-------- .../sharex/util/enums/ResponseEnum.java | 9 +++- 6 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java index f661c91..11b9703 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java @@ -4,6 +4,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.pojo.res.TokenRes; import web.project.sharex.service.IndexService; import web.project.sharex.util.response.UniversalResponse; @@ -28,4 +29,11 @@ public class indexController { @RequestParam String email) { return indexService.signUp(nickname, account, password, email); } + + @IgnoreToken + @PostMapping("/user/sign_in") + UniversalResponse signIn(@RequestParam String account, + @RequestParam String password) { + return indexService.signIn(account, password); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java new file mode 100644 index 0000000..814f24f --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java @@ -0,0 +1,17 @@ +package web.project.sharex.pojo.res; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class TokenRes { + @ApiModelProperty("token") + private String token; + @ApiModelProperty("身份") + private Integer identity; + + public TokenRes(String token, Integer identity) { + this.token = token; + this.identity = identity; + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java index ebe3939..e133e61 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/IndexService.java @@ -1,8 +1,11 @@ package web.project.sharex.service; +import web.project.sharex.pojo.res.TokenRes; import web.project.sharex.util.response.UniversalResponse; public interface IndexService { UniversalResponse signUp(String nickName, String account, String password, String email); + UniversalResponse signIn(String account, String password); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java index b3d0974..de9d961 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java @@ -4,11 +4,15 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.User; +import web.project.sharex.pojo.res.TokenRes; import web.project.sharex.service.IndexService; +import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.enums.UserTypeEnum; import web.project.sharex.util.response.UniversalResponse; +import java.util.HashMap; + @Service public class IndexServiceImpl implements IndexService { @@ -34,4 +38,28 @@ public class IndexServiceImpl implements IndexService { ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg()); } + + @Override + public UniversalResponse signIn(String account, String password) { + User user = userMapper.getUserByAccount(account); + if (user == null) { + ResponseEnum res = ResponseEnum.USER_NOT_EXISTS; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + if (!user.getPassword().equals(password)) { + ResponseEnum res = ResponseEnum.PASSWORD_ERROR; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + HashMap userMap = new HashMap<>(); + userMap.put("account", account); + userMap.put("id", user.getId().toString()); + userMap.put("nickname", user.getNickname()); + userMap.put("identity", user.getType().toString()); + String token = JWTUtil.getToken(userMap); + TokenRes res = new TokenRes(token, user.getType()); + return new UniversalResponse<>( + ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + res); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java index 9477014..a41cb50 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java @@ -1,11 +1,19 @@ package web.project.sharex.util; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletRequest; +import org.apache.logging.log4j.util.Strings; import org.springframework.stereotype.Component; import com.auth0.jwt.JWT; import com.auth0.jwt.JWTCreator; import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.algorithms.Algorithm; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.User; import java.util.Calendar; import java.util.Map; @@ -13,15 +21,15 @@ import java.util.Map; @Component public class JWTUtil { -// @Resource -// private AdminMapper adminMapper; -// -// private static AdminMapper staticAdminMapper; -// -// @PostConstruct -// private void InitStaticAdminDao() { -// staticAdminMapper = adminMapper; -// } + @Resource + private UserMapper userMapper; + + private static UserMapper staticUserMapper; + + @PostConstruct + private void InitStaticAdminDao() { + staticUserMapper = userMapper; + } private static final String SING = "XIAOSHUANG"; @@ -44,12 +52,12 @@ public class JWTUtil { return JWT.require(Algorithm.HMAC256(SING)).build().verify(token); } -// public static Admin getCurrentAdmin() { -// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); -// String token = request.getHeader("token"); -// if (Strings.isNotBlank(token)) { -// return staticAdminMapper.getAdminById(JWT.decode(token).getClaim("id").asString()); -// } -// throw new RuntimeException("token error"); -// } + public static User getCurrentAdmin() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String token = request.getHeader("token"); + if (Strings.isNotBlank(token)) { + return staticUserMapper.selectById(JWT.decode(token).getClaim("id").asString()); + } + throw new RuntimeException("token error"); + } } \ No newline at end of file diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index a6e739f..5adc656 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -8,10 +8,15 @@ public enum ResponseEnum { SUCCESS(1000, "success"), FAILED(1001, "错误"), - //注册相关错误 - USER_ALREADY_EXISTS(2001, "用户已存在"); + USER_ALREADY_EXISTS(2001, "用户已存在"), + + //登录相关错误 + + USER_NOT_EXISTS(2101, "用户不存在"), + + PASSWORD_ERROR(2102, "密码错误"); private final Integer code; private final String msg; -- Gitee From 816eae954e2920c6779a33a51ecabf9341c67d64 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 13 Apr 2024 10:03:44 +0800 Subject: [PATCH 07/59] =?UTF-8?q?ADD:=20=E6=B7=BB=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/pojo/entity/Photo.java | 5 ++++- .../sharex/util/enums/PhotoTypeEnum.java | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/enums/PhotoTypeEnum.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java index 50e3d1e..de938f4 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Photo.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId; import java.io.Serial; import java.io.Serializable; + import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -24,7 +25,7 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("tb_photo") -@ApiModel(value="TbPhoto对象", description="图片信息表") +@ApiModel(value = "TbPhoto对象", description = "图片信息表") public class Photo implements Serializable { @Serial @@ -40,5 +41,7 @@ public class Photo implements Serializable { @ApiModelProperty(value = "引用文章编号") private Integer reference; + @ApiModelProperty(value = "图片类型") + private Integer photoType; } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/PhotoTypeEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/PhotoTypeEnum.java new file mode 100644 index 0000000..a3d6f72 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/PhotoTypeEnum.java @@ -0,0 +1,21 @@ +package web.project.sharex.util.enums; + +public enum PhotoTypeEnum { + + TITLE_PAGE(1), + + ORDINARY(2); + + + private final Integer type; + + PhotoTypeEnum(Integer value) { + type = value; + } + + public Integer getType() { + return type; + } + + +} -- Gitee From ff8b1902e96a45d4ec6b11edd97b6fc45d1e3833 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 13 Apr 2024 10:50:09 +0800 Subject: [PATCH 08/59] =?UTF-8?q?ADD:=20=E7=94=A8=E6=88=B7=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...exController.java => IndexController.java} | 2 +- .../sharex/controller/UserController.java | 31 +++++++++++++++++++ .../web/project/sharex/mapper/UserMapper.java | 17 ++++++++++ .../sharex/pojo/res/ArticleBriefRes.java | 21 +++++++++++++ .../project/sharex/service/UserService.java | 10 ++++++ .../sharex/service/impl/UserServiceImpl.java | 20 ++++++++++++ .../java/web/project/sharex/util/JWTUtil.java | 2 +- 7 files changed, 101 insertions(+), 2 deletions(-) rename back-end/Share-X/src/main/java/web/project/sharex/controller/{indexController.java => IndexController.java} (97%) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBriefRes.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/IndexController.java similarity index 97% rename from back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java rename to back-end/Share-X/src/main/java/web/project/sharex/controller/IndexController.java index 11b9703..f0e3040 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/indexController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/IndexController.java @@ -10,7 +10,7 @@ import web.project.sharex.util.response.UniversalResponse; @RestController @RequestMapping("/") -public class indexController { +public class IndexController { @Resource IndexService indexService; diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java new file mode 100644 index 0000000..c8a44ee --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -0,0 +1,31 @@ +package web.project.sharex.controller; + +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import web.project.sharex.pojo.entity.User; +import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.service.UserService; +import web.project.sharex.util.JWTUtil; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.response.UniversalResponse; + +import java.util.List; + +@RestController +@RequestMapping("/user") +public class UserController { + + @Resource + UserService userService; + + @GetMapping("/history") + UniversalResponse> getUserHistory() { + User current = JWTUtil.getCurrentUser(); + List ret = userService.getUserHistory(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index d13ecca..a171350 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -4,6 +4,9 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import web.project.sharex.pojo.res.ArticleBriefRes; + +import java.util.List; /** *

@@ -19,4 +22,18 @@ public interface UserMapper extends BaseMapper { @Select("select * from tb_user where account = '${account}'") User getUserByAccount(String account); + @Select(""" + select a.id as id, + a.author as author, + a.title as title, + a.status as status, + a.publish_time as publish_time, + (select p.path from tb_photo as p where p.reference = a.id) as cover_photo_path, + th.time as time + from tb_article as a + inner join tb_history th on a.id = th.article_id + where th.user_id = ${ID} + order by time desc;""") + List getUserHistory(Integer ID); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBriefRes.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBriefRes.java new file mode 100644 index 0000000..d2d340e --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBriefRes.java @@ -0,0 +1,21 @@ +package web.project.sharex.pojo.res; + +import lombok.Data; + +@Data +public class ArticleBriefRes { + + private Integer id; + + private Integer author; + + private String title; + + private Integer status; + + private String publishTime; + + private String coverPhotoPath; + + private String time; +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java new file mode 100644 index 0000000..c5bd152 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -0,0 +1,10 @@ +package web.project.sharex.service; + +import web.project.sharex.pojo.res.ArticleBriefRes; + +import java.util.List; + +public interface UserService { + + List getUserHistory(Integer id); +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..e63e256 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -0,0 +1,20 @@ +package web.project.sharex.service.impl; + +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.service.UserService; + +import java.util.List; + +@Service +public class UserServiceImpl implements UserService { + + @Resource + UserMapper userMapper; + @Override + public List getUserHistory(Integer id) { + return userMapper.getUserHistory(id); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java index a41cb50..7d8680c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/JWTUtil.java @@ -52,7 +52,7 @@ public class JWTUtil { return JWT.require(Algorithm.HMAC256(SING)).build().verify(token); } - public static User getCurrentAdmin() { + public static User getCurrentUser() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String token = request.getHeader("token"); if (Strings.isNotBlank(token)) { -- Gitee From fb8f951fd1d2d5d0d8f86341c10ff247e73fb01e Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 13 Apr 2024 11:04:19 +0800 Subject: [PATCH 09/59] =?UTF-8?q?ADD:=20=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=94=B6=E8=97=8F=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/controller/UserController.java | 8 ++++++++ .../java/web/project/sharex/mapper/UserMapper.java | 14 ++++++++++++++ .../web/project/sharex/service/UserService.java | 2 ++ .../sharex/service/impl/UserServiceImpl.java | 5 +++++ 4 files changed, 29 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index c8a44ee..915aff1 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -28,4 +28,12 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); } + @GetMapping("/favorite") + UniversalResponse> getUserFavorite() { + User current = JWTUtil.getCurrentUser(); + List ret = userService.getUserFavorite(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index a171350..5ae98f4 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -36,4 +36,18 @@ public interface UserMapper extends BaseMapper { order by time desc;""") List getUserHistory(Integer ID); + @Select(""" + select a.id as id, + a.author as author, + a.title as title, + a.status as status, + a.publish_time as publish_time, + (select p.path from tb_photo as p where p.reference = a.id) as cover_photo_path, + tf.time as time + from tb_article as a + inner join tb_favorite tf on a.id = tf.article_id + where tf.user_id = 1 + order by tf.time desc;""") + List getUserFavorite(Integer ID); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index c5bd152..2438b31 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -7,4 +7,6 @@ import java.util.List; public interface UserService { List getUserHistory(Integer id); + + List getUserFavorite(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index e63e256..da26960 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -17,4 +17,9 @@ public class UserServiceImpl implements UserService { public List getUserHistory(Integer id) { return userMapper.getUserHistory(id); } + + @Override + public List getUserFavorite(Integer id) { + return userMapper.getUserFavorite(id); + } } -- Gitee From 7347732f2153c9ee5ef0368a4607d35a90a511a8 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 16 Apr 2024 10:51:23 +0800 Subject: [PATCH 10/59] =?UTF-8?q?ADD:=20=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=91=E5=B8=83=E7=9A=84=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 8 ++++++++ .../web/project/sharex/mapper/UserMapper.java | 17 +++++++++++++++-- .../web/project/sharex/service/UserService.java | 2 ++ .../sharex/service/impl/UserServiceImpl.java | 5 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 915aff1..96230da 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -36,4 +36,12 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); } + @GetMapping("/own/articles") + UniversalResponse> getOwnArticles() { + User current = JWTUtil.getCurrentUser(); + List ret = userService.getOwnArticles(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index 5ae98f4..078b379 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -28,7 +28,7 @@ public interface UserMapper extends BaseMapper { a.title as title, a.status as status, a.publish_time as publish_time, - (select p.path from tb_photo as p where p.reference = a.id) as cover_photo_path, + (select p.path from tb_photo as p where p.reference = a.id and p.photo_type = 1) as cover_photo_path, th.time as time from tb_article as a inner join tb_history th on a.id = th.article_id @@ -42,7 +42,7 @@ public interface UserMapper extends BaseMapper { a.title as title, a.status as status, a.publish_time as publish_time, - (select p.path from tb_photo as p where p.reference = a.id) as cover_photo_path, + (select p.path from tb_photo as p where p.reference = a.id and p.photo_type = 1) as cover_photo_path, tf.time as time from tb_article as a inner join tb_favorite tf on a.id = tf.article_id @@ -50,4 +50,17 @@ public interface UserMapper extends BaseMapper { order by tf.time desc;""") List getUserFavorite(Integer ID); + @Select(""" + select a.id as id, + a.author as author, + a.title as title, + a.status as status, + a.publish_time as publish_time, + (select p.path from tb_photo as p where p.reference = a.id and p.photo_type = 1) as cover_photo_path, + a.publish_time as time + from tb_article as a + where a.author = ${ID} + order by a.publish_time desc;""") + List getUserOwnArticles(Integer ID); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 2438b31..3a7a42d 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -9,4 +9,6 @@ public interface UserService { List getUserHistory(Integer id); List getUserFavorite(Integer id); + + List getOwnArticles(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index da26960..428b9ae 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -22,4 +22,9 @@ public class UserServiceImpl implements UserService { public List getUserFavorite(Integer id) { return userMapper.getUserFavorite(id); } + + @Override + public List getOwnArticles(Integer id) { + return userMapper.getUserOwnArticles(id); + } } -- Gitee From 4ee8cd1f10303bde17ef97fa859615fdf313ed2b Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sun, 28 Apr 2024 10:58:56 +0800 Subject: [PATCH 11/59] =?UTF-8?q?ADD:=E9=98=BF=E9=87=8C=E4=BA=91OSS?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/pom.xml | 5 ++++ .../sharex/config/AliyunOSSConfig.java | 26 +++++++++++++++++++ .../main/resources/application-oss.properties | 5 ++++ 3 files changed, 36 insertions(+) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java create mode 100644 back-end/Share-X/src/main/resources/application-oss.properties diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml index d4b83d5..833224e 100644 --- a/back-end/Share-X/pom.xml +++ b/back-end/Share-X/pom.xml @@ -77,6 +77,11 @@ springfox-swagger-ui 2.10.5 + + com.aliyun.oss + aliyun-sdk-oss + 2.8.3 + diff --git a/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java b/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java new file mode 100644 index 0000000..aea2154 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java @@ -0,0 +1,26 @@ +package web.project.sharex.config; + + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClient; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource(value = {"classpath:application-oss.properties"}) +@ConfigurationProperties(prefix = "aliyun") +@Data +public class AliyunOSSConfig { + private String endpoint; + private String accessKeyId; + private String accessKeySecret; + private String bucketName; + private String urlPrefix; + @Bean + public OSS oSSClient(){ + return new OSSClient(endpoint, accessKeyId, accessKeySecret); + } +} diff --git a/back-end/Share-X/src/main/resources/application-oss.properties b/back-end/Share-X/src/main/resources/application-oss.properties new file mode 100644 index 0000000..6f71506 --- /dev/null +++ b/back-end/Share-X/src/main/resources/application-oss.properties @@ -0,0 +1,5 @@ +aliyun.endpoint=oss-cn-wulanchabu.aliyuncs.com +aliyun.accessKeyId=LTAI5tRwhoRZeHsNgZPxaKj8 +aliyun.accessKeySecret=J6Fm7D2PAmD7JAPt7rxujOgHbdkfAX +aliyun.bucketName=web-server-sharex +aliyun.urlPrefix=https://web-server-sharex.oss-cn-wulanchabu.aliyuncs.com/ -- Gitee From ae77d3f856a9f7592df9c714c804177658914d5a Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 1 May 2024 09:54:09 +0800 Subject: [PATCH 12/59] =?UTF-8?q?ADD:=20=E8=8E=B7=E5=8F=96=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 19 +++++++++++++--- .../project/sharex/mapper/ArticleMapper.java | 2 ++ .../project/sharex/service/UserService.java | 3 +++ .../sharex/service/impl/UserServiceImpl.java | 13 ++++++++++- .../sharex/util/enums/ArticleStatusEnum.java | 22 +++++++++++++++++++ .../sharex/util/enums/ResponseEnum.java | 6 ++++- 6 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 96230da..7db675a 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,17 +1,18 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; +import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; import java.util.List; +import java.util.Objects; @RestController @RequestMapping("/user") @@ -44,4 +45,16 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); } + @PostMapping("/get/article") + UniversalResponse

getArticle(@RequestParam Integer id) { + Article article = userService.getArticle(id); + if (Objects.equals(article.getStatus(), ArticleStatusEnum.PASS.getCode())) { + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), article); + } else { + ResponseEnum res = ResponseEnum.ARTICLE_ACCESS_DENIED; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + } + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index f575ad4..845073c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -1,5 +1,6 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Mapper; import web.project.sharex.pojo.entity.Article; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author XenoWYC121 * @since 2024-04-08 */ +@Mapper public interface ArticleMapper extends BaseMapper
{ } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 3a7a42d..06b4578 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,5 +1,6 @@ package web.project.sharex.service; +import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.res.ArticleBriefRes; import java.util.List; @@ -11,4 +12,6 @@ public interface UserService { List getUserFavorite(Integer id); List getOwnArticles(Integer id); + + Article getArticle(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 428b9ae..10aab54 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -2,17 +2,23 @@ package web.project.sharex.service.impl; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; +import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; import java.util.List; @Service -public class UserServiceImpl implements UserService { +public class UserServiceImpl implements UserService { @Resource UserMapper userMapper; + + @Resource + ArticleMapper articleMapper; + @Override public List getUserHistory(Integer id) { return userMapper.getUserHistory(id); @@ -27,4 +33,9 @@ public class UserServiceImpl implements UserService { public List getOwnArticles(Integer id) { return userMapper.getUserOwnArticles(id); } + + @Override + public Article getArticle(Integer id) { + return articleMapper.selectById(id); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java new file mode 100644 index 0000000..dd1309d --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java @@ -0,0 +1,22 @@ +package web.project.sharex.util.enums; + +import lombok.Getter; + +@Getter +public enum ArticleStatusEnum { + + WAITING_FOR_APPROVAL(0), + + PASS(1), + + NOT_PASS(2), + + BAN(3); + + private final Integer code; + + ArticleStatusEnum(Integer value) { + code = value; + } + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 5adc656..fa91f34 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -16,7 +16,11 @@ public enum ResponseEnum { USER_NOT_EXISTS(2101, "用户不存在"), - PASSWORD_ERROR(2102, "密码错误"); + PASSWORD_ERROR(2102, "密码错误"), + + //文章状态错误 + + ARTICLE_ACCESS_DENIED(3001,"文章无法访问"); private final Integer code; private final String msg; -- Gitee From cc6d7c7830cd62fb7d75588142ada0d4a43f2ee5 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 1 May 2024 10:47:31 +0800 Subject: [PATCH 13/59] =?UTF-8?q?ADD:=20=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/pom.xml | 2 +- .../sharex/config/AliyunOSSConfig.java | 26 ------- .../web/project/sharex/config/OSSConfig.java | 25 +++++++ .../sharex/controller/FileController.java | 23 +++++++ .../project/sharex/service/FileService.java | 9 +++ .../sharex/service/impl/FileServiceImpl.java | 67 +++++++++++++++++++ .../sharex/util/enums/ResponseEnum.java | 6 +- .../main/resources/application-oss.properties | 5 -- .../src/main/resources/application.yml | 10 ++- 9 files changed, 139 insertions(+), 34 deletions(-) delete mode 100644 back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/config/OSSConfig.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java delete mode 100644 back-end/Share-X/src/main/resources/application-oss.properties diff --git a/back-end/Share-X/pom.xml b/back-end/Share-X/pom.xml index 833224e..a338258 100644 --- a/back-end/Share-X/pom.xml +++ b/back-end/Share-X/pom.xml @@ -80,7 +80,7 @@ com.aliyun.oss aliyun-sdk-oss - 2.8.3 + 3.16.2 diff --git a/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java b/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java deleted file mode 100644 index aea2154..0000000 --- a/back-end/Share-X/src/main/java/web/project/sharex/config/AliyunOSSConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package web.project.sharex.config; - - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClient; -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(value = {"classpath:application-oss.properties"}) -@ConfigurationProperties(prefix = "aliyun") -@Data -public class AliyunOSSConfig { - private String endpoint; - private String accessKeyId; - private String accessKeySecret; - private String bucketName; - private String urlPrefix; - @Bean - public OSS oSSClient(){ - return new OSSClient(endpoint, accessKeyId, accessKeySecret); - } -} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/config/OSSConfig.java b/back-end/Share-X/src/main/java/web/project/sharex/config/OSSConfig.java new file mode 100644 index 0000000..e2a6fc8 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/config/OSSConfig.java @@ -0,0 +1,25 @@ +package web.project.sharex.config; + + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.io.Serializable; + +@Configuration +@Data +public class OSSConfig implements Serializable { + + @Value("${aliyun.oss.end-point}") + private String endPoint; + + @Value("${aliyun.oss.access-key-id}") + private String accessKeyId; + + @Value("${aliyun.oss.access-key-secret}") + private String accessKeySecret; + + @Value("${aliyun.oss.bucket-name}") + private String bucketName; +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java new file mode 100644 index 0000000..7b8b87a --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java @@ -0,0 +1,23 @@ +package web.project.sharex.controller; + + +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.service.FileService; +import web.project.sharex.util.response.UniversalResponse; + +@RestController +@RequestMapping("/file") +public class FileController { + + @Resource + private FileService fileService; + + @IgnoreToken + @PostMapping("/upload") + public UniversalResponse upload(@RequestParam("file") MultipartFile file) { + return fileService.upload(file); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java new file mode 100644 index 0000000..509165a --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java @@ -0,0 +1,9 @@ +package web.project.sharex.service; + +import org.springframework.web.multipart.MultipartFile; +import web.project.sharex.util.response.UniversalResponse; + +public interface FileService { + + UniversalResponse upload(MultipartFile file); +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java new file mode 100644 index 0000000..269bea8 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -0,0 +1,67 @@ +package web.project.sharex.service.impl; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.PutObjectResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import web.project.sharex.config.OSSConfig; +import web.project.sharex.service.FileService; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.response.UniversalResponse; + +import java.io.IOException; +import java.util.UUID; + +@Service +public class FileServiceImpl implements FileService { + + + @Autowired + private OSSConfig ossConfig; + + @Override + public UniversalResponse upload(MultipartFile file) { + + String bucketName = ossConfig.getBucketName(); + String endPoint = ossConfig.getEndPoint(); + String accessKeyId = ossConfig.getAccessKeyId(); + String accessKeySecret = ossConfig.getAccessKeySecret(); + + //创建OSS对象 + OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret); + + //原生文件名 + String originalFilename = file.getOriginalFilename(); + //扩展名 + String extension; + if (originalFilename != null) { + extension = originalFilename.substring(originalFilename.lastIndexOf(".")); + } else { + throw new RuntimeException(""); + } + String fileName = UUID.randomUUID().toString(); + + //OSS上存储路径 + String uploadFileName = "user/" + fileName + extension; + + ResponseEnum responseEnum; + try { + PutObjectResult result = ossClient.putObject(bucketName, uploadFileName, file.getInputStream()); + if (result != null) { + responseEnum = ResponseEnum.SUCCESS; + System.out.println("https://" + bucketName + "." + endPoint + "/" + uploadFileName); + } else { + responseEnum = ResponseEnum.UPLOAD_ERROR; + + } + + } catch (IOException e) { + responseEnum = ResponseEnum.UPLOAD_ERROR; + } finally { + ossClient.shutdown(); + } + return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg()); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index fa91f34..bf019d5 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -20,7 +20,11 @@ public enum ResponseEnum { //文章状态错误 - ARTICLE_ACCESS_DENIED(3001,"文章无法访问"); + ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), + + //文件错误 + + UPLOAD_ERROR(4001, "文件上传失败"); private final Integer code; private final String msg; diff --git a/back-end/Share-X/src/main/resources/application-oss.properties b/back-end/Share-X/src/main/resources/application-oss.properties deleted file mode 100644 index 6f71506..0000000 --- a/back-end/Share-X/src/main/resources/application-oss.properties +++ /dev/null @@ -1,5 +0,0 @@ -aliyun.endpoint=oss-cn-wulanchabu.aliyuncs.com -aliyun.accessKeyId=LTAI5tRwhoRZeHsNgZPxaKj8 -aliyun.accessKeySecret=J6Fm7D2PAmD7JAPt7rxujOgHbdkfAX -aliyun.bucketName=web-server-sharex -aliyun.urlPrefix=https://web-server-sharex.oss-cn-wulanchabu.aliyuncs.com/ diff --git a/back-end/Share-X/src/main/resources/application.yml b/back-end/Share-X/src/main/resources/application.yml index 312a7c3..8e08fe7 100644 --- a/back-end/Share-X/src/main/resources/application.yml +++ b/back-end/Share-X/src/main/resources/application.yml @@ -7,4 +7,12 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://8.130.23.148:3306/web_project username: fsy - password: 300227QWEqwe! \ No newline at end of file + password: 300227QWEqwe! + + +aliyun: + oss: + end-point: oss-cn-wulanchabu.aliyuncs.com + access-key-id: LTAI5tRwhoRZeHsNgZPxaKj8 + access-key-secret: J6Fm7D2PAmD7JAPt7rxujOgHbdkfAX + bucket-name: web-server-sharex \ No newline at end of file -- Gitee From a2d5fa129f945aeb642bd7f6012373abafee89c8 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 8 May 2024 11:00:15 +0800 Subject: [PATCH 14/59] =?UTF-8?q?ADD:=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/FileController.java | 12 +++-- .../project/sharex/service/FileService.java | 4 +- .../sharex/service/impl/FileServiceImpl.java | 49 ++++++++++++++----- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java index 7b8b87a..9596dce 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java @@ -4,8 +4,10 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import web.project.sharex.annotation.IgnoreToken; +import web.project.sharex.pojo.entity.User; import web.project.sharex.service.FileService; +import web.project.sharex.util.JWTUtil; +import web.project.sharex.util.enums.UserTypeEnum; import web.project.sharex.util.response.UniversalResponse; @RestController @@ -15,9 +17,9 @@ public class FileController { @Resource private FileService fileService; - @IgnoreToken - @PostMapping("/upload") - public UniversalResponse upload(@RequestParam("file") MultipartFile file) { - return fileService.upload(file); + @PostMapping("/upload/profilePhoto") + public UniversalResponse uploadProfilePhoto(@RequestParam("file") MultipartFile file) { + User currentUser = JWTUtil.getCurrentUser(); + return fileService.uploadProfilePhoto(file, currentUser.getId()); } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java index 509165a..6dc7332 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java @@ -5,5 +5,7 @@ import web.project.sharex.util.response.UniversalResponse; public interface FileService { - UniversalResponse upload(MultipartFile file); + String upload(MultipartFile file); + + UniversalResponse uploadProfilePhoto(MultipartFile file, Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java index 269bea8..ca69dde 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import web.project.sharex.config.OSSConfig; +import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.User; import web.project.sharex.service.FileService; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; @@ -21,8 +23,11 @@ public class FileServiceImpl implements FileService { @Autowired private OSSConfig ossConfig; + @Autowired + private UserMapper userMapper; + @Override - public UniversalResponse upload(MultipartFile file) { + public String upload(MultipartFile file) throws RuntimeException { String bucketName = ossConfig.getBucketName(); String endPoint = ossConfig.getEndPoint(); @@ -39,29 +44,51 @@ public class FileServiceImpl implements FileService { if (originalFilename != null) { extension = originalFilename.substring(originalFilename.lastIndexOf(".")); } else { - throw new RuntimeException(""); + throw new RuntimeException("original filename not found"); } String fileName = UUID.randomUUID().toString(); //OSS上存储路径 String uploadFileName = "user/" + fileName + extension; - - ResponseEnum responseEnum; + String resFileName; + //ResponseEnum responseEnum; try { PutObjectResult result = ossClient.putObject(bucketName, uploadFileName, file.getInputStream()); if (result != null) { - responseEnum = ResponseEnum.SUCCESS; - System.out.println("https://" + bucketName + "." + endPoint + "/" + uploadFileName); + //responseEnum = ResponseEnum.SUCCESS; + resFileName = "https://" + bucketName + "." + endPoint + "/" + uploadFileName; } else { - responseEnum = ResponseEnum.UPLOAD_ERROR; - + //responseEnum = ResponseEnum.UPLOAD_ERROR; + throw new RuntimeException("upload error"); } - } catch (IOException e) { - responseEnum = ResponseEnum.UPLOAD_ERROR; + throw new RuntimeException("upload error"); } finally { ossClient.shutdown(); } - return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg()); + return resFileName; + } + + @Override + public UniversalResponse uploadProfilePhoto(MultipartFile file, Integer userId) { + + ResponseEnum resEnum = ResponseEnum.SUCCESS; + String resUrl = ""; + try { + resUrl = upload(file); + } catch (RuntimeException e) { + resEnum = ResponseEnum.UPLOAD_ERROR; + } + if (resEnum == ResponseEnum.UPLOAD_ERROR) { + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); + } + User currentUser = userMapper.selectById(userId); + if (resUrl == null || resUrl.isEmpty()) { + resEnum = ResponseEnum.UPLOAD_ERROR; + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); + } + currentUser.setProfilePhoto(resUrl); + userMapper.updateById(currentUser); + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); } } -- Gitee From 7b3a070a7311a22416834b77da3b79050dafa9fc Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 8 May 2024 11:26:02 +0800 Subject: [PATCH 15/59] =?UTF-8?q?ADD:=E4=B8=8A=E4=BC=A0=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/controller/FileController.java | 9 ++++++++- .../java/web/project/sharex/service/FileService.java | 2 ++ .../web/project/sharex/service/impl/FileServiceImpl.java | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java index 9596dce..8a4dec6 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java @@ -7,7 +7,6 @@ import org.springframework.web.multipart.MultipartFile; import web.project.sharex.pojo.entity.User; import web.project.sharex.service.FileService; import web.project.sharex.util.JWTUtil; -import web.project.sharex.util.enums.UserTypeEnum; import web.project.sharex.util.response.UniversalResponse; @RestController @@ -22,4 +21,12 @@ public class FileController { User currentUser = JWTUtil.getCurrentUser(); return fileService.uploadProfilePhoto(file, currentUser.getId()); } + + @PostMapping("/upload/articlePhoto") + public UniversalResponse uploadArticlePhoto(@RequestParam("file") MultipartFile file, + @RequestParam("articleId") Integer articleId, + @RequestParam("photoType") Integer photoType) { + User currentUser = JWTUtil.getCurrentUser(); + return fileService.uploadArticlePhoto(file, currentUser.getId(), articleId, photoType); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java index 6dc7332..7c0f586 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java @@ -8,4 +8,6 @@ public interface FileService { String upload(MultipartFile file); UniversalResponse uploadProfilePhoto(MultipartFile file, Integer userId); + + UniversalResponse uploadArticlePhoto(MultipartFile file, Integer userId, Integer articleId, Integer photoType); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java index ca69dde..22191ce 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -91,4 +91,9 @@ public class FileServiceImpl implements FileService { userMapper.updateById(currentUser); return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); } + + @Override + public UniversalResponse uploadArticlePhoto(MultipartFile file, Integer userId, Integer articleId, Integer photoType) { + return null; + } } -- Gitee From d40e20ff88402b04356c38e5ff933bfe225170aa Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 8 May 2024 14:07:03 +0800 Subject: [PATCH 16/59] =?UTF-8?q?FIX:=E4=BF=AE=E6=94=B9=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E4=B8=BA?= =?UTF-8?q?20MB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/src/main/resources/application.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/back-end/Share-X/src/main/resources/application.yml b/back-end/Share-X/src/main/resources/application.yml index 8e08fe7..7743c3f 100644 --- a/back-end/Share-X/src/main/resources/application.yml +++ b/back-end/Share-X/src/main/resources/application.yml @@ -3,6 +3,12 @@ spring: application: name: Share-X + servlet: + multipart: + enabled: true + max-file-size: 20MB + max-request-size: 200MB + datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://8.130.23.148:3306/web_project -- Gitee From 91609ceabc4d71b01b54aae92b6306d0accec3b9 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Wed, 8 May 2024 14:07:29 +0800 Subject: [PATCH 17/59] =?UTF-8?q?ADD=EF=BC=9A=E6=96=87=E7=AB=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/mapper/PhotoMapper.java | 10 ++++ .../sharex/service/impl/FileServiceImpl.java | 57 ++++++++++++++++++- .../sharex/util/enums/ResponseEnum.java | 6 +- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java index fd2df88..5e7fa06 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java @@ -1,5 +1,7 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Photo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -11,6 +13,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author XenoWYC121 * @since 2024-04-08 */ +@Mapper public interface PhotoMapper extends BaseMapper { + @Select(""" + select * + from tb_photo as tp + where tp.reference = ${articleId} and + tp.photo_type = 1;""") + Photo getTitlePhoto(Integer articleId); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java index 22191ce..4986571 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -7,9 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import web.project.sharex.config.OSSConfig; +import web.project.sharex.mapper.ArticleMapper; +import web.project.sharex.mapper.PhotoMapper; import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.service.FileService; +import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; @@ -26,6 +31,12 @@ public class FileServiceImpl implements FileService { @Autowired private UserMapper userMapper; + @Autowired + private ArticleMapper articleMapper; + + @Autowired + private PhotoMapper photoMapper; + @Override public String upload(MultipartFile file) throws RuntimeException { @@ -94,6 +105,50 @@ public class FileServiceImpl implements FileService { @Override public UniversalResponse uploadArticlePhoto(MultipartFile file, Integer userId, Integer articleId, Integer photoType) { - return null; + User currentUser = userMapper.selectById(userId); + Article article = articleMapper.selectById(articleId); + if (!article.getAuthor().equals(currentUser.getId())) { + //非法用户 + ResponseEnum resEnum = ResponseEnum.USER_PERMISSION_ERROR; + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); + } + //合法用户,上传文件到oss + String resUrl = ""; + ResponseEnum resEnum = ResponseEnum.SUCCESS; + try { + resUrl = upload(file); + } catch (RuntimeException e) { + resEnum = ResponseEnum.UPLOAD_ERROR; + } + if (resEnum == ResponseEnum.UPLOAD_ERROR) { + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); + } + if (resUrl == null || resUrl.isEmpty()) { + resEnum = ResponseEnum.UPLOAD_ERROR; + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); + } + //上传完成,将图片信息写入数据库 + if (PhotoTypeEnum.TITLE_PAGE.getType().equals(photoType)) { + //上传封面 + Photo photo = photoMapper.getTitlePhoto(articleId); + if (photo == null) { + Photo newPhoto = new Photo(); + newPhoto.setPhotoType(photoType); + newPhoto.setPath(resUrl); + newPhoto.setReference(articleId); + photoMapper.insert(newPhoto); + } else { + photo.setPath(resUrl); + photoMapper.updateById(photo); + } + } else { + //上传普通图片 + Photo newPhoto = new Photo(); + newPhoto.setPhotoType(photoType); + newPhoto.setPath(resUrl); + newPhoto.setReference(articleId); + photoMapper.insert(newPhoto); + } + return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index bf019d5..cbee749 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -24,7 +24,11 @@ public enum ResponseEnum { //文件错误 - UPLOAD_ERROR(4001, "文件上传失败"); + UPLOAD_ERROR(4001, "文件上传失败"), + + //权限错误 + + USER_PERMISSION_ERROR(5001, "用户没有权限"); private final Integer code; private final String msg; -- Gitee From 59c4b0f295208adaf3e195a20bfec6f09677a84c Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Thu, 9 May 2024 19:37:42 +0800 Subject: [PATCH 18/59] =?UTF-8?q?ADD:=E7=AE=A1=E7=90=86=E5=91=98=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/.gitignore | 3 + .../sharex/controller/AdminController.java | 55 +++++++++++++++++++ .../project/sharex/service/AdminService.java | 13 +++++ .../sharex/service/impl/AdminServiceImpl.java | 28 ++++++++++ .../sharex/util/enums/ResponseEnum.java | 2 + 5 files changed, 101 insertions(+) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java diff --git a/back-end/Share-X/.gitignore b/back-end/Share-X/.gitignore index 549e00a..43011b8 100644 --- a/back-end/Share-X/.gitignore +++ b/back-end/Share-X/.gitignore @@ -31,3 +31,6 @@ build/ ### VS Code ### .vscode/ + +### idea +back-end/.idea diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java new file mode 100644 index 0000000..42377c3 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java @@ -0,0 +1,55 @@ +package web.project.sharex.controller; + +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.*; +import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.User; +import web.project.sharex.service.AdminService; +import web.project.sharex.service.UserService; +import web.project.sharex.util.JWTUtil; +import web.project.sharex.util.enums.ArticleStatusEnum; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.enums.UserTypeEnum; +import web.project.sharex.util.response.UniversalResponse; + + + +@RestController +@RequestMapping("/admin") +public class AdminController { + @Resource + AdminService adminService; + @Resource + UserService userService; + @PostMapping("/approve") + UniversalResponse approveArticle(@RequestParam Integer id, @RequestParam Boolean result,@RequestParam String reason){ + User current = JWTUtil.getCurrentUser(); + if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } + Article currentArticle; + currentArticle = adminService.getArticle(id); + if (currentArticle.getStatus().equals(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode())){ + if (result){ + currentArticle.setStatus(ArticleStatusEnum.PASS.getCode()); + adminService.updateArticle(id,currentArticle); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + else { + currentArticle.setStatus(ArticleStatusEnum.NOT_PASS.getCode()); + if(reason.isEmpty()){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getCode(),ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getMsg()); + } + else { + currentArticle.setAdditionalInfo(reason); + adminService.updateArticle(id, currentArticle); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } + } + else { + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_APPROVED.getCode(),ResponseEnum.ARTICLE_ALREADY_APPROVED.getMsg()); + } + } + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java new file mode 100644 index 0000000..72fa89b --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java @@ -0,0 +1,13 @@ +package web.project.sharex.service; + +import web.project.sharex.pojo.entity.Article; + + + + +public interface AdminService { + + Article getArticle(Integer id); + + void updateArticle(Integer id,Article article); +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java new file mode 100644 index 0000000..aa7d02c --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java @@ -0,0 +1,28 @@ +package web.project.sharex.service.impl; + +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import web.project.sharex.mapper.ArticleMapper; +import web.project.sharex.mapper.UserMapper; +import web.project.sharex.pojo.entity.Article; +import web.project.sharex.service.AdminService; + + +@Service +public class AdminServiceImpl implements AdminService { + @Resource + UserMapper userMapper; + + @Resource + ArticleMapper articleMapper; + + public Article getArticle(Integer id) { + return articleMapper.selectById(id); + } + public void updateArticle(Integer id,Article updatedArticle) { + Article oldArticle = articleMapper.selectById(id); + oldArticle.setStatus(updatedArticle.getStatus()); + oldArticle.setAdditionalInfo(updatedArticle.getAdditionalInfo()); + articleMapper.updateById(oldArticle); + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index cbee749..d41f329 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -21,6 +21,8 @@ public enum ResponseEnum { //文章状态错误 ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), + ARTICLE_ALREADY_APPROVED(3002,"文章已经被审核"), + ARTICLE_NOT_PASS_WITHOUT_REASON(3003,"未给出不通过原因"), //文件错误 -- Gitee From 8f08a028759afe355f26ed93b85b442783a69f65 Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Fri, 10 May 2024 14:22:59 +0800 Subject: [PATCH 19/59] =?UTF-8?q?ADD:=E5=B0=81=E7=A6=81=E6=8E=A8=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/AdminController.java | 27 +++++++++++++++++++ .../sharex/util/enums/ResponseEnum.java | 3 +++ 2 files changed, 30 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java index 42377c3..b6bef5d 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java @@ -52,4 +52,31 @@ public class AdminController { } } + @PostMapping("/banArticle") + UniversalResponse banArticle(@RequestParam Integer id,@RequestParam String reason){ + User current = JWTUtil.getCurrentUser(); + if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } + Article currentArticle; + currentArticle = adminService.getArticle(id); + if (currentArticle.getStatus().equals(ArticleStatusEnum.BAN.getCode())){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_BANNED.getCode(),ResponseEnum.ARTICLE_ALREADY_BANNED.getMsg()); + } + else if (currentArticle.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { + if (reason.isEmpty()){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_BAN_WITHOUT_REASON.getCode(), ResponseEnum.ARTICLE_BAN_WITHOUT_REASON.getMsg()); + } + else { + currentArticle.setStatus(ArticleStatusEnum.BAN.getCode()); + currentArticle.setAdditionalInfo(reason); + adminService.updateArticle(id, currentArticle); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } + else { + return new UniversalResponse<>(ResponseEnum.ARTICLE_CANNOT_BAN.getCode(), ResponseEnum.ARTICLE_CANNOT_BAN.getMsg()); + } + } + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index d41f329..7d27a91 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -23,6 +23,9 @@ public enum ResponseEnum { ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), ARTICLE_ALREADY_APPROVED(3002,"文章已经被审核"), ARTICLE_NOT_PASS_WITHOUT_REASON(3003,"未给出不通过原因"), + ARTICLE_ALREADY_BANNED(3004,"文章已经被封禁"), + ARTICLE_CANNOT_BAN(3005,"文章目前不可被封禁"), + ARTICLE_BAN_WITHOUT_REASON(3006,"未给出封禁原因"), //文件错误 -- Gitee From 1382f5c6eb9f4dc5214ba99b665f7960ad3c50ae Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Fri, 10 May 2024 21:36:37 +0800 Subject: [PATCH 20/59] =?UTF-8?q?ADD=EF=BC=9A=E7=94=A8=E6=88=B7=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/web/project/sharex/controller/UserController.java | 1 + .../main/java/web/project/sharex/mapper/ArticleMapper.java | 3 +++ .../main/java/web/project/sharex/service/UserService.java | 2 ++ .../web/project/sharex/service/impl/UserServiceImpl.java | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 7db675a..53f003e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -50,6 +50,7 @@ public class UserController { Article article = userService.getArticle(id); if (Objects.equals(article.getStatus(), ArticleStatusEnum.PASS.getCode())) { ResponseEnum res = ResponseEnum.SUCCESS; + userService.addHistory(id, JWTUtil.getCurrentUser().getId()); return new UniversalResponse<>(res.getCode(), res.getMsg(), article); } else { ResponseEnum res = ResponseEnum.ARTICLE_ACCESS_DENIED; diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 845073c..07b3564 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -1,5 +1,6 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import web.project.sharex.pojo.entity.Article; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -15,4 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @Mapper public interface ArticleMapper extends BaseMapper
{ + @Insert("insert into tb_history(user_id, article_id) values(${userId},${articleId})") + void addHistory(Integer articleId, Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 06b4578..f1ee9b8 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -14,4 +14,6 @@ public interface UserService { List getOwnArticles(Integer id); Article getArticle(Integer id); + + void addHistory(Integer articleId,Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 10aab54..ca7086f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -38,4 +38,9 @@ public class UserServiceImpl implements UserService { public Article getArticle(Integer id) { return articleMapper.selectById(id); } + + @Override + public void addHistory(Integer articleId, Integer userId) { + articleMapper.addHistory(articleId, userId); + } } -- Gitee From 8350b2d755d40f2231e26fed737ce8da4bab58d0 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Fri, 10 May 2024 21:56:22 +0800 Subject: [PATCH 21/59] =?UTF-8?q?ADD=EF=BC=9A=E8=8E=B7=E5=8F=96=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=B0=81=E9=9D=A2=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 6 ++++ .../project/sharex/service/UserService.java | 4 +++ .../sharex/service/impl/UserServiceImpl.java | 28 +++++++++++++++++++ .../sharex/util/enums/ResponseEnum.java | 13 +++++---- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 53f003e..1974b40 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -3,6 +3,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; @@ -58,4 +59,9 @@ public class UserController { } } + + @PostMapping("/get/articleTitlePage") + UniversalResponse getArticleTitlePage(@RequestParam Integer articleId) { + return userService.getArticleTitlePhoto(articleId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index f1ee9b8..e563db8 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,7 +1,9 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.util.response.UniversalResponse; import java.util.List; @@ -16,4 +18,6 @@ public interface UserService { Article getArticle(Integer id); void addHistory(Integer articleId,Integer userId); + + UniversalResponse getArticleTitlePhoto(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index ca7086f..c46e4bc 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -1,12 +1,18 @@ package web.project.sharex.service.impl; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import web.project.sharex.mapper.ArticleMapper; +import web.project.sharex.mapper.PhotoMapper; import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; +import web.project.sharex.util.enums.PhotoTypeEnum; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.response.UniversalResponse; import java.util.List; @@ -18,6 +24,8 @@ public class UserServiceImpl implements UserService { @Resource ArticleMapper articleMapper; + @Autowired + private PhotoMapper photoMapper; @Override public List getUserHistory(Integer id) { @@ -43,4 +51,24 @@ public class UserServiceImpl implements UserService { public void addHistory(Integer articleId, Integer userId) { articleMapper.addHistory(articleId, userId); } + + @Override + public UniversalResponse getArticleTitlePhoto(Integer articleId) { + Article article = articleMapper.selectById(articleId); + if (article == null) { + ResponseEnum responseEnum = ResponseEnum.ARTICLE_NOT_FOUND; + return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg()); + } + Photo titlePhoto = photoMapper.getTitlePhoto(articleId); + if (titlePhoto != null) { + ResponseEnum responseEnum = ResponseEnum.SUCCESS; + return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg(), titlePhoto); + } else { + Photo photo = new Photo(); + ResponseEnum responseEnum = ResponseEnum.SUCCESS; + photo.setPhotoType(PhotoTypeEnum.TITLE_PAGE.getType()); + photo.setPath("https://web-server-sharex.oss-cn-wulanchabu.aliyuncs.com/default.jpg"); + return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg(), photo); + } + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 7d27a91..f637dcb 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -19,13 +19,14 @@ public enum ResponseEnum { PASSWORD_ERROR(2102, "密码错误"), //文章状态错误 - ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), - ARTICLE_ALREADY_APPROVED(3002,"文章已经被审核"), - ARTICLE_NOT_PASS_WITHOUT_REASON(3003,"未给出不通过原因"), - ARTICLE_ALREADY_BANNED(3004,"文章已经被封禁"), - ARTICLE_CANNOT_BAN(3005,"文章目前不可被封禁"), - ARTICLE_BAN_WITHOUT_REASON(3006,"未给出封禁原因"), + ARTICLE_ALREADY_APPROVED(3002, "文章已经被审核"), + ARTICLE_NOT_PASS_WITHOUT_REASON(3003, "未给出不通过原因"), + ARTICLE_ALREADY_BANNED(3004, "文章已经被封禁"), + ARTICLE_CANNOT_BAN(3005, "文章目前不可被封禁"), + ARTICLE_BAN_WITHOUT_REASON(3006, "未给出封禁原因"), + ARTICLE_NOT_FOUND(3007, "文章不存在"), + //文件错误 -- Gitee From bbba8e7bb07103b570cee2288cef7622e1eb853e Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 11 May 2024 10:01:19 +0800 Subject: [PATCH 22/59] =?UTF-8?q?ADD:=E6=94=B6=E8=97=8F=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/controller/UserController.java | 5 +++++ .../web/project/sharex/mapper/ArticleMapper.java | 13 +++++++++++++ .../web/project/sharex/service/UserService.java | 2 ++ .../sharex/service/impl/UserServiceImpl.java | 13 +++++++++++++ .../web/project/sharex/util/enums/ResponseEnum.java | 1 + 5 files changed, 34 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 1974b40..edfebc8 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -64,4 +64,9 @@ public class UserController { UniversalResponse getArticleTitlePage(@RequestParam Integer articleId) { return userService.getArticleTitlePhoto(articleId); } + + @PostMapping("/addToFavourite") + UniversalResponse addToFavourite(@RequestParam Integer id){ + return userService.addToFavourite(id,JWTUtil.getCurrentUser().getId()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 07b3564..fe5e938 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -2,6 +2,7 @@ package web.project.sharex.mapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Article; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -18,4 +19,16 @@ public interface ArticleMapper extends BaseMapper
{ @Insert("insert into tb_history(user_id, article_id) values(${userId},${articleId})") void addHistory(Integer articleId, Integer userId); + + @Insert("insert into tb_favorite(user_id, article_id) values(${userId},${articleId})") + void addFavourite(Integer articleId ,Integer userId); + + @Select(""" + select * + from tb_article as tba + where tba.id = (select tbf.article_id + from tb_favorite as tbf + where tbf.user_id=${userId} and tbf.article_id =${articleId}); + """) + Article getFavorite(Integer articleId, Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index e563db8..06347ca 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -20,4 +20,6 @@ public interface UserService { void addHistory(Integer articleId,Integer userId); UniversalResponse getArticleTitlePhoto(Integer articleId); + + UniversalResponse addToFavourite ( Integer aid,Integer uid); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index c46e4bc..56beec9 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -71,4 +71,17 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg(), photo); } } + + @Override + public UniversalResponse addToFavourite(Integer aid, Integer uid) { + if(articleMapper.selectById(aid)==null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (articleMapper.getFavorite(aid, uid) == null) { + articleMapper.addFavourite(aid, uid); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } else { + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_FAVOURITE.getCode(), ResponseEnum.ARTICLE_ALREADY_FAVOURITE.getMsg()); + } + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index f637dcb..9f4f7e2 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -26,6 +26,7 @@ public enum ResponseEnum { ARTICLE_CANNOT_BAN(3005, "文章目前不可被封禁"), ARTICLE_BAN_WITHOUT_REASON(3006, "未给出封禁原因"), ARTICLE_NOT_FOUND(3007, "文章不存在"), + ARTICLE_ALREADY_FAVOURITE(3008,"文章已经被收藏"), //文件错误 -- Gitee From 6495f917b51f5478efe6ec6e565928d88f5c1b06 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 11 May 2024 10:25:16 +0800 Subject: [PATCH 23/59] =?UTF-8?q?ADD=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/controller/UserController.java | 12 ++++++++++-- .../java/web/project/sharex/service/UserService.java | 2 ++ .../project/sharex/service/impl/UserServiceImpl.java | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index edfebc8..b5a537c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,7 +1,9 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; @@ -21,6 +23,8 @@ public class UserController { @Resource UserService userService; + @Autowired + private ArticleMapper articleMapper; @GetMapping("/history") UniversalResponse> getUserHistory() { @@ -59,6 +63,10 @@ public class UserController { } } + @PostMapping("/newArticle") + UniversalResponse newArticle(@RequestParam String title, @RequestParam String content) { + return userService.newArticle(title, content); + } @PostMapping("/get/articleTitlePage") UniversalResponse getArticleTitlePage(@RequestParam Integer articleId) { @@ -66,7 +74,7 @@ public class UserController { } @PostMapping("/addToFavourite") - UniversalResponse addToFavourite(@RequestParam Integer id){ - return userService.addToFavourite(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse addToFavourite(@RequestParam Integer id) { + return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 06347ca..57df546 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -22,4 +22,6 @@ public interface UserService { UniversalResponse getArticleTitlePhoto(Integer articleId); UniversalResponse addToFavourite ( Integer aid,Integer uid); + + UniversalResponse newArticle(String title,String content); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 56beec9..031a196 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -84,4 +84,9 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_FAVOURITE.getCode(), ResponseEnum.ARTICLE_ALREADY_FAVOURITE.getMsg()); } } + + @Override + public UniversalResponse newArticle(String title, String content) { + return null; + } } -- Gitee From 3983172a75b1bc59396d0fe0855d8122a94b4844 Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 11 May 2024 10:52:15 +0800 Subject: [PATCH 24/59] =?UTF-8?q?ADD:=E7=82=B9=E8=B5=9E=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/controller/UserController.java | 5 +++++ .../web/project/sharex/mapper/ArticleMapper.java | 12 ++++++++++++ .../web/project/sharex/service/UserService.java | 2 ++ .../sharex/service/impl/UserServiceImpl.java | 15 ++++++++++++++- .../project/sharex/util/enums/ResponseEnum.java | 1 + 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index b5a537c..cd8d5bd 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -77,4 +77,9 @@ public class UserController { UniversalResponse addToFavourite(@RequestParam Integer id) { return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); } + + @PostMapping("/addToLike") + UniversalResponse addToLike(@RequestParam Integer id){ + return userService.addToLike(id,JWTUtil.getCurrentUser().getId()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index fe5e938..4130f85 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -31,4 +31,16 @@ public interface ArticleMapper extends BaseMapper
{ where tbf.user_id=${userId} and tbf.article_id =${articleId}); """) Article getFavorite(Integer articleId, Integer userId); + + @Insert("insert into tb_like(user_id,article_id) values(${userId},${articleId})") + void addLike(Integer articleId,Integer userId); + + @Select(""" + select * + from tb_article as tba + where tba.id = (select tbl.article_id + from tb_like as tbl + where tbl.user_id=${userId} and tbl.article_id=${articleId}); + """) + Article getLike(Integer articleId, Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 57df546..9a2d0cb 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -23,5 +23,7 @@ public interface UserService { UniversalResponse addToFavourite ( Integer aid,Integer uid); + UniversalResponse addToLike(Integer aid,Integer uid); + UniversalResponse newArticle(String title,String content); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 031a196..03c0c50 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -74,7 +74,7 @@ public class UserServiceImpl implements UserService { @Override public UniversalResponse addToFavourite(Integer aid, Integer uid) { - if(articleMapper.selectById(aid)==null){ + if (articleMapper.selectById(aid) == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } if (articleMapper.getFavorite(aid, uid) == null) { @@ -89,4 +89,17 @@ public class UserServiceImpl implements UserService { public UniversalResponse newArticle(String title, String content) { return null; } + + @Override + public UniversalResponse addToLike(Integer aid, Integer uid) { + if (articleMapper.selectById(aid) == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (articleMapper.getLike(aid, uid) == null) { + articleMapper.addLike(aid, uid); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } else { + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_LIKE.getCode(), ResponseEnum.ARTICLE_ALREADY_LIKE.getMsg()); + } + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 9f4f7e2..6964974 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -27,6 +27,7 @@ public enum ResponseEnum { ARTICLE_BAN_WITHOUT_REASON(3006, "未给出封禁原因"), ARTICLE_NOT_FOUND(3007, "文章不存在"), ARTICLE_ALREADY_FAVOURITE(3008,"文章已经被收藏"), + ARTICLE_ALREADY_LIKE(3009,"文章已经被点赞"), //文件错误 -- Gitee From bfc8242ff51b01db17acd153498f229639f8372d Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 11 May 2024 12:37:23 +0800 Subject: [PATCH 25/59] =?UTF-8?q?ADD:=E5=8F=96=E6=B6=88=E7=82=B9=E8=B5=9E?= =?UTF-8?q?=20ADD:=E5=8F=96=E6=B6=88=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 10 +++++++ .../project/sharex/mapper/ArticleMapper.java | 7 +++++ .../project/sharex/service/UserService.java | 4 +++ .../sharex/service/impl/UserServiceImpl.java | 28 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index cd8d5bd..107c5ab 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -82,4 +82,14 @@ public class UserController { UniversalResponse addToLike(@RequestParam Integer id){ return userService.addToLike(id,JWTUtil.getCurrentUser().getId()); } + + @PostMapping("/deleteFavorite") + UniversalResponse deleteFavorite(@RequestParam Integer id){ + return userService.deleteFavorite(id,JWTUtil.getCurrentUser().getId()); + } + + @PostMapping("/deleteLike") + UniversalResponse deleteLike(@RequestParam Integer id){ + return userService.deleteLike(id,JWTUtil.getCurrentUser().getId()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 4130f85..7c48d41 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -1,5 +1,6 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; @@ -43,4 +44,10 @@ public interface ArticleMapper extends BaseMapper
{ where tbl.user_id=${userId} and tbl.article_id=${articleId}); """) Article getLike(Integer articleId, Integer userId); + + @Delete("delete from tb_favorite as tbf where tbf.article_id=${articleId} and tbf.user_id=${userId};") + void deleteFavorite(Integer articleId,Integer userId); + + @Delete("delete from tb_like as tbl where tbl.article_id=${articleId} and tbl.user_id=${userId};") + void deleteLike(Integer articleId,Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 9a2d0cb..9bcf554 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -26,4 +26,8 @@ public interface UserService { UniversalResponse addToLike(Integer aid,Integer uid); UniversalResponse newArticle(String title,String content); + + UniversalResponse deleteFavorite(Integer aid,Integer uid); + + UniversalResponse deleteLike(Integer aid,Integer uid); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 03c0c50..96f3645 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -90,6 +90,34 @@ public class UserServiceImpl implements UserService { return null; } + @Override + public UniversalResponse deleteFavorite(Integer aid, Integer uid) { + if (articleMapper.selectById(aid)==null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (articleMapper.getFavorite(aid,uid)==null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(),ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + else { + articleMapper.deleteFavorite(aid,uid); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } + + @Override + public UniversalResponse deleteLike(Integer aid, Integer uid) { + if (articleMapper.selectById(aid)==null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (articleMapper.getLike(aid,uid)==null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(),ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + else { + articleMapper.deleteLike(aid,uid); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } + @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { -- Gitee From 23e9f69ead98a2d1c82f6fd5d8ba077b3380175d Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 11 May 2024 14:31:28 +0800 Subject: [PATCH 26/59] =?UTF-8?q?ADD:=E5=85=B3=E6=B3=A8=E5=92=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=85=B3=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 10 ++++ .../web/project/sharex/mapper/UserMapper.java | 13 ++++++ .../project/sharex/service/UserService.java | 4 ++ .../sharex/service/impl/UserServiceImpl.java | 46 ++++++++++++++----- .../sharex/util/enums/ResponseEnum.java | 1 + 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 107c5ab..9b06522 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -92,4 +92,14 @@ public class UserController { UniversalResponse deleteLike(@RequestParam Integer id){ return userService.deleteLike(id,JWTUtil.getCurrentUser().getId()); } + + @PostMapping("/follow") + UniversalResponse follow(@RequestParam Integer id){ + return userService.follow(id,JWTUtil.getCurrentUser().getId()); + } + + @PostMapping("/unfollow") + UniversalResponse unfollow(@RequestParam Integer id){ + return userService.unfollow(id,JWTUtil.getCurrentUser().getId()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index 078b379..265292c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -1,5 +1,7 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.User; @@ -63,4 +65,15 @@ public interface UserMapper extends BaseMapper { order by a.publish_time desc;""") List getUserOwnArticles(Integer ID); + @Select(""" + select * + from tb_user as tbu + where id=(select followed_user_id from tb_follow as tbf where tbf.user_id=${current_id} and tbf.followed_user_id=${follow_id});""") + User getFollow(Integer follow_id,Integer current_id); + + @Insert("insert into tb_follow(user_id,followed_user_id) values(${current_id},${follow_id})") + void addFollow(Integer follow_id,Integer current_id); + + @Delete("delete from tb_follow as tbfo where user_id=${current_id} and followed_user_id=${follow_id};") + void unfollow(Integer follow_id,Integer current_id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 9bcf554..5d7bffd 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -30,4 +30,8 @@ public interface UserService { UniversalResponse deleteFavorite(Integer aid,Integer uid); UniversalResponse deleteLike(Integer aid,Integer uid); + + UniversalResponse follow(Integer follow_id, Integer current_id); + + UniversalResponse unfollow(Integer follow_id, Integer current_id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 96f3645..c8f6b3d 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -92,28 +92,52 @@ public class UserServiceImpl implements UserService { @Override public UniversalResponse deleteFavorite(Integer aid, Integer uid) { - if (articleMapper.selectById(aid)==null){ + if (articleMapper.selectById(aid) == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } - if (articleMapper.getFavorite(aid,uid)==null){ - return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(),ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); - } - else { - articleMapper.deleteFavorite(aid,uid); + if (articleMapper.getFavorite(aid, uid) == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } else { + articleMapper.deleteFavorite(aid, uid); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } } @Override public UniversalResponse deleteLike(Integer aid, Integer uid) { - if (articleMapper.selectById(aid)==null) { + if (articleMapper.selectById(aid) == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } - if (articleMapper.getLike(aid,uid)==null){ - return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(),ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + if (articleMapper.getLike(aid, uid) == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } else { + articleMapper.deleteLike(aid, uid); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } + + @Override + public UniversalResponse follow(Integer follow_id, Integer current_id) { + if (userMapper.selectById(follow_id) == null) { + return new UniversalResponse<>(ResponseEnum.USER_NOT_EXISTS.getCode(), ResponseEnum.USER_NOT_EXISTS.getMsg()); + } + if (userMapper.getFollow(follow_id, current_id) == null) { + userMapper.addFollow(follow_id, current_id); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } else { + return new UniversalResponse<>(ResponseEnum.USER_ALREADY_FOLLOWED.getCode(), ResponseEnum.USER_ALREADY_FOLLOWED.getMsg()); } - else { - articleMapper.deleteLike(aid,uid); + } + + @Override + public UniversalResponse unfollow(Integer follow_id, Integer current_id) { + if (userMapper.selectById(follow_id) == null) { + return new UniversalResponse<>(ResponseEnum.USER_NOT_EXISTS.getCode(), ResponseEnum.USER_NOT_EXISTS.getMsg()); + } + if (userMapper.getFollow(follow_id, current_id) == null) { + return new UniversalResponse<>(ResponseEnum.USER_NOT_EXISTS.getCode(), ResponseEnum.USER_NOT_EXISTS.getMsg()); + } else { + userMapper.unfollow(follow_id, current_id); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 6964974..6fce972 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -17,6 +17,7 @@ public enum ResponseEnum { USER_NOT_EXISTS(2101, "用户不存在"), PASSWORD_ERROR(2102, "密码错误"), + USER_ALREADY_FOLLOWED(2103,"此用户已经被您关注"), //文章状态错误 ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), -- Gitee From da5444788cadfb103109677ff4923e6fe757bab9 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 11 May 2024 15:30:16 +0800 Subject: [PATCH 27/59] =?UTF-8?q?ADD=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 24 +++++++++---------- .../project/sharex/service/UserService.java | 2 +- .../sharex/service/impl/UserServiceImpl.java | 15 ++++++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 9b06522..4f1ff2a 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -64,8 +64,8 @@ public class UserController { } @PostMapping("/newArticle") - UniversalResponse newArticle(@RequestParam String title, @RequestParam String content) { - return userService.newArticle(title, content); + UniversalResponse newArticle(@RequestParam String title, @RequestParam String content) { + return userService.newArticle(title, content, JWTUtil.getCurrentUser().getId()); } @PostMapping("/get/articleTitlePage") @@ -79,27 +79,27 @@ public class UserController { } @PostMapping("/addToLike") - UniversalResponse addToLike(@RequestParam Integer id){ - return userService.addToLike(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse addToLike(@RequestParam Integer id) { + return userService.addToLike(id, JWTUtil.getCurrentUser().getId()); } @PostMapping("/deleteFavorite") - UniversalResponse deleteFavorite(@RequestParam Integer id){ - return userService.deleteFavorite(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse deleteFavorite(@RequestParam Integer id) { + return userService.deleteFavorite(id, JWTUtil.getCurrentUser().getId()); } @PostMapping("/deleteLike") - UniversalResponse deleteLike(@RequestParam Integer id){ - return userService.deleteLike(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse deleteLike(@RequestParam Integer id) { + return userService.deleteLike(id, JWTUtil.getCurrentUser().getId()); } @PostMapping("/follow") - UniversalResponse follow(@RequestParam Integer id){ - return userService.follow(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse follow(@RequestParam Integer id) { + return userService.follow(id, JWTUtil.getCurrentUser().getId()); } @PostMapping("/unfollow") - UniversalResponse unfollow(@RequestParam Integer id){ - return userService.unfollow(id,JWTUtil.getCurrentUser().getId()); + UniversalResponse unfollow(@RequestParam Integer id) { + return userService.unfollow(id, JWTUtil.getCurrentUser().getId()); } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 5d7bffd..a60d581 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -25,7 +25,7 @@ public interface UserService { UniversalResponse addToLike(Integer aid,Integer uid); - UniversalResponse newArticle(String title,String content); + UniversalResponse newArticle(String title, String content, Integer authorId); UniversalResponse deleteFavorite(Integer aid,Integer uid); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index c8f6b3d..b52ae22 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -86,8 +86,19 @@ public class UserServiceImpl implements UserService { } @Override - public UniversalResponse newArticle(String title, String content) { - return null; + public UniversalResponse newArticle(String title, String content, Integer authorId) { + Article newArticle = new Article(); + newArticle.setText(content); + newArticle.setTitle(title); + newArticle.setAuthor(authorId); + articleMapper.insert(newArticle); + ArticleBriefRes brief = new ArticleBriefRes(); + brief.setTitle(title); + brief.setAuthor(authorId); + brief.setId(newArticle.getId()); + brief.setStatus(0); + brief.setPublishTime(String.valueOf(newArticle.getPublishTime())); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), brief); } @Override -- Gitee From dd774b76bf2df84d10284f51131ca4d46090e07e Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 11 May 2024 16:10:21 +0800 Subject: [PATCH 28/59] =?UTF-8?q?ADD:=E8=8E=B7=E5=8F=96=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=92=8C=E7=B2=89=E4=B8=9D=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E3=80=82=20=20DEBUG=EF=BC=9A=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E5=8F=AF=E4=BB=A5=E5=85=B3=E6=B3=A8=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 19 +++++++++++++++++++ .../web/project/sharex/mapper/UserMapper.java | 14 ++++++++++++++ .../project/sharex/service/UserService.java | 5 +++++ .../sharex/service/impl/UserServiceImpl.java | 9 +++++++++ .../sharex/util/enums/ResponseEnum.java | 3 ++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 4f1ff2a..3b9be0d 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -95,6 +95,9 @@ public class UserController { @PostMapping("/follow") UniversalResponse follow(@RequestParam Integer id) { + if (id.equals(JWTUtil.getCurrentUser().getId())){ + return new UniversalResponse<>(ResponseEnum.CANNOT_DO_TO_YOURSELF.getCode(),ResponseEnum.CANNOT_DO_TO_YOURSELF.getMsg()); + } return userService.follow(id, JWTUtil.getCurrentUser().getId()); } @@ -102,4 +105,20 @@ public class UserController { UniversalResponse unfollow(@RequestParam Integer id) { return userService.unfollow(id, JWTUtil.getCurrentUser().getId()); } + + @GetMapping("/following") + UniversalResponse> getUserFollowing() { + User current = JWTUtil.getCurrentUser(); + List followingList = userService.getUserFollowing(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), followingList); + } + + @GetMapping("/fans") + UniversalResponse> getFans(){ + User current =JWTUtil.getCurrentUser(); + List fanList = userService.getFans(current.getId()); + ResponseEnum res= ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index 265292c..e854bd6 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -76,4 +76,18 @@ public interface UserMapper extends BaseMapper { @Delete("delete from tb_follow as tbfo where user_id=${current_id} and followed_user_id=${follow_id};") void unfollow(Integer follow_id,Integer current_id); + + @Select(""" + select tbu.id,tbu.account,tbu.nickname,tbu.email,tbu.type,tbu.profile_photo + from tb_follow as tbf join tb_user as tbu on tbf.followed_user_id=tbu.id + where tbf.user_id=${userId}; +""") + List getUserFollowing(Integer userId); + + @Select(""" + select tbu.id,tbu.account,tbu.nickname,tbu.email,tbu.type,tbu.profile_photo + from tb_follow as tbf join tb_user as tbu on tbf.user_id=tbu.id + where tbf.followed_user_id=${userId}; +""") + List getFans(Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index a60d581..80f24b0 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -2,6 +2,7 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Photo; +import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.util.response.UniversalResponse; @@ -15,6 +16,8 @@ public interface UserService { List getOwnArticles(Integer id); + List getUserFollowing(Integer userId); + Article getArticle(Integer id); void addHistory(Integer articleId,Integer userId); @@ -34,4 +37,6 @@ public interface UserService { UniversalResponse follow(Integer follow_id, Integer current_id); UniversalResponse unfollow(Integer follow_id, Integer current_id); + + List getFans(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index b52ae22..b1a036b 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -8,6 +8,7 @@ import web.project.sharex.mapper.PhotoMapper; import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Photo; +import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; import web.project.sharex.util.enums.PhotoTypeEnum; @@ -153,6 +154,11 @@ public class UserServiceImpl implements UserService { } } + @Override + public List getFans(Integer userId) { + return userMapper.getFans(userId); + } + @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { @@ -165,4 +171,7 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_LIKE.getCode(), ResponseEnum.ARTICLE_ALREADY_LIKE.getMsg()); } } + + @Override + public List getUserFollowing(Integer userId) {return userMapper.getUserFollowing(userId);} } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 6fce972..0543471 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -37,7 +37,8 @@ public enum ResponseEnum { //权限错误 - USER_PERMISSION_ERROR(5001, "用户没有权限"); + USER_PERMISSION_ERROR(5001, "用户没有权限"), + CANNOT_DO_TO_YOURSELF(5002,"不能对自己操作"); private final Integer code; private final String msg; -- Gitee From ef80cd38c5ed7fa12d1e13df5fa1773a0a1bfa6f Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sun, 12 May 2024 10:06:06 +0800 Subject: [PATCH 29/59] =?UTF-8?q?ADD=EF=BC=9A=E6=B7=BB=E5=8A=A0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 20 +++++++------ .../project/sharex/mapper/CommentMapper.java | 16 ++++++++++ .../project/sharex/pojo/entity/Comment.java | 29 +++++++++++++++++++ .../project/sharex/service/UserService.java | 12 ++++---- .../sharex/service/impl/UserServiceImpl.java | 28 +++++++++++++++++- .../sharex/util/enums/ResponseEnum.java | 10 +++---- 6 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Comment.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 3b9be0d..b2b4ad2 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,9 +1,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; @@ -23,8 +21,6 @@ public class UserController { @Resource UserService userService; - @Autowired - private ArticleMapper articleMapper; @GetMapping("/history") UniversalResponse> getUserHistory() { @@ -95,8 +91,8 @@ public class UserController { @PostMapping("/follow") UniversalResponse follow(@RequestParam Integer id) { - if (id.equals(JWTUtil.getCurrentUser().getId())){ - return new UniversalResponse<>(ResponseEnum.CANNOT_DO_TO_YOURSELF.getCode(),ResponseEnum.CANNOT_DO_TO_YOURSELF.getMsg()); + if (id.equals(JWTUtil.getCurrentUser().getId())) { + return new UniversalResponse<>(ResponseEnum.CANNOT_DO_TO_YOURSELF.getCode(), ResponseEnum.CANNOT_DO_TO_YOURSELF.getMsg()); } return userService.follow(id, JWTUtil.getCurrentUser().getId()); } @@ -115,10 +111,16 @@ public class UserController { } @GetMapping("/fans") - UniversalResponse> getFans(){ - User current =JWTUtil.getCurrentUser(); + UniversalResponse> getFans() { + User current = JWTUtil.getCurrentUser(); List fanList = userService.getFans(current.getId()); - ResponseEnum res= ResponseEnum.SUCCESS; + ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); } + + @PostMapping("/newComment") + UniversalResponse newComment(@RequestParam Integer articleId, @RequestParam String comment) { + User current = JWTUtil.getCurrentUser(); + return userService.newComment(articleId, current.getId(), comment); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java new file mode 100644 index 0000000..3bc389e --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java @@ -0,0 +1,16 @@ +package web.project.sharex.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import web.project.sharex.pojo.entity.Comment; + +import java.util.List; + +@Mapper +public interface CommentMapper extends BaseMapper { + + @Select("select * from tb_comments where article_id = ${articleId};") + List getArticleComments(int articleId); +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Comment.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Comment.java new file mode 100644 index 0000000..e8448ea --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/Comment.java @@ -0,0 +1,29 @@ +package web.project.sharex.pojo.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("tb_comments") +public class Comment implements Serializable { + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer userId; + + private Integer articleId; + + private String comment; + + private LocalDateTime publishTime; +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 80f24b0..4b6dce5 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -20,23 +20,25 @@ public interface UserService { Article getArticle(Integer id); - void addHistory(Integer articleId,Integer userId); + void addHistory(Integer articleId, Integer userId); UniversalResponse getArticleTitlePhoto(Integer articleId); - UniversalResponse addToFavourite ( Integer aid,Integer uid); + UniversalResponse addToFavourite(Integer aid, Integer uid); - UniversalResponse addToLike(Integer aid,Integer uid); + UniversalResponse addToLike(Integer aid, Integer uid); UniversalResponse newArticle(String title, String content, Integer authorId); - UniversalResponse deleteFavorite(Integer aid,Integer uid); + UniversalResponse deleteFavorite(Integer aid, Integer uid); - UniversalResponse deleteLike(Integer aid,Integer uid); + UniversalResponse deleteLike(Integer aid, Integer uid); UniversalResponse follow(Integer follow_id, Integer current_id); UniversalResponse unfollow(Integer follow_id, Integer current_id); List getFans(Integer id); + + UniversalResponse newComment(Integer articleId, Integer userId, String comment); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index b1a036b..39c649a 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -4,13 +4,16 @@ import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import web.project.sharex.mapper.ArticleMapper; +import web.project.sharex.mapper.CommentMapper; import web.project.sharex.mapper.PhotoMapper; import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; +import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; @@ -25,9 +28,13 @@ public class UserServiceImpl implements UserService { @Resource ArticleMapper articleMapper; + @Autowired private PhotoMapper photoMapper; + @Autowired + private CommentMapper commentMapper; + @Override public List getUserHistory(Integer id) { return userMapper.getUserHistory(id); @@ -159,6 +166,23 @@ public class UserServiceImpl implements UserService { return userMapper.getFans(userId); } + @Override + public UniversalResponse newComment(Integer articleId, Integer userId, String comment) { + Article article = articleMapper.selectById(articleId); + if (article == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } else if (!article.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { + ResponseEnum res = ResponseEnum.ARTICLE_STATUS_IS_NOT_PASS; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + Comment newComment = new Comment(); + newComment.setUserId(userId); + newComment.setComment(comment); + newComment.setArticleId(articleId); + commentMapper.insert(newComment); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { @@ -173,5 +197,7 @@ public class UserServiceImpl implements UserService { } @Override - public List getUserFollowing(Integer userId) {return userMapper.getUserFollowing(userId);} + public List getUserFollowing(Integer userId) { + return userMapper.getUserFollowing(userId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 0543471..5c23db5 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -17,7 +17,7 @@ public enum ResponseEnum { USER_NOT_EXISTS(2101, "用户不存在"), PASSWORD_ERROR(2102, "密码错误"), - USER_ALREADY_FOLLOWED(2103,"此用户已经被您关注"), + USER_ALREADY_FOLLOWED(2103, "此用户已经被您关注"), //文章状态错误 ARTICLE_ACCESS_DENIED(3001, "文章无法访问"), @@ -27,9 +27,9 @@ public enum ResponseEnum { ARTICLE_CANNOT_BAN(3005, "文章目前不可被封禁"), ARTICLE_BAN_WITHOUT_REASON(3006, "未给出封禁原因"), ARTICLE_NOT_FOUND(3007, "文章不存在"), - ARTICLE_ALREADY_FAVOURITE(3008,"文章已经被收藏"), - ARTICLE_ALREADY_LIKE(3009,"文章已经被点赞"), - + ARTICLE_ALREADY_FAVOURITE(3008, "文章已经被收藏"), + ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), + ARTICLE_STATUS_IS_NOT_PASS(3010, "本文章当前不可访问"), //文件错误 @@ -38,7 +38,7 @@ public enum ResponseEnum { //权限错误 USER_PERMISSION_ERROR(5001, "用户没有权限"), - CANNOT_DO_TO_YOURSELF(5002,"不能对自己操作"); + CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"); private final Integer code; private final String msg; -- Gitee From 9f5902d0da7e61d4c6fd0dba6675bd669f59b4cd Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sun, 12 May 2024 10:17:17 +0800 Subject: [PATCH 30/59] =?UTF-8?q?ADD=EF=BC=9A=E8=8E=B7=E5=8F=96=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/sharex/controller/UserController.java | 6 ++++++ .../web/project/sharex/mapper/CommentMapper.java | 2 +- .../web/project/sharex/service/UserService.java | 3 +++ .../sharex/service/impl/UserServiceImpl.java | 13 +++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index b2b4ad2..d4e7e5b 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -3,6 +3,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; @@ -123,4 +124,9 @@ public class UserController { User current = JWTUtil.getCurrentUser(); return userService.newComment(articleId, current.getId(), comment); } + + @PostMapping("/getArticleComments") + UniversalResponse> getArticleComments(@RequestParam Integer articleId) { + return userService.getArticleComment(articleId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java index 3bc389e..0d8dfec 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java @@ -11,6 +11,6 @@ import java.util.List; @Mapper public interface CommentMapper extends BaseMapper { - @Select("select * from tb_comments where article_id = ${articleId};") + @Select("select * from tb_comments where article_id = ${articleId} order by publish_time desc;") List getArticleComments(int articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 4b6dce5..d3fad2f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,6 +1,7 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.res.ArticleBriefRes; @@ -41,4 +42,6 @@ public interface UserService { List getFans(Integer id); UniversalResponse newComment(Integer articleId, Integer userId, String comment); + + UniversalResponse> getArticleComment(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 39c649a..790b83e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -183,6 +183,19 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } + @Override + public UniversalResponse> getArticleComment(Integer articleId) { + Article article = articleMapper.selectById(articleId); + if (article == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } else if (!article.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { + ResponseEnum res = ResponseEnum.ARTICLE_STATUS_IS_NOT_PASS; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + List comments = commentMapper.getArticleComments(articleId); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), comments); + } + @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { -- Gitee From de277873c28a27595502b39c30431adecd43a48c Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Mon, 13 May 2024 11:15:21 +0800 Subject: [PATCH 31/59] =?UTF-8?q?ADD=EF=BC=9A=E8=8E=B7=E5=8F=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/controller/UserController.java | 5 +++++ .../java/web/project/sharex/service/UserService.java | 2 ++ .../project/sharex/service/impl/UserServiceImpl.java | 11 +++++++++++ .../web/project/sharex/util/enums/ResponseEnum.java | 6 +++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index d4e7e5b..7bf26be 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -129,4 +129,9 @@ public class UserController { UniversalResponse> getArticleComments(@RequestParam Integer articleId) { return userService.getArticleComment(articleId); } + + @PostMapping("/getUserInfo") + UniversalResponse getUserInfo(@RequestParam Integer userId) { + return userService.getUserInfo(userId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index d3fad2f..07fb132 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -44,4 +44,6 @@ public interface UserService { UniversalResponse newComment(Integer articleId, Integer userId, String comment); UniversalResponse> getArticleComment(Integer articleId); + + UniversalResponse getUserInfo(Integer userId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 790b83e..ad480e3 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -196,6 +196,17 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), comments); } + @Override + public UniversalResponse getUserInfo(Integer userId) { + User user = userMapper.selectById(userId); + if (user == null) { + ResponseEnum res = ResponseEnum.USER_NOT_FOUND; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + user.setPassword(""); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), user); + } + @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 5c23db5..f80ef52 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -38,7 +38,11 @@ public enum ResponseEnum { //权限错误 USER_PERMISSION_ERROR(5001, "用户没有权限"), - CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"); + CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"), + + // 用户信息错误 + + USER_NOT_FOUND(6001, "用户不存在"); private final Integer code; private final String msg; -- Gitee From 1886cc37961c086bbb019187bcced8ba9564b201 Mon Sep 17 00:00:00 2001 From: Miemeng Date: Wed, 15 May 2024 22:59:07 +0800 Subject: [PATCH 32/59] =?UTF-8?q?ADD=20=E6=9F=A5=E7=9C=8B/=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0/=E5=88=A0=E9=99=A4=E6=A0=87=E7=AD=BE=EF=BC=88Tag?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/AdminController.java | 16 +++++++ .../sharex/controller/UserController.java | 23 ++++++++-- .../web/project/sharex/mapper/TagMapper.java | 43 ++++++++++++++++++ .../project/sharex/service/AdminService.java | 6 +-- .../project/sharex/service/UserService.java | 10 +++-- .../sharex/service/impl/AdminServiceImpl.java | 28 ++++++++++-- .../sharex/service/impl/UserServiceImpl.java | 44 ++++++++++++++++++- .../sharex/util/enums/ResponseEnum.java | 6 +++ 8 files changed, 161 insertions(+), 15 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java index b6bef5d..1683282 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java @@ -79,4 +79,20 @@ public class AdminController { } } + @PostMapping("/addTag") + UniversalResponse addTag(@RequestParam String tag){ + User current = JWTUtil.getCurrentUser(); + if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } + return adminService.addTag(tag); + } + @PostMapping("/deleteTag") + UniversalResponse deleteTag(@RequestParam int tagId) { + User current = JWTUtil.getCurrentUser(); + if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } + return adminService.deleteTag(tagId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 7bf26be..f49d48b 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -2,10 +2,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; -import web.project.sharex.pojo.entity.Article; -import web.project.sharex.pojo.entity.Comment; -import web.project.sharex.pojo.entity.Photo; -import web.project.sharex.pojo.entity.User; +import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; @@ -70,6 +67,24 @@ public class UserController { return userService.getArticleTitlePhoto(articleId); } + @PostMapping("/get/articlesByTag") + UniversalResponse> getArticlesByTag(@RequestParam Integer tagId) { + List articles = userService.getArticlesByTag(tagId); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), articles); + } + @PostMapping("/get/tagsByArticle") + UniversalResponse> getTagsByArticle(@RequestParam Integer articleId) { + List tags = userService.getTagsByArticle(articleId); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), tags); + } + @GetMapping("/get/allTags") + UniversalResponse> getTags() { + List tags = userService.getAllTags(); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), tags); + } @PostMapping("/addToFavourite") UniversalResponse addToFavourite(@RequestParam Integer id) { return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java index 5bd4692..cba3cdb 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java @@ -1,7 +1,11 @@ package web.project.sharex.mapper; +import org.apache.ibatis.annotations.*; import web.project.sharex.pojo.entity.Tag; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import web.project.sharex.pojo.res.ArticleBriefRes; + +import java.util.List; /** *

@@ -11,6 +15,45 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author XenoWYC121 * @since 2024-04-08 */ +@Mapper public interface TagMapper extends BaseMapper { + @Select("SELECT * FROM tb_tag WHERE name = #{tagName}") + Tag getTagByName(String tagName); + @Select("SELECT COUNT(*) FROM tb_tag") + int countTag(); + @Select("SELECT * FROM tb_tag") + List getAllTags(); + @Insert("INSERT INTO tb_tag (id,name) VALUES (#{tagId},#{tagName})") + void insertTag(String tagName,int tagId); + @Delete("DELETE FROM tb_tag WHERE id = #{tagId}") + void deleteTag(int tagId); + + @Select("SELECT * FROM tb_article_tag WHERE article_id = #{tagId} AND tag_id = #{tagId}") + Boolean getArticleTag(int articleId,int tagId); + @Insert("INSERT INTO tb_article_tag (article_id,tag_id) VALUES (#{articleId},#{tagId})") + void addArticleTag(int articleId,int tagId); + @Delete("DELETE FROM tb_article_tag WHERE article_id = #{articleId} AND tag_id = #{tagId}") + void deleteArticleTag(int articleId,int tagId); + + @Select(""" + SELECT tb_tag.name,tb_tag.id + FROM tb_article_tag + INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id + WHERE tb_article_tag.article_id = #{articleId} + """) + List getTagsByArticle(int articleId); + @Select(""" + SELECT tb_article.id,author,title,status,publish_time + FROM tb_article + INNER JOIN tb_article_tag ON tb_article.id = tb_article_tag.article_id + INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id + WHERE tb_tag.id = #{tagId} AND tb_article.status = 1 + """) + List getArticlesByTag(int tagId); + + @Select("SELECT COUNT(*) FROM tb_article_tag WHERE tag_id = #{tagId}") + int countArticleByTagId(int tagId); + @Select("SELECT * FROM tb_tag WHERE id = #{tagId}") + Tag getTagById(int tagId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java index 72fa89b..dfc1be8 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java @@ -1,13 +1,13 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.Article; - - +import web.project.sharex.util.response.UniversalResponse; public interface AdminService { Article getArticle(Integer id); - void updateArticle(Integer id,Article article); + UniversalResponse addTag(String tag); + UniversalResponse deleteTag(int tagId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 07fb132..5a6c674 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,9 +1,6 @@ package web.project.sharex.service; -import web.project.sharex.pojo.entity.Article; -import web.project.sharex.pojo.entity.Comment; -import web.project.sharex.pojo.entity.Photo; -import web.project.sharex.pojo.entity.User; +import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.util.response.UniversalResponse; @@ -21,6 +18,11 @@ public interface UserService { Article getArticle(Integer id); + List getTagsByArticle(Integer articleId); + List getAllTags(); + List getArticlesByTag(Integer tagId); + UniversalResponse addTagToArticle(Integer articleId, Integer tagId); + UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId); void addHistory(Integer articleId, Integer userId); UniversalResponse getArticleTitlePhoto(Integer articleId); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java index aa7d02c..d9e637b 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java @@ -3,16 +3,17 @@ package web.project.sharex.service.impl; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import web.project.sharex.mapper.ArticleMapper; -import web.project.sharex.mapper.UserMapper; +import web.project.sharex.mapper.TagMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.service.AdminService; +import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.response.UniversalResponse; @Service public class AdminServiceImpl implements AdminService { @Resource - UserMapper userMapper; - + TagMapper tagMapper; @Resource ArticleMapper articleMapper; @@ -25,4 +26,25 @@ public class AdminServiceImpl implements AdminService { oldArticle.setAdditionalInfo(updatedArticle.getAdditionalInfo()); articleMapper.updateById(oldArticle); } + @Override + public UniversalResponse addTag(String tag){ + int tagCount = tagMapper.countTag(); + if(tagMapper.getTagByName(tag) == null){ + tagMapper.insertTag(tag, tagCount+1); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + }else{ + return new UniversalResponse<>(ResponseEnum.TAG_ALREADY_EXISTS.getCode(), ResponseEnum.TAG_ALREADY_EXISTS.getMsg()); + } + } + @Override + public UniversalResponse deleteTag(int tagId) { + if(tagMapper.getTagById(tagId) == null){ + return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); + } + if(tagMapper.countArticleByTagId(tagId) > 0){ + return new UniversalResponse<>(ResponseEnum.TAG_CANNOT_DELETE.getCode(), ResponseEnum.TAG_CANNOT_DELETE.getMsg()); + } + tagMapper.deleteTag(tagId); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index ad480e3..c3aea1e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -7,10 +7,12 @@ import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.mapper.CommentMapper; import web.project.sharex.mapper.PhotoMapper; import web.project.sharex.mapper.UserMapper; +import web.project.sharex.mapper.TagMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; +import web.project.sharex.pojo.entity.Tag; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.service.UserService; import web.project.sharex.util.enums.ArticleStatusEnum; @@ -29,6 +31,9 @@ public class UserServiceImpl implements UserService { @Resource ArticleMapper articleMapper; + @Resource + TagMapper tagMapper; + @Autowired private PhotoMapper photoMapper; @@ -219,9 +224,46 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_LIKE.getCode(), ResponseEnum.ARTICLE_ALREADY_LIKE.getMsg()); } } - @Override public List getUserFollowing(Integer userId) { return userMapper.getUserFollowing(userId); } + @Override + public List getTagsByArticle(Integer articleId) { + return tagMapper.getTagsByArticle(articleId); + } + @Override + public List getArticlesByTag(Integer tagId) { + return tagMapper.getArticlesByTag(tagId); + } + @Override + public List getAllTags() { + return tagMapper.getAllTags(); + } + @Override + public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { + //TODO: check the User's authority to add tag to article + if (tagMapper.selectById(tagId) == null) { + return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); + } + if (tagMapper.getArticleTag(articleId, tagId) == null) { + tagMapper.addArticleTag(articleId, tagId); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } else { + return new UniversalResponse<>(ResponseEnum.TAG_ALREADY_EXISTS.getCode(), ResponseEnum.TAG_ALREADY_EXISTS.getMsg()); + } + } + @Override + public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { + //TODO: check the User's authority to delete tag from article + if (tagMapper.selectById(tagId) == null) { + return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); + } + if (tagMapper.getArticleTag(articleId, tagId) == null) { + return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); + } else { + tagMapper.deleteArticleTag(articleId, tagId); + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); + } + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index f80ef52..b74fc02 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -31,6 +31,12 @@ public enum ResponseEnum { ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), ARTICLE_STATUS_IS_NOT_PASS(3010, "本文章当前不可访问"), + //标签错误 + + TAG_NOT_FOUND(3101, "标签不存在"), + TAG_ALREADY_EXISTS(3102, "标签已存在"), + TAG_CANNOT_DELETE(3103, "标签不可删除"), + //文件错误 UPLOAD_ERROR(4001, "文件上传失败"), -- Gitee From d57b64860cb9cd6486545d54510b9675433d738d Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Thu, 16 May 2024 10:32:03 +0800 Subject: [PATCH 33/59] =?UTF-8?q?ADD:=E8=8E=B7=E5=8F=96=E4=BB=96=E4=BA=BA?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E6=B3=A8=E5=88=97=E8=A1=A8=E5=92=8C=E7=B2=89?= =?UTF-8?q?=E4=B8=9D=E5=88=97=E8=A1=A8=EF=BC=9B=E8=8E=B7=E5=8F=96=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E5=92=8C=E4=BB=96=E4=BA=BA=E7=9A=84=E7=B2=89=E4=B8=9D?= =?UTF-8?q?=E6=95=B0=E3=80=81=E5=85=B3=E6=B3=A8=E6=95=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 44 +++++++++++++++++++ .../web/project/sharex/mapper/UserMapper.java | 6 +++ .../project/sharex/service/UserService.java | 4 ++ .../sharex/service/impl/UserServiceImpl.java | 12 +++++ 4 files changed, 66 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index f49d48b..dc4337f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -126,6 +126,13 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), followingList); } + @GetMapping("/getOthersFollowing") + UniversalResponse> getOthersFollowing(Integer id){ + List followingList = userService.getUserFollowing(id); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), followingList); + } + @GetMapping("/fans") UniversalResponse> getFans() { User current = JWTUtil.getCurrentUser(); @@ -134,6 +141,13 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); } + @GetMapping("/getOthersFans") + UniversalResponse> getOthersFans(Integer id){ + List fanList = userService.getFans(id); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); + } + @PostMapping("/newComment") UniversalResponse newComment(@RequestParam Integer articleId, @RequestParam String comment) { User current = JWTUtil.getCurrentUser(); @@ -149,4 +163,34 @@ public class UserController { UniversalResponse getUserInfo(@RequestParam Integer userId) { return userService.getUserInfo(userId); } + + @GetMapping("/getFansCount") + UniversalResponse getFansCount() { + User current = JWTUtil.getCurrentUser(); + int count = userService.getFansCount(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), count); + } + + @GetMapping("/getOthersFansCount") + UniversalResponse getOthersFansCount(Integer id){ + int count = userService.getFansCount(id); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), count); + } + + @GetMapping("/getFollowingCount") + UniversalResponse getFollowingCount() { + User current = JWTUtil.getCurrentUser(); + int count = userService.getFollowingCount(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), count); + } + + @GetMapping("/getOthersFollowingCount") + UniversalResponse getOthersFollowingCount(Integer id){ + int count = userService.getFollowingCount(id); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), count); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index e854bd6..b984822 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -90,4 +90,10 @@ public interface UserMapper extends BaseMapper { where tbf.followed_user_id=${userId}; """) List getFans(Integer userId); + + @Select("select count(*) from tb_follow as tbf where tbf.user_id=${current_id};") + int getFollowingCount(Integer current_id); + + @Select("select count(*) from tb_follow as tbf where tbf.followed_user_id=${current_id};") + int getFansCount(Integer current_id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 5a6c674..53762c9 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -48,4 +48,8 @@ public interface UserService { UniversalResponse> getArticleComment(Integer articleId); UniversalResponse getUserInfo(Integer userId); + + int getFansCount(Integer id); + + int getFollowingCount(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index c3aea1e..51127bc 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -266,4 +266,16 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } } + + + @Override + public int getFansCount(Integer userId) { + return userMapper.getFansCount(userId); + } + + @Override + public int getFollowingCount(Integer userId) { + return userMapper.getFollowingCount(userId); + } + } -- Gitee From d210e70cb77891e61b56f17b91d714f5a7e38069 Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Fri, 17 May 2024 17:01:40 +0800 Subject: [PATCH 34/59] =?UTF-8?q?1.FIX:=E6=AD=A3=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=B8=8E=E5=8F=8D=E6=93=8D=E4=BD=9C=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=90=88=E5=B9=B6=EF=BC=88=E6=94=B6=E8=97=8F/=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=94=B6=E8=97=8F=EF=BC=8C=E7=82=B9=E8=B5=9E/?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=82=B9=E8=B5=9E=EF=BC=8C=E5=85=B3=E6=B3=A8?= =?UTF-8?q?/=E5=8F=96=E6=B6=88=E5=85=B3=E6=B3=A8=EF=BC=89=202.FIX:?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E3=80=81=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E3=80=81=E7=B2=89=E4=B8=9D=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=203.FIX=EF=BC=9A=E5=B0=86=E5=85=B3=E6=B3=A8=E6=95=B0?= =?UTF-8?q?=E5=92=8C=E7=B2=89=E4=B8=9D=E6=95=B0=E5=90=88=E5=B9=B6=E5=88=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 112 ++++++------------ .../project/sharex/mapper/ArticleMapper.java | 10 ++ .../web/project/sharex/mapper/UserMapper.java | 51 +++++--- .../web/project/sharex/pojo/res/UserRes.java | 18 +++ .../project/sharex/service/UserService.java | 13 +- .../sharex/service/impl/UserServiceImpl.java | 83 +++++++++---- 6 files changed, 168 insertions(+), 119 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/UserRes.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index dc4337f..1c90750 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -4,6 +4,7 @@ import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; @@ -36,6 +37,14 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); } +/* @GetMapping("/like") + UniversalResponse> getUserLike(){ + User current = JWTUtil.getCurrentUser(); + List ret = userService.getUserLike(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + }*/ + @GetMapping("/own/articles") UniversalResponse> getOwnArticles() { User current = JWTUtil.getCurrentUser(); @@ -85,65 +94,49 @@ public class UserController { ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), tags); } - @PostMapping("/addToFavourite") - UniversalResponse addToFavourite(@RequestParam Integer id) { - return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); - } - - @PostMapping("/addToLike") - UniversalResponse addToLike(@RequestParam Integer id) { - return userService.addToLike(id, JWTUtil.getCurrentUser().getId()); - } - - @PostMapping("/deleteFavorite") - UniversalResponse deleteFavorite(@RequestParam Integer id) { - return userService.deleteFavorite(id, JWTUtil.getCurrentUser().getId()); + @PostMapping("/StarAndUnstar") + UniversalResponse addToFavourite(@RequestParam Integer id,@RequestParam Boolean star) { + if (star) { + return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); + } + else{ + return userService.deleteFavorite(id, JWTUtil.getCurrentUser().getId()); + } } - @PostMapping("/deleteLike") - UniversalResponse deleteLike(@RequestParam Integer id) { - return userService.deleteLike(id, JWTUtil.getCurrentUser().getId()); + @PostMapping("/LikeAndUnlike") + UniversalResponse addToLike(@RequestParam Integer id,@RequestParam Boolean like) { + if(like) { + return userService.addToLike(id, JWTUtil.getCurrentUser().getId()); + } + else { + return userService.deleteLike(id, JWTUtil.getCurrentUser().getId()); + } } - @PostMapping("/follow") - UniversalResponse follow(@RequestParam Integer id) { + @PostMapping("/FollowAndUnfollow") + UniversalResponse follow(@RequestParam Integer id,@RequestParam Boolean follow) { if (id.equals(JWTUtil.getCurrentUser().getId())) { return new UniversalResponse<>(ResponseEnum.CANNOT_DO_TO_YOURSELF.getCode(), ResponseEnum.CANNOT_DO_TO_YOURSELF.getMsg()); } - return userService.follow(id, JWTUtil.getCurrentUser().getId()); - } - - @PostMapping("/unfollow") - UniversalResponse unfollow(@RequestParam Integer id) { - return userService.unfollow(id, JWTUtil.getCurrentUser().getId()); + if (follow){ + return userService.follow(id, JWTUtil.getCurrentUser().getId()); + } + else { + return userService.unfollow(id, JWTUtil.getCurrentUser().getId()); + } } @GetMapping("/following") - UniversalResponse> getUserFollowing() { - User current = JWTUtil.getCurrentUser(); - List followingList = userService.getUserFollowing(current.getId()); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), followingList); - } - - @GetMapping("/getOthersFollowing") - UniversalResponse> getOthersFollowing(Integer id){ - List followingList = userService.getUserFollowing(id); + UniversalResponse> getUserFollowing(@RequestParam Integer id) { + List followingList = userService.getUserFollowing(id); ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), followingList); } @GetMapping("/fans") - UniversalResponse> getFans() { - User current = JWTUtil.getCurrentUser(); - List fanList = userService.getFans(current.getId()); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); - } - - @GetMapping("/getOthersFans") - UniversalResponse> getOthersFans(Integer id){ - List fanList = userService.getFans(id); + UniversalResponse> getFans(@RequestParam Integer id) { + List fanList = userService.getFans(id); ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), fanList); } @@ -160,37 +153,8 @@ public class UserController { } @PostMapping("/getUserInfo") - UniversalResponse getUserInfo(@RequestParam Integer userId) { + UniversalResponse getUserInfo(@RequestParam Integer userId) { return userService.getUserInfo(userId); } - @GetMapping("/getFansCount") - UniversalResponse getFansCount() { - User current = JWTUtil.getCurrentUser(); - int count = userService.getFansCount(current.getId()); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), count); - } - - @GetMapping("/getOthersFansCount") - UniversalResponse getOthersFansCount(Integer id){ - int count = userService.getFansCount(id); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), count); - } - - @GetMapping("/getFollowingCount") - UniversalResponse getFollowingCount() { - User current = JWTUtil.getCurrentUser(); - int count = userService.getFollowingCount(current.getId()); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), count); - } - - @GetMapping("/getOthersFollowingCount") - UniversalResponse getOthersFollowingCount(Integer id){ - int count = userService.getFollowingCount(id); - ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(), count); - } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 7c48d41..4a3ae12 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -50,4 +50,14 @@ public interface ArticleMapper extends BaseMapper

{ @Delete("delete from tb_like as tbl where tbl.article_id=${articleId} and tbl.user_id=${userId};") void deleteLike(Integer articleId,Integer userId); + + @Select("select count(*) from tb_like as tbl where tbl.article_id=${articleId}") + int getLikeCount(Integer articleId); + + @Select("select count(*) from tb_favorite as tbf where tbf.article_id=${articleId}") + int getFavoriteCount(Integer articleId); + + @Select("select count(*) from tb_comments as tbc where article_id=${articleId}") + int getCommentsCount(Integer articleId); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index b984822..97495b3 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.UserRes; import java.util.List; @@ -48,7 +49,7 @@ public interface UserMapper extends BaseMapper { tf.time as time from tb_article as a inner join tb_favorite tf on a.id = tf.article_id - where tf.user_id = 1 + where tf.user_id = ${ID} order by tf.time desc;""") List getUserFavorite(Integer ID); @@ -69,31 +70,45 @@ public interface UserMapper extends BaseMapper { select * from tb_user as tbu where id=(select followed_user_id from tb_follow as tbf where tbf.user_id=${current_id} and tbf.followed_user_id=${follow_id});""") - User getFollow(Integer follow_id,Integer current_id); + User getFollow(Integer follow_id, Integer current_id); @Insert("insert into tb_follow(user_id,followed_user_id) values(${current_id},${follow_id})") - void addFollow(Integer follow_id,Integer current_id); + void addFollow(Integer follow_id, Integer current_id); @Delete("delete from tb_follow as tbfo where user_id=${current_id} and followed_user_id=${follow_id};") - void unfollow(Integer follow_id,Integer current_id); - - @Select(""" - select tbu.id,tbu.account,tbu.nickname,tbu.email,tbu.type,tbu.profile_photo - from tb_follow as tbf join tb_user as tbu on tbf.followed_user_id=tbu.id - where tbf.user_id=${userId}; -""") - List getUserFollowing(Integer userId); - - @Select(""" - select tbu.id,tbu.account,tbu.nickname,tbu.email,tbu.type,tbu.profile_photo - from tb_follow as tbf join tb_user as tbu on tbf.user_id=tbu.id - where tbf.followed_user_id=${userId}; -""") - List getFans(Integer userId); + void unfollow(Integer follow_id, Integer current_id); @Select("select count(*) from tb_follow as tbf where tbf.user_id=${current_id};") int getFollowingCount(Integer current_id); @Select("select count(*) from tb_follow as tbf where tbf.followed_user_id=${current_id};") int getFansCount(Integer current_id); + + /* @Select(""" + select a.id as id, + a.author as author, + a.title as title, + a.status as status, + a.publish_time as publish_time, + (select p.path from tb_photo as p where p.reference = a.id and p.photo_type = 1) as cover_photo_path, + tf.time as time + from tb_article as a + inner join tb_like tf on a.id = tf.article_id + where tf.user_id = ${id} + order by tf.time desc;""") + List getUserLike(Integer id);*/ + + @Select("select id from tb_user;") + List getAllUserId(); + + /// 获取某个用户关注的人的id + @Select(""" + select + followed_user_id + from tb_follow where user_id = ${id};""") + List getUserFollowId(Integer id); + + @Select("select user_id from tb_follow where followed_user_id=${id};") + List getUserFansId(Integer id); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/UserRes.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/UserRes.java new file mode 100644 index 0000000..7cad350 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/UserRes.java @@ -0,0 +1,18 @@ +package web.project.sharex.pojo.res; + + +import lombok.Data; + +@Data +public class UserRes +{ + private Integer id; + private String account; + private String nickname; + private String email; + private Integer type; + private String profile_photo; + private Integer fansCount; + private Integer followingCount; + +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 53762c9..e347c9c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -2,6 +2,7 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.UserRes; import web.project.sharex.util.response.UniversalResponse; import java.util.List; @@ -14,7 +15,7 @@ public interface UserService { List getOwnArticles(Integer id); - List getUserFollowing(Integer userId); + List getUserFollowing(Integer userId); Article getArticle(Integer id); @@ -41,15 +42,17 @@ public interface UserService { UniversalResponse unfollow(Integer follow_id, Integer current_id); - List getFans(Integer id); + List getFans(Integer id); UniversalResponse newComment(Integer articleId, Integer userId, String comment); UniversalResponse> getArticleComment(Integer articleId); - UniversalResponse getUserInfo(Integer userId); + UniversalResponse getUserInfo(Integer userId); - int getFansCount(Integer id); +// List getUserLike(Integer id); - int getFollowingCount(Integer id); + UserRes getUserRes(Integer id); + + List getAllUserRes(); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 51127bc..c2b9834 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -14,12 +14,15 @@ import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.entity.Tag; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; @Service @@ -166,11 +169,6 @@ public class UserServiceImpl implements UserService { } } - @Override - public List getFans(Integer userId) { - return userMapper.getFans(userId); - } - @Override public UniversalResponse newComment(Integer articleId, Integer userId, String comment) { Article article = articleMapper.selectById(articleId); @@ -201,17 +199,6 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), comments); } - @Override - public UniversalResponse getUserInfo(Integer userId) { - User user = userMapper.selectById(userId); - if (user == null) { - ResponseEnum res = ResponseEnum.USER_NOT_FOUND; - return new UniversalResponse<>(res.getCode(), res.getMsg()); - } - user.setPassword(""); - return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), user); - } - @Override public UniversalResponse addToLike(Integer aid, Integer uid) { if (articleMapper.selectById(aid) == null) { @@ -224,22 +211,48 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_LIKE.getCode(), ResponseEnum.ARTICLE_ALREADY_LIKE.getMsg()); } } + + @Override + public List getUserFollowing(Integer userId) { + List followIds = userMapper.getUserFollowId(userId); + List res = new ArrayList<>(); + for(Integer id : followIds) { + res.add(this.getUserRes(id)); + } + return res; + } @Override - public List getUserFollowing(Integer userId) { - return userMapper.getUserFollowing(userId); + public List getFans(Integer userId) { + List fansIds = userMapper.getUserFansId(userId); + List res = new ArrayList<>(); + for (Integer id: fansIds){ + res.add(this.getUserRes(id)); + } + return res; + } + + @Override + public UniversalResponse getUserInfo(Integer userId) { + UserRes Res = getUserRes(userId); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(),Res); } + @Override public List getTagsByArticle(Integer articleId) { return tagMapper.getTagsByArticle(articleId); } + @Override public List getArticlesByTag(Integer tagId) { return tagMapper.getArticlesByTag(tagId); } + @Override public List getAllTags() { return tagMapper.getAllTags(); } + @Override public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { //TODO: check the User's authority to add tag to article @@ -253,6 +266,7 @@ public class UserServiceImpl implements UserService { return new UniversalResponse<>(ResponseEnum.TAG_ALREADY_EXISTS.getCode(), ResponseEnum.TAG_ALREADY_EXISTS.getMsg()); } } + @Override public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { //TODO: check the User's authority to delete tag from article @@ -267,15 +281,40 @@ public class UserServiceImpl implements UserService { } } + /*@Override + public List getUserLike(Integer id) { + return userMapper.getUserLike(id); + }*/ @Override - public int getFansCount(Integer userId) { - return userMapper.getFansCount(userId); + public UserRes getUserRes(Integer id) { + User currentUser = userMapper.selectById(id); + if (currentUser == null) { + return null; + } + int follow = userMapper.getFollowingCount(currentUser.getId()); + int fans = userMapper.getFansCount(currentUser.getId()); + UserRes newRes = new UserRes(); + newRes.setAccount(currentUser.getAccount()); + newRes.setNickname(currentUser.getNickname()); + newRes.setEmail(currentUser.getEmail()); + newRes.setProfile_photo(currentUser.getProfilePhoto()); + newRes.setType(currentUser.getType()); + newRes.setFansCount(fans); + newRes.setFollowingCount(follow); + newRes.setId(currentUser.getId()); + return newRes; } @Override - public int getFollowingCount(Integer userId) { - return userMapper.getFollowingCount(userId); + public List getAllUserRes() { + List allId = userMapper.getAllUserId(); + ArrayList res = new ArrayList<>(); + for (Integer integer : allId) { + res.add(this.getUserRes(integer)); + } + return res; } + } -- Gitee From f6879d2f2585f23452469785d68ffb933e2b20fa Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 01:47:14 +0800 Subject: [PATCH 35/59] =?UTF-8?q?FIX:=20=E7=99=BB=E9=99=86=E6=97=B6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=9B=B4=E8=AF=A6=E7=BB=86=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/web/project/sharex/pojo/res/TokenRes.java | 9 +++++---- .../project/sharex/service/impl/IndexServiceImpl.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java index 814f24f..1151fd6 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/TokenRes.java @@ -2,16 +2,17 @@ package web.project.sharex.pojo.res; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import web.project.sharex.pojo.entity.User; @Data public class TokenRes { @ApiModelProperty("token") private String token; - @ApiModelProperty("身份") - private Integer identity; + @ApiModelProperty("用户信息") + private User userInfo; - public TokenRes(String token, Integer identity) { + public TokenRes(String token, User user) { this.token = token; - this.identity = identity; + this.userInfo = user; } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java index de9d961..ddaecdc 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/IndexServiceImpl.java @@ -56,7 +56,8 @@ public class IndexServiceImpl implements IndexService { userMap.put("nickname", user.getNickname()); userMap.put("identity", user.getType().toString()); String token = JWTUtil.getToken(userMap); - TokenRes res = new TokenRes(token, user.getType()); + user.setPassword(null); + TokenRes res = new TokenRes(token, user); return new UniversalResponse<>( ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), -- Gitee From 8e95783002ec6ab09565929d4cbc911aca00e0ab Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 02:45:26 +0800 Subject: [PATCH 36/59] =?UTF-8?q?ADD:=20=E8=8E=B7=E5=8F=96=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=96=87=E7=AB=A0=E7=AE=80=E8=A6=81=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E3=80=81=E8=8E=B7=E5=8F=96=E6=9F=90=E4=B8=80=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=AE=80=E8=A6=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 38 ++++++++++++----- .../project/sharex/mapper/ArticleMapper.java | 4 ++ .../project/sharex/mapper/PhotoMapper.java | 4 ++ .../project/sharex/pojo/res/ArticleBrief.java | 30 +++++++++++++ .../project/sharex/service/UserService.java | 5 +++ .../sharex/service/impl/UserServiceImpl.java | 42 +++++++++++++++++-- 6 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 1c90750..454e254 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,8 +1,11 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.pojo.entity.*; +import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; @@ -20,6 +23,8 @@ public class UserController { @Resource UserService userService; + @Autowired + private ArticleMapper articleMapper; @GetMapping("/history") UniversalResponse> getUserHistory() { @@ -82,47 +87,47 @@ public class UserController { ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), articles); } + @PostMapping("/get/tagsByArticle") UniversalResponse> getTagsByArticle(@RequestParam Integer articleId) { List tags = userService.getTagsByArticle(articleId); ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), tags); } + @GetMapping("/get/allTags") UniversalResponse> getTags() { List tags = userService.getAllTags(); ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), tags); } + @PostMapping("/StarAndUnstar") - UniversalResponse addToFavourite(@RequestParam Integer id,@RequestParam Boolean star) { + UniversalResponse addToFavourite(@RequestParam Integer id, @RequestParam Boolean star) { if (star) { return userService.addToFavourite(id, JWTUtil.getCurrentUser().getId()); - } - else{ + } else { return userService.deleteFavorite(id, JWTUtil.getCurrentUser().getId()); } } @PostMapping("/LikeAndUnlike") - UniversalResponse addToLike(@RequestParam Integer id,@RequestParam Boolean like) { - if(like) { + UniversalResponse addToLike(@RequestParam Integer id, @RequestParam Boolean like) { + if (like) { return userService.addToLike(id, JWTUtil.getCurrentUser().getId()); - } - else { + } else { return userService.deleteLike(id, JWTUtil.getCurrentUser().getId()); } } @PostMapping("/FollowAndUnfollow") - UniversalResponse follow(@RequestParam Integer id,@RequestParam Boolean follow) { + UniversalResponse follow(@RequestParam Integer id, @RequestParam Boolean follow) { if (id.equals(JWTUtil.getCurrentUser().getId())) { return new UniversalResponse<>(ResponseEnum.CANNOT_DO_TO_YOURSELF.getCode(), ResponseEnum.CANNOT_DO_TO_YOURSELF.getMsg()); } - if (follow){ + if (follow) { return userService.follow(id, JWTUtil.getCurrentUser().getId()); - } - else { + } else { return userService.unfollow(id, JWTUtil.getCurrentUser().getId()); } } @@ -157,4 +162,15 @@ public class UserController { return userService.getUserInfo(userId); } + @GetMapping("/getAllArticleBrief") + UniversalResponse> getAllArticleBrief() { + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), userService.getAllArticleBrief()); + } + + @GetMapping("/getArticleBrief") + UniversalResponse getArticleBrief(@RequestParam Integer articleId) { + return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + userService.getArticleBrief(articleId)); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 4a3ae12..1bcc6a1 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Article; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; + /** *

* 文章信息表 Mapper 接口 @@ -60,4 +62,6 @@ public interface ArticleMapper extends BaseMapper

{ @Select("select count(*) from tb_comments as tbc where article_id=${articleId}") int getCommentsCount(Integer articleId); + @Select("select id from tb_article;") + List getAllArticleIds(); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java index 5e7fa06..3de5787 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java @@ -5,6 +5,8 @@ import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Photo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.ArrayList; + /** *

* 图片信息表 Mapper 接口 @@ -23,4 +25,6 @@ public interface PhotoMapper extends BaseMapper { tp.photo_type = 1;""") Photo getTitlePhoto(Integer articleId); + @Select("select * from tb_photo where reference=${articleId} and photo_type !=1;") + ArrayList getPhotos(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java new file mode 100644 index 0000000..e389290 --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java @@ -0,0 +1,30 @@ +package web.project.sharex.pojo.res; + +import lombok.Data; +import web.project.sharex.pojo.entity.Photo; + +import java.util.ArrayList; + +@Data +public class ArticleBrief { + + private Integer id; + + private Integer author; + + private String title; + + private Integer status; + + private String publishTime; + + private Integer likeNumber; + + private Integer favoriteNumber; + + private Integer commentNumber; + + private Photo cover; + + private ArrayList photos; +} \ No newline at end of file diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index e347c9c..ff4f611 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,6 +1,7 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.*; +import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.util.response.UniversalResponse; @@ -55,4 +56,8 @@ public interface UserService { UserRes getUserRes(Integer id); List getAllUserRes(); + + ArticleBrief getArticleBrief(Integer articleId); + + List getAllArticleBrief(); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index c2b9834..e4f8015 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -13,6 +13,7 @@ import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.entity.Tag; +import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; @@ -22,7 +23,6 @@ import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; @Service @@ -216,16 +216,17 @@ public class UserServiceImpl implements UserService { public List getUserFollowing(Integer userId) { List followIds = userMapper.getUserFollowId(userId); List res = new ArrayList<>(); - for(Integer id : followIds) { + for (Integer id : followIds) { res.add(this.getUserRes(id)); } return res; } + @Override public List getFans(Integer userId) { List fansIds = userMapper.getUserFansId(userId); List res = new ArrayList<>(); - for (Integer id: fansIds){ + for (Integer id : fansIds) { res.add(this.getUserRes(id)); } return res; @@ -235,7 +236,7 @@ public class UserServiceImpl implements UserService { public UniversalResponse getUserInfo(Integer userId) { UserRes Res = getUserRes(userId); ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(), res.getMsg(),Res); + return new UniversalResponse<>(res.getCode(), res.getMsg(), Res); } @Override @@ -316,5 +317,38 @@ public class UserServiceImpl implements UserService { return res; } + @Override + public ArticleBrief getArticleBrief(Integer articleId) { + Article article = articleMapper.selectById(articleId); + Integer likeCounter = articleMapper.getLikeCount(articleId); + Integer favoriteCounter = articleMapper.getFavoriteCount(articleId); + Integer commentCounter = articleMapper.getCommentsCount(articleId); + Photo cover = photoMapper.getTitlePhoto(articleId); + ArrayList photos = photoMapper.getPhotos(articleId); + ArticleBrief brief = new ArticleBrief(); + brief.setId(articleId); + brief.setTitle(article.getTitle()); + brief.setAuthor(article.getAuthor()); + brief.setStatus(article.getStatus()); + brief.setCover(cover); + brief.setPhotos(photos); + brief.setLikeNumber(likeCounter); + brief.setFavoriteNumber(favoriteCounter); + brief.setCommentNumber(commentCounter); + brief.setPublishTime(article.getPublishTime().toString()); + return brief; + } + + @Override + public List getAllArticleBrief() { + ListidArray = articleMapper.getAllArticleIds(); + ArrayList res = new ArrayList<>(); + for(Integer id : idArray) + { + res.add(this.getArticleBrief(id)); + } + return res; + } + } -- Gitee From 19135fb6b7928b1af03b0ec133f676292ceae9f9 Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 18 May 2024 10:45:25 +0800 Subject: [PATCH 37/59] =?UTF-8?q?ADD:=E6=9B=B4=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=88=E5=AF=86=E7=A0=81=E3=80=81=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E3=80=81=E6=98=B5=E7=A7=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 29 +++++++++++++++++++ .../sharex/service/impl/UserServiceImpl.java | 1 + 2 files changed, 30 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 1c90750..3edfc2e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,7 +1,9 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; @@ -21,6 +23,9 @@ public class UserController { @Resource UserService userService; + @Autowired + UserMapper userMapper; + @GetMapping("/history") UniversalResponse> getUserHistory() { User current = JWTUtil.getCurrentUser(); @@ -157,4 +162,28 @@ public class UserController { return userService.getUserInfo(userId); } + @PostMapping("/changeUserInfo") + UniversalResponse changeUserInfo(@RequestParam(value="nickname",required = false) String nickname, + @RequestParam(value ="password",required = false) String password, + @RequestParam(value="email",required = false) String email + ){ + if (nickname.isEmpty()&&password.isEmpty()&&email.isEmpty()){ + ResponseEnum res= ResponseEnum.FAILED; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + User user = JWTUtil.getCurrentUser(); + if (nickname!= null && !nickname.isEmpty()) { + user.setNickname(nickname); + } + if (password!=null && !password.isEmpty()){ + user.setEmail(password); + } + if (email!=null && !email.isEmpty()){ + user.setEmail(email); + } + userMapper.updateById(user); + ResponseEnum resp=ResponseEnum.SUCCESS; + return new UniversalResponse<>(resp.getCode(), resp.getMsg()); + } + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index c2b9834..4e74d3f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -16,6 +16,7 @@ import web.project.sharex.pojo.entity.Tag; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; +import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; -- Gitee From b112dc6e67f69d6a699e40cba779849491169a8e Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 11:14:43 +0800 Subject: [PATCH 38/59] =?UTF-8?q?FIX:=E5=AE=8C=E6=88=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=AD=E7=9A=84=E5=A4=B4=E5=83=8F=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 031d8a0..4d5fa42 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -3,6 +3,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import web.project.sharex.mapper.UserMapper; import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.mapper.UserMapper; @@ -10,6 +11,7 @@ import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.UserRes; +import web.project.sharex.service.FileService; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; @@ -31,6 +33,9 @@ public class UserController { @Autowired UserMapper userMapper; + @Autowired + private FileService fileService; + @GetMapping("/history") UniversalResponse> getUserHistory() { User current = JWTUtil.getCurrentUser(); @@ -168,26 +173,37 @@ public class UserController { } @PostMapping("/changeUserInfo") - UniversalResponse changeUserInfo(@RequestParam(value="nickname",required = false) String nickname, - @RequestParam(value ="password",required = false) String password, - @RequestParam(value="email",required = false) String email - ){ - if (nickname.isEmpty()&&password.isEmpty()&&email.isEmpty()){ - ResponseEnum res= ResponseEnum.FAILED; + UniversalResponse changeUserInfo(@RequestParam(value = "nickname", required = false) String nickname, + @RequestParam(value = "password", required = false) String password, + @RequestParam(value = "email", required = false) String email, + @RequestParam(value = "profile_photo", required = false) MultipartFile profile_photo + ) { + if (nickname.isEmpty() && password.isEmpty() && email.isEmpty() && profile_photo.isEmpty()) { + ResponseEnum res = ResponseEnum.FAILED; return new UniversalResponse<>(res.getCode(), res.getMsg()); } User user = JWTUtil.getCurrentUser(); - if (nickname!= null && !nickname.isEmpty()) { + if (!nickname.isEmpty()) { user.setNickname(nickname); } - if (password!=null && !password.isEmpty()){ + if (!password.isEmpty()) { user.setEmail(password); } - if (email!=null && !email.isEmpty()){ + if (!email.isEmpty()) { user.setEmail(email); } + if (!profile_photo.isEmpty()) { + String url = ""; + try { + url = fileService.upload(profile_photo); + } catch (Exception e) { + ResponseEnum res = ResponseEnum.FAILED; + return new UniversalResponse<>(res.getCode(), "图片上传失败"); + } + user.setProfilePhoto(url); + } userMapper.updateById(user); - ResponseEnum resp=ResponseEnum.SUCCESS; + ResponseEnum resp = ResponseEnum.SUCCESS; return new UniversalResponse<>(resp.getCode(), resp.getMsg()); } -- Gitee From 93f37c8c729955480c25079ca644c1c98237f93e Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 11:31:00 +0800 Subject: [PATCH 39/59] =?UTF-8?q?ADD=EF=BC=9A=E6=96=87=E7=AB=A0=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E4=BF=A1=E6=81=AF=E7=B1=BB=EF=BC=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 12 ++++- .../project/sharex/mapper/ArticleMapper.java | 3 ++ .../sharex/pojo/res/ArticleDetail.java | 45 +++++++++++++++++++ .../project/sharex/service/UserService.java | 3 ++ .../sharex/service/impl/UserServiceImpl.java | 13 ++++-- 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 4d5fa42..40d7980 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -10,6 +10,7 @@ import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.ArticleDetail; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.FileService; import web.project.sharex.service.UserService; @@ -212,10 +213,19 @@ public class UserController { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), userService.getAllArticleBrief()); } - @GetMapping("/getArticleBrief") + @PostMapping("/getArticleBrief") UniversalResponse getArticleBrief(@RequestParam Integer articleId) { return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), userService.getArticleBrief(articleId)); } + + @PostMapping("/getArticleDetail") + UniversalResponse getArticleDetail(@RequestParam Integer articleId) { + return new UniversalResponse<>( + ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + userService.getArticleDetail(articleId) + ); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index 1bcc6a1..cc44c4a 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -64,4 +64,7 @@ public interface ArticleMapper extends BaseMapper

{ @Select("select id from tb_article;") List getAllArticleIds(); + + @Select("select text from tb_article where id=${articleId}") + String getArticleText(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java new file mode 100644 index 0000000..06d3edc --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java @@ -0,0 +1,45 @@ +package web.project.sharex.pojo.res; + +import lombok.Data; +import web.project.sharex.pojo.entity.Photo; + +import java.util.ArrayList; + +@Data +public class ArticleDetail { + private Integer id; + + private Integer author; + + private String title; + + private Integer status; + + private String publishTime; + + private Integer likeNumber; + + private Integer favoriteNumber; + + private Integer commentNumber; + + private Photo cover; + + private ArrayList photos; + + private String text; + + public ArticleDetail(ArticleBrief brief, String text) { + this.id = brief.getId(); + this.author = brief.getAuthor(); + this.title = brief.getTitle(); + this.status = brief.getStatus(); + this.publishTime = brief.getPublishTime(); + this.likeNumber = brief.getLikeNumber(); + this.favoriteNumber = brief.getFavoriteNumber(); + this.commentNumber = brief.getCommentNumber(); + this.cover = brief.getCover(); + this.photos = brief.getPhotos(); + this.text = text; + } +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index ff4f611..46ac267 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -3,6 +3,7 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.ArticleDetail; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.util.response.UniversalResponse; @@ -60,4 +61,6 @@ public interface UserService { ArticleBrief getArticleBrief(Integer articleId); List getAllArticleBrief(); + + ArticleDetail getArticleDetail(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index e090a80..45ea017 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -15,6 +15,7 @@ import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.entity.Tag; import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; +import web.project.sharex.pojo.res.ArticleDetail; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; @@ -342,14 +343,20 @@ public class UserServiceImpl implements UserService { @Override public List getAllArticleBrief() { - ListidArray = articleMapper.getAllArticleIds(); + List idArray = articleMapper.getAllArticleIds(); ArrayList res = new ArrayList<>(); - for(Integer id : idArray) - { + for (Integer id : idArray) { res.add(this.getArticleBrief(id)); } return res; } + @Override + public ArticleDetail getArticleDetail(Integer articleId) { + ArticleBrief brief = this.getArticleBrief(articleId); + String text = articleMapper.getArticleText(articleId); + return new ArticleDetail(brief, text); + } + } -- Gitee From c794396de35aa059a6dbab65c6863053e4062daa Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 18 May 2024 11:46:58 +0800 Subject: [PATCH 40/59] =?UTF-8?q?ADD:=E8=8E=B7=E5=8F=96=E8=B5=9E=E8=BF=87?= =?UTF-8?q?=E7=9A=84=E3=80=81=E8=AF=84=E8=AE=BA=E8=BF=87=E7=9A=84=E3=80=81?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E7=9A=84=E3=80=81=E5=8E=86=E5=8F=B2=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 32 ++++++++++++-- .../web/project/sharex/mapper/UserMapper.java | 23 ++++------ .../project/sharex/service/UserService.java | 8 ++++ .../sharex/service/impl/UserServiceImpl.java | 43 ++++++++++++++++--- 4 files changed, 83 insertions(+), 23 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 40d7980..187fb05 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -53,13 +53,37 @@ public class UserController { return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); } -/* @GetMapping("/like") - UniversalResponse> getUserLike(){ + @GetMapping("/getHistory") + UniversalResponse> getHistory(){ User current = JWTUtil.getCurrentUser(); - List ret = userService.getUserLike(current.getId()); + List ret = userService.getHistory(current.getId()); ResponseEnum res = ResponseEnum.SUCCESS; return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); - }*/ + } + + @GetMapping("/like") + UniversalResponse> getUserLike(){ + User current = JWTUtil.getCurrentUser(); + List ret = userService.getUserLike(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } + + @GetMapping("/getFavorite") + UniversalResponse> getFavotite(){ + User current = JWTUtil.getCurrentUser(); + List ret = userService.getFavorite(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } + + @GetMapping("/getCommented") + UniversalResponse> getCommented(){ + User current = JWTUtil.getCurrentUser(); + List ret = userService.getCommented(current.getId()); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(), res.getMsg(), ret); + } @GetMapping("/own/articles") UniversalResponse> getOwnArticles() { diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index 97495b3..b6f74b8 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -84,20 +84,6 @@ public interface UserMapper extends BaseMapper { @Select("select count(*) from tb_follow as tbf where tbf.followed_user_id=${current_id};") int getFansCount(Integer current_id); - /* @Select(""" - select a.id as id, - a.author as author, - a.title as title, - a.status as status, - a.publish_time as publish_time, - (select p.path from tb_photo as p where p.reference = a.id and p.photo_type = 1) as cover_photo_path, - tf.time as time - from tb_article as a - inner join tb_like tf on a.id = tf.article_id - where tf.user_id = ${id} - order by tf.time desc;""") - List getUserLike(Integer id);*/ - @Select("select id from tb_user;") List getAllUserId(); @@ -111,4 +97,13 @@ public interface UserMapper extends BaseMapper { @Select("select user_id from tb_follow where followed_user_id=${id};") List getUserFansId(Integer id); + @Select("select article_id from tb_like where user_id=${id};") + List getUserAllLikeId(Integer id); + @Select("select article_id from tb_history where user_id=${id};") + List getUserAllHistoryId(Integer id); + @Select("select article_id from tb_favorite where user_id=${id};") + List getUserAllFavoriteId(Integer id); + @Select("select article_id from tb_comments where user_id=${id};") + List getUserAllCommentedId(Integer id); + } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 46ac267..7b3d621 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -63,4 +63,12 @@ public interface UserService { List getAllArticleBrief(); ArticleDetail getArticleDetail(Integer articleId); + + List getHistory(Integer id); + + List getFavorite(Integer id); + + List getCommented(Integer id); + + List getUserLike(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 45ea017..23797f4 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -284,11 +284,6 @@ public class UserServiceImpl implements UserService { } } - /*@Override - public List getUserLike(Integer id) { - return userMapper.getUserLike(id); - }*/ - @Override public UserRes getUserRes(Integer id) { User currentUser = userMapper.selectById(id); @@ -358,5 +353,43 @@ public class UserServiceImpl implements UserService { return new ArticleDetail(brief, text); } + @Override + public List getHistory(Integer id) { + List allHistoryId=userMapper.getUserAllHistoryId(id); + ArrayList articleBriefs=new ArrayList<>(); + for (Integer integer:allHistoryId){ + articleBriefs.add(this.getArticleBrief(integer)); + } + return articleBriefs; + } + + @Override + public List getFavorite(Integer id) { + List allFavoriteId=userMapper.getUserAllFavoriteId(id); + ArrayList articleBriefs=new ArrayList<>(); + for (Integer integer:allFavoriteId){ + articleBriefs.add(this.getArticleBrief(integer)); + } + return articleBriefs; + } + + @Override + public List getCommented(Integer id) { + List allCommentedId=userMapper.getUserAllCommentedId(id); + ArrayList articleBriefs=new ArrayList<>(); + for (Integer integer:allCommentedId){ + articleBriefs.add(this.getArticleBrief(integer)); + } + return articleBriefs; + } + @Override + public List getUserLike(Integer id) { + List allLikeId = userMapper.getUserAllLikeId(id); + ArrayList articleBriefs = new ArrayList<>(); + for (Integer integer : allLikeId) { + articleBriefs.add(this.getArticleBrief(integer)); + } + return articleBriefs; + } } -- Gitee From 2b4439df30dc3d00f55011c5f0568d4618316530 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 12:13:30 +0800 Subject: [PATCH 41/59] =?UTF-8?q?ADD=EF=BC=9A=E6=96=87=E7=AB=A0=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=8E=E5=88=A0=E9=99=A4=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/util/enums/ArticleStatusEnum.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java index dd1309d..a327288 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ArticleStatusEnum.java @@ -11,7 +11,11 @@ public enum ArticleStatusEnum { NOT_PASS(2), - BAN(3); + BAN(3), + + DRAFT(4), + + DELETED(5); private final Integer code; -- Gitee From 79e6dba1c5b7af5b1213c6ea76e538ca70553acb Mon Sep 17 00:00:00 2001 From: Miemeng Date: Sat, 18 May 2024 13:03:46 +0800 Subject: [PATCH 42/59] =?UTF-8?q?ADD:=20=E7=BB=99=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0/=E5=88=A0=E9=99=A4=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 10 ++++++++ .../sharex/service/impl/UserServiceImpl.java | 24 ++++++++++++++++--- .../sharex/util/enums/ResponseEnum.java | 2 ++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 187fb05..0cb5632 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -252,4 +252,14 @@ public class UserController { userService.getArticleDetail(articleId) ); } + + @PostMapping("/addTagToArticle") + UniversalResponse addTagToArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { + return userService.addTagToArticle(articleId, tagId); + } + + @PostMapping("/deleteTagFromArticle") + UniversalResponse deleteTagFromArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { + return userService.deleteTagFromArticle(articleId, tagId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 23797f4..e833449 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -258,10 +258,19 @@ public class UserServiceImpl implements UserService { @Override public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { - //TODO: check the User's authority to add tag to article + User currentUser = JWTUtil.getCurrentUser(); + Article article = articleMapper.selectById(articleId); + if (article == null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ + return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); + } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } + if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } if (tagMapper.getArticleTag(articleId, tagId) == null) { tagMapper.addArticleTag(articleId, tagId); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); @@ -272,12 +281,21 @@ public class UserServiceImpl implements UserService { @Override public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { - //TODO: check the User's authority to delete tag from article + User currentUser = JWTUtil.getCurrentUser(); + Article article = articleMapper.selectById(articleId); + if (article == null){ + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ + return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); + } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } + if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } if (tagMapper.getArticleTag(articleId, tagId) == null) { - return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); + return new UniversalResponse<>(ResponseEnum.TAG_NOT_IN_ARTICLE.getCode(), ResponseEnum.TAG_NOT_IN_ARTICLE.getMsg()); } else { tagMapper.deleteArticleTag(articleId, tagId); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index b74fc02..8c49b39 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -30,12 +30,14 @@ public enum ResponseEnum { ARTICLE_ALREADY_FAVOURITE(3008, "文章已经被收藏"), ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), ARTICLE_STATUS_IS_NOT_PASS(3010, "本文章当前不可访问"), + Article_CANNOT_EDIT(3011, "文章不可编辑"), //标签错误 TAG_NOT_FOUND(3101, "标签不存在"), TAG_ALREADY_EXISTS(3102, "标签已存在"), TAG_CANNOT_DELETE(3103, "标签不可删除"), + TAG_NOT_IN_ARTICLE(3104, "标签不在文章中"), //文件错误 -- Gitee From 4b5e98ee5658c5db8543d25fb35b2fc26b354e48 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 13:09:11 +0800 Subject: [PATCH 43/59] =?UTF-8?q?ADD=EF=BC=9A=E7=BC=96=E8=BE=91=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 8 ++ .../project/sharex/service/UserService.java | 2 + .../sharex/service/impl/UserServiceImpl.java | 81 ++++++++++++++++--- .../sharex/util/enums/ResponseEnum.java | 2 +- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 187fb05..0c619ce 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -252,4 +252,12 @@ public class UserController { userService.getArticleDetail(articleId) ); } + + @PostMapping("/editArticle") + UniversalResponse editArticle(@RequestParam(required = false) Integer id, + @RequestParam(required = true) Integer type, + @RequestParam(required = false) String title, + @RequestParam(required = false) String content) { + return userService.editArticle(id, type, title, content, JWTUtil.getCurrentUser().getId()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 7b3d621..6f6de1f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -64,6 +64,8 @@ public interface UserService { ArticleDetail getArticleDetail(Integer articleId); + UniversalResponse editArticle(Integer id,Integer type,String title,String content,Integer authorId); + List getHistory(Integer id); List getFavorite(Integer id); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 23797f4..0edbdbf 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -18,7 +18,6 @@ import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.ArticleDetail; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; -import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; @@ -177,7 +176,7 @@ public class UserServiceImpl implements UserService { if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } else if (!article.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { - ResponseEnum res = ResponseEnum.ARTICLE_STATUS_IS_NOT_PASS; + ResponseEnum res = ResponseEnum.ARTICLE_STATUS_ERROR; return new UniversalResponse<>(res.getCode(), res.getMsg()); } Comment newComment = new Comment(); @@ -194,7 +193,7 @@ public class UserServiceImpl implements UserService { if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } else if (!article.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { - ResponseEnum res = ResponseEnum.ARTICLE_STATUS_IS_NOT_PASS; + ResponseEnum res = ResponseEnum.ARTICLE_STATUS_ERROR; return new UniversalResponse<>(res.getCode(), res.getMsg()); } List comments = commentMapper.getArticleComments(articleId); @@ -353,11 +352,68 @@ public class UserServiceImpl implements UserService { return new ArticleDetail(brief, text); } + @Override + public UniversalResponse editArticle(Integer id, Integer type, String title, String content, Integer authorId) { + if (type == 0) { + //上传为草稿 + Article newArticle = new Article(); + newArticle.setText(content); + newArticle.setTitle(title); + newArticle.setAuthor(authorId); + newArticle.setStatus(ArticleStatusEnum.DRAFT.getCode()); + articleMapper.insert(newArticle); + ArticleDetail detail = this.getArticleDetail(newArticle.getId()); + return new UniversalResponse<>( + ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + detail); + } else if (type == 1) { + Article article = articleMapper.selectById(id); + if (article == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), + ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), + ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); + } + if (!title.isEmpty()) { + article.setTitle(title); + } + if (!content.isEmpty()) { + article.setText(content); + } + articleMapper.updateById(article); + ArticleDetail detail = this.getArticleDetail(article.getId()); + return new UniversalResponse<>( + ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + detail); + } else { + // type == 2; + Article article = articleMapper.selectById(id); + if (article == null) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), + ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); + } + if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), + ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); + } + article.setStatus(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode()); + ArticleDetail detail = this.getArticleDetail(article.getId()); + return new UniversalResponse<>( + ResponseEnum.SUCCESS.getCode(), + ResponseEnum.SUCCESS.getMsg(), + detail); + } + } + @Override public List getHistory(Integer id) { - List allHistoryId=userMapper.getUserAllHistoryId(id); - ArrayList articleBriefs=new ArrayList<>(); - for (Integer integer:allHistoryId){ + List allHistoryId = userMapper.getUserAllHistoryId(id); + ArrayList articleBriefs = new ArrayList<>(); + for (Integer integer : allHistoryId) { articleBriefs.add(this.getArticleBrief(integer)); } return articleBriefs; @@ -365,9 +421,9 @@ public class UserServiceImpl implements UserService { @Override public List getFavorite(Integer id) { - List allFavoriteId=userMapper.getUserAllFavoriteId(id); - ArrayList articleBriefs=new ArrayList<>(); - for (Integer integer:allFavoriteId){ + List allFavoriteId = userMapper.getUserAllFavoriteId(id); + ArrayList articleBriefs = new ArrayList<>(); + for (Integer integer : allFavoriteId) { articleBriefs.add(this.getArticleBrief(integer)); } return articleBriefs; @@ -375,13 +431,14 @@ public class UserServiceImpl implements UserService { @Override public List getCommented(Integer id) { - List allCommentedId=userMapper.getUserAllCommentedId(id); - ArrayList articleBriefs=new ArrayList<>(); - for (Integer integer:allCommentedId){ + List allCommentedId = userMapper.getUserAllCommentedId(id); + ArrayList articleBriefs = new ArrayList<>(); + for (Integer integer : allCommentedId) { articleBriefs.add(this.getArticleBrief(integer)); } return articleBriefs; } + @Override public List getUserLike(Integer id) { List allLikeId = userMapper.getUserAllLikeId(id); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index b74fc02..b899683 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -29,7 +29,7 @@ public enum ResponseEnum { ARTICLE_NOT_FOUND(3007, "文章不存在"), ARTICLE_ALREADY_FAVOURITE(3008, "文章已经被收藏"), ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), - ARTICLE_STATUS_IS_NOT_PASS(3010, "本文章当前不可访问"), + ARTICLE_STATUS_ERROR(3010, "文章状态错误"), //标签错误 -- Gitee From 16ae069d75fb6455d4eb45733f1ac2d836c8958f Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 13:17:08 +0800 Subject: [PATCH 44/59] =?UTF-8?q?ADD=EF=BC=9A=E9=94=99=E8=AF=AF=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/service/impl/UserServiceImpl.java | 1 + .../java/web/project/sharex/util/enums/ResponseEnum.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index fa17972..523c220 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -18,6 +18,7 @@ import web.project.sharex.pojo.res.ArticleBriefRes; import web.project.sharex.pojo.res.ArticleDetail; import web.project.sharex.pojo.res.UserRes; import web.project.sharex.service.UserService; +import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; import web.project.sharex.util.enums.PhotoTypeEnum; import web.project.sharex.util.enums.ResponseEnum; diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index b899683..f9a181e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -30,6 +30,7 @@ public enum ResponseEnum { ARTICLE_ALREADY_FAVOURITE(3008, "文章已经被收藏"), ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), ARTICLE_STATUS_ERROR(3010, "文章状态错误"), + Article_CANNOT_EDIT(3011, "文章不可编辑"), //标签错误 @@ -46,9 +47,13 @@ public enum ResponseEnum { USER_PERMISSION_ERROR(5001, "用户没有权限"), CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"), + + //tag错误 + TAG_NOT_IN_ARTICLE(6001, "tag不存在"), + // 用户信息错误 - USER_NOT_FOUND(6001, "用户不存在"); + USER_NOT_FOUND(6001,"用户不存在"); private final Integer code; private final String msg; -- Gitee From 2023f069616a2c82e73585215a4c8902b112d766 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 13:34:27 +0800 Subject: [PATCH 45/59] =?UTF-8?q?ADD=EF=BC=9A=E8=8E=B7=E5=8F=96=E6=96=87?= =?UTF-8?q?=E7=AB=A0tag=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/web/project/sharex/mapper/UserMapper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index b6f74b8..a75ede7 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -4,10 +4,10 @@ import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; +import web.project.sharex.pojo.entity.Tag; import web.project.sharex.pojo.entity.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import web.project.sharex.pojo.res.ArticleBriefRes; -import web.project.sharex.pojo.res.UserRes; import java.util.List; @@ -99,11 +99,22 @@ public interface UserMapper extends BaseMapper { @Select("select article_id from tb_like where user_id=${id};") List getUserAllLikeId(Integer id); + @Select("select article_id from tb_history where user_id=${id};") List getUserAllHistoryId(Integer id); + @Select("select article_id from tb_favorite where user_id=${id};") List getUserAllFavoriteId(Integer id); + @Select("select article_id from tb_comments where user_id=${id};") List getUserAllCommentedId(Integer id); + @Select(""" + select * + from tb_tag + where id in (select link_tag.tag_id + from tb_article_tag as link_tag + where link_tag.article_id = ${articleId})""") + List getArticleTag(Integer articleId); + } -- Gitee From 753297b3b5da5d0555e1112b4b6edc6592eb31ee Mon Sep 17 00:00:00 2001 From: misakamikoto <2624331734@qq.com> Date: Sat, 18 May 2024 13:41:20 +0800 Subject: [PATCH 46/59] =?UTF-8?q?ADD:=E5=88=A0=E9=99=A4=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 15 +++++++++++++++ .../web/project/sharex/service/UserService.java | 2 ++ .../sharex/service/impl/UserServiceImpl.java | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index 0c619ce..b3e762e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,6 +1,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; +import net.bytebuddy.asm.Advice; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -260,4 +261,18 @@ public class UserController { @RequestParam(required = false) String content) { return userService.editArticle(id, type, title, content, JWTUtil.getCurrentUser().getId()); } + + @PostMapping("/deleteArticle") + UniversalResponse deleteArticle(@RequestParam Integer articleId){ + User currentUser= JWTUtil.getCurrentUser(); + if (articleMapper.selectById(articleId)==null){ + ResponseEnum res=ResponseEnum.ARTICLE_NOT_FOUND; + return new UniversalResponse<>(res.getCode(),res.getMsg()); + } + if(!currentUser.getId().equals(articleMapper.selectById(articleId).getAuthor())){ + ResponseEnum res=ResponseEnum.USER_PERMISSION_ERROR; + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + return userService.deleteArticle(articleId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 6f6de1f..4149048 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -73,4 +73,6 @@ public interface UserService { List getCommented(Integer id); List getUserLike(Integer id); + + UniversalResponse deleteArticle(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 523c220..f587be4 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -468,4 +468,21 @@ public class UserServiceImpl implements UserService { return articleBriefs; } + @Override + public UniversalResponse deleteArticle(Integer articleId) { + Article article = articleMapper.selectById(articleId); + if (article.getStatus().equals(ArticleStatusEnum.DELETED.getCode())|| + article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())|| + article.getStatus().equals(ArticleStatusEnum.BAN.getCode())){ + ResponseEnum responseEnum= ResponseEnum.ARTICLE_STATUS_ERROR; + return new UniversalResponse<>(responseEnum.getCode(),responseEnum.getMsg()); + } + else{ + article.setStatus(ArticleStatusEnum.DELETED.getCode()); + articleMapper.updateById(article); + ResponseEnum res = ResponseEnum.SUCCESS; + return new UniversalResponse<>(res.getCode(),res.getMsg()); + } + } + } -- Gitee From 48d9df02bca1f8a4aa2ac5c1864b8edc5337172b Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 13:50:31 +0800 Subject: [PATCH 47/59] =?UTF-8?q?FIX:article=20brief=E6=B7=BB=E5=8A=A0tag?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/mapper/ArticleMapper.java | 10 ++++++++++ .../web/project/sharex/mapper/UserMapper.java | 9 +-------- .../web/project/sharex/pojo/res/ArticleBrief.java | 5 ++++- .../project/sharex/pojo/res/ArticleDetail.java | 6 +++++- .../sharex/service/impl/UserServiceImpl.java | 15 ++++++++------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java index cc44c4a..60a2aeb 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/ArticleMapper.java @@ -6,7 +6,9 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Article; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import web.project.sharex.pojo.entity.Tag; +import java.util.ArrayList; import java.util.List; /** @@ -67,4 +69,12 @@ public interface ArticleMapper extends BaseMapper
{ @Select("select text from tb_article where id=${articleId}") String getArticleText(Integer articleId); + + @Select(""" + select * + from tb_tag + where id in (select link_tag.tag_id + from tb_article_tag as link_tag + where link_tag.article_id = ${articleId})""") + ArrayList getArticleTag(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index a75ede7..11145c9 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -9,6 +9,7 @@ import web.project.sharex.pojo.entity.User; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import web.project.sharex.pojo.res.ArticleBriefRes; +import java.util.ArrayList; import java.util.List; /** @@ -109,12 +110,4 @@ public interface UserMapper extends BaseMapper { @Select("select article_id from tb_comments where user_id=${id};") List getUserAllCommentedId(Integer id); - @Select(""" - select * - from tb_tag - where id in (select link_tag.tag_id - from tb_article_tag as link_tag - where link_tag.article_id = ${articleId})""") - List getArticleTag(Integer articleId); - } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java index e389290..d4ef19c 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleBrief.java @@ -2,6 +2,7 @@ package web.project.sharex.pojo.res; import lombok.Data; import web.project.sharex.pojo.entity.Photo; +import web.project.sharex.pojo.entity.Tag; import java.util.ArrayList; @@ -10,7 +11,7 @@ public class ArticleBrief { private Integer id; - private Integer author; + private UserRes author; private String title; @@ -27,4 +28,6 @@ public class ArticleBrief { private Photo cover; private ArrayList photos; + + private ArrayList tags; } \ No newline at end of file diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java index 06d3edc..81cde10 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java @@ -2,6 +2,7 @@ package web.project.sharex.pojo.res; import lombok.Data; import web.project.sharex.pojo.entity.Photo; +import web.project.sharex.pojo.entity.Tag; import java.util.ArrayList; @@ -9,7 +10,7 @@ import java.util.ArrayList; public class ArticleDetail { private Integer id; - private Integer author; + private UserRes author; private String title; @@ -29,6 +30,8 @@ public class ArticleDetail { private String text; + private ArrayList tags; + public ArticleDetail(ArticleBrief brief, String text) { this.id = brief.getId(); this.author = brief.getAuthor(); @@ -40,6 +43,7 @@ public class ArticleDetail { this.commentNumber = brief.getCommentNumber(); this.cover = brief.getCover(); this.photos = brief.getPhotos(); + this.tags = brief.getTags(); this.text = text; } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 523c220..63b7a65 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -260,15 +260,15 @@ public class UserServiceImpl implements UserService { public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); - }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ + } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } - if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + if (!currentUser.getId().equals(getArticle(articleId).getAuthor())) { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } if (tagMapper.getArticleTag(articleId, tagId) == null) { @@ -283,15 +283,15 @@ public class UserServiceImpl implements UserService { public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); - }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ + } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } - if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + if (!currentUser.getId().equals(getArticle(articleId).getAuthor())) { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } if (tagMapper.getArticleTag(articleId, tagId) == null) { @@ -343,7 +343,7 @@ public class UserServiceImpl implements UserService { ArticleBrief brief = new ArticleBrief(); brief.setId(articleId); brief.setTitle(article.getTitle()); - brief.setAuthor(article.getAuthor()); + brief.setAuthor(this.getUserRes(article.getAuthor())); brief.setStatus(article.getStatus()); brief.setCover(cover); brief.setPhotos(photos); @@ -351,6 +351,7 @@ public class UserServiceImpl implements UserService { brief.setFavoriteNumber(favoriteCounter); brief.setCommentNumber(commentCounter); brief.setPublishTime(article.getPublishTime().toString()); + brief.setTags(articleMapper.getArticleTag(articleId)); return brief; } -- Gitee From 3c3cf796e408b4258db14a88c3af840a997df7e0 Mon Sep 17 00:00:00 2001 From: Miemeng Date: Sat, 18 May 2024 13:53:45 +0800 Subject: [PATCH 48/59] =?UTF-8?q?FIXED:=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/AdminController.java | 7 +++++-- .../sharex/controller/UserController.java | 10 ++++++++-- .../project/sharex/service/AdminService.java | 1 - .../sharex/service/impl/AdminServiceImpl.java | 20 +++++++++++++++---- .../sharex/service/impl/UserServiceImpl.java | 18 ++++++++--------- .../sharex/util/enums/ResponseEnum.java | 15 +++++++------- 6 files changed, 45 insertions(+), 26 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java index 1683282..465cae0 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java @@ -2,6 +2,7 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; +import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.User; import web.project.sharex.service.AdminService; @@ -21,6 +22,8 @@ public class AdminController { AdminService adminService; @Resource UserService userService; + @Resource + ArticleMapper articleMapper; @PostMapping("/approve") UniversalResponse approveArticle(@RequestParam Integer id, @RequestParam Boolean result,@RequestParam String reason){ User current = JWTUtil.getCurrentUser(); @@ -28,7 +31,7 @@ public class AdminController { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } Article currentArticle; - currentArticle = adminService.getArticle(id); + currentArticle = articleMapper.selectById(id); if (currentArticle.getStatus().equals(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode())){ if (result){ currentArticle.setStatus(ArticleStatusEnum.PASS.getCode()); @@ -59,7 +62,7 @@ public class AdminController { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } Article currentArticle; - currentArticle = adminService.getArticle(id); + currentArticle = articleMapper.selectById(id); if (currentArticle.getStatus().equals(ArticleStatusEnum.BAN.getCode())){ return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_BANNED.getCode(),ResponseEnum.ARTICLE_ALREADY_BANNED.getMsg()); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index b3e762e..e77965e 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -1,13 +1,11 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; -import net.bytebuddy.asm.Advice; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import web.project.sharex.mapper.UserMapper; import web.project.sharex.mapper.ArticleMapper; -import web.project.sharex.mapper.UserMapper; import web.project.sharex.pojo.entity.*; import web.project.sharex.pojo.res.ArticleBrief; import web.project.sharex.pojo.res.ArticleBriefRes; @@ -275,4 +273,12 @@ public class UserController { } return userService.deleteArticle(articleId); } + @PostMapping("/addTagToArticle") + UniversalResponse addTagToArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { + return userService.addTagToArticle(articleId, tagId); + } + @PostMapping("/deleteTagFromArticle") + UniversalResponse deleteTagFromArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { + return userService.deleteTagFromArticle(articleId, tagId); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java index dfc1be8..2785ba7 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/AdminService.java @@ -6,7 +6,6 @@ import web.project.sharex.util.response.UniversalResponse; public interface AdminService { - Article getArticle(Integer id); void updateArticle(Integer id,Article article); UniversalResponse addTag(String tag); UniversalResponse deleteTag(int tagId); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java index d9e637b..ecc0e66 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/AdminServiceImpl.java @@ -5,10 +5,15 @@ import org.springframework.stereotype.Service; import web.project.sharex.mapper.ArticleMapper; import web.project.sharex.mapper.TagMapper; import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.User; import web.project.sharex.service.AdminService; +import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ResponseEnum; +import web.project.sharex.util.enums.UserTypeEnum; import web.project.sharex.util.response.UniversalResponse; +import java.util.Objects; + @Service public class AdminServiceImpl implements AdminService { @@ -16,10 +21,6 @@ public class AdminServiceImpl implements AdminService { TagMapper tagMapper; @Resource ArticleMapper articleMapper; - - public Article getArticle(Integer id) { - return articleMapper.selectById(id); - } public void updateArticle(Integer id,Article updatedArticle) { Article oldArticle = articleMapper.selectById(id); oldArticle.setStatus(updatedArticle.getStatus()); @@ -28,6 +29,13 @@ public class AdminServiceImpl implements AdminService { } @Override public UniversalResponse addTag(String tag){ + if(tag.isEmpty()){ + return new UniversalResponse<>(ResponseEnum.EMPTY_FIELD.getCode(), ResponseEnum.EMPTY_FIELD.getMsg()); + } + User currentUser = JWTUtil.getCurrentUser(); + if(!Objects.equals(currentUser.getType(), UserTypeEnum.ADMIN.getTypeCode())){ + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } int tagCount = tagMapper.countTag(); if(tagMapper.getTagByName(tag) == null){ tagMapper.insertTag(tag, tagCount+1); @@ -38,6 +46,10 @@ public class AdminServiceImpl implements AdminService { } @Override public UniversalResponse deleteTag(int tagId) { + User currentUser = JWTUtil.getCurrentUser(); + if(!Objects.equals(currentUser.getType(), UserTypeEnum.ADMIN.getTypeCode())){ + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + } if(tagMapper.getTagById(tagId) == null){ return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index f587be4..f4962e7 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -260,15 +260,15 @@ public class UserServiceImpl implements UserService { public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); - }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ - return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); + } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } - if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + if (!currentUser.getId().equals(article.getAuthor())) { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } if (tagMapper.getArticleTag(articleId, tagId) == null) { @@ -283,19 +283,19 @@ public class UserServiceImpl implements UserService { public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); - }else if(!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())){ - return new UniversalResponse<>(ResponseEnum.Article_CANNOT_EDIT.getCode(), ResponseEnum.Article_CANNOT_EDIT.getMsg()); + } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); } if (tagMapper.selectById(tagId) == null) { return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } - if(!currentUser.getId().equals(getArticle(articleId).getAuthor())){ + if (!currentUser.getId().equals(article.getAuthor())) { return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } if (tagMapper.getArticleTag(articleId, tagId) == null) { - return new UniversalResponse<>(ResponseEnum.TAG_NOT_IN_ARTICLE.getCode(), ResponseEnum.TAG_NOT_IN_ARTICLE.getMsg()); + return new UniversalResponse<>(ResponseEnum.TAG_NOT_FOUND.getCode(), ResponseEnum.TAG_NOT_FOUND.getMsg()); } else { tagMapper.deleteArticleTag(articleId, tagId); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index f9a181e..64b2512 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -30,13 +30,12 @@ public enum ResponseEnum { ARTICLE_ALREADY_FAVOURITE(3008, "文章已经被收藏"), ARTICLE_ALREADY_LIKE(3009, "文章已经被点赞"), ARTICLE_STATUS_ERROR(3010, "文章状态错误"), - Article_CANNOT_EDIT(3011, "文章不可编辑"), //标签错误 TAG_NOT_FOUND(3101, "标签不存在"), TAG_ALREADY_EXISTS(3102, "标签已存在"), - TAG_CANNOT_DELETE(3103, "标签不可删除"), + TAG_CANNOT_DELETE(3103, "标签无法删除"), //文件错误 @@ -46,14 +45,14 @@ public enum ResponseEnum { USER_PERMISSION_ERROR(5001, "用户没有权限"), CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"), - - - //tag错误 - TAG_NOT_IN_ARTICLE(6001, "tag不存在"), - // 用户信息错误 - USER_NOT_FOUND(6001,"用户不存在"); + USER_NOT_FOUND(6001,"用户不存在"), + + // 其他错误 + EMPTY_FIELD(7001, "字段不能为空"), + INVALID_FIELD(7002, "字段格式错误"), + OTHER_ERROR(9999, "未知错误"); private final Integer code; private final String msg; -- Gitee From fe34b35babf05fae3aef6c0a6abb4e3470683b9d Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 14:20:52 +0800 Subject: [PATCH 49/59] ADD: CommentDetail --- .../project/sharex/mapper/CommentMapper.java | 4 +- .../sharex/pojo/res/ArticleDetail.java | 5 +- .../sharex/pojo/res/CommentDetail.java | 18 +++++++ .../project/sharex/service/UserService.java | 10 ++-- .../sharex/service/impl/UserServiceImpl.java | 48 +++++++++++++------ 5 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/res/CommentDetail.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java index 0d8dfec..44294b6 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/CommentMapper.java @@ -6,11 +6,11 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import web.project.sharex.pojo.entity.Comment; -import java.util.List; +import java.util.ArrayList; @Mapper public interface CommentMapper extends BaseMapper { @Select("select * from tb_comments where article_id = ${articleId} order by publish_time desc;") - List getArticleComments(int articleId); + ArrayList getArticleComments(int articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java index 81cde10..55427f2 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/ArticleDetail.java @@ -32,7 +32,9 @@ public class ArticleDetail { private ArrayList tags; - public ArticleDetail(ArticleBrief brief, String text) { + private ArrayList commentDetails; + + public ArticleDetail(ArticleBrief brief, String text, ArrayList commentDetails) { this.id = brief.getId(); this.author = brief.getAuthor(); this.title = brief.getTitle(); @@ -45,5 +47,6 @@ public class ArticleDetail { this.photos = brief.getPhotos(); this.tags = brief.getTags(); this.text = text; + this.commentDetails = commentDetails; } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/CommentDetail.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/CommentDetail.java new file mode 100644 index 0000000..74041fd --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/res/CommentDetail.java @@ -0,0 +1,18 @@ +package web.project.sharex.pojo.res; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class CommentDetail { + private Integer id; + + private UserRes userInfo; + + private Integer articleId; + + private String comment; + + private LocalDateTime publishTime; +} diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java index 4149048..4514dc2 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/UserService.java @@ -1,12 +1,10 @@ package web.project.sharex.service; import web.project.sharex.pojo.entity.*; -import web.project.sharex.pojo.res.ArticleBrief; -import web.project.sharex.pojo.res.ArticleBriefRes; -import web.project.sharex.pojo.res.ArticleDetail; -import web.project.sharex.pojo.res.UserRes; +import web.project.sharex.pojo.res.*; import web.project.sharex.util.response.UniversalResponse; +import java.util.ArrayList; import java.util.List; public interface UserService { @@ -75,4 +73,8 @@ public interface UserService { List getUserLike(Integer id); UniversalResponse deleteArticle(Integer articleId); + + CommentDetail getCommentDetail(Integer commentId); + + ArrayList getArticleCommentDetail(Integer articleId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index bdc2af6..0b1dd56 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -13,10 +13,7 @@ import web.project.sharex.pojo.entity.Comment; import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.pojo.entity.Tag; -import web.project.sharex.pojo.res.ArticleBrief; -import web.project.sharex.pojo.res.ArticleBriefRes; -import web.project.sharex.pojo.res.ArticleDetail; -import web.project.sharex.pojo.res.UserRes; +import web.project.sharex.pojo.res.*; import web.project.sharex.service.UserService; import web.project.sharex.util.JWTUtil; import web.project.sharex.util.enums.ArticleStatusEnum; @@ -260,7 +257,7 @@ public class UserServiceImpl implements UserService { public UniversalResponse addTagToArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); @@ -283,7 +280,7 @@ public class UserServiceImpl implements UserService { public UniversalResponse deleteTagFromArticle(Integer articleId, Integer tagId) { User currentUser = JWTUtil.getCurrentUser(); Article article = articleMapper.selectById(articleId); - if (article == null){ + if (article == null) { return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_FOUND.getCode(), ResponseEnum.ARTICLE_NOT_FOUND.getMsg()); } else if (!article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { return new UniversalResponse<>(ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); @@ -369,7 +366,7 @@ public class UserServiceImpl implements UserService { public ArticleDetail getArticleDetail(Integer articleId) { ArticleBrief brief = this.getArticleBrief(articleId); String text = articleMapper.getArticleText(articleId); - return new ArticleDetail(brief, text); + return new ArticleDetail(brief, text, this.getArticleCommentDetail(articleId)); } @Override @@ -472,18 +469,39 @@ public class UserServiceImpl implements UserService { @Override public UniversalResponse deleteArticle(Integer articleId) { Article article = articleMapper.selectById(articleId); - if (article.getStatus().equals(ArticleStatusEnum.DELETED.getCode())|| - article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())|| - article.getStatus().equals(ArticleStatusEnum.BAN.getCode())){ - ResponseEnum responseEnum= ResponseEnum.ARTICLE_STATUS_ERROR; - return new UniversalResponse<>(responseEnum.getCode(),responseEnum.getMsg()); - } - else{ + if (article.getStatus().equals(ArticleStatusEnum.DELETED.getCode()) || + article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode()) || + article.getStatus().equals(ArticleStatusEnum.BAN.getCode())) { + ResponseEnum responseEnum = ResponseEnum.ARTICLE_STATUS_ERROR; + return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg()); + } else { article.setStatus(ArticleStatusEnum.DELETED.getCode()); articleMapper.updateById(article); ResponseEnum res = ResponseEnum.SUCCESS; - return new UniversalResponse<>(res.getCode(),res.getMsg()); + return new UniversalResponse<>(res.getCode(), res.getMsg()); + } + } + + @Override + public CommentDetail getCommentDetail(Integer commentId) { + Comment comment = commentMapper.selectById(commentId); + CommentDetail newCommentDetail = new CommentDetail(); + newCommentDetail.setUserInfo(this.getUserRes(comment.getUserId())); + newCommentDetail.setComment(comment.getComment()); + newCommentDetail.setArticleId(comment.getArticleId()); + newCommentDetail.setId(commentId); + newCommentDetail.setPublishTime(comment.getPublishTime()); + return newCommentDetail; + } + + @Override + public ArrayList getArticleCommentDetail(Integer articleId) { + ArrayList comments = commentMapper.getArticleComments(articleId); + ArrayList res = new ArrayList<>(); + for (Comment comment : comments) { + res.add(this.getCommentDetail(comment.getId())); } + return res; } } -- Gitee From 626b99613e4998ff3637a2008f989f1455610807 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 14:48:58 +0800 Subject: [PATCH 50/59] =?UTF-8?q?ADD:=20=E5=88=A0=E9=99=A4=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/FileController.java | 26 +++++++++++++++++++ .../project/sharex/mapper/PhotoMapper.java | 9 +++++++ .../project/sharex/service/FileService.java | 2 ++ .../sharex/service/impl/FileServiceImpl.java | 5 ++++ .../sharex/util/enums/ResponseEnum.java | 8 ++++-- 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java index 8a4dec6..4828aca 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/FileController.java @@ -2,11 +2,17 @@ package web.project.sharex.controller; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import web.project.sharex.mapper.PhotoMapper; +import web.project.sharex.pojo.entity.Article; +import web.project.sharex.pojo.entity.Photo; import web.project.sharex.pojo.entity.User; import web.project.sharex.service.FileService; import web.project.sharex.util.JWTUtil; +import web.project.sharex.util.enums.ArticleStatusEnum; +import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; @RestController @@ -15,6 +21,8 @@ public class FileController { @Resource private FileService fileService; + @Autowired + private PhotoMapper photoMapper; @PostMapping("/upload/profilePhoto") public UniversalResponse uploadProfilePhoto(@RequestParam("file") MultipartFile file) { @@ -29,4 +37,22 @@ public class FileController { User currentUser = JWTUtil.getCurrentUser(); return fileService.uploadArticlePhoto(file, currentUser.getId(), articleId, photoType); } + + @PostMapping("/delete/articlePhoto") + public UniversalResponse deleteArticlePhoto(@RequestParam Integer id) { + Article currentArticle = photoMapper.getArticleFromPhoto(id); + if (currentArticle == null) { + ResponseEnum resp = ResponseEnum.INVALID_IMAGE; + return new UniversalResponse<>(resp.getCode(), resp.getMsg()); + } + if (!currentArticle.getStatus().equals(ArticleStatusEnum.DRAFT.getCode())) { + return new UniversalResponse<>( + ResponseEnum.ARTICLE_STATUS_ERROR.getCode(), + ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); + } + Photo photo = photoMapper.selectById(id); + photoMapper.deleteById(photo); + ResponseEnum resp = ResponseEnum.SUCCESS; + return new UniversalResponse<>(resp.getCode(), resp.getMsg()); + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java index 3de5787..a7170f5 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/PhotoMapper.java @@ -2,6 +2,7 @@ package web.project.sharex.mapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; +import web.project.sharex.pojo.entity.Article; import web.project.sharex.pojo.entity.Photo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -27,4 +28,12 @@ public interface PhotoMapper extends BaseMapper { @Select("select * from tb_photo where reference=${articleId} and photo_type !=1;") ArrayList getPhotos(Integer articleId); + + @Select(""" + select * + from tb_article + where id in (select reference + from tb_photo + where id = ${photoId})""") + Article getArticleFromPhoto(Integer photoId); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java index 7c0f586..2daa34f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/FileService.java @@ -10,4 +10,6 @@ public interface FileService { UniversalResponse uploadProfilePhoto(MultipartFile file, Integer userId); UniversalResponse uploadArticlePhoto(MultipartFile file, Integer userId, Integer articleId, Integer photoType); + + UniversalResponse deleteArticlePhoto(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java index 4986571..7eb63ad 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -151,4 +151,9 @@ public class FileServiceImpl implements FileService { } return new UniversalResponse<>(resEnum.getCode(), resEnum.getMsg()); } + + @Override + public UniversalResponse deleteArticlePhoto(Integer id) { + + } } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java index 64b2512..b546722 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/util/enums/ResponseEnum.java @@ -47,12 +47,16 @@ public enum ResponseEnum { CANNOT_DO_TO_YOURSELF(5002, "不能对自己操作"), // 用户信息错误 - USER_NOT_FOUND(6001,"用户不存在"), + USER_NOT_FOUND(6001, "用户不存在"), // 其他错误 EMPTY_FIELD(7001, "字段不能为空"), INVALID_FIELD(7002, "字段格式错误"), - OTHER_ERROR(9999, "未知错误"); + OTHER_ERROR(9999, "未知错误"), + + // 图片错误 + + INVALID_IMAGE(8001, "图片无效"); private final Integer code; private final String msg; -- Gitee From c3734d45c41745aa40f0a8a7287a64b5b091f5e9 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Sat, 18 May 2024 14:49:31 +0800 Subject: [PATCH 51/59] =?UTF-8?q?ADD:=20=E5=88=A0=E9=99=A4=E5=9B=BE?= =?UTF-8?q?=E7=89=872?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/web/project/sharex/service/impl/FileServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java index 7eb63ad..a41ae9b 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/FileServiceImpl.java @@ -154,6 +154,6 @@ public class FileServiceImpl implements FileService { @Override public UniversalResponse deleteArticlePhoto(Integer id) { - + return null; } } -- Gitee From 81e98a78c01294294b989d454371a91a86572eb2 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 12:04:27 +0800 Subject: [PATCH 52/59] =?UTF-8?q?ADD:=E6=9B=B4=E6=96=B0mysql=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end/Share-X/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/resources/application.yml b/back-end/Share-X/src/main/resources/application.yml index 7743c3f..3b120ca 100644 --- a/back-end/Share-X/src/main/resources/application.yml +++ b/back-end/Share-X/src/main/resources/application.yml @@ -13,7 +13,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://8.130.23.148:3306/web_project username: fsy - password: 300227QWEqwe! + password: 300227 aliyun: -- Gitee From 9ae136bf637678af26622d56e07bc8c820480f3b Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 18:17:46 +0800 Subject: [PATCH 53/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E6=9B=B4=E6=94=B9=E4=B8=80=E9=83=A8=E5=88=86=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=9A=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/UserController.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java index e77965e..066fc51 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/UserController.java @@ -53,7 +53,7 @@ public class UserController { } @GetMapping("/getHistory") - UniversalResponse> getHistory(){ + UniversalResponse> getHistory() { User current = JWTUtil.getCurrentUser(); List ret = userService.getHistory(current.getId()); ResponseEnum res = ResponseEnum.SUCCESS; @@ -61,7 +61,7 @@ public class UserController { } @GetMapping("/like") - UniversalResponse> getUserLike(){ + UniversalResponse> getUserLike() { User current = JWTUtil.getCurrentUser(); List ret = userService.getUserLike(current.getId()); ResponseEnum res = ResponseEnum.SUCCESS; @@ -69,7 +69,7 @@ public class UserController { } @GetMapping("/getFavorite") - UniversalResponse> getFavotite(){ + UniversalResponse> getFavotite() { User current = JWTUtil.getCurrentUser(); List ret = userService.getFavorite(current.getId()); ResponseEnum res = ResponseEnum.SUCCESS; @@ -77,7 +77,7 @@ public class UserController { } @GetMapping("/getCommented") - UniversalResponse> getCommented(){ + UniversalResponse> getCommented() { User current = JWTUtil.getCurrentUser(); List ret = userService.getCommented(current.getId()); ResponseEnum res = ResponseEnum.SUCCESS; @@ -202,21 +202,23 @@ public class UserController { @RequestParam(value = "email", required = false) String email, @RequestParam(value = "profile_photo", required = false) MultipartFile profile_photo ) { - if (nickname.isEmpty() && password.isEmpty() && email.isEmpty() && profile_photo.isEmpty()) { - ResponseEnum res = ResponseEnum.FAILED; - return new UniversalResponse<>(res.getCode(), res.getMsg()); - } User user = JWTUtil.getCurrentUser(); - if (!nickname.isEmpty()) { - user.setNickname(nickname); + if (nickname != null && !nickname.isEmpty()) { + if (!user.getNickname().equals(nickname)) { + user.setNickname(nickname); + } } - if (!password.isEmpty()) { - user.setEmail(password); + if (password != null && !password.isEmpty()) { + if (!user.getPassword().equals(password)) { + user.setPassword(password); + } } - if (!email.isEmpty()) { - user.setEmail(email); + if (email != null && !email.isEmpty()) { + if(!user.getEmail().equals(email)) { + user.setEmail(email); + } } - if (!profile_photo.isEmpty()) { + if (profile_photo != null && !profile_photo.isEmpty()) { String url = ""; try { url = fileService.upload(profile_photo); @@ -261,22 +263,24 @@ public class UserController { } @PostMapping("/deleteArticle") - UniversalResponse deleteArticle(@RequestParam Integer articleId){ - User currentUser= JWTUtil.getCurrentUser(); - if (articleMapper.selectById(articleId)==null){ - ResponseEnum res=ResponseEnum.ARTICLE_NOT_FOUND; - return new UniversalResponse<>(res.getCode(),res.getMsg()); + UniversalResponse deleteArticle(@RequestParam Integer articleId) { + User currentUser = JWTUtil.getCurrentUser(); + if (articleMapper.selectById(articleId) == null) { + ResponseEnum res = ResponseEnum.ARTICLE_NOT_FOUND; + return new UniversalResponse<>(res.getCode(), res.getMsg()); } - if(!currentUser.getId().equals(articleMapper.selectById(articleId).getAuthor())){ - ResponseEnum res=ResponseEnum.USER_PERMISSION_ERROR; + if (!currentUser.getId().equals(articleMapper.selectById(articleId).getAuthor())) { + ResponseEnum res = ResponseEnum.USER_PERMISSION_ERROR; return new UniversalResponse<>(res.getCode(), res.getMsg()); } return userService.deleteArticle(articleId); } + @PostMapping("/addTagToArticle") UniversalResponse addTagToArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { return userService.addTagToArticle(articleId, tagId); } + @PostMapping("/deleteTagFromArticle") UniversalResponse deleteTagFromArticle(@RequestParam Integer articleId, @RequestParam Integer tagId) { return userService.deleteTagFromArticle(articleId, tagId); -- Gitee From 0f9e788154dd70c1fc40d8b2b377e73f7aef81cb Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 18:49:33 +0800 Subject: [PATCH 54/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=94=A8=E6=88=B7=E8=AF=84=E8=AE=BA=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=BC=9A=E8=BF=94=E5=9B=9E=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E7=AF=87=E6=96=87=E7=AB=A0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/web/project/sharex/mapper/UserMapper.java | 2 +- .../java/web/project/sharex/service/impl/UserServiceImpl.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java index 11145c9..9553ab1 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/UserMapper.java @@ -107,7 +107,7 @@ public interface UserMapper extends BaseMapper { @Select("select article_id from tb_favorite where user_id=${id};") List getUserAllFavoriteId(Integer id); - @Select("select article_id from tb_comments where user_id=${id};") + @Select("select article_id from tb_comments where user_id=${id} order by publish_time desc;") List getUserAllCommentedId(Integer id); } diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 0b1dd56..e70d592 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -22,6 +22,7 @@ import web.project.sharex.util.enums.ResponseEnum; import web.project.sharex.util.response.UniversalResponse; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; @Service @@ -449,8 +450,9 @@ public class UserServiceImpl implements UserService { @Override public List getCommented(Integer id) { List allCommentedId = userMapper.getUserAllCommentedId(id); + LinkedHashSet set1 = new LinkedHashSet<>(allCommentedId); ArrayList articleBriefs = new ArrayList<>(); - for (Integer integer : allCommentedId) { + for (Integer integer : set1) { articleBriefs.add(this.getArticleBrief(integer)); } return articleBriefs; -- Gitee From 43ad69e39f7ceb39f5ad8c397b655552344a22d0 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 20:52:45 +0800 Subject: [PATCH 55/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E7=8A=B6=E6=80=81=E7=9A=84=E6=96=87=E7=AB=A0=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=88=A0=E9=99=A4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/web/project/sharex/service/impl/UserServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index e70d592..5bf9507 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -472,7 +472,6 @@ public class UserServiceImpl implements UserService { public UniversalResponse deleteArticle(Integer articleId) { Article article = articleMapper.selectById(articleId); if (article.getStatus().equals(ArticleStatusEnum.DELETED.getCode()) || - article.getStatus().equals(ArticleStatusEnum.DRAFT.getCode()) || article.getStatus().equals(ArticleStatusEnum.BAN.getCode())) { ResponseEnum responseEnum = ResponseEnum.ARTICLE_STATUS_ERROR; return new UniversalResponse<>(responseEnum.getCode(), responseEnum.getMsg()); -- Gitee From 41ab12ff2ffbe8f39ba2c95a23b7e26403a49ea2 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 21:00:29 +0800 Subject: [PATCH 56/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86tag1?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E4=BA=8E=E6=96=87=E7=AB=A0=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E6=97=A0=E6=B3=95=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/web/project/sharex/mapper/TagMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java index cba3cdb..b07b867 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java @@ -29,7 +29,7 @@ public interface TagMapper extends BaseMapper { void deleteTag(int tagId); @Select("SELECT * FROM tb_article_tag WHERE article_id = #{tagId} AND tag_id = #{tagId}") - Boolean getArticleTag(int articleId,int tagId); + Tag getArticleTag(int articleId,int tagId); @Insert("INSERT INTO tb_article_tag (article_id,tag_id) VALUES (#{articleId},#{tagId})") void addArticleTag(int articleId,int tagId); @Delete("DELETE FROM tb_article_tag WHERE article_id = #{articleId} AND tag_id = #{tagId}") -- Gitee From 9634cf4f0bda18ed2c01b0019426d874e75e5c83 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 21:28:58 +0800 Subject: [PATCH 57/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BA=86?= =?UTF-8?q?=E5=88=A0=E9=99=A4tag=E6=97=B6=EF=BC=8C=E6=98=BE=E7=A4=BAtag?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/project/sharex/mapper/TagMapper.java | 40 +++++++++++-------- .../sharex/pojo/entity/TagArticle.java | 9 +++++ 2 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/TagArticle.java diff --git a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java index b07b867..0e46bf6 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/mapper/TagMapper.java @@ -3,6 +3,7 @@ package web.project.sharex.mapper; import org.apache.ibatis.annotations.*; import web.project.sharex.pojo.entity.Tag; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import web.project.sharex.pojo.entity.TagArticle; import web.project.sharex.pojo.res.ArticleBriefRes; import java.util.List; @@ -19,36 +20,43 @@ import java.util.List; public interface TagMapper extends BaseMapper { @Select("SELECT * FROM tb_tag WHERE name = #{tagName}") Tag getTagByName(String tagName); + @Select("SELECT COUNT(*) FROM tb_tag") int countTag(); + @Select("SELECT * FROM tb_tag") List getAllTags(); + @Insert("INSERT INTO tb_tag (id,name) VALUES (#{tagId},#{tagName})") - void insertTag(String tagName,int tagId); + void insertTag(String tagName, int tagId); + @Delete("DELETE FROM tb_tag WHERE id = #{tagId}") void deleteTag(int tagId); - @Select("SELECT * FROM tb_article_tag WHERE article_id = #{tagId} AND tag_id = #{tagId}") - Tag getArticleTag(int articleId,int tagId); + @Select("SELECT * FROM tb_article_tag WHERE tag_id = ${tagId} and article_id = ${articleId};") + TagArticle getArticleTag(Integer articleId, Integer tagId); + @Insert("INSERT INTO tb_article_tag (article_id,tag_id) VALUES (#{articleId},#{tagId})") - void addArticleTag(int articleId,int tagId); + void addArticleTag(int articleId, int tagId); + @Delete("DELETE FROM tb_article_tag WHERE article_id = #{articleId} AND tag_id = #{tagId}") - void deleteArticleTag(int articleId,int tagId); + void deleteArticleTag(int articleId, int tagId); @Select(""" - SELECT tb_tag.name,tb_tag.id - FROM tb_article_tag - INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id - WHERE tb_article_tag.article_id = #{articleId} - """) + SELECT tb_tag.name,tb_tag.id + FROM tb_article_tag + INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id + WHERE tb_article_tag.article_id = #{articleId} + """) List getTagsByArticle(int articleId); + @Select(""" - SELECT tb_article.id,author,title,status,publish_time - FROM tb_article - INNER JOIN tb_article_tag ON tb_article.id = tb_article_tag.article_id - INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id - WHERE tb_tag.id = #{tagId} AND tb_article.status = 1 - """) + SELECT tb_article.id,author,title,status,publish_time + FROM tb_article + INNER JOIN tb_article_tag ON tb_article.id = tb_article_tag.article_id + INNER JOIN tb_tag ON tb_article_tag.tag_id = tb_tag.id + WHERE tb_tag.id = #{tagId} AND tb_article.status = 1 + """) List getArticlesByTag(int tagId); @Select("SELECT COUNT(*) FROM tb_article_tag WHERE tag_id = #{tagId}") diff --git a/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/TagArticle.java b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/TagArticle.java new file mode 100644 index 0000000..2d265ef --- /dev/null +++ b/back-end/Share-X/src/main/java/web/project/sharex/pojo/entity/TagArticle.java @@ -0,0 +1,9 @@ +package web.project.sharex.pojo.entity; + +import lombok.Data; + +@Data +public class TagArticle { + private int articleId; + private int tagId; +} -- Gitee From 218d110362b3e91705e3137dab7225a9161847ea Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 22:08:39 +0800 Subject: [PATCH 58/59] =?UTF-8?q?FIX:=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E6=97=A0=E6=B3=95=E6=8F=90=E4=BA=A4=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/web/project/sharex/service/impl/UserServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java index 5bf9507..5a0f9d5 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/service/impl/UserServiceImpl.java @@ -419,6 +419,7 @@ public class UserServiceImpl implements UserService { ResponseEnum.ARTICLE_STATUS_ERROR.getMsg()); } article.setStatus(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode()); + articleMapper.updateById(article); ArticleDetail detail = this.getArticleDetail(article.getId()); return new UniversalResponse<>( ResponseEnum.SUCCESS.getCode(), -- Gitee From 3daef2090262bd43c1f65d1a6ac2068d1cdea991 Mon Sep 17 00:00:00 2001 From: XenoWYC121 <1299288319@qq.com> Date: Tue, 21 May 2024 22:13:51 +0800 Subject: [PATCH 59/59] =?UTF-8?q?FIX:=E5=B0=86=E5=AE=A1=E6=89=B9=E6=8B=92?= =?UTF-8?q?=E7=BB=9D=E8=AF=B7=E6=B1=82=E8=AE=BE=E7=BD=AE=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sharex/controller/AdminController.java | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java index 465cae0..cbfab7f 100644 --- a/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java +++ b/back-end/Share-X/src/main/java/web/project/sharex/controller/AdminController.java @@ -14,7 +14,6 @@ import web.project.sharex.util.enums.UserTypeEnum; import web.project.sharex.util.response.UniversalResponse; - @RestController @RequestMapping("/admin") public class AdminController { @@ -24,77 +23,73 @@ public class AdminController { UserService userService; @Resource ArticleMapper articleMapper; + @PostMapping("/approve") - UniversalResponse approveArticle(@RequestParam Integer id, @RequestParam Boolean result,@RequestParam String reason){ + UniversalResponse approveArticle(@RequestParam Integer id, @RequestParam Boolean result, @RequestParam(required = false) String reason) { User current = JWTUtil.getCurrentUser(); if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { - return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } Article currentArticle; currentArticle = articleMapper.selectById(id); - if (currentArticle.getStatus().equals(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode())){ - if (result){ + if (currentArticle.getStatus().equals(ArticleStatusEnum.WAITING_FOR_APPROVAL.getCode())) { + if (result) { currentArticle.setStatus(ArticleStatusEnum.PASS.getCode()); - adminService.updateArticle(id,currentArticle); + adminService.updateArticle(id, currentArticle); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); - } - else { + } else { currentArticle.setStatus(ArticleStatusEnum.NOT_PASS.getCode()); - if(reason.isEmpty()){ - return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getCode(),ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getMsg()); - } - else { + if (reason == null || reason.isEmpty()) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getCode(), ResponseEnum.ARTICLE_NOT_PASS_WITHOUT_REASON.getMsg()); + } else { currentArticle.setAdditionalInfo(reason); adminService.updateArticle(id, currentArticle); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } } - } - else { - return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_APPROVED.getCode(),ResponseEnum.ARTICLE_ALREADY_APPROVED.getMsg()); + } else { + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_APPROVED.getCode(), ResponseEnum.ARTICLE_ALREADY_APPROVED.getMsg()); } } @PostMapping("/banArticle") - UniversalResponse banArticle(@RequestParam Integer id,@RequestParam String reason){ + UniversalResponse banArticle(@RequestParam Integer id, @RequestParam String reason) { User current = JWTUtil.getCurrentUser(); if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { - return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } Article currentArticle; currentArticle = articleMapper.selectById(id); - if (currentArticle.getStatus().equals(ArticleStatusEnum.BAN.getCode())){ - return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_BANNED.getCode(),ResponseEnum.ARTICLE_ALREADY_BANNED.getMsg()); - } - else if (currentArticle.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { - if (reason.isEmpty()){ + if (currentArticle.getStatus().equals(ArticleStatusEnum.BAN.getCode())) { + return new UniversalResponse<>(ResponseEnum.ARTICLE_ALREADY_BANNED.getCode(), ResponseEnum.ARTICLE_ALREADY_BANNED.getMsg()); + } else if (currentArticle.getStatus().equals(ArticleStatusEnum.PASS.getCode())) { + if (reason.isEmpty()) { return new UniversalResponse<>(ResponseEnum.ARTICLE_BAN_WITHOUT_REASON.getCode(), ResponseEnum.ARTICLE_BAN_WITHOUT_REASON.getMsg()); - } - else { + } else { currentArticle.setStatus(ArticleStatusEnum.BAN.getCode()); currentArticle.setAdditionalInfo(reason); adminService.updateArticle(id, currentArticle); return new UniversalResponse<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg()); } - } - else { + } else { return new UniversalResponse<>(ResponseEnum.ARTICLE_CANNOT_BAN.getCode(), ResponseEnum.ARTICLE_CANNOT_BAN.getMsg()); } } @PostMapping("/addTag") - UniversalResponse addTag(@RequestParam String tag){ + UniversalResponse addTag(@RequestParam String tag) { User current = JWTUtil.getCurrentUser(); if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { - return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } return adminService.addTag(tag); } + @PostMapping("/deleteTag") UniversalResponse deleteTag(@RequestParam int tagId) { User current = JWTUtil.getCurrentUser(); if (!current.getType().equals(UserTypeEnum.ADMIN.getTypeCode())) { - return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(),ResponseEnum.USER_PERMISSION_ERROR.getMsg()); + return new UniversalResponse<>(ResponseEnum.USER_PERMISSION_ERROR.getCode(), ResponseEnum.USER_PERMISSION_ERROR.getMsg()); } return adminService.deleteTag(tagId); } -- Gitee