5 vuotta sitten
commit
0e4bab100e

+ 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/

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

@@ -0,0 +1,114 @@
+/*
+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.
+*/
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+    /**
+     * 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/0.4.2/maven-wrapper-0.4.2.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 direcrory '" + 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 {
+        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


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

@@ -0,0 +1 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

+ 286 - 0
mvnw

@@ -0,0 +1,286 @@
+#!/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)`"
+  # TODO classpath?
+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
+    jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+    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 command -v wget > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found wget ... using wget"
+        fi
+        wget "$jarUrl" -O "$wrapperJarPath"
+    elif command -v curl > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found curl ... using curl"
+        fi
+        curl -o "$wrapperJarPath" "$jarUrl"
+    else
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Falling back to using Java to download"
+        fi
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        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
+
+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 "$@"

+ 161 - 0
mvnw.cmd

@@ -0,0 +1,161 @@
+@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 my 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.4.2/maven-wrapper-0.4.2.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% (
+    echo Found %WRAPPER_JAR%
+) else (
+    echo Couldn't find %WRAPPER_JAR%, downloading it ...
+	echo Downloading from: %DOWNLOAD_URL%
+    powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+    echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%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%

+ 101 - 0
pom.xml

@@ -0,0 +1,101 @@
+<?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.8.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.hhsx</groupId>
+    <artifactId>minigame</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>minigame</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <scope>runtime</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- mybatis-plus依赖 -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.1.2</version>
+        </dependency>
+        <!-- mybatis-plus代码生成器依赖 -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.1.2</version>
+        </dependency>
+
+        <!-- velocity模板引擎 -->
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.0</version>
+        </dependency>
+
+        <!-- freemarker 模板引擎-->
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>2.3.23</version>
+        </dependency>
+
+        <!-- fastjson -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.7</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
src/main/java/com/hhsx/minigame/MinigameApplication.java

@@ -0,0 +1,13 @@
+package com.hhsx.minigame;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class MinigameApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(MinigameApplication.class, args);
+    }
+
+}

+ 17 - 0
src/main/java/com/hhsx/minigame/constant/Constant.java

@@ -0,0 +1,17 @@
+
+package com.hhsx.minigame.constant;
+/**
+ * Author: 吴涛涛
+ * Date : 2019 - 07 - 24 16:00
+ * Description:<描述>常量配置类
+ * Version: 1.0
+ */
+public class Constant {
+    public static final String MICROBLOG_APPKEY = "2141531565";//微博的appkey
+    public static final String MICROBLOG_APPSECRET = "f39462b939a56ce6d846bf83e04c20b5";//微博的appsecret
+    public static final String WECHAT_APPID = "2141531565";//微信的appid
+    public static final String WECHAT_APPSECRET = "f39462b939a56ce6d846bf83e04c20b5";//微信的appsecret
+
+}
+
+

+ 17 - 0
src/main/java/com/hhsx/minigame/controller/NewsController.java

@@ -0,0 +1,17 @@
+package com.hhsx.minigame.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author 吴涛涛
+ * @since 2019-09-17
+ */
+@RestController
+@RequestMapping("/news")
+public class NewsController {
+
+}
+

+ 125 - 0
src/main/java/com/hhsx/minigame/entity/News.java

@@ -0,0 +1,125 @@
+package com.hhsx.minigame.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-09-17
+ */
+@TableName("mini_news")
+public class News extends Model<News> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * mini游戏链接表主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 用户昵称
+     */
+    @TableField("nick_name")
+    private String nickName;
+
+    /**
+     * 用户头像
+     */
+    @TableField("header_pic")
+    private String headerPic;
+
+    /**
+     * 创建时间
+     */
+    @TableField("indate")
+    private LocalDateTime indate;
+
+    /**
+     * 获取链接的来源,0-微信 1-微博
+     */
+    @TableField("type")
+    private Integer type;
+
+    /**
+     * 寄语
+     */
+    @TableField("message")
+    private String message;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getHeaderPic() {
+        return headerPic;
+    }
+
+    public void setHeaderPic(String headerPic) {
+        this.headerPic = headerPic;
+    }
+
+    public LocalDateTime getIndate() {
+        return indate;
+    }
+
+    public void setIndate(LocalDateTime indate) {
+        this.indate = indate;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "News{" +
+        "id=" + id +
+        ", nickName=" + nickName +
+        ", headerPic=" + headerPic +
+        ", indate=" + indate +
+        ", type=" + type +
+        ", message=" + message +
+        "}";
+    }
+}

