后端初始化

This commit is contained in:
wty 2022-09-16 15:30:16 +08:00
parent cbfc1b8470
commit 23f7512609
43 changed files with 3078 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
xiuosiot-backend/target/
xiuosiot-backend/.idea/
xiuosiot-backend/.mvn/

23
xiuosiot-backend/HELP.md Normal file
View File

@ -0,0 +1,23 @@
# Getting Started
### Reference Documentation
For further reference, please consider the following sections:
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.3/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.3/maven-plugin/reference/html/#build-image)
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#web)
* [WebSocket](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#messaging.websockets)
* [MyBatis Framework](https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/)
* [Spring Data JDBC](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#data.sql.jdbc)
### Guides
The following guides illustrate how to use some features concretely:
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Using WebSocket to build an interactive web application](https://spring.io/guides/gs/messaging-stomp-websocket/)
* [MyBatis Quick Start](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start)
* [Using Spring Data JDBC](https://github.com/spring-projects/spring-data-examples/tree/master/jdbc/basics)

View File

@ -0,0 +1,2 @@
# xiuosiot

316
xiuosiot-backend/mvnw vendored Normal file
View File

@ -0,0 +1,316 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

188
xiuosiot-backend/mvnw.cmd vendored Normal file
View File

@ -0,0 +1,188 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

144
xiuosiot-backend/pom.xml Normal file
View File

@ -0,0 +1,144 @@
<?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.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.aiit</groupId>
<artifactId>xiuos</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>xiuos</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--MyBatis分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<!-- MyBatis 生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.32</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<!--mybatis自动生成代码插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.0</version>
<!-- mybatis.generator需要依赖的数据库驱动-->
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.softwareloop</groupId>
<artifactId>mybatis-generator-lombok-plugin</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<!-- mybatis用于生成代码的配置文件路径-->
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.yml</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,38 @@
package com.aiit.xiuos.Interceptor;
import com.aiit.xiuos.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 定义拦截器
*/
@Slf4j
@Component
public class SessionInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession();
// 从session中获取用户信息
UserInfo comUser = (UserInfo) session.getAttribute("user");
// session过期
if (comUser == null) {
response.setContentType("application/json; charset=utf-8");
response.getWriter().print("{\"code\":\"200300\",\"message\":\"sessionTimeOut\"}");
log.info("session过期需重新登录");
return false;
}else{
return true;
}
}
}

View File

@ -0,0 +1,35 @@
package com.aiit.xiuos.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
class MyMvcConfigurer implements WebMvcConfigurer {
/**
* 注入第一步定义好的拦截器
*/
@Autowired
private SessionInterceptor sessionInterceptor;
/**
* 定义拦截规则, 根据自己需要进行配置拦截和排除的接口
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(sessionInterceptor)
// .addPathPatterns() 是配置需要拦截的路径
.addPathPatterns("/**")
// .excludePathPatterns() 用于排除拦截
.excludePathPatterns("/login") // 排除登录接口
.excludePathPatterns("/loginOut") //排除登出接口
.excludePathPatterns("/**/register") //排除注册接口
.excludePathPatterns("/lib/**") // 排除静态文件
.excludePathPatterns("/js/**")
.excludePathPatterns("/img/**")
.excludePathPatterns("/css/**");
}
}

View File

@ -0,0 +1,7 @@
package com.aiit.xiuos.Utils;
public class Constant {
public static final String SUCCESS_CODE = "200000";
public static final String ERROR_CODE = "200400";
public static final String SessionTimeOut_CODE="200300";
}

View File

@ -0,0 +1,31 @@
package com.aiit.xiuos.Utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 用于生产各种各样的ID
*/
public class GenerateIdUtil {
public static synchronized String getId(String org,String user){
StringBuffer sb = new StringBuffer();
String time = new SimpleDateFormat("yyyyMMddHHmmss").format(System.currentTimeMillis());
sb.append(time);
sb.append("-"+org);
sb.append("-"+user);
return sb.toString();
}
public static void main(String[] args) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = sdf.format(System.currentTimeMillis());
Date date = (Date) sdf.parse(time);
System.out.println(date);
}
}

View File

