郭超 4 gadi atpakaļ
revīzija
e1321520c4
41 mainītis faili ar 2010 papildinājumiem un 0 dzēšanām
  1. BIN
      .DS_Store
  2. 31 0
      .gitignore
  3. 118 0
      .mvn/wrapper/MavenWrapperDownloader.java
  4. BIN
      .mvn/wrapper/maven-wrapper.jar
  5. 2 0
      .mvn/wrapper/maven-wrapper.properties
  6. 88 0
      mooctestOrgBackend
  7. 310 0
      mvnw
  8. 182 0
      mvnw.cmd
  9. 154 0
      pom.xml
  10. BIN
      src/main/.DS_Store
  11. 8 0
      src/main/docker/Dockerfile
  12. 13 0
      src/main/java/mooctest/org/backend/site/SiteApplication.java
  13. 18 0
      src/main/java/mooctest/org/backend/site/annotation/AutoValue.java
  14. 37 0
      src/main/java/mooctest/org/backend/site/command/NotificationCommand.java
  15. 50 0
      src/main/java/mooctest/org/backend/site/configuration/MongoConfig.java
  16. 20 0
      src/main/java/mooctest/org/backend/site/configuration/MongoDBConfiguration.java
  17. 32 0
      src/main/java/mooctest/org/backend/site/configuration/OSSConfiguration.java
  18. 118 0
      src/main/java/mooctest/org/backend/site/controller/NotificationController.java
  19. 67 0
      src/main/java/mooctest/org/backend/site/controller/UploadController.java
  20. 28 0
      src/main/java/mooctest/org/backend/site/dao/NotificationDao.java
  21. 12 0
      src/main/java/mooctest/org/backend/site/data/DeletedStatus.java
  22. 12 0
      src/main/java/mooctest/org/backend/site/data/NotificationType.java
  23. 13 0
      src/main/java/mooctest/org/backend/site/data/dto/NotificationDTO.java
  24. 28 0
      src/main/java/mooctest/org/backend/site/data/vo/NotificationVO.java
  25. 62 0
      src/main/java/mooctest/org/backend/site/domainObject/Notification.java
  26. 8 0
      src/main/java/mooctest/org/backend/site/domainObject/UploadType.java
  27. 10 0
      src/main/java/mooctest/org/backend/site/exception/BaseException.java
  28. 11 0
      src/main/java/mooctest/org/backend/site/factory/NotificationFactory.java
  29. 46 0
      src/main/java/mooctest/org/backend/site/model/NotificationPO.java
  30. 24 0
      src/main/java/mooctest/org/backend/site/reposity/INotificationRepo.java
  31. 55 0
      src/main/java/mooctest/org/backend/site/reposity/NotificationRepo.java
  32. 102 0
      src/main/java/mooctest/org/backend/site/service/NotificationService.java
  33. 14 0
      src/main/java/mooctest/org/backend/site/service/UploadService.java
  34. 53 0
      src/main/java/mooctest/org/backend/site/service/impl/OSSUploadServiceImpl.java
  35. 82 0
      src/main/java/mooctest/org/backend/site/utils/Converter.java
  36. 73 0
      src/main/java/mooctest/org/backend/site/utils/MongoAPIUtils.java
  37. BIN
      src/main/resources/.DS_Store
  38. 74 0
      src/main/resources/application.yml
  39. 34 0
      src/main/resources/bootstrap.yaml
  40. 13 0
      src/test/java/mooctest/org/backend/site/SiteApplicationTests.java
  41. 8 0
      tool4deploy/Dockerfile

BIN
.DS_Store


+ 31 - 0
.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/

+ 118 - 0
.mvn/wrapper/MavenWrapperDownloader.java