+ 16 - 0
src/main/java/com/hhsx/minigame/mapper/NewsMapper.java

@@ -0,0 +1,16 @@
+package com.hhsx.minigame.mapper;
+
+import com.hhsx.minigame.entity.News;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-09-17
+ */
+public interface NewsMapper extends BaseMapper<News> {
+
+}

+ 16 - 0
src/main/java/com/hhsx/minigame/service/NewsService.java

@@ -0,0 +1,16 @@
+package com.hhsx.minigame.service;
+
+import com.hhsx.minigame.entity.News;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-09-17
+ */
+public interface NewsService extends IService<News> {
+
+}

+ 20 - 0
src/main/java/com/hhsx/minigame/service/impl/NewsServiceImpl.java

@@ -0,0 +1,20 @@
+package com.hhsx.minigame.service.impl;
+
+import com.hhsx.minigame.entity.News;
+import com.hhsx.minigame.mapper.NewsMapper;
+import com.hhsx.minigame.service.NewsService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-09-17
+ */
+@Service
+public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
+
+}

+ 50 - 0
src/main/java/com/hhsx/minigame/utils/AccessToken.java

@@ -0,0 +1,50 @@
+package com.hhsx.minigame.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.hhsx.minigame.constant.Constant;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Date;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 09 - 17 10:04
+ * Description:<描述>
+ * Version: 1.0
+ */
+public class AccessToken {
+
+    private static String wechatAppId = Constant.WECHAT_APPID;
+
+    private static String wechatSecret = Constant.WECHAT_APPSECRET;
+
+    private static String oldAccessToken = null;
+
+    private static Date time = new Date();//oldAccessToken值创建时间
+
+    private static Long expiresIn = 7200L*1000;//accessToken值有效时长 单位毫秒
+
+    public static String getNewAccessToken() throws Exception {
+        if(oldAccessToken == null || (oldAccessToken != null && System.currentTimeMillis() > time.getTime()+expiresIn)){
+            String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + wechatAppId + "&secret=" + wechatSecret;
+            String resp = HttpKit.get(url, true);
+            resp = StringEscapeUtils.unescapeJava(resp);
+            JSONObject json = (JSONObject) JSON.parse(resp);
+            //获取值赋值给全局变量
+            if (!json.containsKey("errcode")) {
+                String newAccessToken = json.getString("access_token");
+                String newExpiresIn = json.getString("expires_in");
+                oldAccessToken = newAccessToken;
+                expiresIn = Long.parseLong(newExpiresIn) * 1000;
+                time = new Date();
+                System.out.println("获取新access_token==>" + oldAccessToken);
+            }
+        }
+        return oldAccessToken;
+    }
+}

+ 218 - 0
src/main/java/com/hhsx/minigame/utils/CodeGenerator.java

