@ -0,0 +1,31 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**
|
||||||
|
!**/src/test/**
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.channels.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
|
private static final String WRAPPER_VERSION = "0.5.5";
|
||||||
|
/**
|
||||||
|
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||||
|
*/
|
||||||
|
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
|
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||||
|
* use instead of the default one.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path where the maven-wrapper.jar will be saved to.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
|
*/
|
||||||
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
System.out.println("- Downloader started");
|
||||||
|
File baseDirectory = new File(args[0]);
|
||||||
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
|
// wrapperUrl parameter.
|
||||||
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
|
try {
|
||||||
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
|
Properties mavenWrapperProperties = new Properties();
|
||||||
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignore ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
|
if (!outputFile.getParentFile().exists()) {
|
||||||
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
|
System.out.println(
|
||||||
|
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
|
||||||
|
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
|
@ -0,0 +1,310 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Maven2 Start Up Batch script
|
||||||
|
#
|
||||||
|
# Required ENV vars:
|
||||||
|
# ------------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# M2_HOME - location of maven2's installed home dir
|
||||||
|
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
# e.g. to debug Maven itself, use
|
||||||
|
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||||
|
|
||||||
|
if [ -f /etc/mavenrc ] ; then
|
||||||
|
. /etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mavenrc" ] ; then
|
||||||
|
. "$HOME/.mavenrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS specific support. $var _must_ be set to either true or false.
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
mingw=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN*) cygwin=true ;;
|
||||||
|
MINGW*) mingw=true;;
|
||||||
|
Darwin*) darwin=true
|
||||||
|
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||||
|
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
if [ -x "/usr/libexec/java_home" ]; then
|
||||||
|
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||||
|
else
|
||||||
|
export JAVA_HOME="/Library/Java/Home"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
if [ -r /etc/gentoo-release ] ; then
|
||||||
|
JAVA_HOME=`java-config --jre-home`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$M2_HOME" ] ; then
|
||||||
|
## resolve links - $0 may be a link to maven's home
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
# need this for relative symlinks
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG="`dirname "$PRG"`/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
saveddir=`pwd`
|
||||||
|
|
||||||
|
M2_HOME=`dirname "$PRG"`/..
|
||||||
|
|
||||||
|
# make it fully qualified
|
||||||
|
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||||
|
|
||||||
|
cd "$saveddir"
|
||||||
|
# echo Using m2 at $M2_HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $mingw ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
javaExecutable="`which javac`"
|
||||||
|
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=`which readlink`
|
||||||
|
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||||
|
else
|
||||||
|
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||||
|
fi
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVACMD" ] ; then
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="`which java`"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||||
|
echo " We cannot execute $JAVACMD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
echo "Warning: JAVA_HOME environment variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||||
|
|
||||||
|
# traverses directory structure from process work directory to filesystem root
|
||||||
|
# first directory with .mvn subdirectory is considered project base directory
|
||||||
|
find_maven_basedir() {
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Path not specified to find_maven_basedir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basedir="$1"
|
||||||
|
wdir="$1"
|
||||||
|
while [ "$wdir" != '/' ] ; do
|
||||||
|
if [ -d "$wdir"/.mvn ] ; then
|
||||||
|
basedir=$wdir
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||||
|
if [ -d "${wdir}" ]; then
|
||||||
|
wdir=`cd "$wdir/.."; pwd`
|
||||||
|
fi
|
||||||
|
# end of workaround
|
||||||
|
done
|
||||||
|
echo "${basedir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# concatenates all lines of a file
|
||||||
|
concat_lines() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
echo "$(tr -s '\n' ' ' < "$1")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
##########################################################################################
|
||||||
|
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||||
|
fi
|
||||||
|
if [ -n "$MVNW_REPOURL" ]; then
|
||||||
|
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
|
||||||
|
else
|
||||||
|
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
|
||||||
|
fi
|
||||||
|
while IFS="=" read key value; do
|
||||||
|
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||||
|
esac
|
||||||
|
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Downloading from: $jarUrl"
|
||||||
|
fi
|
||||||
|
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||||
|
if $cygwin; then
|
||||||
|
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v wget > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found wget ... using wget"
|
||||||
|
fi
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
wget "$jarUrl" -O "$wrapperJarPath"
|
||||||
|
else
|
||||||
|
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||||
|
fi
|
||||||
|
elif command -v curl > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found curl ... using curl"
|
||||||
|
fi
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||||
|
else
|
||||||
|
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Falling back to using Java to download"
|
||||||
|
fi
|
||||||
|
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||||
|
# For Cygwin, switch paths to Windows format before running javac
|
||||||
|
if $cygwin; then
|
||||||
|
javaClass=`cygpath --path --windows "$javaClass"`
|
||||||
|
fi
|
||||||
|
if [ -e "$javaClass" ]; then
|
||||||
|
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
# Compiling the Java class
|
||||||
|
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||||
|
fi
|
||||||
|
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
# Running the downloader
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Running MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##########################################################################################
|
||||||
|
# End of extension
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo $MAVEN_PROJECTBASEDIR
|
||||||
|
fi
|
||||||
|
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||||
|
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||||
|
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
# work with both Windows and non-Windows executions.
|
||||||
|
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||||
|
export MAVEN_CMD_LINE_ARGS
|
||||||
|
|
||||||
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
exec "$JAVACMD" \
|
||||||
|
$MAVEN_OPTS \
|
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,182 @@
|
|||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Maven2 Start Up Batch script
|
||||||
|
@REM
|
||||||
|
@REM Required ENV vars:
|
||||||
|
@REM JAVA_HOME - location of a JDK home dir
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM M2_HOME - location of maven2's installed home dir
|
||||||
|
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||||
|
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||||
|
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
@REM e.g. to debug Maven itself, use
|
||||||
|
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||||
|
@echo off
|
||||||
|
@REM set title of command window
|
||||||
|
title %0
|
||||||
|
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||||
|
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||||
|
|
||||||
|
@REM set %HOME% to equivalent of $HOME
|
||||||
|
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||||
|
|
||||||
|
@REM Execute a user defined script before this one
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||||
|
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||||
|
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||||
|
:skipRcPre
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set ERROR_CODE=0
|
||||||
|
|
||||||
|
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
@REM ==== START VALIDATION ====
|
||||||
|
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME not found in your environment. >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
:OkJHome
|
||||||
|
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||||
|
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
@REM ==== END VALIDATION ====
|
||||||
|
|
||||||
|
:init
|
||||||
|
|
||||||
|
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||||
|
@REM Fallback to current working directory if not found.
|
||||||
|
|
||||||
|
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||||
|
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||||
|
|
||||||
|
set EXEC_DIR=%CD%
|
||||||
|
set WDIR=%EXEC_DIR%
|
||||||
|
:findBaseDir
|
||||||
|
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||||
|
cd ..
|
||||||
|
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||||
|
set WDIR=%CD%
|
||||||
|
goto findBaseDir
|
||||||
|
|
||||||
|
:baseDirFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
goto endDetectBaseDir
|
||||||
|
|
||||||
|
:baseDirNotFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
|
||||||
|
:endDetectBaseDir
|
||||||
|
|
||||||
|
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||||
|
|
||||||
|
@setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||||
|
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||||
|
|
||||||
|
:endReadAdditionalConfig
|
||||||
|
|
||||||
|
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||||
|
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||||
|
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
|
||||||
|
|
||||||
|
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||||
|
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||||
|
)
|
||||||
|
|
||||||
|
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
if exist %WRAPPER_JAR% (
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Found %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
if not "%MVNW_REPOURL%" == "" (
|
||||||
|
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar"
|
||||||
|
)
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||||
|
echo Downloading from: %DOWNLOAD_URL%
|
||||||
|
)
|
||||||
|
|
||||||
|
powershell -Command "&{"^
|
||||||
|
"$webclient = new-object System.Net.WebClient;"^
|
||||||
|
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||||
|
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||||
|
"}"^
|
||||||
|
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||||
|
"}"
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Finished downloading %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@REM End of extension
|
||||||
|
|
||||||
|
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
@REM work with both Windows and non-Windows executions.
|
||||||
|
set MAVEN_CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
set ERROR_CODE=1
|
||||||
|
|
||||||
|
:end
|
||||||
|
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||||
|
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||||
|
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||||
|
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||||
|
:skipRcPost
|
||||||
|
|
||||||
|
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||||
|
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||||
|
|
||||||
|
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||||
|
|
||||||
|
exit /B %ERROR_CODE%
|
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.8.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.orangesale</groupId>
|
||||||
|
<artifactId>orange</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>orange</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
<version>3.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>5.2.0.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.32</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.junit.vintage</groupId>
|
||||||
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.10</version>
|
||||||
|
</dependency>
|
||||||
|
<!--添加mybatis依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>1.3.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.4</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.example.orangesale_end;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class OrangeApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(OrangeApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.orangesale_end.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/10/11 14:40
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebMvcConfigure extends WebMvcConfigurationSupport {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(WebMvcConfigure.class);
|
||||||
|
@Value("${uploadFilePath}")
|
||||||
|
private String uploadFilePath;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
logger.info(uploadFilePath);
|
||||||
|
|
||||||
|
//和页面有关的静态目录都放在项目的static目录下
|
||||||
|
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
|
||||||
|
//上传的图片路径
|
||||||
|
registry.addResourceHandler("/uploaded/**").addResourceLocations("file:" + uploadFilePath);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.example.orangesale_end.controller;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeMessage;
|
||||||
|
import com.example.orangesale_end.service.MessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/orange/message")
|
||||||
|
@CrossOrigin
|
||||||
|
public class OrangeMessageController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageService messageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送消息
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/pushMessage", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> insertMessage(@RequestBody OrangeMessage message) {
|
||||||
|
Integer insertFlag = messageService.insertMessage(message);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (insertFlag > 0) {
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费消息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/consumeMessage", method = RequestMethod.GET)
|
||||||
|
public Map<String, Object> consumeMessage() {
|
||||||
|
OrangeMessage orangeMessage = messageService.consumeMessage();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (Objects.isNull(orangeMessage)) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "consume error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("data", orangeMessage);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置消息为已使用
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/updateMessage", method = RequestMethod.GET)
|
||||||
|
public Map<String, Object> updateMessage() {
|
||||||
|
Integer updateFlag = messageService.updateMessage();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (updateFlag > 0) {
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,152 @@
|
|||||||
|
package com.example.orangesale_end.controller;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeProduct;
|
||||||
|
import com.example.orangesale_end.service.ProductService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/orange/product")
|
||||||
|
@CrossOrigin
|
||||||
|
public class OrangeProductController {
|
||||||
|
@Autowired
|
||||||
|
private ProductService productService;
|
||||||
|
@Value("${uploadFilePath}")
|
||||||
|
private String uploadFilePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询商品信息
|
||||||
|
*
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/searchById", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> searchProductById(String productId) {
|
||||||
|
OrangeProduct orangeProduct = productService.selectById(Integer.valueOf(productId));
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (Objects.isNull(orangeProduct)) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "search by id error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("data", orangeProduct);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询商品详细信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/search", method = RequestMethod.GET)
|
||||||
|
public Map<String, Object> searchProduct() {
|
||||||
|
List<OrangeProduct> productList = productService.selectAll();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (CollectionUtils.isEmpty(productList)) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "search error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("data", productList);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品信息
|
||||||
|
*
|
||||||
|
* @param orangeProduct
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> updateProduct(@RequestBody OrangeProduct orangeProduct) {
|
||||||
|
Integer updateFlag = productService.updateProduct(orangeProduct);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (updateFlag <= 0) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "search error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "update success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品信息
|
||||||
|
*
|
||||||
|
* @param orangeProduct
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||||
|
public Map<String, Object> deleteProduct(@RequestBody OrangeProduct orangeProduct) {
|
||||||
|
Integer deleteFlag = productService.deleteProduct(orangeProduct);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (deleteFlag <= 0) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "delete error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "delete success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品信息
|
||||||
|
*
|
||||||
|
* @param orangeProduct
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> addProduct(@RequestBody OrangeProduct orangeProduct) {
|
||||||
|
Integer addFlag = productService.addProduct(orangeProduct);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
if (addFlag <= 0) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "add error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "add success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传图片
|
||||||
|
*
|
||||||
|
* @param file 上传文件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/uploadCover")
|
||||||
|
public Map<String, Object> uploadCover(@RequestParam("file") MultipartFile file) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
String changeFileName = uploadFilePath + fileName;
|
||||||
|
File destFile = new File(changeFileName);
|
||||||
|
if (!destFile.exists()) {
|
||||||
|
destFile.getParentFile().mkdirs();
|
||||||
|
file.transferTo(destFile);
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("data", "http://192.168.0.102:8081/uploaded/" + fileName);
|
||||||
|
return map;
|
||||||
|
} catch (Exception e) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "upload error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.example.orangesale_end.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/orange/shoppingCart")
|
||||||
|
@CrossOrigin
|
||||||
|
public class OrangeShoppingCartController {
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.example.orangesale_end.controller;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
import com.example.orangesale_end.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/orange/user")
|
||||||
|
@CrossOrigin
|
||||||
|
public class OrangeUserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录验证
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> userLogin(@RequestBody OrangeUser orangeUser) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
OrangeUser user = userService.userLogin(orangeUser);
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "login error");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("data", user);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册验证
|
||||||
|
*
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||||
|
public Map<String, Object> userRegister(@RequestBody OrangeUser orangeUser) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
Integer insertFlag = userService.userRegister(orangeUser);
|
||||||
|
if (insertFlag > 0) {
|
||||||
|
map.put("flag", true);
|
||||||
|
map.put("msg", "register success");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("flag", false);
|
||||||
|
map.put("msg", "register failed");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeMessage {
|
||||||
|
private Integer id;
|
||||||
|
private String content;
|
||||||
|
private Timestamp sendTime;
|
||||||
|
private String used;
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeProduct {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private String imgUrl;
|
||||||
|
private BigDecimal price;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Timestamp addTime;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeProductSale {
|
||||||
|
private Integer productId;
|
||||||
|
private String name;
|
||||||
|
private String imgUrl;
|
||||||
|
private BigDecimal price;
|
||||||
|
private Timestamp addTime;
|
||||||
|
private Integer salesNum;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeSale {
|
||||||
|
private Integer id;
|
||||||
|
private Integer productId;
|
||||||
|
private Integer salesNum;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeShoppingCart {
|
||||||
|
private Integer id;
|
||||||
|
private Integer userId;
|
||||||
|
private Integer productId;
|
||||||
|
private Integer num;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrangeUser {
|
||||||
|
private Integer id;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String city;
|
||||||
|
private String sex;
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.example.orangesale_end.mapper;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeMessage;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MessageMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入一条推送消息
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
Integer insertMessage(OrangeMessage message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新推送消息
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Integer updateMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取推送的消息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrangeMessage getMessage();
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.example.orangesale_end.mapper;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeProduct;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ProductMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品id查询商品信息
|
||||||
|
*
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrangeProduct selectById(@Param("productId") Integer productId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有商品信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrangeProduct> selectAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品
|
||||||
|
*
|
||||||
|
* @param product
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer updateProduct(OrangeProduct product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
*
|
||||||
|
* @param product
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer deleteProduct(OrangeProduct product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品
|
||||||
|
*
|
||||||
|
* @param orangeProduct
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer addProduct(OrangeProduct orangeProduct);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.example.orangesale_end.mapper;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeSale;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SaleMapper {
|
||||||
|
/**
|
||||||
|
* 根据销量查询
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrangeSale> getBySalesNum();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置商品的销量信息
|
||||||
|
*/
|
||||||
|
Integer updateSalesNum(OrangeSale orangeSale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询商品的销量信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<OrangeSale> selectAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入商品销量信息
|
||||||
|
*
|
||||||
|
* @param orangeSale
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer addSalesNum(OrangeSale orangeSale);
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.example.orangesale_end.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ShoppingCartMapper {
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.example.orangesale_end.mapper;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper {
|
||||||
|
/**
|
||||||
|
* 用户登录验证
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrangeUser userLogin(OrangeUser orangeUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册
|
||||||
|
*
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer userRegister(OrangeUser orangeUser);
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.example.orangesale_end.service;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeMessage;
|
||||||
|
import com.example.orangesale_end.mapper.MessageMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MessageService {
|
||||||
|
@Autowired
|
||||||
|
private MessageMapper messageMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送消息
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer insertMessage(OrangeMessage message) {
|
||||||
|
return messageMapper.insertMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费消息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public OrangeMessage consumeMessage() {
|
||||||
|
return messageMapper.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息设置为已读
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer updateMessage() {
|
||||||
|
return messageMapper.updateMessage();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.example.orangesale_end.service;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeProduct;
|
||||||
|
import com.example.orangesale_end.mapper.ProductMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ProductService {
|
||||||
|
@Autowired
|
||||||
|
private ProductMapper productMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品id查询商品信息
|
||||||
|
*
|
||||||
|
* @param productId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public OrangeProduct selectById(Integer productId) {
|
||||||
|
return productMapper.selectById(productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有商品信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<OrangeProduct> selectAll() {
|
||||||
|
return productMapper.selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品
|
||||||
|
*
|
||||||
|
* @param product
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer updateProduct(OrangeProduct product) {
|
||||||
|
return productMapper.updateProduct(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
*
|
||||||
|
* @param product
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer deleteProduct(OrangeProduct product) {
|
||||||
|
return productMapper.deleteProduct(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品
|
||||||
|
*
|
||||||
|
* @param orangeProduct
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer addProduct(OrangeProduct orangeProduct) {
|
||||||
|
return productMapper.addProduct(orangeProduct);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package com.example.orangesale_end.service;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeProduct;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProductSale;
|
||||||
|
import com.example.orangesale_end.entity.OrangeSale;
|
||||||
|
import com.example.orangesale_end.mapper.ProductMapper;
|
||||||
|
import com.example.orangesale_end.mapper.SaleMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SaleService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SaleMapper saleMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProductMapper productMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据销量查询
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<OrangeSale> getBySalesNum() {
|
||||||
|
return saleMapper.getBySalesNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照销量排序好的商品信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<OrangeProductSale> getProductBySalesNum() {
|
||||||
|
List<OrangeSale> saleList = getBySalesNum();
|
||||||
|
return selectAllProductSale(saleList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询销量信息
|
||||||
|
*/
|
||||||
|
public List<OrangeProductSale> searchSaleNum() {
|
||||||
|
List<OrangeProduct> productList = productMapper.selectAll();
|
||||||
|
List<OrangeSale> saleList = saleMapper.selectAll();
|
||||||
|
List<Integer> productIdList = new ArrayList<>();
|
||||||
|
List<Integer> productIdExistList = new ArrayList<>();
|
||||||
|
if (!CollectionUtils.isEmpty(productList)) {
|
||||||
|
for (OrangeProduct orangeProduct : productList) {
|
||||||
|
productIdList.add(orangeProduct.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(saleList)) {
|
||||||
|
for (OrangeSale orangeSale : saleList) {
|
||||||
|
productIdExistList.add(orangeSale.getProductId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(productIdList)) {
|
||||||
|
for (Integer productId : productIdExistList) {
|
||||||
|
if (!productIdList.contains(productId)) {
|
||||||
|
OrangeSale orangeSale = new OrangeSale();
|
||||||
|
orangeSale.setProductId(productId);
|
||||||
|
orangeSale.setSalesNum(0);
|
||||||
|
saleMapper.addSalesNum(orangeSale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saleList = saleMapper.selectAll();
|
||||||
|
return selectAllProductSale(saleList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组装商品和销量信息
|
||||||
|
*
|
||||||
|
* @param orangeSaleList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<OrangeProductSale> selectAllProductSale(List<OrangeSale> orangeSaleList) {
|
||||||
|
List<OrangeProductSale> list = new ArrayList<>();
|
||||||
|
if (!CollectionUtils.isEmpty(orangeSaleList)) {
|
||||||
|
for (OrangeSale orangeSale : orangeSaleList) {
|
||||||
|
OrangeProduct orangeProduct = productMapper.selectById(orangeSale.getProductId());
|
||||||
|
OrangeProductSale orangeProductSale = new OrangeProductSale();
|
||||||
|
orangeProductSale.setAddTime(orangeProduct.getAddTime());
|
||||||
|
orangeProductSale.setImgUrl(orangeProduct.getImgUrl());
|
||||||
|
orangeProductSale.setName(orangeProduct.getName());
|
||||||
|
orangeProductSale.setPrice(orangeProduct.getPrice());
|
||||||
|
orangeProductSale.setSalesNum(orangeSale.getSalesNum());
|
||||||
|
list.add(orangeProductSale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新销量信息
|
||||||
|
*
|
||||||
|
* @param orangeSale
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer updateSaleNum(OrangeSale orangeSale) {
|
||||||
|
return saleMapper.updateSalesNum(orangeSale);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.example.orangesale_end.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ShoppingCartService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.example.orangesale_end.service;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
import com.example.orangesale_end.mapper.UserMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author zhijun
|
||||||
|
* @Date 2019/12/13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserService {
|
||||||
|
@Autowired
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
|
/** 用户登录验证
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public OrangeUser userLogin(OrangeUser orangeUser) {
|
||||||
|
return userMapper.userLogin(orangeUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册
|
||||||
|
*
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Integer userRegister(OrangeUser orangeUser) {
|
||||||
|
return userMapper.userRegister(orangeUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
server.port=8081
|
||||||
|
spring.datasource.url=jdbc:mysql://localhost:3306/orange?useUnicode=true&characterEncoding=UTF-8&useSSL=false
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
spring.datasource.username=root
|
||||||
|
spring.datasource.password=123456
|
||||||
|
#开启驼峰自动转换
|
||||||
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
|
mybatis.mapper-locations=classpath:mapper/*Mapper.xml
|
||||||
|
mybatis.type-aliases-package= com.test.vue.entity
|
||||||
|
|
||||||
|
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||||
|
spring.jackson.time-zone=GMT+8
|
||||||
|
|
||||||
|
#上传图片的路径
|
||||||
|
uploadFilePath=D:\\images\\
|
||||||
|
|
||||||
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
|
spring.servlet.multipart.max-request-size=200MB
|
@ -0,0 +1,16 @@
|
|||||||
|
<?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.example.orangesale_end.mapper.MessageMapper">
|
||||||
|
|
||||||
|
<insert id="insertMessage" parameterType="com.example.orangesale_end.entity.OrangeMessage">
|
||||||
|
insert into orange_message(content) values (#{content})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateMessage">
|
||||||
|
update orange_message set used='YES'
|
||||||
|
</update>
|
||||||
|
<select id="getMessage" resultType="com.example.orangesale_end.entity.OrangeMessage">
|
||||||
|
select content from orange_message where used='NO'
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,26 @@
|
|||||||
|
<?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.example.orangesale_end.mapper.ProductMapper">
|
||||||
|
<select id="selectById" resultType="com.example.orangesale_end.entity.OrangeProduct">
|
||||||
|
select id,name,img_url,price,add_time from orange_product where id=#{productId}
|
||||||
|
</select>
|
||||||
|
<select id="selectAll" resultType="com.example.orangesale_end.entity.OrangeProduct">
|
||||||
|
select id,name,img_url,price,add_time from orange_product
|
||||||
|
</select>
|
||||||
|
<update id="updateProduct">
|
||||||
|
update orange_product set
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
name =#{name},
|
||||||
|
img_url=#{imgUrl},
|
||||||
|
price=#{price}
|
||||||
|
</trim>
|
||||||
|
where id=#{id}
|
||||||
|
</update>
|
||||||
|
<insert id="addProduct" parameterType="com.example.orangesale_end.entity.OrangeProduct">
|
||||||
|
insert into orange_product(name,img_url,price,add_time) values (#{name},#{imgUrl},#{price},#{addTime})
|
||||||
|
</insert>
|
||||||
|
<delete id="deleteProduct">
|
||||||
|
delete from orange_product where id=#{id}
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?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.example.orangesale_end.mapper.SaleMapper">
|
||||||
|
<select id="getBySalesNum" resultType="com.example.orangesale_end.entity.OrangeSale">
|
||||||
|
select product_id,sales_num from orange_sale order by sales_num desc
|
||||||
|
</select>
|
||||||
|
<select id="selectAll" resultType="com.example.orangesale_end.entity.OrangeSale">
|
||||||
|
select product_id from orange_sale
|
||||||
|
</select>
|
||||||
|
<update id="updateSalesNum" parameterType="com.example.orangesale_end.entity.OrangeSale">
|
||||||
|
update orange_sale sales_num=#{salesNum} where product_id=#{productId}
|
||||||
|
</update>
|
||||||
|
<insert id="addSalesNum">
|
||||||
|
insert into orange_sale(product_id,sales_num) values (#{productId},#{salesNum})
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?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.example.orangesale_end.mapper.UserMapper">
|
||||||
|
<select id="userLogin" resultType="com.example.orangesale_end.entity.OrangeUser">
|
||||||
|
select * from orange_user where username=#{username} and password=#{password}
|
||||||
|
</select>
|
||||||
|
<insert id="userRegister">
|
||||||
|
insert into orange_user(username,password,sex,city) values(#{username},#{password},#{sex},#{city})
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,14 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
@ -0,0 +1,116 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<codeStyleSettings language="XML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||||
|
</indentOptions>
|
||||||
|
<arrangement>
|
||||||
|
<rules>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:android</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>xmlns:.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:id</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*:name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>name</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>style</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<rule>
|
||||||
|
<match>
|
||||||
|
<AND>
|
||||||
|
<NAME>.*</NAME>
|
||||||
|
<XML_ATTRIBUTE />
|
||||||
|
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||||
|
</AND>
|
||||||
|
</match>
|
||||||
|
<order>BY_NAME</order>
|
||||||
|
</rule>
|
||||||
|
</section>
|
||||||
|
</rules>
|
||||||
|
</arrangement>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="LOCAL" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="$PROJECT_DIR$/../environment/gradle/gradle-5.4.1" />
|
||||||
|
<option name="gradleJvm" value="1.8" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="Google" />
|
||||||
|
<option name="name" value="Google" />
|
||||||
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -0,0 +1,36 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 30
|
||||||
|
buildToolsVersion "30.0.2"
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.example.orangesale_end"
|
||||||
|
minSdkVersion 26
|
||||||
|
targetSdkVersion 30
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
|
implementation 'liji.library.dev:citypickerview:1.1.0'
|
||||||
|
implementation "com.squareup.okhttp3:okhttp:4.2.2"
|
||||||
|
implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.12'
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.example.orangesale_end;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
|
||||||
|
assertEquals("com.example.orangesale_end", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.orangesale_end">
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
|
<activity android:name=".MainActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity android:name=".activity.RegisterActivity"></activity>
|
||||||
|
<activity android:name=".activity.UserActivity" />
|
||||||
|
<activity android:name=".activity.CategoryActivity" />
|
||||||
|
<activity android:name=".activity.IndexActivity" />
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".service.TimeService"
|
||||||
|
android:enabled="true" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.example.orangesale_end;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.activity.IndexActivity;
|
||||||
|
import com.example.orangesale_end.activity.RegisterActivity;
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
import com.example.orangesale_end.netrequest.OkHttpUser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
private Button registerButton, loginButton;
|
||||||
|
private EditText usernameText, paswdEdit;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.user_login);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.register:
|
||||||
|
Intent intent = new Intent(MainActivity.this, RegisterActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
case R.id.login:
|
||||||
|
//注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//界面组件初始化
|
||||||
|
private void init() {
|
||||||
|
usernameText = findViewById(R.id.username);
|
||||||
|
paswdEdit = findViewById(R.id.password);
|
||||||
|
loginButton = findViewById(R.id.login);
|
||||||
|
loginButton.setOnClickListener(this);
|
||||||
|
registerButton = findViewById(R.id.register);
|
||||||
|
registerButton.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录验证
|
||||||
|
*/
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String username = usernameText.getText().toString();
|
||||||
|
String password = paswdEdit.getText().toString();
|
||||||
|
OrangeUser orangeUser = new OrangeUser();
|
||||||
|
orangeUser.setUsername(username);
|
||||||
|
orangeUser.setPassword(password);
|
||||||
|
OkHttpUser okHttpUser = new OkHttpUser();
|
||||||
|
OrangeUser orangeUser1 = null;
|
||||||
|
try {
|
||||||
|
orangeUser1 = okHttpUser.userLogin(orangeUser);
|
||||||
|
if (orangeUser1 != null) {
|
||||||
|
Intent intent1 = new Intent(MainActivity.this, IndexActivity.class);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("username", usernameText.getText().toString());
|
||||||
|
bundle.putString("password", orangeUser1.getPassword());
|
||||||
|
bundle.putString("city", orangeUser1.getCity());
|
||||||
|
bundle.putString("sex", orangeUser1.getSex());
|
||||||
|
intent1.putExtras(bundle);
|
||||||
|
startActivity(intent1);
|
||||||
|
} else {
|
||||||
|
//解决在子线程中调用Toast的异常情况处理
|
||||||
|
Looper.prepare();
|
||||||
|
Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.example.orangesale_end.activity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.app.FragmentTransaction;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.adapter.Adapter;
|
||||||
|
import com.example.orangesale_end.entity.Product;
|
||||||
|
import com.example.orangesale_end.fragment.SetDetailFragment;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class CategoryActivity extends Activity {
|
||||||
|
public OnChangeListener onchangedListener;
|
||||||
|
private List<Product> productList;
|
||||||
|
private List<String> productCategory = new ArrayList<>();
|
||||||
|
private ListView titleList;
|
||||||
|
private Adapter adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.content_category);
|
||||||
|
initData();
|
||||||
|
init();
|
||||||
|
SetDetailFragment fragment = new SetDetailFragment();
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||||
|
transaction.replace(R.id.category_detail, fragment);
|
||||||
|
transaction.commit();
|
||||||
|
titleList.setOnItemClickListener((parent, view, position, id) -> {
|
||||||
|
adapter.setSelectedPosition(position);
|
||||||
|
adapter.notifyDataSetInvalidated();
|
||||||
|
if (onchangedListener != null) {
|
||||||
|
onchangedListener.changeText(productList.get(position));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnChangeListener(OnChangeListener onChangeListener) {
|
||||||
|
this.onchangedListener = onChangeListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnChangeListener {
|
||||||
|
void changeText(Product product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
private void initData() {
|
||||||
|
productList = new ArrayList<>();
|
||||||
|
productCategory.add("橘子");
|
||||||
|
productCategory.add("橙子");
|
||||||
|
productCategory.add("柚子");
|
||||||
|
Product product = new Product();
|
||||||
|
product.setImageUrlId(R.drawable.arrow_down);
|
||||||
|
product.setProductName("橘子");
|
||||||
|
product.setProductPrice(new BigDecimal("9.9"));
|
||||||
|
Product product1 = new Product();
|
||||||
|
product1.setImageUrlId(R.drawable.orange);
|
||||||
|
product1.setProductName("橙子");
|
||||||
|
product1.setProductPrice(new BigDecimal("29.9"));
|
||||||
|
Product product2 = new Product();
|
||||||
|
product2.setImageUrlId(R.drawable.arrow_left);
|
||||||
|
product2.setProductName("柚子");
|
||||||
|
product2.setProductPrice(new BigDecimal("19.9"));
|
||||||
|
productList.add(product);
|
||||||
|
productList.add(product1);
|
||||||
|
productList.add(product2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化组件
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
titleList = findViewById(R.id.category_title_list);
|
||||||
|
adapter = new Adapter(productCategory, CategoryActivity.this);
|
||||||
|
titleList.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,176 @@
|
|||||||
|
package com.example.orangesale_end.activity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.lljjcoder.citypickerview.widget.CityPicker;
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
import com.example.orangesale_end.netrequest.OkHttpUser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
|
||||||
|
private EditText usernameEdit, passwordEdit, surePasswordEdit;
|
||||||
|
private TextView cityText;
|
||||||
|
private CityPicker cityPicker;
|
||||||
|
private Button regButton;
|
||||||
|
private RadioGroup sexGroup;
|
||||||
|
private String sexStr = "男";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.user_register);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 界面组件初始化
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
cityText = findViewById(R.id.reg_province);
|
||||||
|
cityText.setOnClickListener(this);
|
||||||
|
usernameEdit = findViewById(R.id.reg_username);
|
||||||
|
passwordEdit = findViewById(R.id.reg_password);
|
||||||
|
surePasswordEdit = findViewById(R.id.reg_sure_password);
|
||||||
|
regButton = findViewById(R.id.reg_register);
|
||||||
|
regButton.setOnClickListener(this);
|
||||||
|
sexGroup = findViewById(R.id.sex);
|
||||||
|
sexGroup.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.reg_province:
|
||||||
|
initCityPicker();
|
||||||
|
cityPicker.show();
|
||||||
|
break;
|
||||||
|
case R.id.reg_register:
|
||||||
|
//注册验证方法
|
||||||
|
//validateRegister();
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化城市选择器
|
||||||
|
*/
|
||||||
|
public void initCityPicker() {
|
||||||
|
cityPicker = new CityPicker.Builder(RegisterActivity.this)
|
||||||
|
.textSize(16)
|
||||||
|
.title("地址选择")
|
||||||
|
.backgroundPop(0xa0000000)
|
||||||
|
.titleBackgroundColor("#EFB81C")
|
||||||
|
.titleTextColor("#000000")
|
||||||
|
.backgroundPop(0xa0000000)
|
||||||
|
.confirTextColor("#000000")
|
||||||
|
.cancelTextColor("#000000")
|
||||||
|
.province("江西省")
|
||||||
|
.city("赣州市")
|
||||||
|
.district("章贡区")
|
||||||
|
.textColor(Color.parseColor("#000000"))
|
||||||
|
.provinceCyclic(true)
|
||||||
|
.cityCyclic(false)
|
||||||
|
.districtCyclic(false)
|
||||||
|
.visibleItemsCount(7)
|
||||||
|
.itemPadding(10)
|
||||||
|
.onlyShowProvinceAndCity(false)
|
||||||
|
.build();
|
||||||
|
cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onSelected(String... strings) {
|
||||||
|
String province = strings[0];
|
||||||
|
String city = strings[1];
|
||||||
|
String district = strings[2];
|
||||||
|
cityText.setText(String.format("%s %s %s", province, city, district));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
//根据用户选择来改变sex的值
|
||||||
|
sexStr = checkedId == R.id.reg_man ? "男" : "女";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册验证
|
||||||
|
*/
|
||||||
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String username = usernameEdit.getText().toString();
|
||||||
|
String password = passwordEdit.getText().toString();
|
||||||
|
String surePassword = surePasswordEdit.getText().toString();
|
||||||
|
String city = cityText.getText().toString();
|
||||||
|
//判断两次密码是否输入一致
|
||||||
|
if (password.equals(surePassword)) {
|
||||||
|
//这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作
|
||||||
|
if (!username.equals("") || !password.equals("")) {
|
||||||
|
if (!city.equals("")) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("username", username);
|
||||||
|
bundle.putString("password", password);
|
||||||
|
bundle.putString("sex", sexStr);
|
||||||
|
bundle.putString("city", city);
|
||||||
|
OrangeUser orangeUser = new OrangeUser();
|
||||||
|
orangeUser.setUsername(username);
|
||||||
|
orangeUser.setPassword(password);
|
||||||
|
orangeUser.setCity(city);
|
||||||
|
orangeUser.setSex(sexStr);
|
||||||
|
//将使用安卓自身带的SQLite数据库换成调用okhttp的方式
|
||||||
|
OkHttpUser okHttpUser = new OkHttpUser();
|
||||||
|
try {
|
||||||
|
if (okHttpUser.userRegister(orangeUser)) {
|
||||||
|
Intent intent = new Intent(RegisterActivity.this, IndexActivity.class);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
Looper.prepare();
|
||||||
|
Toast.makeText(RegisterActivity.this, "注册失败!", Toast.LENGTH_SHORT).show();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Looper.prepare();
|
||||||
|
Toast.makeText(RegisterActivity.this, "请选择地址", Toast.LENGTH_SHORT).show();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Looper.prepare();
|
||||||
|
Toast.makeText(RegisterActivity.this, "账号或密码未填写", Toast.LENGTH_SHORT).show();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Looper.prepare();
|
||||||
|
Toast.makeText(RegisterActivity.this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
|
||||||
|
Looper.loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.example.orangesale_end.activity;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
|
||||||
|
public class UserActivity extends Activity implements View.OnClickListener {
|
||||||
|
private ImageView userIconImage;
|
||||||
|
private TextView usernameText, userSexText, userCityText;
|
||||||
|
private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine, userSearchProductLine;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.content_user);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件初始化
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
userIconImage = findViewById(R.id.user_icon);
|
||||||
|
usernameText = findViewById(R.id.user_username);
|
||||||
|
userSexText = findViewById(R.id.user_sex);
|
||||||
|
userCityText = findViewById(R.id.user_city);
|
||||||
|
usernameLine = findViewById(R.id.user_username_line);
|
||||||
|
userSexline = findViewById(R.id.user_sex_line);
|
||||||
|
userCityLine = findViewById(R.id.user_city_line);
|
||||||
|
userPayLine = findViewById(R.id.user_pay);
|
||||||
|
userSettingLine = findViewById(R.id.user_setting);
|
||||||
|
userGeneralLine = findViewById(R.id.user_general);
|
||||||
|
// userSearchProductLine = findViewById(R.id.user_searchProduct);
|
||||||
|
userSearchProductLine.setOnClickListener(this);
|
||||||
|
setData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件赋值
|
||||||
|
*/
|
||||||
|
private void setData() {
|
||||||
|
Intent intent = UserActivity.this.getIntent();
|
||||||
|
Bundle bundle = intent.getExtras();
|
||||||
|
usernameText.setText(String.format("用户名:%s", bundle.getString("username")));
|
||||||
|
userSexText.setText(String.format("性别:%s", bundle.getString("sex")));
|
||||||
|
userCityText.setText(String.format("城市:%s", bundle.getString("city")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
/*case R.id.user_searchProduct:
|
||||||
|
Intent intent1 = new Intent(UserActivity.this, CategoryActivity.class);
|
||||||
|
startActivity(intent1);
|
||||||
|
break;*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.example.orangesale_end.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Adapter extends BaseAdapter {
|
||||||
|
private List<String> productCategory;
|
||||||
|
private LayoutInflater layoutInflater;
|
||||||
|
private int selectionPosition = -1;
|
||||||
|
|
||||||
|
public Adapter(List<String> productCategory, Context context) {
|
||||||
|
this.productCategory = productCategory;
|
||||||
|
this.layoutInflater = LayoutInflater.from(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return productCategory.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return productCategory.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ViewHolder viewHolder = null;
|
||||||
|
if (convertView == null) {
|
||||||
|
viewHolder = new ViewHolder();
|
||||||
|
convertView = layoutInflater.inflate(R.layout.category_list_item, null);
|
||||||
|
Log.i("adapts", "getView: " + convertView);
|
||||||
|
viewHolder.tv = convertView.findViewById(R.id.categor_titles);
|
||||||
|
convertView.setTag(viewHolder);
|
||||||
|
} else {
|
||||||
|
viewHolder = (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
viewHolder.tv.setText(productCategory.get(position));
|
||||||
|
if (selectionPosition == position) {
|
||||||
|
viewHolder.tv.setBackgroundColor(Color.YELLOW);
|
||||||
|
} else {
|
||||||
|
viewHolder.tv.setBackgroundColor(Color.WHITE);
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedPosition(int position) {
|
||||||
|
this.selectionPosition = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewHolder {
|
||||||
|
TextView tv;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package com.example.orangesale_end.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.entity.Condition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListViewAdapter extends BaseAdapter {
|
||||||
|
private List<Condition> conditionList;
|
||||||
|
private LayoutInflater layoutInflater;
|
||||||
|
private int selectedPosition = -1;
|
||||||
|
private int selectColor = Color.GRAY;
|
||||||
|
|
||||||
|
public ListViewAdapter(Context context, List<Condition> conditionList) {
|
||||||
|
this.conditionList = conditionList;
|
||||||
|
this.layoutInflater = LayoutInflater.from(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return conditionList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return conditionList.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ViewHolder viewHolder;
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = layoutInflater.inflate(R.layout.product_condition_item, null);
|
||||||
|
viewHolder = new ViewHolder();
|
||||||
|
viewHolder.imageView = convertView.findViewById(R.id.condition_icon);
|
||||||
|
viewHolder.jiange = convertView.findViewById(R.id.image_jiange);
|
||||||
|
viewHolder.textView = convertView.findViewById(R.id.condition_name);
|
||||||
|
viewHolder.linearLayout = convertView.findViewById(R.id.item_bg);
|
||||||
|
convertView.setTag(viewHolder);
|
||||||
|
} else {
|
||||||
|
viewHolder = (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
Condition condition = conditionList.get(position);
|
||||||
|
if (condition != null) {
|
||||||
|
viewHolder.imageView.setBackgroundResource(condition.getConditionIcon());
|
||||||
|
viewHolder.textView.setText(condition.getConditionName());
|
||||||
|
viewHolder.jiange.setBackgroundColor(Color.rgb(207, 207, 207));
|
||||||
|
if (selectedPosition == position) {
|
||||||
|
viewHolder.linearLayout.setBackgroundColor(selectColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewHolder {
|
||||||
|
ImageView imageView, jiange;
|
||||||
|
TextView textView;
|
||||||
|
LinearLayout linearLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.example.orangesale_end.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProductPack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProductAdapter extends BaseAdapter {
|
||||||
|
//private List<Product> productList;
|
||||||
|
private List<OrangeProductPack> orangeProductList;
|
||||||
|
private LayoutInflater layoutInflater;
|
||||||
|
|
||||||
|
public ProductAdapter(Context context, List<OrangeProductPack> orangeProductList) {
|
||||||
|
this.orangeProductList = orangeProductList;
|
||||||
|
this.layoutInflater = LayoutInflater.from(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return orangeProductList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return orangeProductList.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ViewHolder viewHolder;
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null);
|
||||||
|
viewHolder = new ViewHolder();
|
||||||
|
viewHolder.productImage = convertView.findViewById(R.id.category_product_image);
|
||||||
|
viewHolder.productName = convertView.findViewById(R.id.category_product_name);
|
||||||
|
viewHolder.productPrice = convertView.findViewById(R.id.category_product_price);
|
||||||
|
convertView.setTag(viewHolder);
|
||||||
|
} else {
|
||||||
|
viewHolder = (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
OrangeProductPack product = orangeProductList.get(position);
|
||||||
|
if (product != null) {
|
||||||
|
viewHolder.productImage.setImageBitmap(product.getImgBitmap());
|
||||||
|
viewHolder.productName.setText(product.getName());
|
||||||
|
viewHolder.productPrice.setText(String.format("%s元", String.valueOf(product.getPrice())));
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewHolder {
|
||||||
|
ImageView productImage;
|
||||||
|
TextView productName, productPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
public class Condition {
|
||||||
|
private Integer conditionIcon;
|
||||||
|
private String conditionName;
|
||||||
|
|
||||||
|
public Integer getConditionIcon() {
|
||||||
|
return conditionIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConditionIcon(Integer conditionIcon) {
|
||||||
|
this.conditionIcon = conditionIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConditionName() {
|
||||||
|
return conditionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConditionName(String conditionName) {
|
||||||
|
this.conditionName = conditionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Condition{" +
|
||||||
|
"conditionIcon=" + conditionIcon +
|
||||||
|
", conditionName='" + conditionName + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
public class OrangeMessage {
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getSendTime() {
|
||||||
|
return sendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSendTime(Timestamp sendTime) {
|
||||||
|
this.sendTime = sendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsed() {
|
||||||
|
return used;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsed(String used) {
|
||||||
|
this.used = used;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String content;
|
||||||
|
private Timestamp sendTime;
|
||||||
|
private String used;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OrangeMessage{" +
|
||||||
|
"id=" + id +
|
||||||
|
", content='" + content + '\'' +
|
||||||
|
", sendTime=" + sendTime +
|
||||||
|
", used='" + used + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
public class OrangeProduct {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private BigDecimal price;
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OrangeProduct{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", price=" + price +
|
||||||
|
", imgUrl='" + imgUrl + '\'' +
|
||||||
|
", addTime=" + addTime +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getAddTime() {
|
||||||
|
return addTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddTime(Timestamp addTime) {
|
||||||
|
this.addTime = addTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Timestamp addTime;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(BigDecimal price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImgUrl() {
|
||||||
|
return imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImgUrl(String imgUrl) {
|
||||||
|
this.imgUrl = imgUrl;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
public class OrangeProductPack {
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private Timestamp addTime;
|
||||||
|
private Bitmap imgBitmap;
|
||||||
|
|
||||||
|
public BigDecimal getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(BigDecimal price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OrangeProductPack{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", addTime=" + addTime +
|
||||||
|
", imgBitmap=" + imgBitmap +
|
||||||
|
", price=" + price +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getAddTime() {
|
||||||
|
return addTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddTime(Timestamp addTime) {
|
||||||
|
this.addTime = addTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap getImgBitmap() {
|
||||||
|
return imgBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImgBitmap(Bitmap imgBitmap) {
|
||||||
|
this.imgBitmap = imgBitmap;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
public class OrangeUser {
|
||||||
|
private Integer id;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String sex;
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(String sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OrangeUser{" +
|
||||||
|
"username='" + username + '\'' +
|
||||||
|
", password='" + password + '\'' +
|
||||||
|
", sex='" + sex + '\'' +
|
||||||
|
", city='" + city + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class Product {
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getProductPrice() {
|
||||||
|
return productPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductPrice(BigDecimal productPrice) {
|
||||||
|
this.productPrice = productPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getImageUrlId() {
|
||||||
|
return imageUrlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUrlId(Integer imageUrlId) {
|
||||||
|
this.imageUrlId = imageUrlId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer imageUrlId;
|
||||||
|
private String productName;
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Product{" +
|
||||||
|
"imageUrlId=" + imageUrlId +
|
||||||
|
", productName='" + productName + '\'' +
|
||||||
|
", productPrice=" + productPrice +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.example.orangesale_end.entity;
|
||||||
|
|
||||||
|
public class ShoppingCart {
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getProductId() {
|
||||||
|
return ProductId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Integer productId) {
|
||||||
|
ProductId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(Integer number) {
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private Integer userId;
|
||||||
|
private Integer ProductId;
|
||||||
|
/**
|
||||||
|
* 购买数量
|
||||||
|
*/
|
||||||
|
private Integer number;
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package com.example.orangesale_end.fragment;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.GridView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.SearchView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.adapter.ProductAdapter;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProductPack;
|
||||||
|
import com.example.orangesale_end.entity.Product;
|
||||||
|
import com.example.orangesale_end.netrequest.OkHttpClientProduct;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class IndexFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private SearchView searchView;
|
||||||
|
private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine;
|
||||||
|
private GridView gridView;
|
||||||
|
private ProductAdapter productAdapter;
|
||||||
|
private List<Product> productList;
|
||||||
|
private List<OrangeProductPack> list = new ArrayList<>();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false);
|
||||||
|
init(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化组件
|
||||||
|
*/
|
||||||
|
private void init(View view) {
|
||||||
|
searchView = view.findViewById(R.id.searchView);
|
||||||
|
searchView.setOnClickListener(this);
|
||||||
|
orangeLine = view.findViewById(R.id.chengzi);
|
||||||
|
orangeLine.setOnClickListener(this);
|
||||||
|
youziLine = view.findViewById(R.id.youzi);
|
||||||
|
youziLine.setOnClickListener(this);
|
||||||
|
juziLine = view.findViewById(R.id.juzi);
|
||||||
|
juziLine.setOnClickListener(this);
|
||||||
|
xiguaLine = view.findViewById(R.id.xigua);
|
||||||
|
xiguaLine.setOnClickListener(this);
|
||||||
|
liLine = view.findViewById(R.id.li);
|
||||||
|
liLine.setOnClickListener(this);
|
||||||
|
lemonLine = view.findViewById(R.id.lemon);
|
||||||
|
lemonLine.setOnClickListener(this);
|
||||||
|
mangguoLine = view.findViewById(R.id.mangguo);
|
||||||
|
mangguoLine.setOnClickListener(this);
|
||||||
|
appleLine = view.findViewById(R.id.apple);
|
||||||
|
appleLine.setOnClickListener(this);
|
||||||
|
gridView = view.findViewById(R.id.index_famous_gridview);
|
||||||
|
//initData();
|
||||||
|
new SearchProductTask().execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化商品数据
|
||||||
|
*/
|
||||||
|
private void initData() {
|
||||||
|
productList = new ArrayList<>();
|
||||||
|
Product product = new Product();
|
||||||
|
product.setImageUrlId(R.drawable.taocan1);
|
||||||
|
product.setProductName("熟食龙虾套餐一");
|
||||||
|
product.setProductPrice(new BigDecimal("29.9"));
|
||||||
|
Product product1 = new Product();
|
||||||
|
product1.setImageUrlId(R.drawable.taocan2);
|
||||||
|
product1.setProductName("熟食龙虾套餐二");
|
||||||
|
product1.setProductPrice(new BigDecimal("19.9"));
|
||||||
|
Product product2 = new Product();
|
||||||
|
product2.setImageUrlId(R.drawable.youzip);
|
||||||
|
product2.setProductName("柚子");
|
||||||
|
product2.setProductPrice(new BigDecimal("19.9"));
|
||||||
|
Product product3 = new Product();
|
||||||
|
product3.setImageUrlId(R.drawable.xiguap);
|
||||||
|
product3.setProductName("西瓜");
|
||||||
|
product3.setProductPrice(new BigDecimal("19.9"));
|
||||||
|
Product product4 = new Product();
|
||||||
|
product4.setImageUrlId(R.drawable.applep);
|
||||||
|
product4.setProductName("苹果");
|
||||||
|
product4.setProductPrice(new BigDecimal("49.9"));
|
||||||
|
Product product5 = new Product();
|
||||||
|
product5.setImageUrlId(R.drawable.lemonp);
|
||||||
|
product5.setProductName("柠檬");
|
||||||
|
product5.setProductPrice(new BigDecimal("9.9"));
|
||||||
|
productList.add(product);
|
||||||
|
productList.add(product1);
|
||||||
|
productList.add(product2);
|
||||||
|
productList.add(product3);
|
||||||
|
productList.add(product4);
|
||||||
|
productList.add(product5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送网络请求获取数据
|
||||||
|
*/
|
||||||
|
class SearchProductTask extends AsyncTask<Void, Void, List<OrangeProductPack>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<OrangeProductPack> doInBackground(Void... voids) {
|
||||||
|
OkHttpClientProduct clientProduct = new OkHttpClientProduct();
|
||||||
|
try {
|
||||||
|
list = clientProduct.getProductPack();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<OrangeProductPack> orangeProducts) {
|
||||||
|
productAdapter = new ProductAdapter(getActivity(), list);
|
||||||
|
gridView.setAdapter(productAdapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.example.orangesale_end.fragment;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
|
||||||
|
public class PearsonFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private ImageView userIconImage;
|
||||||
|
private TextView usernameText, userSexText, userCityText;
|
||||||
|
private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine;
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_user, container, false);
|
||||||
|
init(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件初始化
|
||||||
|
*/
|
||||||
|
private void init(View view) {
|
||||||
|
userIconImage = view.findViewById(R.id.user_icon);
|
||||||
|
usernameText = view.findViewById(R.id.user_username);
|
||||||
|
userSexText = view.findViewById(R.id.user_sex);
|
||||||
|
userCityText = view.findViewById(R.id.user_city);
|
||||||
|
usernameLine = view.findViewById(R.id.user_username_line);
|
||||||
|
userSexline = view.findViewById(R.id.user_sex_line);
|
||||||
|
userCityLine = view.findViewById(R.id.user_city_line);
|
||||||
|
userPayLine = view.findViewById(R.id.user_pay);
|
||||||
|
userSettingLine = view.findViewById(R.id.user_setting);
|
||||||
|
userGeneralLine = view.findViewById(R.id.user_general);
|
||||||
|
setData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件赋值
|
||||||
|
*/
|
||||||
|
private void setData() {
|
||||||
|
Bundle bundle = getArguments();
|
||||||
|
usernameText.setText(String.format("用户名:%s", bundle.getString("username")));
|
||||||
|
userSexText.setText(String.format("性别:%s", bundle.getString("sex")));
|
||||||
|
userCityText.setText(String.format("城市:%s", bundle.getString("city")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
package com.example.orangesale_end.fragment;
|
||||||
|
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.GridView;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.adapter.ListViewAdapter;
|
||||||
|
import com.example.orangesale_end.adapter.ProductAdapter;
|
||||||
|
import com.example.orangesale_end.entity.Condition;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProductPack;
|
||||||
|
import com.example.orangesale_end.netrequest.OkHttpClientProduct;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProductFragment extends Fragment {
|
||||||
|
private Spinner conditonListSpinner;
|
||||||
|
private ListViewAdapter listViewAdapter;
|
||||||
|
private List<Condition> conditionList;
|
||||||
|
private GridView productGridView;
|
||||||
|
private List<OrangeProductPack> orangeProductList = new ArrayList<>();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_product, container, false);
|
||||||
|
init(view);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件初始化方法
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
*/
|
||||||
|
private void init(View view) {
|
||||||
|
conditonListSpinner = view.findViewById(R.id.product_select_condition);
|
||||||
|
initCondList();
|
||||||
|
listViewAdapter = new ListViewAdapter(getActivity(), conditionList);
|
||||||
|
conditonListSpinner.setAdapter(listViewAdapter);
|
||||||
|
productGridView = view.findViewById(R.id.product_list);
|
||||||
|
new SearchProductTask().execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化conditionList
|
||||||
|
*/
|
||||||
|
private void initCondList() {
|
||||||
|
conditionList = new ArrayList<>();
|
||||||
|
Condition allCondition = new Condition();
|
||||||
|
allCondition.setConditionIcon(R.drawable.all);
|
||||||
|
allCondition.setConditionName("全部");
|
||||||
|
Condition saleCondition = new Condition();
|
||||||
|
saleCondition.setConditionIcon(R.drawable.salenum);
|
||||||
|
saleCondition.setConditionName("按销量高低排序");
|
||||||
|
Condition timeCondition = new Condition();
|
||||||
|
timeCondition.setConditionIcon(R.drawable.time);
|
||||||
|
timeCondition.setConditionName("按上市时间排序");
|
||||||
|
Condition priceCondition = new Condition();
|
||||||
|
priceCondition.setConditionIcon(R.drawable.price);
|
||||||
|
priceCondition.setConditionName("按商品价格排序");
|
||||||
|
conditionList.add(allCondition);
|
||||||
|
conditionList.add(saleCondition);
|
||||||
|
conditionList.add(timeCondition);
|
||||||
|
conditionList.add(priceCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送网络请求获取数据
|
||||||
|
*/
|
||||||
|
class SearchProductTask extends AsyncTask<Void, Void, List<OrangeProductPack>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<OrangeProductPack> doInBackground(Void... voids) {
|
||||||
|
OkHttpClientProduct clientProduct = new OkHttpClientProduct();
|
||||||
|
try {
|
||||||
|
orangeProductList = clientProduct.getProductPack();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return orangeProductList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<OrangeProductPack> orangeProducts) {
|
||||||
|
ProductAdapter productAdapter = new ProductAdapter(getActivity(), orangeProductList);
|
||||||
|
productGridView.setAdapter(productAdapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.example.orangesale_end.fragment;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Fragment;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.orangesale_end.R;
|
||||||
|
import com.example.orangesale_end.activity.CategoryActivity;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class SetDetailFragment extends Fragment {
|
||||||
|
private View view;
|
||||||
|
private ImageView imageView;
|
||||||
|
private TextView nameText, priceText;
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
view = inflater.inflate(R.layout.categoty_detail_content, container, false);
|
||||||
|
if (view != null) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
CategoryActivity categoryActivity = (CategoryActivity) getActivity();
|
||||||
|
Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> {
|
||||||
|
Log.i("sss", "onCreateView: " + product.getProductName());
|
||||||
|
imageView.setBackgroundResource(product.getImageUrlId());
|
||||||
|
nameText.setText(product.getProductName());
|
||||||
|
priceText.setText(product.getProductPrice().toString());
|
||||||
|
});
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容组件初始化
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
imageView = view.findViewById(R.id.category_product_image);
|
||||||
|
nameText = view.findViewById(R.id.category_product_name);
|
||||||
|
priceText = view.findViewById(R.id.category_product_price);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.example.orangesale_end.netrequest;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProduct;
|
||||||
|
import com.example.orangesale_end.entity.OrangeProductPack;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
public class OkHttpClientProduct {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询商品信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<OrangeProduct> getProduct() throws IOException {
|
||||||
|
OkHttpClient okHttpClient = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("http://10.21.244.195:8081/orange/product/search")
|
||||||
|
.build();
|
||||||
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
|
JSONObject jsonObject = JSON.parseObject(Objects.requireNonNull(response.body()).string());
|
||||||
|
List<OrangeProduct> list = JSON.parseObject(jsonObject.getString("data"), new TypeReference<List<OrangeProduct>>() {
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图片
|
||||||
|
*
|
||||||
|
* @param imgUrl
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public Bitmap getImageBitMap(String imgUrl) throws IOException {
|
||||||
|
Bitmap bitmap;
|
||||||
|
OkHttpClient okHttpClient = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(imgUrl)
|
||||||
|
.build();
|
||||||
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
|
byte[] bytes = Objects.requireNonNull(response.body()).bytes();
|
||||||
|
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||||
|
return bitmap;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
|
||||||
|
public List<OrangeProductPack> getProductPack() throws IOException {
|
||||||
|
List<OrangeProductPack> packList = new ArrayList<>();
|
||||||
|
List<OrangeProduct> list = getProduct();
|
||||||
|
for (OrangeProduct orangeProduct : list) {
|
||||||
|
OrangeProductPack orangeProductPack = new OrangeProductPack();
|
||||||
|
orangeProductPack.setId(orangeProduct.getId());
|
||||||
|
orangeProductPack.setImgBitmap(getImageBitMap(orangeProduct.getImgUrl()));
|
||||||
|
orangeProductPack.setAddTime(orangeProduct.getAddTime());
|
||||||
|
orangeProductPack.setPrice(orangeProduct.getPrice());
|
||||||
|
packList.add(orangeProductPack);
|
||||||
|
}
|
||||||
|
return packList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package com.example.orangesale_end.netrequest;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.example.orangesale_end.entity.OrangeUser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
public class OkHttpUser {
|
||||||
|
/**
|
||||||
|
* 用户登录验证
|
||||||
|
*
|
||||||
|
* @param orangeUser
|
||||||
|
*/
|
||||||
|
public OrangeUser userLogin(OrangeUser orangeUser) throws IOException {
|
||||||
|
OkHttpClient okHttpClient= new OkHttpClient();
|
||||||
|
//数据类型为json格式
|
||||||
|
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||||
|
//将对象转为JSON字符串
|
||||||
|
String jsonStr = JSONObject.toJSONString(orangeUser);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonStr, mediaType);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("http://10.21.244.195:8081/orange/user/login")
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
|
|
||||||
|
String responseStr = response.body().string();
|
||||||
|
System.out.println("responseStr = " + responseStr);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(responseStr);
|
||||||
|
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
|
||||||
|
OrangeUser orangeUser1 = JSON.toJavaObject(jsonObject1, OrangeUser.class);
|
||||||
|
return orangeUser1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户注册
|
||||||
|
*
|
||||||
|
* @param orangeUser
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public boolean userRegister(OrangeUser orangeUser) throws IOException {
|
||||||
|
OkHttpClient okHttpClient = new OkHttpClient();
|
||||||
|
//数据类型为json格式
|
||||||
|
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
||||||
|
//将对象转为JSON字符串
|
||||||
|
String jsonStr = JSONObject.toJSONString(orangeUser);
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonStr, mediaType);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("http://10.21.244.195:8081/orange/user/register")
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
Response response = okHttpClient.newCall(request).execute();
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body().string());
|
||||||
|
Log.i("register", "userRegister: "+jsonObject);
|
||||||
|
return jsonObject.getBoolean("flag");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="78.5885"
|
||||||
|
android:endY="90.9159"
|
||||||
|
android:startX="48.7653"
|
||||||
|
android:startY="61.0927"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 231 B |
After Width: | Height: | Size: 233 B |
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="false">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#EFB81C" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#c0c0c0" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="false">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#c0c0c0" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#c0c0c0" />
|
||||||
|
<corners android:radius="10dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 790 B |
After Width: | Height: | Size: 14 KiB |
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#008577"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
@ -0,0 +1,34 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="78.5885"
|
||||||
|
android:endY="90.9159"
|
||||||
|
android:startX="48.7653"
|
||||||
|
android:startY="61.0927"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<!-- 连框颜色值 -->
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#dddddd" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<!-- 主体背景颜色值 -->
|
||||||
|
<item android:bottom="1dp"> <!--设置只有底部有边框-->
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#ffffff" />
|
||||||
|
<corners android:radius="10dp"></corners>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 10 KiB |