diff --git a/.gitignore b/.gitignore index a1c2a23..8a16dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,70 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..a9959d6 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +decode-web-service \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fbc0c62 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..c5e48f7 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,19 @@ + + + + + mysql + true + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/sb_demo + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e79da7e --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..3b1c5e8 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a99e9b7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..42cb2c1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..fdf1fc8 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c315043 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/db_init.sql b/db_init.sql new file mode 100644 index 0000000..5332117 --- /dev/null +++ b/db_init.sql @@ -0,0 +1,28 @@ +create table irext_collect.collect_remote +( + id int auto_increment, + category_id int null, + category_name varchar(20) null, + brand_id int null, + brand_name varchar(20) null, + city_code varchar(6) null, + city_name varchar(20) null, + operator_id int null, + operator_name varchar(32) null, + remote_map varchar(128) null, + protocol varchar(64) null, + remote varchar(64) null, + constraint collect_remote_pk + primary key (id) +) +comment 'Collected Remote Info'; + +create table irext_collect.collect_key +( + id int auto_increment + primary key, + collect_remote_id int not null, + key_id int not null, + key_name varchar(20) not null, + key_value text not null +); diff --git a/decode-web-service.iml b/decode-web-service.iml new file mode 100644 index 0000000..76dc58e --- /dev/null +++ b/decode-web-service.iml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..5bf251c --- /dev/null +++ b/mvnw @@ -0,0 +1,225 @@ +#!/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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..019bd74 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,143 @@ +@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 http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..902aa70 --- /dev/null +++ b/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + net.irext.collector + spring-boot-mybatis + 0.0.1-SNAPSHOT + jar + + spring-boot-mybatis + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.5.4.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.0 + + + org.springframework.boot + spring-boot-starter-web + + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/src/main/java/net/irext/collector/Constants.java b/src/main/java/net/irext/collector/Constants.java new file mode 100644 index 0000000..bb4184f --- /dev/null +++ b/src/main/java/net/irext/collector/Constants.java @@ -0,0 +1,180 @@ +package net.irext.collector; + +/** + * Filename: Constants.java + * Revised: Date: 2017-12-08 + * Revision: Revision: 1.0 + *

+ * Description: SDK Constants + *