@@ -0,0 +1,218 @@
+package com.hhsx.minigame.utils;
+
+import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.InjectionConfig;
+import com.baomidou.mybatisplus.generator.config.*;
+import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
+import com.baomidou.mybatisplus.generator.config.rules.FileType;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import com.hhsx.minigame.constant.Constant;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * mybatis-plus代码生成器
+ *  使用该类需要添加以下依赖,在此之前请移除所有与mybatis有关的其他依赖,防止冲突
+ *   <dependency>
+ *      <groupId>com.baomidou</groupId>
+ *       <artifactId>mybatis-plus-generator</artifactId>
+ *       <version>3.1.2</version>
+ *  </dependency>
+ *
+ *  <dependency>
+ *        <groupId>com.baomidou</groupId>
+ *        <artifactId>mybatis-plus-boot-starter</artifactId>
+ *        <version>3.1.2</version>
+ *   </dependency>
+ *
+ */
+// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
+public class CodeGenerator {
+
+    /**
+     * <p>
+     * 读取控制台内容
+     * </p>
+     */
+    public static String scanner(String tip) {
+        Scanner scanner = new Scanner(System.in);
+        StringBuilder help = new StringBuilder();
+        help.append("请输入" + tip + ":");
+        System.out.println(help.toString());
+        if (scanner.hasNext()) {
+            String ipt = scanner.next();
+            if (StringUtils.isNotEmpty(ipt)) {
+                return ipt;
+            }
+        }
+        throw new MybatisPlusException("请输入正确的" + tip + "!");
+    }
+
+    public static void main(String[] args) {
+        // 代码生成器
+        AutoGenerator mpg = new AutoGenerator();
+
+        // 全局配置
+        GlobalConfig gc = new GlobalConfig();
+        // 全局配置
+
+
+        // 自定义文件命名,注意 %s 会自动填充表实体属性!
+//        gc.setMapperName("%sDao");
+//        gc.setXmlName("%sMapper");
+//        gc.setServiceName("%sService");
+//        gc.setServiceImplName("%sServiceImap");
+//        gc.setControllerName("%sController");
+        //生成的代码存放到某个路径下,这里是E盘,
+//        gc.setOutputDir("E://");
+        //生成的代码位置为当前项目
+        String projectPath = System.getProperty("user.dir");
+        gc.setOutputDir(projectPath + "/src/main/java");
+        gc.setAuthor("吴涛涛");
+        gc.setOpen(false);
+        gc.setFileOverride(true);
+        gc.setActiveRecord(true);
+        //%s是实体类类名占位符,不配置这行的话,对于User会生成IUserService,配置后即可生成UserService;
+        gc.setServiceName("%sService");
+        // XML 二级缓存
+//      gc.setEnableCache(true);
+        // XML ResultMap
+        gc.setBaseResultMap(true);
+        // XML columList
+        gc.setBaseColumnList(true);
+        //
+        // gc.setSwagger2(true); 实体属性 Swagger2 注解
+        mpg.setGlobalConfig(gc);
+
+        // 数据源配置
+        DataSourceConfig dsc = new DataSourceConfig();
+        dsc.setUrl("jdbc:mysql://118.190.47.230:3306/minigame?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
+//        dsc.setSchemaName("public");
+        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
+        dsc.setUsername("root");
+        dsc.setPassword("p011430seya10");
+        mpg.setDataSource(dsc);
+
+        // 包配置
+        PackageConfig pc = new PackageConfig();
+        //若果需要在Parent(此处即com.example.plus)下新建模块时打开下面注释,后续在控制台提示输入模块时,输入想要新建的模块名就可以
+//        pc.setModuleName(scanner("模块名"));
+        pc.setParent("com.hhsx.minigame");
+        mpg.setPackageInfo(pc);
+
+        // 自定义配置
+        InjectionConfig cfg = new InjectionConfig() {
+            @Override
+            public void initMap() {
+                // to do nothing
+            }
+        };
+        //以下为两种模板来生成*mapper.xml文件,任选一种即可,不同的模板对应不同的依赖
+        // 如果模板引擎是 freemarker,请添加以下依赖。
+        /**
+         *         <dependency>
+         *             <groupId>org.freemarker</groupId>
+         *             <artifactId>freemarker</artifactId>
+         *             <version>2.3.23</version>
+         *         </dependency>
+         */
+//        String templatePath = "/templates/mapper.xml.ftl";
+        // 如果模板引擎是 velocity 请添加以下依赖。
+        /**
+         *         <dependency>
+         *             <groupId>org.apache.velocity</groupId>
+         *             <artifactId>velocity-engine-core</artifactId>
+         *             <version>2.0</version>
+         *         </dependency>
+         */
+         String templatePath = "/templates/mapper.xml.vm";
+
+        // 自定义输出配置
+        List<FileOutConfig> focList = new ArrayList<>();
+        // 自定义配置会被优先输出
+        focList.add(new FileOutConfig(templatePath) {
+            @Override
+            public String outputFile(TableInfo tableInfo) {
+                if(pc.getModuleName() == null){
+                    return projectPath + "/src/main/resources/mapper/"
+                            + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
+                }else{
+                    // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
+                    return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
+                            + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
+                }
+
+            }
+
+        });
+
+        cfg.setFileCreate(new IFileCreate() {
+            @Override
+            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
+                // 判断自定义文件夹是否需要创建,这里调用默认的方法
+                checkDir(filePath);
+                //对于已存在的文件,只需重复生成 entity 和 mapper.xml
+                File file = new File(filePath);
+                boolean exist = file.exists();
+                if(exist){
+                    if (filePath.endsWith("Mapper.xml")||FileType.ENTITY==fileType){
+                        return true;
+                    }else {
+                        return false;
+                    }
+                }
+                //不存在的文件都需要创建
+                return  true;
+            }
+        });
+
+        cfg.setFileOutConfigList(focList);
+        mpg.setCfg(cfg);
+        mpg.setTemplate(new TemplateConfig().setXml(null));
+
+        // 配置模板
+//        TemplateConfig templateConfig = new TemplateConfig();
+//
+//        // 配置自定义输出模板
+//        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
+//        // templateConfig.setEntity("templates/entity2.java");
+//        // templateConfig.setService();
+//        // templateConfig.setController();
+//
+//        templateConfig.setXml(null);
+//        mpg.setTemplate(templateConfig);
+
+        // 策略配置
+        StrategyConfig strategy = new StrategyConfig();
+        strategy.setNaming(NamingStrategy.underline_to_camel);
+        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+        //若想要生成的实体类继承某个类,则可打开下面注释。写上需要继承的类的位置即可
+//        strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
+        //【实体】是否为lombok模型(默认 false)
+//        strategy.setEntityLombokModel(true);
+        //对控制器生成 @RestController 注解
+        strategy.setRestControllerStyle(true);
+        //是否生成实体时,生成字段注解
+        strategy.setEntityTableFieldAnnotationEnable(true);
+//        strategy.setEntitySerialVersionUID(false)//加此行不生成生成实体类序列化编号,不加默认生成
+        //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
+//        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
+        //此处user是表名,多个英文逗号分割
+        strategy.setInclude("mini_news");
+//        strategy.setExclude();//数据库表全生成
+//        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
+        strategy.setControllerMappingHyphenStyle(true);
+        //数据库表前缀,不配置这行的话,生成的类会带有T如:TUser,配置后即可将前缀去掉
+        strategy.setTablePrefix("mini_");
+        mpg.setStrategy(strategy);
+//        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
+        mpg.execute();
+    }
+}