@@ -0,0 +1,118 @@
+/*
+ * Copyright 2012-2019 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.5";
+    /**
+     * 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();
+    }
+
+}

BIN
.mvn/wrapper/maven-wrapper.jar


+ 2 - 0
.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar

+ 88 - 0
mooctestOrgBackend

@@ -0,0 +1,88 @@
+#!/bin/bash
+version="1.0.1";
+BASE_DIR=/tmp
+appName=mooctest-org-backend-1.0-SNAPSHOT.jar
+if [ -z $appName ];then
+    appName=`ls -t |grep .jar$ |head -n1`
+fi
+
+function start()
+{
+	count=`ps -ef |grep java|grep $appName|wc -l`
+	if [ $count != 0 ];then
+		echo "Maybe $appName is running, please check it..."
+	else
+		echo "The $appName is starting..."
+		nohup java -jar ./$appName -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -Xms512M -Xmx4G > /dev/null 2>&1 &
+	fi
+}
+
+function stop()
+{
+	appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
+	if [ -z $appId ];then
+	    echo "Maybe $appName not running, please check it..."
+	else
+        echo "The $appName is stopping..."
+        kill $appId
+	fi
+}
+
+function restart()
+{
+    # get release version
+    releaseApp=`ls -t |grep .jar$ |head -n1`
+
+    # get last version
+    lastVersionApp=`ls -t |grep .jar$ |head -n2 |tail -n1`
+
+    appName=$lastVersionApp
+    stop
+    for i in {5..1}
+    do
+        echo -n "$i "
+        sleep 1
+    done
+    echo 0
+
+    appName=$releaseApp
+    start
+}
+
+function status()
+{
+    appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
+	if [ -z $appId ]
+	then
+	    echo -e "\033[31m Not running \033[0m"
+	else
+	    echo -e "\033[32m Running [$appId] \033[0m"
+	fi
+}
+
+
+function usage()
+{
+    echo "Usage: $0 {start|stop|restart|status|stop -f}"
+    echo "Example: $0 start"
+    exit 1
+}
+
+case $1 in
+	start)
+	start;;
+
+	stop)
+	stop;;
+
+	restart)
+	restart;;
+
+	status)
+	status;;
+
+	*)
+	usage;;
+esac
+
+

+ 310 - 0
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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 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.5/maven-wrapper-0.5.5.jar"
+    else
+      jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.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 "$@"

+ 182 - 0
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 Maven2 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 key stroke 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.5/maven-wrapper-0.5.5.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.5/maven-wrapper-0.5.5.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%

+ 154 - 0
pom.xml

@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.1.1.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>mooctest.org.backend</groupId>
+    <artifactId>mooctest-org-backend</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>site</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <docker.image.prefix>guochaodocker</docker.image.prefix>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>18.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.5.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+        </dependency>
+
+        <!-- Nacos Client -->
+        <!-- 允许服务注册到nacos中 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>0.9.0.RELEASE</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>guava</artifactId>
+                    <groupId>com.google.guava</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>archaius-core</artifactId>
+                    <groupId>com.netflix.archaius</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>servo-core</artifactId>
+                    <groupId>com.netflix.servo</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- 允许服务向nacos拉取配置-->
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-alibaba-nacos-config</artifactId>-->
+<!--            <version>0.9.0.RELEASE</version>-->
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <artifactId>guava</artifactId>-->
+<!--                    <groupId>com.google.guava</groupId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
+<!--        </dependency>-->
+
+        <!-- actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.6</version>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <!--整合Spring Cloud Alibaba-->
+            <dependency>
+                <groupId>com.alibaba.cloud</groupId>
+                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
+                <version>2.1.0.RELEASE</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <!-- Docker maven plugin -->
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.0.0</version>
+                <configuration>
+                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
+                    <dockerDirectory>src/main/docker</dockerDirectory>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

BIN
src/main/.DS_Store


+ 8 - 0
src/main/docker/Dockerfile

@@ -0,0 +1,8 @@
+FROM openjdk:8-jdk-alpine
+MAINTAINER guochao 1021172957@qq.com
+EXPOSE 8090
+ENV TZ=Asia/Shanghai
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+ADD mooctest-org-backend-1.0-SNAPSHOT.jar /root
+WORKDIR /root
+ENTRYPOINT ["java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "mooctest-org-backend-1.0-SNAPSHOT.jar"]

+ 13 - 0
src/main/java/mooctest/org/backend/site/SiteApplication.java

@@ -0,0 +1,13 @@
+package mooctest.org.backend.site;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SiteApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(SiteApplication.class, args);
+    }
+
+}

+ 18 - 0
src/main/java/mooctest/org/backend/site/annotation/AutoValue.java

@@ -0,0 +1,18 @@
+package mooctest.org.backend.site.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 自定义自增长ID注解
+ *
+ * @author xq
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.FIELD })
+public @interface AutoValue {
+
+}

+ 37 - 0
src/main/java/mooctest/org/backend/site/command/NotificationCommand.java

@@ -0,0 +1,37 @@
+package mooctest.org.backend.site.command;
+
+import lombok.Data;
+import mooctest.org.backend.site.domainObject.Notification;
+import mooctest.org.backend.site.factory.NotificationFactory;
+import org.springframework.beans.BeanUtils;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 20:34
+ */
+@Data
+public class NotificationCommand {
+    @NotNull(message = "title不可为空")
+    private String title;
+    @NotNull(message = "内容不可为空")
+    private String content;
+    private String ossUrl;
+    private String pictureUrl;
+    private int type;
+    private int isThirdParty;
+    private int isChangingCreateTime = 0;
+
+    public Notification toNotification(){
+        Notification notification = NotificationFactory.CreateNotification();
+        BeanUtils.copyProperties(this, notification);
+        if(this.ossUrl != null && this.ossUrl != ""){
+            notification.setOssUrl(this.ossUrl);
+        }
+        if(this.pictureUrl != null && this.pictureUrl != ""){
+            notification.setPictureUrl(this.pictureUrl);
+        }
+        return notification;
+    }
+}

+ 50 - 0
src/main/java/mooctest/org/backend/site/configuration/MongoConfig.java

@@ -0,0 +1,50 @@
+//package mooctest.org.backend.site.config;
+//
+//import com.mongodb.MongoClientOptions;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Qualifier;
+//import org.springframework.boot.autoconfigure.mongo.MongoProperties;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.Primary;
+//import org.springframework.core.env.Environment;
+//import org.springframework.data.mongodb.MongoDbFactory;
+//import org.springframework.data.mongodb.core.MongoTemplate;
+//import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
+//import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+//
+///**
+// * @author guochao
+// * @date 2019-12-18 17:49
+// */
+//@Configuration
+//@EnableMongoRepositories(
+//        basePackages = "mooctest.org.backend.site.dao",
+//        mongoTemplateRef = "mongoTemplate")
+//public class MongoConfig {
+//    @Autowired
+//    private Environment environment;
+//
+//
+//    @Primary
+//    @Bean(name = "mongoTemplate")
+//    public MongoTemplate mongoTemplate(@Qualifier("mongoFactory") MongoDbFactory mongoFactory) throws Exception {
+//        return new MongoTemplate(mongoFactory);
+//    }
+//
+//    @Primary
+//    @Bean("mongoFactory")
+//    public MongoDbFactory mongoFactory(@Qualifier("mongoProperties") MongoProperties mongoProperties) throws Exception {
+//        return new SimpleMongoDbFactory(
+//                mongoProperties.createMongoClient(MongoClientOptions.builder().build(), environment),
+//                mongoProperties.getDatabase());
+//    }
+//
+//    @Bean(name = "mongoProperties")
+//    @ConfigurationProperties(prefix = "mongodb")
+//    @Primary
+//    public MongoProperties properties() throws Exception {
+//        return new MongoProperties();
+//    }
+//}

