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 @@
+
+
+ * 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
+ * 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
+ * Description: HTTP Response class
+ *
+ * Revision log:
+ * 2018-12-08: created by strawmanbobi
+ */
+public class CollectRemotesResponse extends ServiceResponse {
+ List
+ * 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