+ 293 - 0
src/main/java/com/hhsx/minigame/utils/HttpKit.java

@@ -0,0 +1,293 @@
+package com.hhsx.minigame.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.net.ssl.*;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+import java.util.Map.Entry;
+
+@Slf4j
+public class HttpKit {
+    
+    private static final String DEFAULT_CHARSET = "UTF-8";
+    /**
+     * 发送Get请求
+     * @param url
+     * @return
+     * @throws NoSuchProviderException 
+     * @throws NoSuchAlgorithmException 
+     * @throws IOException 
+     * @throws KeyManagementException 
+     */
+    public static String get(String url) throws NoSuchAlgorithmException, NoSuchProviderException, IOException, KeyManagementException {
+        StringBuffer bufferRes = null;
+        TrustManager[] tm = { new MyX509TrustManager() };  
+        SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");  
+        sslContext.init(null, tm, new java.security.SecureRandom());  
+        // 从上述SSLContext对象中得到SSLSocketFactory对象  
+        SSLSocketFactory ssf = sslContext.getSocketFactory();
+        
+        URL urlGet = new URL(url);
+        HttpsURLConnection http = (HttpsURLConnection) urlGet.openConnection();
+        // 连接超时
+        http.setConnectTimeout(25000);
+        // 读取超时 --服务器响应比较慢,增大时间
+        http.setReadTimeout(25000);
+        http.setRequestMethod("GET");
+        http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
+        http.setSSLSocketFactory(ssf);
+        http.setDoOutput(true);
+        http.setDoInput(true);
+        http.connect();
+        
+        InputStream in = http.getInputStream();
+        BufferedReader read = new BufferedReader(new InputStreamReader(in, DEFAULT_CHARSET));
+        String valueString = null;
+        bufferRes = new StringBuffer();
+        while ((valueString = read.readLine()) != null){
+            bufferRes.append(valueString);
+        }
+        in.close();
+        if (http != null) {
+            // 关闭连接
+            http.disconnect();
+        }
+        return bufferRes.toString();
+    }
+    
+    /**
+     * 发送Get请求
+     * @param url
+     * @return
+     * @throws NoSuchProviderException 
+     * @throws NoSuchAlgorithmException 
+     * @throws IOException 
+     * @throws KeyManagementException 
+     */
+    public static String get(String url,Boolean https) throws NoSuchAlgorithmException, NoSuchProviderException, IOException, KeyManagementException {
+     if(https != null && https){
+      return get(url);
+     }else{
+      StringBuffer bufferRes = null;
+            URL urlGet = new URL(url);
+            HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
+            // 连接超时
+            http.setConnectTimeout(25000);
+            // 读取超时 --服务器响应比较慢,增大时间
+            http.setReadTimeout(25000);
+            http.setRequestMethod("GET");
+            http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
+            http.setDoOutput(true);
+            http.setDoInput(true);
+            http.connect();
+            
+            InputStream in = http.getInputStream();
+            BufferedReader read = new BufferedReader(new InputStreamReader(in, DEFAULT_CHARSET));
+            String valueString = null;
+            bufferRes = new StringBuffer();
+            while ((valueString = read.readLine()) != null){
+                bufferRes.append(valueString);
+            }
+            in.close();
+            if (http != null) {
+                // 关闭连接
+                http.disconnect();
+            }
+            return bufferRes.toString();
+     }
+    }
+    /**
+     *  发送Get请求
+     * @param url
+     * @param params
+     * @return
+     * @throws IOException 
+     * @throws NoSuchProviderException 
+     * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
+     */
+    public static String get(String url, Map<String, String> params) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
+        return get(initParams(url, params));
+    }
+    /**
+     *  发送Post请求
+     * @param url
+     * @param params
+     * @return
+     * @throws IOException 
+     * @throws NoSuchProviderException 
+     * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
+     */
+    public static String post(String url, String params) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
+     StringBuffer bufferRes = null;
+        TrustManager[] tm = { new MyX509TrustManager() };
+        SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
+        sslContext.init(null, tm, new java.security.SecureRandom());
+        // 从上述SSLContext对象中得到SSLSocketFactory对象  
+        SSLSocketFactory ssf = sslContext.getSocketFactory();
+        URL urlGet = new URL(url);
+        HttpsURLConnection http = (HttpsURLConnection) urlGet.openConnection();
+        // 连接超时
+        http.setConnectTimeout(25000);
+        // 读取超时 --服务器响应比较慢,增大时间
+        http.setReadTimeout(25000);
+        http.setRequestMethod("POST");
+        http.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
+        http.setSSLSocketFactory(ssf);
+        http.setDoOutput(true);
+        http.setDoInput(true);
+        http.connect();
+        OutputStream out = http.getOutputStream();
+        out.write(params.getBytes("UTF-8"));
+        out.flush();
+        out.close();
+        InputStream in = http.getInputStream();
+        BufferedReader read = new BufferedReader(new InputStreamReader(in, DEFAULT_CHARSET));
+        String valueString = null;
+        bufferRes = new StringBuffer();
+        while ((valueString = read.readLine()) != null){
+            bufferRes.append(valueString);
+        }
+        in.close();
+        if (http != null) {
+            // 关闭连接
+            http.disconnect();
+        }
+        return bufferRes.toString();
+    }
+    
+    /**
+     * 上传媒体文件
+     * @param url
+     * @param file
+     * @return
+     * @throws IOException
+     * @throws NoSuchAlgorithmException
+     * @throws NoSuchProviderException
+     * @throws KeyManagementException
+     */
+    public static String upload(String url,File file) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
+        String BOUNDARY = "----WebKitFormBoundaryiDGnV9zdZA1eM1yL"; // 定义数据分隔线  
+        StringBuffer bufferRes = null;
+        URL urlGet = new URL(url);
+        HttpURLConnection conn = (HttpURLConnection) urlGet.openConnection();
+        conn.setDoOutput(true);  
+        conn.setDoInput(true);  
+        conn.setUseCaches(false);  
+        conn.setRequestMethod("POST");  
+        conn.setRequestProperty("connection", "Keep-Alive");  
+        conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36");  
+        conn.setRequestProperty("Charsert", "UTF-8");   
+        conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);  
+          
+        OutputStream out = new DataOutputStream(conn.getOutputStream());  
+        byte[] end_data = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();// 定义最后数据分隔线  
+        StringBuilder sb = new StringBuilder();    
+        sb.append("--");    
+        sb.append(BOUNDARY);    
+        sb.append("\r\n");    
+        sb.append("Content-Disposition: form-data;name=\"media\";filename=\""+ file.getName() + "\"\r\n");    
+        sb.append("Content-Type:application/octet-stream\r\n\r\n");    
+        byte[] data = sb.toString().getBytes();  
+        out.write(data);  
+        DataInputStream fs = new DataInputStream(new FileInputStream(file));  
+        int bytes = 0;  
+        byte[] bufferOut = new byte[1024];  
+        while ((bytes = fs.read(bufferOut)) != -1) {  
+            out.write(bufferOut, 0, bytes);  
+        }  
+        out.write("\r\n".getBytes()); //多个文件时,二个文件之间加入这个  
+        fs.close();  
+        out.write(end_data);  
+        out.flush();    
+        out.close();   
+          
+        // 定义BufferedReader输入流来读取URL的响应  
+        InputStream in = conn.getInputStream();
+        BufferedReader read = new BufferedReader(new InputStreamReader(in, DEFAULT_CHARSET));
+        String valueString = null;
+        bufferRes = new StringBuffer();
+        while ((valueString = read.readLine()) != null){
+            bufferRes.append(valueString);
+        }
+        in.close();
+        if (conn != null) {
+            // 关闭连接
+         conn.disconnect();
+        }
+        return bufferRes.toString();
+    }
+    
+    /**
+     * 构造url
+     * @param url
+     * @param params
+     * @return
+     */
+    private static String initParams(String url, Map<String, String> params){
+        if (null == params || params.isEmpty()) {
+            return url;
+        }
+        StringBuilder sb = new StringBuilder(url);
+        if (url.indexOf("?") == -1) {
+            sb.append("?");
+        } else {
+            sb.append("&");
+        }
+        boolean first = true;
+        for (Entry<String, String> entry : params.entrySet()) {
+            if (first) {
+                first = false;
+            } else {
+                sb.append("&");
+            }
+            String key = entry.getKey();
+            String value = entry.getValue();
+            sb.append(key).append("=");
+            if (StringUtils.isNotEmpty(value)) {
+                try {
+                    sb.append(URLEncoder.encode(value, DEFAULT_CHARSET));
+                } catch (UnsupportedEncodingException e) {
+                    e.printStackTrace();
+                    log.error(url,e);
+                }
+            }
+        }
+        return sb.toString();
+    }
+    
+    public static void main(String[] args) {
+     String fname = "dsasdas.mp4";
+     String s = fname.substring(0, fname.lastIndexOf("."));
+     String f = fname.substring(s.length()+1);
+  System.out.println(f);
+ }
+}
+
+/**
+ * 证书管理
+ */
+class MyX509TrustManager implements X509TrustManager {
+    public X509Certificate[] getAcceptedIssuers() {
+        return null;  
+    }
+    @Override
+    public void checkClientTrusted(X509Certificate[] chain, String authType)
+            throws CertificateException {
+    }
+    @Override
+    public void checkServerTrusted(X509Certificate[] chain, String authType)
+            throws CertificateException {
+    }
+}