+ 20 - 0
src/main/java/mooctest/org/backend/site/configuration/MongoDBConfiguration.java

@@ -0,0 +1,20 @@
+//package mooctest.org.backend.site.config;
+//
+//import lombok.Data;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.stereotype.Component;
+//
+///**
+// * Created by major on 2017/12/21.
+// */
+//@Data
+//@Component
+//@ConfigurationProperties(prefix = "mongodb")
+//public class MongoDBConfiguration {
+//    private String host;
+//    private String port;
+//    private String db;
+//    private String notificationCollection;
+//    private String base64Auth;
+//
+//}

+ 32 - 0
src/main/java/mooctest/org/backend/site/configuration/OSSConfiguration.java

@@ -0,0 +1,32 @@
+package mooctest.org.backend.site.configuration;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Data
+@Configuration
+public class OSSConfiguration {
+
+    @Value("${oss.accessKeyId}")
+    private String accessKeyId;
+
+    @Value(("${oss.accessKeySecret}"))
+    private String accessKeySecret;
+
+    @Value("${oss.endPoint}")
+    private String endPoint;
+
+    @Value("${oss.bucketName}")
+    private String bucketName;
+
+    public String getBaseUrl(){
+        return "http://"+bucketName+"."+endPoint+"/";
+    }
+
+    public OSS ossClient(){
+        return new OSSClientBuilder().build(endPoint, accessKeyId, accessKeySecret);
+    }
+}

+ 118 - 0
src/main/java/mooctest/org/backend/site/controller/NotificationController.java

@@ -0,0 +1,118 @@
+package mooctest.org.backend.site.controller;
+
+import lombok.extern.slf4j.Slf4j;
+import mooctest.org.backend.site.command.NotificationCommand;
+import mooctest.org.backend.site.data.vo.NotificationVO;
+import mooctest.org.backend.site.exception.BaseException;
+import mooctest.org.backend.site.service.NotificationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 16:43
+ */
+@RefreshScope
+@RestController
+@Slf4j
+public class NotificationController {
+
+    @Value("${username:lily}")
+    private String username;
+
+    @RequestMapping("/username")
+    public String get() {
+        return username;
+    }
+
+    @Autowired
+    private NotificationService notificationService;
+
+    /**
+     * 查看首页大赛通知
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/api/view/index", method = RequestMethod.GET)
+    public List<NotificationVO> getIndexNotification(){
+        log.info("获取大赛首页通知列表");
+        List<NotificationVO> notificationDTOList = notificationService.getIndexNotification();
+        return notificationDTOList;
+    }
+
+    /**
+     * 查看所有大赛通知
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/api/view", method = RequestMethod.GET)
+    public List<NotificationVO> getAllNotification(){
+        log.info("获取大赛通知列表");
+        List<NotificationVO> notificationDTOList = notificationService.getAllNotification();
+        return notificationDTOList;
+    }
+
+    /**
+     * 查看指定大赛通知
+     * @param id
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/api/view/{id}", method = RequestMethod.GET)
+    public NotificationVO getNotification(@PathVariable(value = "id") Long id){
+        NotificationVO notificationDTO = notificationService.getNotificationById(id);
+        return notificationDTO;
+    }
+
+    /**
+     * 校验密码
+     * @return
+     */
+    @RequestMapping(value = "/api/checkPWD/{password}", method = RequestMethod.GET)
+    public boolean checkPassword(@PathVariable("password") String password){
+        return notificationService.checkPassword(password);
+    }
+
+    /**
+     * 创建大赛通知
+     * @param notificationCommand
+     * @param result
+     * @return
+     */
+    @RequestMapping(value = "/api/create", method = RequestMethod.POST)
+    public NotificationVO createNotification(@Validated @RequestBody NotificationCommand notificationCommand, BindingResult result){
+        if (result.hasErrors()) {
+            throw new BaseException(result.getFieldErrors().toString());
+        }
+        return notificationService.createNotification(notificationCommand);
+    }
+
+    /**
+     * 更新指定大赛通知
+     * @param notificationCommand
+     * @param result
+     * @return
+     */
+    @RequestMapping(value = "/api/update/{notificationId}", method = RequestMethod.PUT)
+    public NotificationVO updateNotification(@Validated @RequestBody NotificationCommand notificationCommand, @PathVariable("notificationId") Long notificationId, BindingResult result){
+        if (result.hasErrors()) {
+            throw new BaseException(result.getFieldErrors().toString());
+        }
+        return notificationService.updateNotification(notificationCommand, notificationId);
+    }
+
+    /**
+     * 删除指定大赛通知
+     * @return
+     */
+    @RequestMapping(value = "/api/delete/{notificationId}", method = RequestMethod.DELETE)
+    public Boolean deletedNotification(@PathVariable("notificationId") Long notificationId){
+        return notificationService.deleteNotification(notificationId);
+    }
+}

+ 67 - 0
src/main/java/mooctest/org/backend/site/controller/UploadController.java