+ * Revision log: + * 2017-12-08: created by strawmanbobi + */ +public class Constants { + + public static final int ERROR_CODE_SUCCESS = 0; + public static final int ERROR_CODE_NETWORK_ERROR = -1; + public static final int ERROR_CODE_AUTH_FAILURE = 1; + public static final int ERROR_CODE_INVALID_CATEGORY = 2; + public static final int ERROR_CODE_INVALID_BRAND = 3; + public static final int ERROR_CODE_INVALID_PARAMETER = 4; + + public static final int LANG_ZH_CN = 0; + public static final int LANG_EN = 1; + public static final int LANG_TW_CN = 2; + + public enum CategoryID { + AIR_CONDITIONER(1), + TV(2), + STB(3), + NET_BOX(4), + IPTV(5), + DVD(6), + FAN(7), + PROJECTOR(8), + STEREO(9), + LIGHT(10), + BSTB(11), + CLEANING_ROBOT(12), + AIR_CLEANER(13), + DYSON_SERIES(14); + + private final int id; + + CategoryID(int id) { + this.id = id; + } + + public int getValue() { + return id; + } + } + + public enum BinaryType { + TYPE_BINARY(0), + TYPE_HEXDECIMAL(1); + + private final int type; + + BinaryType(int type) { + this.type = type; + } + + public int getValue() { + return type; + } + } + + public enum ACPower { + POWER_ON(0), + POWER_OFF(1); + + private final int power; + + ACPower(int power) { + this.power = power; + } + + public int getValue() { + return power; + } + } + + public enum ACMode { + MODE_COOL(0), + MODE_HEAT(1), + MODE_AUTO(2), + MODE_FAN(3), + MODE_DEHUMIDITY(4); + + private final int mode; + + ACMode(int mode) { + this.mode = mode; + } + + public int getValue() { + return mode; + } + } + + public enum ACTemperature { + TEMP_16(0), + TEMP_17(1), + TEMP_18(2), + TEMP_19(3), + TEMP_20(4), + TEMP_21(5), + TEMP_22(6), + TEMP_23(7), + TEMP_24(8), + TEMP_25(9), + TEMP_26(10), + TEMP_27(11), + TEMP_28(12), + TEMP_29(13), + TEMP_30(14); + + private final int temp; + + ACTemperature(int temp) { + this.temp = temp; + } + + public int getValue() { + return temp; + } + } + + public enum ACWindSpeed { + SPEED_AUTO(0), + SPEED_LOW(1), + SPEED_MEDIUM(2), + SPEED_HIGH(3); + + private final int speed; + + ACWindSpeed(int speed) { + this.speed = speed; + } + + public int getValue() { + return speed; + } + } + + public enum ACSwing { + SWING_ON(0), + SWING_OFF(1); + + private final int swing; + + ACSwing(int swing) { + this.swing = swing; + } + + public int getValue() { + return swing; + } + } + + public enum ACFunction { + FUNCTION_SWITCH_POWER(1), + FUNCTION_CHANGE_MODE(2), + FUNCTION_TEMPERATURE_UP(3), + FUNCTION_TEMPERATURE_DOWN(4), + FUNCTION_SWITCH_WIND_SPEED(5), + FUNCTION_SWITCH_WIND_DIR(6), + FUNCTION_SWITCH_SWING(7); + + private final int function; + + ACFunction(int function) { + this.function = function; + } + + public int getValue() { + return function; + } + } +} diff --git a/src/main/java/net/irext/collector/SpringBootMybatisApplication.java b/src/main/java/net/irext/collector/SpringBootMybatisApplication.java new file mode 100644 index 0000000..fd2bf8f --- /dev/null +++ b/src/main/java/net/irext/collector/SpringBootMybatisApplication.java @@ -0,0 +1,27 @@ +package net.irext.collector; + +import net.irext.collector.model.CollectRemote; +import org.apache.ibatis.type.MappedTypes; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Filename: SpringBootMybatisApplication + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: IRext Code Collector Application + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +@MappedTypes(CollectRemote.class) +@MapperScan("net.irext.collector.mybatis.springbootmybatis.mapper") +@SpringBootApplication +public class SpringBootMybatisApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootMybatisApplication.class, args); + } +} diff --git a/src/main/java/net/irext/collector/businesslogic/CollectCodeLogic.java b/src/main/java/net/irext/collector/businesslogic/CollectCodeLogic.java new file mode 100644 index 0000000..37ffd8d --- /dev/null +++ b/src/main/java/net/irext/collector/businesslogic/CollectCodeLogic.java @@ -0,0 +1,52 @@ +package net.irext.collector.businesslogic; + +import net.irext.collector.model.IRCode; +import org.springframework.stereotype.Controller; + +/** + * Filename: CollectCodeLogic + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: IRext Code Collector Collect Code Logic + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +@Controller +public class CollectCodeLogic { + + private Integer codeCollectState = 0; + private IRCode irCode; + + private static CollectCodeLogic collectCodeLogic; + + public static CollectCodeLogic getInstance(IRCode irCode) { + if (null == collectCodeLogic) { + collectCodeLogic = new CollectCodeLogic(irCode); + } + return collectCodeLogic; + } + + public CollectCodeLogic(IRCode irCode) { + this.irCode = irCode; + } + + public CollectCodeLogic() { + + } + + public boolean collectCodeWorkUnit() { + // step 1. figure out the category and brand for this code + + // step 2. go through the FSM for remote in each category + codeCollectState++; + System.out.println("state = " + codeCollectState + " : " + irCode.getKey()); + + // step 3. record key code + + // step 4. temporarily save to file + + return true; + } +} diff --git a/src/main/java/net/irext/collector/mapper/CollectRemoteMapper.java b/src/main/java/net/irext/collector/mapper/CollectRemoteMapper.java new file mode 100644 index 0000000..6208c21 --- /dev/null +++ b/src/main/java/net/irext/collector/mapper/CollectRemoteMapper.java @@ -0,0 +1,34 @@ +package net.irext.collector.mapper; + +import net.irext.collector.model.CollectRemote; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectKey; + +import java.util.List; + +/** + * Filename: CollectRemoteMapper.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: CollectRemote Mybatis Mapper + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +@Mapper +public interface CollectRemoteMapper { + + @Select("select * from collect_remote") + List listCollectRemotes(); + + @Insert("INSERT INTO collect_remote(category_id, category_name, brand_id, brand_name, city_code, city_name, " + + "operator_id, operator_name, remote_map, protocol, remote) " + + "values(#{categoryId}, #{categoryName}, #{brandId}, #{brandName}, #{cityCode}, #{cityName}, " + + "#{operatorId}, #{operatorName}, #{remoteMap}, #{protocol}, #{remote})") + @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", + before = false, resultType = Integer.class) + void createCollectRemote(CollectRemote collectRemote); +} diff --git a/src/main/java/net/irext/collector/model/CollectKey.java b/src/main/java/net/irext/collector/model/CollectKey.java new file mode 100644 index 0000000..dc92b38 --- /dev/null +++ b/src/main/java/net/irext/collector/model/CollectKey.java @@ -0,0 +1,72 @@ +package net.irext.collector.model; + +/** + * Filename: CollectKey.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: CollectKey Model + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class CollectKey { + + private Integer id; + private Integer collectRemoteId; + private Integer keyId; + private String keyName; + private String keyValue; + + public CollectKey(Integer id, Integer collectRemoteId, Integer keyId, String keyName, String keyValue) { + this.id = id; + this.collectRemoteId = collectRemoteId; + this.keyId = keyId; + this.keyName = keyName; + this.keyValue = keyValue; + } + + public CollectKey() { + + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCollectRemoteId() { + return collectRemoteId; + } + + public void setCollectRemoteId(Integer collectRemoteId) { + this.collectRemoteId = collectRemoteId; + } + + public Integer getKeyId() { + return keyId; + } + + public void setKeyId(Integer keyId) { + this.keyId = keyId; + } + + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + public String getKeyValue() { + return keyValue; + } + + public void setKeyValue(String keyValue) { + this.keyValue = keyValue; + } +} diff --git a/src/main/java/net/irext/collector/model/CollectRemote.java b/src/main/java/net/irext/collector/model/CollectRemote.java new file mode 100644 index 0000000..36dd483 --- /dev/null +++ b/src/main/java/net/irext/collector/model/CollectRemote.java @@ -0,0 +1,144 @@ +package net.irext.collector.model; + +/** + * Filename: CollectRemote.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: CollectRemote Model + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class CollectRemote { + + private Integer id; + private Integer categoryId; + private String categoryName; + private Integer brandId; + private String brandName; + private String cityCode; + private String cityName; + private Integer operatorId; + private String operatorName; + private String remoteMap; + private String protocol; + private String remote; + + public CollectRemote(Integer id, Integer categoryId, String categoryName, Integer brandId, String brandName, + String cityCode, String cityName, Integer operatorId, String operatorName, + String remoteMap, String protocol, String remote) { + this.id = id; + this.categoryId = categoryId; + this.categoryName = categoryName; + this.brandId = brandId; + this.brandName = brandName; + this.cityCode = cityCode; + this.cityName = cityName; + this.operatorId = operatorId; + this.operatorName = operatorName; + this.remoteMap = remoteMap; + this.protocol = protocol; + this.remote = remote; + } + + public CollectRemote() { + + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getCategoryId() { + return categoryId; + } + + public void setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public Integer getBrandId() { + return brandId; + } + + public void setBrandId(Integer brandId) { + this.brandId = brandId; + } + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public Integer getOperatorId() { + return operatorId; + } + + public void setOperatorId(Integer operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public String getRemoteMap() { + return remoteMap; + } + + public void setRemoteMap(String remoteMap) { + this.remoteMap = remoteMap; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getRemote() { + return remote; + } + + public void setRemote(String remote) { + this.remote = remote; + } +} diff --git a/src/main/java/net/irext/collector/model/IRCode.java b/src/main/java/net/irext/collector/model/IRCode.java new file mode 100644 index 0000000..7e8b905 --- /dev/null +++ b/src/main/java/net/irext/collector/model/IRCode.java @@ -0,0 +1,54 @@ +package net.irext.collector.model; + +/** + * Filename: IRCode.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: IR Code + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class IRCode { + + private int id; + private String text; + private String key; + private String code; + + public IRCode(int id, String text, String key, String code) { + this.id = id; + this.text = text; + this.key = key; + this.code = code; + } + + public IRCode() { + + } + + public void setText(String text) { + this.text = text; + } + + public void setKey(String key) { + this.key = key; + } + + public void setCode(String code) { + this.code = code; + } + + public String getText() { + return this.text; + } + + public String getKey() { + return this.key; + } + + public String getCode() { + return this.code; + } +} diff --git a/src/main/java/net/irext/collector/response/CollectKeysResponse.java b/src/main/java/net/irext/collector/response/CollectKeysResponse.java new file mode 100644 index 0000000..1294e2e --- /dev/null +++ b/src/main/java/net/irext/collector/response/CollectKeysResponse.java @@ -0,0 +1,36 @@ +package net.irext.collector.response; + +import net.irext.collector.model.CollectKey; + +import java.util.List; + +/** + * Filename: CollectKeysResponse.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response class + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class CollectKeysResponse extends ServiceResponse { + List entity; + + public CollectKeysResponse(Status status, List entity) { + super(status); + this.entity = entity; + } + + public CollectKeysResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} \ No newline at end of file diff --git a/src/main/java/net/irext/collector/response/CollectRemotesResponse.java b/src/main/java/net/irext/collector/response/CollectRemotesResponse.java new file mode 100644 index 0000000..6c0f584 --- /dev/null +++ b/src/main/java/net/irext/collector/response/CollectRemotesResponse.java @@ -0,0 +1,36 @@ +package net.irext.collector.response; + +import net.irext.collector.model.CollectRemote; + +import java.util.List; + +/** + * Filename: CollectRemotesResponse.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response class + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class CollectRemotesResponse extends ServiceResponse { + List entity; + + public CollectRemotesResponse(Status status, List entity) { + super(status); + this.entity = entity; + } + + public CollectRemotesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/src/main/java/net/irext/collector/response/ServiceResponse.java b/src/main/java/net/irext/collector/response/ServiceResponse.java new file mode 100644 index 0000000..5d27503 --- /dev/null +++ b/src/main/java/net/irext/collector/response/ServiceResponse.java @@ -0,0 +1,32 @@ +package net.irext.collector.response; + +/** + * Filename: ServiceResponse.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response class + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class ServiceResponse { + + private Status status; + + public ServiceResponse(Status status) { + this.status = status; + } + + public ServiceResponse() { + + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/src/main/java/net/irext/collector/response/Status.java b/src/main/java/net/irext/collector/response/Status.java new file mode 100644 index 0000000..e936ac1 --- /dev/null +++ b/src/main/java/net/irext/collector/response/Status.java @@ -0,0 +1,44 @@ +package net.irext.collector.response; + +import net.irext.collector.Constants; + +/** + * Filename: Status.java + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: HTTP response status + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +public class Status { + + private int code; + private String cause; + + public Status(int code, String cause) { + this.code = code; + this.cause = cause; + } + + public Status() { + this.code = Constants.ERROR_CODE_SUCCESS; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getCause() { + return cause; + } + + public void setCause(String cause) { + this.cause = cause; + } +} diff --git a/src/main/java/net/irext/collector/service/CollectRemoteService.java b/src/main/java/net/irext/collector/service/CollectRemoteService.java new file mode 100644 index 0000000..630db59 --- /dev/null +++ b/src/main/java/net/irext/collector/service/CollectRemoteService.java @@ -0,0 +1,46 @@ +package net.irext.collector.service; + +import net.irext.collector.mapper.CollectRemoteMapper; +import net.irext.collector.model.CollectRemote; +import net.irext.collector.response.CollectRemotesResponse; +import net.irext.collector.response.ServiceResponse; +import net.irext.collector.response.Status; +import org.springframework.web.bind.annotation.*; + +/** + * Filename: CollectRemoteService + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: IRext Remote Management Service + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +@RestController +@RequestMapping("/irext/collect") +public class CollectRemoteService { + + private CollectRemoteMapper collectRemoteMapper; + + public CollectRemoteService(CollectRemoteMapper collectRemoteMapper) { + this.collectRemoteMapper = collectRemoteMapper; + } + + @GetMapping("/list_collect_remotes") + public CollectRemotesResponse listCollectRemotes() { + CollectRemotesResponse collectRemotesResponse = new CollectRemotesResponse(); + collectRemotesResponse.setEntity(collectRemoteMapper.listCollectRemotes()); + collectRemotesResponse.setStatus(new Status()); + return collectRemotesResponse; + } + + @PostMapping("/create_collect_remote") + private ServiceResponse createCollectRemote(@RequestBody CollectRemote collectRemote) { + + ServiceResponse serviceResponse = new ServiceResponse(); + collectRemoteMapper.createCollectRemote(collectRemote); + serviceResponse.setStatus(new Status()); + return serviceResponse; + } +} diff --git a/src/main/java/net/irext/collector/service/IRCodeService.java b/src/main/java/net/irext/collector/service/IRCodeService.java new file mode 100644 index 0000000..104736c --- /dev/null +++ b/src/main/java/net/irext/collector/service/IRCodeService.java @@ -0,0 +1,33 @@ +package net.irext.collector.service; + +import net.irext.collector.businesslogic.CollectCodeLogic; +import net.irext.collector.model.IRCode; +import net.irext.collector.response.ServiceResponse; +import net.irext.collector.response.Status; +import org.springframework.web.bind.annotation.*; + +/** + * Filename: IRCodeService + * Revised: Date: 2018-12-08 + * Revision: Revision: 1.0 + *

+ * Description: IRext Code Collector Service + *

+ * Revision log: + * 2018-12-08: created by strawmanbobi + */ +@RestController +@RequestMapping("/irext/collect") +public class IRCodeService { + + public IRCodeService() { + } + + @PostMapping("/collect_code") + public ServiceResponse collectCode(@RequestBody IRCode irCode) { + CollectCodeLogic.getInstance(irCode).collectCodeWorkUnit(); + ServiceResponse serviceResponse = new ServiceResponse(); + serviceResponse.setStatus(new Status()); + return serviceResponse; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..66ca309 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,5 @@ +server.port=8081 + +spring.datasource.url=jdbc:mysql://localhost:3306/irext_collect +spring.datasource.username=root +spring.datasource.password=root