diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/android/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..1125ce8 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.library' + +android { + signingConfigs { + irext_key { + keyAlias 'irext_key' + keyPassword 'ghostcicy' + storeFile file('D:/Project/Github_Work/irext/keys/irext_key.jks') + storePassword 'ghostcicy' + } + } + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + minSdkVersion 19 + targetSdkVersion 25 + versionCode 1 + versionName "0.1.2" + signingConfig signingConfigs.irext_key + } + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.irext_key + versionNameSuffix '0.1.2' + } + } + productFlavors { + + } +} + +dependencies { + compile files('libs/gson-2.8.0.jar') + compile files('libs/okhttp-3.7.0.jar') + compile files('libs/okio-1.12.0.jar') +} diff --git a/lib/gson-2.8.0.jar b/android/libs/gson-2.8.0.jar similarity index 100% rename from lib/gson-2.8.0.jar rename to android/libs/gson-2.8.0.jar diff --git a/lib/okhttp-3.7.0.jar b/android/libs/okhttp-3.7.0.jar similarity index 100% rename from lib/okhttp-3.7.0.jar rename to android/libs/okhttp-3.7.0.jar diff --git a/lib/okio-1.12.0.jar b/android/libs/okio-1.12.0.jar similarity index 100% rename from lib/okio-1.12.0.jar rename to android/libs/okio-1.12.0.jar diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 0000000..e4fe55e --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in C:\Android\android-sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..179f9a3 --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/android/src/main/java/net/irext/webapi/WebAPIs.java b/android/src/main/java/net/irext/webapi/WebAPIs.java new file mode 100644 index 0000000..a8142af --- /dev/null +++ b/android/src/main/java/net/irext/webapi/WebAPIs.java @@ -0,0 +1,324 @@ +package net.irext.webapi; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; + +import com.google.gson.Gson; +import net.irext.webapi.model.*; +import net.irext.webapi.utils.Constants; +import net.irext.webapi.request.*; +import net.irext.webapi.response.*; +import net.irext.webapi.utils.PackageUtils; + +import okhttp3.*; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +/** + * Filename: WebAPIs.java + * Revised: Date: 2017-03-30 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Request initializer + *