@ -0,0 +1,150 @@
package com.aiit.xiuos.Utils;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class HttpClientUtil {
private static String tokenString = "";
private static String AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED";
private static CloseableHttpClient httpClient = null;
/**
* 以get方式调用第三方接口
* @param url
* @param token
* @return
*/
public static JSONObject doGet(String url) {
//创建HttpClient对象
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(url);
// if (null != tokenString && !tokenString.equals("")) {
// tokenString = getToken();
// }
//api_gateway_auth_token自定义header头用于token验证使用
httpGet.addHeader("api_gateway_auth_token",tokenString);
httpGet.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
try {
HttpResponse response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//返回json格式
String res = EntityUtils.toString(response.getEntity());
return (JSONObject) JSONObject.parse(res);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* 以post方式调用第三方接口
* @param url
* @param json
* @return
*/
public static String doPost(String url, JSONObject json) {
if (null == httpClient) {
httpClient = HttpClientBuilder.create().build();
}
HttpPost httpPost = new HttpPost(url);
if (null != tokenString && tokenString.equals("")) {
tokenString = getToken();
}
//api_gateway_auth_token自定义header头用于token验证使用
httpPost.addHeader("api_gateway_auth_token", tokenString);
httpPost.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
try {
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding("UTF-8");
//发送json数据需要设置contentType
se.setContentType("application/x-www-form-urlencoded");
//设置请求参数
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//返回json格式
String res = EntityUtils.toString(response.getEntity());
return res;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (httpClient != null){
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
/**
* 获取第三方接口的token
*/
public static String getToken() {
String token = "";
JSONObject object = new JSONObject();
object.put("appid", "appid");
object.put("secretkey", "secretkey");
if (null == httpClient) {
httpClient = HttpClientBuilder.create().build();
}
HttpPost httpPost = new HttpPost("http://localhost/login");
httpPost.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36");
try {
StringEntity se = new StringEntity(object.toString());
se.setContentEncoding("UTF-8");
//发送json数据需要设置contentType
se.setContentType("application/x-www-form-urlencoded");
//设置请求参数
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
//这里可以把返回的结果按照自定义的返回数据结果把string转换成自定义类
//ResultTokenBO result = JSONObject.parseObject(response, ResultTokenBO.class);
//把response转为jsonObject
JSONObject result = (JSONObject) JSONObject.parseObject(String.valueOf(response));
if (result.containsKey("token")) {
token = result.getString("token");
}
} catch (IOException e) {
e.printStackTrace();
}
return token;
}
/**
* 测试
*/
public static void test(String telephone) {
JSONObject object = new JSONObject();
object.put("telephone", telephone);
//首先获取token
tokenString = getToken();
String response = doPost("http://localhost/searchUrl", object);
//如果返回的结果是list形式的需要使用JSONObject.parseArray转换
//List<Result> list = JSONObject.parseArray(response, Result.class);
System.out.println(response);
}
public static void main(String[] args) {
test("12345678910");
}
}

View File

@ -0,0 +1,160 @@
package com.aiit.xiuos.Utils;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class MyUtils {
public static void main(String[] args) {
// 测试 导出
// List<String> dataList = new ArrayList<String>();
// dataList.add("1,张三,男");
// dataList.add("2,李四,男");
// dataList.add("3,小红,女");
// boolean isSuccess = exportCsv(new File("D:/test.csv"), dataList);
// System.out.println(isSuccess);
// 测试 导入
// List<String> dataList = importCsv(new File("D:/test.csv"));
// if (dataList != null && !dataList.isEmpty()) {
// for (String data : dataList) {
// System.out.println(data);
// }
// }
JSONObject result = MyUtils.StringToJson("");
String jsonString = MyUtils.jsonToString(result);
System.out.println(jsonString);
}
public static String getIp(HttpServletRequest request){
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
public static String getTime(){
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis());
return time;
}
/**
* 导出
*
* @param file
* csv文件(路径+文件名)csv文件不存在会自动创建
* @param dataList
* 数据
* @return
*/
public static boolean exportCsv(File file, List<String> dataList) {
boolean isSucess = false;
FileOutputStream out = null;
OutputStreamWriter osw = null;
BufferedWriter bw = null;
try {
out = new FileOutputStream(file);
osw = new OutputStreamWriter(out);
bw = new BufferedWriter(osw);
if (dataList != null && !dataList.isEmpty()) {
for (String data : dataList) {
bw.append(data).append("\r\n");
}
}
isSucess = true;
} catch (Exception e) {
isSucess = false;
} finally {
if (bw != null) {
try {
bw.close();
bw = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (osw != null) {
try {
osw.close();
osw = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (out != null) {
try {
out.close();
out = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
return isSucess;
}
/**
* 导入
*
* @param file
* csv文件(路径+文件)
* @return
*/
public static List<String> importCsv(File file) {
List<String> dataList = new ArrayList<String>();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
String line = "";
while ((line = br.readLine()) != null) {
dataList.add(line);
}
} catch (Exception e) {
} finally {
if (br != null) {
try {
br.close();
br = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
return dataList;
}
public static JSONObject StringToJson(String jsonString){
JSONObject jsonObject =JSONObject.parseObject(jsonString);
return jsonObject;
}
public static String jsonToString(JSONObject jsonObject){
return jsonObject.toJSONString();
}
}

View File

@ -0,0 +1,19 @@
package com.aiit.xiuos.Utils;
import lombok.Data;
@Data
public class ResultRespons {
private String code;
private String message;
private Object data;
public ResultRespons(String code,String message,Object data){
this.code= code;
this.message=message;
this.data=data;
}
public ResultRespons(String code,String message){
this.code= code;
this.message=message;
}
}

View File

@ -0,0 +1,22 @@
package com.aiit.xiuos;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {"com.aiit.xiuos"})
@MapperScan("com.aiit.xiuos.dao")
@EnableScheduling
@EnableCaching
public class XiuosApplication {
public static void main(String[] args) {
SpringApplication.run(XiuosApplication.class, args);
}
}

View File

@ -0,0 +1,69 @@
package com.aiit.xiuos.controller;
import com.aiit.xiuos.Utils.Constant;
import com.aiit.xiuos.Utils.GenerateIdUtil;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.DeviceInfo;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.DeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/device")
public class DeviceController {
@Autowired
private DeviceInfoService deviceInfoService;
@PostMapping("/add")
public ResultRespons addDevice(@RequestBody DeviceInfo deviceInfo, HttpServletRequest request){
List<DeviceInfo> devs =deviceInfoService.selectbyNo(deviceInfo.getNo());
if(devs==null||devs.size()>0){
return new ResultRespons(Constant.ERROR_CODE,"设备已存在!");
}
UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user");
if(userInfo==null){
return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!");
}
String id =GenerateIdUtil.getId(userInfo.getUsername(),userInfo.getOrg());
deviceInfo.setId(id);
deviceInfo.setUpdatetime(MyUtils.getTime());
int res=deviceInfoService.addDevice(deviceInfo);
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"新增设备成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"新增设备失败!");
}
@GetMapping("/select")
public ResultRespons selectDevice(@RequestParam int activestatus, HttpServletRequest request){
List<DeviceInfo> deviceInfoList =null;
if(1==activestatus){
deviceInfoList=deviceInfoService.selectActiveDevice();
}else if(0==activestatus){
deviceInfoList=deviceInfoService.selectUnActiveDevice();
}
return new ResultRespons(Constant.SUCCESS_CODE,"查询设备成功!",deviceInfoList);
}
@PostMapping("/delete")
public ResultRespons deleteDevice(@RequestBody DeviceInfo deviceInfo, HttpServletRequest request){
int res=deviceInfoService.deleteDeviceByNo(deviceInfo.getNo());
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"删除设备成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"删除设备失败!");
}
@PostMapping("/active")
public ResultRespons activeDevice(@RequestBody DeviceInfo deviceInfo, HttpServletRequest request){
int res=deviceInfoService.activeDeviceByNo(deviceInfo.getNo());
if(1==res){
return new ResultRespons(Constant.SUCCESS_CODE,"激活设备成功!");
}
return new ResultRespons(Constant.ERROR_CODE,"激活设备失败!");
}
}

View File

@ -0,0 +1,41 @@
package com.aiit.xiuos.controller;
import com.aiit.xiuos.Utils.Constant;
import com.aiit.xiuos.Utils.HttpClientUtil;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.dao.mappers.AvgDayDataMapper;
import com.aiit.xiuos.model.AvgDayData;
import com.aiit.xiuos.service.AvgDayDataService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/data")
public class DeviceDataController {
@Autowired
AvgDayDataService avgDayDataService;
@GetMapping("/getAll")
public ResultRespons getAllDataFromDSD(HttpServletRequest request){
JSONObject result = HttpClientUtil.doGet("http://115.238.53.60:33333/Month/allData");
return new ResultRespons(Constant.SUCCESS_CODE,"查询数据成功!",result);
}
@GetMapping("/getDayAvg")
public ResultRespons getDayAvgData(){
List<AvgDayData> list = avgDayDataService.getAvgDayData();
AvgDayData avg =avgDayDataService.getAvg();
list.add(0,avg);
if(list!=null){
return new ResultRespons(Constant.SUCCESS_CODE,"查询数据成功!",list);
}
return new ResultRespons(Constant.ERROR_CODE,"查询数据失败");
}
}

View File

@ -0,0 +1,44 @@
package com.aiit.xiuos.controller;
import com.aiit.xiuos.Utils.Constant;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
public class LoginController {
@Autowired
private UserInfoService userInfoService;
@PostMapping("/login")
public ResultRespons login (@RequestBody UserInfo userInfo, HttpServletRequest request) {
UserInfo user = userInfoService.login(userInfo);
if(null!=user){
HttpSession session = request.getSession();
session.setAttribute("user",user);//session存用户
System.out.println("session======="+session.getId());
String ip = MyUtils.getIp(request);
userInfoService.updateLoginInfo(MyUtils.getTime(),ip,user.getId());
System.out.println("ip++++++++===="+ip);
return new ResultRespons(Constant.SUCCESS_CODE,"登录成功");
}
return new ResultRespons(Constant.ERROR_CODE,"登录失败,用户名或密码有误");
}
@PostMapping("/loginOut")
public Object loginOut(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
session.invalidate();
return new ResultRespons(Constant.SUCCESS_CODE,"用户登出");
}
}

View File

@ -0,0 +1,38 @@
package com.aiit.xiuos.controller;
import com.aiit.xiuos.Utils.Constant;
import com.aiit.xiuos.Utils.GenerateIdUtil;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.Utils.ResultRespons;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserInfoService userInfoService;
@PostMapping("/register")
public ResultRespons addUser (@RequestBody UserInfo userInfo, HttpServletRequest request) {
String id = GenerateIdUtil.getId(userInfo.getUsername(),userInfo.getOrg());
userInfo.setId(id);
String ip = MyUtils.getIp(request);
userInfo.setLastloginip(ip);
userInfo.setLastlogintime(MyUtils.getTime());
int res= userInfoService.addUser(userInfo);
if(res==1){
return new ResultRespons(Constant.SUCCESS_CODE,"注册成功");
}
return new ResultRespons(Constant.ERROR_CODE,"注册失败");
}
}

View File

@ -0,0 +1,45 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.AvgDayData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface AvgDayDataMapper {
int deleteByPrimaryKey(String id);
int insert(AvgDayData record);
int insertSelective(AvgDayData record);
AvgDayData selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(AvgDayData record);
int updateByPrimaryKey(AvgDayData record);
@Select("select * from avg_day_data order by datatime desc limit 24")
List<AvgDayData> selectAvgDayData();
@Select("SELECT CAST\n" +
"\t( SUM ( A.windspeed ) / 24 AS DECIMAL ( 18, 2 ) ) AS windspeed,\n" +
"\tCAST ( SUM ( A.noise ) / 24 AS DECIMAL ( 18, 2 ) ) AS noise,\n" +
"\tCAST ( SUM ( A.methanal ) / 24 AS DECIMAL ( 18, 2 ) ) AS methanal,\n" +
"\tCAST ( SUM ( A.pm1d0 ) / 24 AS DECIMAL ( 18, 2 ) ) AS pm1d0,\n" +
"\tCAST ( SUM ( A.pm2d5 ) / 24 AS DECIMAL ( 18, 2 ) ) AS pm2d5,\n" +
"\tCAST ( SUM ( A.pm10 ) / 24 AS DECIMAL ( 18, 2 ) ) AS pm10,\n" +
"\tCAST ( SUM ( A.so2 ) / 24 AS DECIMAL ( 18, 2 ) ) AS so2,\n" +
"\tCAST ( SUM ( A.temperature ) / 24 AS DECIMAL ( 18, 2 ) ) AS temperature,\n" +
"\tCAST ( SUM ( A.humidness ) / 24 AS DECIMAL ( 18, 2 ) ) AS humidness,\n" +
"\tCAST ( SUM ( A.co2 ) / 24 AS DECIMAL ( 18, 2 ) ) AS co2,\n" +
"\tCAST ( SUM ( A.airpressure ) / 24 AS DECIMAL ( 18, 2 ) ) AS airpressure,\n" +
"\tCAST ( SUM ( A.tvoc ) / 24 AS DECIMAL ( 18, 2 ) ) AS tvoc,\n" +
"\tCAST ( SUM ( A.ethanol ) / 24 AS DECIMAL ( 18, 2 ) ) AS ethanol,\n" +
"\tCAST ( SUM ( A.methane ) / 24 AS DECIMAL ( 18, 2 ) ) AS methane \n" +
"FROM\n" +
"\t( SELECT * FROM avg_day_data ORDER BY datatime DESC LIMIT 24 ) AS A")
AvgDayData selectAvg();
}

View File

@ -0,0 +1,40 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.DeviceInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface DeviceInfoMapper {
int deleteByPrimaryKey(@Param("id") String id, @Param("no") String no);
int insert(DeviceInfo record);
int insertSelective(DeviceInfo record);
DeviceInfo selectByPrimaryKey(@Param("id") String id, @Param("no") String no);
int updateByPrimaryKeySelective(DeviceInfo record);
int updateByPrimaryKey(DeviceInfo record);
@Update("update device_info set activestatus=1,updatetime=#{time} where no =#{no}")
int updateStatusByNo(@Param("time") String updateTime, @Param("no") String no);
@Select("select * from device_info where activestatus=1")
List<DeviceInfo> selectActiveDevices();
@Select("select * from device_info where activestatus=0")
List<DeviceInfo> selectUnActiveDevices();
@Delete("delete from device_info where no =#{no}")
int deleteByNo(@Param("no") String no);
@Select("select * from device_info where no=#{no}")
List<DeviceInfo> selectByNo(@Param("no") String no);
}

View File

@ -0,0 +1,28 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
@Repository
public interface UserInfoMapper {
int deleteByPrimaryKey(String id);
int insert(UserInfo record);
int insertSelective(UserInfo record);
UserInfo selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(UserInfo record);
int updateByPrimaryKey(UserInfo record);
@Select("select * from user_info where username= #{username} and password = #{password}")
UserInfo getUser(@Param("username") String username, @Param("password") String password);
@Update("update user_info set lastlogintime=#{time} ,lastloginip=#{ip} where id=#{id}")
int updateLoginInfo(@Param("time") String time,@Param("ip") String ip,@Param("id") String id);
}

View File

@ -0,0 +1,65 @@
package com.aiit.xiuos.model;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AvgDayData {
private Integer id;
private BigDecimal windspeed;
private BigDecimal noise;
private BigDecimal methanal;
private BigDecimal pm1d0;
private BigDecimal pm2d5;
private BigDecimal pm10;
private BigDecimal so2;
private BigDecimal temperature;
private BigDecimal humidness;
private BigDecimal co2;
private BigDecimal airpressure;
private BigDecimal tvoc;
private BigDecimal ethanol;
private BigDecimal methane;
private Date datatime;
public AvgDayData(Integer id, BigDecimal windspeed, BigDecimal noise, BigDecimal methanal, BigDecimal pm1d0, BigDecimal pm2d5, BigDecimal pm10, BigDecimal so2, BigDecimal temperature, BigDecimal humidness, BigDecimal co2, BigDecimal airpressure, BigDecimal tvoc, BigDecimal ethanol, BigDecimal methane, Date datatime) {
this.id = id;
this.windspeed = windspeed;
this.noise = noise;
this.methanal = methanal;
this.pm1d0 = pm1d0;
this.pm2d5 = pm2d5;
this.pm10 = pm10;
this.so2 = so2;
this.temperature = temperature;
this.humidness = humidness;
this.co2 = co2;
this.airpressure = airpressure;
this.tvoc = tvoc;
this.ethanol = ethanol;
this.methane = methane;
this.datatime = datatime;
}
public AvgDayData() {
super();
}
}

View File

@ -0,0 +1,88 @@
package com.aiit.xiuos.model;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class DeviceInfo {
private String id;
private String no;
private String productname;
private String type;
private Integer activestatus;
private String updatetime;
private String devicedesc;
private Integer runstatus;
private String statusdesc;
private String kernel;
private String webversion;
private String ipaddr;
private String netmask;
private String gateway;
private String dnsserver0;
private String dnsserver1;
private String topic;
private String serveraddr;
private String serverport;
private String username;
private String clientid;
private String privateserveraddr;
private String privateserverport;
private String privateserverusername;
public DeviceInfo(String id, String no, String productname, String type, Integer activestatus, String updatetime, String devicedesc, Integer runstatus, String statusdesc, String kernel, String webversion, String ipaddr, String netmask, String gateway, String dnsserver0, String dnsserver1, String topic, String serveraddr, String serverport, String username, String clientid, String privateserveraddr, String privateserverport, String privateserverusername) {
this.id = id;
this.no = no;
this.productname = productname;
this.type = type;
this.activestatus = activestatus;
this.updatetime = updatetime;
this.devicedesc = devicedesc;
this.runstatus = runstatus;
this.statusdesc = statusdesc;
this.kernel = kernel;
this.webversion = webversion;
this.ipaddr = ipaddr;
this.netmask = netmask;
this.gateway = gateway;
this.dnsserver0 = dnsserver0;
this.dnsserver1 = dnsserver1;
this.topic = topic;
this.serveraddr = serveraddr;
this.serverport = serverport;
this.username = username;
this.clientid = clientid;
this.privateserveraddr = privateserveraddr;
this.privateserverport = privateserverport;
this.privateserverusername = privateserverusername;
}
public DeviceInfo() {
super();
}
}

View File

@ -0,0 +1,42 @@
package com.aiit.xiuos.model;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class UserInfo {
private String id;
private String username;
private String password;
private String realname;
private Integer phonenum;
private String updatetime;
private String lastlogintime;
private String lastloginip;
private String org;
public UserInfo(String id, String username, String password, String realname, Integer phonenum, String updatetime, String lastlogintime, String lastloginip, String org) {
this.id = id;
this.username = username;
this.password = password;
this.realname = realname;
this.phonenum = phonenum;
this.updatetime = updatetime;
this.lastlogintime = lastlogintime;
this.lastloginip = lastloginip;
this.org = org;
}
public UserInfo() {
super();
}
}

View File

@ -0,0 +1,83 @@
package com.aiit.xiuos.scheduled;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.model.AvgDayData;
import com.aiit.xiuos.service.AvgDayDataService;
import com.aiit.xiuos.service.impl.AvgDayDataServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Component
public class TaskScheduled {
@Autowired
AvgDayDataService avgDayDataService;
@Scheduled(cron = "0 0 */1 * * ?")//every hour
public void insertAvgDayData() throws ParseException {
AvgDayData avgDayData =new AvgDayData();
Random rand = new Random();
DecimalFormat df = new DecimalFormat("#.00"); //保留两位数若数据库已截取java可不作保留
//生成在max与min之间的随机数
// int randNumber = rand.nextInt(MAX - MIN + 1) + MIN;
double winspeed =rand.nextInt(3)+Math.random(); //风速m/s
avgDayData.setWindspeed(new BigDecimal(df.format(winspeed)));
double noise =rand.nextInt(71)+30+Math.random(); //噪音 pd
avgDayData.setNoise(new BigDecimal(df.format(noise)));
double methanal =rand.nextInt(101)+Math.random(); //甲醛 ppb
avgDayData.setMethanal(new BigDecimal(df.format(methanal)));
double pm1_0=rand.nextInt(20)+Math.random(); //pm1.0 ug/m3
avgDayData.setPm1d0(new BigDecimal(df.format(pm1_0)));
double pm2_5=rand.nextInt(20)+Math.random(); //pm2.5 ug/m3
avgDayData.setPm2d5(new BigDecimal(df.format(pm2_5)));
double pm10=rand.nextInt(40)+Math.random(); //pm10 ug/m3
avgDayData.setPm10(new BigDecimal(df.format(pm10)));
double so2=rand.nextInt(30)+Math.random(); //so2
avgDayData.setSo2(new BigDecimal(df.format(so2)));
double temperature =rand.nextInt(10)+20+Math.random(); //温度
avgDayData.setTemperature(new BigDecimal(df.format(temperature)));
double humidness = rand.nextInt(40)+30+Math.random(); //湿度 百分比
avgDayData.setHumidness(new BigDecimal(df.format(humidness)));
double co2 =rand.nextInt(20)+80+Math.random(); //co2
avgDayData.setCo2(new BigDecimal(df.format(co2)));
double airpressure=rand.nextInt(41)+80+Math.random(); //气压
avgDayData.setAirpressure(new BigDecimal(df.format(airpressure)));
double tvoc =rand.nextInt(60)+20+Math.random(); //tvoc
avgDayData.setTvoc(new BigDecimal(df.format(tvoc)));
double ethanol =rand.nextInt(21)+Math.random(); //乙醇
avgDayData.setEthanol(new BigDecimal(df.format(ethanol)));
double methane =rand.nextInt(11)+Math.random(); //甲烷
avgDayData.setMethane(new BigDecimal(df.format(methane)));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(MyUtils.getTime());
avgDayData.setDatatime(date);
avgDayDataService.addAvgDayData(avgDayData);
}
}

View File

@ -0,0 +1,11 @@
package com.aiit.xiuos.service;
import com.aiit.xiuos.model.AvgDayData;
import java.util.List;
public interface AvgDayDataService {
List<AvgDayData> getAvgDayData();
int addAvgDayData(AvgDayData avgDayData);
AvgDayData getAvg();
}

View File

@ -0,0 +1,14 @@
package com.aiit.xiuos.service;
import com.aiit.xiuos.model.DeviceInfo;
import java.util.List;
public interface DeviceInfoService {
int addDevice(DeviceInfo deviceInfo);
int deleteDeviceByNo(String no);
int activeDeviceByNo(String no);
List<DeviceInfo> selectActiveDevice();
List<DeviceInfo> selectUnActiveDevice();
List<DeviceInfo> selectbyNo(String no);
}

View File

@ -0,0 +1,14 @@
package com.aiit.xiuos.service;
import com.aiit.xiuos.model.UserInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
public interface UserInfoService {
UserInfo login(UserInfo userInfo);
int updateLoginInfo(String date, String ip,String id);
int addUser(UserInfo userInfo);
}

View File

@ -0,0 +1,28 @@
package com.aiit.xiuos.service.impl;
import com.aiit.xiuos.dao.mappers.AvgDayDataMapper;
import com.aiit.xiuos.model.AvgDayData;
import com.aiit.xiuos.service.AvgDayDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AvgDayDataServiceImpl implements AvgDayDataService {
@Autowired
AvgDayDataMapper avgDayDataMapper;
@Override
public List<AvgDayData> getAvgDayData() {
return avgDayDataMapper.selectAvgDayData();
}
@Override
public int addAvgDayData(AvgDayData avgDayData) {
return avgDayDataMapper.insertSelective(avgDayData);
}
@Override
public AvgDayData getAvg() {
return avgDayDataMapper.selectAvg();
}
}

View File

@ -0,0 +1,46 @@
package com.aiit.xiuos.service.impl;
import com.aiit.xiuos.Utils.MyUtils;
import com.aiit.xiuos.dao.mappers.DeviceInfoMapper;
import com.aiit.xiuos.model.DeviceInfo;
import com.aiit.xiuos.service.DeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DeviceInfoServiceImpl implements DeviceInfoService {
@Autowired
private DeviceInfoMapper deviceInfoMapper;
@Override
public int addDevice(DeviceInfo deviceInfo) {
return deviceInfoMapper.insert(deviceInfo);
}
@Override
public int deleteDeviceByNo(String no) {
return deviceInfoMapper.deleteByNo(no);
}
@Override
public int activeDeviceByNo(String no) {
String updateTime = MyUtils.getTime();
return deviceInfoMapper.updateStatusByNo(updateTime,no);
}
@Override
public List<DeviceInfo> selectActiveDevice() {
return deviceInfoMapper.selectActiveDevices();
}
@Override
public List<DeviceInfo> selectUnActiveDevice() {
return deviceInfoMapper.selectUnActiveDevices();
}
@Override
public List<DeviceInfo> selectbyNo(String no) {
return deviceInfoMapper.selectByNo(no);
}
}

View File

@ -0,0 +1,30 @@
package com.aiit.xiuos.service.impl;
import com.aiit.xiuos.dao.mappers.UserInfoMapper;
import com.aiit.xiuos.model.UserInfo;
import com.aiit.xiuos.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserInfoServiceImpl implements UserInfoService {
@Autowired
private UserInfoMapper userInfoMapper;
@Override
public UserInfo login(UserInfo userInfo) {
UserInfo user = userInfoMapper.getUser(userInfo.getUsername(),userInfo.getPassword());
return user;
}
@Override
public int updateLoginInfo(String date, String ip,String id) {
return userInfoMapper.updateLoginInfo(date,ip,id);
}
@Override
public int addUser(UserInfo userInfo) {
return userInfoMapper.insertSelective(userInfo);
}
}

View File

@ -0,0 +1,19 @@
package com.aiit.xiuos.socket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* 开启WebSocket支持 启动
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,162 @@
package com.aiit.xiuos.socket;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint(value = "/{paramName}")
@Component
@Slf4j
public class WebSocketServer {
/**
* 静态变量用来记录当前在线连接数应该把它设计成线程安全的
*/
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set用来存放每个客户端对应的MyWebSocket对象
*/
public static ConcurrentHashMap<String, WebSocketServer> webSocketSet = new ConcurrentHashMap<String, WebSocketServer>();
public HashMap<String,Integer> cntofParam=new HashMap<String,Integer>();
public HashMap<String,Integer> numofAccount=new HashMap<String,Integer>();
/**
* 与某个客户端的连接会话需要通过它来给客户端发送数据
*/
private Session session;
/**
* 传过来的id
*/
private String name = "";
/**
* 连接建立成功调用的方法*/
@OnOpen
public void onOpen(@PathParam(value = "paramName") String param, Session session) {
if(numofAccount.containsKey(param)){
Integer num=numofAccount.get(param);
String paramtmp=param;
param=param+num;
System.out.println(param);
numofAccount.put(paramtmp,num+1);
}else{
numofAccount.put(param,1);
}
//接收到发送消息的人员编号
name = param;
this.session = session;
/**加入set中*/
webSocketSet.put(param,this);
/**在线数加1*/
addOnlineCount();
System.out.println("有新连接"+param+"加入!当前在线人数为" + getOnlineCount());
//try {
//sendMessage("-连接已建立-");
//} catch (IOException e) {
// System.out.println("IO异常");
// }
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
if (name != null && name != "") {
/** 从set中删除 */
webSocketSet.remove(name);
/** 在线数减1 */
subOnlineCount();
System.out.println("有一连接关闭!当前在线人数为" + getOnlineCount());
}
}
/**
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息*/
@OnMessage
public void onMessage(String message, Session session) {
System.out.println("来自客户端的消息:" + message);
try {
this.sendMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 发生错误时调用
* **/
@OnError
public void onError(Session session, Throwable error) {
System.out.println("发生错误");
error.printStackTrace();
}
public void sendMessage(String message) throws IOException {
synchronized (session) {
getSession().getBasicRemote().sendText(message);
}
}
/**
* 给指定的人发送消息
* @param message
*/
public void sendToMessageById(String id,String message) {
try {
if (webSocketSet.get(id) != null) {
webSocketSet.get(id).sendMessage(message);
} else {
System.out.println("webSocketSet中没有此key不推送消息");
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 群发自定义消息
* */
public static void sendInfo(String message) throws IOException {
try {
for (Map.Entry<String, WebSocketServer> entry : webSocketSet.entrySet()) {
String name = entry.getKey();
log.info(name);
WebSocketServer value = entry.getValue();
value.sendMessage(message);
}
}catch(IOException e){
e.printStackTrace();
}
}
public Session getSession() {
return session;
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
WebSocketServer.onlineCount++;
}
public static synchronized void subOnlineCount() {
WebSocketServer.onlineCount--;
}
}

View File

@ -0,0 +1,29 @@
server:
port: 8080
servlet:
session:
timeout: 43200s
spring:
datasource:
nama: xiuosiot
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/xiuosiot
username: xiuosiot
password: 123456
hikari:
minimum-idle: 5
maximum-pool-size: 10
idle-timeout: 30000
max-lifetime: 1800000
connection-timeout: 30000
connection-test-query: select 'x'
pool-name: xiuosiots
password: 123456
jdbc-url: jdbc:postgresql://localhost:5432/xiuosiot
mybatis:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
mapper-locations: classpath:mappers/*.xml

View File

@ -0,0 +1,17 @@
package com.aiit.xiuos.dao.mappers;
import com.aiit.xiuos.model.AvgDayData;
public interface AvgDayDataMapper {
int deleteByPrimaryKey(Integer id);
int insert(AvgDayData record);
int insertSelective(AvgDayData record);
AvgDayData selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AvgDayData record);
int updateByPrimaryKey(AvgDayData record);
}

View File

@ -0,0 +1,64 @@
package com.aiit.xiuos.model;
import java.util.Date;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AvgDayData {
private String id;
private String windspeed;
private String noise;
private String methanal;
private String pm1_0;
private String pm2_5;
private String pm10;
private String so2;
private String temperature;
private String humidness;
private String co2;
private String airpressure;
private String tvoc;
private String ethanol;
private String methane;
private Date datatime;
public AvgDayData(String id, String windspeed, String noise, String methanal, String pm1_0, String pm2_5, String pm10, String so2, String temperature, String humidness, String co2, String airpressure, String tvoc, String ethanol, String methane, Date datatime) {
this.id = id;
this.windspeed = windspeed;
this.noise = noise;
this.methanal = methanal;
this.pm1_0 = pm1_0;
this.pm2_5 = pm2_5;
this.pm10 = pm10;
this.so2 = so2;
this.temperature = temperature;
this.humidness = humidness;
this.co2 = co2;
this.airpressure = airpressure;
this.tvoc = tvoc;
this.ethanol = ethanol;
this.methane = methane;
this.datatime = datatime;
}
public AvgDayData() {
super();
}
}

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<!--id:必选上下文id用于在生成错误时提示-->
<context id="xiousiot" targetRuntime="MyBatis3" defaultModelType="flat">
<!-- 生成的Java文件的编码 -->
<property name="javaFileEncoding" value="UTF-8"/>
<plugin type="com.softwareloop.mybatis.generator.plugins.LombokPlugin">
<!-- enable annotations -->
<property name="builder" value="true"/>
<!-- annotation's option(boolean) -->
<property name="builder.fluent" value="true"/>
<!-- annotation's option(String) -->
<property name="builder.builderMethodName" value="myBuilder"/>
<property name="accessors" value="true"/>
<!-- annotation's option(array of String) -->
<property name="accessors.prefix" value="m_, _"/>
<!-- disable annotations -->
<property name="allArgsConstructor" value="false"/>
</plugin>
<!-- 对注释进行控制 -->
<commentGenerator>
<!-- suppressDate是去掉生成日期那行注释 -->
<property name="suppressDate" value="true"/>
<!-- suppressAllComments是去掉所有的注解 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass="org.postgresql.Driver"
connectionURL="jdbc:postgresql://localhost:5432/xiuosiot"
userId="xiuosiot"
password="123456">
</jdbcConnection>
<!-- java类型处理器
用于处理DB中的类型到Java中的类型默认使用JavaTypeResolverDefaultImpl
注意一点默认会先尝试使用IntegerLongShort等来对应DECIMAL和 NUMERIC数据类型
-->
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<javaModelGenerator targetPackage="com.aiit.xiuos.model" targetProject="src/main/java">
<!-- 是否允许子包即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="false"/>
<!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/>
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
<property name="trimStrings" value="true"/>
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法只有构造方法 -->
<property name="immutable" value="false"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="mybatisGenerate/generatorXML" targetProject="src/main/resources">
<!-- 在targetPackage的基础上根据数据库的schema再生成一层package最终生成的类放在这个package下默认为false -->
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="mybatisGenerate/generatormapper" type="XMLMAPPER"
targetProject="src/main/resources">
<!-- 在targetPackage的基础上根据数据库的schema再生成一层package最终生成的类放在这个package下默认为false -->
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- 选择一个table来生成相关文件可以有一个或多个table必须要有table元素
tableName必要要生成对象的表名
domainObjectName 给表对应的 model 起名字
注意:大小写敏感问题。
-->
<!-- <table tableName="user_info" domainObjectName="UserInfo"-->
<!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"-->
<!-- enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<table tableName="avg_day_data" domainObjectName="AvgDayData"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>

View File

@ -0,0 +1,225 @@
<?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.aiit.xiuos.dao.mappers.AvgDayDataMapper">
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.AvgDayData">
<constructor>
<idArg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="windspeed" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="noise" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="methanal" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="pm1d0" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="pm2d5" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="pm10" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="so2" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="temperature" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="humidness" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="co2" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="airpressure" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="tvoc" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="ethanol" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="methane" javaType="java.math.BigDecimal" jdbcType="NUMERIC" />
<arg column="datatime" javaType="java.util.Date" jdbcType="TIMESTAMP" />
</constructor>
</resultMap>
<sql id="Base_Column_List">
id, windspeed, noise, methanal, pm1d0, pm2d5, pm10, so2, temperature, humidness,
co2, airpressure, tvoc, ethanol, methane, datatime
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from avg_day_data
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from avg_day_data
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.aiit.xiuos.model.AvgDayData">
insert into avg_day_data (id, windspeed, noise,
methanal, pm1d0, pm2d5,
pm10, so2, temperature,
humidness, co2, airpressure,
tvoc, ethanol, methane,
datatime)
values (#{id,jdbcType=INTEGER}, #{windspeed,jdbcType=NUMERIC}, #{noise,jdbcType=NUMERIC},
#{methanal,jdbcType=NUMERIC}, #{pm1d0,jdbcType=NUMERIC}, #{pm2d5,jdbcType=NUMERIC},
#{pm10,jdbcType=NUMERIC}, #{so2,jdbcType=NUMERIC}, #{temperature,jdbcType=NUMERIC},
#{humidness,jdbcType=NUMERIC}, #{co2,jdbcType=NUMERIC}, #{airpressure,jdbcType=NUMERIC},
#{tvoc,jdbcType=NUMERIC}, #{ethanol,jdbcType=NUMERIC}, #{methane,jdbcType=NUMERIC},
#{datatime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.AvgDayData">
insert into avg_day_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="windspeed != null">
windspeed,
</if>
<if test="noise != null">
noise,
</if>
<if test="methanal != null">
methanal,
</if>
<if test="pm1d0 != null">
pm1d0,
</if>
<if test="pm2d5 != null">
pm2d5,
</if>
<if test="pm10 != null">
pm10,
</if>
<if test="so2 != null">
so2,
</if>
<if test="temperature != null">
temperature,
</if>
<if test="humidness != null">
humidness,
</if>
<if test="co2 != null">
co2,
</if>
<if test="airpressure != null">
airpressure,
</if>
<if test="tvoc != null">
tvoc,
</if>
<if test="ethanol != null">
ethanol,
</if>
<if test="methane != null">
methane,
</if>
<if test="datatime != null">
datatime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="windspeed != null">
#{windspeed,jdbcType=NUMERIC},
</if>
<if test="noise != null">
#{noise,jdbcType=NUMERIC},
</if>
<if test="methanal != null">
#{methanal,jdbcType=NUMERIC},
</if>
<if test="pm1d0 != null">
#{pm1d0,jdbcType=NUMERIC},
</if>
<if test="pm2d5 != null">
#{pm2d5,jdbcType=NUMERIC},
</if>
<if test="pm10 != null">
#{pm10,jdbcType=NUMERIC},
</if>
<if test="so2 != null">
#{so2,jdbcType=NUMERIC},
</if>
<if test="temperature != null">
#{temperature,jdbcType=NUMERIC},
</if>
<if test="humidness != null">
#{humidness,jdbcType=NUMERIC},
</if>
<if test="co2 != null">
#{co2,jdbcType=NUMERIC},
</if>
<if test="airpressure != null">
#{airpressure,jdbcType=NUMERIC},
</if>
<if test="tvoc != null">
#{tvoc,jdbcType=NUMERIC},
</if>
<if test="ethanol != null">
#{ethanol,jdbcType=NUMERIC},
</if>
<if test="methane != null">
#{methane,jdbcType=NUMERIC},
</if>
<if test="datatime != null">
#{datatime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.AvgDayData">
update avg_day_data
<set>
<if test="windspeed != null">
windspeed = #{windspeed,jdbcType=NUMERIC},
</if>
<if test="noise != null">
noise = #{noise,jdbcType=NUMERIC},
</if>
<if test="methanal != null">
methanal = #{methanal,jdbcType=NUMERIC},
</if>
<if test="pm1d0 != null">
pm1d0 = #{pm1d0,jdbcType=NUMERIC},
</if>
<if test="pm2d5 != null">
pm2d5 = #{pm2d5,jdbcType=NUMERIC},
</if>
<if test="pm10 != null">
pm10 = #{pm10,jdbcType=NUMERIC},
</if>
<if test="so2 != null">
so2 = #{so2,jdbcType=NUMERIC},
</if>
<if test="temperature != null">
temperature = #{temperature,jdbcType=NUMERIC},
</if>
<if test="humidness != null">
humidness = #{humidness,jdbcType=NUMERIC},
</if>
<if test="co2 != null">
co2 = #{co2,jdbcType=NUMERIC},
</if>
<if test="airpressure != null">
airpressure = #{airpressure,jdbcType=NUMERIC},
</if>
<if test="tvoc != null">
tvoc = #{tvoc,jdbcType=NUMERIC},
</if>
<if test="ethanol != null">
ethanol = #{ethanol,jdbcType=NUMERIC},
</if>
<if test="methane != null">
methane = #{methane,jdbcType=NUMERIC},
</if>
<if test="datatime != null">
datatime = #{datatime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.AvgDayData">
update avg_day_data
set windspeed = #{windspeed,jdbcType=NUMERIC},
noise = #{noise,jdbcType=NUMERIC},
methanal = #{methanal,jdbcType=NUMERIC},
pm1d0 = #{pm1d0,jdbcType=NUMERIC},
pm2d5 = #{pm2d5,jdbcType=NUMERIC},
pm10 = #{pm10,jdbcType=NUMERIC},
so2 = #{so2,jdbcType=NUMERIC},
temperature = #{temperature,jdbcType=NUMERIC},
humidness = #{humidness,jdbcType=NUMERIC},
co2 = #{co2,jdbcType=NUMERIC},
airpressure = #{airpressure,jdbcType=NUMERIC},
tvoc = #{tvoc,jdbcType=NUMERIC},
ethanol = #{ethanol,jdbcType=NUMERIC},
methane = #{methane,jdbcType=NUMERIC},
datatime = #{datatime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,320 @@
<?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.aiit.xiuos.dao.mappers.DeviceInfoMapper">
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.DeviceInfo">
<constructor>
<idArg column="id" javaType="java.lang.String" jdbcType="VARCHAR" />
<idArg column="no" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="productname" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="type" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="activestatus" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="updatetime" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="devicedesc" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="runstatus" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="statusdesc" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="kernel" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="webversion" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="ipaddr" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="netmask" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="gateway" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="dnsserver0" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="dnsserver1" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="topic" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="serveraddr" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="serverport" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="username" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="clientid" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="privateserveraddr" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="privateserverport" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="privateserverusername" javaType="java.lang.String" jdbcType="VARCHAR" />
</constructor>
</resultMap>
<sql id="Base_Column_List">
id, no, productname, type, activestatus, updatetime, devicedesc, runstatus, statusdesc,
kernel, webversion, ipaddr, netmask, gateway, dnsserver0, dnsserver1, topic, serveraddr,
serverport, username, clientid, privateserveraddr, privateserverport, privateserverusername
</sql>
<select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_info
where id = #{id,jdbcType=INTEGER}
and no = #{no,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="map">
delete from device_info
where id = #{id,jdbcType=INTEGER}
and no = #{no,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.aiit.xiuos.model.DeviceInfo">
insert into device_info (id, no, productname,
type, activestatus, updatetime,
devicedesc, runstatus, statusdesc,
kernel, webversion, ipaddr,
netmask, gateway, dnsserver0,
dnsserver1, topic, serveraddr,
serverport, username, clientid,
privateserveraddr, privateserverport, privateserverusername
)
values (#{id,jdbcType=INTEGER}, #{no,jdbcType=VARCHAR}, #{productname,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR}, #{activestatus,jdbcType=INTEGER}, #{updatetime,jdbcType=VARCHAR},
#{devicedesc,jdbcType=VARCHAR}, #{runstatus,jdbcType=INTEGER}, #{statusdesc,jdbcType=VARCHAR},
#{kernel,jdbcType=VARCHAR}, #{webversion,jdbcType=VARCHAR}, #{ipaddr,jdbcType=VARCHAR},
#{netmask,jdbcType=VARCHAR}, #{gateway,jdbcType=VARCHAR}, #{dnsserver0,jdbcType=VARCHAR},
#{dnsserver1,jdbcType=VARCHAR}, #{topic,jdbcType=VARCHAR}, #{serveraddr,jdbcType=VARCHAR},
#{serverport,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{clientid,jdbcType=INTEGER},
#{privateserveraddr,jdbcType=VARCHAR}, #{privateserverport,jdbcType=VARCHAR}, #{privateserverusername,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.DeviceInfo">
insert into device_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="no != null">
no,
</if>
<if test="productname != null">
productname,
</if>
<if test="type != null">
type,
</if>
<if test="activestatus != null">
activestatus,
</if>
<if test="updatetime != null">
updatetime,
</if>
<if test="devicedesc != null">
devicedesc,
</if>
<if test="runstatus != null">
runstatus,
</if>
<if test="statusdesc != null">
statusdesc,
</if>
<if test="kernel != null">
kernel,
</if>
<if test="webversion != null">
webversion,
</if>
<if test="ipaddr != null">
ipaddr,
</if>
<if test="netmask != null">
netmask,
</if>
<if test="gateway != null">
gateway,
</if>
<if test="dnsserver0 != null">
dnsserver0,
</if>
<if test="dnsserver1 != null">
dnsserver1,
</if>
<if test="topic != null">
topic,
</if>
<if test="serveraddr != null">
serveraddr,
</if>
<if test="serverport != null">
serverport,
</if>
<if test="username != null">
username,
</if>
<if test="clientid != null">
clientid,
</if>
<if test="privateserveraddr != null">
privateserveraddr,
</if>
<if test="privateserverport != null">
privateserverport,
</if>
<if test="privateserverusername != null">
privateserverusername,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="no != null">
#{no,jdbcType=VARCHAR},
</if>
<if test="productname != null">
#{productname,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="activestatus != null">
#{activestatus,jdbcType=INTEGER},
</if>
<if test="updatetime != null">
#{updatetime,jdbcType=VARCHAR},
</if>
<if test="devicedesc != null">
#{devicedesc,jdbcType=VARCHAR},
</if>
<if test="runstatus != null">
#{runstatus,jdbcType=INTEGER},
</if>
<if test="statusdesc != null">
#{statusdesc,jdbcType=VARCHAR},
</if>
<if test="kernel != null">
#{kernel,jdbcType=VARCHAR},
</if>
<if test="webversion != null">
#{webversion,jdbcType=VARCHAR},
</if>
<if test="ipaddr != null">
#{ipaddr,jdbcType=VARCHAR},
</if>
<if test="netmask != null">
#{netmask,jdbcType=VARCHAR},
</if>
<if test="gateway != null">
#{gateway,jdbcType=VARCHAR},
</if>
<if test="dnsserver0 != null">
#{dnsserver0,jdbcType=VARCHAR},
</if>
<if test="dnsserver1 != null">
#{dnsserver1,jdbcType=VARCHAR},
</if>
<if test="topic != null">
#{topic,jdbcType=VARCHAR},
</if>
<if test="serveraddr != null">
#{serveraddr,jdbcType=VARCHAR},
</if>
<if test="serverport != null">
#{serverport,jdbcType=VARCHAR},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="clientid != null">
#{clientid,jdbcType=INTEGER},
</if>
<if test="privateserveraddr != null">
#{privateserveraddr,jdbcType=VARCHAR},
</if>
<if test="privateserverport != null">
#{privateserverport,jdbcType=VARCHAR},
</if>
<if test="privateserverusername != null">
#{privateserverusername,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.DeviceInfo">
update device_info
<set>
<if test="productname != null">
productname = #{productname,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="activestatus != null">
activestatus = #{activestatus,jdbcType=INTEGER},
</if>
<if test="updatetime != null">
updatetime = #{updatetime,jdbcType=VARCHAR},
</if>
<if test="devicedesc != null">
devicedesc = #{devicedesc,jdbcType=VARCHAR},
</if>
<if test="runstatus != null">
runstatus = #{runstatus,jdbcType=INTEGER},
</if>
<if test="statusdesc != null">
statusdesc = #{statusdesc,jdbcType=VARCHAR},
</if>
<if test="kernel != null">
kernel = #{kernel,jdbcType=VARCHAR},
</if>
<if test="webversion != null">
webversion = #{webversion,jdbcType=VARCHAR},
</if>
<if test="ipaddr != null">
ipaddr = #{ipaddr,jdbcType=VARCHAR},
</if>
<if test="netmask != null">
netmask = #{netmask,jdbcType=VARCHAR},
</if>
<if test="gateway != null">
gateway = #{gateway,jdbcType=VARCHAR},
</if>
<if test="dnsserver0 != null">
dnsserver0 = #{dnsserver0,jdbcType=VARCHAR},
</if>
<if test="dnsserver1 != null">
dnsserver1 = #{dnsserver1,jdbcType=VARCHAR},
</if>
<if test="topic != null">
topic = #{topic,jdbcType=VARCHAR},
</if>
<if test="serveraddr != null">
serveraddr = #{serveraddr,jdbcType=VARCHAR},
</if>
<if test="serverport != null">
serverport = #{serverport,jdbcType=VARCHAR},
</if>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="clientid != null">
clientid = #{clientid,jdbcType=INTEGER},
</if>
<if test="privateserveraddr != null">
privateserveraddr = #{privateserveraddr,jdbcType=VARCHAR},
</if>
<if test="privateserverport != null">
privateserverport = #{privateserverport,jdbcType=VARCHAR},
</if>
<if test="privateserverusername != null">
privateserverusername = #{privateserverusername,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
and no = #{no,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.DeviceInfo">
update device_info
set productname = #{productname,jdbcType=VARCHAR},
type = #{type,jdbcType=VARCHAR},
activestatus = #{activestatus,jdbcType=INTEGER},
updatetime = #{updatetime,jdbcType=VARCHAR},
devicedesc = #{devicedesc,jdbcType=VARCHAR},
runstatus = #{runstatus,jdbcType=INTEGER},
statusdesc = #{statusdesc,jdbcType=VARCHAR},
kernel = #{kernel,jdbcType=VARCHAR},
webversion = #{webversion,jdbcType=VARCHAR},
ipaddr = #{ipaddr,jdbcType=VARCHAR},
netmask = #{netmask,jdbcType=VARCHAR},
gateway = #{gateway,jdbcType=VARCHAR},
dnsserver0 = #{dnsserver0,jdbcType=VARCHAR},
dnsserver1 = #{dnsserver1,jdbcType=VARCHAR},
topic = #{topic,jdbcType=VARCHAR},
serveraddr = #{serveraddr,jdbcType=VARCHAR},
serverport = #{serverport,jdbcType=VARCHAR},
username = #{username,jdbcType=VARCHAR},
clientid = #{clientid,jdbcType=INTEGER},
privateserveraddr = #{privateserveraddr,jdbcType=VARCHAR},
privateserverport = #{privateserverport,jdbcType=VARCHAR},
privateserverusername = #{privateserverusername,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
and no = #{no,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,144 @@
<?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.aiit.xiuos.dao.mappers.UserInfoMapper">
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.UserInfo">
<constructor>
<idArg column="id" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="username" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="password" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="realname" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="phonenum" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="updatetime" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="lastlogintime" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="lastloginip" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="org" javaType="java.lang.String" jdbcType="VARCHAR" />
</constructor>
</resultMap>
<sql id="Base_Column_List">
id, username, password, realname, phonenum, updatetime, lastlogintime, lastloginip,
org
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_info
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from user_info
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.aiit.xiuos.model.UserInfo">
insert into user_info (id, username, password,
realname, phonenum, updatetime,
lastlogintime, lastloginip, org
)
values (#{id,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{realname,jdbcType=VARCHAR}, #{phonenum,jdbcType=INTEGER}, #{updatetime,jdbcType=VARCHAR},
#{lastlogintime,jdbcType=VARCHAR}, #{lastloginip,jdbcType=VARCHAR}, #{org,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.UserInfo">
insert into user_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="username != null">
username,
</if>
<if test="password != null">
password,
</if>
<if test="realname != null">
realname,
</if>
<if test="phonenum != null">
phonenum,
</if>
<if test="updatetime != null">
updatetime,
</if>
<if test="lastlogintime != null">
lastlogintime,
</if>
<if test="lastloginip != null">
lastloginip,
</if>
<if test="org != null">
org,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="realname != null">
#{realname,jdbcType=VARCHAR},
</if>
<if test="phonenum != null">
#{phonenum,jdbcType=INTEGER},
</if>
<if test="updatetime != null">
#{updatetime,jdbcType=VARCHAR},
</if>
<if test="lastlogintime != null">
#{lastlogintime,jdbcType=VARCHAR},
</if>
<if test="lastloginip != null">
#{lastloginip,jdbcType=VARCHAR},
</if>
<if test="org != null">
#{org,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.UserInfo">
update user_info
<set>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="realname != null">
realname = #{realname,jdbcType=VARCHAR},
</if>
<if test="phonenum != null">
phonenum = #{phonenum,jdbcType=INTEGER},
</if>
<if test="updatetime != null">
updatetime = #{updatetime,jdbcType=VARCHAR},
</if>
<if test="lastlogintime != null">
lastlogintime = #{lastlogintime,jdbcType=VARCHAR},
</if>
<if test="lastloginip != null">
lastloginip = #{lastloginip,jdbcType=VARCHAR},
</if>
<if test="org != null">
org = #{org,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.UserInfo">
update user_info
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
realname = #{realname,jdbcType=VARCHAR},
phonenum = #{phonenum,jdbcType=INTEGER},
updatetime = #{updatetime,jdbcType=VARCHAR},
lastlogintime = #{lastlogintime,jdbcType=VARCHAR},
lastloginip = #{lastloginip,jdbcType=VARCHAR},
org = #{org,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -0,0 +1,17 @@
package mybatisGenerate/generatormapper;
import com.aiit.xiuos.model.AvgDayData;
public interface AvgDayDataMapper {
int deleteByPrimaryKey(Integer id);
int insert(AvgDayData record);
int insertSelective(AvgDayData record);
AvgDayData selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AvgDayData record);
int updateByPrimaryKey(AvgDayData record);
}

View File

@ -0,0 +1,13 @@
package com.aiit.xiuos;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class XiuosApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.7.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.7.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.13.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.13.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.13.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.13.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.65" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.65" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.65" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.7.3" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.postgresql:postgresql:42.3.6" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.checkerframework:checker-qual:3.5.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.24" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.7.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.7.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.7.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.4.8" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:2.4.8" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:9.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.22.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:4.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.12.13" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.12.13" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:3.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:4.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.22" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.3.22" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.9.0" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.1" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.generator:mybatis-generator-core:1.4.0" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.15" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.32" level="project" />
</component>
</module>