mirror of
https://github.com/samnyan/arcade-db-server.git
synced 2026-03-21 17:24:15 -05:00
First commit
This commit is contained in:
commit
5de18a1a94
44
.gitignore
vendored
Normal file
44
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
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
|
||||
!.idea/compiler.xml
|
||||
!.idea/encodings.xml
|
||||
!.idea/misc.xml
|
||||
!.idea/modules.xml
|
||||
!.idea/vcs.xml
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
src/main/resources/application.yml
|
||||
|
||||
!.idea/arcade-db-server.iml
|
||||
!.idea/compiler.xml
|
||||
|
||||
node_modules/
|
||||
package-lock.json
|
||||
114
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
114
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
|
|
@ -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
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
1
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
1
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
|
|
@ -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
|
||||
10
gulpfile.js
Normal file
10
gulpfile.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
const gulp = require('gulp');
|
||||
|
||||
gulp.task('thymeleaf', function () {
|
||||
return gulp.src('src/main/resources/**')
|
||||
.pipe(gulp.dest('target/classes/'));
|
||||
});
|
||||
|
||||
gulp.task('watch', function () {
|
||||
gulp.watch('src/main/resources/**', gulp.series('thymeleaf'));
|
||||
});
|
||||
286
mvnw
vendored
Normal file
286
mvnw
vendored
Normal file
|
|
@ -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
mvnw.cmd
vendored
Normal file
161
mvnw.cmd
vendored
Normal file
|
|
@ -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%
|
||||
22
package.json
Normal file
22
package.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "arcade-db-server",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"gulp-watch": "gulp watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp": "4.0.2",
|
||||
"gulp-watch": "^5.0.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitlab.com/sam_nya/arcade-db-server.git"
|
||||
},
|
||||
"author": "sam_nya",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/sam_nya/arcade-db-server/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/sam_nya/arcade-db-server#readme"
|
||||
}
|
||||
104
pom.xml
Normal file
104
pom.xml
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?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>cn.samnya</groupId>
|
||||
<artifactId>arcade-db-server</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>arcade-db-server</name>
|
||||
<description>Arcade DB API Server</description>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.webjars/jquery -->
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
|
||||
<version>3.0.4.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>10</source>
|
||||
<target>10</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package cn.samnya.arcadedbserver;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ArcadeDbServerApplication implements WebMvcConfigurer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ArcadeDbServerApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource() {
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.setBasename("classpath:messages");
|
||||
messageSource.setDefaultEncoding("UTF-8");
|
||||
messageSource.setFallbackToSystemLocale(true);
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocalValidatorFactoryBean validator(MessageSource messageSource) {
|
||||
LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
|
||||
bean.setValidationMessageSource(messageSource);
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocaleResolver localeResolver() {
|
||||
SessionLocaleResolver localeResolver = new SessionLocaleResolver();
|
||||
localeResolver.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
|
||||
return localeResolver;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocaleChangeInterceptor localeChangeInterceptor() {
|
||||
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
|
||||
localeChangeInterceptor.setParamName("lang");
|
||||
return localeChangeInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(localeChangeInterceptor());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.samnya.arcadedbserver;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.DefaultRedirectStrategy;
|
||||
import org.springframework.security.web.RedirectStrategy;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public class LoginSuccessHandler implements AuthenticationSuccessHandler {
|
||||
|
||||
protected Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
redirectStrategy.sendRedirect(request,response,"/");
|
||||
}
|
||||
}
|
||||
75
src/main/java/cn/samnya/arcadedbserver/SecurityConfig.java
Normal file
75
src/main/java/cn/samnya/arcadedbserver/SecurityConfig.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package cn.samnya.arcadedbserver;
|
||||
|
||||
import cn.samnya.arcadedbserver.service.UserDetailsServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserDetailsServiceImpl userDetailsService;
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LoginSuccessHandler loginSuccessHandler() { return new LoginSuccessHandler(); }
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http
|
||||
.csrf()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/company/new", "/game/new", "/hardware/new", "/location/new", "/series/new").authenticated()
|
||||
.antMatchers("/admin", "/admin/**").hasAuthority("ADMIN")
|
||||
.antMatchers("/company/*", "/game/*", "/hardware/*", "/location/*", "/series/*").permitAll()
|
||||
.antMatchers("/location/*/cabinet/add").authenticated()
|
||||
.antMatchers("/location/*/cabinet","/location/*/cabinet/*").permitAll()
|
||||
.antMatchers("/favicon.ico", "/webjars/**", "/css/**", "/js/**", "/images/**", "/fonts/**", "/noimage.png").permitAll()
|
||||
.antMatchers("/", "/error", "/registration").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage("/login")
|
||||
.loginProcessingUrl("/login")
|
||||
.successHandler(loginSuccessHandler())
|
||||
.permitAll()
|
||||
.and()
|
||||
.logout()
|
||||
.logoutUrl("/logout")
|
||||
.logoutSuccessUrl("/login?logout")
|
||||
.deleteCookies("JSESSIONID")
|
||||
.invalidateHttpSession(true)
|
||||
.permitAll();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager customAuthenticationManager() throws Exception {
|
||||
return authenticationManager();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.samnya.arcadedbserver.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
|
||||
@GetMapping
|
||||
public String adminIndex() {
|
||||
return "admin/index";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package cn.samnya.arcadedbserver.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.web.firewall.RequestRejectedException;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class ErrorHandlerController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ErrorHandlerController.class);
|
||||
|
||||
@ExceptionHandler(value = NoSuchElementException.class)
|
||||
public String elementNotFound(Model model) {
|
||||
model.addAttribute("message", "未找到该项目");
|
||||
return "commons/error";
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = NumberFormatException.class)
|
||||
public String numberFormat(Model model) {
|
||||
model.addAttribute("message", "参数错误");
|
||||
return "commons/error";
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = RequestRejectedException.class)
|
||||
public String requestRejected(Model model) {
|
||||
model.addAttribute("message", "参数错误");
|
||||
return "commons/error";
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public String handle404(Model model) {
|
||||
model.addAttribute("message", "未找到该项目");
|
||||
return "commons/error";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.samnya.arcadedbserver.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
public class HomeController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(){
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package cn.samnya.arcadedbserver.controller;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.User;
|
||||
import cn.samnya.arcadedbserver.service.SecurityService;
|
||||
import cn.samnya.arcadedbserver.service.UserService;
|
||||
import cn.samnya.arcadedbserver.validator.UserValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private SecurityService securityService;
|
||||
|
||||
@Autowired
|
||||
private UserValidator userValidator;
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login(Model model, String error, String logout) {
|
||||
if (error != null)
|
||||
model.addAttribute("error", "Your username and password is invalid.");
|
||||
|
||||
if (logout != null)
|
||||
model.addAttribute("message", "You have been logged out successfully.");
|
||||
|
||||
return "login";
|
||||
}
|
||||
|
||||
@GetMapping("/registration")
|
||||
public String registration(Model model) {
|
||||
model.addAttribute("user", new User());
|
||||
|
||||
return "registration";
|
||||
}
|
||||
|
||||
@PostMapping("/registration")
|
||||
public String registration(@ModelAttribute User user, BindingResult bindingResult) {
|
||||
userValidator.validate(user, bindingResult);
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return "registration";
|
||||
}
|
||||
|
||||
userService.save(user);
|
||||
|
||||
securityService.autoLogin(user.getUsername(), user.getPasswordConfirm());
|
||||
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package cn.samnya.arcadedbserver.controller.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Company;
|
||||
import cn.samnya.arcadedbserver.service.arcade.CompanyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/company")
|
||||
public class CompanyController {
|
||||
|
||||
@Autowired
|
||||
CompanyService companyService;
|
||||
|
||||
@GetMapping("browser")
|
||||
public String index(Model model, @RequestParam(value = "page", defaultValue = "1") int page) {
|
||||
Pageable pageRequest = PageRequest.of(page - 1, 10, Sort.by("id").descending());
|
||||
Page<Company> companyPage = companyService.findAll(pageRequest);
|
||||
model.addAttribute("page", companyPage);
|
||||
model.addAttribute("companyList", companyPage.getContent());
|
||||
return "company/browser";
|
||||
}
|
||||
|
||||
@GetMapping("new")
|
||||
public String create(Model model) {
|
||||
Company company = new Company();
|
||||
model.addAttribute("company", company);
|
||||
return "company/new";
|
||||
}
|
||||
|
||||
@PostMapping("new")
|
||||
public String create(@Valid @ModelAttribute Company company, BindingResult result) {
|
||||
if (result.hasErrors()) return "company/new";
|
||||
long id = companyService.save(company);
|
||||
return "redirect:/company/"+id;
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public String findById(@PathVariable Long id, Model model){
|
||||
Optional<Company> company = companyService.findOne(id);
|
||||
model.addAttribute("company", company.orElseThrow());
|
||||
|
||||
return "company/show";
|
||||
}
|
||||
|
||||
/**
|
||||
* Linking
|
||||
*/
|
||||
|
||||
@GetMapping("{id}/link")
|
||||
public String linkPage(@PathVariable Long id, Model model){
|
||||
Optional<Company> company = companyService.findOne(id);
|
||||
model.addAttribute("company", company.orElseThrow());
|
||||
|
||||
return "company/link";
|
||||
}
|
||||
|
||||
@PostMapping("{id}/link")
|
||||
public String createLink(@PathVariable long id, @RequestParam String type, @RequestParam long target_id) {
|
||||
switch(type) {
|
||||
case "series": companyService.linkSeries(id,target_id); break;
|
||||
case "game": companyService.linkGame(id,target_id); break;
|
||||
}
|
||||
|
||||
return "redirect:/company/"+id;
|
||||
}
|
||||
|
||||
// @GetMapping("{id}/linkall")
|
||||
// public String linkall(@PathVariable long id) {
|
||||
// companyService.linkAll(id);
|
||||
// return "redirect:/company/"+id;
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package cn.samnya.arcadedbserver.controller.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Game;
|
||||
import cn.samnya.arcadedbserver.service.arcade.GameService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/game")
|
||||
public class GameController {
|
||||
|
||||
@Autowired
|
||||
GameService gameService;
|
||||
|
||||
@GetMapping("browser")
|
||||
public String browser(Model model, @RequestParam(value = "page", defaultValue = "1") int page) {
|
||||
Pageable pageRequest = PageRequest.of(page - 1, 10, Sort.by("id").descending());
|
||||
Page<Game> gamePage = gameService.findAll(pageRequest);
|
||||
model.addAttribute("page", gamePage);
|
||||
model.addAttribute("gameList", gamePage.getContent());
|
||||
return "game/browser";
|
||||
}
|
||||
|
||||
@GetMapping("new")
|
||||
public String create(Model model) {
|
||||
Game game = new Game();
|
||||
model.addAttribute("game", game);
|
||||
return "game/new";
|
||||
}
|
||||
|
||||
@PostMapping("new")
|
||||
public String create(@Valid @ModelAttribute Game game, BindingResult result) {
|
||||
if (result.hasErrors()) return "game/new";
|
||||
long id = gameService.save(game);
|
||||
return "redirect:/game/"+id;
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public String detail(@PathVariable Long id, Model model){
|
||||
Optional<Game> game = gameService.findOne(id);
|
||||
model.addAttribute("game", game.orElseThrow());
|
||||
|
||||
return "game/show";
|
||||
}
|
||||
|
||||
@GetMapping("{id}/link")
|
||||
public String linkPage(@PathVariable Long id, Model model){
|
||||
Optional<Game> game = gameService.findOne(id);
|
||||
model.addAttribute("game", game.orElseThrow());
|
||||
|
||||
return "game/link";
|
||||
}
|
||||
|
||||
@PostMapping("{id}/link")
|
||||
public String createLink(@PathVariable long id, @RequestParam long series_id) {
|
||||
gameService.linkSeries(id,series_id);
|
||||
return "redirect:/game/"+id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package cn.samnya.arcadedbserver.controller.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Hardware;
|
||||
import cn.samnya.arcadedbserver.service.arcade.HardwareService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/hardware")
|
||||
public class HardwareController {
|
||||
|
||||
@Autowired
|
||||
HardwareService hardwareService;
|
||||
|
||||
@GetMapping("browser")
|
||||
public String index(Model model, @RequestParam(value = "page", defaultValue = "1") int page) {
|
||||
Pageable pageRequest = PageRequest.of(page - 1, 10, Sort.by("id").descending());
|
||||
Page<Hardware> hardwarePage = hardwareService.findAll(pageRequest);
|
||||
model.addAttribute("page", hardwarePage);
|
||||
model.addAttribute("hardwareList", hardwarePage.getContent());
|
||||
return "hardware/browser";
|
||||
}
|
||||
|
||||
@GetMapping("new")
|
||||
public String create(Model model) {
|
||||
Hardware hardware = new Hardware();
|
||||
model.addAttribute("hardware", hardware);
|
||||
return "hardware/new";
|
||||
}
|
||||
|
||||
@PostMapping("new")
|
||||
public String create(@Valid @ModelAttribute Hardware hardware, BindingResult result) {
|
||||
if (result.hasErrors()) return "hardware/new";
|
||||
long id = hardwareService.save(hardware);
|
||||
return "redirect:/hardware/"+id;
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public String findById(@PathVariable Long id, Model model) {
|
||||
Optional<Hardware> hardware = hardwareService.findOne(id);
|
||||
model.addAttribute("hardware", hardware.orElseThrow());
|
||||
|
||||
return "hardware/show";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package cn.samnya.arcadedbserver.controller.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Cabinet;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Location;
|
||||
import cn.samnya.arcadedbserver.service.arcade.CabinetService;
|
||||
import cn.samnya.arcadedbserver.service.arcade.LocationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/location")
|
||||
public class LocationController {
|
||||
|
||||
@Autowired
|
||||
LocationService locationService;
|
||||
|
||||
@Autowired
|
||||
CabinetService cabinetService;
|
||||
|
||||
@GetMapping("browser")
|
||||
public String browser(Model model, @RequestParam(value = "page", defaultValue = "1") int page) {
|
||||
Pageable pageRequest = PageRequest.of(page - 1, 10, Sort.by("id").descending());
|
||||
Page<Location> locationPage = locationService.findAll(pageRequest);
|
||||
model.addAttribute("page", locationPage);
|
||||
model.addAttribute("locationList", locationPage.getContent());
|
||||
return "location/browser";
|
||||
}
|
||||
|
||||
@GetMapping("new")
|
||||
public String create(Model model) {
|
||||
Location location = new Location();
|
||||
model.addAttribute("location", location);
|
||||
return "location/new";
|
||||
}
|
||||
|
||||
@PostMapping("new")
|
||||
public String create(@Valid @ModelAttribute Location location, BindingResult result) {
|
||||
if (result.hasErrors()) return "location/new";
|
||||
long id = locationService.save(location);
|
||||
return "redirect:/location/"+id;
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public String findById(@PathVariable Long id, Model model) {
|
||||
Optional<Location> location = locationService.findOne(id);
|
||||
model.addAttribute("location", location.orElseThrow());
|
||||
|
||||
return "location/show";
|
||||
}
|
||||
|
||||
/**
|
||||
* Cabinet
|
||||
*/
|
||||
|
||||
|
||||
@GetMapping("{id}/cabinet")
|
||||
public String showCabinetList(@PathVariable Long id, Model model) {
|
||||
Optional<Location> location = locationService.findOne(id);
|
||||
model.addAttribute("location", location.orElseThrow());
|
||||
return "location/cabinet/list";
|
||||
}
|
||||
|
||||
@GetMapping("{locationId}/cabinet/{cabinetId}")
|
||||
public String showCabinet(@PathVariable Long locationId, @PathVariable Long cabinetId, Model model) {
|
||||
Optional<Cabinet> cabinet = cabinetService.findOne(cabinetId);
|
||||
model.addAttribute("cabinet", cabinet.orElseThrow());
|
||||
return "location/cabinet/show";
|
||||
}
|
||||
|
||||
@GetMapping("{locationId}/cabinet/add")
|
||||
public String addCabinet(@PathVariable Long locationId, Model model) {
|
||||
Optional<Location> location = locationService.findOne(locationId);
|
||||
model.addAttribute("location", location.orElseThrow());
|
||||
Cabinet cabinet = new Cabinet();
|
||||
cabinet.setLocation(location.orElseThrow());
|
||||
model.addAttribute("cabinet",cabinet);
|
||||
return "location/cabinet/add";
|
||||
}
|
||||
|
||||
@PostMapping("{locationId}/cabinet/add")
|
||||
public String addCabinet(@PathVariable Long locationId, Model model, @ModelAttribute Cabinet cabinet, BindingResult result) {
|
||||
if (result.hasErrors()) return "location/cabinet/add";
|
||||
long cabinetId = cabinetService.save(cabinet);
|
||||
return "redirect:/location/"+locationId+"/cabinet/"+cabinetId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package cn.samnya.arcadedbserver.controller.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Series;
|
||||
import cn.samnya.arcadedbserver.service.arcade.SeriesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/series")
|
||||
public class SeriesController {
|
||||
|
||||
@Autowired
|
||||
private SeriesService seriesService;
|
||||
|
||||
@GetMapping("browser")
|
||||
public String browser(Model model, @RequestParam(value = "page", defaultValue = "1") int page) {
|
||||
Pageable pageRequest = PageRequest.of(page - 1, 10, Sort.by("id").descending());
|
||||
Page<Series> seriesPage = seriesService.findAll(pageRequest);
|
||||
model.addAttribute("page", seriesPage);
|
||||
model.addAttribute("seriesList", seriesPage.getContent());
|
||||
return "series/browser";
|
||||
}
|
||||
|
||||
@GetMapping("new")
|
||||
public String create(Model model) {
|
||||
Series series = new Series();
|
||||
model.addAttribute("series", series);
|
||||
return "series/new";
|
||||
}
|
||||
|
||||
@PostMapping("new")
|
||||
public String create(@Valid @ModelAttribute Series series, BindingResult result) {
|
||||
if (result.hasErrors()) return "series/new";
|
||||
long id = seriesService.save(series);
|
||||
return "redirect:/series/" + id;
|
||||
}
|
||||
|
||||
@PostMapping("search")
|
||||
public String search(){
|
||||
return "series/browser";
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public String findById(@PathVariable Long id, Model model){
|
||||
Optional<Series> series = seriesService.findOne(id);
|
||||
model.addAttribute("series", series.orElseThrow());
|
||||
return "series/show";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("{id}")
|
||||
public String update(@PathVariable Long id, @ModelAttribute Series series){
|
||||
series.setId(id);
|
||||
seriesService.save(series);
|
||||
return "redirect:/series";
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
public String delete(@PathVariable Long id){
|
||||
seriesService.delete(id);
|
||||
return "redirect:/series";
|
||||
}
|
||||
|
||||
@GetMapping("{id}/link")
|
||||
public String linkPage(@PathVariable Long id, Model model){
|
||||
Optional<Series> series = seriesService.findOne(id);
|
||||
model.addAttribute("series", series.orElseThrow());
|
||||
|
||||
return "series/link";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Cabinet;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface CabinetRepository extends PagingAndSortingRepository<Cabinet, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Company;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface CompanyRepository extends PagingAndSortingRepository<Company, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Game;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface GameRepository extends PagingAndSortingRepository<Game, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Hardware;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface HardwareRepository extends PagingAndSortingRepository<Hardware, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Location;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface LocationRepository extends PagingAndSortingRepository<Location, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.Role;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public interface RoleRepository extends JpaRepository<Role, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Series;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Repository
|
||||
public interface SeriesRepository extends PagingAndSortingRepository<Series, Long> {
|
||||
|
||||
List<Series> findByNameContaining(String name);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
|
||||
User findByUsername(String username);
|
||||
}
|
||||
53
src/main/java/cn/samnya/arcadedbserver/model/Role.java
Normal file
53
src/main/java/cn/samnya/arcadedbserver/model/Role.java
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package cn.samnya.arcadedbserver.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Role implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToMany(mappedBy = "roles")
|
||||
private Set<User> users;
|
||||
|
||||
public Role() {
|
||||
}
|
||||
|
||||
public Role(String name, Set<User> users) {
|
||||
this.name = name;
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Set<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
}
|
||||
87
src/main/java/cn/samnya/arcadedbserver/model/User.java
Normal file
87
src/main/java/cn/samnya/arcadedbserver/model/User.java
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
package cn.samnya.arcadedbserver.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class User implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String email;
|
||||
|
||||
@Transient
|
||||
private String passwordConfirm;
|
||||
|
||||
@ManyToMany
|
||||
private Set<Role> roles;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String username, String password, String email, String passwordConfirm, Set<Role> roles) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.email = email;
|
||||
this.passwordConfirm = passwordConfirm;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPasswordConfirm() {
|
||||
return passwordConfirm;
|
||||
}
|
||||
|
||||
public void setPasswordConfirm(String passwordConfirm) {
|
||||
this.passwordConfirm = passwordConfirm;
|
||||
}
|
||||
|
||||
public Set<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
132
src/main/java/cn/samnya/arcadedbserver/model/arcade/Cabinet.java
Normal file
132
src/main/java/cn/samnya/arcadedbserver/model/arcade/Cabinet.java
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* This is the class contain the information about the actual cabinet running in a arcade.
|
||||
* Containing the software and hardware version as well as price
|
||||
*
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Cabinet implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "location_id")
|
||||
private Location location;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "game_id")
|
||||
private Game game;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "hardware_id")
|
||||
private Hardware hardware;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Integer price;
|
||||
|
||||
@Column( name = "unit_condition" )
|
||||
private Condition condition;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
public Cabinet() {
|
||||
}
|
||||
|
||||
public Cabinet(Location location, Game game, Hardware hardware, String remark, Integer price, Condition condition, LocalDateTime updateTime, String description) {
|
||||
this.location = location;
|
||||
this.game = game;
|
||||
this.hardware = hardware;
|
||||
this.remark = remark;
|
||||
this.price = price;
|
||||
this.condition = condition;
|
||||
this.updateTime = updateTime;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public void setGame(Game game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public Hardware getHardware() {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
public void setHardware(Hardware hardware) {
|
||||
this.hardware = hardware;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Integer getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Integer price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public void setCondition(Condition condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
110
src/main/java/cn/samnya/arcadedbserver/model/arcade/Company.java
Normal file
110
src/main/java/cn/samnya/arcadedbserver/model/arcade/Company.java
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Company {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String name;
|
||||
|
||||
@Size(max = 200)
|
||||
private String homePage;
|
||||
|
||||
@Size(max = 200)
|
||||
private String imageUrl;
|
||||
|
||||
@ManyToMany(mappedBy = "companies")
|
||||
private Set<Game> games = new HashSet<>();
|
||||
|
||||
@ManyToMany(mappedBy = "companies")
|
||||
private List<Series> series = new ArrayList<>();
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
public Company() {
|
||||
}
|
||||
|
||||
public Company(String name, String homePage, String imageUrl, Set<Game> games, List<Series> series, String description) {
|
||||
this.name = name;
|
||||
this.homePage = homePage;
|
||||
this.imageUrl = imageUrl;
|
||||
this.games = games;
|
||||
this.series = series;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHomePage() {
|
||||
return homePage;
|
||||
}
|
||||
|
||||
public void setHomePage(String homePage) {
|
||||
this.homePage = homePage;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public Set<Game> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
public void setGames(Set<Game> games) {
|
||||
this.games = games;
|
||||
}
|
||||
|
||||
public List<Series> getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public void setSeries(List<Series> series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public enum Condition {
|
||||
|
||||
PERFECT("完美"),
|
||||
NORMAL("正常"),
|
||||
ABNORMAL("勉强能玩"),
|
||||
BROKEN("坏机"),
|
||||
REMOVED("已撤机");
|
||||
|
||||
private String displayName;
|
||||
|
||||
Condition(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
166
src/main/java/cn/samnya/arcadedbserver/model/arcade/Game.java
Normal file
166
src/main/java/cn/samnya/arcadedbserver/model/arcade/Game.java
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.metadata.Release;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Game implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String name;
|
||||
|
||||
@Size(max = 200)
|
||||
private String imageUrl;
|
||||
|
||||
@NotNull
|
||||
private Genre genre;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "game_company_mapping",
|
||||
joinColumns = @JoinColumn(name = "game_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "company_id")
|
||||
)
|
||||
private List<Company> companies = new ArrayList<>();
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "series_id")
|
||||
private Series series;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "game_hardware_mapping",
|
||||
joinColumns = @JoinColumn(name = "game_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "hardware_id")
|
||||
)
|
||||
private List<Hardware> hardware = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "game")
|
||||
private List<Cabinet> cabinets = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "game")
|
||||
private List<Release> releases = new ArrayList<>();
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
public Game() {
|
||||
}
|
||||
|
||||
public Game(@NotBlank @Size(max = 200) String name, @Size(max = 200) String imageUrl, @NotNull Genre genre, Series series, String description) {
|
||||
this.name = name;
|
||||
this.imageUrl = imageUrl;
|
||||
this.genre = genre;
|
||||
this.series = series;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Game(@NotBlank @Size(max = 200) String name, @Size(max = 200) String imageUrl, @NotNull Genre genre, List<Company> companies, Series series, List<Hardware> hardware, List<Cabinet> cabinets, List<Release> releases, String description) {
|
||||
this.name = name;
|
||||
this.imageUrl = imageUrl;
|
||||
this.genre = genre;
|
||||
this.companies = companies;
|
||||
this.series = series;
|
||||
this.hardware = hardware;
|
||||
this.cabinets = cabinets;
|
||||
this.releases = releases;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<Cabinet> getCabinets() {
|
||||
return cabinets;
|
||||
}
|
||||
|
||||
public void setCabinets(List<Cabinet> cabinets) {
|
||||
this.cabinets = cabinets;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public Genre getGenre() {
|
||||
return genre;
|
||||
}
|
||||
|
||||
public void setGenre(Genre genre) {
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
public List<Company> getCompanies() {
|
||||
return companies;
|
||||
}
|
||||
|
||||
public void setCompanies(List<Company> companies) {
|
||||
this.companies = companies;
|
||||
}
|
||||
|
||||
public Series getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public void setSeries(Series series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
public List<Hardware> getHardware() {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
public void setHardware(List<Hardware> hardware) {
|
||||
this.hardware = hardware;
|
||||
}
|
||||
|
||||
public List<Release> getReleases() {
|
||||
return releases;
|
||||
}
|
||||
|
||||
public void setReleases(List<Release> releases) {
|
||||
this.releases = releases;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public enum Genre {
|
||||
MUSIC_GAME("音乐类"),
|
||||
RACING_GAME("竞速类"),
|
||||
SHOOTING_GAME("射击类");
|
||||
|
||||
|
||||
private String displayName;
|
||||
|
||||
Genre(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override public String toString() { return displayName; }
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Hardware implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String name;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String model;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate releaseDate;
|
||||
|
||||
@Size(max = 200)
|
||||
private String imageUrl;
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
@ManyToMany(mappedBy = "hardware")
|
||||
private List<Game> games = new ArrayList<>();
|
||||
|
||||
@ManyToMany(mappedBy = "hardware")
|
||||
private List<Series> series = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "hardware")
|
||||
private List<Cabinet> cabinets = new ArrayList<>();
|
||||
|
||||
public Hardware() {
|
||||
}
|
||||
|
||||
public Hardware(String name, String model, LocalDate releaseDate, String imageUrl, String description, List<Game> games, List<Series> series) {
|
||||
this.name = name;
|
||||
this.model = model;
|
||||
this.releaseDate = releaseDate;
|
||||
this.imageUrl = imageUrl;
|
||||
this.description = description;
|
||||
this.games = games;
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public LocalDate getReleaseDate() {
|
||||
return releaseDate;
|
||||
}
|
||||
|
||||
public void setReleaseDate(LocalDate releaseDate) {
|
||||
this.releaseDate = releaseDate;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<Game> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
public void setGames(List<Game> games) {
|
||||
this.games = games;
|
||||
}
|
||||
|
||||
public List<Series> getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public void setSeries(List<Series> series) {
|
||||
this.series = series;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Location {
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
private LocationStatus status = LocationStatus.OPEN;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String name;
|
||||
|
||||
@Size(max = 200)
|
||||
private String imageUrl;
|
||||
|
||||
private double longitude;
|
||||
|
||||
private double latitude;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 200)
|
||||
private String address;
|
||||
|
||||
@Size(max = 200)
|
||||
private String website;
|
||||
|
||||
@Size(max = 200)
|
||||
private String contact;
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String workTime;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "location")
|
||||
private List<Cabinet> cabinets = new ArrayList<>();
|
||||
|
||||
public Location() {
|
||||
}
|
||||
|
||||
public Location(LocationStatus status, String name, String imageUrl, double longitude, double latitude, String address, String website, String contact, String description, String workTime, List<Cabinet> cabinets) {
|
||||
this.status = status;
|
||||
this.name = name;
|
||||
this.imageUrl = imageUrl;
|
||||
this.longitude = longitude;
|
||||
this.latitude = latitude;
|
||||
this.address = address;
|
||||
this.website = website;
|
||||
this.contact = contact;
|
||||
this.description = description;
|
||||
this.workTime = workTime;
|
||||
this.cabinets = cabinets;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocationStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(LocationStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
|
||||
public String getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(String contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getWorkTime() {
|
||||
return workTime;
|
||||
}
|
||||
|
||||
public void setWorkTime(String workTime) {
|
||||
this.workTime = workTime;
|
||||
}
|
||||
|
||||
public List<Cabinet> getCabinets() {
|
||||
return cabinets;
|
||||
}
|
||||
|
||||
public void setCabinets(List<Cabinet> cabinets) {
|
||||
this.cabinets = cabinets;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
public enum LocationStatus {
|
||||
CLOSED("已关闭"),
|
||||
OPEN("正常开放"),
|
||||
TEMPORARY_CLOSED("临时关闭"),
|
||||
CONSTRUCTING("施工中");
|
||||
|
||||
private String displayName;
|
||||
|
||||
LocationStatus(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
131
src/main/java/cn/samnya/arcadedbserver/model/arcade/Series.java
Normal file
131
src/main/java/cn/samnya/arcadedbserver/model/arcade/Series.java
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
package cn.samnya.arcadedbserver.model.arcade;
|
||||
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
public class Series implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
private String imageUrl;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "series_company_mapping",
|
||||
joinColumns = @JoinColumn(name = "series_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "company_id")
|
||||
)
|
||||
private List<Company> companies = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "series")
|
||||
private List<Game> games = new ArrayList<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "series_hardware_mapping",
|
||||
joinColumns = @JoinColumn(name = "series_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "hardware_id")
|
||||
)
|
||||
private List<Hardware> hardware = new ArrayList<>();
|
||||
|
||||
@Column(length = 65535, columnDefinition = "TEXT")
|
||||
@Type(type = "text")
|
||||
private String description;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate firstReleaseDate;
|
||||
|
||||
public Series() {
|
||||
}
|
||||
|
||||
public Series(String name, String imageUrl, List<Company> companies, List<Game> games, List<Hardware> hardwares, String description, LocalDate firstReleaseDate) {
|
||||
this.name = name;
|
||||
this.imageUrl = imageUrl;
|
||||
this.companies = companies;
|
||||
this.games = games;
|
||||
this.hardware = hardwares;
|
||||
this.description = description;
|
||||
this.firstReleaseDate = firstReleaseDate;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public List<Company> getCompanies() {
|
||||
return companies;
|
||||
}
|
||||
|
||||
public void setCompanies(List<Company> companies) {
|
||||
this.companies = companies;
|
||||
}
|
||||
|
||||
public List<Game> getGames() {
|
||||
return games;
|
||||
}
|
||||
|
||||
public void setGames(List<Game> games) {
|
||||
this.games = games;
|
||||
}
|
||||
|
||||
public List<Hardware> getHardware() {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
public void setHardware(List<Hardware> hardware) {
|
||||
this.hardware = hardware;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public LocalDate getFirstReleaseDate() {
|
||||
return firstReleaseDate;
|
||||
}
|
||||
|
||||
public void setFirstReleaseDate(LocalDate firstReleaseDate) {
|
||||
this.firstReleaseDate = firstReleaseDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package cn.samnya.arcadedbserver.model.metadata;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Game;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Entity
|
||||
@Table( name = "region_release" )
|
||||
public class Release implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue( strategy = GenerationType.IDENTITY )
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "game_id")
|
||||
private Game game;
|
||||
|
||||
private String region;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate releaseDate;
|
||||
|
||||
public Release() {
|
||||
}
|
||||
|
||||
public Release(Game game, String region, LocalDate releaseDate) {
|
||||
this.game = game;
|
||||
this.region = region;
|
||||
this.releaseDate = releaseDate;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public void setGame(Game game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public LocalDate getReleaseDate() {
|
||||
return releaseDate;
|
||||
}
|
||||
|
||||
public void setReleaseDate(LocalDate releaseDate) {
|
||||
this.releaseDate = releaseDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package cn.samnya.arcadedbserver.service;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class SecurityService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SecurityService.class);
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
@Autowired
|
||||
private UserDetailsServiceImpl userDetailsService;
|
||||
|
||||
public String findLoggedInUsername() {
|
||||
Object userDetails = SecurityContextHolder.getContext().getAuthentication().getDetails();
|
||||
if (userDetails instanceof UserDetails) {
|
||||
return ((UserDetails) userDetails).getUsername();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void autoLogin(String username, String password) {
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
|
||||
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
|
||||
|
||||
authenticationManager.authenticate(usernamePasswordAuthenticationToken);
|
||||
|
||||
if (usernamePasswordAuthenticationToken.isAuthenticated()) {
|
||||
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
|
||||
logger.debug(String.format("Auto login %s successfully!", username));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package cn.samnya.arcadedbserver.service;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.UserRepository;
|
||||
import cn.samnya.arcadedbserver.model.Role;
|
||||
import cn.samnya.arcadedbserver.model.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
User user = userRepository.findByUsername(username);
|
||||
|
||||
if (user == null) throw new UsernameNotFoundException(username);
|
||||
|
||||
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
|
||||
for (Role role : user.getRoles()) {
|
||||
grantedAuthorities.add(new SimpleGrantedAuthority(role.getName()));
|
||||
}
|
||||
|
||||
return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), grantedAuthorities);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package cn.samnya.arcadedbserver.service;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.RoleRepository;
|
||||
import cn.samnya.arcadedbserver.dao.UserRepository;
|
||||
import cn.samnya.arcadedbserver.model.Role;
|
||||
import cn.samnya.arcadedbserver.model.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
public void save(User user) {
|
||||
user.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));
|
||||
Optional<Role> userRole = roleRepository.findById((long) 1);
|
||||
userRole.ifPresent(role -> {
|
||||
Set<Role> roleSet = new HashSet<Role>();
|
||||
roleSet.add(role);
|
||||
user.setRoles(roleSet);
|
||||
});
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
public User findByUsername(String username) {
|
||||
return userRepository.findByUsername(username);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.CabinetRepository;
|
||||
import cn.samnya.arcadedbserver.dao.GameRepository;
|
||||
import cn.samnya.arcadedbserver.dao.HardwareRepository;
|
||||
import cn.samnya.arcadedbserver.dao.LocationRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Cabinet;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class CabinetService {
|
||||
|
||||
@Autowired
|
||||
GameRepository gameRepository;
|
||||
|
||||
@Autowired
|
||||
HardwareRepository hardwareRepository;
|
||||
|
||||
@Autowired
|
||||
LocationRepository locationRepository;
|
||||
|
||||
@Autowired
|
||||
CabinetRepository cabinetRepository;
|
||||
|
||||
public Optional<Cabinet> findOne(Long id) {
|
||||
return cabinetRepository.findById(id);
|
||||
}
|
||||
|
||||
public long save(Cabinet cabinet) {
|
||||
cabinetRepository.save(cabinet);
|
||||
return cabinet.getId();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.CompanyRepository;
|
||||
import cn.samnya.arcadedbserver.dao.GameRepository;
|
||||
import cn.samnya.arcadedbserver.dao.SeriesRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Company;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class CompanyService {
|
||||
|
||||
@Autowired
|
||||
CompanyRepository companyRepository;
|
||||
|
||||
@Autowired
|
||||
SeriesRepository seriesRepository;
|
||||
|
||||
@Autowired
|
||||
GameRepository gameRepository;
|
||||
|
||||
public Page<Company> findAll(Pageable pageable) {
|
||||
return companyRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public Optional<Company> findOne(Long id) {
|
||||
return companyRepository.findById(id);
|
||||
}
|
||||
|
||||
public long save(Company company) {
|
||||
companyRepository.save(company);
|
||||
return company.getId();
|
||||
}
|
||||
|
||||
public void linkSeries(long company_id, long series_id) {
|
||||
companyRepository.findById(company_id).ifPresent(company -> {
|
||||
seriesRepository.findById(series_id).ifPresent(series -> {
|
||||
company.getSeries().add(series);
|
||||
series.getCompanies().add(company);
|
||||
companyRepository.save(company);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void linkGame(long company_id, long game_id) {
|
||||
companyRepository.findById(company_id).ifPresent(company -> {
|
||||
gameRepository.findById(game_id).ifPresent(game -> {
|
||||
company.getGames().add(game);
|
||||
game.getCompanies().add(company);
|
||||
companyRepository.save(company);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void linkAll(long company_id) {
|
||||
companyRepository.findById(company_id).ifPresent(company -> {
|
||||
gameRepository.findAll().forEach(game -> {
|
||||
game.getCompanies().add(company);
|
||||
company.getGames().add(game);
|
||||
});
|
||||
seriesRepository.findAll().forEach(series -> {
|
||||
series.getCompanies().add(company);
|
||||
company.getSeries().add(series);
|
||||
});
|
||||
companyRepository.save(company);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.GameRepository;
|
||||
import cn.samnya.arcadedbserver.dao.SeriesRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Game;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class GameService {
|
||||
|
||||
@Autowired
|
||||
GameRepository gameRepository;
|
||||
|
||||
@Autowired
|
||||
SeriesRepository seriesRepository;
|
||||
|
||||
public Page<Game> findAll(Pageable pageable) {
|
||||
return gameRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public long save(Game game) {
|
||||
gameRepository.save(game);
|
||||
return game.getId();
|
||||
}
|
||||
|
||||
public Optional<Game> findOne(Long id) {
|
||||
return gameRepository.findById(id);
|
||||
}
|
||||
|
||||
public void linkSeries(long game_id, long series_id) {
|
||||
gameRepository.findById(game_id).ifPresent(game -> {
|
||||
seriesRepository.findById(series_id).ifPresent(series -> {
|
||||
game.setSeries(series);
|
||||
gameRepository.save(game);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.HardwareRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Hardware;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class HardwareService {
|
||||
|
||||
@Autowired
|
||||
HardwareRepository hardwareRepository;
|
||||
|
||||
public Page<Hardware> findAll(Pageable pageable) {
|
||||
return hardwareRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public long save(Hardware hardware) {
|
||||
hardwareRepository.save(hardware);
|
||||
return hardware.getId();
|
||||
}
|
||||
|
||||
public Optional<Hardware> findOne(Long id) {
|
||||
return hardwareRepository.findById(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.LocationRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Location;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class LocationService {
|
||||
|
||||
@Autowired
|
||||
LocationRepository locationRepository;
|
||||
|
||||
public Page<Location> findAll(Pageable pageable) {
|
||||
return locationRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public long save(Location location) {
|
||||
locationRepository.save(location);
|
||||
return location.getId();
|
||||
}
|
||||
|
||||
public Optional<Location> findOne(Long id) {
|
||||
return locationRepository.findById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package cn.samnya.arcadedbserver.service.arcade;
|
||||
|
||||
import cn.samnya.arcadedbserver.dao.SeriesRepository;
|
||||
import cn.samnya.arcadedbserver.model.arcade.Series;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Service
|
||||
public class SeriesService {
|
||||
|
||||
@Autowired
|
||||
private SeriesRepository seriesRepository;
|
||||
|
||||
public Page<Series> findAll(Pageable pageable) {
|
||||
return seriesRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public Optional<Series> findOne(Long id) {
|
||||
return seriesRepository.findById(id);
|
||||
}
|
||||
|
||||
public long save(Series series) {
|
||||
seriesRepository.save(series);
|
||||
return series.getId();
|
||||
}
|
||||
|
||||
public void delete(Long id) {
|
||||
seriesRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package cn.samnya.arcadedbserver.validator;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.User;
|
||||
import cn.samnya.arcadedbserver.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@Component
|
||||
public class UserValidator implements Validator {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return User.class.equals(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object o, Errors errors) {
|
||||
User user = (User) o;
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "NotEmpty");
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "NotEmpty");
|
||||
if (user.getUsername().length() < 6 || user.getUsername().length() > 32) {
|
||||
errors.rejectValue("username", "Size.user.username");
|
||||
}
|
||||
if (userService.findByUsername(user.getUsername()) != null) {
|
||||
errors.rejectValue("username", "Duplicate.user.username");
|
||||
}
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "NotEmpty");
|
||||
if (user.getPassword().length() < 8 || user.getPassword().length() > 32) {
|
||||
errors.rejectValue("password", "Size.user.password");
|
||||
}
|
||||
|
||||
if (!user.getPasswordConfirm().equals(user.getPassword())) {
|
||||
errors.rejectValue("passwordConfirm", "Diff.user.passwordConfirm");
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/main/resources/ValidationMessages.properties
Normal file
5
src/main/resources/ValidationMessages.properties
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
org.hibernate.validator.constraints.NotEmpty.message=必須項目です
|
||||
javax.validation.constraints.NotNull.message=必須項目です
|
||||
javax.validation.constraints.Max.message={value} 以下にして下さい
|
||||
javax.validation.constraints.Min.message={value} 以上にして下さい
|
||||
javax.validation.constraints.Size.message={min} 文字以上 {max} 文字以下にして下さい
|
||||
18
src/main/resources/application-sample.yml
Normal file
18
src/main/resources/application-sample.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
spring:
|
||||
datasource:
|
||||
driver-class-name: org.mariadb.jdbc.Driver
|
||||
username:
|
||||
password:
|
||||
url: jdbc:mariadb://localhost:3306/arcadedb?useSSL=false
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MariaDB10Dialect
|
||||
profiles:
|
||||
active: dev
|
||||
thymeleaf:
|
||||
cache: false
|
||||
check-template: true
|
||||
encoding: UTF-8
|
||||
5
src/main/resources/messages_zh.properties
Normal file
5
src/main/resources/messages_zh.properties
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
NotEmpty=该项不能为空
|
||||
Size.user.username=请输入 8 到 32 个字符
|
||||
Duplicate.user.username=这个用户名已经被人使用了
|
||||
Size.user.password=请输入至少 8 个字符
|
||||
Diff.user.passwordConfirm=密码输入不一致
|
||||
7
src/main/resources/static/css/bootstrap-datepicker.min.css
vendored
Normal file
7
src/main/resources/static/css/bootstrap-datepicker.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
40
src/main/resources/static/css/common.css
Normal file
40
src/main/resources/static/css/common.css
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*.item-list {*/
|
||||
/* padding-left: 0;*/
|
||||
/* background-color: #fff;*/
|
||||
/* background-clip: border-box;*/
|
||||
/* border: 1px solid rgba(0,0,0,.125);*/
|
||||
/* border-radius: .25rem;*/
|
||||
/*}*/
|
||||
/*.item-list .item {*/
|
||||
/* padding: 7px 5px;*/
|
||||
/* height: 150px;*/
|
||||
/*}*/
|
||||
|
||||
/*.item-list .item a {*/
|
||||
/* margin: auto;*/
|
||||
/*}*/
|
||||
|
||||
/*.item-list-item a img {*/
|
||||
|
||||
/*}*/
|
||||
|
||||
.table-img {
|
||||
width: 120px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.table-id {
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
max-height: 41px;
|
||||
}
|
||||
BIN
src/main/resources/static/css/noimage.png
Normal file
BIN
src/main/resources/static/css/noimage.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
src/main/resources/static/drs.jpg
Normal file
BIN
src/main/resources/static/drs.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
8
src/main/resources/static/js/bootstrap-datepicker.min.js
vendored
Normal file
8
src/main/resources/static/js/bootstrap-datepicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/main/resources/static/js/bootstrap-datepicker.zh-CN.min.js
vendored
Normal file
1
src/main/resources/static/js/bootstrap-datepicker.zh-CN.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
!function(a){a.fn.datepicker.dates["zh-CN"]={days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],daysShort:["周日","周一","周二","周三","周四","周五","周六"],daysMin:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],today:"今天",monthsTitle:"选择月份",clear:"清除",format:"yyyy-mm-dd",titleFormat:"yyyy年mm月",weekStart:1}}(jQuery);
|
||||
22
src/main/resources/templates/admin/index.html
Normal file
22
src/main/resources/templates/admin/index.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh"
|
||||
layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<title>Admin</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3>你好</h3>
|
||||
<div>
|
||||
Name: <span sec:authentication="name"></span>
|
||||
<div sec:authorize="hasAuthority('ADMIN')">
|
||||
<p>今は<b>ADMIN</b>権限でログインしています。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
15
src/main/resources/templates/commons/error.html
Normal file
15
src/main/resources/templates/commons/error.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${message}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3 th:text="${message}"></h3>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
48
src/main/resources/templates/commons/pagination.html
Normal file
48
src/main/resources/templates/commons/pagination.html
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<body>
|
||||
|
||||
<!--/*@thymesVar id="page" type="org.springframework.data.domain.Page"*/-->
|
||||
<nav th:fragment="pagination(page)" th:if="${page.totalPages gt 0}">
|
||||
|
||||
<ul class="pagination justify-content-center">
|
||||
<li class="page-item" th:classappend="${page.number eq 0} ? 'disabled'">
|
||||
<a class="page-link"
|
||||
aria-label="上一页"
|
||||
th:href="'?page='+${page.number lt 2 ? 1 : page.number}"
|
||||
>
|
||||
<span aria-hidden="true">«</span>
|
||||
<span class="sr-only">上一页</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item" th:if="${page.number > 1 && page.totalPages > 8}">
|
||||
<a class="page-link" href="?page=1">
|
||||
<span th:text="..."></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"
|
||||
th:each="i : ${#numbers.sequence( page.totalPages > 7 ? ( page.totalPages > 7 + page.number ? ( page.number > 0 ? page.number : 1 ) : page.totalPages - 7 ) : 1 , page.totalPages > 7 + page.number ? ( page.number > 0 ? page.number + 7 : page.number + 8 ) : page.totalPages )}"
|
||||
th:classappend="${i eq page.number + 1} ? 'active'"
|
||||
>
|
||||
<a class="page-link"
|
||||
th:href="'?page=' + ${i}"
|
||||
th:text="${i}"
|
||||
></a>
|
||||
</li>
|
||||
<li class="page-item" th:if="${page.number + 7 < page.totalPages}">
|
||||
<a class="page-link" th:href="'?page=' + ${page.totalPages}">
|
||||
<span th:text="..."></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item" th:classappend="${page.number + 1 eq page.totalPages} ? 'disabled'">
|
||||
<a class="page-link"
|
||||
aria-label="下一页"
|
||||
th:href="'?page=' + ${page.number + 2}">
|
||||
<span aria-hidden="true">»</span>
|
||||
<span class="sr-only">下一页</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</body>
|
||||
</html>
|
||||
50
src/main/resources/templates/company/browser.html
Normal file
50
src/main/resources/templates/company/browser.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>全部厂商</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<h3>全部厂商</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="company:${companyList}" th:object="${company}">
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/company/{id}(id=*{id})}">
|
||||
<img alt="company logo" class="img-thumbnail" th:src="${company.imageUrl == '' ? '/css/noimage.png' : company.imageUrl}">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/company/{id}(id=*{id})}" th:text="*{name}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav th:replace="commons/pagination :: pagination(${page})"></nav>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
43
src/main/resources/templates/company/link.html
Normal file
43
src/main/resources/templates/company/link.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>编辑关联</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 >编辑关联:<span th:text="${company.name}"></span> </h3></div>
|
||||
|
||||
<div class="col col-lg-2 btn-group" role="group">
|
||||
<a class="nav-item btn btn-secondary" href="#">
|
||||
返回
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<form th:action="@{/company/{id}/link(id=${company.id})}" th:method="post">
|
||||
<div class="form-group">
|
||||
<input type="hidden" name="type" value="series">
|
||||
<label class="control-label">系列ID</label>
|
||||
<input class="form-control" type="number" name="target_id">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
<form th:action="@{/company/{id}/link(id=${company.id})}" th:method="post">
|
||||
<div class="form-group">
|
||||
<input type="hidden" name="type" value="game">
|
||||
<label class="control-label">游戏ID</label>
|
||||
<input class="form-control" type="number" name="target_id">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
44
src/main/resources/templates/company/new.html
Normal file
44
src/main/resources/templates/company/new.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加新厂商</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加新厂商</h3>
|
||||
<form th:action="@{/company/new}" th:method="post" th:object="${company}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">名称*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{name}" th:if="${#fields.hasErrors('name')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">图片</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('imageUrl')} ? 'is-invalid'"
|
||||
th:field="*{imageUrl}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{imageUrl}" th:if="${#fields.hasErrors('imageUrl')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">主页链接</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('homePage')} ? 'is-invalid'"
|
||||
th:field="*{homePage}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{homePage}" th:if="${#fields.hasErrors('homePage')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">简介</label>
|
||||
<textarea class="form-control" rows="4"
|
||||
th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'"
|
||||
th:field="*{description}"></textarea>
|
||||
<div class="invalid-feedback" th:errors="*{description}"
|
||||
th:if="${#fields.hasErrors('description')}"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
68
src/main/resources/templates/company/show.html
Normal file
68
src/main/resources/templates/company/show.html
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title th:text="${company.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${company.name}"></h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group" sec:authorize="!isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/company/{id}/edit(id=${company.id})}">
|
||||
编辑条目
|
||||
</a>
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/company/{id}/link(id=${company.id})}">
|
||||
编辑关联
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<img alt="company image" class="card-img-top" th:src="${company.imageUrl == '' ? '/css/noimage.png' : company.imageUrl}">
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">简介</h6>
|
||||
<p class="card-text" th:text="${company.description}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">主页地址: <a th:text="${company.homePage}" th:href="${company.homePage}"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
关联系列
|
||||
</div>
|
||||
<ul class="list-group list-group-flush" th:each="series:${company.series}" th:object="${series}">
|
||||
<li class="list-group-item"><a th:href="@{/series/{id}(id=${series.id})}" th:text="${series.name}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
关联游戏
|
||||
</div>
|
||||
<ul class="list-group list-group-flush" th:each="game:${company.games}" th:object="${game}">
|
||||
<li class="list-group-item"><a th:href="@{/game/{id}(id=${game.id})}" th:text="${game.name}"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
15
src/main/resources/templates/error.html
Normal file
15
src/main/resources/templates/error.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh"
|
||||
layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<title>未找到项目</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3>未找到项目</h3>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
65
src/main/resources/templates/game/browser.html
Normal file
65
src/main/resources/templates/game/browser.html
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>全部游戏</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<h3>全部游戏</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
<th scope="col">发布时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="game:${gameList}" th:object="${game}">
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/game/{id}(id=*{id})}">
|
||||
<img alt="game logo" class="img-thumbnail" th:src="${game.imageUrl == '' ? '/css/noimage.png' : game.imageUrl}">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/game/{id}(id=*{id})}" th:text="*{name}"></a>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav th:replace="commons/pagination :: pagination(${page})"></nav>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
类型
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<a class="btn">音乐类</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-header">
|
||||
发布时间
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<a class="btn">2019年</a>
|
||||
<a class="btn">2018年</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body">
|
||||
<a class="btn" href="/game/new">创建新条目</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
34
src/main/resources/templates/game/link.html
Normal file
34
src/main/resources/templates/game/link.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>编辑关联</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 >编辑关联:<span th:text="${game.name}"></span> </h3></div>
|
||||
|
||||
<div class="col col-lg-2 btn-group" role="group">
|
||||
<a class="nav-item btn btn-secondary" href="#">
|
||||
返回
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<form th:action="@{/game/{id}/link(id=${game.id})}" th:method="post">
|
||||
<div class="form-group">
|
||||
<label class="control-label">系列ID</label>
|
||||
<input class="form-control" type="number" name="series_id">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
49
src/main/resources/templates/game/location.html
Normal file
49
src/main/resources/templates/game/location.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title th:text="${game.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${game.name}">系列名称</h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group">
|
||||
<a class="nav-item btn btn-secondary" href="#">
|
||||
编辑条目
|
||||
</a>
|
||||
<a class="nav-item btn btn-secondary" href="#">
|
||||
编辑关联
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<img src="/drs.jpg" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">简介</h6>
|
||||
<p class="card-text" th:text="${game.description}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">关联系列: <a th:href="'/series/'+${game.series.id}" th:text="${game.series.name}"></a></li>
|
||||
<li class="list-group-item">游戏类型: <span th:text="${game.genre}"></span></li>
|
||||
<li class="list-group-item">制作公司</li>
|
||||
<li class="list-group-item">稼动时间</li>
|
||||
<li class="list-group-item">...</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
44
src/main/resources/templates/game/new.html
Normal file
44
src/main/resources/templates/game/new.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加新游戏</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加新游戏</h3>
|
||||
<form th:action="@{/game/new}" th:method="post" th:object="${game}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">名称*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{name}" th:if="${#fields.hasErrors('name')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">图片</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('imageUrl')} ? 'is-invalid'"
|
||||
th:field="*{imageUrl}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{imageUrl}" th:if="${#fields.hasErrors('imageUrl')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">类别*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('genre')} ? 'is-invalid'"
|
||||
th:field="*{genre}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{genre}" th:if="${#fields.hasErrors('genre')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">简介</label>
|
||||
<textarea class="form-control" rows="4"
|
||||
th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'"
|
||||
th:field="*{description}"></textarea>
|
||||
<div class="invalid-feedback" th:errors="*{description}"
|
||||
th:if="${#fields.hasErrors('description')}"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
67
src/main/resources/templates/game/show.html
Normal file
67
src/main/resources/templates/game/show.html
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${game.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${game.name}"></h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group" sec:authorize="!isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" th:href="@{{id}/edit(id=${game.id})}">
|
||||
编辑条目
|
||||
</a>
|
||||
<a class="nav-item btn btn-secondary" th:href="@{{id}/link(id=${game.id})}">
|
||||
编辑关联
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<img src="/drs.jpg" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">简介</h6>
|
||||
<p class="card-text" th:text="${game.description}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">关联系列: <a th:href="@{/series/{id}(id=${game.series.id})}"
|
||||
th:if="${game.series}"
|
||||
th:text="${game.series.name}"></a></li>
|
||||
<li class="list-group-item">游戏类型: <span th:text="${game.genre.displayName}"></span></li>
|
||||
<li class="list-group-item">制作公司:
|
||||
<span th:switch="${!game.companies.isEmpty()}">
|
||||
<span th:case="true" >
|
||||
<span th:each="company, iterStat : ${game.companies}">
|
||||
<a th:href="@{/company/{id}(id=${company.id})}"
|
||||
th:text="${company.name}"
|
||||
></a>
|
||||
<span th:unless="${iterStat.last}">、</span>
|
||||
</span>
|
||||
</span>
|
||||
<span th:case="false" th:text="未关联"></span>
|
||||
</span>
|
||||
|
||||
</li>
|
||||
<li class="list-group-item">稼动时间: </li>
|
||||
<li class="list-group-item">...</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
50
src/main/resources/templates/hardware/browser.html
Normal file
50
src/main/resources/templates/hardware/browser.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>全部硬件</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<h3>全部硬件</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="hardware:${hardwareList}" th:object="${hardware}">
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/hardware/{id}(id=*{id})}">
|
||||
<img alt="hardware logo" class="img-thumbnail" th:src="${hardware.imageUrl == '' ? '/css/noimage.png' : hardware.imageUrl}">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/hardware/{id}(id=*{id})}" th:text="*{name}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav th:replace="commons/pagination :: pagination(${page})"></nav>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
44
src/main/resources/templates/hardware/new.html
Normal file
44
src/main/resources/templates/hardware/new.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加新硬件</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加新硬件</h3>
|
||||
<form th:action="@{/hardware/new}" th:method="post" th:object="${hardware}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">名称*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{name}" th:if="${#fields.hasErrors('name')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">型号*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('model')} ? 'is-invalid'" type="text" th:field="*{model}">
|
||||
<div class="invalid-feedback" th:errors="*{model}" th:if="${#fields.hasErrors('model')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">图片</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('imageUrl')} ? 'is-invalid'" type="text" th:field="*{imageUrl}">
|
||||
<div class="invalid-feedback" th:errors="*{imageUrl}" th:if="${#fields.hasErrors('imageUrl')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">发布日期</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('releaseDate')} ? 'is-invalid'" type="text" id="releaseDate" th:field="*{releaseDate}">
|
||||
<div class="invalid-feedback" th:errors="*{releaseDate}" th:if="${#fields.hasErrors('releaseDate')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">简介</label>
|
||||
<textarea class="form-control" th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'" th:field="*{description}" rows="4"></textarea>
|
||||
<div class="invalid-feedback" th:errors="*{description}" th:if="${#fields.hasErrors('description')}"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
33
src/main/resources/templates/hardware/show.html
Normal file
33
src/main/resources/templates/hardware/show.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${hardware.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3 th:text="${hardware.name}"></h3>
|
||||
<h5 th:text="${hardware.model}"></h5>
|
||||
<p th:text="${hardware.description}"></p>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
关联系列
|
||||
</div>
|
||||
<ul class="list-group list-group-flush" th:each="series:${hardware.series}" th:object="${series}">
|
||||
<li class="list-group-item"><a th:href="@{/series/{id}(id=${series.id})}" th:text="${series.name}"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
关联游戏
|
||||
</div>
|
||||
<ul class="list-group list-group-flush" th:each="game:${hardware.games}" th:object="${game}">
|
||||
<li class="list-group-item"><a th:href="@{/game/{id}(id=${game.id})}" th:text="${game.name}"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
22
src/main/resources/templates/index.html
Normal file
22
src/main/resources/templates/index.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh"
|
||||
layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<title>登录</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3>你好</h3>
|
||||
<div>
|
||||
Name: <span sec:authentication="name"></span>
|
||||
<div sec:authorize="hasAuthority('USER')">
|
||||
<p>今は<b>USER</b>権限でログインしています。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
127
src/main/resources/templates/layout.html
Normal file
127
src/main/resources/templates/layout.html
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title layout:title-pattern="$CONTENT_TITLE - $LAYOUT_TITLE">Arcade DB</title>
|
||||
<link rel="stylesheet" th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.min.css}"/>
|
||||
<script th:src="@{/webjars/jquery/3.4.1/jquery.min.js}" type="text/javascript"></script>
|
||||
<script th:src="@{/webjars/bootstrap/4.3.1/js/bootstrap.min.js}" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="/css/common.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark bg-dark shadow" style="margin-bottom: 32px;">
|
||||
<a class="navbar-brand" href="#">Arcade DB</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="gameDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
游戏
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="gameDropdown">
|
||||
<a class="dropdown-item" href="/game/browser">所有</a>
|
||||
<a class="dropdown-item" href="#">分类浏览</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/game/new">创建条目</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="seriesDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
系列
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="seriesDropdown">
|
||||
<a class="dropdown-item" href="/series/browser">所有</a>
|
||||
<a class="dropdown-item" href="#">分类浏览</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/series/new">创建条目</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="hardwareDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
硬件
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="hardwareDropdown">
|
||||
<a class="dropdown-item" href="/hardware/browser">所有</a>
|
||||
<a class="dropdown-item" href="#">分类浏览</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/hardware/new">创建条目</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="companyDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
厂商
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="companyDropdown">
|
||||
<a class="dropdown-item" href="/company/browser">所有</a>
|
||||
<a class="dropdown-item" href="#">分类浏览</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/company/new">创建条目</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="locationDropdown" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
街机厅
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="locationDropdown">
|
||||
<a class="dropdown-item" href="/location/browser">所有</a>
|
||||
<a class="dropdown-item" href="#">分类浏览</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/location/new">创建条目</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="form-inline my mr-md-4 mb-md-auto mb-sm-2">
|
||||
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-light my-2 my-sm-0" type="submit">搜索</button>
|
||||
</form>
|
||||
<div aria-label="登录注册按键组" class="navbar-nav btn-group" role="group" sec:authorize="isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" href="/login">
|
||||
登录
|
||||
</a>
|
||||
<a class="nav-item btn btn-secondary" href="/registration">
|
||||
注册
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-nav btn-group" sec:authorize="!isAnonymous()">
|
||||
<button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" type="button">
|
||||
<span sec:authentication="name"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<form method="POST" name="logout" th:action="@{/logout}">
|
||||
<a class="dropdown-item" href="javascript:logout.submit()">登出</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
</header>
|
||||
<main class="container">
|
||||
<div layout:fragment="content">
|
||||
<p>Page content goes here</p>
|
||||
</div>
|
||||
</main>
|
||||
<footer th:fragment="footer">
|
||||
|
||||
</footer>
|
||||
<footer class="footer mt-auto py-3">
|
||||
<div class="container">
|
||||
<span class="text-muted">© 2019 Arcade DB</span>
|
||||
</div>
|
||||
</footer>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
50
src/main/resources/templates/location/browser.html
Normal file
50
src/main/resources/templates/location/browser.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>全部街机厅</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<h3>全部街机厅</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="location:${locationList}" th:object="${location}">
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/location/{id}(id=*{id})}">
|
||||
<img alt="location logo" class="img-thumbnail" th:src="${location.imageUrl == '' ? '/css/noimage.png' : location.imageUrl}">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/location/{id}(id=*{id})}" th:text="*{name}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav th:replace="commons/pagination :: pagination(${page})"></nav>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
54
src/main/resources/templates/location/cabinet/add.html
Normal file
54
src/main/resources/templates/location/cabinet/add.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加机台</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加机台</h3>
|
||||
<form th:action="@{/location/{id}/cabinet/add(id=${location.id})}" th:method="post" th:object="${cabinet}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">所属机厅*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('location.id')} ? 'is-invalid'"
|
||||
th:field="*{location.id}" type="number" th:value="${location.id}" readonly>
|
||||
<div class="invalid-feedback" th:errors="*{location}" th:if="${#fields.hasErrors('location')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">游戏ID</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('game.id')} ? 'is-invalid'"
|
||||
th:field="*{game.id}" type="number">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">框体ID</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('hardware.id')} ? 'is-invalid'"
|
||||
th:field="*{hardware.id}" type="number">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">价格</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('price')} ? 'is-invalid'"
|
||||
th:field="*{price}" type="number">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">备注</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('remark')} ? 'is-invalid'"
|
||||
th:field="*{remark}" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">机况</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('condition')} ? 'is-invalid'"
|
||||
th:field="*{condition}" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">描述</label>
|
||||
<textarea class="form-control" th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'"
|
||||
th:field="*{description}" rows="4"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
53
src/main/resources/templates/location/cabinet/list.html
Normal file
53
src/main/resources/templates/location/cabinet/list.html
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${location.name}+' 机台列表'"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${location.name}+' 机台列表'"></h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group" sec:authorize="!isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/location/{locationId}/cabinet/add(locationId=${location.id})}">
|
||||
添加机台
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
<th scope="col">价格</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="cabinet:${location.cabinets}" th:object="${cabinet}">
|
||||
</th>
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/location/{locationId}/cabinet/{id}(locationId=${location.id},id=*{id})}">
|
||||
<img alt="game logo" class="img-thumbnail" src="/drs.jpg">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/location/{locationId}/cabinet/{id}(locationId=${location.id},id=*{id})}" th:text="*{game.name}"></a>
|
||||
</td>
|
||||
<td>
|
||||
<span th:text="*{price}"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
41
src/main/resources/templates/location/cabinet/show.html
Normal file
41
src/main/resources/templates/location/cabinet/show.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${cabinet.game.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${cabinet.game.name}"></h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group" sec:authorize="!isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/location/{locationId}/cabinet/{cabinetId}/edit(locationId=${locationId},cabinetId=${cabinet.id})}">
|
||||
编辑条目
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">游戏: <a th:text="${cabinet.game.name}" th:href="@{/game/{id}(id=${cabinet.game.id})}"></a></li>
|
||||
<li class="list-group-item">框体: <a th:text="${cabinet.hardware.name}+' '+${cabinet.hardware.model}" th:href="@{/hardware/{id}(id=${cabinet.hardware.id})}"></a></li>
|
||||
<li class="list-group-item">备注: <span th:text="${cabinet.remark}"></span></li>
|
||||
<li class="list-group-item">价格: <span th:text="${cabinet.price}"></span>币</li>
|
||||
<li class="list-group-item">机况: <span th:text="${cabinet.condition}"></span></li>
|
||||
<li class="list-group-item">描述: <span th:text="${cabinet.description}"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
54
src/main/resources/templates/location/new.html
Normal file
54
src/main/resources/templates/location/new.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加新街机厅</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加新街机厅</h3>
|
||||
<form th:action="@{/location/new}" th:method="post" th:object="${location}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">名称*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{name}" th:if="${#fields.hasErrors('name')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">图片</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('imageUrl')} ? 'is-invalid'"
|
||||
th:field="*{imageUrl}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{imageUrl}" th:if="${#fields.hasErrors('imageUrl')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">地址*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('address')} ? 'is-invalid'"
|
||||
th:field="*{address}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{address}" th:if="${#fields.hasErrors('address')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">网站</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('website')} ? 'is-invalid'"
|
||||
th:field="*{website}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{website}" th:if="${#fields.hasErrors('website')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">联系方式</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('contact')} ? 'is-invalid'"
|
||||
th:field="*{contact}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{contact}" th:if="${#fields.hasErrors('contact')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">简介</label>
|
||||
<textarea class="form-control" th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'"
|
||||
th:field="*{description}" rows="4"></textarea>
|
||||
<div class="invalid-feedback" th:errors="*{description}" th:if="${#fields.hasErrors('description')}"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
112
src/main/resources/templates/location/show.html
Normal file
112
src/main/resources/templates/location/show.html
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title th:text="${location.name}"></title>
|
||||
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=6DGBZ-MGSWU-P4UVD-4MAWX-6ADZS-JEBR5"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 th:text="${location.name}"></h3></div>
|
||||
|
||||
<div class="col col-lg-3 btn-group" role="group" sec:authorize="!isAnonymous()">
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/location/{id}/edit(id=${location.id})}">
|
||||
编辑条目
|
||||
</a>
|
||||
<a class="nav-item btn btn-secondary" th:href="@{/location/{id}/link(id=${location.id})}">
|
||||
编辑关联
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<img alt="..." class="card-img-top" th:src="${location.imageUrl == '' ? '' : location.imageUrl}">
|
||||
<div class="card-body">
|
||||
<h6 class="card-subtitle mb-2 text-muted">简介</h6>
|
||||
<p class="card-text" th:text="${location.description}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">地址: <span th:text="${location.address}"></span></li>
|
||||
<li class="list-group-item">状态: <span th:text="${location.status.displayName}"></span></li>
|
||||
<li class="list-group-item">开放时间: <span th:text="${location.workTime}"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
地图
|
||||
</div>
|
||||
<div id="map_container" style="width: 100%;height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="mr-auto">机台列表</span>
|
||||
<a th:href="@{/location/{id}/cabinet(id=${location.id})}" style="float:right;">查看全部</a>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item" th:each="cabinet:${location.cabinets}" th:object="${cabinet}">
|
||||
<span th:text="*{game.name}"></span> <span th:text="*{price+'币'}"></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
<script layout:fragment="script" th:inline="javascript">
|
||||
var unicodeUnescape = function(str) {
|
||||
var result = '', strs = str.match(/\\u.{4}/ig);
|
||||
if (!strs) return '';
|
||||
for (var i = 0, len = strs.length; i < len; i++) {
|
||||
result += String.fromCharCode(strs[i].replace('\\u', '0x'));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/*<![CDATA[*/
|
||||
const latitude = /*[[${location.latitude}]]*/ 0.0;
|
||||
const longitude = /*[[${location.longitude}]]*/ 0.0;
|
||||
let address = /*[[${location.address}]]*/ '';
|
||||
// address = unicodeUnescape(address);
|
||||
/*]]>*/
|
||||
|
||||
let callback = {
|
||||
complete: function init(result) {
|
||||
let map = new qq.maps.Map(document.getElementById("map_container"), {
|
||||
center: result.detail.location,
|
||||
zoom:15
|
||||
});
|
||||
let marker = new qq.maps.Marker({
|
||||
position: result.detail.location,
|
||||
map: map
|
||||
});
|
||||
}
|
||||
};
|
||||
window.onload = function(){
|
||||
let geocoder = new qq.maps.Geocoder(callback);
|
||||
geocoder.getLocation(address);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
35
src/main/resources/templates/login.html
Normal file
35
src/main/resources/templates/login.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>登录</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3>登录</h3>
|
||||
<div th:if="${param.error}">
|
||||
<div class="alert alert-danger">
|
||||
用户名或密码错误.
|
||||
</div>
|
||||
</div>
|
||||
<div th:if="${param.logout}">
|
||||
<div class="alert alert-info">
|
||||
成功退出登录.
|
||||
</div>
|
||||
</div>
|
||||
<form th:action="@{/login}" th:method="post">
|
||||
<div class="form-group">
|
||||
<label class="control-label">用户名</label>
|
||||
<input class="form-control" name="username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">密码</label>
|
||||
<input class="form-control" name="password" type="password">
|
||||
</div>
|
||||
<button class="btn btn-outline-dark btn-block" type="submit">登录</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
43
src/main/resources/templates/registration.html
Normal file
43
src/main/resources/templates/registration.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>注册</title>
|
||||
</head>
|
||||
<body>
|
||||
<section class="row" layout:fragment="content">
|
||||
<div class="col-md-8">
|
||||
<h3>注册</h3>
|
||||
<form th:action="@{/registration}" th:method="post" th:object="${user}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">邮箱</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'"
|
||||
th:field="*{email}" type="email">
|
||||
<div class="invalid-feedback" th:errors="*{email}" th:if="${#fields.hasErrors('email')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">用户名</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('username')} ? 'is-invalid'"
|
||||
th:field="*{username}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{username}" th:if="${#fields.hasErrors('username')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">密码</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('password')} ? 'is-invalid'"
|
||||
th:field="*{password}" type="password">
|
||||
|
||||
<div class="invalid-feedback" th:errors="*{password}" th:if="${#fields.hasErrors('password')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">确认密码</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('passwordConfirm')} ? 'is-invalid'"
|
||||
th:field="*{passwordConfirm}" type="password">
|
||||
<div class="invalid-feedback" th:errors="*{passwordConfirm}"
|
||||
th:if="${#fields.hasErrors('passwordConfirm')}"></div>
|
||||
</div>
|
||||
<button class="btn btn-outline-dark btn-block" type="submit">注册</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
65
src/main/resources/templates/series/browser.html
Normal file
65
src/main/resources/templates/series/browser.html
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>全部系列</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<h3>全部系列</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">图片</th>
|
||||
<th scope="col">名称</th>
|
||||
<th scope="col">发布时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="series:${seriesList}" th:object="${series}">
|
||||
<td class="table-img">
|
||||
<a class="" th:href="@{/series/{id}(id=*{id})}">
|
||||
<img alt="series logo" class="img-thumbnail" th:src="${series.imageUrl == '' ? '/css/noimage.png' : series.imageUrl}">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a th:href="@{/series/{id}(id=*{id})}" th:text="*{name}"></a>
|
||||
</td>
|
||||
<td th:text="*{firstReleaseDate}">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<nav th:replace="commons/pagination :: pagination(${page})"></nav>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
类型
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<a class="btn">音乐类</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-header">
|
||||
发布时间
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<a class="btn">2019年</a>
|
||||
<a class="btn">2018年</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body">
|
||||
<a class="btn" href="/series/new">创建新条目</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
34
src/main/resources/templates/series/link.html
Normal file
34
src/main/resources/templates/series/link.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>编辑关联</title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" >
|
||||
<div class="row content-header">
|
||||
<div class="col"><h3 >编辑关联:<span th:text="${series.name}"></span> </h3></div>
|
||||
|
||||
<div class="col col-lg-2 btn-group" role="group">
|
||||
<a class="nav-item btn btn-secondary" href="#">
|
||||
返回
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<form th:action="@{/series/{id}/link(id=${series.id})}" th:method="post">
|
||||
<div class="form-group">
|
||||
<label class="control-label">游戏ID</label>
|
||||
<input class="form-control" type="number" name="game_id">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
52
src/main/resources/templates/series/new.html
Normal file
52
src/main/resources/templates/series/new.html
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title>添加新系列</title>
|
||||
<link rel="stylesheet" href="/css/bootstrap-datepicker.min.css"/>
|
||||
<script src="/js/bootstrap-datepicker.min.js"></script>
|
||||
<script src="/js/bootstrap-datepicker.zh-CN.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content" class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>添加新系列</h3>
|
||||
<form th:action="@{/series/new}" th:method="post" th:object="${series}">
|
||||
<div class="form-group">
|
||||
<label class="control-label">名称*</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{name}" th:if="${#fields.hasErrors('name')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">图片</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('imageUrl')} ? 'is-invalid'"
|
||||
th:field="*{imageUrl}" type="text">
|
||||
<div class="invalid-feedback" th:errors="*{imageUrl}" th:if="${#fields.hasErrors('imageUrl')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">发布日期</label>
|
||||
<input class="form-control" th:classappend="${#fields.hasErrors('firstReleaseDate')} ? 'is-invalid'"
|
||||
th:field="*{firstReleaseDate}" type="text" id="firstReleaseDate">
|
||||
<div class="invalid-feedback" th:errors="*{firstReleaseDate}" th:if="${#fields.hasErrors('firstReleaseDate')}"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">简介</label>
|
||||
<textarea class="form-control" th:classappend="${#fields.hasErrors('description')} ? 'is-invalid'"
|
||||
th:field="*{description}" rows="4"></textarea>
|
||||
<div class="invalid-feedback" th:errors="*{description}" th:if="${#fields.hasErrors('description')}"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-outline-dark btn-block">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
<script layout:fragment="script">
|
||||
$('#firstReleaseDate').datepicker({
|
||||
format: "yyyy-mm-dd",
|
||||
todayBtn: "linked",
|
||||
language: "zh-CN",
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
43
src/main/resources/templates/series/show.html
Normal file
43
src/main/resources/templates/series/show.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
|
||||
<head>
|
||||
<title th:text="${series.name}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<section layout:fragment="content">
|
||||
<h3 th:text="${series.name}">系列名称</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="card">
|
||||
<img alt="company image" class="card-img-top" th:src="${series.imageUrl == '' ? '/css/noimage.png' : series.imageUrl}">
|
||||
<div class="card-body">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Info
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">简介: <span th:text="${series.description}"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
关联游戏
|
||||
</div>
|
||||
<ul class="list-group list-group-flush" th:each="game:${series.games}" th:object="${game}">
|
||||
<li class="list-group-item"><a th:href="@{/game/{id}(id=${game.id})}" th:text="${game.name}"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package cn.samnya.arcadedbserver;
|
||||
|
||||
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 ArcadeDbServerApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package cn.samnya.arcadedbserver.dao;
|
||||
|
||||
import cn.samnya.arcadedbserver.model.arcade.Series;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author sam_nya (samnya@outlook.com)
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SeriesRepositoryTests {
|
||||
|
||||
@Autowired
|
||||
SeriesRepository seriesRepository;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTableAuto(){
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpringDataFindId(){
|
||||
Optional<Series> series = seriesRepository.findById((long) 1);
|
||||
System.out.println(series);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user