+ 39 - 0
src/main/java/com/hhsx/minigame/utils/HttpRespMsg.java

@@ -0,0 +1,39 @@
+package com.hhsx.minigame.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.io.Serializable;
+
+public class HttpRespMsg implements Serializable {
+
+    //status code, ok or error.
+    public String code;
+
+
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    public String msg;
+
+    //data content, in jsonformat, or zipped string when format is gzip
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    public Object data;
+
+    public HttpRespMsg() {
+        code = "ok";
+    }
+
+    public void setError(String errorMsg) {
+        code = "error";
+        msg = errorMsg;
+    }
+
+
+    public String toJSONStr() {
+        JSONObject json = new JSONObject();
+        json.put("code", code);
+        json.put("data", data);
+        json.put("msg", msg);
+
+        return json.toJSONString();
+    }
+}

+ 49 - 0
src/main/java/com/hhsx/minigame/utils/WechatUserNews.java

@@ -0,0 +1,49 @@
+package com.hhsx.minigame.utils;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 09 - 17 10:25
+ * Description:<描述>
+ * Version: 1.0
+ */
+@Data
+public class WechatUserNews {
+
+    private String subscribe;//用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息,1表示用户已关注。
+
+    private String openid;//用户的标识,对当前公众号唯一
+
+    private String nickname;//用户的昵称
+
+    private String sex;//用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
+
+    private String city;//用户所在城市
+
+    private String country;//用户所在国家
+
+    private String province;//用户所在省份
+
+    private String language;//用户的语言,简体中文为zh_CN
+
+    private String headimgurl;//用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
+
+    private Long subscribe_time;//用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间
+
+    private String unionid;//只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
+
+    private String remark;//公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
+
+    private String groupid;//用户所在的分组ID(兼容旧的用户分组接口)
+
+    private List<Integer> tagid_list;//用户被打上的标签ID列表
+
+    private String subscribe_scene;//返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENE_PROFILE_ LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_OTHERS 其他
+
+    private String qr_scene;//二维码扫码场景(开发者自定义)
+
+    private String qr_scene_str;//二维码扫码场景描述(开发者自定义)
+}