@@ -0,0 +1,67 @@
+package mooctest.org.backend.site.controller;
+
+import mooctest.org.backend.site.service.UploadService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/files")
+public class UploadController {
+
+    @Autowired
+    private UploadService uploadService;
+
+//    @RequestMapping(value = "/notificationDoc", method = RequestMethod.POST)
+//    public Map<String, Object> uploadRequirementDoc(@RequestPart(name = "file") MultipartFile[] uploadFile){
+//        Map<String, Object> map = new HashMap<>();
+////        List<Map<String, Object>> mapList = new ArrayList<>();
+//        if(uploadFile != null && uploadFile.length > 0){
+//            for(MultipartFile file : uploadFile){
+//                String fileName = file.getOriginalFilename();
+//                String url = uploadService.uploadDoc(file);
+//                map.put("uploaded", 1);
+//                map.put("fileName", fileName);
+//                map.put("url", url);
+////                mapList.add(map);
+//            }
+//        }else{
+//            map.put("message", "No file is uploaded");
+////            mapList.add(map);
+//        }
+////        return mapList;
+//        return map;
+//    }
+    @RequestMapping(value = "/notificationDoc", method = RequestMethod.POST)
+    public Map<String, Object> uploadRequirementDoc(@RequestPart(name = "file") MultipartFile[] uploadFile){
+        Map<String, Object> map = new HashMap<>();
+        if(uploadFile != null && uploadFile.length > 0){
+            for(MultipartFile file : uploadFile){
+                String fileName = file.getOriginalFilename();
+                String url = uploadService.uploadDoc(file);
+                map.put("uploaded", 1);
+                map.put("fileName", fileName);
+                map.put("url", url);
+            }
+        }else{
+            map.put("message", "No file is uploaded");
+        }
+        return map;
+    }
+
+    @RequestMapping(value = "/notificationDocOne", method = RequestMethod.POST)
+    public Map uploadRequirementDocOne(@RequestPart(name = "upload", required = false) MultipartFile uploadFile){
+        Map<String, Object> map = new HashMap<>();
+        String fileName = uploadFile.getOriginalFilename();
+        String url = uploadService.uploadDoc(uploadFile);
+        map.put("uploaded", 1);
+        map.put("fileName", fileName);
+        map.put("url", url);
+        return map;
+    }
+}

+ 28 - 0
src/main/java/mooctest/org/backend/site/dao/NotificationDao.java

@@ -0,0 +1,28 @@
+package mooctest.org.backend.site.dao;
+
+import mooctest.org.backend.site.model.NotificationPO;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import java.util.List;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:38
+ */
+@Component
+public interface NotificationDao extends CrudRepository<NotificationPO, Long> {
+
+    @Query(value = "select * from notification where N_IS_DELETED = ?1 order by N_TYPE DESC, N_CREATE_TIME DESC limit ?2", nativeQuery = true)
+    List<NotificationPO> findOrderByIdDescLimit(Integer notDeleted, int limitCount);
+
+    @Query(value = "select * from notification where N_IS_DELETED = ?1 order by N_TYPE DESC, N_CREATE_TIME DESC", nativeQuery = true)
+    List<NotificationPO> findAll(Integer notDeleted);
+
+    @Query(value = "select * from notification where N_TYPE = ?1 and N_IS_DELETED = ?2 order by N_CREATE_TIME DESC", nativeQuery = true)
+    List<NotificationPO> findAllByType(int type, Integer notDeleted);
+
+    Optional<NotificationPO> findByIdAndDeletedStatus(Long id, int deletedStatus);
+
+}

+ 12 - 0
src/main/java/mooctest/org/backend/site/data/DeletedStatus.java

@@ -0,0 +1,12 @@
+package mooctest.org.backend.site.data;
+
+/**
+ * @author guochao
+ * @date 2020-03-30 17:13
+ */
+public class DeletedStatus {
+
+    public static final Integer NOT_DELETED = 0;
+    public static final Integer IS_DELETED = 1;
+
+}

+ 12 - 0
src/main/java/mooctest/org/backend/site/data/NotificationType.java

@@ -0,0 +1,12 @@
+package mooctest.org.backend.site.data;
+
+/**
+ * @author guochao
+ * @date 2020-03-30 17:13
+ */
+public class NotificationType {
+
+    public static final Integer GENERATION = 0;
+    public static final Integer NEW = 1;
+    public static final Integer TOP = 2;
+}

+ 13 - 0
src/main/java/mooctest/org/backend/site/data/dto/NotificationDTO.java

@@ -0,0 +1,13 @@
+package mooctest.org.backend.site.data.dto;
+
+import lombok.Data;
+import mooctest.org.backend.site.data.vo.NotificationVO;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 20:54
+ */
+@Data
+public class NotificationDTO {
+    private NotificationVO notificationVO;
+}

+ 28 - 0
src/main/java/mooctest/org/backend/site/data/vo/NotificationVO.java

@@ -0,0 +1,28 @@
+package mooctest.org.backend.site.data.vo;
+
+import lombok.Data;
+import mooctest.org.backend.site.domainObject.Notification;
+import org.springframework.beans.BeanUtils;
+
+import java.sql.Timestamp;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 20:54
+ */
+@Data
+public class NotificationVO {
+    private Long id;
+    private String title;
+    private String content;
+    private String pictureUrl;
+    private String ossUrl;
+    private int type;
+    private int isThirdParty;
+    private int deletedStatus;
+    private Timestamp createTime;
+
+    public NotificationVO(Notification notification){
+        BeanUtils.copyProperties(notification, this);
+    }
+}

+ 62 - 0
src/main/java/mooctest/org/backend/site/domainObject/Notification.java

@@ -0,0 +1,62 @@
+package mooctest.org.backend.site.domainObject;
+
+import lombok.Data;
+import mooctest.org.backend.site.command.NotificationCommand;
+import mooctest.org.backend.site.data.DeletedStatus;
+import mooctest.org.backend.site.data.NotificationType;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:40
+ */
+@Data
+public class Notification {
+    private Long id;
+    private String title;
+    private String content;
+    private String pictureUrl;
+    private String ossUrl;
+    private int type;
+    private int isThirdParty;
+    private int deletedStatus;
+    private int isChangingCreateTime = 0;
+    private Timestamp createTime;
+
+
+    public Notification createNotification(){
+        this.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        return this;
+    }
+
+
+    public void update(NotificationCommand notificationModify) {
+        this.setTitle(notificationModify.getTitle());
+        this.setContent(notificationModify.getContent());
+        if(notificationModify.getPictureUrl() != null && notificationModify.getPictureUrl() != ""){
+            this.setOssUrl(notificationModify.getPictureUrl());
+        }
+        if(notificationModify.getOssUrl() != null && notificationModify.getOssUrl() != ""){
+            this.setOssUrl(notificationModify.getOssUrl());
+        }
+        if(notificationModify.getIsChangingCreateTime() == 1){
+            this.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        }
+        this.setType(notificationModify.getType());
+    }
+
+    public void delete() {
+        this.deletedStatus = DeletedStatus.IS_DELETED;
+    }
+
+    public void changeTypeToNew() {
+        this.type = NotificationType.NEW;
+    }
+
+    public void changeTypeToGeneration() {
+        this.type = NotificationType.GENERATION;
+    }
+}

