diff --git a/api/.mvn/wrapper/maven-wrapper.jar b/api/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..c1dd12f Binary files /dev/null and b/api/.mvn/wrapper/maven-wrapper.jar differ diff --git a/api/.mvn/wrapper/maven-wrapper.properties b/api/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..b74bf7f --- /dev/null +++ b/api/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/api/HELP.md b/api/HELP.md new file mode 100644 index 0000000..22eb08a --- /dev/null +++ b/api/HELP.md @@ -0,0 +1,26 @@ +# Getting Started + +### Reference Documentation + +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.6.13/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.6.13/maven-plugin/reference/html/#build-image) +* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.6.13/reference/htmlsingle/#using.devtools) +* [Validation](https://docs.spring.io/spring-boot/docs/2.6.13/reference/htmlsingle/#io.validation) +* [MyBatis Framework](https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/) +* [Spring Configuration Processor](https://docs.spring.io/spring-boot/docs/2.6.13/reference/htmlsingle/#appendix.configuration-metadata.annotation-processor) +* [Spring Web](https://docs.spring.io/spring-boot/docs/2.6.13/reference/htmlsingle/#web) + +### Guides + +The following guides illustrate how to use some features concretely: + +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) +* [Validation](https://spring.io/guides/gs/validating-form-input/) +* [MyBatis Quick Start](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start) +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) + diff --git a/api/mvnw b/api/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/api/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + 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="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$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 \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/api/mvnw.cmd b/api/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/api/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq 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%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000..1ebca30 --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + + me.xiaoyan + point + 1.0-SNAPSHOT + + me.xiaoyan.point + api + 0.0.1-SNAPSHOT + api + api + + 1.8 + + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + com.baomidou + mybatis-plus-boot-starter + 3.5.2 + + + + com.alibaba + druid-spring-boot-starter + 1.2.14 + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents.client5 + httpclient5 + 5.1.3 + + + io.springfox + springfox-boot-starter + 3.0.0 + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/api/src/main/java/me/xiaoyan/point/api/ApiApplication.java b/api/src/main/java/me/xiaoyan/point/api/ApiApplication.java new file mode 100644 index 0000000..31d9a35 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/ApiApplication.java @@ -0,0 +1,13 @@ +package me.xiaoyan.point.api; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ApiApplication { + + public static void main(String[] args) { + SpringApplication.run(ApiApplication.class, args); + } + +} diff --git a/api/src/main/java/me/xiaoyan/point/api/config/MybatisPlusConfig.java b/api/src/main/java/me/xiaoyan/point/api/config/MybatisPlusConfig.java new file mode 100644 index 0000000..a057b41 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/config/MybatisPlusConfig.java @@ -0,0 +1,16 @@ +package me.xiaoyan.point.api.config; + +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MybatisPlusConfig { + @Bean + public MybatisPlusInterceptor paginationInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); + return interceptor; + } +} \ No newline at end of file diff --git a/api/src/main/java/me/xiaoyan/point/api/config/SwaggerConfiguration.java b/api/src/main/java/me/xiaoyan/point/api/config/SwaggerConfiguration.java new file mode 100644 index 0000000..861bf8b --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/config/SwaggerConfiguration.java @@ -0,0 +1,80 @@ +package me.xiaoyan.point.api.config; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanPostProcessor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.ReflectionUtils; +import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.oas.annotations.EnableOpenApi; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider; +import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.stream.Collectors; + +@Configuration +@EnableOpenApi +public class SwaggerConfiguration { + + // 创建api文档信息 + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("me.xiaoyan.point.api.controller")) + .paths(PathSelectors.any()) + .build(); + } + + // API的信息 + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("积分系统 API文档") + .description("积分系统 API文档") + .version("1.0").build(); + } + + + // 解决swagger nullpointer + @Bean + public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { + return new BeanPostProcessor() { + + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { + customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); + } + return bean; + } + + private void customizeSpringfoxHandlerMappings(List mappings) { + List copy = mappings.stream() + .filter(mapping -> mapping.getPatternParser() == null) + .collect(Collectors.toList()); + mappings.clear(); + mappings.addAll(copy); + } + + @SuppressWarnings("unchecked") + private List getHandlerMappings(Object bean) { + try { + Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings"); + field.setAccessible(true); + return (List) field.get(bean); + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new IllegalStateException(e); + } + } + }; + } +} \ No newline at end of file diff --git a/api/src/main/java/me/xiaoyan/point/api/controller/WechatController.java b/api/src/main/java/me/xiaoyan/point/api/controller/WechatController.java new file mode 100644 index 0000000..0f28de7 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/controller/WechatController.java @@ -0,0 +1,29 @@ +package me.xiaoyan.point.api.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.message.BasicClassicHttpResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +public class WechatController { + + // code => openid等信息 + // 使用wx.login获取到的code进行登录,完成登录后下发用户登录凭证 + @RequestMapping("/wechat/login") + @SneakyThrows + public String login(String code) { + return null; + } +} diff --git a/api/src/main/java/me/xiaoyan/point/api/error/BizException.java b/api/src/main/java/me/xiaoyan/point/api/error/BizException.java new file mode 100644 index 0000000..27a9e35 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/error/BizException.java @@ -0,0 +1,18 @@ +package me.xiaoyan.point.api.error; + +public class BizException extends RuntimeException { + /** + * 错误码 + */ + private int code; + + public BizException(int code, String message) { + super(message); + this.code = code; + } + + public BizException(Throwable e) { + super(e.getMessage()); + this.code = 500; + } +} diff --git a/api/src/main/java/me/xiaoyan/point/api/mapper/PointMapper.java b/api/src/main/java/me/xiaoyan/point/api/mapper/PointMapper.java new file mode 100644 index 0000000..433364c --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/mapper/PointMapper.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.pojo.UserInfo; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PointMapper extends BaseMapper { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/mapper/PointRecordMapper.java b/api/src/main/java/me/xiaoyan/point/api/mapper/PointRecordMapper.java new file mode 100644 index 0000000..6e7211b --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/mapper/PointRecordMapper.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.pojo.PointRecord; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface PointRecordMapper extends BaseMapper { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/mapper/SignRecordMapper.java b/api/src/main/java/me/xiaoyan/point/api/mapper/SignRecordMapper.java new file mode 100644 index 0000000..fc06de4 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/mapper/SignRecordMapper.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.pojo.SignRecord; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SignRecordMapper extends BaseMapper { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/mapper/UserInfoMapper.java b/api/src/main/java/me/xiaoyan/point/api/mapper/UserInfoMapper.java new file mode 100644 index 0000000..9aa6ef8 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/mapper/UserInfoMapper.java @@ -0,0 +1,12 @@ +package me.xiaoyan.point.api.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import me.xiaoyan.point.api.pojo.UserInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface UserInfoMapper extends BaseMapper { + + public UserInfo selectOneByOpenId(@Param("openId") String openId); +} diff --git a/api/src/main/java/me/xiaoyan/point/api/pojo/Point.java b/api/src/main/java/me/xiaoyan/point/api/pojo/Point.java new file mode 100644 index 0000000..deb6759 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/pojo/Point.java @@ -0,0 +1,21 @@ +package me.xiaoyan.point.api.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@Accessors(chain = true) +@Builder +public class Point implements Serializable { + private Integer uid; + private Integer total_point; + private Integer valid_point; + private Integer expire_point; + private Integer expire_time; + private Integer update_time; +} diff --git a/api/src/main/java/me/xiaoyan/point/api/pojo/PointRecord.java b/api/src/main/java/me/xiaoyan/point/api/pojo/PointRecord.java new file mode 100644 index 0000000..ad088e9 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/pojo/PointRecord.java @@ -0,0 +1,26 @@ +package me.xiaoyan.point.api.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +@Data +@Accessors(chain = true) +@Builder +@TableName("point_record") +public class PointRecord implements Serializable { + @TableId(type = IdType.AUTO) + private Integer id; + private Integer uid; + private Integer point; + private Integer currentTotalPoint; + private String reason; + private Date validTime; + private Date expireTime; +} diff --git a/api/src/main/java/me/xiaoyan/point/api/pojo/SignRecord.java b/api/src/main/java/me/xiaoyan/point/api/pojo/SignRecord.java new file mode 100644 index 0000000..a93284c --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/pojo/SignRecord.java @@ -0,0 +1,22 @@ +package me.xiaoyan.point.api.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +@Data +@Accessors(chain = true) +@Builder +public class SignRecord implements Serializable { + @TableId(type = IdType.AUTO) + private Integer id; + private Integer uid; + private Integer point; + private String ip; + private Date create_time; +} diff --git a/api/src/main/java/me/xiaoyan/point/api/pojo/UserInfo.java b/api/src/main/java/me/xiaoyan/point/api/pojo/UserInfo.java new file mode 100644 index 0000000..eb0d9d2 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/pojo/UserInfo.java @@ -0,0 +1,58 @@ +package me.xiaoyan.point.api.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +@Data +@Accessors(chain = true) +@Builder +public class UserInfo implements Serializable { + /** + * 用户id + */ + @TableId(type = IdType.AUTO) + private Integer id; + /** + * 微信openid + */ + private String openId; + /** + * 昵称 + */ + private String nickname; + /** + * 投下给你 + */ + private String headImage; + /** + * 性别 + */ + private Integer gender; + /** + * 省份 + */ + private String province; + /** + * 城市 + */ + private String city; + /** + * 推荐人ID + */ + private Integer parentId; + /** + * 第一次登录时间 + */ + private Date firstLoginTime; + private Date updateTime; + /** + * 状态 + */ + private Integer status; +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/PointRecordService.java b/api/src/main/java/me/xiaoyan/point/api/service/PointRecordService.java new file mode 100644 index 0000000..16c25ee --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/PointRecordService.java @@ -0,0 +1,8 @@ +package me.xiaoyan.point.api.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import me.xiaoyan.point.api.pojo.PointRecord; +import me.xiaoyan.point.api.pojo.UserInfo; + +public interface PointRecordService extends IService { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/PointService.java b/api/src/main/java/me/xiaoyan/point/api/service/PointService.java new file mode 100644 index 0000000..7128169 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/PointService.java @@ -0,0 +1,8 @@ +package me.xiaoyan.point.api.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.pojo.UserInfo; + +public interface PointService extends IService { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/SignRecordService.java b/api/src/main/java/me/xiaoyan/point/api/service/SignRecordService.java new file mode 100644 index 0000000..1dd8966 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/SignRecordService.java @@ -0,0 +1,9 @@ +package me.xiaoyan.point.api.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import me.xiaoyan.point.api.pojo.SignRecord; +import me.xiaoyan.point.api.pojo.UserInfo; + +public interface SignRecordService extends IService { + +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/UserInfoService.java b/api/src/main/java/me/xiaoyan/point/api/service/UserInfoService.java new file mode 100644 index 0000000..26a59ac --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/UserInfoService.java @@ -0,0 +1,14 @@ +package me.xiaoyan.point.api.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import me.xiaoyan.point.api.pojo.UserInfo; + +public interface UserInfoService extends IService { + + /** + * 用户的登录 + * @param code 执行wx.login成功后的code + * @return + */ + public UserInfo login(String code); +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/impl/PointRecordServiceImpl.java b/api/src/main/java/me/xiaoyan/point/api/service/impl/PointRecordServiceImpl.java new file mode 100644 index 0000000..0d4009b --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/impl/PointRecordServiceImpl.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import me.xiaoyan.point.api.mapper.PointRecordMapper; +import me.xiaoyan.point.api.pojo.PointRecord; +import me.xiaoyan.point.api.service.PointRecordService; + +public class PointRecordServiceImpl extends ServiceImpl + implements PointRecordService { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/impl/PointServiceImpl.java b/api/src/main/java/me/xiaoyan/point/api/service/impl/PointServiceImpl.java new file mode 100644 index 0000000..59874db --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/impl/PointServiceImpl.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import me.xiaoyan.point.api.mapper.PointMapper; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.service.PointService; + +public class PointServiceImpl extends ServiceImpl + implements PointService { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/impl/SignRecordServiceImpl.java b/api/src/main/java/me/xiaoyan/point/api/service/impl/SignRecordServiceImpl.java new file mode 100644 index 0000000..34e2ff6 --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/impl/SignRecordServiceImpl.java @@ -0,0 +1,10 @@ +package me.xiaoyan.point.api.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import me.xiaoyan.point.api.mapper.SignRecordMapper; +import me.xiaoyan.point.api.pojo.SignRecord; +import me.xiaoyan.point.api.service.SignRecordService; + +public class SignRecordServiceImpl extends ServiceImpl + implements SignRecordService { +} diff --git a/api/src/main/java/me/xiaoyan/point/api/service/impl/UserInfoServiceImpl.java b/api/src/main/java/me/xiaoyan/point/api/service/impl/UserInfoServiceImpl.java new file mode 100644 index 0000000..26181fc --- /dev/null +++ b/api/src/main/java/me/xiaoyan/point/api/service/impl/UserInfoServiceImpl.java @@ -0,0 +1,106 @@ +package me.xiaoyan.point.api.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import me.xiaoyan.point.api.error.BizException; +import me.xiaoyan.point.api.mapper.PointMapper; +import me.xiaoyan.point.api.mapper.UserInfoMapper; +import me.xiaoyan.point.api.pojo.Point; +import me.xiaoyan.point.api.pojo.UserInfo; +import me.xiaoyan.point.api.service.PointRecordService; +import me.xiaoyan.point.api.service.PointService; +import me.xiaoyan.point.api.service.UserInfoService; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.util.Map; + +@Service +@Slf4j +public class UserInfoServiceImpl extends ServiceImpl + implements UserInfoService { + private static final String LOG_TAG = "【USERSERVICE】"; + + @Value("${wechat.app_id}") + private String app_id; + @Value("${wechat.app_secret}") + private String app_secret; + private static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session"; + + // 第一次登录的赠送积分 + @Value("${application.point.first_login}") + private int firstLoginPoint; + // 推荐人的赠送积分 + @Value("${application.point.recommend}") + private int recommendPoint; + + + private PointService pointService; + private PointRecordService pointRecordService; + + public void firstLogin(UserInfo info) { + // 先新增用户基本信息 + save(info); + // 新增积分信息 + Point point = Point.builder() + .uid(info.getId()) + .expire_point(0) + .total_point(firstLoginPoint) + .valid_point(firstLoginPoint) + .build(); + pointService.save(point); + // 新增积分记录 + } + + @Transactional + @Override + public UserInfo login(String code) { + String openId = getOpenIdByCode(code); + // TODO 获取用户的基本信息 + + // 使用openid查询用户信息 + final UserInfo userInfo = this.getBaseMapper().selectOneByOpenId(openId); + // 判断用户信息是否存在 + if (userInfo == null) { + // 不存在走 第一次登录流程 + firstLogin(userInfo); + } + // 首先 + return userInfo; + } + + private void updateUserBasicInfo(UserInfo userInfo) { + try { + this.getBaseMapper().updateById(userInfo); + } catch (Exception e) { + log.warn(LOG_TAG + "更新用户基本信息失败", e); + } + } + + // 使用code换取openId + @SneakyThrows + private String getOpenIdByCode(String code) { + String url = CODE2SESSION + "?appid=" + app_id + "&secret=" + app_secret + + "&js_code=" + code + "&grant_type=authorization_code"; + try (CloseableHttpClient client = HttpClients.createDefault()) { + HttpGet get = new HttpGet(url); + final CloseableHttpResponse response = (CloseableHttpResponse) client.execute(get); + final String content = EntityUtils.toString(response.getEntity()); + ObjectMapper mapper = new ObjectMapper(); + final Map map = mapper.convertValue(content, Map.class); + if ((Integer) map.get("errcode") != 0) { + throw new BizException(1101, "换取code失败(" + map.get("errmsg") + ")"); + } + return map.get("openid").toString(); + } + } +} diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml new file mode 100644 index 0000000..8b232cb --- /dev/null +++ b/api/src/main/resources/application.yml @@ -0,0 +1,54 @@ +server: + port: 8001 +wechat: + app_id: wxafc2a812fe936d88 + app_secret: 3e5f5a577cb06b7d1815db146d552b95 +application: + point: + first_login: 200 + recommend: 100 +spring: + application: + name: point_api + datasource: + name: defaultSource + url: jdbc:mysql://localhost:3306/points_sys?serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: 123456 + type: com.alibaba.druid.pool.DruidDataSource + #数据源配置 + druid: + max-active: 1000 + initial-size: 10 + max-wait: 1000 + min-idle: 10 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + validation-query: select 1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + max-pool-prepared-statement-per-connection-size: 0 + + #监控 + stat-view-servlet: + url-pattern: /druid/* + reset-enable: false + login-username: admin + login-password: admin + allow: 127.0.0.1 + # 是否启用 + enabled: true + web-stat-filter: + url-pattern: /* + exclusions: /druid/*,*.js,*.css,*.html,*.png,*.jpg + filters: stat,wall +springfox: + documentation: + enabled: true +mybatis-plus: + configuration: + # 日志接口 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + cache-enabled: true \ No newline at end of file diff --git a/api/src/main/resources/db.sql b/api/src/main/resources/db.sql new file mode 100644 index 0000000..6c814ce --- /dev/null +++ b/api/src/main/resources/db.sql @@ -0,0 +1,45 @@ +create database points_sys; +use points_sys; +create table userinfo +( + id int(10) primary key auto_increment, + open_id varchar(50) not null unique, + nickname varchar(30) not null, + head_image varchar(200) not null, + gender tinyint(2) null default -1, + province varchar(5) null, + city varchar(20) null, + parent_id int(10) null default 0 comment '推荐人id', + first_login_time datetime default current_timestamp, + update_time datetime null on update current_timestamp, + status tinyint(2) default 1 +) engine = innodb comment '用户表'; + +create table point +( + uid int(10) primary key, + total_point int(10) not null, + valid_point int(10) not null, + expire_point int(10) null default 0, + expire_time datetime null, + update_time datetime null on update current_timestamp +) engine = innodb comment '积分表'; +create table point_record +( + id bigint(15) primary key auto_increment, + uid int(10) not null, + point int(10) not null, + current_total_point int(10) not null, + reason varchar(100) not null, + valid_time datetime null, + expire_time datetime null +) engine = innodb comment '积分记录表'; + +create table sign_record +( + id bigint(15) primary key auto_increment, + uid int(10) not null, + point int(10) not null, + ip varchar(50) not null, + create_time datetime not null +) engine = innodb comment '打卡记录表'; \ No newline at end of file diff --git a/api/src/main/resources/docs/er.png b/api/src/main/resources/docs/er.png new file mode 100644 index 0000000..a593e1e Binary files /dev/null and b/api/src/main/resources/docs/er.png differ diff --git a/api/src/main/resources/docs/process/login.svg b/api/src/main/resources/docs/process/login.svg new file mode 100644 index 0000000..9162b18 --- /dev/null +++ b/api/src/main/resources/docs/process/login.svg @@ -0,0 +1,4 @@ + + + +
登录
登录
登录流程说明
登录流程说明
小程序执行wx.login()
小程序执行wx.login()
授权失败
授权失败
授权成功,
获取code
授权成功, 获取code
是否授权
是否授权
获取用户信息失败
获取用户信息失败
获取用户信息成功
获取用户信息成功
1、使用code到微信服务器获取用户的基本信息(openid/unionid)
1、使用code到微信服务器获取用户的基本信息(openid/unionid)
不存在
不存在
已经存在用户
已经存在用户
2、判断用户信息是否已经存在
2、判断用户信息是否已经存在
失败
失败
成功
成功
3、新增用户信息
新增积分信息
新增积分记录信息
3、新增用户信息...
完成登录
完成登录
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/api/src/main/resources/docs/积分系统.jpg b/api/src/main/resources/docs/积分系统.jpg new file mode 100644 index 0000000..71fe676 Binary files /dev/null and b/api/src/main/resources/docs/积分系统.jpg differ diff --git a/api/src/main/resources/mapper/UserInfoMapper.xml b/api/src/main/resources/mapper/UserInfoMapper.xml new file mode 100644 index 0000000..969eda4 --- /dev/null +++ b/api/src/main/resources/mapper/UserInfoMapper.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/api/src/test/java/me/xiaoyan/point/api/ApiApplicationTests.java b/api/src/test/java/me/xiaoyan/point/api/ApiApplicationTests.java new file mode 100644 index 0000000..2202460 --- /dev/null +++ b/api/src/test/java/me/xiaoyan/point/api/ApiApplicationTests.java @@ -0,0 +1,13 @@ +package me.xiaoyan.point.api; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ApiApplicationTests { + + @Test + void contextLoads() { + } + +}