diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 42d5c9e..7b69941 100644 --- a/pom.xml +++ b/pom.xml @@ -1,56 +1,56 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - net.irext.decoder - irext-decode-service - 0.0.1-SNAPSHOT - jar + net.irext.decoder + irext-decode-service + 0.0.1-SNAPSHOT + jar - IRext Decode Service - Decoding IR binaries online + IRext Decode Service + Decoding IR binaries online - + org.springframework.boot spring-boot-starter-parent 2.1.1.RELEASE - - + + - - UTF-8 - UTF-8 - 1.8 - + + UTF-8 + UTF-8 + 1.8 + - + org.mybatis.spring.boot mybatis-spring-boot-starter 1.3.2 - - org.springframework.boot - spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-web 2.1.1.RELEASE - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-data-redis 2.1.1.RELEASE - - - mysql - mysql-connector-java + + + mysql + mysql-connector-java 8.0.13 - + commons-io commons-io @@ -61,30 +61,30 @@ aliyun-sdk-oss 3.4.0 - - org.springframework.boot - spring-boot-autoconfigure - 2.1.1.RELEASE - - - redis.clients - jedis - - - org.springframework.boot - spring-boot-starter-log4j2 - 2.1.1.RELEASE - - + + org.springframework.boot + spring-boot-autoconfigure + 2.1.1.RELEASE + + + redis.clients + jedis + + + org.springframework.boot + spring-boot-starter-log4j2 + 2.1.1.RELEASE + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/src/main/java/net/irext/decoder/IRDecoderApplication.java b/src/main/java/net/irext/decoder/IRDecoderApplication.java index 8967ec3..bd9ec28 100644 --- a/src/main/java/net/irext/decoder/IRDecoderApplication.java +++ b/src/main/java/net/irext/decoder/IRDecoderApplication.java @@ -22,8 +22,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class IRDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(IRDecoderApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(IRDecoderApplication.class, args); + } } diff --git a/src/main/java/net/irext/decoder/businesslogic/DecodeLogic.java b/src/main/java/net/irext/decoder/businesslogic/DecodeLogic.java index 5e3f2de..a3436e7 100644 --- a/src/main/java/net/irext/decoder/businesslogic/DecodeLogic.java +++ b/src/main/java/net/irext/decoder/businesslogic/DecodeLogic.java @@ -2,9 +2,8 @@ package net.irext.decoder.businesslogic; import net.irext.decoder.alioss.OSSHelper; import net.irext.decoder.cache.IDecodeSessionRepository; -import net.irext.decoder.model.IRBinary; -import net.irext.decoder.model.RemoteIndex; import net.irext.decoder.cache.IIRBinaryRepository; +import net.irext.decoder.model.RemoteIndex; import net.irext.decoder.utils.FileUtil; import net.irext.decoder.utils.LoggerUtil; import net.irext.decoder.utils.MD5Util; @@ -44,7 +43,7 @@ public class DecodeLogic { return decodeLogic; } - public byte[] openIRBinary(ServletContext context, IIRBinaryRepository irBinaryRepository, + public RemoteIndex openIRBinary(ServletContext context, IIRBinaryRepository irBinaryRepository, RemoteIndex remoteIndex) { if (null == remoteIndex) { return null; @@ -56,15 +55,16 @@ public class DecodeLogic { LoggerUtil.getInstance().trace(TAG, "checksum for remoteIndex " + remoteIndex.getId() + " = " + checksum); - byte[] binaries = irBinaryRepository.find(remoteIndex.getId()); - if (null != binaries) { - LoggerUtil.getInstance().trace(TAG, "binary content fetched from redis : " + binaries.length); + RemoteIndex cachedRemoteIndex = irBinaryRepository.find(remoteIndex.getId()); + if (null != cachedRemoteIndex) { + LoggerUtil.getInstance().trace(TAG, "binary content fetched from redis : " + + cachedRemoteIndex.getRemoteMap()); // validate binary content String cachedChecksum = MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5") - .digest(binaries)).toUpperCase(); + .digest(cachedRemoteIndex.getBinaries())).toUpperCase(); if (cachedChecksum.equals(checksum)) { - return binaries; + return cachedRemoteIndex; } } @@ -79,9 +79,9 @@ public class DecodeLogic { if (null != fin) { byte[] newBinaries = IOUtils.toByteArray(fin); LoggerUtil.getInstance().trace(TAG, "binary content get, save it to redis"); - - irBinaryRepository.add(remoteIndex.getId(), newBinaries); - return binaries; + remoteIndex.setBinaries(newBinaries); + irBinaryRepository.add(remoteIndex.getId(), remoteIndex); + return remoteIndex; } } else { LoggerUtil.getInstance().trace(TAG, "servlet context is null"); @@ -94,20 +94,24 @@ public class DecodeLogic { } public int[] decode(IIRBinaryRepository irBinaryRepository, IDecodeSessionRepository decodeSessionRepository, - String sessionId, int remoteIndexId, ACStatus acStatus, int keyCode, int changeWindDirection) { + String sessionId, int remoteIndexId, ACStatus acStatus, int keyCode, int changeWindDirection) { // since the binary is already opened and probably cached to redis, we just need to load it Integer cachedRemoteIndexId = decodeSessionRepository.find(sessionId); - int []decoded = null; + int[] decoded = null; if (null != cachedRemoteIndexId) { - byte[] remoteBinary = irBinaryRepository.find(cachedRemoteIndexId); - IRDecode irDecode = IRDecode.getInstance(); - int ret = 0; - // int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length); - if (0 == ret) { - decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection); + RemoteIndex cachedRemoteIndex = irBinaryRepository.find(cachedRemoteIndexId); + if (null != cachedRemoteIndex) { + int categoryId = cachedRemoteIndex.getCategoryId(); + int subCate = cachedRemoteIndex.getSubCate(); + byte[] binaryContent = cachedRemoteIndex.getBinaries(); + IRDecode irDecode = IRDecode.getInstance(); + int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length); + if (0 == ret) { + decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection); + } + irDecode.closeBinary(); + return decoded; } - irDecode.closeBinary(); - return decoded; } else { LoggerUtil.getInstance().trace(TAG, "session cache missed, need to re-open binary"); } @@ -124,7 +128,7 @@ public class DecodeLogic { if (binFile.exists()) { FileInputStream fileInputStream = new FileInputStream(binFile); // validate binary content - byte []binaries = IOUtils.toByteArray(fileInputStream); + byte[] binaries = IOUtils.toByteArray(fileInputStream); String fileChecksum = MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5").digest(binaries)).toUpperCase(); @@ -135,7 +139,7 @@ public class DecodeLogic { OSSHelper ossHelper = new OSSHelper(); InputStream inputStream = ossHelper.getOSS2InputStream(OSSHelper.BUCKET_NAME, "", fileName); // validate binary content - byte []binaries = IOUtils.toByteArray(inputStream); + byte[] binaries = IOUtils.toByteArray(inputStream); String ossChecksum = MD5Util.byteArrayToHexString(MessageDigest.getInstance("MD5").digest(binaries)).toUpperCase(); if (ossChecksum.equals(checksum)) { diff --git a/src/main/java/net/irext/decoder/cache/IDecodeSessionRepository.java b/src/main/java/net/irext/decoder/cache/IDecodeSessionRepository.java index 5a6c6c2..5820541 100644 --- a/src/main/java/net/irext/decoder/cache/IDecodeSessionRepository.java +++ b/src/main/java/net/irext/decoder/cache/IDecodeSessionRepository.java @@ -1,7 +1,5 @@ package net.irext.decoder.cache; -import net.irext.decoder.model.DecodeSession; - import java.util.Map; /** diff --git a/src/main/java/net/irext/decoder/cache/IIRBinaryRepository.java b/src/main/java/net/irext/decoder/cache/IIRBinaryRepository.java index 2e1d5d9..abffd0b 100644 --- a/src/main/java/net/irext/decoder/cache/IIRBinaryRepository.java +++ b/src/main/java/net/irext/decoder/cache/IIRBinaryRepository.java @@ -1,6 +1,6 @@ package net.irext.decoder.cache; -import net.irext.decoder.model.IRBinary; +import net.irext.decoder.model.RemoteIndex; import java.util.Map; @@ -16,11 +16,11 @@ import java.util.Map; */ public interface IIRBinaryRepository { - Map findAllIRBinaries(); + Map findAllRemoteIndexes(); - void add(Integer id, byte[] binaries); + void add(Integer id, RemoteIndex remoteIndex); void delete(Integer id); - byte[] find(Integer id); + RemoteIndex find(Integer id); } \ No newline at end of file diff --git a/src/main/java/net/irext/decoder/cache/impl/DecodeSessionRepositoryImpl.java b/src/main/java/net/irext/decoder/cache/impl/DecodeSessionRepositoryImpl.java index b80ca12..a538bfe 100644 --- a/src/main/java/net/irext/decoder/cache/impl/DecodeSessionRepositoryImpl.java +++ b/src/main/java/net/irext/decoder/cache/impl/DecodeSessionRepositoryImpl.java @@ -1,6 +1,5 @@ package net.irext.decoder.cache.impl; -import net.irext.decoder.model.DecodeSession; import net.irext.decoder.cache.IDecodeSessionRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.HashOperations; diff --git a/src/main/java/net/irext/decoder/cache/impl/IRBinaryRepositoryImpl.java b/src/main/java/net/irext/decoder/cache/impl/IRBinaryRepositoryImpl.java index e6909bf..3820a61 100644 --- a/src/main/java/net/irext/decoder/cache/impl/IRBinaryRepositoryImpl.java +++ b/src/main/java/net/irext/decoder/cache/impl/IRBinaryRepositoryImpl.java @@ -1,6 +1,7 @@ package net.irext.decoder.cache.impl; import net.irext.decoder.cache.IIRBinaryRepository; +import net.irext.decoder.model.RemoteIndex; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; @@ -24,7 +25,7 @@ import java.util.Map; public class IRBinaryRepositoryImpl implements IIRBinaryRepository { private static final String KEY = "BINARY_KEY"; - @Resource(name="redisTemplate") + @Resource(name = "redisTemplate") private RedisTemplate redisTemplate; private HashOperations hashOperations; @@ -38,19 +39,19 @@ public class IRBinaryRepositoryImpl implements IIRBinaryRepository { hashOperations = redisTemplate.opsForHash(); } - public void add(Integer id, byte[] binaries) { - hashOperations.put(KEY, id, binaries); + public void add(Integer id, RemoteIndex remoteIndex) { + hashOperations.put(KEY, id, remoteIndex); } public void delete(final Integer id) { hashOperations.delete(KEY, id); } - public byte[] find(final Integer id) { - return (byte[])hashOperations.get(KEY, id); + public RemoteIndex find(final Integer id) { + return (RemoteIndex) hashOperations.get(KEY, id); } - public Map findAllIRBinaries() { + public Map findAllRemoteIndexes() { return hashOperations.entries(KEY); } } \ No newline at end of file diff --git a/src/main/java/net/irext/decoder/model/RemoteIndex.java b/src/main/java/net/irext/decoder/model/RemoteIndex.java index 04abaa3..a48b549 100644 --- a/src/main/java/net/irext/decoder/model/RemoteIndex.java +++ b/src/main/java/net/irext/decoder/model/RemoteIndex.java @@ -1,693 +1,255 @@ package net.irext.decoder.model; public class RemoteIndex { - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.id - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Integer id; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.category_id - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Integer categoryId; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.category_name - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String categoryName; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.brand_id - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Integer brandId; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.brand_name - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String brandName; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.city_code - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String cityCode; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.city_name - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String cityName; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.operator_id - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String operatorId; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.operator_name - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String operatorName; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.protocol - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String protocol; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.remote - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String remote; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.remote_map - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String remoteMap; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.status - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Byte status; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.sub_cate - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Byte subCate; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.priority - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private Integer priority; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.remote_number - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String remoteNumber; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.operator_name_tw - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String operatorNameTw; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.category_name_tw - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String categoryNameTw; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.brand_name_tw - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String brandNameTw; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.city_name_tw - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String cityNameTw; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.binary_md5 - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String binaryMd5; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.contributor - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String contributor; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column remote_index.update_time - * - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ private String updateTime; + private byte[] binaries; + + public RemoteIndex(Integer id, Integer categoryId, String categoryName, Integer brandId, String brandName, + String cityCode, String cityName, String operatorId, String operatorName, String protocol, + String remote, String remoteMap, Byte status, Byte subCate, Integer priority, + String remoteNumber, String operatorNameTw, String categoryNameTw, String brandNameTw, + String cityNameTw, String binaryMd5, String contributor, String updateTime, byte[] binaries) { + 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.protocol = protocol; + this.remote = remote; + this.remoteMap = remoteMap; + this.status = status; + this.subCate = subCate; + this.priority = priority; + this.remoteNumber = remoteNumber; + this.operatorNameTw = operatorNameTw; + this.categoryNameTw = categoryNameTw; + this.brandNameTw = brandNameTw; + this.cityNameTw = cityNameTw; + this.binaryMd5 = binaryMd5; + this.contributor = contributor; + this.updateTime = updateTime; + this.binaries = binaries; + } + + public RemoteIndex() { + + } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.id - * - * @return the value of remote_index.id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Integer getId() { return id; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.id - * - * @param id the value for remote_index.id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setId(Integer id) { this.id = id; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.category_id - * - * @return the value of remote_index.category_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Integer getCategoryId() { return categoryId; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.category_id - * - * @param categoryId the value for remote_index.category_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.category_name - * - * @return the value of remote_index.category_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getCategoryName() { return categoryName; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.category_name - * - * @param categoryName the value for remote_index.category_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCategoryName(String categoryName) { this.categoryName = categoryName; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.brand_id - * - * @return the value of remote_index.brand_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Integer getBrandId() { return brandId; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.brand_id - * - * @param brandId the value for remote_index.brand_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setBrandId(Integer brandId) { this.brandId = brandId; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.brand_name - * - * @return the value of remote_index.brand_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getBrandName() { return brandName; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.brand_name - * - * @param brandName the value for remote_index.brand_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setBrandName(String brandName) { this.brandName = brandName; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.city_code - * - * @return the value of remote_index.city_code - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getCityCode() { return cityCode; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.city_code - * - * @param cityCode the value for remote_index.city_code - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCityCode(String cityCode) { this.cityCode = cityCode; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.city_name - * - * @return the value of remote_index.city_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getCityName() { return cityName; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.city_name - * - * @param cityName the value for remote_index.city_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCityName(String cityName) { this.cityName = cityName; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.operator_id - * - * @return the value of remote_index.operator_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getOperatorId() { return operatorId; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.operator_id - * - * @param operatorId the value for remote_index.operator_id - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setOperatorId(String operatorId) { this.operatorId = operatorId; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.operator_name - * - * @return the value of remote_index.operator_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getOperatorName() { return operatorName; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.operator_name - * - * @param operatorName the value for remote_index.operator_name - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setOperatorName(String operatorName) { this.operatorName = operatorName; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.protocol - * - * @return the value of remote_index.protocol - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getProtocol() { return protocol; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.protocol - * - * @param protocol the value for remote_index.protocol - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setProtocol(String protocol) { this.protocol = protocol; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.remote - * - * @return the value of remote_index.remote - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getRemote() { return remote; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.remote - * - * @param remote the value for remote_index.remote - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setRemote(String remote) { this.remote = remote; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.remote_map - * - * @return the value of remote_index.remote_map - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getRemoteMap() { return remoteMap; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.remote_map - * - * @param remoteMap the value for remote_index.remote_map - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setRemoteMap(String remoteMap) { this.remoteMap = remoteMap; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.status - * - * @return the value of remote_index.status - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Byte getStatus() { return status; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.status - * - * @param status the value for remote_index.status - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setStatus(Byte status) { this.status = status; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.sub_cate - * - * @return the value of remote_index.sub_cate - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Byte getSubCate() { return subCate; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.sub_cate - * - * @param subCate the value for remote_index.sub_cate - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setSubCate(Byte subCate) { this.subCate = subCate; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.priority - * - * @return the value of remote_index.priority - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public Integer getPriority() { return priority; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.priority - * - * @param priority the value for remote_index.priority - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setPriority(Integer priority) { this.priority = priority; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.remote_number - * - * @return the value of remote_index.remote_number - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getRemoteNumber() { return remoteNumber; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.remote_number - * - * @param remoteNumber the value for remote_index.remote_number - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setRemoteNumber(String remoteNumber) { this.remoteNumber = remoteNumber; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.operator_name_tw - * - * @return the value of remote_index.operator_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getOperatorNameTw() { return operatorNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.operator_name_tw - * - * @param operatorNameTw the value for remote_index.operator_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setOperatorNameTw(String operatorNameTw) { this.operatorNameTw = operatorNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.category_name_tw - * - * @return the value of remote_index.category_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getCategoryNameTw() { return categoryNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.category_name_tw - * - * @param categoryNameTw the value for remote_index.category_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCategoryNameTw(String categoryNameTw) { this.categoryNameTw = categoryNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.brand_name_tw - * - * @return the value of remote_index.brand_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getBrandNameTw() { return brandNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.brand_name_tw - * - * @param brandNameTw the value for remote_index.brand_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setBrandNameTw(String brandNameTw) { this.brandNameTw = brandNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.city_name_tw - * - * @return the value of remote_index.city_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getCityNameTw() { return cityNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.city_name_tw - * - * @param cityNameTw the value for remote_index.city_name_tw - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setCityNameTw(String cityNameTw) { this.cityNameTw = cityNameTw; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.binary_md5 - * - * @return the value of remote_index.binary_md5 - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getBinaryMd5() { return binaryMd5; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.binary_md5 - * - * @param binaryMd5 the value for remote_index.binary_md5 - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setBinaryMd5(String binaryMd5) { this.binaryMd5 = binaryMd5; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.contributor - * - * @return the value of remote_index.contributor - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getContributor() { return contributor; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.contributor - * - * @param contributor the value for remote_index.contributor - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setContributor(String contributor) { this.contributor = contributor; } - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column remote_index.update_time - * - * @return the value of remote_index.update_time - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public String getUpdateTime() { return updateTime; } - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column remote_index.update_time - * - * @param updateTime the value for remote_index.update_time - * @mbggenerated Thu May 04 12:06:44 CST 2017 - */ public void setUpdateTime(String updateTime) { this.updateTime = updateTime; } + + public byte[] getBinaries() { + return binaries; + } + + public void setBinaries(byte[] binaries) { + this.binaries = binaries; + } } \ No newline at end of file diff --git a/src/main/java/net/irext/decoder/queue/MessageSubscriber.java b/src/main/java/net/irext/decoder/queue/MessageSubscriber.java index f17ba7f..471b5fe 100644 --- a/src/main/java/net/irext/decoder/queue/MessageSubscriber.java +++ b/src/main/java/net/irext/decoder/queue/MessageSubscriber.java @@ -1,12 +1,12 @@ package net.irext.decoder.queue; -import java.util.ArrayList; -import java.util.List; - import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + /** * Filename: MessageSubscriber.java * Revised: Date: 2018-12-29 diff --git a/src/main/java/net/irext/decoder/service/IRDecodeService.java b/src/main/java/net/irext/decoder/service/IRDecodeService.java index d356c63..cc95bb2 100644 --- a/src/main/java/net/irext/decoder/service/IRDecodeService.java +++ b/src/main/java/net/irext/decoder/service/IRDecodeService.java @@ -2,11 +2,11 @@ package net.irext.decoder.service; import net.irext.decoder.businesslogic.DecodeLogic; import net.irext.decoder.businesslogic.IndexLogic; +import net.irext.decoder.cache.IDecodeSessionRepository; +import net.irext.decoder.cache.IIRBinaryRepository; import net.irext.decoder.mapper.RemoteIndexMapper; import net.irext.decoder.model.DecodeSession; import net.irext.decoder.model.RemoteIndex; -import net.irext.decoder.cache.IDecodeSessionRepository; -import net.irext.decoder.cache.IIRBinaryRepository; import net.irext.decoder.request.CloseRequest; import net.irext.decoder.request.DecodeRequest; import net.irext.decoder.request.OpenRequest; @@ -21,7 +21,10 @@ import net.irext.decodesdk.bean.ACStatus; import net.irext.decodesdk.utils.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.*; +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.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -64,7 +67,7 @@ public class IRDecodeService extends AbstractBaseService { try { int remoteIndexId = openRequest.getRemoteIndexId(); - LoggerUtil.getInstance().trace(TAG,"irOpen API called : " + remoteIndexId); + LoggerUtil.getInstance().trace(TAG, "irOpen API called : " + remoteIndexId); StringResponse response = new StringResponse(); RemoteIndex remoteIndex = IndexLogic.getInstance(remoteIndexMapper).getRemoteIndex(remoteIndexId); @@ -76,10 +79,10 @@ public class IRDecodeService extends AbstractBaseService { LoggerUtil.getInstance().trace(TAG, "remoteIndex get : " + remoteIndex.getId() + ", " + remoteIndex.getRemoteMap()); } - byte []binaryContent = DecodeLogic.getInstance().openIRBinary(context, irBinaryRepository, remoteIndex); + byte[] binaryContent = DecodeLogic.getInstance().openIRBinary(context, irBinaryRepository, remoteIndex); if (null != binaryContent) { - LoggerUtil.getInstance().trace(TAG,"binary content fetched : " + binaryContent.length); + LoggerUtil.getInstance().trace(TAG, "binary content fetched : " + binaryContent.length); // construct a session with this binary String address = request.getRemoteAddr(); LoggerUtil.getInstance().trace(TAG, "request Address = " + address); diff --git a/src/main/java/net/irext/decoder/service/base/AbstractBaseService.java b/src/main/java/net/irext/decoder/service/base/AbstractBaseService.java index 232ff35..ea7f037 100644 --- a/src/main/java/net/irext/decoder/service/base/AbstractBaseService.java +++ b/src/main/java/net/irext/decoder/service/base/AbstractBaseService.java @@ -5,8 +5,6 @@ import net.irext.decoder.response.ServiceResponse; import net.irext.decoder.response.Status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Filename: AbstractBaseService.java diff --git a/src/main/java/net/irext/decoder/utils/FileUtil.java b/src/main/java/net/irext/decoder/utils/FileUtil.java index 1629b00..2859b07 100644 --- a/src/main/java/net/irext/decoder/utils/FileUtil.java +++ b/src/main/java/net/irext/decoder/utils/FileUtil.java @@ -90,7 +90,7 @@ public class FileUtil { if (f.isDirectory()) { deleteAllFiles(f); try { - if(!f.delete()) { + if (!f.delete()) { System.out.println("failed to delete file"); } } catch (Exception e) { @@ -100,7 +100,7 @@ public class FileUtil { if (f.exists()) { deleteAllFiles(f); try { - if(!f.delete()) { + if (!f.delete()) { System.out.println("failed to delete file"); } } catch (Exception e) { diff --git a/src/main/java/net/irext/decoder/utils/LoggerUtil.java b/src/main/java/net/irext/decoder/utils/LoggerUtil.java index 03ab5e7..b0a3644 100644 --- a/src/main/java/net/irext/decoder/utils/LoggerUtil.java +++ b/src/main/java/net/irext/decoder/utils/LoggerUtil.java @@ -1,6 +1,5 @@ package net.irext.decoder.utils; -import net.irext.decoder.service.IRDecodeService; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/irext/decodesdk/IRDecode.java b/src/main/java/net/irext/decodesdk/IRDecode.java index 8f532e4..9df7fe6 100644 --- a/src/main/java/net/irext/decodesdk/IRDecode.java +++ b/src/main/java/net/irext/decodesdk/IRDecode.java @@ -66,7 +66,7 @@ public class IRDecode { } public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) { - int []decoded; + int[] decoded; synchronized (mSync) { if (null == acStatus) { acStatus = new ACStatus(); @@ -86,7 +86,7 @@ public class IRDecode { public int[] getACSupportedMode() { // cool, heat, auto, fan, de-humidification - int []retSupportedMode = {0, 0, 0, 0, 0}; + int[] retSupportedMode = {0, 0, 0, 0, 0}; int supportedMode = irACGetSupportedMode(); for (int i = Constants.ACMode.MODE_COOL.getValue(); i <= Constants.ACMode.MODE_DEHUMIDITY.getValue(); i++) { @@ -97,7 +97,7 @@ public class IRDecode { public int[] getACSupportedWindSpeed(int acMode) { // auto, low, medium, high - int []retSupportedWindSpeed = {0, 0, 0, 0}; + int[] retSupportedWindSpeed = {0, 0, 0, 0}; int supportedWindSpeed = irACGetSupportedWindSpeed(acMode); for (int i = Constants.ACWindSpeed.SPEED_AUTO.getValue(); i <= Constants.ACWindSpeed.SPEED_HIGH.getValue(); @@ -109,7 +109,7 @@ public class IRDecode { public int[] getACSupportedSwing(int acMode) { // swing-on, swing-off - int []retSupportedSwing= {0, 0}; + int[] retSupportedSwing = {0, 0}; int supportedSwing = irACGetSupportedSwing(acMode); for (int i = Constants.ACSwing.SWING_ON.getValue(); i <= Constants.ACSwing.SWING_OFF.getValue(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4aafd26..0cbfd2d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,9 +1,7 @@ server.port=8082 - spring.cache.type=redis spring.redis.host=localhost spring.redis.port=6379 - spring.datasource.url=jdbc:mysql://localhost:3306/irext?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=root \ No newline at end of file diff --git a/src/main/resources/log4j2-spring.xml b/src/main/resources/log4j2-spring.xml index 539824a..0092bf6 100644 --- a/src/main/resources/log4j2-spring.xml +++ b/src/main/resources/log4j2-spring.xml @@ -3,7 +3,7 @@ + pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable"/> - + - + size="10 MB"/> + @@ -26,8 +26,8 @@ - - + +