+ 33 - 0
src/main/java/com/hhsx/minigame/utils/WechatUtil.java

@@ -0,0 +1,33 @@
+package com.hhsx.minigame.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import java.util.Date;
+
+/**
+ * Author: 吴涛涛 cuiyi@itany.com
+ * Date : 2019 - 09 - 17 10:02
+ * Description:<描述>
+ * Version: 1.0
+ */
+public class WechatUtil {
+
+    public static WechatUserNews getWechatUserNews(String openId,String lang,String access_token)throws Exception{
+        WechatUserNews wechatUserNews = new WechatUserNews();
+        String url ="https://api.weixin.qq.com/cgi-bin/user/info?access_token="+access_token+"&openid="+openId+"&lang=zh_CN";
+        String resp = HttpKit.get(url, true);
+        resp = StringEscapeUtils.unescapeJava(resp);
+        JSONObject json = (JSONObject) JSON.parse(resp);
+        //获取值赋值给全局变量
+        if (!json.containsKey("errcode")) {
+            wechatUserNews.setHeadimgurl(json.getString("headimgurl"));;
+            String newExpiresIn = json.getString("expires_in");
+//            System.out.println("获取新access_token==>" + oldAccessToken);
+        }
+        return wechatUserNews;
+    }
+
+
+}