+ 8 - 0
src/main/java/mooctest/org/backend/site/domainObject/UploadType.java

@@ -0,0 +1,8 @@
+package mooctest.org.backend.site.domainObject;
+
+/**
+ * @说明: 上传文件的类型表示,与OSS中的文件夹相对应
+ */
+public class UploadType {
+    public static final String DOC = "mooctest-org/";
+}

+ 10 - 0
src/main/java/mooctest/org/backend/site/exception/BaseException.java

@@ -0,0 +1,10 @@
+package mooctest.org.backend.site.exception;
+
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+public class BaseException extends RuntimeException {
+    public BaseException(String msg){
+        super(msg);
+    }
+}

+ 11 - 0
src/main/java/mooctest/org/backend/site/factory/NotificationFactory.java

@@ -0,0 +1,11 @@
+package mooctest.org.backend.site.factory;
+
+import mooctest.org.backend.site.domainObject.Notification;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 20:16
+ */
+public class NotificationFactory {
+    public static Notification CreateNotification(){return new Notification();}
+}

+ 46 - 0
src/main/java/mooctest/org/backend/site/model/NotificationPO.java

@@ -0,0 +1,46 @@
+package mooctest.org.backend.site.model;
+
+import lombok.Data;
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:40
+ */
+@Data
+@Entity
+@Table(name="notification")
+public class NotificationPO implements Serializable {
+
+    @Id
+    @Column(name = "N_ID")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    @Column(name = "N_TITLE")
+    private String title;
+
+    @Column(name = "N_CONTENT")
+    private String content;
+
+    @Column(name = "N_PICTURE_OSS_URL")
+    private String pictureUrl;
+
+    @Column(name = "N_FILE_OSS_URL")
+    private String ossUrl;
+
+    @Column(name = "N_TYPE")
+    private int type;
+
+    @Column(name = "N_IS_THIRD_PARTY")
+    private int isThirdParty;
+
+    @Column(name = "N_IS_DELETED")
+    private int deletedStatus;
+
+    @Column(name = "N_CREATE_TIME")
+    private Timestamp createTime;
+
+}

+ 24 - 0
src/main/java/mooctest/org/backend/site/reposity/INotificationRepo.java

@@ -0,0 +1,24 @@
+package mooctest.org.backend.site.reposity;
+
+import mooctest.org.backend.site.domainObject.Notification;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:36
+ */
+@Service
+public interface INotificationRepo {
+
+    List<Notification> getAllNotification();
+
+    List<Notification> getIndexNotification(int limitCount);
+
+    List<Notification> getNotificationByType(int type);
+
+    Notification getNotificationById(Long id);
+
+    Long saveNotification(Notification notification);
+}

+ 55 - 0
src/main/java/mooctest/org/backend/site/reposity/NotificationRepo.java

@@ -0,0 +1,55 @@
+package mooctest.org.backend.site.reposity;
+
+import mooctest.org.backend.site.dao.NotificationDao;
+import mooctest.org.backend.site.data.DeletedStatus;
+import mooctest.org.backend.site.domainObject.Notification;
+import mooctest.org.backend.site.exception.BaseException;
+import mooctest.org.backend.site.model.NotificationPO;
+import mooctest.org.backend.site.utils.Converter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:36
+ */
+@Component
+public class NotificationRepo implements INotificationRepo{
+
+    @Autowired
+    private NotificationDao notificationDao;
+
+    @Override
+    public List<Notification> getAllNotification(){
+        return notificationDao.findAll(DeletedStatus.NOT_DELETED).stream().map(notificationPO -> Converter.convert(Notification.class, notificationPO)).collect(Collectors.toList());
+    }
+
+    @Override
+    public List<Notification> getIndexNotification(int limitCount){
+        return notificationDao.findOrderByIdDescLimit(DeletedStatus.NOT_DELETED, limitCount).stream().map(notificationPO -> Converter.convert(Notification.class, notificationPO)).collect(Collectors.toList());
+    }
+
+    @Override
+    public List<Notification> getNotificationByType(int type){
+        return notificationDao.findAllByType(type, DeletedStatus.NOT_DELETED).stream().map(notificationPO -> Converter.convert(Notification.class, notificationPO)).collect(Collectors.toList());
+    }
+
+    @Override
+    public Notification getNotificationById(Long id) {
+        Optional<NotificationPO> notificationOptional = notificationDao.findByIdAndDeletedStatus(id, DeletedStatus.NOT_DELETED);
+        if(!notificationOptional.isPresent()){
+            throw new BaseException("无此通知的信息!");
+        }
+        return Converter.convert(Notification.class, notificationOptional.get());
+    }
+
+    @Override
+    public Long saveNotification(Notification notification) {
+        return notificationDao.save(Converter.convert(NotificationPO.class, notification)).getId();
+    }
+
+}

+ 102 - 0
src/main/java/mooctest/org/backend/site/service/NotificationService.java

