移植原始版本
This commit is contained in:
parent
70798c5e94
commit
5d5a4eef97
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
118
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
118
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2007-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
private static final String WRAPPER_VERSION = "0.5.6";
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if (mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||
String username = System.getenv("MVNW_USERNAME");
|
||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
}
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
BIN
.mvn/wrapper/maven-wrapper.jar
vendored
Normal file
Binary file not shown.
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
2
.mvn/wrapper/maven-wrapper.properties
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
BIN
libmsc32.so
Normal file
BIN
libmsc32.so
Normal file
Binary file not shown.
BIN
libmsc64.so
Normal file
BIN
libmsc64.so
Normal file
Binary file not shown.
BIN
libs/Msc.jar
Normal file
BIN
libs/Msc.jar
Normal file
Binary file not shown.
BIN
libs/json-jena-1.0.jar
Normal file
BIN
libs/json-jena-1.0.jar
Normal file
Binary file not shown.
310
mvnw
vendored
Normal file
310
mvnw
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
182
mvnw.cmd
vendored
Normal file
182
mvnw.cmd
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
183
pom.xml
Normal file
183
pom.xml
Normal file
@ -0,0 +1,183 @@
|
||||
<?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.4.4</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.yutou</groupId>
|
||||
<artifactId>nas</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<name>nas</name>
|
||||
<description>NAS Service</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<kotlin.version>1.4.10</kotlin.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jaudiotagger-repository</id>
|
||||
<url>https://dl.bintray.com/ijabz/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<url>https://jcenter.bintray.com/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>3.6.0-RC1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
<version>2.4.7</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.67</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
||||
<dependency>
|
||||
<groupId>com.jcraft</groupId>
|
||||
<artifactId>jsch</artifactId>
|
||||
<version>0.1.55</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.jthink</groupId>
|
||||
<artifactId>jaudiotagger</artifactId>
|
||||
<version>2.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ealva</groupId>
|
||||
<artifactId>ealvatag</artifactId>
|
||||
<version>0.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.mamoe</groupId>
|
||||
<artifactId>mirai-core-jvm</artifactId>
|
||||
<version>2.5.0</version> <!-- 替换版本为你需要的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bramp.ffmpeg</groupId>
|
||||
<artifactId>ffmpeg</artifactId>
|
||||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iflytek</groupId>
|
||||
<artifactId>msc</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/Msc.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iflytek</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/json-jena-1.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<!-- <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>libs</directory>
|
||||
<targetPath>/BOOT-INF/lib/</targetPath>
|
||||
<includes>
|
||||
<include>**/*.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
215
src/main/java/com/yutou/nas/Controllers/MusicController.java
Normal file
215
src/main/java/com/yutou/nas/Controllers/MusicController.java
Normal file
@ -0,0 +1,215 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.mybatis.model.MusicData;
|
||||
import com.yutou.nas.utils.ConfigTools;
|
||||
import com.yutou.nas.utils.MusicToolsServiceImpl;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import static com.yutou.nas.Datas.AppData.defaultMusicPath;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/nas/music/")
|
||||
public class MusicController {
|
||||
|
||||
@Resource
|
||||
MusicToolsServiceImpl musicTools;
|
||||
|
||||
@RequestMapping("all.do")
|
||||
@ResponseBody
|
||||
public String getAllMusicList() {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject data = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("scan", musicTools.isScan());
|
||||
json.put("size", musicTools.getLength());
|
||||
json.put("data", JSONArray.toJSON(musicTools.getMusicList()));
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("list.do")
|
||||
@ResponseBody
|
||||
public String getMusicListOfPath(@RequestBody JSONObject body) {
|
||||
String path = body.getString("path");
|
||||
boolean type = body.containsKey("type") ? body.getBoolean("type") : false;
|
||||
System.out.println("接收到地址:" + path);
|
||||
if (StringUtils.isEmpty(path)
|
||||
|| path.equals("root")
|
||||
|| !path.contains(defaultMusicPath)
|
||||
) {
|
||||
path = defaultMusicPath;
|
||||
}
|
||||
|
||||
//path=path.replace(defaultMusicPath+File.separator,"");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("scan", musicTools.isScan());
|
||||
json.put("size", musicTools.getLength());
|
||||
json.put("data", JSONArray.toJSON(musicTools.getPath(path, type)));
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("getAlbum.do")
|
||||
public String getAlbum(@RequestBody JSONObject body) {
|
||||
String album = body.getString("album");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
if (StringUtils.isEmpty(album)) {
|
||||
json.put("data", JSONArray.toJSON(musicTools.getAllAlbum()));
|
||||
} else {
|
||||
json.put("data", JSONArray.toJSON(musicTools.selectAlbum(album)));
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("getArtist.do")
|
||||
public String getArtist(@RequestBody JSONObject body) {
|
||||
String artist = body.getString("artist");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
if (StringUtils.isEmpty(artist)) {
|
||||
json.put("data", JSONArray.toJSON(musicTools.getAllArtist()));
|
||||
} else {
|
||||
json.put("data", JSONArray.toJSON(musicTools.selectArtist(artist)));
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("reload.do")
|
||||
@ResponseBody
|
||||
public String reload() {
|
||||
JSONObject json = new JSONObject();
|
||||
musicTools.scanMusic();
|
||||
json.put("msg", "ok");
|
||||
json.put("code", 0);
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("find/file.do")
|
||||
@ResponseBody
|
||||
public String findFile(@RequestBody JSONObject body) {
|
||||
String path = body.getString("path");
|
||||
if (!path.startsWith(defaultMusicPath)) {
|
||||
path = Tools.base64ToString(path);
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
if (StringUtils.isEmpty(path)) {
|
||||
json.put("code", -1);
|
||||
json.put("msg", "地址为空");
|
||||
return json.toJSONString();
|
||||
}
|
||||
json.put("code", 0);
|
||||
json.put("data", musicTools.getMusicData(path));
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("getlocalhost.do")
|
||||
@ResponseBody
|
||||
public String getLocalHost() {
|
||||
JSONObject json = new JSONObject();
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
|
||||
json.put("data", "");
|
||||
} else {
|
||||
json.put("data", "http://" + UpdateIp.nas_ip);
|
||||
}
|
||||
json.put("code", 0);
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "web/image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||
@ResponseBody
|
||||
public byte[] getImage(String fileName, String type) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("fileName", fileName);
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
json.put("type", "file");
|
||||
} else {
|
||||
json.put("type", type);
|
||||
}
|
||||
return getImage(json);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "image.do", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||
@ResponseBody
|
||||
public byte[] getImage(@RequestBody JSONObject body) {
|
||||
String fileName = body.getString("fileName");
|
||||
if (!fileName.startsWith(defaultMusicPath)) {
|
||||
fileName = Tools.base64ToString(fileName);
|
||||
}
|
||||
List<MusicData> list = null;
|
||||
if (body.getString("type").equals("album")) {
|
||||
list = musicTools.selectAlbum(fileName);
|
||||
}
|
||||
File file;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
fileName = list.get(0).getFile();
|
||||
}
|
||||
file = new File(fileName);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return musicTools.readImage(file.getAbsolutePath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping("random.do")
|
||||
@ResponseBody
|
||||
public String random() {
|
||||
List<MusicData> list = musicTools.getMusicList();
|
||||
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
try {
|
||||
json.put("data", URLEncoder.encode(getBase64(data.getFile()), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
private String getBase64(String str) {
|
||||
return new String(Base64.getEncoder().encode(str.getBytes()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("play.do")
|
||||
public ResponseEntity<FileSystemResource> play(String filePath, String random) {
|
||||
String _filePath;
|
||||
boolean _random;
|
||||
_random = !StringUtils.isEmpty(random) && random.equals("true");
|
||||
_filePath = Tools.base64ToString(filePath);
|
||||
if (_random) {
|
||||
List<MusicData> list = musicTools.getMusicList();
|
||||
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
|
||||
_filePath = data.getFile();
|
||||
}
|
||||
File file = new File(_filePath);
|
||||
if (file.exists()) {
|
||||
return Tools.getFile(file);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.mybatis.dao.MusicDataDao;
|
||||
import com.yutou.nas.mybatis.dao.MusicFavoritesDao;
|
||||
import com.yutou.nas.mybatis.dao.MusicFavoritesDirDao;
|
||||
import com.yutou.nas.mybatis.model.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏夹相关
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/nas/music/favorite/")
|
||||
public class MusicFavoritesController {
|
||||
@Resource
|
||||
MusicFavoritesDao favoritesDao;
|
||||
@Resource
|
||||
MusicFavoritesDirDao favoritesDirDao;
|
||||
@Resource
|
||||
MusicDataDao musicDataDao;
|
||||
|
||||
@RequestMapping("dir/add.do")
|
||||
@ResponseBody
|
||||
public String addFavoriteDir(@RequestBody JSONObject body) {
|
||||
String favorite = body.getString("favorite");
|
||||
JSONObject json = new JSONObject();
|
||||
MusicFavoritesDirExample example = new MusicFavoritesDirExample();
|
||||
example.createCriteria().andTitleEqualTo(favorite);
|
||||
if (!favoritesDirDao.selectByExample(example).isEmpty()) {
|
||||
json.put("code", -1);
|
||||
json.put("msg", "已有该收藏夹");
|
||||
} else {
|
||||
MusicFavoritesDir favoritesDir = new MusicFavoritesDir();
|
||||
favoritesDir.setTitle(favorite);
|
||||
int ret = favoritesDirDao.insert(favoritesDir);
|
||||
json.put("code", ret == 0 ? -1 : 0);
|
||||
json.put("msg", ret == 0 ? "添加失败" : "添加成功");
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("dir/list.do")
|
||||
@ResponseBody
|
||||
public String getAllFavoriteDir() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
List<MusicFavoritesDir> list = favoritesDirDao.selectByExample(new MusicFavoritesDirExample());
|
||||
JSONArray array = new JSONArray();
|
||||
for (MusicFavoritesDir favoritesDir : list) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("id", favoritesDir.getId());
|
||||
data.put("title", favoritesDir.getTitle());
|
||||
MusicFavoritesExample example = new MusicFavoritesExample();
|
||||
example.createCriteria().andFavoriteidEqualTo(favoritesDir.getId());
|
||||
data.put("count", favoritesDao.countByExample(example));
|
||||
array.add(data);
|
||||
}
|
||||
json.put("data", array);
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("dir/rename.do")
|
||||
@ResponseBody
|
||||
public String renameFavoriteDir(@RequestBody JSONObject body) {
|
||||
int id = body.getInteger("id");
|
||||
String title = body.getString("title");
|
||||
JSONObject json = new JSONObject();
|
||||
MusicFavoritesDir favoritesDir = favoritesDirDao.selectByPrimaryKey(id);
|
||||
if (favoritesDir == null) {
|
||||
json.put("code", -1);
|
||||
json.put("msg", "没有该收藏夹");
|
||||
} else {
|
||||
favoritesDir.setTitle(title);
|
||||
favoritesDirDao.updateByPrimaryKey(favoritesDir);
|
||||
json.put("code", 0);
|
||||
json.put("msg", "更新成功");
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("add.do")
|
||||
@ResponseBody
|
||||
public String addFavorite(@RequestBody JSONObject body) {
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray array = body.getJSONArray("md5s");
|
||||
int fid = body.getInteger("fid");
|
||||
if (array == null || fid == -1) {
|
||||
json.put("code", -1);
|
||||
json.put("msg", "参数异常: " + body);
|
||||
return json.toJSONString();
|
||||
}
|
||||
for (Object md5 : array) {
|
||||
MusicFavoritesExample example = new MusicFavoritesExample();
|
||||
example.createCriteria().andMusisMd5EqualTo((String) md5);
|
||||
if (favoritesDao.countByExample(example) == 0) {
|
||||
MusicFavorites favorites = new MusicFavorites();
|
||||
favorites.setMusisMd5((String) md5);
|
||||
favorites.setFavoriteid(fid);
|
||||
favorites.setSubTime(new Date());
|
||||
favoritesDao.insert(favorites);
|
||||
}
|
||||
}
|
||||
json.put("code", 0);
|
||||
json.put("msg", "添加成功");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("remove.do")
|
||||
@ResponseBody
|
||||
public String removeFavorite(@RequestBody JSONObject body) {
|
||||
JSONArray md5s = body.getJSONArray("data");
|
||||
JSONObject json = new JSONObject();
|
||||
for (Object md5 : md5s) {
|
||||
LinkedHashMap<String,Object> js= (LinkedHashMap<String, Object>) md5;
|
||||
MusicFavoritesExample example = new MusicFavoritesExample();
|
||||
example.createCriteria().andMusisMd5EqualTo((String) js.get("md5"))
|
||||
.andFavoriteidEqualTo((Integer) js.get("fid"));
|
||||
favoritesDao.deleteByExample(example);
|
||||
}
|
||||
json.put("code", 0);
|
||||
json.put("msg", "已从收藏夹中移除");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@RequestMapping("get.do")
|
||||
@ResponseBody
|
||||
public String getFavorite(@RequestBody JSONObject body) {
|
||||
int fid = body.getInteger("fid");
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
MusicFavoritesExample example = new MusicFavoritesExample();
|
||||
example.createCriteria().andFavoriteidEqualTo(fid);
|
||||
List<MusicFavorites> list = favoritesDao.selectByExample(example);
|
||||
List<MusicData> dataList = new ArrayList<>();
|
||||
for (MusicFavorites favorites : list) {
|
||||
MusicDataExample dataExample = new MusicDataExample();
|
||||
dataExample.createCriteria().andMd5EqualTo(favorites.getMusisMd5());
|
||||
try {
|
||||
dataList.add(musicDataDao.selectByExample(dataExample).get(0));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
list.clear();
|
||||
json.put("code", 0);
|
||||
json.put("data", JSONArray.toJSON(dataList));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
json.put("code", -1);
|
||||
json.put("msg", e.getLocalizedMessage());
|
||||
json.put("data", new ArrayList<>());
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
}
|
79
src/main/java/com/yutou/nas/Controllers/QQBot.java
Normal file
79
src/main/java/com/yutou/nas/Controllers/QQBot.java
Normal file
@ -0,0 +1,79 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.interfaces.DownloadInterface;
|
||||
import com.yutou.nas.utils.QQBotManager;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/qq/bot")
|
||||
public class QQBot {
|
||||
@RequestMapping("test.do")
|
||||
@ResponseBody
|
||||
public String test(){
|
||||
return "123";
|
||||
}
|
||||
|
||||
@RequestMapping("send.do")
|
||||
@ResponseBody
|
||||
public String send(String msg,String imgUrl){
|
||||
JSONObject json=new JSONObject();
|
||||
try {
|
||||
String ret;
|
||||
if(StringUtils.isEmpty(imgUrl)){
|
||||
ret= QQBotManager.getInstance().sendMessage(msg);
|
||||
}else{
|
||||
Tools.download(imgUrl, new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(String file) {
|
||||
super.onDownload(file);
|
||||
QQBotManager.getInstance().sendMessage(new File(file),msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
super.onError(e);
|
||||
QQBotManager.getInstance().sendMessage(imgUrl+"\n"+msg);
|
||||
}
|
||||
});
|
||||
ret="图片下载中";
|
||||
}
|
||||
json.put("code",0);
|
||||
json.put("msg",ret);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
json.put("code",-1);
|
||||
json.put("msg",e.getMessage());
|
||||
}
|
||||
return json.toJSONString();
|
||||
}
|
||||
@RequestMapping("sendAndImg.do")
|
||||
@ResponseBody
|
||||
public String botMsg(String msg,@RequestParam("file") MultipartFile file){
|
||||
JSONObject json=new JSONObject();
|
||||
if(file==null){
|
||||
json.put("code",-1);
|
||||
json.put("msg","图片为空");
|
||||
return json.toJSONString();
|
||||
}
|
||||
String ret;
|
||||
try {
|
||||
String path = Tools.createFile("qq_image",file, file.getName());
|
||||
ret=QQBotManager.getInstance().sendMessage(new File(path),msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret=e.getLocalizedMessage();
|
||||
}
|
||||
json.put("code",0);
|
||||
json.put("msg",ret);
|
||||
return json.toJSONString();
|
||||
}
|
||||
}
|
44
src/main/java/com/yutou/nas/Controllers/ToolsController.java
Normal file
44
src/main/java/com/yutou/nas/Controllers/ToolsController.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.yutou.nas.utils.HttpTools;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@Controller
|
||||
public class ToolsController {
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/openpc.do")
|
||||
public String open_pc(HttpServletRequest request, String type) {
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
if (Tools.checkWebLogin(request) == 1) {
|
||||
HttpTools.get("http://" + UpdateIp.nas_ip + ":8000/tools/openpc.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor&type=nas");
|
||||
}
|
||||
} else {
|
||||
if (type.equals("nas")) {
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("wakeonlan 00:D8:61:6F:02:2F");
|
||||
RedisTools.processOut(process.getInputStream());
|
||||
RedisTools.processOut(process.getErrorStream());
|
||||
process.destroy();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/tools/server.do")
|
||||
public String sendServerManager(String title, String msg) {
|
||||
Tools.sendServer(title, msg);
|
||||
return "ok";
|
||||
}
|
||||
}
|
139
src/main/java/com/yutou/nas/Controllers/UpdateIp.java
Normal file
139
src/main/java/com/yutou/nas/Controllers/UpdateIp.java
Normal file
@ -0,0 +1,139 @@
|
||||
package com.yutou.nas.Controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Controller
|
||||
public class UpdateIp {
|
||||
private static List<String> keys = new ArrayList<>();
|
||||
public static String nas_ip=null;
|
||||
/* static {
|
||||
keys.add("nas.yutou233.cn;");
|
||||
keys.add("bt.yutou233.cn;");
|
||||
keys.add("samba445-server");
|
||||
keys.add("samba139-server");
|
||||
keys.add("nas-ssh-server");
|
||||
keys.add("nas-ftp-server");
|
||||
}*/
|
||||
|
||||
|
||||
@RequestMapping("/nas/updateip.do")
|
||||
public void updateIp(String ip) {
|
||||
|
||||
updateList();
|
||||
File file = new File("/etc/nginx/nginx.conf");
|
||||
if (file.exists()) {
|
||||
System.out.println("文件存在,修改 ip>" + ip);
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
String line = null;
|
||||
boolean isIp = false;
|
||||
boolean isNas=false;
|
||||
nas_ip=ip;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
//System.out.println(line.trim().replace("server_name","").replace("upstream","").trim());
|
||||
if (keys.contains(line.trim().replace("server_name", "").replace("upstream", "").replace("{", "").trim())) {
|
||||
isIp = true;
|
||||
}
|
||||
if(line.trim().replace("server_name", "").trim().equals("nas.yutou233.cn;")){
|
||||
isNas=true;
|
||||
}
|
||||
if (isIp) {
|
||||
String testIp = testIp(line);
|
||||
if (testIp != null) {
|
||||
System.out.println("检测到目标:" + line + " 修改IP " + testIp + " > " + ip);
|
||||
if(isNas){
|
||||
String adminAddress= RedisTools.get("adminAddress");
|
||||
if(adminAddress!=null) {
|
||||
JSONObject json=JSONObject.parseObject(adminAddress);
|
||||
line = "proxy_pass http://" +ip+":"+json.getInteger("port")+"/;";
|
||||
}else{
|
||||
line = line.replace(testIp, ip);
|
||||
}
|
||||
isNas=false;
|
||||
}else {
|
||||
line = line.replace(testIp, ip);
|
||||
}
|
||||
|
||||
isIp = false;
|
||||
}
|
||||
}
|
||||
stringBuffer.append(line).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(stringBuffer.toString());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
System.out.println("修改完成");
|
||||
Runtime.getRuntime().exec("nginx -s reload");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/nas/getIp.do")
|
||||
@ResponseBody
|
||||
public String getIP(HttpServletRequest request) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", -1);
|
||||
json.put("msg", "未登录");
|
||||
if (Tools.checkWebLogin(request) != 1) {
|
||||
// return json.toJSONString();
|
||||
}
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok");
|
||||
json.put("data", nas_ip);
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
public String testIp(String ip) {
|
||||
String pattern = "((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}";
|
||||
Pattern p = Pattern.compile(pattern);
|
||||
Matcher matcher = p.matcher(ip);
|
||||
// System.out.println("送检测IP:"+ip);
|
||||
if (matcher.find())
|
||||
return ip.substring(matcher.start(), matcher.end());
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
File file = new File("ipconfig.txt");
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
boolean create = file.createNewFile();
|
||||
if (create)
|
||||
System.out.println("创建文件完成:" + file.getAbsolutePath());
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
if (!keys.contains(tmp.trim()))
|
||||
keys.add(tmp.trim());
|
||||
}
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
5
src/main/java/com/yutou/nas/Datas/AppData.java
Normal file
5
src/main/java/com/yutou/nas/Datas/AppData.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.yutou.nas.Datas;
|
||||
|
||||
public class AppData {
|
||||
public static String defaultMusicPath = "/media/yutou/4t/public/音乐";
|
||||
}
|
20
src/main/java/com/yutou/nas/NasApplication.java
Normal file
20
src/main/java/com/yutou/nas/NasApplication.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.yutou.nas;
|
||||
|
||||
import com.yutou.nas.Datas.AppData;
|
||||
import com.yutou.nas.utils.ConfigTools;
|
||||
import com.yutou.nas.utils.QQBotManager;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class NasApplication {
|
||||
public static final String version="1.0.0";
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NasApplication.class, args);
|
||||
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
RedisTools.initRedisPoolSub();
|
||||
QQBotManager.getInstance();
|
||||
}
|
||||
|
||||
}
|
135
src/main/java/com/yutou/nas/bangumi/AnimationController.java
Normal file
135
src/main/java/com/yutou/nas/bangumi/AnimationController.java
Normal file
@ -0,0 +1,135 @@
|
||||
package com.yutou.nas.bangumi;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.mybatis.dao.BangumiItemDao;
|
||||
import com.yutou.nas.mybatis.dao.BangumiListDao;
|
||||
import com.yutou.nas.mybatis.model.BangumiItem;
|
||||
import com.yutou.nas.mybatis.model.BangumiItemExample;
|
||||
import com.yutou.nas.mybatis.model.BangumiList;
|
||||
import com.yutou.nas.mybatis.model.BangumiListExample;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("anim/")
|
||||
public class AnimationController {
|
||||
@Resource
|
||||
BangumiListDao listDao;
|
||||
@Resource
|
||||
BangumiItemDao itemDao;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "rss/data.do", method = RequestMethod.GET)
|
||||
public String getAnimList(String key,String type,String team, int page) {
|
||||
boolean isNull = key.length() == 0;
|
||||
if(!StringUtils.isEmpty(type)&&type.length()>2)
|
||||
type=type.substring(2);
|
||||
if(!StringUtils.isEmpty(team)&&team.length()>2)
|
||||
team=team.substring(2);
|
||||
String[] keys = key.split(" ");
|
||||
JSONArray items = null;
|
||||
if (!isNull)
|
||||
items = new AnimationData().bangumiList(page,type,team, keys);
|
||||
JSONObject json = new JSONObject();
|
||||
if (items != null) {
|
||||
json.put("data", items);
|
||||
} else {
|
||||
json.put("data", new JSONArray());
|
||||
}
|
||||
json.put("count", 999);
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "type/add.do", method = RequestMethod.POST)
|
||||
public String addRssType(String title) {
|
||||
BangumiList bangumiList = new BangumiList();
|
||||
bangumiList.setTitle(title);
|
||||
bangumiList.setStatus(1);
|
||||
int i = listDao.insert(bangumiList);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", i == 0 ? "添加失败" : "添加成功");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "type/list.do", method = RequestMethod.GET)
|
||||
public String getRssTypeList() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok");
|
||||
json.put("data", JSONArray.toJSON(listDao.selectByExample(new BangumiListExample())));
|
||||
return json.toJSONString();
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "type/del.do", method = RequestMethod.POST)
|
||||
public String delType(int id){
|
||||
BangumiItemExample example=new BangumiItemExample();
|
||||
example.createCriteria().andBidEqualTo(id+"");
|
||||
itemDao.deleteByExample(example);
|
||||
int i=listDao.deleteByPrimaryKey(id);
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", i == 0 ? "删除失败" : "删除成功");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "rss/add.do", method = RequestMethod.POST)
|
||||
public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
|
||||
BangumiItem item = new BangumiItem();
|
||||
item.setTitle(title);
|
||||
item.setAuthor(author);
|
||||
item.setCategories(categories);
|
||||
item.setTitlekey(titleKey);
|
||||
item.setBid(bid);
|
||||
int i = itemDao.insert(item);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", i == 0 ? "添加失败" : "添加成功");
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "rss/list.do", method = RequestMethod.GET)
|
||||
public String getAnimationRssList(String type) {
|
||||
JSONObject json = new JSONObject();
|
||||
BangumiItemExample example=new BangumiItemExample();
|
||||
example.createCriteria().andBidEqualTo(type);
|
||||
json.put("code", 0);
|
||||
json.put("msg", "ok");
|
||||
json.put("data", JSONArray.toJSON(itemDao.selectByExample(example)));
|
||||
return json.toJSONString();
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "rss/del.do", method = RequestMethod.POST)
|
||||
public String delAnimation(int id){
|
||||
int i=itemDao.deleteByPrimaryKey(id);
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("msg", i == 0 ? "删除失败" : "删除成功");
|
||||
return json.toJSONString();
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "client/get.do", method = RequestMethod.GET)
|
||||
public String clientApi(){
|
||||
AnimationData animationData=new AnimationData();
|
||||
List<BangumiItem> list=itemDao.selectByExample(new BangumiItemExample());
|
||||
for (BangumiItem item : list) {
|
||||
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
|
||||
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
|
||||
}
|
||||
JSONArray array= (JSONArray) JSONArray.toJSON(list);
|
||||
return array.toJSONString();
|
||||
}
|
||||
}
|
62
src/main/java/com/yutou/nas/bangumi/AnimationData.java
Normal file
62
src/main/java/com/yutou/nas/bangumi/AnimationData.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.yutou.nas.bangumi;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.utils.HttpTools;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
||||
public class AnimationData {
|
||||
private String rss2jsonApi_1="wtfm5pebya13pnl8rtu51wfgfpte0mb9sap1foll";
|
||||
private String rss2jsonApi_2="z2s7zyzxvrsjz9vh5alvq3lxdypzykly2nnvqpdx";
|
||||
private String rss2jsonUrl = "https://api.rss2json.com/v1/api.json?rss_url=";
|
||||
private String animUrl = "http://share.dmhy.org/topics/rss/page/%s/rss.xml?keyword=%s&sort_id=%s&team_id=%s&order=date-desc";
|
||||
private String team="[{\"0\":\"全部\"},{\"117\":\"動漫花園\"},{\"669\":\"喵萌奶茶屋\"},{\"648\":\"魔星字幕团\"},{\"185\":\"极影字幕社\"},{\"619\":\"桜都字幕组\"},{\"604\":\"lleeopen\"},{\"241\":\"幻樱字幕组\"},{\"151\":\"悠哈C9字幕社\"},{\"657\":\"LoliHouse\"},{\"283\":\"千夏字幕组\"},{\"755\":\"GMTeam\"},{\"390\":\"天使动漫\"},{\"731\":\"星空字幕组\"},{\"303\":\"动漫国字幕组\"},{\"563\":\"花園壓制組\"},{\"37\":\"雪飄工作室(FLsnow)\"},{\"47\":\"爱恋字幕社\"},{\"710\":\"咪梦动漫组\"},{\"88\":\"动音漫影\"},{\"574\":\"梦蓝字幕组\"},{\"504\":\"LoveEcho!\"},{\"765\":\"爱咕字幕组\"},{\"520\":\"豌豆字幕组\"},{\"650\":\"SweetSub\"},{\"430\":\"幻之字幕组\"},{\"407\":\"DHR動研字幕組\"},{\"321\":\"轻之国度\"},{\"581\":\"VCB-Studio\"},{\"703\":\"届恋字幕组\"},{\"576\":\"银色子弹字幕组\"},{\"454\":\"风车字幕组\"},{\"485\":\"天空树双语字幕组\"},{\"134\":\"漫游字幕组\"},{\"434\":\"风之圣殿\"},{\"630\":\"枫叶字幕组\"},{\"228\":\"KRL字幕组\"},{\"526\":\"东京不够热\"},{\"592\":\"未央阁联盟\"},{\"288\":\"诸神kamigami字幕组\"},{\"767\":\"天月動漫&發佈組\"},{\"768\":\"千歲字幕組\"},{\"423\":\"漫貓字幕組\"},{\"562\":\"129.3字幕組\"},{\"447\":\"夢幻戀櫻\"},{\"680\":\"Little字幕组\"},{\"641\":\"冷番补完字幕组\"},{\"31\":\"卡通空間\"},{\"649\":\"云光字幕组\"},{\"701\":\"狐狸小宮\"},{\"459\":\"紫音動漫&發佈組\"},{\"699\":\"小花花同盟戰線\"},{\"626\":\"驯兽师联盟\"},{\"58\":\"澄空学园\"},{\"769\":\"动漫萌\"},{\"734\":\"TD-RAWS\"},{\"225\":\"鈴風字幕組\"},{\"673\":\"VRAINSTORM\"},{\"741\":\"銀月字幕組\"},{\"675\":\"AikatsuFans\"},{\"759\":\"红鸟窝字幕组\"},{\"764\":\"MCE汉化组\"},{\"391\":\"ZERO字幕组\"},{\"561\":\"钉铛字幕组\"},{\"727\":\"2B4B\"},{\"104\":\"动漫先锋\"},{\"567\":\"雪梦字幕组\"},{\"573\":\"Centaurea-Raws\"},{\"652\":\"SFEO-Raws\"},{\"666\":\"中肯字幕組\"},{\"754\":\"BYYM发布组\"},{\"613\":\"AI-Raws\"},{\"706\":\"K&W-RAWS\"},{\"732\":\"肥猫压制\"},{\"424\":\"TSDM字幕組\"},{\"739\":\"Clarita 压制组\"},{\"432\":\"自由字幕组\"},{\"217\":\"AQUA工作室\"},{\"753\":\"柠檬水字幕组\"},{\"763\":\"光之家族字幕组\"},{\"332\":\"CureSub\"},{\"537\":\"NEO·QSW\"},{\"632\":\"歐克勒亞\"},{\"548\":\"Cornflower Studio\"},{\"638\":\"LittleBakas!\"}]";
|
||||
private String type="[{\"0\":\"全部\"},{\"2\":\"動畫\"},{\"31\":\"季度全集\"},{\"3\":\"漫畫\"},{\"41\":\"港台原版\"},{\"42\":\"日文原版\"},{\"4\":\"音樂\"},{\"43\":\"動漫音樂\"},{\"44\":\"同人音樂\"},{\"15\":\"流行音樂\"},{\"6\":\"日劇\"},{\"7\":\"RAW\"},{\"9\":\"遊戲\"},{\"17\":\"電腦遊戲\"},{\"18\":\"電視遊戲\"},{\"19\":\"掌機遊戲\"},{\"20\":\"網絡遊戲\"},{\"21\":\"遊戲周邊\"},{\"12\":\"特攝\"},{\"1\":\"其他\"}]";
|
||||
|
||||
public JSONArray bangumiList(int index,String type, String team,String... keys) {
|
||||
try {
|
||||
String title = "";
|
||||
for (String key : keys) {
|
||||
System.out.println(key);
|
||||
title += key + "+";
|
||||
}
|
||||
title = title.substring(1, title.length() - 1);
|
||||
System.out.println(String.format(animUrl, "" + index, title,type,team));
|
||||
System.out.println(rss2jsonUrl + URLEncoder.encode(String.format(animUrl, "" + index, title,type,team), "UTF-8") +String.format( "&api_key=%s&count=500",rss2jsonApi_2));
|
||||
String js= HttpTools.get(rss2jsonUrl+ URLEncoder.encode(String.format(animUrl,""+index,title,type,team),"UTF-8")+String.format( "&api_key=%s&count=500",rss2jsonApi_2));
|
||||
JSONObject json=JSONObject.parseObject(js);
|
||||
if(json.getString("status").equals("ok")){
|
||||
return json.getJSONArray("items");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public int nameToValue(String name,boolean isTeam){
|
||||
JSONArray array;
|
||||
if(isTeam){
|
||||
array=JSONArray.parseArray(team);
|
||||
}else{
|
||||
array=JSONArray.parseArray(type);
|
||||
}
|
||||
for (Object o : array) {
|
||||
JSONObject json= (JSONObject) o;
|
||||
for (String s : json.keySet()) {
|
||||
if(json.get(s).equals(name)){
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static void initData(){
|
||||
String url="https://share.dmhy.org/topics/advanced-search?team_id=0&sort_id=0&orderby=";
|
||||
String data=HttpTools.get(url);
|
||||
System.out.println(data);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
initData();
|
||||
}
|
||||
}
|
330
src/main/java/com/yutou/nas/bangumi/BangumiTools.java
Normal file
330
src/main/java/com/yutou/nas/bangumi/BangumiTools.java
Normal file
@ -0,0 +1,330 @@
|
||||
package com.yutou.nas.bangumi;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.utils.HttpTools;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class BangumiTools {
|
||||
private static final String url = "http://api.bgm.tv/";
|
||||
private static final String toDayBangumi = url + "calendar";
|
||||
private static final String BangumiInfo = url + "/subject/%s?responseGroup=large";
|
||||
private static final String SearchBangumi = url + "/search/subject/%s?responseGroup=large";
|
||||
|
||||
/**
|
||||
* 获取番剧列表
|
||||
*
|
||||
* @param day 周几,-1为全部,非1~7范围则为当天
|
||||
* @return 当日数据
|
||||
*/
|
||||
public static JSONObject getBangumi(int day) {
|
||||
String str = HttpTools.get(toDayBangumi);
|
||||
JSONArray main = JSONArray.parseArray(str);
|
||||
if (day == -1) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("bangumi", main);
|
||||
return json;
|
||||
}
|
||||
if (day < 1 || day > 7) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
||||
calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
calendar.setTime(new Date());
|
||||
day = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (day == 0) {
|
||||
day = 7;
|
||||
}
|
||||
}
|
||||
if (main != null)
|
||||
for (Object o : main) {
|
||||
JSONObject json = (JSONObject) o;
|
||||
if (json.getJSONObject("weekday").getInteger("id") == day) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取番剧详细信息
|
||||
*
|
||||
* @param id 剧集id
|
||||
* @return 详细信息
|
||||
*/
|
||||
public static JSONObject getBangumiInfo(int id) {
|
||||
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
|
||||
return JSONObject.parseObject(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索番剧
|
||||
*
|
||||
* @param key 关键词
|
||||
* @return 详细信息
|
||||
*/
|
||||
public static JSONObject search(String key) {
|
||||
String str = HttpTools.get(String.format(SearchBangumi, key));
|
||||
return JSONObject.parseObject(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一集播放日期
|
||||
*
|
||||
* @param id 番剧id
|
||||
* @return 日期
|
||||
*/
|
||||
public static String getPlayNextTime(int id) {
|
||||
JSONObject info = getBangumiInfo(id);
|
||||
JSONArray eps = info.getJSONArray("eps");
|
||||
String toDayTime = Tools.getToDayTime();
|
||||
for (Object o : eps) {
|
||||
JSONObject ep = (JSONObject) o;
|
||||
String time = ep.getString("airdate");
|
||||
try {
|
||||
if (new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime() >=
|
||||
new SimpleDateFormat("yyyy-MM-dd").parse(toDayTime).getTime()) {
|
||||
return time;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化字符串输出番剧详细信息
|
||||
*
|
||||
* @param id 番剧id
|
||||
* @return 详细内容
|
||||
*/
|
||||
public static String reportBangumiInfo(int id) {
|
||||
JSONObject json = getBangumiInfo(id);
|
||||
if(json.containsKey("code")){
|
||||
return json.getString("error");
|
||||
}
|
||||
JSONArray eps = json.getJSONArray("eps");
|
||||
JSONArray crts = json.getJSONArray("crt");
|
||||
JSONArray staffs = json.getJSONArray("staff");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("<img ").append(json.getJSONObject("images").getString("large")).append(" /img>").append("\n");
|
||||
builder.append("标题:").append(json.getString("name_cn")).append("\n");
|
||||
builder.append("日文标题:").append(json.getString("name")).append("\n");
|
||||
builder.append("首播时间:").append(json.getString("air_date")).append("\n");
|
||||
builder.append("每周").append(json.getInteger("air_weekday")).append("放送").append("\n");
|
||||
builder.append("Bangumi地址:").append(json.getString("url")).append("\n");
|
||||
builder.append("Bangumi评分:").append(json.getJSONObject("rating").getFloat("score")).append("\n");
|
||||
builder.append("预计放送集数:").append(json.getInteger("eps_count")).append("\n");
|
||||
if (eps != null) {
|
||||
builder.append("已放送集:").append("\n");
|
||||
for (Object o : eps) {
|
||||
JSONObject ep = (JSONObject) o;
|
||||
if (ep.getString("status").equals("Air")) {
|
||||
builder.append("· 第").append(ep.getInteger("sort")).append("话:");
|
||||
builder.append(ep.getString("name"));
|
||||
builder.append("[").append(ep.getString("name_cn")).append("]").append("\n");
|
||||
builder.append("播放日期:").append(ep.getString("airdate")).append(";\n");
|
||||
builder.append("播放时长:").append(ep.getString("duration")).append(";\n");
|
||||
builder.append("单集介绍:").append(ep.getString("desc"));
|
||||
builder.append("\n\n");
|
||||
} else {
|
||||
builder.append("下一话:");
|
||||
builder.append(" 第").append(ep.getInteger("sort")).append("话:");
|
||||
builder.append("播放日期:").append(ep.getString("airdate")).append("\n\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (crts != null) {
|
||||
builder.append("角色介绍:").append("\n");
|
||||
for (Object o : crts) {
|
||||
JSONObject crt = (JSONObject) o;
|
||||
JSONObject info = crt.getJSONObject("info");
|
||||
builder.append(crt.getString("role_name")).append(":");
|
||||
builder.append(crt.getString("name"));
|
||||
builder.append("(").append(crt.getString("name_cn")).append(")").append(" ");
|
||||
builder.append("CV:").append(crt.getJSONArray("actors").getJSONObject(0).getString("name"));
|
||||
builder.append("(").append(info.getString("gender")).append(")");
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
Map<String, List<JSONObject>> map = new HashMap<>();
|
||||
for (Object o : staffs) {
|
||||
JSONObject staff = (JSONObject) o;
|
||||
for (Object jobs : staff.getJSONArray("jobs")) {
|
||||
String job = (String) jobs;
|
||||
List<JSONObject> list;
|
||||
if (!map.containsKey(job)) {
|
||||
list = new ArrayList<>();
|
||||
} else {
|
||||
list = map.get(job);
|
||||
}
|
||||
list.add(staff);
|
||||
map.put(job, list);
|
||||
}
|
||||
}
|
||||
if (!map.isEmpty()) {
|
||||
builder.append("staff:").append("\n");
|
||||
for (String key : map.keySet()) {
|
||||
builder.append(key).append(":");
|
||||
for (JSONObject staff : map.get(key)) {
|
||||
builder.append(staff.getString("name_cn"));
|
||||
builder.append("(").append(staff.getString("name")).append(")");
|
||||
builder.append("、");
|
||||
}
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出新番列表
|
||||
* @return 新番信息
|
||||
*/
|
||||
public static String reportBangumiList(){
|
||||
try {
|
||||
JSONObject json=getBangumi(-1);
|
||||
StringBuilder builder=new StringBuilder();
|
||||
assert json != null;
|
||||
JSONArray array=json.getJSONArray("bangumi");
|
||||
for (Object o : array) {
|
||||
JSONObject data= (JSONObject) o;
|
||||
JSONObject weekday=data.getJSONObject("weekday");
|
||||
JSONArray items=data.getJSONArray("items");
|
||||
builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
|
||||
builder.append(":").append("\n");
|
||||
reportBangumi(builder, items,false);
|
||||
builder.append("\n");
|
||||
}
|
||||
return builder.toString();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private static void reportBangumi(StringBuilder builder, JSONArray items,boolean reportEp) {
|
||||
int epIndex = 0;
|
||||
String epName = "N/A";
|
||||
for (Object oj : items) {
|
||||
JSONObject item = (JSONObject) oj;
|
||||
builder.append("[").append(item.getInteger("id")).append("]");
|
||||
builder.append(StringUtils.isEmpty(item.getString("name_cn"))
|
||||
?item.getString("name"):item.getString("name_cn"));
|
||||
if(!reportEp){
|
||||
builder.append("\n");
|
||||
continue;
|
||||
}
|
||||
JSONObject info=getBangumiInfo(item.getInteger("id"));
|
||||
if(info.get("eps")==null){
|
||||
continue;
|
||||
}
|
||||
JSONArray eps = info.getJSONArray("eps");
|
||||
for (Object oe : eps) {
|
||||
JSONObject ep = (JSONObject) oe;
|
||||
if (ep.getString("status").equals("Air")) {
|
||||
epIndex = ep.getInteger("sort");
|
||||
epName = ep.getString("name");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.append(" 第").append(epIndex).append("话:");
|
||||
builder.append(epName);
|
||||
builder.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化字符串输出今日播放番剧列表
|
||||
*
|
||||
* @return 番剧列表
|
||||
*/
|
||||
public static String reportToDayBangumi() {
|
||||
String toDayTime = Tools.getToDayTime();
|
||||
if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
|
||||
RedisTools.set("reportToDayBangumi", toDayTime);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
JSONObject toDay = getBangumi(0);
|
||||
if (toDay == null) {
|
||||
builder.append("今天没有任何番剧放送~");
|
||||
} else {
|
||||
JSONObject weekday = toDay.getJSONObject("weekday");
|
||||
JSONArray items = toDay.getJSONArray("items");
|
||||
builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
|
||||
builder.append(" 放送列表:").append("\n");
|
||||
reportBangumi(builder, items,true);
|
||||
}
|
||||
RedisTools.set("toDayBangumi", builder.toString());
|
||||
return builder.toString();
|
||||
} else {
|
||||
return RedisTools.get("toDayBangumi");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化字符串输出搜索动画
|
||||
*
|
||||
* @param key 关键词
|
||||
* @return 详细内容
|
||||
*/
|
||||
public static String reportSearchBangumi(String key) {
|
||||
JSONObject main = search(key);
|
||||
if (main.getInteger("results") > 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
List<JSONObject> list = main.getJSONArray("list").toJavaList(JSONObject.class);
|
||||
Collections.reverse(list);
|
||||
for (Object items : list) {
|
||||
JSONObject item = (JSONObject) items;
|
||||
builder.append("标题:").append(item.getString("name_cn")).append("\n");
|
||||
builder.append("日文标题:").append(item.getString("name")).append("\n");
|
||||
String type;
|
||||
switch (item.getInteger("type")) {
|
||||
case 1:
|
||||
type = "书籍";
|
||||
break;
|
||||
case 2:
|
||||
type = "动画";
|
||||
break;
|
||||
case 3:
|
||||
type = "音乐";
|
||||
break;
|
||||
case 4:
|
||||
type = "游戏";
|
||||
break;
|
||||
case 6:
|
||||
type = "真人剧(Real)";
|
||||
break;
|
||||
default:
|
||||
type = item.getInteger("type") + "";
|
||||
}
|
||||
builder.append("类型:").append(type).append("\n");
|
||||
builder.append("id:").append(item.getInteger("id")).append("\n");
|
||||
if (item.containsKey("rating"))
|
||||
builder.append("Bangumi评分:").append(item.getJSONObject("rating").getFloat("score")).append("\n");
|
||||
builder.append("首播时间:").append(item.getString("air_date")).append("\n");
|
||||
builder.append("每周 ").append(item.getInteger("air_weekday")).append(" 放送").append("\n");
|
||||
builder.append("放送集数:").append(item.getInteger("eps")).append("\n");
|
||||
builder.append("Bangumi地址:").append(item.getString("url")).append("\n");
|
||||
builder.append("介绍:").append(item.getString("summary")).append("\n");
|
||||
builder.append("\n").append("\n");
|
||||
}
|
||||
return builder.toString();
|
||||
} else {
|
||||
return "搜索不到任何内容:" + key;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = reportBangumiList();
|
||||
System.out.println(str);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.yutou.nas.interfaces;
|
||||
|
||||
public abstract class DownloadInterface {
|
||||
public void onDownload(String file){};
|
||||
public void onError(Exception e){};
|
||||
}
|
32
src/main/java/com/yutou/nas/mybatis/dao/BangumiItemDao.java
Normal file
32
src/main/java/com/yutou/nas/mybatis/dao/BangumiItemDao.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.yutou.nas.mybatis.dao;
|
||||
|
||||
import com.yutou.nas.mybatis.model.BangumiItem;
|
||||
import com.yutou.nas.mybatis.model.BangumiItemExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface BangumiItemDao {
|
||||
long countByExample(BangumiItemExample example);
|
||||
|
||||
int deleteByExample(BangumiItemExample example);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(BangumiItem record);
|
||||
|
||||
int insertSelective(BangumiItem record);
|
||||
|
||||
List<BangumiItem> selectByExample(BangumiItemExample example);
|
||||
|
||||
BangumiItem selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") BangumiItem record, @Param("example") BangumiItemExample example);
|
||||
|
||||
int updateByExample(@Param("record") BangumiItem record, @Param("example") BangumiItemExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(BangumiItem record);
|
||||
|
||||
int updateByPrimaryKey(BangumiItem record);
|
||||
}
|
32
src/main/java/com/yutou/nas/mybatis/dao/BangumiListDao.java
Normal file
32
src/main/java/com/yutou/nas/mybatis/dao/BangumiListDao.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.yutou.nas.mybatis.dao;
|
||||
|
||||
import com.yutou.nas.mybatis.model.BangumiList;
|
||||
import com.yutou.nas.mybatis.model.BangumiListExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface BangumiListDao {
|
||||
long countByExample(BangumiListExample example);
|
||||
|
||||
int deleteByExample(BangumiListExample example);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(BangumiList record);
|
||||
|
||||
int insertSelective(BangumiList record);
|
||||
|
||||
List<BangumiList> selectByExample(BangumiListExample example);
|
||||
|
||||
BangumiList selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") BangumiList record, @Param("example") BangumiListExample example);
|
||||
|
||||
int updateByExample(@Param("record") BangumiList record, @Param("example") BangumiListExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(BangumiList record);
|
||||
|
||||
int updateByPrimaryKey(BangumiList record);
|
||||
}
|
41
src/main/java/com/yutou/nas/mybatis/dao/MusicDataDao.java
Normal file
41
src/main/java/com/yutou/nas/mybatis/dao/MusicDataDao.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.yutou.nas.mybatis.dao;
|
||||
|
||||
import com.yutou.nas.mybatis.model.MusicData;
|
||||
import com.yutou.nas.mybatis.model.MusicDataExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface MusicDataDao {
|
||||
long countByExample(MusicDataExample example);
|
||||
|
||||
int deleteByExample(MusicDataExample example);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(MusicData record);
|
||||
|
||||
int insertSelective(MusicData record);
|
||||
|
||||
List<MusicData> selectByExample(MusicDataExample example);
|
||||
|
||||
MusicData selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") MusicData record, @Param("example") MusicDataExample example);
|
||||
|
||||
int updateByExample(@Param("record") MusicData record, @Param("example") MusicDataExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(MusicData record);
|
||||
|
||||
int updateByPrimaryKey(MusicData record);
|
||||
|
||||
void truncate();
|
||||
List<MusicData> selectByRegexp(String regexp);
|
||||
|
||||
List<String> selectAllAlbum();
|
||||
List<String> selectAllArtist();
|
||||
List<MusicData> selectAlbum(String album);
|
||||
List<MusicData> selectArtist(String artist);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.yutou.nas.mybatis.dao;
|
||||
|
||||
import com.yutou.nas.mybatis.model.MusicFavorites;
|
||||
import com.yutou.nas.mybatis.model.MusicFavoritesExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface MusicFavoritesDao {
|
||||
long countByExample(MusicFavoritesExample example);
|
||||
|
||||
int deleteByExample(MusicFavoritesExample example);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(MusicFavorites record);
|
||||
|
||||
int insertSelective(MusicFavorites record);
|
||||
|
||||
List<MusicFavorites> selectByExample(MusicFavoritesExample example);
|
||||
|
||||
MusicFavorites selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") MusicFavorites record, @Param("example") MusicFavoritesExample example);
|
||||
|
||||
int updateByExample(@Param("record") MusicFavorites record, @Param("example") MusicFavoritesExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(MusicFavorites record);
|
||||
|
||||
int updateByPrimaryKey(MusicFavorites record);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.yutou.nas.mybatis.dao;
|
||||
|
||||
import com.yutou.nas.mybatis.model.MusicFavoritesDir;
|
||||
import com.yutou.nas.mybatis.model.MusicFavoritesDirExample;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface MusicFavoritesDirDao {
|
||||
long countByExample(MusicFavoritesDirExample example);
|
||||
|
||||
int deleteByExample(MusicFavoritesDirExample example);
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(MusicFavoritesDir record);
|
||||
|
||||
int insertSelective(MusicFavoritesDir record);
|
||||
|
||||
List<MusicFavoritesDir> selectByExample(MusicFavoritesDirExample example);
|
||||
|
||||
MusicFavoritesDir selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") MusicFavoritesDir record, @Param("example") MusicFavoritesDirExample example);
|
||||
|
||||
int updateByExample(@Param("record") MusicFavoritesDir record, @Param("example") MusicFavoritesDirExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(MusicFavoritesDir record);
|
||||
|
||||
int updateByPrimaryKey(MusicFavoritesDir record);
|
||||
}
|
28
src/main/java/com/yutou/nas/mybatis/model/BangumiItem.java
Normal file
28
src/main/java/com/yutou/nas/mybatis/model/BangumiItem.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* bangumi_item
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
public class BangumiItem implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String bid;
|
||||
|
||||
private String categories;
|
||||
|
||||
private String author;
|
||||
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 标题过滤词
|
||||
*/
|
||||
private String titlekey;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,611 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BangumiItemExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public BangumiItemExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Integer value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Integer value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Integer value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Integer value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Integer> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Integer> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidIsNull() {
|
||||
addCriterion("bid is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidIsNotNull() {
|
||||
addCriterion("bid is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidEqualTo(String value) {
|
||||
addCriterion("bid =", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidNotEqualTo(String value) {
|
||||
addCriterion("bid <>", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidGreaterThan(String value) {
|
||||
addCriterion("bid >", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("bid >=", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidLessThan(String value) {
|
||||
addCriterion("bid <", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidLessThanOrEqualTo(String value) {
|
||||
addCriterion("bid <=", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidLike(String value) {
|
||||
addCriterion("bid like", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidNotLike(String value) {
|
||||
addCriterion("bid not like", value, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidIn(List<String> values) {
|
||||
addCriterion("bid in", values, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidNotIn(List<String> values) {
|
||||
addCriterion("bid not in", values, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidBetween(String value1, String value2) {
|
||||
addCriterion("bid between", value1, value2, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBidNotBetween(String value1, String value2) {
|
||||
addCriterion("bid not between", value1, value2, "bid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesIsNull() {
|
||||
addCriterion("categories is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesIsNotNull() {
|
||||
addCriterion("categories is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesEqualTo(String value) {
|
||||
addCriterion("categories =", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesNotEqualTo(String value) {
|
||||
addCriterion("categories <>", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesGreaterThan(String value) {
|
||||
addCriterion("categories >", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("categories >=", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesLessThan(String value) {
|
||||
addCriterion("categories <", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesLessThanOrEqualTo(String value) {
|
||||
addCriterion("categories <=", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesLike(String value) {
|
||||
addCriterion("categories like", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesNotLike(String value) {
|
||||
addCriterion("categories not like", value, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesIn(List<String> values) {
|
||||
addCriterion("categories in", values, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesNotIn(List<String> values) {
|
||||
addCriterion("categories not in", values, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesBetween(String value1, String value2) {
|
||||
addCriterion("categories between", value1, value2, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCategoriesNotBetween(String value1, String value2) {
|
||||
addCriterion("categories not between", value1, value2, "categories");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorIsNull() {
|
||||
addCriterion("author is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorIsNotNull() {
|
||||
addCriterion("author is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorEqualTo(String value) {
|
||||
addCriterion("author =", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorNotEqualTo(String value) {
|
||||
addCriterion("author <>", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorGreaterThan(String value) {
|
||||
addCriterion("author >", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("author >=", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorLessThan(String value) {
|
||||
addCriterion("author <", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorLessThanOrEqualTo(String value) {
|
||||
addCriterion("author <=", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorLike(String value) {
|
||||
addCriterion("author like", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorNotLike(String value) {
|
||||
addCriterion("author not like", value, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorIn(List<String> values) {
|
||||
addCriterion("author in", values, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorNotIn(List<String> values) {
|
||||
addCriterion("author not in", values, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorBetween(String value1, String value2) {
|
||||
addCriterion("author between", value1, value2, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAuthorNotBetween(String value1, String value2) {
|
||||
addCriterion("author not between", value1, value2, "author");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNull() {
|
||||
addCriterion("title is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNotNull() {
|
||||
addCriterion("title is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleEqualTo(String value) {
|
||||
addCriterion("title =", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotEqualTo(String value) {
|
||||
addCriterion("title <>", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThan(String value) {
|
||||
addCriterion("title >", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("title >=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThan(String value) {
|
||||
addCriterion("title <", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThanOrEqualTo(String value) {
|
||||
addCriterion("title <=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLike(String value) {
|
||||
addCriterion("title like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotLike(String value) {
|
||||
addCriterion("title not like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIn(List<String> values) {
|
||||
addCriterion("title in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotIn(List<String> values) {
|
||||
addCriterion("title not in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleBetween(String value1, String value2) {
|
||||
addCriterion("title between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotBetween(String value1, String value2) {
|
||||
addCriterion("title not between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyIsNull() {
|
||||
addCriterion("titleKey is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyIsNotNull() {
|
||||
addCriterion("titleKey is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyEqualTo(String value) {
|
||||
addCriterion("titleKey =", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyNotEqualTo(String value) {
|
||||
addCriterion("titleKey <>", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyGreaterThan(String value) {
|
||||
addCriterion("titleKey >", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("titleKey >=", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyLessThan(String value) {
|
||||
addCriterion("titleKey <", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyLessThanOrEqualTo(String value) {
|
||||
addCriterion("titleKey <=", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyLike(String value) {
|
||||
addCriterion("titleKey like", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyNotLike(String value) {
|
||||
addCriterion("titleKey not like", value, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyIn(List<String> values) {
|
||||
addCriterion("titleKey in", values, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyNotIn(List<String> values) {
|
||||
addCriterion("titleKey not in", values, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyBetween(String value1, String value2) {
|
||||
addCriterion("titleKey between", value1, value2, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlekeyNotBetween(String value1, String value2) {
|
||||
addCriterion("titleKey not between", value1, value2, "titlekey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
19
src/main/java/com/yutou/nas/mybatis/model/BangumiList.java
Normal file
19
src/main/java/com/yutou/nas/mybatis/model/BangumiList.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* bangumi_list
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
public class BangumiList implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,391 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BangumiListExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public BangumiListExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Integer value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Integer value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Integer value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Integer value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Integer> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Integer> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNull() {
|
||||
addCriterion("title is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNotNull() {
|
||||
addCriterion("title is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleEqualTo(String value) {
|
||||
addCriterion("title =", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotEqualTo(String value) {
|
||||
addCriterion("title <>", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThan(String value) {
|
||||
addCriterion("title >", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("title >=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThan(String value) {
|
||||
addCriterion("title <", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThanOrEqualTo(String value) {
|
||||
addCriterion("title <=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLike(String value) {
|
||||
addCriterion("title like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotLike(String value) {
|
||||
addCriterion("title not like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIn(List<String> values) {
|
||||
addCriterion("title in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotIn(List<String> values) {
|
||||
addCriterion("title not in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleBetween(String value1, String value2) {
|
||||
addCriterion("title between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotBetween(String value1, String value2) {
|
||||
addCriterion("title not between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNull() {
|
||||
addCriterion("`status` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIsNotNull() {
|
||||
addCriterion("`status` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusEqualTo(Integer value) {
|
||||
addCriterion("`status` =", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotEqualTo(Integer value) {
|
||||
addCriterion("`status` <>", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThan(Integer value) {
|
||||
addCriterion("`status` >", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`status` >=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThan(Integer value) {
|
||||
addCriterion("`status` <", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`status` <=", value, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusIn(List<Integer> values) {
|
||||
addCriterion("`status` in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotIn(List<Integer> values) {
|
||||
addCriterion("`status` not in", values, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`status` between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andStatusNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`status` not between", value1, value2, "status");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
117
src/main/java/com/yutou/nas/mybatis/model/MusicData.java
Normal file
117
src/main/java/com/yutou/nas/mybatis/model/MusicData.java
Normal file
@ -0,0 +1,117 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* music_data
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
public class MusicData implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 艺术家
|
||||
*/
|
||||
private String artist;
|
||||
|
||||
/**
|
||||
* 专辑
|
||||
*/
|
||||
private String album;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 评论
|
||||
*/
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 年份
|
||||
*/
|
||||
private String year;
|
||||
|
||||
/**
|
||||
* 音轨号
|
||||
*/
|
||||
private String track;
|
||||
|
||||
/**
|
||||
* 碟片编号
|
||||
*/
|
||||
private String discNo;
|
||||
|
||||
/**
|
||||
* 作曲
|
||||
*/
|
||||
private String composer;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private String artistSort;
|
||||
|
||||
/**
|
||||
* 音乐文件路径
|
||||
*/
|
||||
private String file;
|
||||
|
||||
/**
|
||||
* 上一个文件夹
|
||||
*/
|
||||
private String lastdir;
|
||||
|
||||
private Integer isdir;
|
||||
|
||||
/**
|
||||
* 比特率
|
||||
*/
|
||||
private Integer bitrate;
|
||||
|
||||
/**
|
||||
* 采样率
|
||||
*/
|
||||
private Integer samplerate;
|
||||
|
||||
/**
|
||||
* 采样数
|
||||
*/
|
||||
private Long noofsamples;
|
||||
|
||||
/**
|
||||
* 声道
|
||||
*/
|
||||
private Integer channelcount;
|
||||
|
||||
/**
|
||||
* 解码类型
|
||||
*/
|
||||
private String encodingtype;
|
||||
|
||||
/**
|
||||
* 持续时长
|
||||
*/
|
||||
private Double durationasdouble;
|
||||
|
||||
/**
|
||||
* 无损
|
||||
*/
|
||||
private Integer lossless;
|
||||
|
||||
/**
|
||||
* 固定码率
|
||||
*/
|
||||
private Integer variablebitrate;
|
||||
|
||||
/**
|
||||
* md5
|
||||
*/
|
||||
private String md5;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
1651
src/main/java/com/yutou/nas/mybatis/model/MusicDataExample.java
Normal file
1651
src/main/java/com/yutou/nas/mybatis/model/MusicDataExample.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* music_favorites
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
public class MusicFavorites implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private Integer favoriteid;
|
||||
|
||||
private String musisMd5;
|
||||
|
||||
private Date subTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* music_favorites_dir
|
||||
* @author
|
||||
*/
|
||||
@Data
|
||||
public class MusicFavoritesDir implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 收藏夹标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,331 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MusicFavoritesDirExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public MusicFavoritesDirExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Integer value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Integer value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Integer value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Integer value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Integer> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Integer> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNull() {
|
||||
addCriterion("title is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIsNotNull() {
|
||||
addCriterion("title is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleEqualTo(String value) {
|
||||
addCriterion("title =", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotEqualTo(String value) {
|
||||
addCriterion("title <>", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThan(String value) {
|
||||
addCriterion("title >", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("title >=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThan(String value) {
|
||||
addCriterion("title <", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLessThanOrEqualTo(String value) {
|
||||
addCriterion("title <=", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleLike(String value) {
|
||||
addCriterion("title like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotLike(String value) {
|
||||
addCriterion("title not like", value, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleIn(List<String> values) {
|
||||
addCriterion("title in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotIn(List<String> values) {
|
||||
addCriterion("title not in", values, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleBetween(String value1, String value2) {
|
||||
addCriterion("title between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitleNotBetween(String value1, String value2) {
|
||||
addCriterion("title not between", value1, value2, "title");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,452 @@
|
||||
package com.yutou.nas.mybatis.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class MusicFavoritesExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public MusicFavoritesExample() {
|
||||
oredCriteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Integer value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Integer value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Integer value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Integer value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Integer> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Integer> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidIsNull() {
|
||||
addCriterion("favoriteId is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidIsNotNull() {
|
||||
addCriterion("favoriteId is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidEqualTo(Integer value) {
|
||||
addCriterion("favoriteId =", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidNotEqualTo(Integer value) {
|
||||
addCriterion("favoriteId <>", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidGreaterThan(Integer value) {
|
||||
addCriterion("favoriteId >", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("favoriteId >=", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidLessThan(Integer value) {
|
||||
addCriterion("favoriteId <", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("favoriteId <=", value, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidIn(List<Integer> values) {
|
||||
addCriterion("favoriteId in", values, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidNotIn(List<Integer> values) {
|
||||
addCriterion("favoriteId not in", values, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidBetween(Integer value1, Integer value2) {
|
||||
addCriterion("favoriteId between", value1, value2, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFavoriteidNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("favoriteId not between", value1, value2, "favoriteid");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5IsNull() {
|
||||
addCriterion("musis_md5 is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5IsNotNull() {
|
||||
addCriterion("musis_md5 is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5EqualTo(String value) {
|
||||
addCriterion("musis_md5 =", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5NotEqualTo(String value) {
|
||||
addCriterion("musis_md5 <>", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5GreaterThan(String value) {
|
||||
addCriterion("musis_md5 >", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5GreaterThanOrEqualTo(String value) {
|
||||
addCriterion("musis_md5 >=", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5LessThan(String value) {
|
||||
addCriterion("musis_md5 <", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5LessThanOrEqualTo(String value) {
|
||||
addCriterion("musis_md5 <=", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5Like(String value) {
|
||||
addCriterion("musis_md5 like", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5NotLike(String value) {
|
||||
addCriterion("musis_md5 not like", value, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5In(List<String> values) {
|
||||
addCriterion("musis_md5 in", values, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5NotIn(List<String> values) {
|
||||
addCriterion("musis_md5 not in", values, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5Between(String value1, String value2) {
|
||||
addCriterion("musis_md5 between", value1, value2, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMusisMd5NotBetween(String value1, String value2) {
|
||||
addCriterion("musis_md5 not between", value1, value2, "musisMd5");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeIsNull() {
|
||||
addCriterion("sub_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeIsNotNull() {
|
||||
addCriterion("sub_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeEqualTo(Date value) {
|
||||
addCriterion("sub_time =", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeNotEqualTo(Date value) {
|
||||
addCriterion("sub_time <>", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeGreaterThan(Date value) {
|
||||
addCriterion("sub_time >", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeGreaterThanOrEqualTo(Date value) {
|
||||
addCriterion("sub_time >=", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeLessThan(Date value) {
|
||||
addCriterion("sub_time <", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeLessThanOrEqualTo(Date value) {
|
||||
addCriterion("sub_time <=", value, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeIn(List<Date> values) {
|
||||
addCriterion("sub_time in", values, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeNotIn(List<Date> values) {
|
||||
addCriterion("sub_time not in", values, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeBetween(Date value1, Date value2) {
|
||||
addCriterion("sub_time between", value1, value2, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andSubTimeNotBetween(Date value1, Date value2) {
|
||||
addCriterion("sub_time not between", value1, value2, "subTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
9
src/main/java/com/yutou/nas/other/QQAudio.java
Normal file
9
src/main/java/com/yutou/nas/other/QQAudio.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.yutou.nas.other;
|
||||
|
||||
import com.yutou.nas.utils.AudioTools;
|
||||
|
||||
public class QQAudio {
|
||||
public static void playText(String text){
|
||||
AudioTools.playText(text);
|
||||
}
|
||||
}
|
202
src/main/java/com/yutou/nas/other/QQSetu.java
Normal file
202
src/main/java/com/yutou/nas/other/QQSetu.java
Normal file
@ -0,0 +1,202 @@
|
||||
package com.yutou.nas.other;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.utils.QQBotManager;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent;
|
||||
import net.mamoe.mirai.message.data.At;
|
||||
import net.mamoe.mirai.message.data.Image;
|
||||
import net.mamoe.mirai.message.data.MessageChainBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class QQSetu {
|
||||
public static void printTodaySetu() {
|
||||
String redisKey=Tools.getToDayTime() + "_setu";
|
||||
System.out.println("redisKey = " + redisKey);
|
||||
String js = RedisTools.get(redisKey, 1);
|
||||
if (js != null) {
|
||||
JSONObject json = JSONObject.parseObject(js);
|
||||
if(json.containsKey("isPrint")&&json.getBoolean("isPrint")){
|
||||
return;
|
||||
}
|
||||
Map<String,Float> groupAverage=new HashMap<>();
|
||||
Map<String,String> groupImage=new HashMap<>();
|
||||
JSONObject setu=null;
|
||||
for (String id : json.keySet()) {
|
||||
String group=json.getJSONObject(id).getJSONObject("info").getLong("group")+"";
|
||||
if(groupAverage.containsKey(group)){
|
||||
if(groupAverage.get(group)<=json.getJSONObject(id).getFloat("average")){
|
||||
groupAverage.put(group,json.getJSONObject(id).getFloat("average"));
|
||||
groupImage.put(group,id);
|
||||
}
|
||||
}else{
|
||||
groupAverage.put(group,json.getJSONObject(id).getFloat("average"));
|
||||
groupImage.put(group,id);
|
||||
}
|
||||
}
|
||||
for (String id : groupImage.keySet()) {
|
||||
setu=json.getJSONObject(groupImage.get(id));
|
||||
if(setu!=null){
|
||||
json.put("isPrint",true);
|
||||
RedisTools.set(1,redisKey,json.toJSONString());
|
||||
JSONObject info=setu.getJSONObject("info");
|
||||
JSONObject score=setu.getJSONObject("score");
|
||||
MessageChainBuilder builder = new MessageChainBuilder();
|
||||
builder.append(Image.fromId(info.getString("id")));
|
||||
builder.append("本日最佳涩图由").append(new At(info.getLong("sourQQ"))).append("提供\n");
|
||||
builder.append("获得分数 ").append(String.valueOf(setu.getFloat("average"))).append("\n");
|
||||
builder.append("共有 ").append(String.valueOf(score.getIntValue("userNumber"))).append(" 人参与投票");
|
||||
QQBotManager.getInstance().sendMessage(info.getLong("group"),builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSetu(Image image) {
|
||||
String url = Image.queryUrl(image);
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
int length = connection.getContentLength();
|
||||
connection.disconnect();
|
||||
if (length > 50000) {
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setuBuilder(Image image, GroupMessageEvent event) {
|
||||
if (!isSetu(image)) {
|
||||
return;
|
||||
}
|
||||
if (RedisTools.get(event.getGroup().getId()+"setu") != null) {
|
||||
printSetu(event.getGroup().getId());
|
||||
}
|
||||
setuScore.clear();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", image.getImageId());
|
||||
json.put("sourName", event.getSenderName());
|
||||
json.put("sourQQ", event.getSender().getId());
|
||||
json.put("group", event.getGroup().getId());
|
||||
RedisTools.set(event.getGroup().getId()+"setu", json.toJSONString(),6*60);
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
startTimer(event.getGroup().getId());
|
||||
}
|
||||
|
||||
private void startTimer(long group) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!setuScore.isEmpty()){
|
||||
printSetu(group);
|
||||
}
|
||||
timer = null;
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
}
|
||||
|
||||
private void printSetu(long group) {
|
||||
JSONObject jt = JSONObject.parseObject(RedisTools.get(group+"setu"));
|
||||
String id = jt.getString("id");
|
||||
float average = 0;
|
||||
float max = 0;
|
||||
float min = 10;
|
||||
float length = 0;
|
||||
String maxName = "";
|
||||
String minName = "";
|
||||
if(setuScore.size()<=1){
|
||||
return;
|
||||
}
|
||||
for (String name : setuScore.keySet()) {
|
||||
length += setuScore.get(name);
|
||||
average += setuScore.get(name);
|
||||
if (setuScore.get(name) > max) {
|
||||
max = setuScore.get(name);
|
||||
maxName = name.split("\\|")[0];
|
||||
}
|
||||
if (setuScore.get(name) < min) {
|
||||
min = setuScore.get(name);
|
||||
minName = name.split("\\|")[0];
|
||||
}
|
||||
}
|
||||
JSONObject score = new JSONObject();
|
||||
score.put("max", max);
|
||||
score.put("min", min);
|
||||
score.put("sum", length);
|
||||
score.put("maxName", maxName);
|
||||
score.put("minName", minName);
|
||||
score.put("userNumber", setuScore.size());
|
||||
|
||||
average = average / setuScore.size();
|
||||
String builder = "涩图评分:" + average +"\n "+
|
||||
"其中最高分由:" + maxName + " 给与:" + max +"\n "+
|
||||
"其中最低分由:" + minName + " 给与:" + min;
|
||||
QQBotManager.getInstance().sendMessage(group, builder);
|
||||
String st = RedisTools.get(Tools.getToDayTime() + "_setu", 1);
|
||||
JSONObject json;
|
||||
if (st == null) {
|
||||
json = new JSONObject();
|
||||
} else {
|
||||
json = JSONObject.parseObject(st);
|
||||
}
|
||||
if (!json.containsKey(id)) {
|
||||
JSONObject item;
|
||||
if (json.containsKey("item")) {
|
||||
item = json.getJSONObject("item");
|
||||
} else {
|
||||
item = new JSONObject();
|
||||
}
|
||||
|
||||
item.put("score", score);
|
||||
item.put("info", jt);
|
||||
item.put("average", average);
|
||||
json.put(id, item);
|
||||
RedisTools.set(1, Tools.getToDayTime() + "_setu", json.toJSONString());
|
||||
}
|
||||
RedisTools.remove(group+"setu",0);
|
||||
setuScore.clear();
|
||||
}
|
||||
public void setu(String msg, GroupMessageEvent event) {
|
||||
if (msg.trim().equals("[图片]")) {
|
||||
Image image = (Image) event.getMessage().stream().filter(Image.class::isInstance).findFirst().orElse(null);
|
||||
if (image != null) {
|
||||
setuBuilder(image, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(msg.trim().length()>3){
|
||||
return;
|
||||
}
|
||||
float i = Float.parseFloat(msg.trim());
|
||||
if (i > 0 && i <= 10) {
|
||||
String name = event.getSenderName();
|
||||
String qq=event.getSender().getId()+"";
|
||||
if (!setuScore.containsKey(name)) {
|
||||
setuScore.put(name+"|"+qq, i);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private Timer timer;
|
||||
private static Map<String, Float> setuScore = new HashMap<>();
|
||||
}
|
122
src/main/java/com/yutou/nas/other/tools.java
Normal file
122
src/main/java/com/yutou/nas/other/tools.java
Normal file
@ -0,0 +1,122 @@
|
||||
package com.yutou.nas.other;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.NasApplication;
|
||||
import com.yutou.nas.utils.RedisTools;
|
||||
import com.yutou.nas.utils.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class tools {
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "tools/get.do")
|
||||
public String getJs(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Enumeration<String> name = request.getHeaderNames();
|
||||
while (name.hasMoreElements()) {
|
||||
String na = name.nextElement();
|
||||
System.out.println(na + " " + request.getHeader(na));
|
||||
}
|
||||
File file = new File("D:\\IDEA\\web_toolset\\web\\js\\my.js");
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String tmp, str = "";
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
if (tmp.contains("\"")) {
|
||||
// tmp=tmp.replace("\"","\\\"");
|
||||
}
|
||||
str += tmp;
|
||||
}
|
||||
reader.close();
|
||||
/* response.setHeader("Content-Type","application/javascript; charset=utf-8");
|
||||
PrintWriter writer=response.getWriter();
|
||||
writer.write(str);
|
||||
writer.flush();
|
||||
writer.close();*/
|
||||
return str;
|
||||
//return "function test(){ return \"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588139022200&di=8cc8405f7514dd54bd82fcd070349603&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg\" }";
|
||||
}
|
||||
|
||||
@RequestMapping("/public/version.do")
|
||||
@ResponseBody
|
||||
public String getVersion() {
|
||||
return NasApplication.version;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/public/request.do")
|
||||
public String testRequest(HttpServletRequest request) {
|
||||
JSONObject params = new JSONObject();
|
||||
JSONArray cookies = new JSONArray();
|
||||
JSONObject header = new JSONObject();
|
||||
for (String key : request.getParameterMap().keySet()) {
|
||||
params.put(key, request.getParameter(key));
|
||||
}
|
||||
if (request.getCookies() != null) {
|
||||
for (Cookie cookie : request.getCookies()) {
|
||||
JSONObject ck = JSONObject.parseObject(JSONObject.toJSONString(cookie));
|
||||
cookies.add(ck);
|
||||
}
|
||||
}
|
||||
Enumeration<String> enumeration = request.getHeaderNames();
|
||||
while (enumeration != null && enumeration.hasMoreElements()) {
|
||||
String tmp = enumeration.nextElement();
|
||||
header.put(tmp, request.getHeader(tmp));
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
json.put("method", request.getMethod());
|
||||
json.put("address", Tools.getRemoteAddress(request));
|
||||
json.put("UA", request.getHeader("User-Agent"));
|
||||
json.put("addressUrl", request.getPathInfo());
|
||||
json.put("params", params);
|
||||
json.put("cookie", cookies);
|
||||
json.put("header", header);
|
||||
Tools.sendServer("打印请求", json.toJSONString());
|
||||
try {
|
||||
switch (RedisTools.get("request")) {
|
||||
case "success":
|
||||
return "success";
|
||||
case "-999":
|
||||
case "param":
|
||||
return json.toJSONString();
|
||||
default:
|
||||
return RedisTools.get("request");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
return json.toJSONString();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/private/request.do")
|
||||
public String setRequest(String ret, String data) {
|
||||
switch (ret) {
|
||||
case "success":
|
||||
RedisTools.set("request", "success");
|
||||
break;
|
||||
case "user":
|
||||
RedisTools.set("request", data);
|
||||
break;
|
||||
default:
|
||||
RedisTools.set("request", "param");
|
||||
break;
|
||||
}
|
||||
return RedisTools.get("request");
|
||||
}
|
||||
|
||||
}
|
44
src/main/java/com/yutou/nas/utils/ApplicationInit.java
Normal file
44
src/main/java/com/yutou/nas/utils/ApplicationInit.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.yutou.nas.other.QQSetu;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* 服务启动后执行
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationInit implements ApplicationRunner {
|
||||
@Resource
|
||||
MusicToolsServiceImpl musicTools;
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
AudioTools.init();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
String time = new SimpleDateFormat("HH:mm").format(new Date());
|
||||
switch (time){
|
||||
case "00:00":
|
||||
musicTools.scanMusic();
|
||||
break;
|
||||
case "08:00":
|
||||
case "20:00":
|
||||
QQBotManager.getInstance().reportToDayBangumi();
|
||||
break;
|
||||
case "23:59":
|
||||
QQSetu.printTodaySetu();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
},0,35 * 1000);
|
||||
}
|
||||
}
|
66
src/main/java/com/yutou/nas/utils/AudioTools.java
Normal file
66
src/main/java/com/yutou/nas/utils/AudioTools.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.iflytek.cloud.speech.*;
|
||||
|
||||
public class AudioTools {
|
||||
private static boolean init = false;
|
||||
|
||||
synchronized static void init() {
|
||||
if (init) {
|
||||
return;
|
||||
}
|
||||
SpeechUtility.createUtility(SpeechConstant.APPID + "=601f7f7d");
|
||||
SpeechUtility.getUtility().setParameter(SpeechConstant.VOLUME,"100");
|
||||
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_64,"/media/yutou/4t/public/servier/tools/");
|
||||
SpeechUtility.getUtility().setParameter(SpeechConstant.LIB_NAME_32,"/media/yutou/4t/public/servier/tools/");
|
||||
init = true;
|
||||
System.out.println("讯飞语音已初始化");
|
||||
}
|
||||
|
||||
public static void playText(String text) {
|
||||
SpeechSynthesizer mss = SpeechSynthesizer.createSynthesizer();
|
||||
mss.startSpeaking(text, new SynthesizerListener() {
|
||||
@Override
|
||||
public void onBufferProgress(int progress, int beginPos, int endPos,
|
||||
String info) {
|
||||
if (progress == 100) {
|
||||
mss.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakBegin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakProgress(int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakPaused() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpeakResumed() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(SpeechError speechError) {
|
||||
System.out.println(speechError.getErrorDesc() + " code " + speechError.getErrorCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(int i, int i1, int i2, int i3, Object o, Object o1) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
init();
|
||||
playText("小爱同学,开灯");
|
||||
}
|
||||
}
|
86
src/main/java/com/yutou/nas/utils/ConfigTools.java
Normal file
86
src/main/java/com/yutou/nas/utils/ConfigTools.java
Normal file
@ -0,0 +1,86 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 配置和参数
|
||||
*/
|
||||
public class ConfigTools {
|
||||
public static final String CONFIG="config.json";
|
||||
public static final String DATA="data.json";
|
||||
public static final String SQLITE="sqlite.json";
|
||||
static {
|
||||
try {
|
||||
File file=new File(CONFIG);
|
||||
if(!file.exists()){
|
||||
file.createNewFile();
|
||||
}
|
||||
file=new File(DATA);
|
||||
if(!file.exists()){
|
||||
file.createNewFile();
|
||||
}
|
||||
file=null;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public static Object load(String type,String key){
|
||||
File file=new File(type);
|
||||
//System.out.println(type+"配置文件地址:"+file.getAbsolutePath());
|
||||
String src=readFile(file);
|
||||
if(src!=null){
|
||||
try {
|
||||
JSONObject json=JSONObject.parseObject(src);
|
||||
if(json==null){
|
||||
json=new JSONObject();
|
||||
saveFile(file,json.toJSONString());
|
||||
}
|
||||
return json.getOrDefault(key, "");
|
||||
}catch (Exception e){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public static boolean save(String type,String key,Object data){
|
||||
File file=new File(type);
|
||||
String src=readFile(file);
|
||||
if(src==null){
|
||||
src="{}";
|
||||
}
|
||||
JSONObject json=JSONObject.parseObject(src);
|
||||
json.put(key,data);
|
||||
saveFile(file,json.toJSONString());
|
||||
return false;
|
||||
}
|
||||
public static boolean saveFile(File file,String data){
|
||||
try {
|
||||
FileWriter writer=new FileWriter(file);
|
||||
writer.write(data);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static String readFile(File file){
|
||||
try {
|
||||
BufferedReader reader=new BufferedReader(new FileReader(file));
|
||||
String tmp;
|
||||
StringBuilder str= new StringBuilder();
|
||||
while ((tmp=reader.readLine())!=null){
|
||||
str.append(tmp);
|
||||
}
|
||||
reader.close();
|
||||
return str.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
27
src/main/java/com/yutou/nas/utils/CorsConfig.java
Normal file
27
src/main/java/com/yutou/nas/utils/CorsConfig.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
// 设置允许跨域请求的域名
|
||||
.allowedOriginPatterns("*")
|
||||
// 是否允许证书(cookies)
|
||||
.allowCredentials(true)
|
||||
// 设置允许的方法
|
||||
.allowedMethods("*")
|
||||
// 跨域允许时间
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
132
src/main/java/com/yutou/nas/utils/HttpTools.java
Normal file
132
src/main/java/com/yutou/nas/utils/HttpTools.java
Normal file
@ -0,0 +1,132 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.nas.utils.Interfaces.NetworkInterface;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Set;
|
||||
|
||||
public class HttpTools {
|
||||
public static String get(String url) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setRequestProperty("User-Agent", getKuKuUA());
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder str = new StringBuilder();
|
||||
String tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str.append(tmp);
|
||||
}
|
||||
reader.close();
|
||||
connection.disconnect();
|
||||
return str.toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void post(final String url, final byte[] body, final NetworkInterface networkInterface) {
|
||||
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder();
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setConnectTimeout(5 * 1000);
|
||||
connection.setReadTimeout(10 * 1000);
|
||||
//connection.addRequestProperty("Connection", "keep-alive");
|
||||
//connection.addRequestProperty("User-Agent", getExtUa());
|
||||
//connection.addRequestProperty("content-type", "application/json");
|
||||
connection.addRequestProperty("charset", "UTF-8");
|
||||
OutputStream outputStream = connection.getOutputStream();
|
||||
|
||||
outputStream.write(body);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str.append(tmp);
|
||||
}
|
||||
final String finalStr = str.toString();
|
||||
|
||||
// Log.i(TAG + "[" + url + "?" + toGetSplice(body) + "]", "body:" + str + " (" + connection.getResponseCode() + ")");
|
||||
if (networkInterface != null) {
|
||||
try {
|
||||
networkInterface.httpGetData(str.toString(), connection.getResponseCode());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
connection.disconnect();
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static String getExtUa() {
|
||||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36";
|
||||
}
|
||||
|
||||
private static String getKuKuUA() {
|
||||
return "/KUKU_APP(Android/#/cn.kuku.sdk/ttsdk17228/29401/A-2.9.4.01.KUSDK/868139039134314/fcddf839c8c135fa/F4:60:E2:AB:25:1A/460019406520644/+8618569400341/#/9/Redmi 6 Pro/xiaomi/1736/76fda4d6-cd6b-485f-987b-8d347b007f24/#/KUKU/Native/92972ea9651fbd2e)";
|
||||
}
|
||||
|
||||
public String toUrlParams(JSONObject json) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
Set<String> keys = json.keySet();
|
||||
for (String key : keys) {
|
||||
try {
|
||||
string.append("&").append(key).append("=").append(URLEncoder.encode(json.getString(key), "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
string.append("&").append(URLEncoder.encode(key, "UTF-8")).append("=");
|
||||
// string += "&" + key + "=";
|
||||
} catch (Exception e1) {
|
||||
string.append("&").append(key).append("=");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string = new StringBuilder(string.substring(1, string.length()).replaceAll(" ", ""));
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("pid", "102");
|
||||
json.put("gid", "100584");
|
||||
json.put("gameKey", "0gha58u1c9FjZkeAsEmYIzTvp");
|
||||
json.put("access_token", "659c-S1gV0DwMXdYjPDlSrSLNYOvA8qUoCSvmdFEHvZugKgNX4Z2BCwF18A7W2gRdG7WiWfKsbZgF6YssZHhaozksI9RBn2QQFTXzmAHtbMd4ginEEtwdKmPCM4JbJGg1ollqoNE0PcGENpa4F3e7EdSOa_JFyE6XyUQN1iurJU3F8MZfLlTIcTR9USYoHX15vsAkCht_0mrapZblkeY1_8HFrmK8rlenbZLxccy7PrMz5eZ9uPPDJL5OYiEahyrtLENB8SVmlGofJfQw8wUjN8_XVZSfLMujdwz24");
|
||||
String url = "http://192.168.1.156:9020/Faxing/reg?" +
|
||||
"&tpyeCode=dimai" +
|
||||
"®ParamJson=" + json.toJSONString();
|
||||
/* ExecutorService service= Executors.newCachedThreadPool();
|
||||
for (int i = 0; i < 3000; i++) {
|
||||
service.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
get(url);
|
||||
}
|
||||
});
|
||||
}*/
|
||||
System.out.println(url);
|
||||
//String str=get(url);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.yutou.nas.utils.Interfaces;
|
||||
|
||||
|
||||
import com.yutou.nas.mybatis.model.MusicData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMusicToolsService {
|
||||
void init();
|
||||
|
||||
void scanMusic();
|
||||
|
||||
List<MusicData> getPath(String path, boolean isDir);
|
||||
|
||||
MusicData getMusicData(String md5);
|
||||
|
||||
List<MusicData> findOfTitle(String title);
|
||||
|
||||
List<MusicData> findOfArtist(String by);
|
||||
|
||||
List<MusicData> getMusicList();
|
||||
|
||||
int getLength();
|
||||
|
||||
boolean isScan();
|
||||
|
||||
String getMusicPath();
|
||||
|
||||
byte[] readImage(String path) throws Exception;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.yutou.nas.utils.Interfaces;
|
||||
|
||||
public interface NetworkInterface {
|
||||
/**
|
||||
* 请求成功
|
||||
* @param data 请求参数
|
||||
* @param state http状态
|
||||
*/
|
||||
void httpGetData(Object data, int state);
|
||||
|
||||
/**
|
||||
* 请求异常
|
||||
* @param e 异常
|
||||
*/
|
||||
void httpError(Exception e);
|
||||
}
|
545
src/main/java/com/yutou/nas/utils/MusicToolsServiceImpl.java
Normal file
545
src/main/java/com/yutou/nas/utils/MusicToolsServiceImpl.java
Normal file
@ -0,0 +1,545 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.yutou.nas.Datas.AppData;
|
||||
import com.yutou.nas.mybatis.dao.MusicDataDao;
|
||||
import com.yutou.nas.mybatis.model.MusicData;
|
||||
import com.yutou.nas.mybatis.model.MusicDataExample;
|
||||
import com.yutou.nas.utils.Interfaces.IMusicToolsService;
|
||||
|
||||
import ealvatag.audio.AudioFile;
|
||||
import ealvatag.audio.AudioFileIO;
|
||||
import ealvatag.audio.AudioHeader;
|
||||
import ealvatag.tag.FieldKey;
|
||||
import ealvatag.tag.NullTag;
|
||||
import ealvatag.tag.Tag;
|
||||
import ealvatag.tag.images.NullArtwork;
|
||||
import net.bramp.ffmpeg.FFprobe;
|
||||
import net.bramp.ffmpeg.probe.FFmpegFormat;
|
||||
import net.bramp.ffmpeg.probe.FFmpegProbeResult;
|
||||
import net.bramp.ffmpeg.probe.FFmpegStream;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service("MusicToolsService")
|
||||
public class MusicToolsServiceImpl implements IMusicToolsService {
|
||||
public static final int FIND_TITLE = 1;
|
||||
public static final int FIND_ARTIST = 2;
|
||||
|
||||
private String musicPath = "/media/yutou/4t/public/音乐";
|
||||
private boolean isScan = false;
|
||||
|
||||
@Resource
|
||||
MusicDataDao musicDataDao;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
scanMusic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanMusic() {
|
||||
if (isScan) {
|
||||
return;
|
||||
}
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "musicScan").equals("false")) {
|
||||
return;
|
||||
}
|
||||
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||
musicDataDao.truncate();
|
||||
System.out.println("执行扫描:" + musicPath);
|
||||
new Thread(() -> {
|
||||
long startTime = System.currentTimeMillis();
|
||||
QQBotManager.getInstance().sendMessage("开始扫描音乐夹");
|
||||
isScan = true;
|
||||
scan(new File(musicPath));
|
||||
isScan = false;
|
||||
System.out.println("扫描完成");
|
||||
QQBotManager.getInstance().sendMessage("音乐扫描完成,共" + getLength() + "首歌,耗时:"
|
||||
+ (System.currentTimeMillis() - startTime));
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
private void scan(File path) {
|
||||
if (path.isFile()) {
|
||||
add(path);
|
||||
} else if (path.isDirectory()) {
|
||||
for (File file : Objects.requireNonNull(path.listFiles())) {
|
||||
if (file.isDirectory()) {
|
||||
scan(file);
|
||||
} else {
|
||||
add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getPathOrDir(String path, List<MusicData> list) {
|
||||
File files = new File(path);
|
||||
for (File file : files.listFiles()) {
|
||||
if (file.isFile()) {
|
||||
list.add(getMetadata(file));
|
||||
} else {
|
||||
getPathOrDir(file.getAbsolutePath(), list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定目录下的音乐
|
||||
*
|
||||
* @param path 指定目录
|
||||
* @param isDir 是否扫描目录下的所有文件,false则仅为当前目录
|
||||
* @return 音乐列表
|
||||
*/
|
||||
@Override
|
||||
public List<MusicData> getPath(String path, boolean isDir) {
|
||||
List<MusicData> list = new ArrayList<>();
|
||||
List<MusicData> main = new ArrayList<>();
|
||||
MusicDataExample example = new MusicDataExample();
|
||||
String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/";
|
||||
String tmpPath = path;
|
||||
if (isDir) {
|
||||
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%");
|
||||
main = musicDataDao.selectByExample(example);
|
||||
}
|
||||
tmpPath = tmpPath.replace(File.separator, replacement)
|
||||
.replace("[", "\\[")
|
||||
.replace("(", "\\(")
|
||||
.replace(")", "\\)")
|
||||
.replace("]", "\\]");
|
||||
main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$"));
|
||||
|
||||
if (!path.equals(AppData.defaultMusicPath) && !path.equals("root")) {
|
||||
MusicData t2 = new MusicData();
|
||||
t2.setTitle("返回");
|
||||
if (main.isEmpty()) {
|
||||
t2.setFile("root");
|
||||
} else {
|
||||
MusicData tmp = main.get(0);
|
||||
t2.setFile(new File(tmp.getLastdir()).getAbsolutePath());
|
||||
}
|
||||
System.out.println("查询地址:" + path + " 设置返回地址:" + t2.getFile());
|
||||
t2.setIsdir(1);
|
||||
list.add(t2);
|
||||
}
|
||||
getDirList(path, list);
|
||||
list.addAll(main);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> getAllAlbum() {
|
||||
return musicDataDao.selectAllAlbum();
|
||||
}
|
||||
|
||||
public List<String> getAllArtist() {
|
||||
return musicDataDao.selectAllArtist();
|
||||
}
|
||||
|
||||
public List<MusicData> selectAlbum(String album) {
|
||||
return musicDataDao.selectAlbum(album);
|
||||
}
|
||||
|
||||
public List<MusicData> selectArtist(String artist) {
|
||||
return musicDataDao.selectArtist(artist);
|
||||
}
|
||||
|
||||
private void getDirList(String path, List<MusicData> list) {
|
||||
File file = new File(path);
|
||||
System.out.println("扫描文件:"+path);
|
||||
if(file.isDirectory()) {
|
||||
for (File listFile : file.listFiles()) {
|
||||
if (listFile.isDirectory()) {
|
||||
MusicData data = new MusicData();
|
||||
data.setTitle(listFile.getName());
|
||||
data.setIsdir(1);
|
||||
data.setFile(listFile.getAbsolutePath());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
MusicData data = new MusicData();
|
||||
data.setTitle(file.getName());
|
||||
data.setIsdir(0);
|
||||
data.setFile(file.getAbsolutePath());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(File file) {
|
||||
MusicData data = getMetadata(file);
|
||||
if (data != null) {
|
||||
try {
|
||||
musicDataDao.insert(data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
QQBotManager.getInstance().sendMessage("音乐文件添加失败:" + data.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicData getMusicData(String path) {
|
||||
MusicDataExample example = new MusicDataExample();
|
||||
example.createCriteria().andFileEqualTo(path);
|
||||
List<MusicData> list = musicDataDao.selectByExample(example);
|
||||
if (list != null && list.size() > 0) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public MusicData getMetadata(File file) {
|
||||
try {
|
||||
if (file.getName().endsWith(".lrc")
|
||||
|| file.getName().endsWith(".jpg")
|
||||
|| file.getName().endsWith(".ini")
|
||||
|| file.getName().endsWith(".png")
|
||||
|| file.getName().endsWith(".torrent")
|
||||
|| file.getName().endsWith(".log")
|
||||
|| file.getName().endsWith(".mkv")
|
||||
|| file.getName().endsWith(".dff")
|
||||
|| file.getName().endsWith(".cue")
|
||||
|| file.getName().endsWith(".m3u")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AudioFile audioFile = AudioFileIO.read(file);
|
||||
Tag tag = audioFile.getTag().or(NullTag.INSTANCE);
|
||||
MusicData data = new MusicData();
|
||||
try {
|
||||
data.setAlbum(tag.getFirst(FieldKey.ALBUM));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setArtist(tag.getFirst(FieldKey.ARTIST));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setArtistSort(tag.getFirst(FieldKey.ARTIST_SORT));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setComment(tag.getFirst(FieldKey.COMMENT));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setComposer(tag.getFirst(FieldKey.COMPOSER));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setDiscNo(tag.getFirst(FieldKey.DISC_NO));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (StringUtils.isEmpty(tag.getFirst(FieldKey.TITLE))) {
|
||||
data.setTitle(file.getName());
|
||||
} else {
|
||||
data.setTitle(tag.getFirst(FieldKey.TITLE));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
data.setTitle(file.getName());
|
||||
}
|
||||
try {
|
||||
data.setTrack(tag.getFirst(FieldKey.TRACK));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
data.setYear(tag.getFirst(FieldKey.YEAR));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
data.setFile(file.getAbsolutePath());
|
||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||
data.setLastdir(file.getParentFile().getParent());
|
||||
|
||||
AudioHeader header = audioFile.getAudioHeader();
|
||||
data.setBitrate(header.getBitRate());
|
||||
data.setSamplerate(header.getSampleRate());
|
||||
data.setNoofsamples(header.getNoOfSamples());
|
||||
data.setChannelcount(header.getChannelCount());
|
||||
data.setEncodingtype(header.getEncodingType());
|
||||
data.setDurationasdouble(header.getDurationAsDouble());
|
||||
data.setLossless(header.isLossless() ? 1 : 0);
|
||||
data.setVariablebitrate(header.isVariableBitRate() ? 1 : 0);
|
||||
try {
|
||||
data.setMd5(header.getClass().getMethod("getMd5").invoke(header).toString());
|
||||
} catch (Exception ignored) {
|
||||
data.setMd5(Tools.getFileMD5(file));
|
||||
}
|
||||
return data;
|
||||
} catch (IOException e) {
|
||||
return getMetadata_jthink(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MusicData getMetadata_jthink(File file) {
|
||||
try {
|
||||
org.jaudiotagger.audio.AudioFile audioFile = org.jaudiotagger.audio.AudioFileIO.read(file);
|
||||
org.jaudiotagger.tag.Tag tag = audioFile.getTag();
|
||||
MusicData data = new MusicData();
|
||||
try {
|
||||
data.setAlbum(tag.getFirst(org.jaudiotagger.tag.FieldKey.ALBUM));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setArtist(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setArtistSort(tag.getFirst(org.jaudiotagger.tag.FieldKey.ARTIST_SORT));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setComment(tag.getFirst(org.jaudiotagger.tag.FieldKey.COMMENT));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setComposer(tag.getFirst(org.jaudiotagger.tag.FieldKey.COMPOSER));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setDiscNo(tag.getFirst(org.jaudiotagger.tag.FieldKey.DISC_NO));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
if (StringUtils.isEmpty(tag.getFirst(org.jaudiotagger.tag.FieldKey.TITLE))) {
|
||||
data.setTitle(file.getName());
|
||||
} else {
|
||||
data.setTitle(tag.getFirst(org.jaudiotagger.tag.FieldKey.TITLE));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
data.setTitle(file.getName());
|
||||
}
|
||||
try {
|
||||
data.setTrack(tag.getFirst(org.jaudiotagger.tag.FieldKey.TRACK));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
data.setYear(tag.getFirst(org.jaudiotagger.tag.FieldKey.YEAR));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
data.setFile(file.getAbsolutePath());
|
||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||
data.setLastdir(file.getParentFile().getParent());
|
||||
|
||||
org.jaudiotagger.audio.AudioHeader header = audioFile.getAudioHeader();
|
||||
data.setBitrate(Integer.parseInt(header.getBitRate()));
|
||||
data.setSamplerate(Integer.parseInt(header.getSampleRate()));
|
||||
data.setNoofsamples(Long.parseLong(header.getSampleRateAsNumber() + ""));
|
||||
data.setChannelcount(Integer.parseInt(header.getChannels()));
|
||||
data.setEncodingtype(header.getEncodingType() + "");
|
||||
data.setDurationasdouble(Double.parseDouble(header.getTrackLength() + ""));
|
||||
data.setLossless(header.isLossless() ? 1 : 0);
|
||||
data.setVariablebitrate(header.isVariableBitRate() ? 1 : 0);
|
||||
try {
|
||||
data.setMd5(header.getClass().getMethod("getMd5").invoke(header).toString());
|
||||
} catch (Exception ignored) {
|
||||
data.setMd5(Tools.getFileMD5(file));
|
||||
}
|
||||
return data;
|
||||
} catch (Exception e) {
|
||||
return getMetadataOfFFmpeg(file);
|
||||
}
|
||||
}
|
||||
|
||||
private MusicData getMetadataOfFFmpeg(File file) {
|
||||
MusicData data;
|
||||
try {
|
||||
data = new MusicData();
|
||||
FFprobe fFprobe = new FFprobe((String) ConfigTools.load(ConfigTools.CONFIG, "ffprobe"));
|
||||
FFmpegProbeResult result = fFprobe.probe(file.getAbsolutePath());
|
||||
FFmpegFormat format = result.getFormat();
|
||||
FFmpegStream stream = null;
|
||||
for (FFmpegStream tmp : result.getStreams()) {
|
||||
if (tmp.index == 0) {
|
||||
stream = tmp;
|
||||
}
|
||||
}
|
||||
Map<String, String> tag = format.tags;
|
||||
data.setTitle(getTitle(tag));
|
||||
data.setAlbum(getAlbum(tag));
|
||||
data.setArtist(getArtist(tag));
|
||||
data.setDiscNo(tag.get("disc") == null ? tag.get("disc".toUpperCase()) : tag.get("disc"));
|
||||
data.setTrack(tag.get("track") == null ? tag.get("track".toUpperCase()) : tag.get("track"));
|
||||
data.setYear(getYear(tag));
|
||||
data.setArtistSort(tag.get("album_artist") == null ? tag.get("album_artist".toUpperCase()) : tag.get("album_artist"));
|
||||
data.setDurationasdouble(format.duration);
|
||||
data.setBitrate((int) (format.bit_rate / 1000));
|
||||
if (stream != null) {
|
||||
if (data.getBitrate() == 0)
|
||||
data.setBitrate((int) (stream.bit_rate / 1000));
|
||||
data.setChannelcount(stream.channels);
|
||||
data.setLossless(0);
|
||||
data.setSamplerate(stream.sample_rate);
|
||||
data.setNoofsamples(stream.duration_ts);
|
||||
}
|
||||
data.setEncodingtype(format.format_long_name);
|
||||
data.setComment("");
|
||||
data.setComposer("");
|
||||
data.setVariablebitrate(0);
|
||||
data.setFile(file.getAbsolutePath());
|
||||
data.setLastdir(file.getParentFile().getParent());
|
||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||
if (data.getYear() == null) {
|
||||
data.setYear("0000");
|
||||
}
|
||||
data.setMd5(Tools.getFileMD5(file));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
data = new MusicData();
|
||||
data.setTitle(file.getName());
|
||||
data.setFile(file.getAbsolutePath());
|
||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||
data.setLastdir(file.getParentFile().getParent());
|
||||
data.setMd5(Tools.getFileMD5(file));
|
||||
QQBotManager.getInstance().sendMessage("添加音乐文件失败:\n" + data.toString() + "\n" + Tools.getExceptionString(e));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private String getTitle(Map<String, String> tag) {
|
||||
String title = tag.get("title");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("TITLE");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("Title");
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
private String getArtist(Map<String, String> tag) {
|
||||
String title = tag.get("artist");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("ARTIST");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("Artist");
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
private String getAlbum(Map<String, String> tag) {
|
||||
String title = tag.get("album");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("ALBUM");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("Album");
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
private String getYear(Map<String, String> tag) {
|
||||
String title = tag.get("year");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("YEAR");
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
title = tag.get("Year");
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MusicData> findOfTitle(String title) {
|
||||
return find(title, FIND_TITLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MusicData> findOfArtist(String by) {
|
||||
return find(by, FIND_ARTIST);
|
||||
}
|
||||
|
||||
public List<MusicData> getMusicList() {
|
||||
return musicDataDao.selectByExample(new MusicDataExample());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLength() {
|
||||
return musicDataDao.selectByExample(new MusicDataExample()).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScan() {
|
||||
return isScan;
|
||||
}
|
||||
|
||||
private List<MusicData> find(String title, int type) {
|
||||
List<MusicData> list;
|
||||
MusicDataExample example = new MusicDataExample();
|
||||
if (type == FIND_TITLE) {
|
||||
example.createCriteria().andTitleEqualTo(title);
|
||||
} else if (type == FIND_ARTIST) {
|
||||
example.createCriteria().andArtistEqualTo(title);
|
||||
}
|
||||
list = musicDataDao.selectByExample(example);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMusicPath() {
|
||||
return musicPath;
|
||||
}
|
||||
|
||||
public void setMusicPath(String musicPath) {
|
||||
this.musicPath = musicPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readImage(String path) throws Exception {
|
||||
File file = new File(path);
|
||||
AudioFile audioFile = null;
|
||||
audioFile = AudioFileIO.read(file);
|
||||
Tag tag = audioFile.getTag().or(NullTag.INSTANCE);
|
||||
byte[] bytes = tag.getFirstArtwork().or(NullArtwork.INSTANCE).getBinaryData();
|
||||
if (bytes.length == 0) {
|
||||
return readImageFile(file);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private byte[] readImageFile(File file) throws Exception {
|
||||
String path = file.getAbsolutePath().replace(file.getName(), "");
|
||||
File img = new File(path, "cover.jpg");
|
||||
if (!img.exists()) {
|
||||
img = new File(path, "Cover.jpg");
|
||||
if (!img.exists()) {
|
||||
img = new File(path, "COVER.jpg");
|
||||
if (!img.exists()) {
|
||||
throw new NullPointerException("没有cover文件");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Files.readAllBytes(Paths.get(img.getAbsolutePath()));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File("Z:\\音乐\\总之就是非常酸\\ED\\カノエラナ - 月と星空\\カノエラナ.wav");
|
||||
file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac");
|
||||
// file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape");
|
||||
System.out.println(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file));
|
||||
}
|
||||
|
||||
|
||||
}
|
339
src/main/java/com/yutou/nas/utils/QQBotManager.java
Normal file
339
src/main/java/com/yutou/nas/utils/QQBotManager.java
Normal file
@ -0,0 +1,339 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.yutou.nas.NasApplication;
|
||||
import com.yutou.nas.bangumi.BangumiTools;
|
||||
import com.yutou.nas.interfaces.DownloadInterface;
|
||||
import com.yutou.nas.other.QQAudio;
|
||||
import com.yutou.nas.other.QQSetu;
|
||||
import net.mamoe.mirai.Bot;
|
||||
import net.mamoe.mirai.BotFactory;
|
||||
import net.mamoe.mirai.event.GlobalEventChannel;
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent;
|
||||
import net.mamoe.mirai.message.data.Image;
|
||||
import net.mamoe.mirai.message.data.MessageChainBuilder;
|
||||
import net.mamoe.mirai.utils.BotConfiguration;
|
||||
import net.mamoe.mirai.utils.ExternalResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class QQBotManager {
|
||||
|
||||
|
||||
private static class QQCommands {
|
||||
private final static String QQ_HELP = "!help";
|
||||
private final static String QQ_UPDATE_IP = "!更新ip";
|
||||
private final static String QQ_GET_IP = "!ip";
|
||||
private final static String QQ_OPEN_PC = "!开机";
|
||||
private final static String QQ_GET_VERSION = "!version";
|
||||
private final static String QQ_CMD = "!cmd";
|
||||
private final static String QQ_BANGUMI_TODAY = "!今日动画";
|
||||
private final static String QQ_BANGUMI_LIST = "!新番";
|
||||
private final static String QQ_BANGUMI_SUB = "!查动画";
|
||||
private final static String QQ_AUDIO = "!语音";
|
||||
private final static String QQ_AUDIO_OPEN_LAMP = "!开灯";
|
||||
private final static String QQ_AUDIO_OPEN_AIR = "!开空调";
|
||||
}
|
||||
|
||||
private static QQBotManager botManager = null;
|
||||
private Bot bot;
|
||||
private static final long qqGroup = 891655174L;
|
||||
private boolean isLogin = false;
|
||||
private static boolean isInit = false;
|
||||
|
||||
|
||||
private QQBotManager() {
|
||||
Object isRun = ConfigTools.load(ConfigTools.CONFIG, "qq_bot");
|
||||
if (isRun != null && (boolean) isRun) {
|
||||
isLogin = true;
|
||||
isInit = true;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long qq = 2476945931L;
|
||||
String password = "zhang34864394";
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("dev")) {
|
||||
qq = 3620756944L;
|
||||
password = "UAs6YBYMyxJU";
|
||||
}
|
||||
|
||||
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
|
||||
{
|
||||
setProtocol(MiraiProtocol.ANDROID_PAD);
|
||||
fileBasedDeviceInfo("qq_bot_devices_info.json");
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
|
||||
noBotLog();
|
||||
noNetworkLog();
|
||||
}
|
||||
}
|
||||
});
|
||||
//Events.registerEvents(bot, new MessageListener());
|
||||
GlobalEventChannel.INSTANCE.subscribeAlways(GroupMessageEvent.class, new MessageListener());
|
||||
bot.login();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String str = sendMessage("姬妻酱上线拉~");
|
||||
System.out.println(str);
|
||||
|
||||
}
|
||||
}).start();
|
||||
bot.join();
|
||||
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
public static QQBotManager getInstance() {
|
||||
if (botManager == null && !isInit) {
|
||||
botManager = new QQBotManager();
|
||||
}
|
||||
return botManager;
|
||||
}
|
||||
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
private Image getImage(File file) {
|
||||
if (bot != null) {
|
||||
return Objects.requireNonNull(bot.getGroup(qqGroup)).uploadImage(ExternalResource.create(file));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getNotLoginQQ() {
|
||||
return "没有登录QQ";
|
||||
}
|
||||
|
||||
public void reportToDayBangumi() {
|
||||
getInstance().sendMessage(BangumiTools.reportToDayBangumi());
|
||||
}
|
||||
|
||||
public String sendMessage(String text) {
|
||||
if (bot != null) {
|
||||
try {
|
||||
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(text).toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return getNotLoginQQ();
|
||||
}
|
||||
|
||||
public String sendMessage(Long group, String text) {
|
||||
if (bot != null) {
|
||||
try {
|
||||
return Objects.requireNonNull(bot.getGroup(group)).sendMessage(text).toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return getNotLoginQQ();
|
||||
}
|
||||
|
||||
public void sendMessage(Long group, MessageChainBuilder builder) {
|
||||
if (bot != null) {
|
||||
Objects.requireNonNull(bot.getGroup(group)).sendMessage(builder.asMessageChain());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String sendMessage(File imageFile, String text) {
|
||||
try {
|
||||
if (bot != null) {
|
||||
Image image = getImage(imageFile);
|
||||
MessageChainBuilder builder = new MessageChainBuilder();
|
||||
if (image != null) {
|
||||
builder.append(image);
|
||||
}
|
||||
builder.append(text);
|
||||
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(builder.asMessageChain()).toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return getNotLoginQQ();
|
||||
}
|
||||
|
||||
public String sendMessage(List<File> imgs, String text) {
|
||||
if (bot != null) {
|
||||
MessageChainBuilder builder = new MessageChainBuilder();
|
||||
for (File img : imgs) {
|
||||
builder.append(Objects.requireNonNull(getImage(img)));
|
||||
}
|
||||
builder.append(text);
|
||||
return Objects.requireNonNull(bot.getGroup(qqGroup)).sendMessage(builder.asMessageChain()).toString();
|
||||
}
|
||||
return getNotLoginQQ();
|
||||
}
|
||||
|
||||
public static List<String> getImages(String str) {
|
||||
List<String> list = new ArrayList<>();
|
||||
String regex = "<img(.*?)/img>";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
while (matcher.find()) {
|
||||
list.add(matcher.group().replace("<img", "")
|
||||
.replace("/img>", "")
|
||||
.trim());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
getInstance();
|
||||
}
|
||||
|
||||
private static class MessageListener implements Consumer<GroupMessageEvent> {
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(GroupMessageEvent event) {
|
||||
String msg = event.getMessage().contentToString();
|
||||
switch (event.getGroup().getId() + "") {
|
||||
case qqGroup + "":
|
||||
myGroup(msg);
|
||||
case "570197155":
|
||||
new QQSetu().setu(msg, event);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void myGroup(String msg) {
|
||||
msg = msg.replace("!", "!").toLowerCase();
|
||||
switch (msg) {
|
||||
case QQCommands.QQ_OPEN_PC:
|
||||
RedisTools.Consumer.system("openPC", null);
|
||||
String time = new SimpleDateFormat("HH").format(new Date());
|
||||
if (Integer.parseInt(time) < 18) {
|
||||
break;
|
||||
}
|
||||
case QQCommands.QQ_AUDIO_OPEN_LAMP:
|
||||
QQAudio.playText("小爱同学,开灯");
|
||||
break;
|
||||
case QQCommands.QQ_AUDIO_OPEN_AIR:
|
||||
QQAudio.playText("小爱同学,开空调");
|
||||
break;
|
||||
case QQCommands.QQ_UPDATE_IP:
|
||||
RedisTools.Consumer.system("updateIP", null);
|
||||
break;
|
||||
case QQCommands.QQ_GET_IP:
|
||||
RedisTools.Consumer.bot("getip");
|
||||
break;
|
||||
case QQCommands.QQ_GET_VERSION:
|
||||
sendVersion();
|
||||
break;
|
||||
case QQCommands.QQ_BANGUMI_TODAY:
|
||||
QQBotManager.getInstance().sendMessage(BangumiTools.reportToDayBangumi());
|
||||
break;
|
||||
case QQCommands.QQ_BANGUMI_LIST:
|
||||
getInstance().sendMessage("获取中...");
|
||||
getInstance().sendMessage(BangumiTools.reportBangumiList());
|
||||
break;
|
||||
|
||||
case QQCommands.QQ_HELP:
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Field field : QQCommands.class.getDeclaredFields()) {
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
builder.append(field.get(null)).append("\n");
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getInstance().sendMessage(builder.toString());
|
||||
break;
|
||||
default:
|
||||
if (msg.startsWith(QQCommands.QQ_CMD)) {
|
||||
RedisTools.Consumer.system("cmd", msg.replace(QQCommands.QQ_CMD, ""));
|
||||
} else if (msg.startsWith(QQCommands.QQ_BANGUMI_SUB)) {
|
||||
String info = null;
|
||||
try {
|
||||
int id = Integer.parseInt(msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim());
|
||||
info = BangumiTools.reportBangumiInfo(id);
|
||||
} catch (Exception e) {
|
||||
String key = msg.replace(QQCommands.QQ_BANGUMI_SUB, "").trim();
|
||||
info = BangumiTools.reportSearchBangumi(key);
|
||||
}
|
||||
List<String> imgs = new ArrayList<>();
|
||||
if (info.contains("<img") && info.contains(" /img>")) {
|
||||
imgs = getImages(info);
|
||||
for (String img : imgs) {
|
||||
info = info.replace("<img " + img + " /img>", "");
|
||||
}
|
||||
}
|
||||
sendImagesMsg(imgs, info);
|
||||
} else if (msg.startsWith(QQCommands.QQ_AUDIO)) {
|
||||
QQAudio.playText(msg.replace(QQCommands.QQ_AUDIO, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<File> files;
|
||||
private int index = 0;
|
||||
|
||||
private void sendImagesMsg(List<String> imgs, String text) {
|
||||
files = new ArrayList<>();
|
||||
index = 0;
|
||||
if (imgs.size() == 0) {
|
||||
getInstance().sendMessage(text);
|
||||
return;
|
||||
}
|
||||
for (String img : imgs) {
|
||||
Tools.download(img, new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(String file) {
|
||||
super.onDownload(file);
|
||||
files.add(new File(file));
|
||||
send(imgs.size(), text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
super.onError(e);
|
||||
index++;
|
||||
send(imgs.size(), text);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void send(int size, String text) {
|
||||
if ((files.size() + index) == size) {
|
||||
String str = getInstance().sendMessage(files, text);
|
||||
System.out.println("str = " + str);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendVersion() {
|
||||
String localVersion = NasApplication.version;
|
||||
String serverVersion = HttpTools.get("http://tools.yutou233.cn:8000/public/version.do?token=zIrsh9TUZP2lfRW753PannG49E7VJvor");
|
||||
String msg = "本地版本:" + localVersion + "\n" + "服务器版本:" + serverVersion;
|
||||
QQBotManager.getInstance().sendMessage(msg);
|
||||
Tools.sendServer("服务版本查询", msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
298
src/main/java/com/yutou/nas/utils/RedisTools.java
Normal file
298
src/main/java/com/yutou/nas/utils/RedisTools.java
Normal file
@ -0,0 +1,298 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class RedisTools {
|
||||
private static boolean isNotInstallRedis = false;
|
||||
private static String host;
|
||||
private static int port;
|
||||
public static int TOKEN_TIMEOUT_DEFAULT = 360;
|
||||
|
||||
private RedisTools() {
|
||||
|
||||
}
|
||||
|
||||
// 写成静态代码块形式,只加载一次,节省资源
|
||||
static {
|
||||
//Properties properties = PropertyUtil.loadProperties("jedis.properties");
|
||||
//host = properties.getProperty("redis.host");
|
||||
//port = Integer.valueOf(properties.getProperty("redis.port"));
|
||||
host = "127.0.0.1";
|
||||
port = 6379;
|
||||
}
|
||||
|
||||
public static boolean set(int dbIndex, String key, String value) {
|
||||
try {
|
||||
if (isNotInstallRedis) {
|
||||
return false;
|
||||
}
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(dbIndex);
|
||||
String ret = jedis.set(key, value);
|
||||
System.out.println("Redis set =" + ret);
|
||||
jedis.close();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean set(String key, String value) {
|
||||
return set(0, key, value);
|
||||
}
|
||||
|
||||
public static boolean set(String key, String value, int timeout) {
|
||||
try {
|
||||
if (isNotInstallRedis) {
|
||||
return false;
|
||||
}
|
||||
Jedis jedis = getRedis();
|
||||
if (timeout == -1) {
|
||||
jedis.set(key, value);
|
||||
} else {
|
||||
jedis.setex(key, timeout, value);
|
||||
}
|
||||
jedis.close();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String get(String key, int dbIndex) {
|
||||
String value = "-999";
|
||||
if (isNotInstallRedis) {
|
||||
return value;
|
||||
}
|
||||
try (Jedis jedis = getRedis()) {
|
||||
jedis.select(dbIndex);
|
||||
value = jedis.get(key);
|
||||
jedis.close();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
return get(key, 0);
|
||||
}
|
||||
|
||||
public static boolean remove(String key) {
|
||||
return remove(key,0);
|
||||
}
|
||||
|
||||
public static void removeLoginState(String uid) {
|
||||
Jedis jedis = getRedis();
|
||||
Set<String> keys = jedis.keys("*");
|
||||
for (String string : keys) {
|
||||
if (string.equals(uid)) {
|
||||
jedis.del(string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String ping() {
|
||||
Jedis jedis = getRedis();
|
||||
String tmp = jedis.ping();
|
||||
jedis.close();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public static boolean exists(String key, String value) {
|
||||
if (isNotInstallRedis) {
|
||||
return false;
|
||||
}
|
||||
Jedis jedis = getRedis();
|
||||
boolean flag = value.equals(jedis.get(key));
|
||||
jedis.close();
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static Jedis getRedis() {
|
||||
return new Jedis(host, port);
|
||||
}
|
||||
|
||||
public static boolean remove(String key, int index) {
|
||||
if (isNotInstallRedis) {
|
||||
return false;
|
||||
}
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(index);
|
||||
Long i = jedis.del(key);
|
||||
jedis.close();
|
||||
if (i > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PropertyUtil {
|
||||
|
||||
// 加载property文件到io流里面
|
||||
public static Properties loadProperties(String propertyFile) {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
InputStream is = PropertyUtil.class.getClassLoader().getResourceAsStream(propertyFile);
|
||||
if (is == null) {
|
||||
is = PropertyUtil.class.getClassLoader().getResourceAsStream(propertyFile);
|
||||
}
|
||||
properties.load(is);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
private static Jedis getPoolRedis() {
|
||||
if (isNotInstallRedis) {
|
||||
return null;
|
||||
}
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxIdle(0);
|
||||
poolConfig.setMaxWaitMillis(1000);
|
||||
JedisPool pool = new JedisPool(poolConfig, host);
|
||||
return pool.getResource();
|
||||
}
|
||||
|
||||
public static void pullMsg(String channel, String msg) {
|
||||
System.out.println("1");
|
||||
Jedis jedis = getPoolRedis();
|
||||
System.out.println("2");
|
||||
jedis.publish(channel, msg);
|
||||
System.out.println("3");
|
||||
jedis.close();
|
||||
System.out.println("4");
|
||||
}
|
||||
|
||||
private static boolean init = false;
|
||||
|
||||
public static void initRedisPoolSub() {
|
||||
if (init)
|
||||
return;
|
||||
init = true;
|
||||
System.out.println("初始化订阅");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Jedis jedis = getPoolRedis();
|
||||
if (jedis != null)
|
||||
jedis.psubscribe(new Consumer(), "*");
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
protected static class Consumer extends JedisPubSub {
|
||||
@Override
|
||||
public void onPMessage(String pattern, String channel, String message) {
|
||||
super.onPMessage(pattern, channel, message);
|
||||
System.out.println("onPMessage: channel=" + channel + " msg=" + message + " pattern=" + pattern);
|
||||
switch (channel) {
|
||||
case "system":
|
||||
switch (message) {
|
||||
case "openPC":
|
||||
system("openPC", null);
|
||||
break;
|
||||
case "updateIP":
|
||||
system("updateIP", null);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "bot":
|
||||
bot(message);
|
||||
break;
|
||||
case "cmd":
|
||||
system("cmd", message);
|
||||
break;
|
||||
case "msg":
|
||||
Tools.sendServer("来自服务姬的通知~",message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
super.onMessage(channel, message);
|
||||
System.out.println("onMessage: channel=" + channel + " msg=" + message);
|
||||
}
|
||||
|
||||
public static void system(String type, String value) {
|
||||
try {
|
||||
String exec = null;
|
||||
switch (type) {
|
||||
case "openPC":
|
||||
exec = "wakeonlan 00:D8:61:6F:02:2F";
|
||||
break;
|
||||
case "cmd":
|
||||
exec = value;
|
||||
break;
|
||||
case "updateIP":
|
||||
exec = "python3 /media/yutou/4t/public/Python/tools/ip.py";
|
||||
break;
|
||||
}
|
||||
if (exec != null) {
|
||||
Process process = Runtime.getRuntime().exec(exec);
|
||||
processOut(process.getInputStream());
|
||||
processOut(process.getErrorStream());
|
||||
process.destroy();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void bot(String value) {
|
||||
switch (value) {
|
||||
case "getip":
|
||||
JSONObject json = JSONObject.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
|
||||
String ip = json.getString("ip");
|
||||
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void processOut(InputStream inputStream) {
|
||||
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder("null");
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
str.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("cmd > " + str);
|
||||
QQBotManager.getInstance().sendMessage(str.toString());
|
||||
System.out.println("线程结束");
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
RedisTools.pullMsg("msg", "abc");
|
||||
}
|
||||
}
|
385
src/main/java/com/yutou/nas/utils/Tools.java
Normal file
385
src/main/java/com/yutou/nas/utils/Tools.java
Normal file
@ -0,0 +1,385 @@
|
||||
package com.yutou.nas.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.yutou.nas.Controllers.UpdateIp;
|
||||
import com.yutou.nas.interfaces.DownloadInterface;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
public class Tools {
|
||||
/**
|
||||
* 设置Cookie
|
||||
*
|
||||
* @param response
|
||||
* @param key
|
||||
* @param value
|
||||
* @param time
|
||||
*/
|
||||
public static void setCookie(HttpServletResponse response, String key, String value, int time) {
|
||||
Cookie cookie = new Cookie(key, value);
|
||||
if (time != -1) {
|
||||
cookie.setMaxAge(time);
|
||||
}
|
||||
cookie.setPath("/");
|
||||
response.addCookie(cookie);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Cookie
|
||||
*
|
||||
* @param request
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Cookie getCookie(HttpServletRequest request, String key) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
try {
|
||||
for (Cookie cookie : cookies) {
|
||||
if (key != null && cookie.getName().equals(key)) {
|
||||
return cookie;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Cookie
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String deleteCookie(HttpServletRequest request, HttpServletResponse response, String key) {
|
||||
for (Cookie cookie : request.getCookies()) {
|
||||
if (cookie.getName().equals(key)) {
|
||||
System.out.println("删除key=" + key);
|
||||
cookie.setMaxAge(0);
|
||||
cookie.setPath("/");
|
||||
cookie.setValue(null);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
public static void sendServer(String title, String msg) {
|
||||
try {
|
||||
System.out.println("title=" + title + " msg=" + msg);
|
||||
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
|
||||
("title="+URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8),
|
||||
null);
|
||||
if (ConfigTools.load(ConfigTools.CONFIG, "model").equals("nas")) {
|
||||
String img = null;
|
||||
msg = msg.replace("<br/>", "\n");
|
||||
if (msg.contains("![logo]")) {
|
||||
try {
|
||||
img = msg.split("!\\[logo\\]\\(")[1].split("\\)")[0];
|
||||
msg = msg.replace("![logo](" + img + ")", "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (img == null) {
|
||||
QQBotManager.getInstance().sendMessage(title + "\n" + msg);
|
||||
} else {
|
||||
String finalMsg = msg;
|
||||
String finalImg = img;
|
||||
if (QQBotManager.getInstance().isLogin()) {
|
||||
download(img, new DownloadInterface() {
|
||||
@Override
|
||||
public void onDownload(String file) {
|
||||
super.onDownload(file);
|
||||
QQBotManager.getInstance().sendMessage(new File(file), title + "\n" + finalMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
super.onError(e);
|
||||
QQBotManager.getInstance().sendMessage(title + "\n" + finalMsg + "\n" + finalImg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
|
||||
String img = null;
|
||||
msg = msg.replace("<br/>", "\n");
|
||||
if (msg.contains("![logo]")) {
|
||||
try {
|
||||
img = msg.split("!\\[logo\\]\\(")[1].split("\\)")[0];
|
||||
msg = msg.replace("![logo](" + img + ")", "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String url;
|
||||
if (img == null) {
|
||||
url = "http://" + UpdateIp.nas_ip + ":8000/qq/bot/send.do?msg=" + URLEncoder.encode((title + "\n" + msg), "UTF-8") + "&token=zIrsh9TUZP2lfRW753PannG49E7VJvor";
|
||||
} else {
|
||||
url = "http://" + UpdateIp.nas_ip + ":8000/qq/bot/send.do?msg=" + URLEncoder.encode((title + "\n" + msg), "UTF-8")
|
||||
+ "&imgUrl=" + img
|
||||
+ "&token=zIrsh9TUZP2lfRW753PannG49E7VJvor";
|
||||
}
|
||||
System.out.println(url);
|
||||
HttpTools.get(url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目路径
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getPath(HttpServletRequest request) {
|
||||
return request.getServletContext().getRealPath("/") + "/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端IP
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getRemoteAddress(HttpServletRequest request) {
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* N以内的不重复随机数
|
||||
*
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
* @param n
|
||||
* @return
|
||||
*/
|
||||
public static int[] randomCommon(int min, int max, int n) {
|
||||
int len = max - min + 1;
|
||||
if (max < min || n > len) {
|
||||
return new int[0];
|
||||
}
|
||||
// 初始化给定范围的待选数组
|
||||
int[] source = new int[len];
|
||||
for (int i = min; i < min + len; i++) {
|
||||
source[i - min] = i;
|
||||
}
|
||||
int[] result = new int[n];
|
||||
Random rd = new Random();
|
||||
int index = 0;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
// 待选数组0到(len-2)随机一个下标
|
||||
index = Math.abs(rd.nextInt() % len--);
|
||||
// 将随机到的数放入结果集
|
||||
result[i] = source[index];
|
||||
// 将待选数组中被随机到的数,用待选数组(len-1)下标对应的数替换
|
||||
source[index] = source[len];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int checkWebLogin(HttpServletRequest request) {
|
||||
JSONArray array = new JSONArray();
|
||||
if (RedisTools.get("bean") != null) {
|
||||
array = JSONArray.parseArray(RedisTools.get("bean"));
|
||||
}
|
||||
if (array.contains(Tools.getRemoteAddress(request))) {
|
||||
System.out.println("IP已被封禁");
|
||||
return -100;
|
||||
}
|
||||
Cookie cookie = Tools.getCookie(request, "user");
|
||||
if (cookie == null) {
|
||||
return -1;
|
||||
}
|
||||
if (RedisTools.get(cookie.getValue()).equals("ok")) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存上传的文件
|
||||
*
|
||||
* @param path 路径
|
||||
* @param file 文件
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String createFile(String path, MultipartFile file, String newFileName) throws Exception {
|
||||
String savePath = new File("").getAbsolutePath() + File.separator + "html" + File.separator + path;
|
||||
File servicePath = new File(savePath);
|
||||
if (!servicePath.exists()) {
|
||||
servicePath.mkdirs();
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (newFileName != null) {
|
||||
fileName = newFileName;
|
||||
}
|
||||
File saveFile = new File(savePath + "/" + fileName);
|
||||
if (saveFile.exists()) {
|
||||
if (!saveFile.delete()) {
|
||||
saveFile = new File(savePath + "/" + fileName.replace(".", "_" + new Date().getTime() + "."));
|
||||
}
|
||||
}
|
||||
file.transferTo(saveFile);
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
System.out.println("上传文件保存路径:" + saveFile.getAbsolutePath());
|
||||
return path + fileName;
|
||||
}
|
||||
|
||||
public static void download(String url, DownloadInterface downloadInterface) {
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36");
|
||||
connection.disconnect();
|
||||
new File("tmp").mkdirs();
|
||||
File file = new File("tmp" + File.separator + url.trim().split("/")[url.trim().split("/").length - 1]);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
byte[] bytes = new byte[4096];
|
||||
int len;
|
||||
while ((len = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, len);
|
||||
outputStream.flush();
|
||||
}
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
downloadInterface.onDownload(file.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
downloadInterface.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造给前端的文件
|
||||
*
|
||||
* @param file 文件路径
|
||||
* @return 前端获取的文件
|
||||
*/
|
||||
public static ResponseEntity<FileSystemResource> getFile(File file) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
try {
|
||||
headers.add("Content-Disposition", "attachment; filename=" + URLEncoder.encode(file.getName(), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
headers.add("Content-Disposition", "attachment; filename=" + file.getName());
|
||||
}
|
||||
headers.add("Pragma", "no-cache");
|
||||
headers.add("Expires", "0");
|
||||
headers.add("Last-Modified", new Date().toString());
|
||||
headers.add("ETag", String.valueOf(System.currentTimeMillis()));
|
||||
return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file));
|
||||
}
|
||||
|
||||
public static String getFileMD5(File file) {
|
||||
if (!file.isFile()) {
|
||||
return null;
|
||||
}
|
||||
MessageDigest digest = null;
|
||||
FileInputStream in = null;
|
||||
byte buffer[] = new byte[1024];
|
||||
int len;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("MD5");
|
||||
in = new FileInputStream(file);
|
||||
while ((len = in.read(buffer, 0, 1024)) != -1) {
|
||||
digest.update(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return bytesToHexString(digest.digest());
|
||||
}
|
||||
|
||||
private static String bytesToHexString(byte[] src) {
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
if (src == null || src.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (byte aSrc : src) {
|
||||
int v = aSrc & 0xFF;
|
||||
String hv = Integer.toHexString(v);
|
||||
if (hv.length() < 2) {
|
||||
stringBuilder.append(0);
|
||||
}
|
||||
stringBuilder.append(hv);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static String base64ToString(String base) {
|
||||
base = base.replace(" ", "+");
|
||||
try {
|
||||
base = new String(Base64.getDecoder().decode(base.replace("\r\n", "").getBytes()));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
base = URLDecoder.decode(base, "UTF-8");
|
||||
base = base.replace(" ", "+");
|
||||
base = new String(Base64.getDecoder().decode(base.replace("\r\n", "").getBytes()));
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常输出
|
||||
*
|
||||
* @param e 异常
|
||||
* @return
|
||||
*/
|
||||
public static String getExceptionString(Exception e) {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(writer);
|
||||
e.printStackTrace(printWriter);
|
||||
printWriter.close();
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public static String getToDayTime() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
}
|
||||
}
|
220
src/main/resources/mappers/BangumiItemDao.xml
Normal file
220
src/main/resources/mappers/BangumiItemDao.xml
Normal file
@ -0,0 +1,220 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yutou.nas.mybatis.dao.BangumiItemDao">
|
||||
<resultMap id="BaseResultMap" type="com.yutou.nas.mybatis.model.BangumiItem">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="bid" jdbcType="VARCHAR" property="bid" />
|
||||
<result column="categories" jdbcType="VARCHAR" property="categories" />
|
||||
<result column="author" jdbcType="VARCHAR" property="author" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
<result column="titleKey" jdbcType="VARCHAR" property="titlekey" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, bid, categories, author, title, titleKey
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.nas.mybatis.model.BangumiItemExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from bangumi_item
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from bangumi_item
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from bangumi_item
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.yutou.nas.mybatis.model.BangumiItemExample">
|
||||
delete from bangumi_item
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.BangumiItem" useGeneratedKeys="true">
|
||||
insert into bangumi_item (bid, categories, author,
|
||||
title, titleKey)
|
||||
values (#{bid,jdbcType=VARCHAR}, #{categories,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
|
||||
#{title,jdbcType=VARCHAR}, #{titlekey,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.BangumiItem" useGeneratedKeys="true">
|
||||
insert into bangumi_item
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="bid != null">
|
||||
bid,
|
||||
</if>
|
||||
<if test="categories != null">
|
||||
categories,
|
||||
</if>
|
||||
<if test="author != null">
|
||||
author,
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
<if test="titlekey != null">
|
||||
titleKey,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="bid != null">
|
||||
#{bid,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="categories != null">
|
||||
#{categories,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="author != null">
|
||||
#{author,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="titlekey != null">
|
||||
#{titlekey,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.yutou.nas.mybatis.model.BangumiItemExample" resultType="java.lang.Long">
|
||||
select count(*) from bangumi_item
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update bangumi_item
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.bid != null">
|
||||
bid = #{record.bid,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.categories != null">
|
||||
categories = #{record.categories,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.author != null">
|
||||
author = #{record.author,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.titlekey != null">
|
||||
titleKey = #{record.titlekey,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update bangumi_item
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
bid = #{record.bid,jdbcType=VARCHAR},
|
||||
categories = #{record.categories,jdbcType=VARCHAR},
|
||||
author = #{record.author,jdbcType=VARCHAR},
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
titleKey = #{record.titlekey,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.nas.mybatis.model.BangumiItem">
|
||||
update bangumi_item
|
||||
<set>
|
||||
<if test="bid != null">
|
||||
bid = #{bid,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="categories != null">
|
||||
categories = #{categories,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="author != null">
|
||||
author = #{author,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="titlekey != null">
|
||||
titleKey = #{titlekey,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.nas.mybatis.model.BangumiItem">
|
||||
update bangumi_item
|
||||
set bid = #{bid,jdbcType=VARCHAR},
|
||||
categories = #{categories,jdbcType=VARCHAR},
|
||||
author = #{author,jdbcType=VARCHAR},
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
titleKey = #{titlekey,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
173
src/main/resources/mappers/BangumiListDao.xml
Normal file
173
src/main/resources/mappers/BangumiListDao.xml
Normal file
@ -0,0 +1,173 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yutou.nas.mybatis.dao.BangumiListDao">
|
||||
<resultMap id="BaseResultMap" type="com.yutou.nas.mybatis.model.BangumiList">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, title, `status`
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.nas.mybatis.model.BangumiListExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from bangumi_list
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from bangumi_list
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from bangumi_list
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.yutou.nas.mybatis.model.BangumiListExample">
|
||||
delete from bangumi_list
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.BangumiList" useGeneratedKeys="true">
|
||||
insert into bangumi_list (title, `status`)
|
||||
values (#{title,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.BangumiList" useGeneratedKeys="true">
|
||||
insert into bangumi_list
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status`,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.yutou.nas.mybatis.model.BangumiListExample" resultType="java.lang.Long">
|
||||
select count(*) from bangumi_list
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update bangumi_list
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.status != null">
|
||||
`status` = #{record.status,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update bangumi_list
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
`status` = #{record.status,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.nas.mybatis.model.BangumiList">
|
||||
update bangumi_list
|
||||
<set>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status` = #{status,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.nas.mybatis.model.BangumiList">
|
||||
update bangumi_list
|
||||
set title = #{title,jdbcType=VARCHAR},
|
||||
`status` = #{status,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
496
src/main/resources/mappers/MusicDataDao.xml
Normal file
496
src/main/resources/mappers/MusicDataDao.xml
Normal file
@ -0,0 +1,496 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yutou.nas.mybatis.dao.MusicDataDao">
|
||||
<resultMap id="BaseResultMap" type="com.yutou.nas.mybatis.model.MusicData">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="artist" jdbcType="VARCHAR" property="artist" />
|
||||
<result column="album" jdbcType="VARCHAR" property="album" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
<result column="comment" jdbcType="VARCHAR" property="comment" />
|
||||
<result column="year" jdbcType="VARCHAR" property="year" />
|
||||
<result column="track" jdbcType="VARCHAR" property="track" />
|
||||
<result column="disc_no" jdbcType="VARCHAR" property="discNo" />
|
||||
<result column="composer" jdbcType="VARCHAR" property="composer" />
|
||||
<result column="artist_sort" jdbcType="VARCHAR" property="artistSort" />
|
||||
<result column="file" jdbcType="VARCHAR" property="file" />
|
||||
<result column="lastDir" jdbcType="VARCHAR" property="lastdir" />
|
||||
<result column="isDir" jdbcType="INTEGER" property="isdir" />
|
||||
<result column="bitRate" jdbcType="INTEGER" property="bitrate" />
|
||||
<result column="sampleRate" jdbcType="INTEGER" property="samplerate" />
|
||||
<result column="noOfSamples" jdbcType="BIGINT" property="noofsamples" />
|
||||
<result column="channelCount" jdbcType="INTEGER" property="channelcount" />
|
||||
<result column="encodingType" jdbcType="VARCHAR" property="encodingtype" />
|
||||
<result column="durationAsDouble" jdbcType="DOUBLE" property="durationasdouble" />
|
||||
<result column="lossless" jdbcType="INTEGER" property="lossless" />
|
||||
<result column="variableBitRate" jdbcType="INTEGER" property="variablebitrate" />
|
||||
<result column="md5" jdbcType="VARCHAR" property="md5" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, artist, album, title, `comment`, `year`, track, disc_no, composer, artist_sort,
|
||||
`file`, lastDir, isDir, bitRate, sampleRate, noOfSamples, channelCount, encodingType,
|
||||
durationAsDouble, lossless, variableBitRate, md5
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.nas.mybatis.model.MusicDataExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from music_data
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from music_data
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from music_data
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.yutou.nas.mybatis.model.MusicDataExample">
|
||||
delete from music_data
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicData" useGeneratedKeys="true">
|
||||
insert into music_data (artist, album, title,
|
||||
`comment`, `year`, track,
|
||||
disc_no, composer, artist_sort,
|
||||
`file`, lastDir, isDir,
|
||||
bitRate, sampleRate, noOfSamples,
|
||||
channelCount, encodingType, durationAsDouble,
|
||||
lossless, variableBitRate, md5
|
||||
)
|
||||
values (#{artist,jdbcType=VARCHAR}, #{album,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
|
||||
#{comment,jdbcType=VARCHAR}, #{year,jdbcType=VARCHAR}, #{track,jdbcType=VARCHAR},
|
||||
#{discNo,jdbcType=VARCHAR}, #{composer,jdbcType=VARCHAR}, #{artistSort,jdbcType=VARCHAR},
|
||||
#{file,jdbcType=VARCHAR}, #{lastdir,jdbcType=VARCHAR}, #{isdir,jdbcType=INTEGER},
|
||||
#{bitrate,jdbcType=INTEGER}, #{samplerate,jdbcType=INTEGER}, #{noofsamples,jdbcType=BIGINT},
|
||||
#{channelcount,jdbcType=INTEGER}, #{encodingtype,jdbcType=VARCHAR}, #{durationasdouble,jdbcType=DOUBLE},
|
||||
#{lossless,jdbcType=INTEGER}, #{variablebitrate,jdbcType=INTEGER}, #{md5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicData" useGeneratedKeys="true">
|
||||
insert into music_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="artist != null">
|
||||
artist,
|
||||
</if>
|
||||
<if test="album != null">
|
||||
album,
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
<if test="comment != null">
|
||||
`comment`,
|
||||
</if>
|
||||
<if test="year != null">
|
||||
`year`,
|
||||
</if>
|
||||
<if test="track != null">
|
||||
track,
|
||||
</if>
|
||||
<if test="discNo != null">
|
||||
disc_no,
|
||||
</if>
|
||||
<if test="composer != null">
|
||||
composer,
|
||||
</if>
|
||||
<if test="artistSort != null">
|
||||
artist_sort,
|
||||
</if>
|
||||
<if test="file != null">
|
||||
`file`,
|
||||
</if>
|
||||
<if test="lastdir != null">
|
||||
lastDir,
|
||||
</if>
|
||||
<if test="isdir != null">
|
||||
isDir,
|
||||
</if>
|
||||
<if test="bitrate != null">
|
||||
bitRate,
|
||||
</if>
|
||||
<if test="samplerate != null">
|
||||
sampleRate,
|
||||
</if>
|
||||
<if test="noofsamples != null">
|
||||
noOfSamples,
|
||||
</if>
|
||||
<if test="channelcount != null">
|
||||
channelCount,
|
||||
</if>
|
||||
<if test="encodingtype != null">
|
||||
encodingType,
|
||||
</if>
|
||||
<if test="durationasdouble != null">
|
||||
durationAsDouble,
|
||||
</if>
|
||||
<if test="lossless != null">
|
||||
lossless,
|
||||
</if>
|
||||
<if test="variablebitrate != null">
|
||||
variableBitRate,
|
||||
</if>
|
||||
<if test="md5 != null">
|
||||
md5,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="artist != null">
|
||||
#{artist,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="album != null">
|
||||
#{album,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="comment != null">
|
||||
#{comment,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="year != null">
|
||||
#{year,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="track != null">
|
||||
#{track,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="discNo != null">
|
||||
#{discNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="composer != null">
|
||||
#{composer,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="artistSort != null">
|
||||
#{artistSort,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="file != null">
|
||||
#{file,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lastdir != null">
|
||||
#{lastdir,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isdir != null">
|
||||
#{isdir,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="bitrate != null">
|
||||
#{bitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="samplerate != null">
|
||||
#{samplerate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="noofsamples != null">
|
||||
#{noofsamples,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="channelcount != null">
|
||||
#{channelcount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="encodingtype != null">
|
||||
#{encodingtype,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="durationasdouble != null">
|
||||
#{durationasdouble,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="lossless != null">
|
||||
#{lossless,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="variablebitrate != null">
|
||||
#{variablebitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="md5 != null">
|
||||
#{md5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.yutou.nas.mybatis.model.MusicDataExample" resultType="java.lang.Long">
|
||||
select count(*) from music_data
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByRegexp" resultType="com.yutou.nas.mybatis.model.MusicData">
|
||||
select * from music_data where `file` REGEXP #{regexp,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<select id="selectAllAlbum" resultType="java.lang.String">
|
||||
SELECT album FROM music_data group by `album`;
|
||||
</select>
|
||||
<select id="selectAllArtist" resultType="java.lang.String">
|
||||
SELECT artist FROM music_data group by `artist`;
|
||||
</select>
|
||||
<select id="selectAlbum" resultType="com.yutou.nas.mybatis.model.MusicData">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from music_data where `album`= #{album,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<select id="selectArtist" resultType="com.yutou.nas.mybatis.model.MusicData">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from music_data where `artist`= #{artist,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update music_data
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.artist != null">
|
||||
artist = #{record.artist,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.album != null">
|
||||
album = #{record.album,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.comment != null">
|
||||
`comment` = #{record.comment,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.year != null">
|
||||
`year` = #{record.year,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.track != null">
|
||||
track = #{record.track,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.discNo != null">
|
||||
disc_no = #{record.discNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.composer != null">
|
||||
composer = #{record.composer,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.artistSort != null">
|
||||
artist_sort = #{record.artistSort,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.file != null">
|
||||
`file` = #{record.file,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.lastdir != null">
|
||||
lastDir = #{record.lastdir,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.isdir != null">
|
||||
isDir = #{record.isdir,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.bitrate != null">
|
||||
bitRate = #{record.bitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.samplerate != null">
|
||||
sampleRate = #{record.samplerate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.noofsamples != null">
|
||||
noOfSamples = #{record.noofsamples,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.channelcount != null">
|
||||
channelCount = #{record.channelcount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.encodingtype != null">
|
||||
encodingType = #{record.encodingtype,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.durationasdouble != null">
|
||||
durationAsDouble = #{record.durationasdouble,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="record.lossless != null">
|
||||
lossless = #{record.lossless,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.variablebitrate != null">
|
||||
variableBitRate = #{record.variablebitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.md5 != null">
|
||||
md5 = #{record.md5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update music_data
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
artist = #{record.artist,jdbcType=VARCHAR},
|
||||
album = #{record.album,jdbcType=VARCHAR},
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
`comment` = #{record.comment,jdbcType=VARCHAR},
|
||||
`year` = #{record.year,jdbcType=VARCHAR},
|
||||
track = #{record.track,jdbcType=VARCHAR},
|
||||
disc_no = #{record.discNo,jdbcType=VARCHAR},
|
||||
composer = #{record.composer,jdbcType=VARCHAR},
|
||||
artist_sort = #{record.artistSort,jdbcType=VARCHAR},
|
||||
`file` = #{record.file,jdbcType=VARCHAR},
|
||||
lastDir = #{record.lastdir,jdbcType=VARCHAR},
|
||||
isDir = #{record.isdir,jdbcType=INTEGER},
|
||||
bitRate = #{record.bitrate,jdbcType=INTEGER},
|
||||
sampleRate = #{record.samplerate,jdbcType=INTEGER},
|
||||
noOfSamples = #{record.noofsamples,jdbcType=BIGINT},
|
||||
channelCount = #{record.channelcount,jdbcType=INTEGER},
|
||||
encodingType = #{record.encodingtype,jdbcType=VARCHAR},
|
||||
durationAsDouble = #{record.durationasdouble,jdbcType=DOUBLE},
|
||||
lossless = #{record.lossless,jdbcType=INTEGER},
|
||||
variableBitRate = #{record.variablebitrate,jdbcType=INTEGER},
|
||||
md5 = #{record.md5,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.nas.mybatis.model.MusicData">
|
||||
update music_data
|
||||
<set>
|
||||
<if test="artist != null">
|
||||
artist = #{artist,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="album != null">
|
||||
album = #{album,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="comment != null">
|
||||
`comment` = #{comment,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="year != null">
|
||||
`year` = #{year,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="track != null">
|
||||
track = #{track,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="discNo != null">
|
||||
disc_no = #{discNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="composer != null">
|
||||
composer = #{composer,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="artistSort != null">
|
||||
artist_sort = #{artistSort,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="file != null">
|
||||
`file` = #{file,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lastdir != null">
|
||||
lastDir = #{lastdir,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isdir != null">
|
||||
isDir = #{isdir,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="bitrate != null">
|
||||
bitRate = #{bitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="samplerate != null">
|
||||
sampleRate = #{samplerate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="noofsamples != null">
|
||||
noOfSamples = #{noofsamples,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="channelcount != null">
|
||||
channelCount = #{channelcount,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="encodingtype != null">
|
||||
encodingType = #{encodingtype,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="durationasdouble != null">
|
||||
durationAsDouble = #{durationasdouble,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="lossless != null">
|
||||
lossless = #{lossless,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="variablebitrate != null">
|
||||
variableBitRate = #{variablebitrate,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="md5 != null">
|
||||
md5 = #{md5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.nas.mybatis.model.MusicData">
|
||||
update music_data
|
||||
set artist = #{artist,jdbcType=VARCHAR},
|
||||
album = #{album,jdbcType=VARCHAR},
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
`comment` = #{comment,jdbcType=VARCHAR},
|
||||
`year` = #{year,jdbcType=VARCHAR},
|
||||
track = #{track,jdbcType=VARCHAR},
|
||||
disc_no = #{discNo,jdbcType=VARCHAR},
|
||||
composer = #{composer,jdbcType=VARCHAR},
|
||||
artist_sort = #{artistSort,jdbcType=VARCHAR},
|
||||
`file` = #{file,jdbcType=VARCHAR},
|
||||
lastDir = #{lastdir,jdbcType=VARCHAR},
|
||||
isDir = #{isdir,jdbcType=INTEGER},
|
||||
bitRate = #{bitrate,jdbcType=INTEGER},
|
||||
sampleRate = #{samplerate,jdbcType=INTEGER},
|
||||
noOfSamples = #{noofsamples,jdbcType=BIGINT},
|
||||
channelCount = #{channelcount,jdbcType=INTEGER},
|
||||
encodingType = #{encodingtype,jdbcType=VARCHAR},
|
||||
durationAsDouble = #{durationasdouble,jdbcType=DOUBLE},
|
||||
lossless = #{lossless,jdbcType=INTEGER},
|
||||
variableBitRate = #{variablebitrate,jdbcType=INTEGER},
|
||||
md5 = #{md5,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="truncate">
|
||||
TRUNCATE music_data;
|
||||
</update>
|
||||
</mapper>
|
190
src/main/resources/mappers/MusicFavoritesDao.xml
Normal file
190
src/main/resources/mappers/MusicFavoritesDao.xml
Normal file
@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yutou.nas.mybatis.dao.MusicFavoritesDao">
|
||||
<resultMap id="BaseResultMap" type="com.yutou.nas.mybatis.model.MusicFavorites">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="favoriteId" jdbcType="INTEGER" property="favoriteid" />
|
||||
<result column="musis_md5" jdbcType="VARCHAR" property="musisMd5" />
|
||||
<result column="sub_time" jdbcType="TIMESTAMP" property="subTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, favoriteId, musis_md5, sub_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from music_favorites
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from music_favorites
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from music_favorites
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesExample">
|
||||
delete from music_favorites
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicFavorites" useGeneratedKeys="true">
|
||||
insert into music_favorites (favoriteId, musis_md5, sub_time
|
||||
)
|
||||
values (#{favoriteid,jdbcType=INTEGER}, #{musisMd5,jdbcType=VARCHAR}, #{subTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicFavorites" useGeneratedKeys="true">
|
||||
insert into music_favorites
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="favoriteid != null">
|
||||
favoriteId,
|
||||
</if>
|
||||
<if test="musisMd5 != null">
|
||||
musis_md5,
|
||||
</if>
|
||||
<if test="subTime != null">
|
||||
sub_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="favoriteid != null">
|
||||
#{favoriteid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="musisMd5 != null">
|
||||
#{musisMd5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="subTime != null">
|
||||
#{subTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesExample" resultType="java.lang.Long">
|
||||
select count(*) from music_favorites
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update music_favorites
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.favoriteid != null">
|
||||
favoriteId = #{record.favoriteid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.musisMd5 != null">
|
||||
musis_md5 = #{record.musisMd5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.subTime != null">
|
||||
sub_time = #{record.subTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update music_favorites
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
favoriteId = #{record.favoriteid,jdbcType=INTEGER},
|
||||
musis_md5 = #{record.musisMd5,jdbcType=VARCHAR},
|
||||
sub_time = #{record.subTime,jdbcType=TIMESTAMP}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.nas.mybatis.model.MusicFavorites">
|
||||
update music_favorites
|
||||
<set>
|
||||
<if test="favoriteid != null">
|
||||
favoriteId = #{favoriteid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="musisMd5 != null">
|
||||
musis_md5 = #{musisMd5,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="subTime != null">
|
||||
sub_time = #{subTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.nas.mybatis.model.MusicFavorites">
|
||||
update music_favorites
|
||||
set favoriteId = #{favoriteid,jdbcType=INTEGER},
|
||||
musis_md5 = #{musisMd5,jdbcType=VARCHAR},
|
||||
sub_time = #{subTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
158
src/main/resources/mappers/MusicFavoritesDirDao.xml
Normal file
158
src/main/resources/mappers/MusicFavoritesDirDao.xml
Normal file
@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yutou.nas.mybatis.dao.MusicFavoritesDirDao">
|
||||
<resultMap id="BaseResultMap" type="com.yutou.nas.mybatis.model.MusicFavoritesDir">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="title" jdbcType="VARCHAR" property="title" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, title
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDirExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from music_favorites_dir
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from music_favorites_dir
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from music_favorites_dir
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDirExample">
|
||||
delete from music_favorites_dir
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDir" useGeneratedKeys="true">
|
||||
insert into music_favorites_dir (title)
|
||||
values (#{title,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDir" useGeneratedKeys="true">
|
||||
insert into music_favorites_dir
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDirExample" resultType="java.lang.Long">
|
||||
select count(*) from music_favorites_dir
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update music_favorites_dir
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update music_favorites_dir
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
title = #{record.title,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDir">
|
||||
update music_favorites_dir
|
||||
<set>
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.nas.mybatis.model.MusicFavoritesDir">
|
||||
update music_favorites_dir
|
||||
set title = #{title,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
13
src/test/java/com/yutou/nas/NasApplicationTests.java
Normal file
13
src/test/java/com/yutou/nas/NasApplicationTests.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.yutou.nas;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class NasApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user