+ * Revision log: + * 2017-03-30: created by strawmanbobi + */ +public class WebAPIs { + + @SuppressWarnings("all") + private static final String TAG = WebAPIs.class.getSimpleName(); + + private static WebAPIs mInstance = null; + + private static final String DEFAULT_ADDRESS = "http://irext.net"; + private static final String DEFAULT_APP = "/irext-server"; + private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP; + + private static final String SERVICE_SIGN_IN = "/app/app_login"; + private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories"; + private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands"; + private static final String SERVICE_LIST_PROVINCES = "/indexing/list_provinces"; + private static final String SERVICE_LIST_CITIES = "/indexing/list_cities"; + private static final String SERVICE_LIST_OPERATORS = "/indexing/list_operators"; + private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes"; + private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin"; + private static final String SERVICE_ONLINE_DECODE = "/operation/decode"; + + private int adminId; + private String token; + + private OkHttpClient mHttpClient; + + private WebAPIs(String address, String appName) { + if (null != address && null != appName) { + URL_PREFIX = address + appName; + } + mHttpClient = new OkHttpClient(); + } + + private static void initializeInstance(String address, String appName) { + mInstance = new WebAPIs(address, appName); + } + + @SuppressWarnings("unused") + public static WebAPIs getInstance(String address, String appName) { + if (null == mInstance) { + initializeInstance(address, appName); + } + return mInstance; + } + + private String postToServer(String url, String json) throws IOException { + MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + + RequestBody body = RequestBody.create(JSON, json); + Request request = new Request.Builder() + .url(url) + .post(body) + .build(); + Response response = mHttpClient.newCall(request).execute(); + return response.body().string(); + } + + private InputStream postToServerForOctets(String url, String json) throws IOException { + MediaType JSON + = MediaType.parse("application/json; charset=utf-8"); + RequestBody body = RequestBody.create(JSON, json); + + Request request = new Request.Builder() + .url(url) + .post(body) + .build(); + + Response response = mHttpClient.newCall(request).execute(); + return response.body().byteStream(); + } + + @SuppressWarnings("unused") + public UserApp signIn(Context context) { + try { + String signInURL = URL_PREFIX + SERVICE_SIGN_IN; + AppSignInRequest appSignInRequest = new AppSignInRequest(); + + ApplicationInfo appInfo = context.getPackageManager() + .getApplicationInfo(context.getPackageName(), + PackageManager.GET_META_DATA); + String appKey = appInfo.metaData.getString("irext_app_key"); + String appSecret = appInfo.metaData.getString("irext_app_secret"); + + appSignInRequest.setAppKey(appKey); + appSignInRequest.setAppSecret(appSecret); + appSignInRequest.setAppType(0); + + String packageName = context.getApplicationContext().getPackageName(); + appSignInRequest.setAndroidPackageName(packageName); + + String signature = PackageUtils.getCertificateSHA1Fingerprint(context); + + appSignInRequest.setAndroidSignature(signature); + String bodyJson = appSignInRequest.toJson(); + + String response = postToServer(signInURL, bodyJson); + LoginResponse loginResponse = new Gson().fromJson(response, LoginResponse.class); + if (loginResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + UserApp admin = loginResponse.getEntity(); + if (0 != admin.getId() && null != admin.getToken()) { + adminId = admin.getId(); + token = admin.getToken(); + } + return admin; + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public List listCategories(int from, int count) { + String listCategoriesURL = URL_PREFIX + SERVICE_LIST_CATEGORIES; + ListCategoriesRequest listCategoriesRequest = new ListCategoriesRequest(); + listCategoriesRequest.setAdminId(adminId); + listCategoriesRequest.setToken(token); + listCategoriesRequest.setFrom(from); + listCategoriesRequest.setCount(count); + String bodyJson = listCategoriesRequest.toJson(); + + try { + String response = postToServer(listCategoriesURL, bodyJson); + CategoriesResponse categoriesResponse = new Gson().fromJson(response, CategoriesResponse.class); + + if(categoriesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return categoriesResponse.getEntity(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public List listBrands(int categoryId, int from, int count) { + String listBrandsURL = URL_PREFIX + SERVICE_LIST_BRANDS; + ListBrandsRequest listBrandsRequest = new ListBrandsRequest(); + listBrandsRequest.setAdminId(adminId); + listBrandsRequest.setToken(token); + listBrandsRequest.setCategoryId(categoryId); + listBrandsRequest.setFrom(from); + listBrandsRequest.setCount(count); + String bodyJson = listBrandsRequest.toJson(); + + try { + String response = postToServer(listBrandsURL, bodyJson); + BrandsResponse brandsResponse = new Gson().fromJson(response, BrandsResponse.class); + + if(brandsResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return brandsResponse.getEntity(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public List listProvinces() { + String listProvincesURL = URL_PREFIX + SERVICE_LIST_PROVINCES; + ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); + listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setToken(token); + String bodyJson = listCitiesRequest.toJson(); + + return listCitiesCommon(listProvincesURL, bodyJson); + } + + @SuppressWarnings("unused") + public List listCities(String prefix) { + String listCitiesURL = URL_PREFIX + SERVICE_LIST_CITIES; + ListCitiesRequest listCitiesRequest = new ListCitiesRequest(); + listCitiesRequest.setAdminId(adminId); + listCitiesRequest.setToken(token); + listCitiesRequest.setProvincePrefix(prefix); + String bodyJson = listCitiesRequest.toJson(); + + return listCitiesCommon(listCitiesURL, bodyJson); + } + + private List listCitiesCommon(String url, String bodyJson) { + try { + String response = postToServer(url, bodyJson); + CitiesResponse citiesResponse = new Gson().fromJson(response, CitiesResponse.class); + + if (citiesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return citiesResponse.getEntity(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public List listOperators(String cityCode) { + String listOperatorsURL = URL_PREFIX + SERVICE_LIST_OPERATORS; + ListOperatorsRequest listOperatorsRequest = new ListOperatorsRequest(); + listOperatorsRequest.setAdminId(adminId); + listOperatorsRequest.setToken(token); + listOperatorsRequest.setCityCode(cityCode); + listOperatorsRequest.setFrom(0); + listOperatorsRequest.setCount(20); + String bodyJson = listOperatorsRequest.toJson(); + + try { + String response = postToServer(listOperatorsURL, bodyJson); + OperatorsResponse operatorsResponse = new Gson().fromJson(response, OperatorsResponse.class); + + if (operatorsResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return operatorsResponse.getEntity(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public List listRemoteIndexes(int categoryId, int brandId, String cityCode, String operatorId) { + String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES; + ListIndexesRequest listIndexesRequest = new ListIndexesRequest(); + listIndexesRequest.setAdminId(adminId); + listIndexesRequest.setToken(token); + listIndexesRequest.setCategoryId(categoryId); + listIndexesRequest.setBrandId(brandId); + listIndexesRequest.setCityCode(cityCode); + listIndexesRequest.setOperatorId(operatorId); + listIndexesRequest.setFrom(0); + listIndexesRequest.setCount(20); + String bodyJson = listIndexesRequest.toJson(); + + try { + String response = postToServer(listIndexesURL, bodyJson); + + IndexesResponse indexesResponse = new Gson().fromJson(response, IndexesResponse.class); + + if (indexesResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return indexesResponse.getEntity(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @SuppressWarnings("unused") + public InputStream downloadBin(String remoteMap, int indexId) { + String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN; + DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest(); + downloadBinaryRequest.setAdminId(adminId); + downloadBinaryRequest.setToken(token); + downloadBinaryRequest.setIndexId(indexId); + + String bodyJson = downloadBinaryRequest.toJson(); + + if (null != bodyJson) { + try { + return postToServerForOctets(downloadURL, bodyJson); + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + @SuppressWarnings("unused") + @Deprecated + public int[] decodeIR(int indexId) { + String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE; + DecodeRequest decodeRequest = new DecodeRequest(); + decodeRequest.setAdminId(adminId); + decodeRequest.setToken(token); + decodeRequest.setIndexId(indexId); + + String bodyJson = decodeRequest.toJson(); + + if (null != bodyJson) { + try { + String response = postToServer(decodeURL, bodyJson); + + DecodeResponse decodeResponse = new Gson().fromJson(response, DecodeResponse.class); + + if (decodeResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) { + return decodeResponse.getEntity(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } +} diff --git a/src/net/irext/webapi/bean/ACStatus.java b/android/src/main/java/net/irext/webapi/bean/ACStatus.java similarity index 100% rename from src/net/irext/webapi/bean/ACStatus.java rename to android/src/main/java/net/irext/webapi/bean/ACStatus.java diff --git a/src/net/irext/webapi/bean/TemperatureRange.java b/android/src/main/java/net/irext/webapi/bean/TemperatureRange.java similarity index 100% rename from src/net/irext/webapi/bean/TemperatureRange.java rename to android/src/main/java/net/irext/webapi/bean/TemperatureRange.java diff --git a/src/net/irext/webapi/model/Brand.java b/android/src/main/java/net/irext/webapi/model/Brand.java similarity index 100% rename from src/net/irext/webapi/model/Brand.java rename to android/src/main/java/net/irext/webapi/model/Brand.java diff --git a/src/net/irext/webapi/model/Category.java b/android/src/main/java/net/irext/webapi/model/Category.java similarity index 100% rename from src/net/irext/webapi/model/Category.java rename to android/src/main/java/net/irext/webapi/model/Category.java diff --git a/src/net/irext/webapi/model/City.java b/android/src/main/java/net/irext/webapi/model/City.java similarity index 100% rename from src/net/irext/webapi/model/City.java rename to android/src/main/java/net/irext/webapi/model/City.java diff --git a/src/net/irext/webapi/model/RemoteIndex.java b/android/src/main/java/net/irext/webapi/model/RemoteIndex.java similarity index 100% rename from src/net/irext/webapi/model/RemoteIndex.java rename to android/src/main/java/net/irext/webapi/model/RemoteIndex.java diff --git a/src/net/irext/webapi/model/StbOperator.java b/android/src/main/java/net/irext/webapi/model/StbOperator.java similarity index 100% rename from src/net/irext/webapi/model/StbOperator.java rename to android/src/main/java/net/irext/webapi/model/StbOperator.java diff --git a/android/src/main/java/net/irext/webapi/model/UserApp.java b/android/src/main/java/net/irext/webapi/model/UserApp.java new file mode 100644 index 0000000..e16c502 --- /dev/null +++ b/android/src/main/java/net/irext/webapi/model/UserApp.java @@ -0,0 +1,397 @@ +package net.irext.webapi.model; + +public class UserApp { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Integer adminId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String adminName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Byte appType; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String androidPackageName; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String androidSignature; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String iosIdentity; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private Byte isDebug; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appKey; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String appSecret; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + private String updateTime; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.id + * + * @return the value of user_app.id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.id + * + * @param id the value for user_app.id + * + * @mbggenerated Fri May 26 19:47:48 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 user_app.app_name + * + * @return the value of user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppName() { + return appName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_name + * + * @param appName the value for user_app.app_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppName(String appName) { + this.appName = appName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.admin_id + * + * @return the value of user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Integer getAdminId() { + return adminId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.admin_id + * + * @param adminId the value for user_app.admin_id + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAdminId(Integer adminId) { + this.adminId = adminId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.admin_name + * + * @return the value of user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAdminName() { + return adminName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.admin_name + * + * @param adminName the value for user_app.admin_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAdminName(String adminName) { + this.adminName = adminName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_type + * + * @return the value of user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Byte getAppType() { + return appType; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_type + * + * @param appType the value for user_app.app_type + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppType(Byte appType) { + this.appType = appType; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.android_package_name + * + * @return the value of user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAndroidPackageName() { + return androidPackageName; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.android_package_name + * + * @param androidPackageName the value for user_app.android_package_name + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAndroidPackageName(String androidPackageName) { + this.androidPackageName = androidPackageName; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.android_signature + * + * @return the value of user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAndroidSignature() { + return androidSignature; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.android_signature + * + * @param androidSignature the value for user_app.android_signature + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAndroidSignature(String androidSignature) { + this.androidSignature = androidSignature; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.ios_identity + * + * @return the value of user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getIosIdentity() { + return iosIdentity; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.ios_identity + * + * @param iosIdentity the value for user_app.ios_identity + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setIosIdentity(String iosIdentity) { + this.iosIdentity = iosIdentity; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.is_debug + * + * @return the value of user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public Byte getIsDebug() { + return isDebug; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.is_debug + * + * @param isDebug the value for user_app.is_debug + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setIsDebug(Byte isDebug) { + this.isDebug = isDebug; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_key + * + * @return the value of user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppKey() { + return appKey; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_key + * + * @param appKey the value for user_app.app_key + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.app_secret + * + * @return the value of user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getAppSecret() { + return appSecret; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.app_secret + * + * @param appSecret the value for user_app.app_secret + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_app.update_time + * + * @return the value of user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public String getUpdateTime() { + return updateTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_app.update_time + * + * @param updateTime the value for user_app.update_time + * + * @mbggenerated Fri May 26 19:47:48 CST 2017 + */ + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} \ No newline at end of file diff --git a/android/src/main/java/net/irext/webapi/request/AppSignInRequest.java b/android/src/main/java/net/irext/webapi/request/AppSignInRequest.java new file mode 100644 index 0000000..7cb3bc8 --- /dev/null +++ b/android/src/main/java/net/irext/webapi/request/AppSignInRequest.java @@ -0,0 +1,83 @@ +package net.irext.webapi.request; + +/** + * Filename: AppSignInRequest.java + * Revised: Date: 2017-05-27 + * Revision: Revision: 1.0 + *

+ * Description: HTTP admin login request + *

+ * Revision log: + * 2017-05-27: created by strawmanbobi + */ +public class AppSignInRequest extends BaseRequest { + + private String appKey; + private String appSecret; + private int appType; + private String iOSID; + private String androidPackageName; + private String androidSignature; + + public AppSignInRequest(String appKey, String appSecret, int appType, + String iOSID, String androidPackageName, String androidSignature) { + this.appKey = appKey; + this.appSecret = appSecret; + this.appType = appType; + this.iOSID = iOSID; + this.androidPackageName = androidPackageName; + this.androidSignature = androidSignature; + } + + public AppSignInRequest() { + + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getAppSecret() { + return appSecret; + } + + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + public int getAppType() { + return appType; + } + + public void setAppType(int appType) { + this.appType = appType; + } + + public String getiOSID() { + return iOSID; + } + + public void setiOSID(String iOSID) { + this.iOSID = iOSID; + } + + public String getAndroidPackageName() { + return androidPackageName; + } + + public void setAndroidPackageName(String androidPackageName) { + this.androidPackageName = androidPackageName; + } + + public String getAndroidSignature() { + return androidSignature; + } + + public void setAndroidSignature(String androidSignature) { + this.androidSignature = androidSignature; + } +} diff --git a/src/net/irext/webapi/request/BaseRequest.java b/android/src/main/java/net/irext/webapi/request/BaseRequest.java similarity index 100% rename from src/net/irext/webapi/request/BaseRequest.java rename to android/src/main/java/net/irext/webapi/request/BaseRequest.java diff --git a/src/net/irext/webapi/request/DecodeRequest.java b/android/src/main/java/net/irext/webapi/request/DecodeRequest.java similarity index 100% rename from src/net/irext/webapi/request/DecodeRequest.java rename to android/src/main/java/net/irext/webapi/request/DecodeRequest.java diff --git a/src/net/irext/webapi/request/DownloadBinaryRequest.java b/android/src/main/java/net/irext/webapi/request/DownloadBinaryRequest.java similarity index 100% rename from src/net/irext/webapi/request/DownloadBinaryRequest.java rename to android/src/main/java/net/irext/webapi/request/DownloadBinaryRequest.java diff --git a/src/net/irext/webapi/request/ListBrandsRequest.java b/android/src/main/java/net/irext/webapi/request/ListBrandsRequest.java similarity index 100% rename from src/net/irext/webapi/request/ListBrandsRequest.java rename to android/src/main/java/net/irext/webapi/request/ListBrandsRequest.java diff --git a/src/net/irext/webapi/request/ListCategoriesRequest.java b/android/src/main/java/net/irext/webapi/request/ListCategoriesRequest.java similarity index 100% rename from src/net/irext/webapi/request/ListCategoriesRequest.java rename to android/src/main/java/net/irext/webapi/request/ListCategoriesRequest.java diff --git a/src/net/irext/webapi/request/ListCitiesRequest.java b/android/src/main/java/net/irext/webapi/request/ListCitiesRequest.java similarity index 100% rename from src/net/irext/webapi/request/ListCitiesRequest.java rename to android/src/main/java/net/irext/webapi/request/ListCitiesRequest.java diff --git a/src/net/irext/webapi/request/ListIndexesRequest.java b/android/src/main/java/net/irext/webapi/request/ListIndexesRequest.java similarity index 100% rename from src/net/irext/webapi/request/ListIndexesRequest.java rename to android/src/main/java/net/irext/webapi/request/ListIndexesRequest.java diff --git a/src/net/irext/webapi/request/ListOperatorsRequest.java b/android/src/main/java/net/irext/webapi/request/ListOperatorsRequest.java similarity index 100% rename from src/net/irext/webapi/request/ListOperatorsRequest.java rename to android/src/main/java/net/irext/webapi/request/ListOperatorsRequest.java diff --git a/src/net/irext/webapi/response/BrandsResponse.java b/android/src/main/java/net/irext/webapi/response/BrandsResponse.java similarity index 100% rename from src/net/irext/webapi/response/BrandsResponse.java rename to android/src/main/java/net/irext/webapi/response/BrandsResponse.java diff --git a/src/net/irext/webapi/response/CategoriesResponse.java b/android/src/main/java/net/irext/webapi/response/CategoriesResponse.java similarity index 100% rename from src/net/irext/webapi/response/CategoriesResponse.java rename to android/src/main/java/net/irext/webapi/response/CategoriesResponse.java diff --git a/src/net/irext/webapi/response/CitiesResponse.java b/android/src/main/java/net/irext/webapi/response/CitiesResponse.java similarity index 100% rename from src/net/irext/webapi/response/CitiesResponse.java rename to android/src/main/java/net/irext/webapi/response/CitiesResponse.java diff --git a/src/net/irext/webapi/response/DecodeResponse.java b/android/src/main/java/net/irext/webapi/response/DecodeResponse.java similarity index 100% rename from src/net/irext/webapi/response/DecodeResponse.java rename to android/src/main/java/net/irext/webapi/response/DecodeResponse.java diff --git a/src/net/irext/webapi/response/IndexesResponse.java b/android/src/main/java/net/irext/webapi/response/IndexesResponse.java similarity index 100% rename from src/net/irext/webapi/response/IndexesResponse.java rename to android/src/main/java/net/irext/webapi/response/IndexesResponse.java diff --git a/android/src/main/java/net/irext/webapi/response/LoginResponse.java b/android/src/main/java/net/irext/webapi/response/LoginResponse.java new file mode 100644 index 0000000..9f06381 --- /dev/null +++ b/android/src/main/java/net/irext/webapi/response/LoginResponse.java @@ -0,0 +1,35 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.UserApp; + +/** + * Filename: LoginResponse.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Admin login response + *

+ * Revision log: + * 2017-03-31: created by strawmanbobi + */ +public class LoginResponse extends ServiceResponse { + + private UserApp entity; + + public LoginResponse(Status status, UserApp userApp) { + super(status); + this.entity = userApp; + } + + public LoginResponse() { + + } + + public UserApp getEntity() { + return entity; + } + + public void setEntity(UserApp entity) { + this.entity = entity; + } +} diff --git a/src/net/irext/webapi/response/OperatorsResponse.java b/android/src/main/java/net/irext/webapi/response/OperatorsResponse.java similarity index 100% rename from src/net/irext/webapi/response/OperatorsResponse.java rename to android/src/main/java/net/irext/webapi/response/OperatorsResponse.java diff --git a/src/net/irext/webapi/response/ServiceResponse.java b/android/src/main/java/net/irext/webapi/response/ServiceResponse.java similarity index 100% rename from src/net/irext/webapi/response/ServiceResponse.java rename to android/src/main/java/net/irext/webapi/response/ServiceResponse.java diff --git a/src/net/irext/webapi/response/Status.java b/android/src/main/java/net/irext/webapi/response/Status.java similarity index 100% rename from src/net/irext/webapi/response/Status.java rename to android/src/main/java/net/irext/webapi/response/Status.java diff --git a/src/net/irext/webapi/utils/Constants.java b/android/src/main/java/net/irext/webapi/utils/Constants.java similarity index 100% rename from src/net/irext/webapi/utils/Constants.java rename to android/src/main/java/net/irext/webapi/utils/Constants.java diff --git a/src/net/irext/webapi/utils/MD5Digest.java b/android/src/main/java/net/irext/webapi/utils/MD5Digest.java similarity index 100% rename from src/net/irext/webapi/utils/MD5Digest.java rename to android/src/main/java/net/irext/webapi/utils/MD5Digest.java diff --git a/android/src/main/java/net/irext/webapi/utils/PackageUtils.java b/android/src/main/java/net/irext/webapi/utils/PackageUtils.java new file mode 100644 index 0000000..f7bac70 --- /dev/null +++ b/android/src/main/java/net/irext/webapi/utils/PackageUtils.java @@ -0,0 +1,79 @@ +package net.irext.webapi.utils; + +import android.content.Context; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.Signature; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +/** + * Filename: PackageUtils.java + * Revised: Date: 2017-05-27 + * Revision: Revision: 1.0 + *

+ * Description: String utils + *

+ * Revision log: + * 2017-05-27: created by strawmanbobi + */ +public class PackageUtils { + + public static String byte2HexFormatted(byte[] arr) { + StringBuilder str = new StringBuilder(arr.length * 2); + for (int i = 0; i < arr.length; i++) { + String h = Integer.toHexString(arr[i]); + int l = h.length(); + if (l == 1) h = "0" + h; + if (l > 2) h = h.substring(l - 2, l); + str.append(h.toUpperCase()); + if (i < (arr.length - 1)) str.append(':'); + } + return str.toString(); + } + + public static String getCertificateSHA1Fingerprint(Context context) { + PackageManager pm = context.getPackageManager(); + String packageName = context.getPackageName(); + int flags = PackageManager.GET_SIGNATURES; + PackageInfo packageInfo = null; + try { + packageInfo = pm.getPackageInfo(packageName, flags); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + Signature[] signatures = packageInfo.signatures; + byte[] cert = signatures[0].toByteArray(); + InputStream input = new ByteArrayInputStream(cert); + CertificateFactory cf = null; + try { + cf = CertificateFactory.getInstance("X509"); + } catch (CertificateException e) { + e.printStackTrace(); + } + X509Certificate c = null; + try { + c = (X509Certificate) cf.generateCertificate(input); + } catch (CertificateException e) { + e.printStackTrace(); + } + String hexString = null; + try { + MessageDigest md = MessageDigest.getInstance("SHA1"); + byte[] publicKey = md.digest(c.getEncoded()); + hexString = byte2HexFormatted(publicKey); + } catch (NoSuchAlgorithmException e1) { + e1.printStackTrace(); + } catch (CertificateEncodingException e) { + e.printStackTrace(); + } + return hexString; + } +} diff --git a/android/web-api.iml b/android/web-api.iml new file mode 100644 index 0000000..a86eaf3 --- /dev/null +++ b/android/web-api.iml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/net/irext/webapi/request/LoginRequest.java b/src/net/irext/webapi/request/LoginRequest.java deleted file mode 100644 index 740c1b0..0000000 --- a/src/net/irext/webapi/request/LoginRequest.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.irext.webapi.request; - -/** - * Filename: LoginRequest.java - * Revised: Date: 2017-04-07 - * Revision: Revision: 1.0 - *

- * Description: HTTP admin login request - *

- * Revision log: - * 2017-04-07: created by strawmanbobi - */ -public class LoginRequest extends BaseRequest { - - private String userName; - private String password; - - public LoginRequest(String userName, String password) { - this.userName = userName; - this.password = password; - } - - public LoginRequest() { - - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/.gitignore b/web/.gitignore similarity index 100% rename from .gitignore rename to web/.gitignore diff --git a/web/lib/gson-2.8.0.jar b/web/lib/gson-2.8.0.jar new file mode 100644 index 0000000..1235f63 Binary files /dev/null and b/web/lib/gson-2.8.0.jar differ diff --git a/web/lib/okhttp-3.7.0.jar b/web/lib/okhttp-3.7.0.jar new file mode 100644 index 0000000..853c553 Binary files /dev/null and b/web/lib/okhttp-3.7.0.jar differ diff --git a/web/lib/okio-1.12.0.jar b/web/lib/okio-1.12.0.jar new file mode 100644 index 0000000..0ac0d70 Binary files /dev/null and b/web/lib/okio-1.12.0.jar differ diff --git a/release/irext-web-api-0.1.1.jar b/web/release/irext-web-api-0.1.1.jar similarity index 100% rename from release/irext-web-api-0.1.1.jar rename to web/release/irext-web-api-0.1.1.jar diff --git a/src/META-INF/MANIFEST.MF b/web/src/META-INF/MANIFEST.MF similarity index 100% rename from src/META-INF/MANIFEST.MF rename to web/src/META-INF/MANIFEST.MF diff --git a/src/net/irext/webapi/WebAPIs.java b/web/src/net/irext/webapi/WebAPIs.java similarity index 96% rename from src/net/irext/webapi/WebAPIs.java rename to web/src/net/irext/webapi/WebAPIs.java index 0d7790d..727e777 100644 --- a/src/net/irext/webapi/WebAPIs.java +++ b/web/src/net/irext/webapi/WebAPIs.java @@ -3,7 +3,6 @@ package net.irext.webapi; import com.google.gson.Gson; import net.irext.webapi.model.*; import net.irext.webapi.utils.Constants; -import net.irext.webapi.utils.MD5Digest; import net.irext.webapi.request.*; import net.irext.webapi.response.*; import okhttp3.*; @@ -29,12 +28,11 @@ public class WebAPIs { private static WebAPIs mInstance = null; - // private static final String DEFAULT_ADDRESS = "http://192.168.137.128:8080"; private static final String DEFAULT_ADDRESS = "http://irext.net"; private static final String DEFAULT_APP = "/irext-server"; private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP; - private static final String SERVICE_SIGN_IN = "/admin/sign_in"; + private static final String SERVICE_SIGN_IN = "/app/app_login"; private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories"; private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands"; private static final String SERVICE_LIST_PROVINCES = "/indexing/list_provinces"; @@ -96,12 +94,13 @@ public class WebAPIs { } @SuppressWarnings("unused") - public Admin signIn(String userName, String password) { + public Admin signIn(String appKey, String appSecret) { String signInURL = URL_PREFIX + SERVICE_SIGN_IN; - LoginRequest loginRequest = new LoginRequest(); - loginRequest.setUserName(userName); - loginRequest.setPassword(MD5Digest.MD5(password)); - String bodyJson = loginRequest.toJson(); + AppSignInRequest appSignInRequest = new AppSignInRequest(); + appSignInRequest.setAppKey(appKey); + appSignInRequest.setAppSecret(appSecret); + appSignInRequest.setAppType(2); + String bodyJson = appSignInRequest.toJson(); try { String response = postToServer(signInURL, bodyJson); diff --git a/web/src/net/irext/webapi/bean/ACStatus.java b/web/src/net/irext/webapi/bean/ACStatus.java new file mode 100644 index 0000000..ca4c51d --- /dev/null +++ b/web/src/net/irext/webapi/bean/ACStatus.java @@ -0,0 +1,104 @@ +package net.irext.webapi.bean; + +/** + * Filename: ACStatus.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Status descriptor for air-conditioner + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class ACStatus { + + private static final String TAG = ACStatus.class.getSimpleName(); + + private int acPower; + private int acTemp; + private int acMode; + private int acWindDir; + private int acWindSpeed; + private int acDisplay; + private int acSleep; + private int acTimer; + + public ACStatus() { + } + + public ACStatus(int acPower, int acMode, int acTemp, int acWindSpeed, int acWindDir, + int acDisplay, int acSleep, int acTimer) { + this.acPower = acPower; + this.acTemp = acTemp; + this.acMode = acMode; + this.acWindDir = acWindDir; + this.acWindSpeed = acWindSpeed; + this.acDisplay = acDisplay; + this.acSleep = acSleep; + this.acTimer = acTimer; + } + + public int getAcPower() { + return acPower; + } + + public void setAcPower(int acPower) { + this.acPower = acPower; + } + + public int getAcTemp() { + return acTemp; + } + + public void setAcTemp(int acTemp) { + this.acTemp = acTemp; + } + + public int getAcMode() { + return acMode; + } + + public void setAcMode(int acMode) { + this.acMode = acMode; + } + + public int getAcWindDir() { + return acWindDir; + } + + public void setAcWindDir(int acWindDir) { + this.acWindDir = acWindDir; + } + + public int getAcWindSpeed() { + return acWindSpeed; + } + + public void setAcWindSpeed(int acWindSpeed) { + this.acWindSpeed = acWindSpeed; + } + + public int getAcDisplay() { + return acDisplay; + } + + public void setAcDisplay(int acDisplay) { + this.acDisplay = acDisplay; + } + + public int getAcSleep() { + return acSleep; + } + + public void setAcSleep(int acSleep) { + this.acSleep = acSleep; + } + + public int getAcTimer() { + return acTimer; + } + + public void setAcTimer(int acTimer) { + this.acTimer = acTimer; + } +} diff --git a/web/src/net/irext/webapi/bean/TemperatureRange.java b/web/src/net/irext/webapi/bean/TemperatureRange.java new file mode 100644 index 0000000..5e5106d --- /dev/null +++ b/web/src/net/irext/webapi/bean/TemperatureRange.java @@ -0,0 +1,43 @@ +package net.irext.webapi.bean; + +/** + * Filename: TemperatureRange.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Temperature range for air-conditioner + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class TemperatureRange { + + private static final String TAG = TemperatureRange.class.getSimpleName(); + + private int tempMin; + private int tempMax; + + public TemperatureRange() { + } + + public TemperatureRange(int tempMin, int tempMax) { + this.tempMin = tempMin; + this.tempMax = tempMax; + } + + public int getTempMin() { + return tempMin; + } + + public void setTempMin(int tempMin) { + this.tempMin = tempMin; + } + + public int getTempMax() { + return tempMax; + } + + public void setTempMax(int tempMax) { + this.tempMax = tempMax; + } +} diff --git a/src/net/irext/webapi/model/Admin.java b/web/src/net/irext/webapi/model/Admin.java similarity index 100% rename from src/net/irext/webapi/model/Admin.java rename to web/src/net/irext/webapi/model/Admin.java diff --git a/web/src/net/irext/webapi/model/Brand.java b/web/src/net/irext/webapi/model/Brand.java new file mode 100644 index 0000000..d7fa2be --- /dev/null +++ b/web/src/net/irext/webapi/model/Brand.java @@ -0,0 +1,124 @@ +package net.irext.webapi.model; + +/** + * Filename: Brand.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Brand bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class Brand { + + private int id; + private String name; + private int categoryId; + private String categoryName; + private int status; + private String updateTime; + private int priority; + private String nameEn; + private String nameTw; + private String contributor; + + public Brand(int id, String name, int categoryId, String categoryName, int status, + String updateTime, int priority, + String nameEn, String nameTw, String contributor) { + this.id = id; + this.name = name; + this.categoryId = categoryId; + this.categoryName = categoryName; + this.status = status; + this.updateTime = updateTime; + this.priority = priority; + this.nameEn = nameEn; + this.nameTw = nameTw; + this.contributor = contributor; + } + + public Brand() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } +} diff --git a/web/src/net/irext/webapi/model/Category.java b/web/src/net/irext/webapi/model/Category.java new file mode 100644 index 0000000..9e36e8a --- /dev/null +++ b/web/src/net/irext/webapi/model/Category.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: Category.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: Category bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class Category { + + private int id; + private String name; + private int status; + private String updateTime; + private String nameEn; + private String nameTw; + private String contributor; + + public Category(int id, String name, int status, String updateTime, + String nameEn, String nameTw, String contributor) { + this.id = id; + this.name = name; + this.status = status; + this.updateTime = updateTime; + this.nameEn = nameEn; + this.nameTw = nameTw; + this.contributor = contributor; + } + + public Category() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getNameEn() { + return nameEn; + } + + public void setNameEn(String nameEn) { + this.nameEn = nameEn; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } +} diff --git a/web/src/net/irext/webapi/model/City.java b/web/src/net/irext/webapi/model/City.java new file mode 100644 index 0000000..6105c34 --- /dev/null +++ b/web/src/net/irext/webapi/model/City.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: City.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: City bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class City { + + private int id; + private String code; + private String name; + private double longitude; + private double latitude; + private int status; + private String nameTw; + + public City(int id, String code, String name, double longitude, double latitude, + int status, String nameTw) { + this.id = id; + this.code = code; + this.name = name; + this.longitude = longitude; + this.latitude = latitude; + this.status = status; + this.nameTw = nameTw; + } + + public City() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getNameTw() { + return nameTw; + } + + public void setNameTw(String nameTw) { + this.nameTw = nameTw; + } +} diff --git a/web/src/net/irext/webapi/model/RemoteIndex.java b/web/src/net/irext/webapi/model/RemoteIndex.java new file mode 100644 index 0000000..57e7314 --- /dev/null +++ b/web/src/net/irext/webapi/model/RemoteIndex.java @@ -0,0 +1,259 @@ +package net.irext.webapi.model; + +/** + * Filename: RemoteIndex.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: RemoteIndex bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class RemoteIndex { + + private int id; + private int categoryId; + private String categoryName; + private int brandId; + private String brandName; + private String cityCode; + private String cityName; + private String operatorId; + private String operatorName; + private String protocol; + private String remote; + private String remoteMap; + private int status; + private int subCate; + private int priority; + private String remoteNumber; + private String categoryNameTw; + private String brandNameTw; + private String cityNameTw; + private String operatorNameTw; + private String binaryMd5; + private String contributor; + private String updateTime; + + public RemoteIndex(int id, + int categoryId, String categoryName, int brandId, String brandName, + String cityCode, String cityName, String operatorId, String operatorName, + String protocol, String remote, String remoteMap, int status, int subCate, + int priority, String remoteNumber, + String categoryNameTw, String brandNameTw, + String cityNameTw, String operatorNameTw, + String binaryMd5, String contributor, String updateTime) { + 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.categoryNameTw = categoryNameTw; + this.brandNameTw = brandNameTw; + this.cityNameTw = cityNameTw; + this.operatorNameTw = operatorNameTw; + this.binaryMd5 = binaryMd5; + this.contributor = contributor; + this.updateTime = updateTime; + } + + public RemoteIndex() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public int getBrandId() { + return brandId; + } + + public void setBrandId(int 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 String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + 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; + } + + public String getRemoteMap() { + return remoteMap; + } + + public void setRemoteMap(String remoteMap) { + this.remoteMap = remoteMap; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public int getSubCate() { + return subCate; + } + + public void setSubCate(int subCate) { + this.subCate = subCate; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + public String getRemoteNumber() { + return remoteNumber; + } + + public void setRemoteNumber(String remoteNumber) { + this.remoteNumber = remoteNumber; + } + + public String getCategoryNameTw() { + return categoryNameTw; + } + + public void setCategoryNameTw(String categoryNameTw) { + this.categoryNameTw = categoryNameTw; + } + + public String getBrandNameTw() { + return brandNameTw; + } + + public void setBrandNameTw(String brandNameTw) { + this.brandNameTw = brandNameTw; + } + + public String getCityNameTw() { + return cityNameTw; + } + + public void setCityNameTw(String cityNameTw) { + this.cityNameTw = cityNameTw; + } + + public String getOperatorNameTw() { + return operatorNameTw; + } + + public void setOperatorNameTw(String operatorNameTw) { + this.operatorNameTw = operatorNameTw; + } + + public String getBinaryMd5() { + return binaryMd5; + } + + public void setBinaryMd5(String binaryMd5) { + this.binaryMd5 = binaryMd5; + } + + public String getContributor() { + return contributor; + } + + public void setContributor(String contributor) { + this.contributor = contributor; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } +} diff --git a/web/src/net/irext/webapi/model/StbOperator.java b/web/src/net/irext/webapi/model/StbOperator.java new file mode 100644 index 0000000..167d938 --- /dev/null +++ b/web/src/net/irext/webapi/model/StbOperator.java @@ -0,0 +1,93 @@ +package net.irext.webapi.model; + +/** + * Filename: StbOperator.java + * Revised: Date: 2017-03-28 + * Revision: Revision: 1.0 + *

+ * Description: StbOperator bean + *

+ * Revision log: + * 2017-03-28: created by strawmanbobi + */ +public class StbOperator { + + private int id; + private String operatorId; + private String operatorName; + private String cityCode; + private String cityName; + private int status; + private String operatorNameTw; + + public StbOperator(int id, String operatorId, String operatorName, + String cityCode, String cityName, int status, String operatorNameTw) { + this.id = id; + this.operatorId = operatorId; + this.operatorName = operatorName; + this.cityCode = cityCode; + this.cityName = cityName; + this.status = status; + this.operatorNameTw = operatorNameTw; + } + + public StbOperator() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + 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 int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getOperatorNameTw() { + return operatorNameTw; + } + + public void setOperatorNameTw(String operatorNameTw) { + this.operatorNameTw = operatorNameTw; + } +} diff --git a/web/src/net/irext/webapi/request/AppSignInRequest.java b/web/src/net/irext/webapi/request/AppSignInRequest.java new file mode 100644 index 0000000..7cb3bc8 --- /dev/null +++ b/web/src/net/irext/webapi/request/AppSignInRequest.java @@ -0,0 +1,83 @@ +package net.irext.webapi.request; + +/** + * Filename: AppSignInRequest.java + * Revised: Date: 2017-05-27 + * Revision: Revision: 1.0 + *

+ * Description: HTTP admin login request + *

+ * Revision log: + * 2017-05-27: created by strawmanbobi + */ +public class AppSignInRequest extends BaseRequest { + + private String appKey; + private String appSecret; + private int appType; + private String iOSID; + private String androidPackageName; + private String androidSignature; + + public AppSignInRequest(String appKey, String appSecret, int appType, + String iOSID, String androidPackageName, String androidSignature) { + this.appKey = appKey; + this.appSecret = appSecret; + this.appType = appType; + this.iOSID = iOSID; + this.androidPackageName = androidPackageName; + this.androidSignature = androidSignature; + } + + public AppSignInRequest() { + + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getAppSecret() { + return appSecret; + } + + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + public int getAppType() { + return appType; + } + + public void setAppType(int appType) { + this.appType = appType; + } + + public String getiOSID() { + return iOSID; + } + + public void setiOSID(String iOSID) { + this.iOSID = iOSID; + } + + public String getAndroidPackageName() { + return androidPackageName; + } + + public void setAndroidPackageName(String androidPackageName) { + this.androidPackageName = androidPackageName; + } + + public String getAndroidSignature() { + return androidSignature; + } + + public void setAndroidSignature(String androidSignature) { + this.androidSignature = androidSignature; + } +} diff --git a/web/src/net/irext/webapi/request/BaseRequest.java b/web/src/net/irext/webapi/request/BaseRequest.java new file mode 100644 index 0000000..93777aa --- /dev/null +++ b/web/src/net/irext/webapi/request/BaseRequest.java @@ -0,0 +1,48 @@ +package net.irext.webapi.request; + +import com.google.gson.Gson; + +/** + * Filename: BaseRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: authentication factors included + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class BaseRequest { + + private int adminId; + private String token; + + public BaseRequest(int adminId, String token) { + this.adminId = adminId; + this.token = token; + } + + BaseRequest() { + + } + + public int getAdminId() { + return adminId; + } + + public void setAdminId(int adminId) { + this.adminId = adminId; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String toJson() { + return new Gson().toJson(this, this.getClass()); + } +} diff --git a/web/src/net/irext/webapi/request/DecodeRequest.java b/web/src/net/irext/webapi/request/DecodeRequest.java new file mode 100644 index 0000000..93b977e --- /dev/null +++ b/web/src/net/irext/webapi/request/DecodeRequest.java @@ -0,0 +1,64 @@ +package net.irext.webapi.request; + +import net.irext.webapi.bean.ACStatus; + +/** + * Filename: DecodeRequest.java + * Revised: Date: 2017-05-16 + * Revision: Revision: 1.0 + *

+ * Description: HTTP decode online + *

+ * Revision log: + * 2017-05-16: created by strawmanbobi + */ +public class DecodeRequest extends BaseRequest { + + private int indexId; + private ACStatus acStatus; + private int keyCode; + private int changeWindDir; + + public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir) { + this.indexId = indexId; + this.acStatus = acStatus; + this.keyCode = keyCode; + this.changeWindDir = changeWindDir; + } + + public DecodeRequest() { + + } + + public int getIndexId() { + return indexId; + } + + public void setIndexId(int indexId) { + this.indexId = indexId; + } + + public ACStatus getAcStatus() { + return acStatus; + } + + public void setAcStatus(ACStatus acStatus) { + this.acStatus = acStatus; + } + + public int getKeyCode() { + return keyCode; + } + + public void setKeyCode(int keyCode) { + this.keyCode = keyCode; + } + + public int getChangeWindDir() { + return changeWindDir; + } + + public void setChangeWindDir(int changeWindDir) { + this.changeWindDir = changeWindDir; + } +} diff --git a/web/src/net/irext/webapi/request/DownloadBinaryRequest.java b/web/src/net/irext/webapi/request/DownloadBinaryRequest.java new file mode 100644 index 0000000..ee995b4 --- /dev/null +++ b/web/src/net/irext/webapi/request/DownloadBinaryRequest.java @@ -0,0 +1,32 @@ +package net.irext.webapi.request; + +/** + * Filename: DownloadBinaryRequest.java + * Revised: Date: 2017-04-14 + * Revision: Revision: 1.0 + *

+ * Description: HTTP download IR binary + *

+ * Revision log: + * 2017-04-14: created by strawmanbobi + */ +public class DownloadBinaryRequest extends BaseRequest { + + private int indexId; + + public DownloadBinaryRequest(int indexId) { + this.indexId = indexId; + } + + public DownloadBinaryRequest() { + + } + + public int getIndexId() { + return indexId; + } + + public void setIndexId(int indexId) { + this.indexId = indexId; + } +} diff --git a/web/src/net/irext/webapi/request/ListBrandsRequest.java b/web/src/net/irext/webapi/request/ListBrandsRequest.java new file mode 100644 index 0000000..6dcd236 --- /dev/null +++ b/web/src/net/irext/webapi/request/ListBrandsRequest.java @@ -0,0 +1,52 @@ +package net.irext.webapi.request; + +/** + * Filename: ListBrandsRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list brands request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListBrandsRequest extends BaseRequest { + + private int categoryId; + private int from; + private int count; + + public ListBrandsRequest(int categoryId, int from, int count) { + this.categoryId = categoryId; + this.from = from; + this.count = count; + } + + public ListBrandsRequest() { + + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/web/src/net/irext/webapi/request/ListCategoriesRequest.java b/web/src/net/irext/webapi/request/ListCategoriesRequest.java new file mode 100644 index 0000000..48760f3 --- /dev/null +++ b/web/src/net/irext/webapi/request/ListCategoriesRequest.java @@ -0,0 +1,42 @@ +package net.irext.webapi.request; + +/** + * Filename: ListCategoriesRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list categories request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListCategoriesRequest extends BaseRequest { + + private int from; + private int count; + + public ListCategoriesRequest(int from, int count) { + this.from = from; + this.count = count; + } + + public ListCategoriesRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/web/src/net/irext/webapi/request/ListCitiesRequest.java b/web/src/net/irext/webapi/request/ListCitiesRequest.java new file mode 100644 index 0000000..6bd0cd9 --- /dev/null +++ b/web/src/net/irext/webapi/request/ListCitiesRequest.java @@ -0,0 +1,32 @@ +package net.irext.webapi.request; + +/** + * Filename: ListCitiesRequest.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list cities request + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class ListCitiesRequest extends BaseRequest { + + private String provincePrefix; + + public ListCitiesRequest(String provincePrefix) { + this.provincePrefix = provincePrefix; + } + + public ListCitiesRequest() { + + } + + public String getProvincePrefix() { + return provincePrefix; + } + + public void setProvincePrefix(String provincePrefix) { + this.provincePrefix = provincePrefix; + } +} diff --git a/web/src/net/irext/webapi/request/ListIndexesRequest.java b/web/src/net/irext/webapi/request/ListIndexesRequest.java new file mode 100644 index 0000000..8ece383 --- /dev/null +++ b/web/src/net/irext/webapi/request/ListIndexesRequest.java @@ -0,0 +1,83 @@ +package net.irext.webapi.request; + +/** + * Filename: ListIndexesRequest.java + * Revised: Date: 2017-04-12 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list remote indexes request + *

+ * Revision log: + * 2017-04-12: created by strawmanbobi + */ +public class ListIndexesRequest extends BaseRequest { + + private int from; + private int count; + private int categoryId; + private int brandId; + private String cityCode; + private String operatorId; + + public ListIndexesRequest(int from, int count, int categoryId, int brandId, + String cityCode, String operatorId) { + this.from = from; + this.count = count; + this.categoryId = categoryId; + this.brandId = brandId; + this.cityCode = cityCode; + this.operatorId = operatorId; + } + + public ListIndexesRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public int getBrandId() { + return brandId; + } + + public void setBrandId(int brandId) { + this.brandId = brandId; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } +} diff --git a/web/src/net/irext/webapi/request/ListOperatorsRequest.java b/web/src/net/irext/webapi/request/ListOperatorsRequest.java new file mode 100644 index 0000000..264be93 --- /dev/null +++ b/web/src/net/irext/webapi/request/ListOperatorsRequest.java @@ -0,0 +1,52 @@ +package net.irext.webapi.request; + +/** + * Filename: ListOperatorsRequest.java + * Revised: Date: 2017-04-10 + * Revision: Revision: 1.0 + *

+ * Description: HTTP list STB operators request + *

+ * Revision log: + * 2017-04-10: created by strawmanbobi + */ +public class ListOperatorsRequest extends BaseRequest { + + private int from; + private int count; + private String cityCode; + + public ListOperatorsRequest(int from, int count, String cityCode) { + this.from = from; + this.count = count; + this.cityCode = cityCode; + } + + public ListOperatorsRequest() { + + } + + public int getFrom() { + return from; + } + + public void setFrom(int from) { + this.from = from; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } +} diff --git a/web/src/net/irext/webapi/response/BrandsResponse.java b/web/src/net/irext/webapi/response/BrandsResponse.java new file mode 100644 index 0000000..327227f --- /dev/null +++ b/web/src/net/irext/webapi/response/BrandsResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.Brand; + +import java.util.List; + +/** + * Filename: BrandsResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List brands response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class BrandsResponse extends ServiceResponse { + + private List entity; + + public BrandsResponse(Status status, List brands) { + super(status); + this.entity = brands; + } + + public BrandsResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/web/src/net/irext/webapi/response/CategoriesResponse.java b/web/src/net/irext/webapi/response/CategoriesResponse.java new file mode 100644 index 0000000..409f582 --- /dev/null +++ b/web/src/net/irext/webapi/response/CategoriesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.Category; + +import java.util.List; + +/** + * Filename: CategoriesResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List categories response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class CategoriesResponse extends ServiceResponse { + + private List entity; + + public CategoriesResponse(Status status, List categories) { + super(status); + this.entity = categories; + } + + public CategoriesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/web/src/net/irext/webapi/response/CitiesResponse.java b/web/src/net/irext/webapi/response/CitiesResponse.java new file mode 100644 index 0000000..a97a868 --- /dev/null +++ b/web/src/net/irext/webapi/response/CitiesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.City; + +import java.util.List; + +/** + * Filename: CitiesResponse.java + * Revised: Date: 2017-04-07 + * Revision: Revision: 1.0 + *

+ * Description: List cities response + *

+ * Revision log: + * 2017-04-07: created by strawmanbobi + */ +public class CitiesResponse extends ServiceResponse { + + private List entity; + + public CitiesResponse(Status status, List cities) { + super(status); + this.entity = cities; + } + + public CitiesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/web/src/net/irext/webapi/response/DecodeResponse.java b/web/src/net/irext/webapi/response/DecodeResponse.java new file mode 100644 index 0000000..c221f4e --- /dev/null +++ b/web/src/net/irext/webapi/response/DecodeResponse.java @@ -0,0 +1,33 @@ +package net.irext.webapi.response; + +/** + * Filename: DecodeResponse.java + * Revised: Date: 2017-05-16 + * Revision: Revision: 1.0 + *

+ * Description: Online decode response + *

+ * Revision log: + * 2017-05-16: created by strawmanbobi + */ +public class DecodeResponse extends ServiceResponse { + + private int[] entity; + + public DecodeResponse(Status status, int[] entity) { + super(status); + this.entity = entity; + } + + public DecodeResponse() { + + } + + public int[] getEntity() { + return entity; + } + + public void setEntity(int[] entity) { + this.entity = entity; + } +} diff --git a/web/src/net/irext/webapi/response/IndexesResponse.java b/web/src/net/irext/webapi/response/IndexesResponse.java new file mode 100644 index 0000000..7b666a5 --- /dev/null +++ b/web/src/net/irext/webapi/response/IndexesResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.RemoteIndex; + +import java.util.List; + +/** + * Filename: IndexesResponse.java + * Revised: Date: 2017-04-12 + * Revision: Revision: 1.0 + *

+ * Description: List remote indexes response + *

+ * Revision log: + * 2017-04-12: created by strawmanbobi + */ +public class IndexesResponse extends ServiceResponse { + + private List entity; + + public IndexesResponse(Status status, List indexes) { + super(status); + this.entity = indexes; + } + + public IndexesResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/src/net/irext/webapi/response/LoginResponse.java b/web/src/net/irext/webapi/response/LoginResponse.java similarity index 100% rename from src/net/irext/webapi/response/LoginResponse.java rename to web/src/net/irext/webapi/response/LoginResponse.java diff --git a/web/src/net/irext/webapi/response/OperatorsResponse.java b/web/src/net/irext/webapi/response/OperatorsResponse.java new file mode 100644 index 0000000..4856989 --- /dev/null +++ b/web/src/net/irext/webapi/response/OperatorsResponse.java @@ -0,0 +1,37 @@ +package net.irext.webapi.response; + +import net.irext.webapi.model.StbOperator; + +import java.util.List; + +/** + * Filename: OperatorsResponse.java + * Revised: Date: 2017-04-10 + * Revision: Revision: 1.0 + *

+ * Description: List STB operators response + *

+ * Revision log: + * 2017-04-10: created by strawmanbobi + */ +public class OperatorsResponse extends ServiceResponse { + + private List entity; + + public OperatorsResponse(Status status, List cities) { + super(status); + this.entity = cities; + } + + public OperatorsResponse() { + + } + + public List getEntity() { + return entity; + } + + public void setEntity(List entity) { + this.entity = entity; + } +} diff --git a/web/src/net/irext/webapi/response/ServiceResponse.java b/web/src/net/irext/webapi/response/ServiceResponse.java new file mode 100644 index 0000000..8f8852f --- /dev/null +++ b/web/src/net/irext/webapi/response/ServiceResponse.java @@ -0,0 +1,32 @@ +package net.irext.webapi.response; + +/** + * Filename: ServiceResponse.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP Response base class + *

+ * Revision log: + * 2017-03-31: 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/web/src/net/irext/webapi/response/Status.java b/web/src/net/irext/webapi/response/Status.java new file mode 100644 index 0000000..7c354d4 --- /dev/null +++ b/web/src/net/irext/webapi/response/Status.java @@ -0,0 +1,42 @@ +package net.irext.webapi.response; + +/** + * Filename: Status.java + * Revised: Date: 2017-03-31 + * Revision: Revision: 1.0 + *

+ * Description: HTTP response status + *

+ * Revision log: + * 2017-03-31: 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() { + + } + + 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/web/src/net/irext/webapi/utils/Constants.java b/web/src/net/irext/webapi/utils/Constants.java new file mode 100644 index 0000000..fa00765 --- /dev/null +++ b/web/src/net/irext/webapi/utils/Constants.java @@ -0,0 +1,175 @@ +package net.irext.webapi.utils; + +/** + * Filename: Constants.java + * Revised: Date: 2017-04-03 + * Revision: Revision: 1.0 + *

+ * Description: SDK Constants + *

+ * Revision log: + * 2017-04-03: 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 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); + + 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/web/src/net/irext/webapi/utils/MD5Digest.java b/web/src/net/irext/webapi/utils/MD5Digest.java new file mode 100644 index 0000000..1c48710 --- /dev/null +++ b/web/src/net/irext/webapi/utils/MD5Digest.java @@ -0,0 +1,40 @@ +package net.irext.webapi.utils; + +import java.security.MessageDigest; + +/** + * Filename: MD5Digest.java + * Revised: Date: 2017-04-03 + * Revision: Revision: 1.0 + *

+ * Description: MD5 digest algorithm + *

+ * Revision log: + * 2017-04-03: created by strawmanbobi + */ +public class MD5Digest { + + public static String MD5(String content) { + String result = null; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(content.getBytes()); + byte b[] = md.digest(); + + int i; + + StringBuffer buf = new StringBuffer(""); + for (int offset = 0; offset < b.length; offset++) { + i = b[offset]; + if (i < 0) i += 256; + if (i < 16) buf.append("0"); + buf.append(Integer.toHexString(i)); + } + result = buf.toString(); + } catch (Exception e) { + e.printStackTrace(); + return content; + } + return result; + } +}