@@ -0,0 +1,102 @@
+package mooctest.org.backend.site.service;
+
+import lombok.extern.slf4j.Slf4j;
+import mooctest.org.backend.site.command.NotificationCommand;
+import mooctest.org.backend.site.data.DeletedStatus;
+import mooctest.org.backend.site.data.NotificationType;
+import mooctest.org.backend.site.data.vo.NotificationVO;
+import mooctest.org.backend.site.domainObject.Notification;
+import mooctest.org.backend.site.reposity.INotificationRepo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author guochao
+ * @date 2019-12-18 17:36
+ */
+@Service
+@Slf4j
+public class NotificationService {
+
+    @Autowired
+    private INotificationRepo notificationRepo;
+    @Value("${password}")
+    private String correctPassword;
+    @Value("${limit.count}")
+    private String limitCount;
+
+    public List<NotificationVO> getIndexNotification(){
+        return notificationRepo.getIndexNotification(Integer.parseInt(limitCount))
+                .stream().map(notification -> new NotificationVO(notification)).collect(Collectors.toList());
+    }
+
+    public List<NotificationVO> getAllNotification(){
+        return notificationRepo.getAllNotification()
+                .stream().map(notification -> new NotificationVO(notification)).collect(Collectors.toList());
+    }
+
+    public NotificationVO getNotificationById(Long id) {
+        Notification notification = notificationRepo.getNotificationById(id);
+        log.info("获取id为:{} title为:\"{}\" 的大赛通知", id, notification.getTitle());
+        return new NotificationVO(notification);
+    }
+
+    public NotificationVO createNotification(NotificationCommand notificationCommand) {
+        Notification notification = notificationCommand.toNotification();
+        notification.createNotification();
+        Long id = notificationRepo.saveNotification(notification);
+        notification.setId(id);
+        log.info("创建id为:{} title为:\"{}\" 的大赛通知", id, notification.getTitle());
+        checkAndSaveNotification(notificationCommand, notification);
+        return new NotificationVO(notification);
+    }
+
+    public NotificationVO updateNotification(NotificationCommand notificationCommand, Long notificationId) {
+        Notification notification = notificationRepo.getNotificationById(notificationId);
+        log.info("修改id为:{} title为:\"{}\" 的大赛通知", notificationId, notificationCommand.getTitle());
+        notification.update(notificationCommand);
+        checkAndSaveNotification(notificationCommand, notification);
+        notificationRepo.saveNotification(notification);
+        return new NotificationVO(notification);
+    }
+
+    /**
+     * 保存通知信息,区分是否置顶,保证创建的置顶通知仅有1个
+     * @param notificationCommand
+     * @param notification
+     */
+    private void checkAndSaveNotification(NotificationCommand notificationCommand, Notification notification) {
+        // 置顶操作
+        if(notificationCommand.getType() == NotificationType.TOP){
+            notificationRepo.getNotificationByType(notificationCommand.getType())
+                    .stream().filter(notificationType -> notificationType.getDeletedStatus() == DeletedStatus.NOT_DELETED && notificationType.getId() != notification.getId())
+                    .map(notificationType -> {
+                        notificationType.changeTypeToNew();
+                        notificationRepo.saveNotification(notificationType);
+                        return notificationType;
+                    }).collect(Collectors.toList());
+        }
+        notificationRepo.saveNotification(notification);
+    }
+
+    public Boolean deleteNotification(Long notificationId) {
+        Notification notification = notificationRepo.getNotificationById(notificationId);
+        log.info("删除id为:{} title为:\"{}\" 的大赛通知", notificationId, notification.getTitle());
+        notification.delete();
+        notificationRepo.saveNotification(notification);
+        if(notification.getDeletedStatus() == DeletedStatus.IS_DELETED){
+            return true;
+        }else{
+            return false;
+        }
+
+    }
+
+    public boolean checkPassword(String password) {
+        return correctPassword.equals(password);
+    }
+}

+ 14 - 0
src/main/java/mooctest/org/backend/site/service/UploadService.java

@@ -0,0 +1,14 @@
+package mooctest.org.backend.site.service;
+
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author: Diors.Po
+ * @Email: 171256175@qq.com
+ * @date 2019-08-05 15:41
+ */
+public interface UploadService {
+
+    String uploadDoc(MultipartFile file);
+
+}

+ 53 - 0
src/main/java/mooctest/org/backend/site/service/impl/OSSUploadServiceImpl.java

@@ -0,0 +1,53 @@
+package mooctest.org.backend.site.service.impl;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.model.PutObjectResult;
+import lombok.extern.slf4j.Slf4j;
+import mooctest.org.backend.site.configuration.OSSConfiguration;
+import mooctest.org.backend.site.domainObject.UploadType;
+import mooctest.org.backend.site.exception.BaseException;
+import mooctest.org.backend.site.service.UploadService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+
+/**
+ * @author: Diors.Po
+ * @Email: 171256175@qq.com
+ * @date 2019-08-05 15:42
+ */
+@Slf4j
+@Service
+public class OSSUploadServiceImpl implements UploadService {
+
+    @Autowired
+    private OSSConfiguration ossConfig;
+
+    @Value("${oss.fileName}")
+    private String ossFileName;
+
+    @Override
+    public String uploadDoc(MultipartFile file) {
+        String fileName = ossFileName + file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."))+"_"
+                +System.currentTimeMillis()+""
+                +file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."), file.getOriginalFilename().length());
+        return doUpload(fileName, file);
+    }
+
+    private String doUpload(String fileName, MultipartFile file){
+        OSS ossClient = ossConfig.ossClient();
+        try {
+            PutObjectResult result = ossClient.putObject(ossConfig.getBucketName(), fileName, file.getInputStream());
+            log.info(result.toString());
+            return ossConfig.getBaseUrl()+fileName;
+        } catch (IOException e) {
+            log.error("OSS上传出错!", e);
+            throw new BaseException(e.getMessage());
+        } finally {
+            ossClient.shutdown();
+        }
+    }
+}