+ 56 - 0
src/main/resources/application.properties

@@ -0,0 +1,56 @@
+# ####################################################################################################
+# 服务端配置
+server.port=8095
+server.servlet.context-path=/
+server.tomcat.uri-encoding=UTF-8
+server.tomcat.max-http-post-size=-1
+server.connection-timeout=18000000s
+# ####################################################################################################
+# thymeleaf 配置
+spring.thymeleaf.cache=false
+spring.thymeleaf.jackson.time-zone=GMT+8
+spring.thymeleaf.jackson.date-format=yyyy-MM-dd HH:mm:ss
+# ####################################################################################################
+# 数据源配置
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://118.190.47.230:3306/minigame?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+spring.datasource.username=root
+spring.datasource.password=p011430seya10
+#spring.datasource.druid.test-on-borrow=true
+#spring.datasource.druid.test-while-idle=true
+# ####################################################################################################
+# MyBatis 配置
+mybatis.mapper-locations=mappers/*Mapper.xml
+mybatis.type-aliases-package=com.hssx.minigame.entity/*
+# 控制台输出SQL语句
+logging.level.com.hssx.cloudmodel.mapper = debug
+# ####################################################################################################
+#配置Session
+spring.session.store-type=none
+# ####################################################################################################
+#成功页面跳转
+spring.thymeleaf.prefix=classpath:/static/
+######################################################################################################
+## redis 配置
+#spring.redis.host=localhost
+#spring.redis.port=6379
+######################################################################################################
+## 文件上传路径
+#upload.path=D:/mould/upload/
+#######################################################################################################
+## 文件下载路径
+#download.path=D:/mould/download/
+## 邀请人员链接前缀
+#invitation.url.prefix=https://localhost:8090/#/invite/
+#######################################################################################################
+# 配置上传文件的大小设置
+# Single file max size  即单个文件大小
+spring.servlet.multipart.max-file-size=10000MB
+spring.servlet.multipart.max-request-size=10000MB
+##################SpringBoot连接池配置########
+spring.datasource.hikari.minimum-idle=3
+spring.datasource.hikari.maximum-pool-size=10
+spring.datasource.hikari.max-lifetime =30000
+spring.datasource.hikari.connection-test-query=SELECT 1
+logging.path=E:/
+

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

@@ -0,0 +1,30 @@
+
+##########
+logging:
+  level:
+    root: info
+    org.mybatis: debug
+    java.sql: debug
+    org.springframework.web: trace
+    #打印sql语句
+    com.example.plus.mapper: debug
+##########
+mybatis-plus:
+#  mapper-locations: classpath:mapper/*/*.xml
+#  #实体扫描,多个package用逗号或者分号分隔
+#  typeAliasesPackage: com.hssx.cloudmodel
+  global-config:
+    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
+    id-type: 0
+    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
+    field-strategy: 2
+    db-column-underline: true
+    refresh-mapper:
+#################插入和更新非null判断
+    db-config:
+      insert-strategy: not_null
+      update-strategy: not_null
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: false
+

+ 20 - 0
src/main/resources/mapper/NewsMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hhsx.minigame.mapper.NewsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hhsx.minigame.entity.News">
+        <id column="id" property="id" />
+        <result column="nick_name" property="nickName" />
+        <result column="header_pic" property="headerPic" />
+        <result column="indate" property="indate" />
+        <result column="type" property="type" />
+        <result column="message" property="message" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, nick_name, header_pic, indate, type, message
+    </sql>
+
+</mapper>

+ 16 - 0
src/test/java/com/hhsx/minigame/MinigameApplicationTests.java

@@ -0,0 +1,16 @@
+package com.hhsx.minigame;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class MinigameApplicationTests {
+
+    @Test
+    public void contextLoads() {
+    }
+
+}