diff --git a/campus_sec_deal.sql b/campus_sec_deal.sql
new file mode 100644
index 0000000..af0cde0
--- /dev/null
+++ b/campus_sec_deal.sql
@@ -0,0 +1,127 @@
+# 校园二手交易平台------campus_sec_deal--------------------------------------------
+# 作者: Colyn 日期: 2022-09-12
+# 数据库: MySQL 编码: utf8mb4 引擎: InnoDB 排序: utf8mb4_0900_ai_ci
+# ------------------------------------------------------------------------------
+# _________
+# \_ ___ \______ _____ ______ __ __ ______
+# / \ \/\__ \ / \ \___ \ | || \/ ___/
+# \ \____/ __ \| Y Y \ |_\ \| |_| /\___ \
+# \______ (____ /__|_| /| __/|_____//____/ /
+# \/ \/ \/ |__| \/
+# -----------------------------------------------------------------------------
+
+# 创建数据库
+DROP DATABASE IF EXISTS campus_sec_deal;
+CREATE DATABASE campus_sec_deal DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
+show databases;
+
+# 创建数据表
+USE campus_sec_deal;
+
+# 创建campus_user表
+DROP TABLE IF EXISTS `campus_user`;
+CREATE TABLE `campus_user`
+(
+ `user_id` CHAR(14) NOT NULL DEFAULT (CURRENT_TIMESTAMP + 0) COMMENT '用户信息唯一标识符',
+ `user_name` VARCHAR(30) NOT NULL COMMENT '用户名',
+ `user_time` DATE NOT NULL DEFAULT (CURRENT_DATE) COMMENT '用户信息唯一标识符',
+ `user_tel` CHAR(11) NOT NULL COMMENT '用户电话号码',
+ `user_mail` VARCHAR(20) NOT NULL COMMENT '用户邮箱号',
+ `user_sign` VARCHAR(100) NULL DEFAULT ('这个人很懒,什么都没写') COMMENT '用户个性签名',
+ `img_url` VARCHAR(100) NULL DEFAULT ('/imgs/0/default.jpg') COMMENT '用户头像本地相对路径',
+ `user_pwd` VARCHAR(12) NOT NULL COMMENT '用户登录密码',
+ UNIQUE KEY (`user_tel`),
+ UNIQUE KEY (`user_mail`),
+ PRIMARY KEY (`user_id`)
+) COMMENT = '用户信息表', DEFAULT CHARSET = utf8;
+
+# ---------------------------------------------------------------------------------------
+# 创建campus_publish表
+DROP TABLE IF EXISTS `campus_publish`;
+CREATE TABLE `campus_publish`
+(
+ `publish_id` CHAR(14) NOT NULL DEFAULT (CURRENT_TIMESTAMP + 0) COMMENT '发布信息唯一标识符',
+ `publisher_id` CHAR(14) NOT NULL COMMENT '发布者信息唯一标识符',
+ `publisher_tel` CHAR(11) NOT NULL COMMENT '发布者联系电话',
+ `publish_time` TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) COMMENT '信息发布时间戳',
+ `publish_type` INT(1) NOT NULL COMMENT '发布信息类别',
+ `publish_status` BOOLEAN NULL DEFAULT (true) COMMENT '信息是否显示',
+ `publish_name` VARCHAR(20) NOT NULL COMMENT '物品名称',
+ `publish_describe` VARCHAR(500) NULL DEFAULT ('暂无描述信息') COMMENT '物品描述',
+ `publish_cat` INT(1) NOT NULL COMMENT '物品分类',
+ `publish_Oprice` FLOAT NOT NULL COMMENT '物品原价',
+ `publish_Nprice` FLOAT NOT NULL COMMENT '物品现价',
+ `publish_degree` INT(2) NOT NULL DEFAULT (9) COMMENT '物品新旧程度',
+ `img_url` VARCHAR(100) NOT NULL COMMENT '物品图片本地相对路径',
+ PRIMARY KEY (`publish_id`),
+ FOREIGN KEY (`publisher_id`) REFERENCES `campus_user` (`user_id`)
+) COMMENT = '发布信息表', DEFAULT CHARSET = utf8;
+
+# ---------------------------------------------------------------------------------------
+# 创建campus_order表
+DROP TABLE IF EXISTS `campus_order`;
+CREATE TABLE `campus_order`
+(
+ `order_id` CHAR(32) NOT NULL COMMENT '订单唯一标识符',
+ `goods_id` CHAR(14) NOT NULL COMMENT '物品唯一标识符',
+ `order_time` TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) COMMENT '订单生成时间戳',
+ `receiver_id` CHAR(14) NOT NULL COMMENT '物品唯一标识符',
+ `receiver_tel` CHAR(11) NOT NULL COMMENT '下单者联系电话',
+ `deal_addr` VARCHAR(200) NOT NULL COMMENT '交易地点',
+ `order_status` INT(1) NOT NULL DEFAULT (3) COMMENT '订单状态',
+ PRIMARY KEY (`order_id`),
+ FOREIGN KEY (`goods_id`) REFERENCES `campus_publish` (`publish_id`),
+ FOREIGN KEY (`receiver_id`) REFERENCES `campus_user` (`user_id`)
+) COMMENT = '订单信息表', DEFAULT CHARSET = utf8;
+
+# ---------------------------------------------------------------------------------------
+# 创建campus_wallet表
+DROP TABLE IF EXISTS `campus_wallet`;
+CREATE TABLE `campus_wallet`
+(
+ `wallet_id` CHAR(14) NOT NULL COMMENT '用户钱包唯一标识符',
+ `user_id` CHAR(14) NOT NULL COMMENT '用户信息唯一标识符',
+ `wallet_balance` FLOAT NOT NULL DEFAULT (0.00) COMMENT '用户的钱包账户余额',
+ `wallet_pwd` INT(6) NOT NULL DEFAULT (888888) COMMENT '用户钱包支付密码',
+ PRIMARY KEY (`wallet_id`)
+) COMMENT = '账户钱包表', DEFAULT CHARSET = utf8;
+-- 触发器 --
+CREATE TRIGGER trig_insert_user
+ AFTER INSERT
+ ON `campus_user`
+ FOR EACH ROW
+ INSERT INTO `campus_wallet`
+ values (NEW.user_id, NEW.user_id, default, default);
+
+# ---------------------------------------------------------------------------------------
+# 创建campus_chat表
+DROP TABLE IF EXISTS `campus_chat`;
+CREATE TABLE `campus_chat`
+(
+ `chat_id` CHAR(14) NOT NULL DEFAULT (CURRENT_TIMESTAMP + 0) COMMENT '聊天房间号',
+ `msg_id` INT NOT NULL AUTO_INCREMENT COMMENT '消息ID',
+ `from_id` CHAR(14) NOT NULL COMMENT '发消息者ID',
+ `chat_content` VARCHAR(500) NULL COMMENT '消息内容',
+ `send_time` TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) COMMENT '消息发送时间戳',
+ `to_id` CHAR(14) NOT NULL COMMENT '收消息者ID',
+ UNIQUE KEY (`msg_id`),
+ PRIMARY KEY (`chat_id`),
+ FOREIGN KEY (`from_id`) REFERENCES `campus_user` (`user_id`),
+ FOREIGN KEY (`to_id`) REFERENCES `campus_user` (`user_id`)
+) COMMENT = '交易私聊表', DEFAULT CHARSET = utf8;
+
+# ---------------------------------------------------------------------------------------
+# 创建campus_notice表
+DROP TABLE IF EXISTS `campus_notice`;
+CREATE TABLE `campus_notice`
+(
+ `order_id` CHAR(32) NOT NULL COMMENT '订单唯一标识符',
+ `opt_time` TIMESTAMP NOT NULL DEFAULT (CURRENT_TIMESTAMP) COMMENT '操作时间戳',
+ `publisher_id` CHAR(14) NOT NULL COMMENT '发布者信息唯一标识符',
+ `receiver_id` CHAR(14) NOT NULL COMMENT '物品唯一标识符',
+ `order_status` INT(1) NOT NULL DEFAULT (3) COMMENT '订单状态',
+ PRIMARY KEY (`order_id`),
+ FOREIGN KEY (`order_id`) REFERENCES `campus_order` (`order_id`),
+ FOREIGN KEY (`publisher_id`) REFERENCES `campus_user` (`user_id`),
+ FOREIGN KEY (`receiver_id`) REFERENCES `campus_user` (`user_id`)
+) COMMENT = '订单通知表', DEFAULT CHARSET = utf8;
\ No newline at end of file
diff --git a/campus_sec_deal/.gitignore b/campus_sec_deal/.gitignore
new file mode 100644
index 0000000..a2a3040
--- /dev/null
+++ b/campus_sec_deal/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### 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/
+
+### VS Code ###
+.vscode/
diff --git a/campus_sec_deal/.mvn/wrapper/MavenWrapperDownloader.java b/campus_sec_deal/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..a45eb6b
--- /dev/null
+++ b/campus_sec_deal/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ private static final String WRAPPER_VERSION = "0.5.6";
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if (mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if (mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if (!outputFile.getParentFile().exists()) {
+ if (!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+ String username = System.getenv("MVNW_USERNAME");
+ char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+ }
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/campus_sec_deal/.mvn/wrapper/maven-wrapper.jar b/campus_sec_deal/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..2cc7d4a
Binary files /dev/null and b/campus_sec_deal/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/campus_sec_deal/.mvn/wrapper/maven-wrapper.properties b/campus_sec_deal/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..642d572
--- /dev/null
+++ b/campus_sec_deal/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
diff --git a/campus_sec_deal/README.md b/campus_sec_deal/README.md
new file mode 100644
index 0000000..c0d9ab2
--- /dev/null
+++ b/campus_sec_deal/README.md
@@ -0,0 +1,4 @@
+# 工程简介
+
+# 延伸阅读
+
diff --git a/campus_sec_deal/mvnw b/campus_sec_deal/mvnw
new file mode 100644
index 0000000..a16b543
--- /dev/null
+++ b/campus_sec_deal/mvnw
@@ -0,0 +1,310 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ if [ -n "$MVNW_REPOURL" ]; then
+ jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ else
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ fi
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+ if $cygwin; then
+ wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+ fi
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget "$jarUrl" -O "$wrapperJarPath"
+ else
+ wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl -o "$wrapperJarPath" "$jarUrl" -f
+ else
+ curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+ fi
+
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaClass=`cygpath --path --windows "$javaClass"`
+ fi
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/campus_sec_deal/mvnw.cmd b/campus_sec_deal/mvnw.cmd
new file mode 100644
index 0000000..c8d4337
--- /dev/null
+++ b/campus_sec_deal/mvnw.cmd
@@ -0,0 +1,182 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
+
+exit /B %ERROR_CODE%
diff --git a/campus_sec_deal/pom.xml b/campus_sec_deal/pom.xml
new file mode 100644
index 0000000..9b7b871
--- /dev/null
+++ b/campus_sec_deal/pom.xml
@@ -0,0 +1,209 @@
+
+
+ 4.0.0
+ edu.njust
+ campus_sec_deal
+ 1.3.0-STABLE
+ campus_sec_deal
+ campus_sec_deal
+ jar
+
+
+
+
+
+
+
+
+ 15
+ UTF-8
+ UTF-8
+ 2.3.7.RELEASE
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ com.google.guava
+ guava
+ 28.2-android
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.2
+
+
+
+ com.baomidou
+ mybatis-plus-generator
+ 3.5.3
+
+
+
+ org.apache.velocity
+ velocity-engine-core
+ 2.3
+
+
+
+ com.alibaba
+ fastjson
+ 2.0.14.graal
+
+
+ com.vaadin.external.google
+ android-json
+ 0.0.20131108.vaadin1
+ compile
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ 1.4.5
+
+
+
+ com.auth0
+ java-jwt
+ 4.0.0
+
+
+ io.jsonwebtoken
+ jjwt
+ 0.9.1
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+
+ 11
+ UTF-8
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.3.7.RELEASE
+
+ edu.njust.campus_sec_deal.CampusSecDealApplication
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+ repackage
+
+ repackage
+
+
+
+
+
+
+
+ src/main/java
+
+ **/*.xml
+
+ true
+
+
+ src/main/resources
+
+ **.*
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/CampusSecDealApplication.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/CampusSecDealApplication.java
new file mode 100644
index 0000000..6f50c4d
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/CampusSecDealApplication.java
@@ -0,0 +1,20 @@
+package edu.njust.campus_sec_deal;
+
+import edu.njust.campus_sec_deal.controller.WSChatController;
+import edu.njust.campus_sec_deal.controller.WSNoticeController;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+@SpringBootApplication
+@MapperScan("edu.njust.campus_sec_deal.mapper")
+public class CampusSecDealApplication {
+
+ public static void main(String[] args) {
+ ConfigurableApplicationContext run = SpringApplication.run(CampusSecDealApplication.class, args);
+ WSChatController.setApplicationContext(run);
+ WSNoticeController.setApplicationContext(run);
+ }
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/MybatisPlusGenerator.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/MybatisPlusGenerator.java
new file mode 100644
index 0000000..44444e5
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/MybatisPlusGenerator.java
@@ -0,0 +1,101 @@
+/**
+ * @title: MybatisPlusGenerator
+ * @date: 2022/9/18 11:43
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @version: 1.0.0
+ */
+
+package edu.njust.campus_sec_deal;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
+import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MybatisPlusGenerator {
+
+ public static void main(String[] args) {
+ /*
+ 特别注意:生成的时间类型均为:“LocalDateTime”格式,需要假如以下注解方可正常使用
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ */
+
+ //数据库连接
+ String url = "jdbc:mysql://localhost:3306/campus_sec_deal?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT";//数据库url
+ String username = "root";//账号
+ String password = "Njust123";//密码
+ String module = "campus_sec_deal";//模块名
+ //全局配置参数
+ String author = "Colyn";//作者
+ String outputDir = System.getProperty("user.dir") + "\\src\\main\\java";//指定输出目录
+ //包配置参数
+ String parent = "edu.njust";//父包名
+ String moduleName = "campus_sec_deal";//父包模块名
+ String entity = "entity";//Entity 实体类包名
+ String mapper = "mapper";//Mapper 包名
+ String mapperXml = "mapper";//Mapper XML 包名
+ String service = "service";//Service 包名
+ String serviceImpl = "service.impl";//Service Impl 包名
+ String controller = "controller";//Controller 包名*/
+ //要生成的数据库表
+ List tables = new ArrayList<>();
+ tables.add("campus_notice");
+ tables.add("campus_publish");
+ tables.add("campus_chat");
+ tables.add("campus_order");
+ tables.add("campus_wallet");
+ //开始生成
+ FastAutoGenerator.create(url, username, password)
+ //全局配置
+ .globalConfig(builder -> {
+ builder.author(author)
+ .outputDir(outputDir)
+ /*.enableSwagger()//开启swagger*/
+ .commentDate("yyyy-MM-dd");//注释日期
+ })
+ //包配置
+ .packageConfig(builder ->
+ builder.parent(parent)
+ .moduleName(moduleName)
+ .entity(entity)
+ .mapper(mapper)
+ .xml(mapperXml)
+ .service(service)
+ .serviceImpl(serviceImpl)
+ .controller(controller)
+ )
+ //策略配置
+ .strategyConfig(builder ->
+ builder.addInclude(tables)
+ //开启生成实体类
+ .entityBuilder()
+ .enableLombok()//开启 lombok 模型
+ .enableTableFieldAnnotation()//开启生成实体时生成字段注解
+ //开启生成mapper
+ .mapperBuilder()
+ .enableBaseResultMap()//启用 BaseResultMap 生成
+ .superClass(BaseMapper.class)//设置父类
+ .enableMapperAnnotation()//开启 @Mapper 注解
+ .formatMapperFileName("%sMapper")//格式化 mapper 文件名称
+ .formatXmlFileName("%sMapper")//格式化 xml 实现类文件名称
+ //开启生成service及impl
+ .serviceBuilder()
+ .formatServiceFileName("%sService")//格式化 service 接口文件名称
+ .formatServiceImplFileName("%sServiceImpl")//格式化 service 实现类文件名称
+ //开启生成controller
+ .controllerBuilder()
+ // 映射路径使用连字符格式,而不是驼峰
+ .enableHyphenStyle()
+ .formatFileName("%sController")//格式化文件名称
+ .enableRestStyle()
+ )
+ .templateEngine(new VelocityTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
+ .templateConfig(builder -> builder.controller(""))//关闭生成controller
+ .execute();
+ }
+}
\ No newline at end of file
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ImgTypeConf.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ImgTypeConf.java
new file mode 100644
index 0000000..3951035
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ImgTypeConf.java
@@ -0,0 +1,18 @@
+/**
+ * @Class: ImgType
+ * @Date: 2022/9/20
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.config;
+
+public class ImgTypeConf {
+ public static final int AVATAR = 0; //用户头像
+
+ public static final int PRODUCT = 1; //二手商品
+
+ public static final int DEMAND = 2; //二手征品
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ReturnCodeConf.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ReturnCodeConf.java
new file mode 100644
index 0000000..1799aae
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/ReturnCodeConf.java
@@ -0,0 +1,65 @@
+/**
+ * @Class: ReturnCodeConf
+ * @Date: 2022/9/23
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.config;
+
+public class ReturnCodeConf {
+ /**
+ * 此类用于设置RESTful API返回状态码规范
+ */
+
+ /**
+ * 操作成功
+ **/
+ public static final int OPT_SUCCESS = 200;
+
+ /**
+ * token校验失败
+ **/
+ public static final int TOKEN_ERR = 401;
+
+ /**
+ * 信息错误
+ **/
+ public static final int INFO_ERR = 402;
+
+ /**
+ * 信息警告
+ **/
+ public static final int INFO_WARN = 403;
+
+ /**
+ * 信息非法
+ **/
+ public static final int INFO_ILLEGAL = 404;
+
+ /**
+ * 信息提示
+ **/
+ public static final int INFO_TIPS = 405;
+
+ /**
+ * 信息存在
+ **/
+ public static final int INFO_EXIST = 406;
+
+ /**
+ * 信息不存在
+ **/
+ public static final int INFO_NOT_EXIST = 407;
+
+ /**
+ * 操作失败
+ **/
+ public static final int OPT_FAIL = 408;
+
+ /**
+ * 系统错误
+ **/
+ public static final int SYS_ERR = 500;
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/UserTypeConf.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/UserTypeConf.java
new file mode 100644
index 0000000..6cbbbb7
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/UserTypeConf.java
@@ -0,0 +1,22 @@
+/**
+ * @Class: UserTypeConf
+ * @Date: 2022/9/23
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.config;
+
+public class UserTypeConf {
+
+ public static final int USER_TEL = 0;
+
+ public static final int USER_MAIL = 1;
+
+ public static final int USER_SIGN = 2;
+
+ public static final int USER_PWD = 3;
+
+ public static final int USER_NAME = 4;
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/WSConf.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/WSConf.java
new file mode 100644
index 0000000..b9bc68a
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/config/WSConf.java
@@ -0,0 +1,25 @@
+/**
+ * @Class: WSConf
+ * @Date: 2022/9/20
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+@Configuration
+public class WSConf implements WebSocketMessageBrokerConfigurer {
+
+ @Bean
+ public ServerEndpointExporter exporter() {
+ return new ServerEndpointExporter();
+ }
+
+}
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/CheckInfoController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/CheckInfoController.java
new file mode 100644
index 0000000..4f76213
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/CheckInfoController.java
@@ -0,0 +1,148 @@
+/**
+ * @Class: CheckInfoController
+ * @Date: 2022/9/20
+ * @Project: campus_sec_deal
+ * @author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.service.CampusOrderService;
+import edu.njust.campus_sec_deal.service.CampusUserService;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/api/v1/check")
+public class CheckInfoController {
+
+ @Autowired
+ CampusUserService userService;
+
+ @Autowired
+ CampusOrderService orderService;
+
+ @Autowired
+ CampusWalletService walletService;
+
+ /**
+ * 电话号验证接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/user_tel")
+ public JsonResultUtil> checkTel(@NotNull HttpServletRequest request) {
+
+ //获取请求头中的参数uer_tel的值
+ String tel = request.getHeader("user_tel");
+
+ if (!tel.isEmpty()) { //前端传来的Tel非空时
+ //查询是否存在该号码
+ if (userService.hasTel(tel)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "该号码已存在");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "该号码不存在");
+ }
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "号码不可为空");
+ }
+
+
+ /**
+ * 邮箱号验证接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/user_mail")
+ public JsonResultUtil> checkMail(@NotNull HttpServletRequest request) {
+
+ //获取请求头中的参数user_mail的值
+ String mail = request.getHeader("user_mail");
+
+ if (!mail.isEmpty()) { //前端传来的Mail非空时
+ //查询是否存在该邮箱
+ if (userService.hasMail(mail)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "该邮箱已存在");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "该邮箱不存在");
+ }
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "邮箱不可为空");
+ }
+
+ /**
+ * 用户ID验证接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/user_id")
+ public JsonResultUtil> checkUid(@NotNull HttpServletRequest request) {
+
+ //获取请求头中的参数user_id的值
+ String uid = request.getHeader("user_id");
+
+ if (!uid.isEmpty()) { //前端传来的Uid非空时
+ //查询是否存在该用户
+ if (userService.hasTel(uid)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "该用户已存在");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "该用户不存在");
+ }
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "用户ID不可为空");
+ }
+
+ /**
+ * 发布订单验证接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/publish_order")
+ public JsonResultUtil> checkOrder(@NotNull HttpServletRequest request) {
+
+ //获取请求头中的参数publish_id的值
+ String pid = request.getHeader("publish_id");
+
+ if (!pid.isEmpty()) { //前端传来的物品ID非空时
+ //查询是否存在该发布物品生成的订单
+ if (orderService.hasOrder(pid)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "已生成订单");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "未生成订单");
+ }
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "物品ID不可为空");
+ }
+
+
+ /**
+ * 用户余额验证接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/user_wallet")
+ public JsonResultUtil> checkWallet(@NotNull HttpServletRequest request) {
+
+ //获取请求头中的参数user_id的值
+ String uid = request.getHeader("user_id");
+
+ if (!uid.isEmpty()) { //前端传来的用户ID非空时
+ //查询是否存在该用户ID
+ if (userService.hasUser(uid)) {
+ //封装返回json的data键值对
+ Map data = new HashMap<>();
+ data.put("wallet_balance", walletService.getWallet(uid).getWalletBalance());
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "未找到该用户信息");
+ }
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "用户ID不可为空");
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/ImgUploadController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/ImgUploadController.java
new file mode 100644
index 0000000..8d30c1e
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/ImgUploadController.java
@@ -0,0 +1,96 @@
+/**
+ * @title: ImgUploadController
+ * @date: 2022/9/19 23:26
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import edu.njust.campus_sec_deal.entity.CampusUser;
+import edu.njust.campus_sec_deal.mapper.CampusUserMapper;
+import edu.njust.campus_sec_deal.utils.FileUploadUtil;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import edu.njust.campus_sec_deal.config.ImgTypeConf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1")
+public class ImgUploadController {
+
+ @Value("${campus.file.upload-location}")
+ private String path;
+
+ @Value("${campus.file.upload-pattern}")
+ private String pattern;
+
+ @Autowired
+ CampusUserMapper userMapper;
+
+
+ /**
+ * 图片上传接口
+ *
+ * @param file
+ * @param type
+ * @param request
+ * @return img_url
+ * @decribe: 前端上传图片须携带token,校验通过后才能上传。返回图片相对路径
+ */
+ @PostMapping("/upload")
+ public JsonResultUtil> imgUpload(@RequestParam("file") MultipartFile file, @RequestParam("img_type") int type, HttpServletRequest request) throws IOException {
+
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ } else {
+
+ //写入图片并获得图片url
+ String img_url = FileUploadUtil.SaveFile(file, type, this.path, this.pattern);
+
+ if (img_url != null) {
+
+ /**
+ * 将图片写入相应的数据表中
+ */
+ switch (type) {
+ case ImgTypeConf.AVATAR:
+ CampusUser User = new CampusUser().setImgUrl(img_url);
+ try {
+ userMapper.update(User, Wrappers.lambdaUpdate().eq(CampusUser::getUserId, uid));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ break;
+ default:
+ break;
+ }
+
+ //封装返回json的data键值对
+ Map data = new HashMap<>();
+ data.put("img_url", img_url);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "图片上传失败");
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/OrderManageController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/OrderManageController.java
new file mode 100644
index 0000000..b8f25a9
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/OrderManageController.java
@@ -0,0 +1,278 @@
+/**
+ * @Class: OrderManageController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.entity.CampusOrder;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.entity.CampusWallet;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+import edu.njust.campus_sec_deal.service.CampusNoticeService;
+import edu.njust.campus_sec_deal.service.CampusOrderService;
+import edu.njust.campus_sec_deal.service.CampusPublishService;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1/order")
+public class OrderManageController {
+
+ @Autowired
+ CampusPublishService publishService;
+
+ @Autowired
+ CampusOrderService orderService;
+
+ @Autowired
+ CampusWalletService walletService;
+
+ @Autowired
+ CampusNoticeService noticeService;
+
+
+ /**
+ * 生成订单接口
+ *
+ * @param order
+ * @param request
+ * @return status
+ */
+ @PostMapping("/gen_order")
+ public JsonResultUtil> genOrder(@RequestBody Map order, @NotNull HttpServletRequest request) {
+ /**
+ * 注意:这个只是订单生成接口,默认的订单状态为”待付款“,因此该接口并不能自动支付,支付请调用支付订单接口pay_order
+ * 订单处于”待付款“状态30min后会被自动取消该订单
+ */
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ CampusPublish publish = publishService.getOnePublish(order.get("publish_id"));
+
+ //如果是发布者本人
+ if (order.get("receiver_id").equals(publish.getPublisherId())) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_ILLEGAL, "不能下单自己发布的物品");
+ } else {
+
+ String order_id = RandomDataUtil.getUUID32();
+ if (orderService.insertOrder(order_id, 3, order) && publishService.updatePublish(publish.getPublishId(), false, null)) {
+
+ //创建订单提醒
+ Map map = new HashMap<>();
+ map.put("order_id", order_id);
+ map.put("publisher_id", publish.getPublisherId());
+ map.put("receiver_id", uid);
+ map.put("order_status", "3");
+ noticeService.insertOrderNotice(map);
+
+ //添加订单编号到data键里
+ Map data = new HashMap<>();
+ data.put("order_id", order_id);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,下单失败");
+ }
+ }
+ }
+
+
+ /**
+ * 支付订单接口
+ *
+ * @param order
+ * @param request
+ * @return status
+ */
+ @PostMapping("/pay_order")
+ public JsonResultUtil> payOrder(@RequestBody Map order, @NotNull HttpServletRequest request) {
+ /**
+ * 注意:此部分是对上述生成订单进行支付,来使得订单状态变成”待交易“
+ * 订单处于”待交易”状态7days后会被自动取消该订单
+ * 仅付款方(征品的发布者或商品的下单者)才有权调用该接口
+ */
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ CampusWallet wallet = walletService.getWallet(uid);
+ CampusPublish publish = publishService.getPublishByOrder(order.get("order_id"));
+ CampusOrder get_order = orderService.getOneOrder(order.get("order_id"));
+
+ //验证支付密码
+ if (wallet.getWalletPwd() != Integer.parseInt(order.get("pay_pwd"))) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "支付密码错误");
+ } else { //支付密码正确
+
+ /**对于商品和征品均只能买家付款,卖家无需付款**/
+ if (get_order != null/*订单存在*/
+ && ((publish.getPublishType().equals(0)/*是商品*/
+ && get_order.getReceiverId().equals(uid)/*是买家*/)
+ || (publish.getPublishType().equals(1)/*是征品*/
+ && publish.getPublisherId().equals(uid)/*是买家*/))) {
+
+ //查询商(征)品价格
+ if (wallet.getWalletBalance() < publish.getPublishNprice()) { //用户余额不足以支付订单
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "余额不足,请充值");
+ } else {
+
+ if (orderService.updateOrder(order.get("order_id"), 2) && walletService.updateWallet(uid, -publish.getPublishNprice())) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,支付失败");
+ }
+ } else return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "你无需支付");
+ }
+ }
+ }
+
+
+ /**
+ * 获取订单接口
+ *
+ * @param request
+ * @return status
+ */
+ @GetMapping("/get_order")
+ public JsonResultUtil> getOrder(@NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ int pageNum = request.getIntHeader("pageNum"); //第n页
+ int pageSize = request.getIntHeader("pageSize"); //每页有n条数据
+
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+
+ /**
+ * 分别获取用户作为发布者和下单者的信息,封装成json格式
+ */
+ //封装成json
+ Map> order_data = orderService.getAllOrder(uid, pageNum, pageSize);
+ // 过滤掉超时的订单
+ Map> orderList = orderService.filterAllOrderByTime(order_data);
+ if (orderList != null) {
+ return new JsonResultUtil<>(orderList);
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "找不到相关订单");
+ }
+ }
+
+ /**
+ * 取消订单接口
+ *
+ * @param order
+ * @param request
+ * @return status
+ */
+ @PutMapping("/cancel_order")
+ public JsonResultUtil> cancelOrder(@RequestBody Map order, @NotNull HttpServletRequest request) {
+ /**
+ * 取消订单是用户主动取消的接口
+ * 取消的订单仅处于“待付款“或“待交易”状态可取消,如果处于“待付款“状态将直接取消,如果处于“待交易”状态则分如下2种情况:
+ * 1.商品:钱退还至下单者(买家) 2.征品:钱退还至发布者(买家)
+ * 注意:仅下单方可取消订单,征品为卖家下单,商品为买家下单
+ */
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ CampusOrder get_order = orderService.getOneOrder(order.get("order_id"));
+ CampusPublish get_publish = publishService.getOnePublish(get_order.getGoodsId());
+
+ /**仅下单者可取消订单**/
+ if (!uid.equals(get_order.getReceiverId())) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_ILLEGAL, "无权操作");
+ } else {
+ if (get_order.getOrderStatus().equals(0)/*已完成*/) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "该订单已完成,不可取消订单");
+
+ } else if (get_order.getOrderStatus().equals(1)/*已取消*/) {
+ return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "该订单已取消,不可重复操作");
+ } else {
+
+ publishService.updatePublish(get_publish.getPublishId(), true, null);//先修改发布的物品为可显示状态
+ orderService.updateOrder(get_order.getOrderId(), 1);//修改订单为已取消
+ if (get_order.getOrderStatus().equals(2)) { //如果是待交易,退钱
+
+ //如果是商品,退钱给下单者
+ if (get_publish.getPublishType().equals(0))
+ walletService.updateWallet(uid, get_publish.getPublishNprice());
+
+ //如果是征品,退钱给发布者
+ else walletService.updateWallet(get_publish.getPublisherId(), get_publish.getPublishNprice());
+ }
+ return new JsonResultUtil<>();
+ }
+ }
+ }
+ }
+
+ /**
+ * 完成订单接口
+ *
+ * @param order
+ * @param request
+ * @return status
+ */
+ @PutMapping("over_order")
+ public JsonResultUtil> overOrder(@RequestBody Map order, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+
+ /**
+ * 仅付款方可结束订单
+ * 如果是征品订单,仅发布者可结束订单
+ * 如果是商品订单,仅下单者可结束订单
+ * 结束订单时,如果商品,则打钱给发布者(卖家);如果是征品,则打钱给下单者(卖家)
+ */
+ CampusOrder get_order = orderService.getOneOrder(order.get("order_id"));
+ CampusPublish get_publish = publishService.getOnePublish(get_order.getGoodsId());
+
+ /**订单状态为"待交易"才可结束订单**/
+ if (!get_order.getOrderStatus().equals(2)) return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "订单状态不符合完成条件");
+ else {
+ if (get_publish.getPublishType().equals(1)/*征品*/ && get_publish.getPublisherId().equals(uid)/*发布者*/) {
+
+ if (walletService.updateWallet(get_order.getReceiverId(), get_publish.getPublishNprice()) //征品,打钱给下单者(卖家)
+ && orderService.updateOrder(get_order.getOrderId(), 0)) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,操作失败");
+
+ } else if (get_publish.getPublishType().equals(0)/*商品*/ && get_order.getReceiverId().equals(uid)/*下单者*/) {
+
+ if (walletService.updateWallet(get_publish.getPublisherId(), get_publish.getPublishNprice()) //商品,打钱给发布者(卖家)
+ && orderService.updateOrder(get_order.getOrderId(), 0)) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,操作失败");
+
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ILLEGAL, "无权操作");
+ }
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/PublishManageController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/PublishManageController.java
new file mode 100644
index 0000000..f5246df
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/PublishManageController.java
@@ -0,0 +1,139 @@
+/**
+ * @Class: PublishManageController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.service.CampusOrderService;
+import edu.njust.campus_sec_deal.service.CampusPublishService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1/publish")
+public class PublishManageController {
+
+ @Autowired
+ CampusPublishService publishService;
+
+ @Autowired
+ CampusOrderService orderService;
+
+ /**
+ * 发布信息接口
+ *
+ * @param publish
+ * @param request
+ * @return status
+ */
+ @PostMapping("/post_info")
+ public JsonResultUtil> postPublish(@RequestBody Map publish, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+
+ String publish_id = RandomDataUtil.getIDByTime();
+
+ if (publishService.insertPublish(publish_id, true, publish)) {
+ HashMap data = new HashMap<>();
+ data.put("publish_id", publish_id);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,发布失败");
+ }
+ }
+
+
+ /**
+ * 获取发布信息接口
+ *
+ * @return Map
+ */
+ @GetMapping("/get_info")
+ public JsonResultUtil> getPublish(HttpServletRequest request) {
+
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ List publishList = publishService.getAllPublish(uid);
+ if (publishList != null) {
+ return new JsonResultUtil<>(publishList);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,查询失败");
+ }
+
+ /**
+ * 修改发布信息接口
+ *
+ * @param publish
+ * @param request
+ * @return status
+ */
+ @PutMapping("/modify_info")
+ public JsonResultUtil> modifyInfo(@RequestBody Map publish, @NotNull HttpServletRequest request) {
+
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+
+ if (!publishService.getStatus(publish.get("publish_id"))) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "已生成订单,无权修改");
+ } else {
+ if (publishService.updatePublish(publish.get("publish_id"), true, publish)) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,修改失败");
+ }
+ }
+ }
+
+
+ /**
+ * 删除发布信息接口
+ *
+ * @param publish
+ * @param request
+ * @return status
+ */
+ @DeleteMapping("/delete_info")
+ public JsonResultUtil> deleteInfo(@RequestBody Map publish, @NotNull HttpServletRequest request) {
+
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+
+ //如果存在订单,则不允许删除该
+ if (orderService.hasOrder(publish.get("publish_id"))) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_ILLEGAL, "已生成订单,无权删除");
+ } else {
+ if (publishService.deletePublish(publish.get("publish_id"))) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,删除失败");
+ }
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/SearchController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/SearchController.java
new file mode 100644
index 0000000..1d6ce81
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/SearchController.java
@@ -0,0 +1,95 @@
+/**
+ * @Class: PublishManageController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+import edu.njust.campus_sec_deal.service.CampusOrderService;
+import edu.njust.campus_sec_deal.service.CampusPublishService;
+import edu.njust.campus_sec_deal.service.CampusSearchService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1/search")
+public class SearchController {
+
+ @Autowired
+ CampusPublishService publishService;
+
+ @Autowired
+ CampusSearchService searchService;
+
+ @Autowired
+ CampusOrderService orderService;
+
+ public static Logger log = LoggerFactory.getLogger(SearchController.class);
+
+ /**
+ * 根据关键词返回物品列表接口
+ *
+ * @param query
+ * @return status
+ */
+ @GetMapping("/get_publish")
+ public JsonResultUtil> getPublishByKeywords(@RequestBody Map query) {
+ List originList = publishService.getAllPublish(null);
+ if (originList != null) {
+ List publishList = searchService.filterPublishList(originList, query.get("keywords"));
+ return new JsonResultUtil<>(publishList);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,查询失败");
+ }
+
+ /**
+ * 根据关键词返回订单列表接口
+ *
+ * @param query
+ * @param request
+ * @return status
+ */
+
+ @GetMapping("/get_order")
+ public JsonResultUtil> getOrderByKeywords(@RequestBody Map query, @NotNull HttpServletRequest request) {
+ log.info(query.get("keywords"));
+ String token = request.getHeader("token");
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ }
+ Map> origin_order_data = orderService.getAllOrder(uid, 0, 0);
+ if (origin_order_data != null) {
+ List as_publisher = origin_order_data.get("publish");
+ List as_receiver = origin_order_data.get("receive");
+ List pub = searchService.filterOrderList(as_publisher, query.get("keywords"));
+ List rec = searchService.filterOrderList(as_receiver, query.get("keywords"));
+ Map> map = new HashMap<>();
+ if (pub == null || !pub.isEmpty()) {
+ map.put("publish", pub);
+ } else map.put("publish", null);
+
+ if (rec == null || !rec.isEmpty()) {
+ map.put("receive", rec);
+ } else map.put("receive", null);
+ return new JsonResultUtil<>(map);
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "找不到相关订单");
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserManageController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserManageController.java
new file mode 100644
index 0000000..9d39341
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserManageController.java
@@ -0,0 +1,115 @@
+/**
+ * @Class: UserManageController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.entity.CampusUser;
+import edu.njust.campus_sec_deal.service.CampusUserService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1")
+public class UserManageController {
+
+ @Value("${campus.default.user-sign}")
+ private String user_sign;
+
+ @Value("${campus.default.user-logo}")
+ private String img_url;
+
+ @Autowired
+ CampusUserService userService;
+
+ /**
+ * 用户注册接口
+ *
+ * @param user
+ * @return status
+ */
+ @PostMapping("/register")
+ public JsonResultUtil> userRegister(@NotNull @RequestBody Map user) {
+ user.put("user_sign", this.user_sign);
+ user.put("img_url", this.img_url);
+
+ if (userService.insertUser(user)) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,注册失败");
+ }
+
+ /**
+ * 用户找回密码接口
+ *
+ * @param user
+ * @return status
+ */
+ @PutMapping("/reset_pwd")
+ public JsonResultUtil> resetPwd(@NotNull @RequestBody Map user) {
+
+ if (userService.isRightUser(user.get("user_id"), user.get("user_tel"), user.get("user_mail"))) {
+ if (userService.retrievePassword(user.get("user_id"), user.get("new_pwd"))) {
+ Map data = new HashMap<>();
+ data.put("new_pwd", user.get("new_pwd"));
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,找回密码失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "填写信息错误");
+ }
+
+ /**
+ * 用户登录接口
+ *
+ * @param user
+ * @return status
+ */
+ @PostMapping("/login")
+ public JsonResultUtil> userLogin(@NotNull @RequestBody Map user) {
+ System.out.println("getUser: " + user);
+
+ //验证信息是否正确
+ CampusUser get_user = userService.loginCheck(user);
+ if (get_user != null) {
+
+ //封装payload信息
+ Map payload = new HashMap<>();
+ payload.put("user_id", get_user.getUserId());
+
+ //封装token到data
+ Map data = new HashMap<>();
+ data.put("token", JWTUtil.getToken(payload));
+ data.put("user", get_user);
+
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ILLEGAL, "认证信息错误,登陆失败");
+ }
+
+ /**
+ * 获取用户简介
+ * @param request
+ * @return map
+ */
+ @GetMapping("/get_user_info")
+ public JsonResultUtil> getUserInfo(@NotNull HttpServletRequest request){
+ String uid = request.getHeader("user_id");
+
+ Map data = userService.getUserInfo(uid);
+ if (data != null){
+ return new JsonResultUtil<>(data);
+ }else return new JsonResultUtil<>(ReturnCodeConf.INFO_NOT_EXIST, "找不到该用户信息");
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserModifyController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserModifyController.java
new file mode 100644
index 0000000..5021e79
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/UserModifyController.java
@@ -0,0 +1,192 @@
+/**
+ * @Class: UserModifyController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.config.UserTypeConf;
+import edu.njust.campus_sec_deal.service.CampusUserService;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1/modify")
+public class UserModifyController {
+
+ @Autowired
+ CampusUserService userService;
+
+ @Autowired
+ CampusWalletService walletService;
+
+ /**
+ * 修改电话接口
+ *
+ * @param tel
+ * @param request
+ * @return status
+ */
+ @PutMapping("/user_tel")
+ public JsonResultUtil> userTel(@RequestParam("user_tel") String tel, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ } else {
+ if (!tel.isEmpty()) { //前端传来的Tel非空时
+ //查询是否存在该号码
+ if (userService.hasTel(tel)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "该号码已存在");
+ } else {
+ if (userService.modifyUserInfo(uid, tel, UserTypeConf.USER_TEL)) {
+ Map data = new HashMap<>();
+ data.put("user_tel", tel);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统出错,电话修改失败");
+ }
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "号码不可为空");
+ }
+ }
+
+ /**
+ * 修改邮箱接口
+ *
+ * @param mail
+ * @param request
+ * @return status
+ */
+ @PutMapping("/user_mail")
+ public JsonResultUtil> userMail(@RequestParam("user_mail") String mail, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ } else {
+ if (!mail.isEmpty()) { //前端传来的Mail非空时
+ //查询是否存在该邮箱
+ if (userService.hasMail(mail)) {
+ return new JsonResultUtil<>(ReturnCodeConf.INFO_EXIST, "该邮箱已存在");
+ } else {
+ if (userService.modifyUserInfo(uid, mail, UserTypeConf.USER_MAIL)) {
+ Map data = new HashMap<>();
+ data.put("user_mail", mail);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "邮箱修改失败");
+ }
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "邮箱不可为空");
+ }
+ }
+
+ /**
+ * 修改个性签名接口
+ *
+ * @param sign
+ * @param request
+ * @return status
+ */
+ @PutMapping("/user_sign")
+ public JsonResultUtil> userSign(@RequestParam("user_sign") String sign, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ } else {
+ if (!sign.isEmpty()) { //前端传来的Sign非空时
+ if (userService.modifyUserInfo(uid, sign, UserTypeConf.USER_SIGN)) {
+ Map data = new HashMap<>();
+ data.put("user_sign", sign);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "签名修改失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "签名不可为空");
+ }
+ }
+
+ /**
+ * 修改用户昵称接口
+ *
+ * @param name
+ * @param request
+ * @return status
+ */
+ @PutMapping("/user_name")
+ public JsonResultUtil> userName(@RequestParam("user_name") String name, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误");
+ } else {
+ if (!name.isEmpty()) { //前端传来的name非空时
+ if (userService.modifyUserInfo(uid, name, UserTypeConf.USER_NAME)) {
+ Map data = new HashMap<>();
+ data.put("user_name", name);
+ return new JsonResultUtil<>(data);
+ } else return new JsonResultUtil<>(ReturnCodeConf.OPT_FAIL, "昵称修改失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "昵称不可为空");
+ }
+ }
+
+ /**
+ * 修改登录密码接口
+ *
+ * @param user
+ * @param request
+ * @return status
+ */
+ @PutMapping("/user_pwd")
+ public JsonResultUtil> loginPwd(@RequestBody Map user, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ if (userService.isRightPwd(uid, user.get("Ologin_pwd")) && user.get("Nlogin_pwd") != null && !user.get("Nlogin_pwd").equals("")) {
+ if (userService.modifyUserInfo(uid, user.get("Nlogin_pwd"), UserTypeConf.USER_PWD)) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,登陆密码修改失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "信息填写错误");
+ }
+ }
+
+ /**
+ * 修改支付密码接口
+ *
+ * @param user
+ * @param request
+ * @return
+ */
+ @PutMapping("/pay_pwd")
+ public JsonResultUtil> payPwd(@RequestBody Map user, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ if (walletService.isRightPwd(uid, Integer.parseInt(user.get("Opay_pwd"))) && user.get("Npay_pwd") != null && !user.get("Npay_pwd").equals("")) {
+ if (walletService.modifyPwd(uid, Integer.parseInt(user.get("Npay_pwd")))) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,支付密码修改失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "信息填写错误");
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/VerificationCodeController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/VerificationCodeController.java
new file mode 100644
index 0000000..b7908a0
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/VerificationCodeController.java
@@ -0,0 +1,38 @@
+/**
+ * @title: VerificationCodeController
+ * @date: 2022/9/18 20:21
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+
+@RestController()
+@RequestMapping(value = "/api/v1", produces = "application/json;charset=UTF-8")
+public class VerificationCodeController {
+
+
+ /**
+ * 验证码接口
+ *
+ * @return ver_code
+ */
+ @GetMapping("/ver_code")
+ public JsonResultUtil> getVerCode() {
+
+ HashMap data = new HashMap<>();
+
+ // 业务逻辑代码
+ data.put("ver_code", RandomDataUtil.getVerCode());
+ return new JsonResultUtil<>(data);
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSChatController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSChatController.java
new file mode 100644
index 0000000..78d89fc
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSChatController.java
@@ -0,0 +1,133 @@
+/**
+ * @Class: WSChatController
+ * @Date: 2022/9/20
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import edu.njust.campus_sec_deal.entity.CampusChat;
+import edu.njust.campus_sec_deal.mapper.CampusChatMapper;
+import edu.njust.campus_sec_deal.mapper.CampusUserMapper;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import lombok.Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 交易私聊接口
+ */
+@ServerEndpoint("/api/v1/ws/chat/{user_id}")
+@Component
+@Data
+public class WSChatController {
+
+ private static ApplicationContext applicationContext;
+
+ //初始化
+ public static void setApplicationContext(ApplicationContext applicationContext) {
+ WSChatController.applicationContext = applicationContext;
+ }
+
+ public static CampusChatMapper chatMapper() {
+ return applicationContext.getBean(CampusChatMapper.class);
+ }
+
+ public static CampusUserMapper userMapper() {
+ return applicationContext.getBean(CampusUserMapper.class);
+ }
+
+ private static int onlineCount = 0;
+ public static Logger log = LoggerFactory.getLogger(WSChatController.class);
+ private static ConcurrentHashMap mapUS = new ConcurrentHashMap<>();//根据用户找session
+ private static ConcurrentHashMap mapSU = new ConcurrentHashMap<>();//根据session找用户
+ public Session session;
+
+
+ @OnOpen
+ public void onOpen(Session session, @PathParam("user_id") String uid) throws IOException {
+ this.session = session;
+ mapUS.put(uid, this.session);//添加唯一标识的用户ID为key,session为值
+ mapSU.put(this.session, uid);//添加session为key,唯一标识的用户ID为值
+ addOnlineCount(); //在线数加1
+
+ log.info("有新连接用户:" + uid + "加入!当前在线人数为:" + getOnlineCount());
+ List msgs = chatMapper().selectList(new QueryWrapper().lambda().eq(CampusChat::getToId, uid));
+ if (msgs.size() != 0) {
+ chatMapper().deleteBatchIds(msgs);
+ log.info("用户" + uid + "上线,推送离线消息");
+ for (CampusChat msg : msgs) {
+ session.getBasicRemote().sendText("[" + msg.getSendTime().toString().replaceAll("T", " ") + "] " + userMapper().selectById(msg.getFromId()).getUserName() + ": " + msg.getChatContent());
+ }
+ }
+ }
+
+ @OnClose
+ public void onClose(Session session) {
+ String uid = mapSU.get(session);
+ mapUS.remove(uid);
+ mapSU.remove(session);
+ subOnlineCount(); //在线数减1
+ log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
+ }
+
+ @OnMessage
+ public void onMessage(String message) {
+ log.info("收到来自窗口的信息:" + message);
+ String[] split = message.split("@");
+ String fromId = split[0];
+ String toId = split[1];
+ String msg = split[2];
+ Session to = mapUS.get(toId);
+
+ if (to == null) {//用户不在线
+ CampusChat chat = new CampusChat()
+ .setChatId(RandomDataUtil.getIDByTime())
+ .setFromId(String.valueOf(fromId))
+ .setToId(String.valueOf(toId))
+ .setChatContent(msg);
+ int insert = chatMapper().insert(chat);
+ if (Integer.valueOf(insert).equals(1)) {
+ log.info("用户" + toId + "离线,将消息存入数据库");
+ }
+ }
+
+ if (to == null || msg == null || msg.equals("")) {
+ return;
+ }
+ to.getAsyncRemote().sendText("[" + RandomDataUtil.getSendTime() + "] " + userMapper().selectById(fromId).getUserName() + ": " + msg);
+
+ }
+
+ @OnError
+ public void onError(Throwable error) {
+ log.error("发生错误");
+ error.printStackTrace();
+ }
+
+ public static synchronized int getOnlineCount() {
+ return onlineCount;//返回在线人数
+ }
+
+ public static synchronized void addOnlineCount() {
+ WSChatController.onlineCount++;//在线人数+1
+ }
+
+ public static synchronized void subOnlineCount() {
+ WSChatController.onlineCount--;//在线人数-1
+ }
+}
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSNoticeController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSNoticeController.java
new file mode 100644
index 0000000..9d74f5b
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WSNoticeController.java
@@ -0,0 +1,69 @@
+/**
+ * @Class: WSNoticeController
+ * @Date: 2022/9/20
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import edu.njust.campus_sec_deal.entity.CampusNotice;
+import edu.njust.campus_sec_deal.mapper.CampusNoticeMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.OnClose;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+/**
+ * 订单通知接口
+ */
+@Component
+@ServerEndpoint("/api/v1/ws/notice/{user_id}")
+public class WSNoticeController {
+
+ private static ApplicationContext applicationContext;
+
+ public static Logger log = LoggerFactory.getLogger(WSNoticeController.class);
+
+ //存放所有的websocket连接
+ private static final CopyOnWriteArraySet myWebSocketServicesSet = new CopyOnWriteArraySet<>();
+
+ //初始化
+ public static void setApplicationContext(ApplicationContext applicationContext) {
+ WSNoticeController.applicationContext = applicationContext;
+ }
+
+ public static CampusNoticeMapper noticeMapper() {
+ return applicationContext.getBean(CampusNoticeMapper.class);
+ }
+
+ //建立websocket连接时自动调用
+ @OnOpen
+ public void onOpen(Session session, @PathParam("user_id") String uid) throws IOException {
+ myWebSocketServicesSet.add(this);
+ log.info("有新用户进入,当前连接总数为" + myWebSocketServicesSet.size());
+ log.info("该用户id为: " + uid);
+ if (noticeMapper().selectCount(new QueryWrapper().lambda().eq(CampusNotice::getPublisherId, uid)) > 0) {
+ log.info("开始推送订单...");
+ noticeMapper().delete(new QueryWrapper().lambda().eq(CampusNotice::getPublisherId, uid));
+ session.getBasicRemote().sendText("您有新的订单!");
+ }
+ }
+
+ //关闭websocket连接时自动调用
+ @OnClose
+ public void onClose() {
+ myWebSocketServicesSet.remove(this);
+ log.info("连接断开,当前连接总数为" + myWebSocketServicesSet.size());
+ }
+}
\ No newline at end of file
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WalletManageController.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WalletManageController.java
new file mode 100644
index 0000000..6ad0b56
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/controller/WalletManageController.java
@@ -0,0 +1,82 @@
+/**
+ * @Class: WalletManageController
+ * @Date: 2022/9/21
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.controller;
+
+import edu.njust.campus_sec_deal.config.ReturnCodeConf;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import edu.njust.campus_sec_deal.utils.JWTUtil;
+import edu.njust.campus_sec_deal.utils.JsonResultUtil;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+@RestController
+@PropertySource("classpath:application.properties")
+@RequestMapping(value = "/api/v1/wallet")
+public class WalletManageController {
+
+ @Autowired
+ CampusWalletService walletService;
+
+ /**
+ * 余额充值接口
+ *
+ * @param wallet
+ * @param request
+ * @return status
+ */
+ @PostMapping("/charge_wallet")
+ public JsonResultUtil> chargeWallet(@RequestBody Map wallet, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ //验证信息是否正确
+ if (walletService.isRightPwd(uid, Integer.parseInt(wallet.get("wallet_pwd")))) {
+ if (walletService.updateWallet(uid, Float.parseFloat(wallet.get("charge_money")))) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,充值失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "支付密码错误");
+ }
+ }
+
+ /**
+ * 余额提现接口
+ *
+ * @param wallet
+ * @param request
+ * @return status
+ */
+ @PostMapping("/withdraw_wallet")
+ public JsonResultUtil> withdrawWallet(@RequestBody Map wallet, @NotNull HttpServletRequest request) {
+ String token = request.getHeader("token");
+ //从token中取出用户ID
+ String uid = JWTUtil.verifyToken(token, "user_id");
+ if (uid == null) {
+ return new JsonResultUtil<>(ReturnCodeConf.TOKEN_ERR, "token错误,请登录");
+ } else {
+ //验证信息是否正确
+ if (walletService.isRightPwd(uid, Integer.parseInt(wallet.get("wallet_pwd")))) {
+ //如果余额小于提现金额
+ if (walletService.getWallet(uid).getWalletBalance() > Float.parseFloat(wallet.get("withdraw_money"))) {
+ //如果顺利提现
+ if (walletService.updateWallet(uid, -Float.parseFloat(wallet.get("withdraw_money")))) {
+ return new JsonResultUtil<>();
+ } else return new JsonResultUtil<>(ReturnCodeConf.SYS_ERR, "系统错误,充值失败");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_WARN, "余额不足");
+ } else return new JsonResultUtil<>(ReturnCodeConf.INFO_ERR, "支付密码错误");
+ }
+ }
+}
\ No newline at end of file
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusChat.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusChat.java
new file mode 100644
index 0000000..f945fd3
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusChat.java
@@ -0,0 +1,65 @@
+/**
+ *
+ * 交易私聊表
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_chat")
+public class CampusChat implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 聊天房间号
+ */
+ @TableId("chat_id")
+ private String chatId;
+
+ /**
+ * 消息ID
+ */
+ @TableField("msg_id")
+ private Integer msgId;
+
+ /**
+ * 发消息者ID
+ */
+ @TableField("from_id")
+ private String fromId;
+
+ /**
+ * 消息内容
+ */
+ @TableField("chat_content")
+ private String chatContent;
+
+ /**
+ * 消息发送时间戳
+ */
+ @TableField("send_time")
+ private LocalDateTime sendTime;
+
+ /**
+ * 收消息者ID
+ */
+ @TableField("to_id")
+ private String toId;
+
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusNotice.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusNotice.java
new file mode 100644
index 0000000..47b2acb
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusNotice.java
@@ -0,0 +1,58 @@
+/**
+ *
+ * 订单通知表
+ *
+ *
+ * @author Colyn
+ * @since 2022-10-02
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_notice")
+public class CampusNotice implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 订单唯一标识符
+ */
+ @TableId("order_id")
+ private String orderId;
+
+ /**
+ * 操作时间戳
+ */
+ @TableField("opt_time")
+ private LocalDateTime optTime;
+
+ /**
+ * 发布者信息唯一标识符
+ */
+ @TableField("publisher_id")
+ private String publisherId;
+
+ /**
+ * 物品唯一标识符
+ */
+ @TableField("receiver_id")
+ private String receiverId;
+
+ /**
+ * 订单状态
+ */
+ @TableField("order_status")
+ private Integer orderStatus;
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusOrder.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusOrder.java
new file mode 100644
index 0000000..7a8fdd5
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusOrder.java
@@ -0,0 +1,72 @@
+/**
+ *
+ * 订单信息表
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_order")
+public class CampusOrder implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 订单唯一标识符
+ */
+ @TableId("order_id")
+ private String orderId;
+
+ /**
+ * 物品唯一标识符
+ */
+ @TableField("goods_id")
+ private String goodsId;
+
+ /**
+ * 订单生成时间戳
+ */
+ @TableField("order_time")
+ private LocalDateTime orderTime;
+
+ /**
+ * 物品唯一标识符
+ */
+ @TableField("receiver_id")
+ private String receiverId;
+
+ /**
+ * 下单者联系电话
+ */
+ @TableField("receiver_tel")
+ private String receiverTel;
+
+ /**
+ * 交易地点
+ */
+ @TableField("deal_addr")
+ private String dealAddr;
+
+ /**
+ * 订单状态
+ */
+ @TableField("order_status")
+ private Integer orderStatus;
+
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusPublish.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusPublish.java
new file mode 100644
index 0000000..fedb316
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusPublish.java
@@ -0,0 +1,108 @@
+/**
+ *
+ * 发布信息表
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_publish")
+public class CampusPublish implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 发布信息唯一标识符
+ */
+ @TableId("publish_id")
+ private String publishId;
+
+ /**
+ * 发布者信息唯一标识符
+ */
+ @TableField("publisher_id")
+ private String publisherId;
+
+ /**
+ * 发布者联系电话
+ */
+ @TableField("publisher_tel")
+ private String publisherTel;
+
+ /**
+ * 信息发布时间戳
+ */
+ @TableField("publish_time")
+ private LocalDateTime publishTime;
+
+ /**
+ * 发布信息类别
+ */
+ @TableField("publish_type")
+ private Integer publishType;
+
+ /**
+ * 信息是否显示
+ */
+ @TableField("publish_status")
+ private Boolean publishStatus;
+
+ /**
+ * 物品名称
+ */
+ @TableField("publish_name")
+ private String publishName;
+
+ /**
+ * 物品描述
+ */
+ @TableField("publish_describe")
+ private String publishDescribe;
+
+ /**
+ * 物品分类
+ */
+ @TableField("publish_cat")
+ private Integer publishCat;
+
+ /**
+ * 物品原价
+ */
+ @TableField("publish_Oprice")
+ private Float publishOprice;
+
+ /**
+ * 物品现价
+ */
+ @TableField("publish_Nprice")
+ private Float publishNprice;
+
+ /**
+ * 物品新旧程度
+ */
+ @TableField("publish_degree")
+ private Integer publishDegree;
+
+ /**
+ * 物品图片本地相对路径
+ */
+ @TableField("img_url")
+ private String imgUrl;
+
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusUser.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusUser.java
new file mode 100644
index 0000000..3ec4b0a
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusUser.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * 用户信息表
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDate;
+
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_user")
+public class CampusUser implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 用户信息唯一标识符
+ */
+ @TableId("user_id")
+ private String userId;
+
+ /**
+ * 用户名
+ */
+ @TableField("user_name")
+ private String userName;
+
+ /**
+ * 用户信息唯一标识符
+ */
+ @TableField("user_time")
+ private LocalDate userTime;
+
+ /**
+ * 用户电话号码
+ */
+ @TableField("user_tel")
+ private String userTel;
+
+ /**
+ * 用户邮箱号
+ */
+ @TableField("user_mail")
+ private String userMail;
+
+ /**
+ * 用户个性签名
+ */
+ @TableField("user_sign")
+ private String userSign;
+
+ /**
+ * 用户头像本地相对路径
+ */
+ @TableField("img_url")
+ private String imgUrl;
+
+ /**
+ * 用户登录密码
+ */
+ @TableField("user_pwd")
+ private String userPwd;
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusWallet.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusWallet.java
new file mode 100644
index 0000000..9edff38
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/CampusWallet.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * 账户钱包表
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+
+@Data
+@Accessors(chain = true)
+@TableName("campus_wallet")
+public class CampusWallet implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 用户钱包唯一标识符
+ */
+ @TableId("wallet_id")
+ private String walletId;
+
+ /**
+ * 用户信息唯一标识符
+ */
+ @TableField("user_id")
+ private String userId;
+
+ /**
+ * 用户的钱包账户余额
+ */
+ @TableField("wallet_balance")
+ private Float walletBalance;
+
+ /**
+ * 用户钱包支付密码
+ */
+ @TableField("wallet_pwd")
+ private Integer walletPwd;
+
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/PublishCoOder.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/PublishCoOder.java
new file mode 100644
index 0000000..bcafba1
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/entity/PublishCoOder.java
@@ -0,0 +1,119 @@
+/**
+ * @Class: PublishCoOder
+ * @Date: 2022/9/22
+ * @Project: campus_sec_deal
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.entity;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+
+@Data
+public class PublishCoOder {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 发布信息唯一标识符
+ */
+ private String publishId;
+
+ /**
+ * 发布者信息唯一标识符
+ */
+ private String publisherId;
+
+ /**
+ * 发布者联系电话
+ */
+ private String publisherTel;
+
+ /**
+ * 信息发布时间戳
+ */
+ private LocalDateTime publishTime;
+
+ /**
+ * 发布信息类别
+ */
+ private Integer publishType;
+
+ /**
+ * 信息是否显示
+ */
+ private Boolean publishStatus;
+
+ /**
+ * 物品名称
+ */
+ private String publishName;
+
+ /**
+ * 物品描述
+ */
+ private String publishDescribe;
+
+ /**
+ * 物品分类
+ */
+ private Integer publishCat;
+
+ /**
+ * 物品原价
+ */
+ private Float publishOprice;
+
+ /**
+ * 物品现价
+ */
+ private Float publishNprice;
+
+ /**
+ * 物品新旧程度
+ */
+ private Integer publishDegree;
+
+ /**
+ * 物品图片本地相对路径
+ */
+ private String imgUrl;
+
+ /**
+ * 订单唯一标识符
+ */
+ private String orderId;
+
+ /**
+ * 物品唯一标识符
+ */
+ private String goodsId;
+
+ /**
+ * 订单生成时间戳
+ */
+ private LocalDateTime orderTime;
+
+ /**
+ * 物品唯一标识符
+ */
+ private String receiverId;
+
+ /**
+ * 下单者联系电话
+ */
+ private String receiverTel;
+
+ /**
+ * 交易地点
+ */
+ private String dealAddr;
+
+ /**
+ * 订单状态
+ */
+ private Integer orderStatus;
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.java
new file mode 100644
index 0000000..c5430ea
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * 交易私聊表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import edu.njust.campus_sec_deal.entity.CampusChat;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface CampusChatMapper extends BaseMapper {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.xml
new file mode 100644
index 0000000..6065869
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusChatMapper.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.java
new file mode 100644
index 0000000..0754f14
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * 订单通知表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-10-02
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import edu.njust.campus_sec_deal.entity.CampusNotice;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface CampusNoticeMapper extends BaseMapper {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.xml
new file mode 100644
index 0000000..1e7ce4a
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusNoticeMapper.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.java
new file mode 100644
index 0000000..a9996ca
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * 订单信息表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import edu.njust.campus_sec_deal.entity.CampusOrder;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+@Mapper
+public interface CampusOrderMapper extends BaseMapper {
+
+ @Select("select p.*, o.* from campus_publish p, campus_order o where p.publish_id = o.goods_id and p.publish_id in (select publish_id from campus_publish where publisher_id=#{id})")
+ List orderListALLByPublisher(String id);
+
+ @Select("select p.*, o.* from campus_publish p, campus_order o where p.publish_id = o.goods_id and o.goods_id in (select goods_id from campus_order where o.receiver_id=#{id})")
+ List orderListALLByReceiver(String id);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.xml
new file mode 100644
index 0000000..c4d2296
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusOrderMapper.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.java
new file mode 100644
index 0000000..e27fe35
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.java
@@ -0,0 +1,23 @@
+/**
+ *
+ * 发布信息表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+@Mapper
+public interface CampusPublishMapper extends BaseMapper {
+
+ @Select("select * from campus_publish where publish_id in (select goods_id from campus_order where order_id = #{oid})")
+ CampusPublish selectPublishByOrder(String oid);
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.xml
new file mode 100644
index 0000000..db4e65e
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusPublishMapper.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.java
new file mode 100644
index 0000000..dac24a2
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * 用户信息表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import edu.njust.campus_sec_deal.entity.CampusUser;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface CampusUserMapper extends BaseMapper {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.xml
new file mode 100644
index 0000000..e31edb0
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusUserMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.java
new file mode 100644
index 0000000..fa6123d
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * 账户钱包表 Mapper 接口
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import edu.njust.campus_sec_deal.entity.CampusWallet;
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface CampusWalletMapper extends BaseMapper {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.xml b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.xml
new file mode 100644
index 0000000..72c8755
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/mapper/CampusWalletMapper.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusChatService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusChatService.java
new file mode 100644
index 0000000..196cfcf
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusChatService.java
@@ -0,0 +1,18 @@
+/**
+ *
+ * 交易私聊表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import edu.njust.campus_sec_deal.entity.CampusChat;
+
+
+public interface CampusChatService extends IService {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusNoticeService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusNoticeService.java
new file mode 100644
index 0000000..8f79078
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusNoticeService.java
@@ -0,0 +1,23 @@
+/**
+ *
+ * 订单通知表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-10-02
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import edu.njust.campus_sec_deal.entity.CampusNotice;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+
+public interface CampusNoticeService extends IService {
+
+ void insertOrderNotice(Map map);
+
+ boolean getOrderNotice(String uid);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusOrderService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusOrderService.java
new file mode 100644
index 0000000..a0d8a85
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusOrderService.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * 订单信息表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import edu.njust.campus_sec_deal.entity.CampusOrder;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+
+import java.util.List;
+import java.util.Map;
+
+
+public interface CampusOrderService extends IService {
+
+ boolean hasOrder(String pid);
+
+ boolean insertOrder(String oid, int status, Map map);
+
+ boolean updateOrder(String oid, int status);
+
+ Map> getAllOrder(String uid, int pageNum, int pageSize);
+
+ CampusOrder getOneOrder(String oid);
+
+ Map> filterAllOrderByTime(Map> map);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusPublishService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusPublishService.java
new file mode 100644
index 0000000..4c934eb
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusPublishService.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * 发布信息表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+
+import java.util.List;
+import java.util.Map;
+
+
+public interface CampusPublishService extends IService {
+
+ CampusPublish getOnePublish(String pid);
+
+ boolean updatePublish(String pid, boolean status, Map map);
+
+ CampusPublish getPublishByOrder(String oid);
+
+ boolean insertPublish(String pid, boolean status, Map map);
+
+ List getAllPublish(String uid);
+
+ boolean getStatus(String pid);
+
+ boolean deletePublish(String pid);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusSearchService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusSearchService.java
new file mode 100644
index 0000000..6c6e368
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusSearchService.java
@@ -0,0 +1,20 @@
+/**
+ *
+ * 发布信息表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+
+import java.util.List;
+
+public interface CampusSearchService {
+ List filterPublishList(List list, String keys);
+ List filterOrderList(List list, String keys);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusUserService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusUserService.java
new file mode 100644
index 0000000..301d587
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusUserService.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * 用户信息表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import edu.njust.campus_sec_deal.entity.CampusUser;
+
+import java.util.Map;
+
+
+public interface CampusUserService extends IService {
+
+ boolean hasTel(String tel);
+
+ boolean hasMail(String mail);
+
+ boolean hasUser(String uid);
+
+ boolean isRightUser(String uid, String tel, String mail);
+
+ boolean isRightPwd(String uid, String pwd);
+
+ boolean insertUser(Map map);
+
+ boolean retrievePassword(String uid, String pwd);
+
+ CampusUser loginCheck(Map map);
+
+ Map getUserInfo(String uid);
+
+ boolean modifyUserInfo(String uid, String modify, int type);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusWalletService.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusWalletService.java
new file mode 100644
index 0000000..ecdc4f8
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/CampusWalletService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * 账户钱包表 服务类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import edu.njust.campus_sec_deal.entity.CampusWallet;
+
+
+public interface CampusWalletService extends IService {
+
+ CampusWallet getWallet(String uid);
+
+ boolean updateWallet(String wid, float add);
+
+ boolean isRightPwd(String wid, int pwd);
+
+ boolean modifyPwd(String wid, int pwd);
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusChatServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusChatServiceImpl.java
new file mode 100644
index 0000000..d6dbf78
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusChatServiceImpl.java
@@ -0,0 +1,22 @@
+/**
+ *
+ * 交易私聊表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.njust.campus_sec_deal.entity.CampusChat;
+import edu.njust.campus_sec_deal.mapper.CampusChatMapper;
+import edu.njust.campus_sec_deal.service.CampusChatService;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class CampusChatServiceImpl extends ServiceImpl implements CampusChatService {
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusNoticeServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusNoticeServiceImpl.java
new file mode 100644
index 0000000..80f66de
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusNoticeServiceImpl.java
@@ -0,0 +1,49 @@
+/**
+ *
+ * 订单通知表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-10-02
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import edu.njust.campus_sec_deal.entity.CampusNotice;
+import edu.njust.campus_sec_deal.mapper.CampusNoticeMapper;
+import edu.njust.campus_sec_deal.service.CampusNoticeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+
+@Service
+public class CampusNoticeServiceImpl extends ServiceImpl implements CampusNoticeService {
+
+ @Autowired
+ CampusNoticeMapper noticeMapper;
+
+ public void insertOrderNotice(Map map) {
+
+ CampusNotice notice = new CampusNotice()
+ .setOrderId(map.get("order_id"))
+ .setPublisherId(map.get("publisher_id"))
+ .setReceiverId(map.get("receiver_id"))
+ .setOrderStatus(Integer.parseInt(map.get("order_status")));
+
+ try {
+ noticeMapper.insert(notice);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean getOrderNotice(String uid) {
+ Long cnt = noticeMapper.selectCount(Wrappers.lambdaQuery().eq(CampusNotice::getPublisherId, uid));
+ if (cnt > 0) noticeMapper.delete(Wrappers.lambdaQuery().eq(CampusNotice::getPublisherId, uid));
+ return cnt > 0;
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusOrderServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusOrderServiceImpl.java
new file mode 100644
index 0000000..52d8109
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusOrderServiceImpl.java
@@ -0,0 +1,219 @@
+/**
+ *
+ * 搜索
+ *
+ *
+ * @author Colyn
+ * @since 2022-10-02
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import edu.njust.campus_sec_deal.controller.SearchController;
+import edu.njust.campus_sec_deal.entity.CampusOrder;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+import edu.njust.campus_sec_deal.mapper.CampusOrderMapper;
+import edu.njust.campus_sec_deal.service.CampusOrderService;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.*;
+
+/**
+ *
+ * 订单信息表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+@Service
+public class CampusOrderServiceImpl extends ServiceImpl implements CampusOrderService {
+
+ @Autowired
+ CampusOrderMapper orderMapper;
+
+ @Value("${campus.default.time-to-pay}")
+ private int time_to_pay;
+ @Value("${campus.default.time-to-ex}")
+ private int time_to_ex;
+
+ public static Logger log = LoggerFactory.getLogger(CampusOrderServiceImpl.class);
+
+ public boolean hasOrder(String pid) {
+ Long cnt = orderMapper.selectCount(Wrappers.lambdaQuery().eq(CampusOrder::getGoodsId, pid));
+ return cnt > 0;
+ }
+
+ @Override
+ public boolean insertOrder(String oid, int status, Map map) {
+ CampusOrder order = new CampusOrder()
+ .setOrderId(oid)
+ .setOrderTime(RandomDataUtil.getDateTime())
+ .setGoodsId(map.get("publish_id"))
+ .setReceiverId(map.get("receiver_id"))
+ .setReceiverTel(map.get("receiver_tel"))
+ .setDealAddr(map.get("deal_addr"))
+ .setOrderStatus(status);
+ try {
+ orderMapper.insert(order);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean updateOrder(String oid, int status) {
+ CampusOrder order = new CampusOrder()
+ .setOrderId(oid)
+ .setOrderStatus(status);
+ try {
+ orderMapper.updateById(order);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public Map> getAllOrder(String uid, int pageNum, int pageSize) {
+
+ try {
+ PageHelper.startPage(pageNum, pageSize);
+ List as_publisher = orderMapper.orderListALLByPublisher(uid);
+ List as_receiver = orderMapper.orderListALLByReceiver(uid);
+
+ //封装成Map信息
+ Map> map = new HashMap<>();
+ if (!as_publisher.isEmpty()) {
+ map.put("publish", as_publisher);
+ } else map.put("publish", null);
+
+ if (!as_receiver.isEmpty()) {
+ map.put("receive", as_receiver);
+ } else map.put("receive", null);
+
+
+ return map;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public Map> filterAllOrderByTime(Map> map) {
+
+ List as_publisher = map.get("publish");
+ List as_receiver = map.get("receive");
+
+ // 过滤 publisher中的过期订单
+ do {
+ if(as_publisher == null) {
+ break;
+ }
+ Iterator iter = as_publisher.iterator();
+ while(iter.hasNext()) {
+ PublishCoOder order = iter.next();
+ if(order.getOrderStatus() == 3) { // 如果是待付款订单
+ LocalDateTime ddl = order.getOrderTime().plus(time_to_pay, ChronoUnit.MINUTES);
+
+ LocalDateTime now = RandomDataUtil.getDateTime();
+
+ long time = now.until(ddl, ChronoUnit.SECONDS);
+ if(time <= 0) {
+ // 取消订单 将status设置为1
+ order.setOrderStatus(1);
+ // 把数据库的值也同步修改
+ updateOrder(order.getOrderId(), 1);
+ }
+ } else if(order.getOrderStatus() == 2) { // 如果是待交易订单
+ LocalDateTime ddl = order.getOrderTime().plus(time_to_ex, ChronoUnit.MINUTES);
+
+ LocalDateTime now = RandomDataUtil.getDateTime();
+
+ long time = now.until(ddl, ChronoUnit.SECONDS);
+
+ if(time <= 0) {
+ // 取消订单 将status设置为1
+ order.setOrderStatus(1);
+ // 把数据库的值也同步修改
+ updateOrder(order.getOrderId(), 1);
+ }
+ }
+ }
+ }while(false);
+
+ // 过滤 receiver 中的过期订单
+ do {
+ if(as_receiver == null) {
+ break;
+ }
+ Iterator iter = as_receiver.iterator();
+ while(iter.hasNext()) {
+ PublishCoOder order = iter.next();
+ if(order.getOrderStatus() == 3) { // 如果是待付款订单
+ LocalDateTime ddl = order.getOrderTime().plus(time_to_pay, ChronoUnit.MINUTES);
+
+ LocalDateTime now = RandomDataUtil.getDateTime();
+
+ long time = now.until(ddl, ChronoUnit.SECONDS);
+ if(time <= 0) {
+ // 取消订单 将status设置为1
+ order.setOrderStatus(1);
+ // 把数据库的值也同步修改
+ updateOrder(order.getOrderId(), 1);
+ }
+ } else if(order.getOrderStatus() == 2) { // 如果是待交易订单
+ LocalDateTime ddl = order.getOrderTime().plus(time_to_ex, ChronoUnit.MINUTES);
+
+ LocalDateTime now = RandomDataUtil.getDateTime();
+
+ long time = now.until(ddl, ChronoUnit.SECONDS);
+
+ if(time <= 0) {
+ // 取消订单 将status设置为1
+ order.setOrderStatus(1);
+ // 把数据库的值也同步修改
+ updateOrder(order.getOrderId(), 1);
+ }
+ }
+ }
+ }while(false);
+
+ Map> result = new HashMap<>();
+ if (as_publisher == null || !as_publisher.isEmpty()) {
+ result.put("publish", as_publisher);
+ } else result.put("publish", null);
+
+ if (as_receiver == null || !as_receiver.isEmpty()) {
+ result.put("receive", as_receiver);
+ } else result.put("receive", null);
+
+ return result;
+ }
+
+ @Override
+ public CampusOrder getOneOrder(String oid) {
+ try {
+ return orderMapper.selectById(oid);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusPublishServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusPublishServiceImpl.java
new file mode 100644
index 0000000..6ec9c27
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusPublishServiceImpl.java
@@ -0,0 +1,140 @@
+/**
+ *
+ * 发布信息表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.mapper.CampusPublishMapper;
+import edu.njust.campus_sec_deal.service.CampusPublishService;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+@Service
+public class CampusPublishServiceImpl extends ServiceImpl implements CampusPublishService {
+
+ @Autowired
+ CampusPublishMapper publishMapper;
+
+ @Override
+ public CampusPublish getOnePublish(String pid) {
+ return publishMapper.selectById(pid);
+ }
+
+ @Override
+ public boolean updatePublish(String pid, boolean status, Map map) {
+
+ if (map == null) {
+ CampusPublish publish = new CampusPublish()
+ .setPublishId(pid)
+ .setPublishStatus(status);
+ try {
+ publishMapper.updateById(publish);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ } else {
+ CampusPublish publish = new CampusPublish()
+ .setPublishId(pid)
+ .setPublisherId(map.get("publisher_id"))
+ .setPublisherTel(map.get("publisher_tel"))
+ .setPublishTime(RandomDataUtil.getDateTime())
+ .setPublishType(Integer.parseInt(map.get("publish_type")))
+ .setPublishStatus(status)
+ .setPublishName(map.get("publish_name"))
+ .setPublishDescribe(map.get("publish_describe"))
+ .setPublishCat(Integer.parseInt(map.get("publish_cat")))
+ .setPublishOprice(Float.parseFloat(map.get("publish_Oprice")))
+ .setPublishNprice(Float.parseFloat(map.get("publish_Nprice")))
+ .setPublishDegree(Integer.parseInt(map.get("publish_degree")))
+ .setImgUrl(map.get("img_url"));
+ try {
+ publishMapper.updateById(publish);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public CampusPublish getPublishByOrder(String oid) {
+ return publishMapper.selectPublishByOrder(oid);
+ }
+
+ @Override
+ public boolean insertPublish(String pid, boolean status, Map map) {
+ CampusPublish publish = new CampusPublish()
+ .setPublishId(pid)
+ .setPublisherId(map.get("publisher_id"))
+ .setPublisherTel(map.get("publisher_tel"))
+ .setPublishTime(RandomDataUtil.getDateTime())
+ .setPublishType(Integer.parseInt(map.get("publish_type")))
+ .setPublishStatus(status)
+ .setPublishName(map.get("publish_name"))
+ .setPublishDescribe(map.get("publish_describe"))
+ .setPublishCat(Integer.parseInt(map.get("publish_cat")))
+ .setPublishOprice(Float.parseFloat(map.get("publish_Oprice")))
+ .setPublishNprice(Float.parseFloat(map.get("publish_Nprice")))
+ .setPublishDegree(Integer.parseInt(map.get("publish_degree")))
+ .setImgUrl(map.get("img_url"));
+
+ try {
+ publishMapper.insert(publish);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public List getAllPublish(String uid) {
+ if (uid != null) {
+ try {
+ return publishMapper.selectList(Wrappers.lambdaQuery().eq(CampusPublish::getPublisherId, uid));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ } else {
+ try {
+ return publishMapper.selectList(Wrappers.lambdaQuery().eq(CampusPublish::getPublishStatus, true));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public boolean getStatus(String pid) {
+ return publishMapper.selectById(pid).getPublishStatus();
+ }
+
+ @Override
+ public boolean deletePublish(String pid) {
+ try {
+ publishMapper.deleteById(pid);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusSearchServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusSearchServiceImpl.java
new file mode 100644
index 0000000..485c9f1
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusSearchServiceImpl.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * 搜索
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import edu.njust.campus_sec_deal.entity.CampusPublish;
+import edu.njust.campus_sec_deal.entity.PublishCoOder;
+import edu.njust.campus_sec_deal.service.CampusSearchService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CampusSearchServiceImpl implements CampusSearchService {
+
+ boolean isKeyInPublish(CampusPublish pub, String key) {
+ // 在所有字符串字段中检索关键字
+ return pub.getPublishDescribe().contains(key)
+ || pub.getPublishName().contains(key)
+ || pub.getPublisherTel().contains(key)
+ || pub.getPublisherId().contains(key)
+ || pub.getPublishId().contains(key)
+ || pub.getPublishTime().toString().contains(key);
+ }
+
+ boolean isKeyInOrder(PublishCoOder order, String key) {
+ return order.getOrderId().contains(key)
+ || order.getGoodsId().contains(key)
+ || order.getOrderTime().toString().contains(key)
+ || order.getPublishDescribe().contains(key)
+ || order.getDealAddr().contains(key)
+ || order.getPublisherId().contains(key)
+ || order.getPublisherTel().contains(key)
+ || order.getPublishName().contains(key);
+ }
+
+ @Override
+ public List filterPublishList(List list, String keys) {
+ if(keys == null || "".equals(keys)) {
+ return list;
+ }
+ // 根据关键词剔除不满足条件的项目
+ list.removeIf(pub -> !isKeyInPublish(pub, keys));
+ return list;
+ }
+
+ @Override
+ public List filterOrderList(List list, String keys) {
+ if(list == null) {
+ return list;
+ }
+ if(keys == null || "".equals(keys)) {
+ return list;
+ }
+ list.removeIf(ord -> !isKeyInOrder(ord, keys));
+ return list;
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusUserServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusUserServiceImpl.java
new file mode 100644
index 0000000..ce24a35
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusUserServiceImpl.java
@@ -0,0 +1,173 @@
+/**
+ *
+ * 用户信息表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.njust.campus_sec_deal.entity.CampusUser;
+import edu.njust.campus_sec_deal.mapper.CampusUserMapper;
+import edu.njust.campus_sec_deal.service.CampusUserService;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import edu.njust.campus_sec_deal.config.UserTypeConf;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Service
+public class CampusUserServiceImpl extends ServiceImpl implements CampusUserService {
+
+ @Autowired
+ CampusUserMapper userMapper;
+
+ @Override
+ public boolean hasTel(String tel) { //查询是否存在该号码
+ Long cnt = userMapper.selectCount(Wrappers.lambdaQuery().eq(CampusUser::getUserTel, tel));
+ return cnt > 0;
+ }
+
+ @Override
+ public boolean hasMail(String mail) { //查询是否存在该邮箱
+ Long cnt = userMapper.selectCount(Wrappers.lambdaQuery().eq(CampusUser::getUserMail, mail));
+ return cnt > 0;
+ }
+
+ @Override
+ public boolean hasUser(String uid) { //查询是否存在该用户
+ Long cnt = userMapper.selectCount(Wrappers.lambdaQuery().eq(CampusUser::getUserId, uid));
+ return cnt > 0;
+ }
+
+ @Override
+ public boolean isRightUser(String uid, String tel, String mail) {
+ Long cnt = userMapper.selectCount(Wrappers.lambdaQuery().eq(CampusUser::getUserId, uid).eq(CampusUser::getUserTel, tel).eq(CampusUser::getUserMail, mail));
+ return cnt > 0;
+ }
+
+ @Override
+ public boolean insertUser(Map map) {
+ try {
+ CampusUser user = new CampusUser()
+ .setUserId(RandomDataUtil.getIDByTime())
+ .setUserName(map.get("user_name"))
+ .setUserTime(RandomDataUtil.getDate())
+ .setUserTel(map.get("user_tel"))
+ .setUserMail(map.get("user_mail"))
+ .setUserSign(map.get("user_sign"))
+ .setImgUrl(map.get("img_url"))
+ .setUserPwd(map.get("user_pwd"));
+
+ userMapper.insert(user);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean retrievePassword(String uid, String pwd) {
+ try {
+ CampusUser user = new CampusUser()
+ .setUserId(uid)
+ .setUserPwd(pwd);
+ userMapper.updateById(user);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public CampusUser loginCheck(Map map) {
+ if (map.get("user_id") != null) {
+ try {
+ return userMapper.selectById(map.get("user_id"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ } else if (map.get("user_tel") != null) {
+ try {
+ return userMapper.selectOne(Wrappers.lambdaQuery().eq(CampusUser::getUserTel, map.get("user_tel")));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ } else if (map.get("user_mail") != null) {
+ try {
+ return userMapper.selectOne(Wrappers.lambdaQuery().eq(CampusUser::getUserMail, map.get("user_mail")));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public boolean modifyUserInfo(String uid, String modify, int type) {
+
+ CampusUser user = new CampusUser().setUserId(uid);
+
+ switch (type) {
+ case UserTypeConf.USER_TEL:
+ user.setUserTel(modify);
+ break;
+ case UserTypeConf.USER_MAIL:
+ user.setUserMail(modify);
+ break;
+ case UserTypeConf.USER_SIGN:
+ user.setUserSign(modify);
+ break;
+ case UserTypeConf.USER_PWD:
+ user.setUserPwd(modify);
+ break;
+ case UserTypeConf.USER_NAME:
+ user.setUserName(modify);
+ break;
+ default:
+ break;
+ }
+
+ try {
+ userMapper.updateById(user);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isRightPwd(String uid, String pwd) {
+ return pwd.equals(userMapper.selectById(uid).getUserPwd());
+ }
+
+ @Override
+ public Map getUserInfo(String uid) {
+
+ try {
+ CampusUser user = userMapper.selectById(uid);
+ Map map = new HashMap<>();
+ map.put("userName", user.getUserName());
+ map.put("userSign", user.getUserSign());
+ map.put("imgUrl", user.getImgUrl());
+ return map;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusWalletServiceImpl.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusWalletServiceImpl.java
new file mode 100644
index 0000000..92511b3
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/service/impl/CampusWalletServiceImpl.java
@@ -0,0 +1,64 @@
+/**
+ *
+ * 账户钱包表 服务实现类
+ *
+ *
+ * @author Colyn
+ * @since 2022-09-18
+ */
+
+package edu.njust.campus_sec_deal.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.njust.campus_sec_deal.entity.CampusWallet;
+import edu.njust.campus_sec_deal.mapper.CampusWalletMapper;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class CampusWalletServiceImpl extends ServiceImpl implements CampusWalletService {
+
+ @Autowired
+ CampusWalletMapper walletMapper;
+
+ @Override
+ public CampusWallet getWallet(String uid) {
+ return walletMapper.selectById(uid);
+ }
+
+ @Override
+ public boolean updateWallet(String wid, float add) {
+ UpdateWrapper update = new UpdateWrapper<>();
+ CampusWallet wallet = new CampusWallet();
+ update.lambda().eq(CampusWallet::getWalletId, wid).setSql("wallet_balance=wallet_balance+" + add);
+ try {
+ walletMapper.update(wallet, update);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isRightPwd(String wid, int pwd) {
+ return pwd == walletMapper.selectById(wid).getWalletPwd();
+ }
+
+ @Override
+ public boolean modifyPwd(String wid, int pwd) {
+ try {
+ CampusWallet wallet = new CampusWallet()
+ .setWalletId(wid)
+ .setWalletPwd(pwd);
+ walletMapper.updateById(wallet);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/FileUploadUtil.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/FileUploadUtil.java
new file mode 100644
index 0000000..13ecd33
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/FileUploadUtil.java
@@ -0,0 +1,52 @@
+/**
+ * @Class: FileUploadUtil
+ * @Date: 2022/9/20
+ * @Project: demo
+ * @Author: Colyn
+ * @Builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.utils;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+
+@Component
+public class FileUploadUtil {
+
+ public static String SaveFile(MultipartFile file, int type, String path, String pattern) throws IOException {
+
+ if (!file.isEmpty()) {
+ //获取文件名
+ String fileName = file.getOriginalFilename();
+ //获取文件后缀名。也可以在这里添加判断语句,规定特定格式的图片才能上传,否则拒绝保存。
+ assert fileName != null;
+ String suffixName = fileName.substring(fileName.lastIndexOf("."));
+ //支持的图片文件类型
+ List strings = Arrays.asList(".webp", ".png", ".jpg", ".jpeg", ".PNG", ".JPG", ".JPEG", ".WEBP");
+ if (strings.contains(suffixName)) {
+ //利用36位UUID重命名文件
+ fileName = (RandomDataUtil.getUUID36()) + suffixName;
+ System.out.println("fileName: " + fileName);
+ System.out.println("Path: " + path + "imgs" + pattern + type + pattern + fileName);
+ //文件转存到本地文件目录
+ try {
+ file.transferTo(new File(path + "imgs" + pattern + type + pattern + fileName));
+ return "/imgs/" + type + "/" + fileName;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ } else {
+ return null;
+ }
+ return null;
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JWTUtil.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JWTUtil.java
new file mode 100644
index 0000000..23739cf
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JWTUtil.java
@@ -0,0 +1,84 @@
+/**
+ * @title: JWTUtil
+ * @date: 2022/9/19 18:50
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.utils;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTCreator;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import org.springframework.stereotype.Component;
+
+import java.util.Calendar;
+import java.util.Map;
+
+
+@Component
+public class JWTUtil {
+ /**
+ * 过期时间,单位:秒,默认半小时过期
+ **/
+ private static final int EXPIRATION = 7;
+ /**
+ * 密钥,一般长度较长,内容较复杂
+ **/
+ private static final String SECRET = "d4e131a2a6f543c8a4995d7576de58f2";
+
+ private JWTUtil() {
+ }
+ /**
+ * 生成token header.payload.signature
+ * @param map 用户信息,以 Map 类型封装
+ * @return token字符串
+ */
+ public static String getToken(Map map) {
+ System.out.println("----------------------------------------\n密钥:"+SECRET+"\n-------------------------------------");
+ Calendar instance = Calendar.getInstance();
+ instance.add(Calendar.DATE, EXPIRATION); // 默认7天过期
+
+ //创建 JWTBuilder
+ JWTCreator.Builder builder = JWT.create();
+
+ //header不写则使用默认值
+ // payload
+ map.forEach(builder::withClaim);
+
+ String token = builder
+ .withExpiresAt(instance.getTime()) //过期时间
+ .sign(Algorithm.HMAC256(SECRET)); //签名算法
+
+ return token;
+ }
+
+ /**
+ * 验证token是否合法,若不合法则会抛出异常
+ * @param token token字符串
+ */
+ public static String verifyToken(String token, String userID) {
+ try {
+ DecodedJWT token_value = JWT.require(Algorithm.HMAC256(SECRET)).build().verify(token);
+ return token_value.getClaim(userID).asString();
+ } catch (JWTVerificationException | IllegalArgumentException e) {
+ e.printStackTrace();
+ //若token校验失败,则返回null
+ return null;
+ }
+
+ }
+
+ /**
+ * 获取token的信息,通过调用 DecodedJWT 的 get 方法,可以得到 token 的各种信息
+ * 该方法也可以和验证 token 方法合并
+ * @param token token字符串
+ * @return DecodedJWT
+ */
+ public static DecodedJWT getTokenInfo(String token) {
+ return JWT.require(Algorithm.HMAC256(SECRET)).build().verify(token);
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JsonResultUtil.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JsonResultUtil.java
new file mode 100644
index 0000000..44eba63
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/JsonResultUtil.java
@@ -0,0 +1,60 @@
+/**
+ * @title: JsonResultUtil
+ * @date: 2022/9/19 12:08
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.utils;
+
+import lombok.Data;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Data
+public class JsonResultUtil {
+ private T data;
+ private int code;
+ private String msg;
+
+ /**
+ * 若没有数据返回,默认状态码为 200,提示信息为“success”
+ */
+ public JsonResultUtil() {
+ this.code = 200;
+ this.msg = "success";
+ }
+
+ /**
+ * 若没有数据返回,可以人为指定状态码和提示信息
+ * @param code
+ * @param msg
+ */
+ public JsonResultUtil(int code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ /**
+ * 有数据返回时,状态码为 200,默认提示信息为“success”
+ * @param data
+ */
+ public JsonResultUtil(T data) {
+ this.data = data;
+ this.code = 200;
+ this.msg = "success";
+ }
+
+ /**
+ * 有数据返回,状态码为 200,人为指定提示信息
+ * @param data
+ * @param msg
+ */
+ public JsonResultUtil(T data, String msg) {
+ this.data = data;
+ this.code = 200;
+ this.msg = msg;
+ }
+}
diff --git a/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/RandomDataUtil.java b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/RandomDataUtil.java
new file mode 100644
index 0000000..c6d1c1a
--- /dev/null
+++ b/campus_sec_deal/src/main/java/edu/njust/campus_sec_deal/utils/RandomDataUtil.java
@@ -0,0 +1,76 @@
+/**
+ * @title: RandomDataUtil
+ * @date: 2022/9/18 21:02
+ * @projectName: campus_sec_deal
+ * @author: Colyn
+ * @builder: IntelliJ IDEA
+ */
+
+package edu.njust.campus_sec_deal.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.Date;
+import java.util.Random;
+import java.util.UUID;
+
+
+@Component
+public class RandomDataUtil {
+
+ public static String getIDByTime() {
+ Date date = new Date();
+ SimpleDateFormat format = new SimpleDateFormat("yyyMMddHHmmss");
+ return format.format(date);
+ }
+
+ public static String getSendTime() {
+ Date date = new Date();
+ SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
+ return format.format(date);
+ }
+
+ public static LocalDate getDate() {
+ return LocalDate.now();
+ }
+
+ public static LocalDateTime getDateTime() {
+ return LocalDateTime.now();
+ }
+
+ public static LocalTime getTime() {
+ return LocalTime.now();
+ }
+
+ public static String getUUID32() {
+ return UUID.randomUUID()
+ .toString()
+ .replace("-", "")
+ .toLowerCase();
+ }
+
+ public static String getUUID36() {
+ return UUID.randomUUID().toString().toLowerCase();
+ }
+
+ public static String getVerCode() {
+ //定义一个字符串(A-Z,a-z,0-9)即62位;
+ String str = "2zxcv7bnmlkjhg9fdsaqwe8rtyuiopQ6WERT0YUIOPAS4DFGH5JKL3ZXCVBNM1";
+ //由Random生成随机数
+ Random random = new Random();
+ StringBuffer sb = new StringBuffer();
+ //长度为几就循环几次
+ for (int i = 0; i < 4; ++i) {
+ //产生0-61的数字
+ int number = random.nextInt(62);
+ //将产生的数字通过length次承载到sb中
+ sb.append(str.charAt(number));
+ }
+ //将承载的字符转换成字符串
+ return sb.toString();
+ }
+}
diff --git a/campus_sec_deal/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/campus_sec_deal/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 0000000..5e884a1
--- /dev/null
+++ b/campus_sec_deal/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,24 @@
+{
+ "properties": [
+ {
+ "name": "campus.file.upload-location",
+ "type": "java.lang.String",
+ "description": "文件上传本地位置设置."
+ },
+ {
+ "name": "campus.default.user-sign",
+ "type": "java.lang.String",
+ "description": "用户默认个性签名设置."
+ },
+ {
+ "name": "campus.default.user-logo",
+ "type": "java.lang.String",
+ "description": "用户默认头像URL."
+ },
+ {
+ "name": "campus.file.upload-pattern",
+ "type": "java.lang.String",
+ "description": "文件路径匹配规则."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/campus_sec_deal/src/main/resources/application.properties b/campus_sec_deal/src/main/resources/application.properties
new file mode 100644
index 0000000..5e9dcb4
--- /dev/null
+++ b/campus_sec_deal/src/main/resources/application.properties
@@ -0,0 +1,65 @@
+# 应用名称
+spring.application.name=campus_sec_deal
+# 服务器端口
+server.port=8080
+# DataSource Config
+spring.datasource.username=root
+
+spring.datasource.password=Njust123
+
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+
+spring.datasource.url=jdbc:mysql://localhost:3306/campus_sec_deal?userUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+
+# 开启自动配置
+spring.servlet.multipart.enabled=true
+
+#单个最大文件大小,默认是1MB
+spring.servlet.multipart.max-file-size=10MB
+
+#总请求文件大小
+spring.servlet.multipart.max-request-size=100MB
+
+# 修改默认静态寻址资源路径
+# 如果是Windows下,则为 file:D:/upload/
+# 如果是Linux下,则为 file:/www/wwwroot/xxx/upload/
+spring.resources.static-locations=file:D:/upload/
+
+# -----------------自定义参数------------------------
+# 文件上传路径
+# 如果是Windows下,则为 /www/wwwroot/xxx/upload/
+# 如果是Linux下,则为 D:\\upload\\
+campus.file.upload-location=D:\\upload\\
+
+# 文件路径匹配规则
+# 如果是Windows下,则为 \\
+# 如果是Linux下,则为 /
+campus.file.upload-pattern=\\
+
+# 用户默认签名
+campus.default.user-sign=Oops, this guy is lazy.
+
+# 用户默认头像URL
+campus.default.user-logo=/imgs/0/default.jpg
+
+# 待付款超时时间 (min)
+campus.default.time-to-pay=30
+
+# 待交易超时时间 (min)
+campus.default.time-to-ex=5040
+
+# -------------------------------------------------
+
+# Mybatis-plus加载器
+mybatis-plus.mapper-locations=classpath:edu/njust/campus_sec_deal/**/mapper/*.xml
+mybatis-plus.configuration.call-setters-on-nulls=true
+
+# 分页框架
+pagehelper.helperDialect=mysql
+pagehelper.reasonable=true
+pagehelper.supportMethodsArguments=true
+pagehelper.params=count=countSql
+
+
diff --git a/campus_sec_deal/src/test/java/edu/njust/campus_sec_deal/CampusSecDealApplicationTests.java b/campus_sec_deal/src/test/java/edu/njust/campus_sec_deal/CampusSecDealApplicationTests.java
new file mode 100644
index 0000000..7b7afa4
--- /dev/null
+++ b/campus_sec_deal/src/test/java/edu/njust/campus_sec_deal/CampusSecDealApplicationTests.java
@@ -0,0 +1,172 @@
+package edu.njust.campus_sec_deal;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import edu.njust.campus_sec_deal.entity.*;
+import edu.njust.campus_sec_deal.mapper.*;
+import edu.njust.campus_sec_deal.service.CampusUserService;
+import edu.njust.campus_sec_deal.service.CampusWalletService;
+import edu.njust.campus_sec_deal.utils.RandomDataUtil;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.cglib.beans.BeanMap;
+
+import java.text.SimpleDateFormat;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.List;
+
+@SpringBootTest
+class CampusSecDealApplicationTests {
+
+ @Autowired
+ private CampusUserMapper stuMapper;
+ @Autowired
+ CampusWalletMapper walletMapper;
+
+ @Autowired
+ CampusOrderMapper orderMapper;
+
+ @Autowired
+ CampusPublishMapper publishMapper;
+
+ @Autowired
+ CampusChatMapper chatMapper;
+
+ @Test
+ void test01() {
+ //测试查询所有
+ List stus = stuMapper.selectList(null);
+ for (CampusUser stu : stus) {
+ System.out.println(stu);
+ }
+ }
+
+ @Test
+ void test02() {
+ QueryWrapper query = new QueryWrapper<>();
+
+// query.eq("user_pwd", "Admin123");
+ query.lambda()
+ .eq(CampusUser::getUserId, "20220920192450")
+ .eq(CampusUser::getUserTel, "18080808080")
+ .eq(CampusUser::getUserMail, "colyn@foxmail.com");
+ Long count = stuMapper.selectCount(query);
+ CampusUser user = stuMapper.selectById(Long.valueOf("20220920192450"));
+
+ System.out.println("--------------------------------------------------------------------------------");
+ System.out.println("The count: " + count);
+ System.out.println("UserById: " + user);
+ System.out.println("--------------------------------------------------------------------------------");
+ String str = (String) JSONObject.toJSONString(user);
+ Date date = new Date();
+ SimpleDateFormat format = new SimpleDateFormat("yyyMMddHHmmss");
+ System.out.println("UserById: " + str + "\nDate: " + format.format(date));
+
+ CampusUser user_info;
+ QueryWrapper get_query = new QueryWrapper<>();
+ get_query.lambda().eq(CampusUser::getUserMail, "colyn@foxmail.com");
+ user_info = stuMapper.selectOne(get_query);
+ System.out.println("get_query_mail: " + user_info);
+ }
+
+ @Test
+ void test03() {
+ CampusWallet wallet = new CampusWallet().setWalletId("20220920192450").setWalletPwd(222222).setWalletBalance(100F + walletMapper.selectById("20220920192450").getWalletBalance());
+ int result = walletMapper.updateById(wallet);
+ System.out.println(result);
+ }
+
+ @Test
+ void test04() {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.select("user_name").eq("user_id", "20220921213611");
+ CampusUser sysUsers = stuMapper.selectOne(queryWrapper);
+
+ System.out.println("--------------------------------------------------------------------------------");
+ System.out.println("sysUser: " + sysUsers);
+ System.out.println("--------------------------------------------------------------------------------");
+
+ }
+
+ @Test
+ void test05() {
+ //查询商品价格
+ QueryWrapper query = new QueryWrapper<>();
+
+ String publish_id = orderMapper.selectById("92934c838031400484abfe1c31601326").getGoodsId();
+ float price = publishMapper.selectById(publish_id).getPublishNprice();
+ System.out.println("--------------------------------------------------------------------------------");
+ System.out.println("publish_id: " + publish_id);
+ System.out.println("price: " + price);
+ System.out.println("--------------------------------------------------------------------------------");
+ }
+
+ @Test
+ void test06() {
+ System.out.println("--------------------------------------------------------------------------------");
+ List order = orderMapper.orderListALLByReceiver("20220921213624");
+ System.out.println("order: " + order);
+// .forEach(System.out::println);
+ System.out.println("--------------------------------------------------------------------------------");
+ }
+
+ @Autowired
+ CampusUserService service;
+
+// @Test
+// void test07() {
+// System.out.println("--------------------------------------------------------------------------------");
+// int result = service.Add(1, 3);
+// System.out.println("ServiceResult: " + result);
+// System.out.println("--------------------------------------------------------------------------------");
+// }
+
+// @Test
+// void test08(){
+//
+// CampusUser user = service.getOne(Wrappers.lambdaQuery().eq(CampusUser::getUserId, "20220921112424"),false);
+// System.out.println("--------------------------------------------------------------------------------");
+// System.out.println("service.getOne: " + user);
+// System.out.println("--------------------------------------------------------------------------------");
+// }
+
+ @Test
+ void test09() {
+ CampusChat chat = new CampusChat()
+ .setChatContent("Hello, everyone!")
+ .setChatId(RandomDataUtil.getIDByTime())
+ .setFromId("20220921112424")
+ .setToId("20220924120845")
+ .setSendTime(RandomDataUtil.getDateTime());
+ int result = chatMapper.insert(chat);
+
+// CampusUser user = service.getOne(Wrappers.lambdaQuery().eq(CampusUser::getUserId, "20220921112424"), false);
+ System.out.println("--------------------------------------------------------------------------------");
+ System.out.println("service.getOne: " + result);
+ System.out.println("--------------------------------------------------------------------------------");
+ }
+
+// @Test
+// void test10(){
+// List msgs = chatMapper.selectList(new QueryWrapper().eq("to_id", "20220922154423"));
+// msgs.forEach(System.out::println);
+// }
+
+ @Test
+ public void testSelectListPaged() {
+ PageHelper.startPage(1, 3);
+ List user = stuMapper.selectList(null);
+ PageInfo pageInfo = new PageInfo(user);
+ System.out.println("totalPage:"+pageInfo.getPages()+",totalInfo:"+pageInfo.getTotal()+",CurrentPage:"+pageInfo.getPageNum());
+ for (CampusUser stu : user){
+ System.out.println("name:"+stu.getUserName()+",id:"+stu.getUserId());
+ }
+ }
+}
diff --git a/create_demo_data.sql b/create_demo_data.sql
new file mode 100644
index 0000000..65bc11f
--- /dev/null
+++ b/create_demo_data.sql
@@ -0,0 +1,40 @@
+# 校园二手交易平台------campus_sec_deal测试脚本--------------------------------------
+# 作者: Colyn 日期: 2022-09-12
+# 数据库: MySQL 编码: utf8mb4 引擎: InnoDB 排序: utf8mb4_0900_ai_ci
+# ------------------------------------------------------------------------------
+# _________
+# \_ ___ \______ _____ ______ __ __ ______
+# / \ \/\__ \ / \ \___ \ | || \/ ___/
+# \ \____/ __ \| Y Y \ |_\ \| |_| /\___ \
+# \______ (____ /__|_| /| __/|_____//____/ /
+# \/ \/ \/ |__| \/
+# ------------------------------------------------------------------------------
+
+-- DATABASE DEMO TEST --
+USE campus_sec_deal;
+
+# #添加campus_user表数据------------------------------------------------------------
+INSERT INTO `campus_user`
+VALUES ('20220921112424', '汪汪队睡大觉', default, '18282828282', 'sdj@foxmail.com', default, default, 'Admin123'),
+ ('20220922034526', '汪汪队离大谱', default, '18080808080', 'ldp@foxmail.com', default, default, 'Admin123'),
+ ('20220922154423', '汪汪队立大功', default, '18181818181', 'ldg@foxmail.com', default, default, 'Admin123'),
+ ('20220923080814', '汪汪队吹大牛', default, '17979797979', 'cdn@foxmail.com', default, default, 'Admin123'),
+ ('20220924120845', '汪汪队熬大夜', default, '18383838383', 'ady@foxmail.com', default, default, 'Admin123');
+SELECT * FROM `campus_user`;
+
+# #添加campus_publish表数据------------------------------------------------------------
+INSERT INTO `campus_publish`
+VALUES ('20220924114523', '20220921112424', '18282828282', default, 0, default, '二手华为P50', default, 0, 6999.10, 3999.20, default, '/imgs/0/37c92cf4-6a25-46d0-633c-46e7e2fa1bcb.png'),
+ ('20220921112424', '20220922034526', '18080808080', default, 1, default, '二手联想拯救者', default, 0, 11999.00, 5999.00, default, '/imgs/0/37c92cf4-6a25-46d0-633c-46e7e2fa1bcb.png');
+SELECT * FROM `campus_publish`;
+
+# #添加campus_order表数据------------------------------------------------------------
+INSERT INTO `campus_order`
+VALUES ('f1c92cf46a2546d0633c46e7e2fa1bf7', '20220924114523', default, '20220923080814', '17979797979', '美利坚合众国华盛顿特区宾夕法尼亚大道1600号', default),
+ ('14fa4a97f9d547b780cbd375d400a6ee', '20220921112424', default, '20220924120845', '18383838383', '美利坚合众国华盛顿特区宾夕法尼亚大道1600号', default);
+SELECT * FROM `campus_order`;
+#
+#添加campus_chat表数据------------------------------------------------------------
+INSERT INTO `campus_chat`
+VALUES (default, default, '20220921112424', '抓你抓你咯!', default, '20220922154423');
+SELECT * FROM `campus_chat`;
\ No newline at end of file
diff --git a/upload/imgs/0/2c0cdd40-08bf-4f55-9b24-7ef67447dd80.jpg b/upload/imgs/0/2c0cdd40-08bf-4f55-9b24-7ef67447dd80.jpg
new file mode 100644
index 0000000..9cb2353
Binary files /dev/null and b/upload/imgs/0/2c0cdd40-08bf-4f55-9b24-7ef67447dd80.jpg differ
diff --git a/upload/imgs/0/6850cde0-f45c-4cf9-b72d-08e1f14a62e7.jpg b/upload/imgs/0/6850cde0-f45c-4cf9-b72d-08e1f14a62e7.jpg
new file mode 100644
index 0000000..3060178
Binary files /dev/null and b/upload/imgs/0/6850cde0-f45c-4cf9-b72d-08e1f14a62e7.jpg differ
diff --git a/upload/imgs/0/96cb96ca-3b2e-417b-83b4-8534e14fdce3.png b/upload/imgs/0/96cb96ca-3b2e-417b-83b4-8534e14fdce3.png
new file mode 100644
index 0000000..8942ab7
Binary files /dev/null and b/upload/imgs/0/96cb96ca-3b2e-417b-83b4-8534e14fdce3.png differ
diff --git a/upload/imgs/0/9b87533c-321a-493e-a0d5-6dfb02eae702.jpg b/upload/imgs/0/9b87533c-321a-493e-a0d5-6dfb02eae702.jpg
new file mode 100644
index 0000000..fc198e0
Binary files /dev/null and b/upload/imgs/0/9b87533c-321a-493e-a0d5-6dfb02eae702.jpg differ
diff --git a/upload/imgs/0/default.jpg b/upload/imgs/0/default.jpg
new file mode 100644
index 0000000..1deb851
Binary files /dev/null and b/upload/imgs/0/default.jpg differ
diff --git a/upload/imgs/1/6b2d7d24-534e-4a63-b5ba-4baaa616a494.jpeg b/upload/imgs/1/6b2d7d24-534e-4a63-b5ba-4baaa616a494.jpeg
new file mode 100644
index 0000000..ff5d144
Binary files /dev/null and b/upload/imgs/1/6b2d7d24-534e-4a63-b5ba-4baaa616a494.jpeg differ
diff --git a/upload/imgs/1/fef64389-2b4f-4b28-b71e-6c40f6f6ac21.jpeg b/upload/imgs/1/fef64389-2b4f-4b28-b71e-6c40f6f6ac21.jpeg
new file mode 100644
index 0000000..ff5d144
Binary files /dev/null and b/upload/imgs/1/fef64389-2b4f-4b28-b71e-6c40f6f6ac21.jpeg differ
diff --git a/upload/imgs/2/d851b5ce-d3f1-420f-8a5c-33eaa16887c3.jpeg b/upload/imgs/2/d851b5ce-d3f1-420f-8a5c-33eaa16887c3.jpeg
new file mode 100644
index 0000000..2561c5e
Binary files /dev/null and b/upload/imgs/2/d851b5ce-d3f1-420f-8a5c-33eaa16887c3.jpeg differ