+ 82 - 0
src/main/java/mooctest/org/backend/site/utils/Converter.java

@@ -0,0 +1,82 @@
+package mooctest.org.backend.site.utils;
+
+import com.google.common.collect.Maps;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.cglib.beans.BeanCopier;
+
+import java.util.Map;
+
+public class Converter {
+
+    private static Map<CopierIdentity, BeanCopier> copierCache = Maps.newConcurrentMap();
+    private static PrimitiveConverter primitiveConverter = new PrimitiveConverter();
+
+    public static <T> T copy(T target, Object source) {
+        BeanCopier copier = getCopier(source.getClass(), target.getClass());
+        copier.copy(source, target, primitiveConverter);
+        return target;
+    }
+
+    public static <T> T convert(Class<T> targetClass, Object source) {
+        try {
+            T target = targetClass.newInstance();
+            BeanCopier copier = getCopier(source.getClass(), targetClass);
+            copier.copy(source, target, primitiveConverter);
+            return target;
+        } catch (InstantiationException | IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static BeanCopier getCopier(Class<?> source, Class<?> target) {
+        CopierIdentity identity = new CopierIdentity(source, target);
+        BeanCopier copier;
+        if (copierCache.containsKey(identity)) {
+            copier = copierCache.get(identity);
+        } else {
+            copier = BeanCopier.create(source, target, true);
+            copierCache.putIfAbsent(identity, copier);
+        }
+        return copier;
+    }
+
+    public static class PrimitiveConverter implements org.springframework.cglib.core.Converter {
+        @Override
+        @SuppressWarnings("unchecked")
+        public Object convert(Object value, Class target, Object context) {
+            if (value == null) return null;
+            if (target.equals(String.class)
+                    && !String.class.isAssignableFrom(value.getClass()))
+                return value.toString();
+            if (Number.class.isAssignableFrom(value.getClass())) {
+                Number num = (Number) value;
+                if (target.equals(int.class) || target.equals(Integer.class))
+                    return num.intValue();
+                else if (target.equals(long.class) || target.equals(Long.class))
+                    return num.longValue();
+                else if (target.equals(short.class) || target.equals(Short.class))
+                    return num.shortValue();
+                else if (target.equals(float.class) || target.equals(Float.class))
+                    return num.floatValue();
+                else if (target.equals(double.class) || target.equals(Double.class))
+                    return num.doubleValue();
+                else if (target.equals(byte.class) || target.equals(Byte.class))
+                    return num.byteValue();
+            } else if (target.isAssignableFrom(value.getClass()))
+                return value;
+            return null;
+        }
+    }
+
+    @AllArgsConstructor
+    @Data
+    @EqualsAndHashCode
+    private static class CopierIdentity {
+        private Class<?> source;
+        private Class<?> target;
+    }
+
+}
+

+ 73 - 0
src/main/java/mooctest/org/backend/site/utils/MongoAPIUtils.java

@@ -0,0 +1,73 @@
+//package mooctest.org.backend.site.utils;
+//
+//import mooctest.org.backend.site.config.MongoDBConfiguration;
+//import net.sf.json.JSONObject;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.http.HttpHeaders;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.Map;
+//
+///**
+// * Created by major on 2017/9/26.
+// */
+//@Component
+//public class MongoAPIUtils {
+//    public static final String MONGODB_COLLECTION_NOTIFICATION = "notification";
+//
+//    public static final String WITH_MAX_PAGE_SIZE = "&count&page=1&pagesize=1000";
+//
+//    static MongoDBConfiguration mongoDBConfiguration;
+//
+//    @Autowired
+//    public MongoAPIUtils(MongoDBConfiguration mongoDBConfig) {
+//        mongoDBConfiguration = mongoDBConfig;
+//    }
+//
+//    public static String generateCommonUrl(String dbName, String collectionName) {
+//        StringBuilder builder = new StringBuilder();
+//        builder.append("http://").append(mongoDBConfiguration.getHost()).append(":")
+//                .append(mongoDBConfiguration.getPort()).append("/")
+//                .append(mongoDBConfiguration.getDb()).append("/").append(collectionName);
+//        return builder.toString();
+//    }
+//
+//    public static String generateFilterUrl(String dbName, String collectionName) {
+//        return generateCommonUrl(dbName, collectionName) + "?filter={filter}";
+//    }
+//
+//    public static String generateFilterAndPagingUrl(String dbName, String collectionName) {
+//        return generateFilterUrl(dbName, collectionName) + "&count&hal=f&np&page={activePage}&pagesize={pageSize}&sort={sortBy}";
+//    }
+//
+//    public static String generatePagingUrl(String dbName, String collectionName) {
+//        return generateCommonUrl(dbName, collectionName) + "?&count&hal=f&np&page={activePage}&pagesize={pageSize}&sort={sortBy}";
+//    }
+//
+//    public static String generateAggrUrl(String dbName, String collectionName, String Aggr) {
+//        return generateCommonUrl(dbName, collectionName) + "/_aggrs/" + Aggr + "?avars={avars}";
+//    }
+//
+//    public static String generateUrlWithResourceId(String dbName, String collectionName, String resourceId) {
+//        return generateCommonUrl(dbName, collectionName) + "/" + resourceId;
+//    }
+//
+//    public static String generateFilterStr(Map params) {
+//        JSONObject jsonObject = JSONObject.fromObject(params);
+//        return jsonObject.toString();
+//    }
+//
+//    public static HttpHeaders createAuthHeaderForMongo() {
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("Authorization", mongoDBConfiguration.getBase64Auth());
+//        return headers;
+//    }
+//
+//    public static String generateOidFilterUrl(String dbName, String collectionName) {
+//        return generateCommonUrl(dbName, collectionName) + "?keys={keys}" + "&filter={filter}";
+//    }
+//
+//    public static String generateBulkFilterString(String dbName, String collectionName) {
+//        return generateCommonUrl(dbName, collectionName) + "/*?" + "filter={filter}";
+//    }
+//}

BIN
src/main/resources/.DS_Store


+ 74 - 0
src/main/resources/application.yml

@@ -0,0 +1,74 @@
+server.port: 8090
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    # Keep the connection alive if idle for a long time (needed in production)
+    testWhileIdle: true
+    validationQuery: SELECT 1
+    # Show or not log for each sql query
+  jpa:
+    show-sql: true
+  # Hibernate ddl auto (create, create-drop, update)
+  hibernate:
+    ddl-auto: validate
+    #hbm2ddl.auto: update
+    # Naming strategy
+    naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+  # The SQL dialect makes Hibernate generate better SQL for the chosen database
+  properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
+
+  servlet:
+    multipart:
+      max-file-size: 1000MB
+      max-request-size: 1000MB
+
+oss:
+  accessKeyId: LTAI4FdrT3HsfdR5edBVN7ws
+  accessKeySecret: yroxrpm46DzTyzHrLBZzS3MRNIicP6
+  endPoint: oss-cn-hangzhou.aliyuncs.com
+  bucketName: mooctest-share
+
+sleep: 0
+
+ #配置输出日志
+logging:
+  level:
+    org.springframework.cloud.gateway: TRACE
+    org.springframework.http.server.reactive: DEBUG
+    org.springframework.web.reactive: DEBUG
+    reactor.ipc.netty: DEBUG
+
+password: WWW.MOOCTEST.ORG123$
+
+limit:
+  count: 7
+
+---
+spring:
+  profiles: dev
+  datasource:
+    url: jdbc:mysql://106.14.81.62:3306/mooctest_org_dev?useSSL=false&useUnicode=yes&characterEncoding=UTF-8
+    username: root
+    password: KBrhRYguzeZh4cFh
+oss:
+  fileName: mooctest-org-test/
+
+---
+spring:
+  profiles: pre
+  datasource:
+    url: jdbc:mysql://106.14.81.62:3306/mooctest_org_pre?useSSL=false&useUnicode=yes&characterEncoding=UTF-8
+    username: root
+    password: KBrhRYguzeZh4cFh
+oss:
+  fileName: mooctest-org-test/
+
+---
+spring:
+  profiles: online
+  datasource:
+    url: jdbc:mysql://106.14.81.62:3306/mooctest_org_online?useSSL=false&useUnicode=yes&characterEncoding=UTF-8
+    username: root
+    password: KBrhRYguzeZh4cFh
+oss:
+  fileName: mooctest-org/

+ 34 - 0
src/main/resources/bootstrap.yaml

@@ -0,0 +1,34 @@
+spring.profiles.active: dev
+spring:
+  application:
+    name: mooctest-org-backend
+  cloud:
+    nacos:
+      discovery:
+#        namespace: 98123199-6adc-41b1-9c28-a97c6ed0e689 # 分组(dev,test等)
+        # 指定nacos server的地址
+        server-addr: 106.14.81.62:8848
+        namespace: 7b6ae537-56f8-4e80-b551-c143db51a389
+#        server-addr: 192.168.43.174:8848
+#        namespace: 98123199-6adc-41b1-9c28-a97c6ed0e689
+      config:
+        server-addr: 106.14.81.62:8848
+        namespace: 7b6ae537-56f8-4e80-b551-c143db51a389
+#        server-addr: 192.168.43.174:8848
+#        namespace: 98123199-6adc-41b1-9c28-a97c6ed0e689 # 分组(dev,test等)
+        file-extension: yaml
+##        shared-dataids: pkcs8_rsa_private_key.pem,mongo.yaml,mysql.yaml,redis.yaml,xxl-job.yaml,mybatis-plus.yaml,actuator.yaml,mybatis-plus.yaml
+##        refreshable-dataids: pkcs8_rsa_private_key.pem,mongo.yaml,mysql.yaml,redis.yaml,xxl-job.yaml,mybatis-plus.yaml,actuator.yaml,mybatis-plus.yaml
+
+        # 用于多配置项 (比如读取该项目的主配置之后,再读取一个单独的配置)
+        ext-config[0]:                      # 数组形式
+          data-id: 'mooctest-org-backend-public.yml'             # 配置名称
+          group: 'MOOCTEST-ORG'
+          refresh: true                    # 分组名称     # 是否动态刷新
+
+#        prefix: ${spring.application.name}
+# ${prefix}-${spring.profile.active}.${file-extension}
+# prefix 默认为 spring.application.name 的值,也可以通过配置项 spring.cloud.nacos.config.prefix来配置。
+# file-exetension 为配置内容的数据格式,可以通过配置项 spring.cloud.nacos.config.file-extension 来配置。目前只支持 properties 和 yaml 类型。
+#  profiles:
+#    active: dev

+ 13 - 0
src/test/java/mooctest/org/backend/site/SiteApplicationTests.java

@@ -0,0 +1,13 @@
+package mooctest.org.backend.site;
+
+import org.junit.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SiteApplicationTests {
+
+//    @Test
+//    void contextLoads() {
+//    }
+
+}

+ 8 - 0
tool4deploy/Dockerfile

@@ -0,0 +1,8 @@
+FROM openjdk:8-jdk-alpine
+MAINTAINER guochao 1021172957@qq.com
+EXPOSE 8090
+ENV TZ=Asia/Shanghai
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+ADD mooctest-org-backend-1.0-SNAPSHOT.jar /root
+WORKDIR /root
+ENTRYPOINT ["java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "mooctest-org-backend-1.0-SNAPSHOT.jar"]