diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
index 4784d72..2730058 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
@@ -1,16 +1,20 @@
package com.casic.app.smartwell.sanxi.view
+import android.annotation.SuppressLint
import android.os.CountDownTimer
+import androidx.lifecycle.ViewModelProvider
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseActivity
import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : BaseActivity() {
private val kTag = "SplashScreenActivity"
-// private lateinit var userDetailViewModel: UserDetailViewModel
-// private lateinit var authenticateViewModel: AuthenticateViewModel
-// private val imageModels: MutableList = ArrayList()
+ private lateinit var userViewModel: UserViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
override fun initLayoutView(): Int = R.layout.activity_splash
@@ -19,28 +23,11 @@
}
override fun initData() {
-// userDetailViewModel = ViewModelProvider(this).get(UserDetailViewModel::class.java)
-// authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
}
override fun initEvent() {
-// Constant.NEWS_PAGE.forEach {
-// WebCrawler.Builder()
-// .addLifecycleCoroutineScope(lifecycleScope)
-// .ignoreHttpErrors(true)
-// .setTimeout(15000)
-// .setTargetWebSite(it)
-// .addOnWebCrawlerCallback(object : WebCrawler.OnWebCrawlerCallback {
-// override fun onParseSuccess(model: BannerImageModel) {
-// imageModels.add(model)
-// SaveKeyValues.putValue(Constant.BANNER_MODEL, imageModels.toJson())
-// }
-//
-// override fun onParseFailure(e: Exception) {
-// Log.e(kTag, "onParseFailure: $e", e)
-// }
-// }).build().start()
-// }
countDownTimer.start()
}
@@ -49,19 +36,19 @@
/**
* 获取token之后保存用户信息
* */
-// userDetailViewModel.obtainUserDetail()
- /**
- * 根据用户有权查看的设备类型
- */
-// authenticateViewModel.obtainAuthorByDept()
-// userDetailViewModel.flag.observe(this@SplashScreenActivity, {
-// if (it) {
- navigatePageTo()
-// } else {
-// navigatePageTo(LoginActivity::class.java)
-// }
- finish()
-// })
+ userViewModel.obtainUserDetail()
+ userViewModel.userDetailModel.observe(this@SplashScreenActivity, {
+ if (it.code == 200) {
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ navigatePageTo()
+ } else {
+ navigatePageTo()
+ }
+ finish()
+ })
}
override fun onTick(millisUntilFinished: Long) {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
index 4784d72..2730058 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
@@ -1,16 +1,20 @@
package com.casic.app.smartwell.sanxi.view
+import android.annotation.SuppressLint
import android.os.CountDownTimer
+import androidx.lifecycle.ViewModelProvider
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseActivity
import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : BaseActivity() {
private val kTag = "SplashScreenActivity"
-// private lateinit var userDetailViewModel: UserDetailViewModel
-// private lateinit var authenticateViewModel: AuthenticateViewModel
-// private val imageModels: MutableList = ArrayList()
+ private lateinit var userViewModel: UserViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
override fun initLayoutView(): Int = R.layout.activity_splash
@@ -19,28 +23,11 @@
}
override fun initData() {
-// userDetailViewModel = ViewModelProvider(this).get(UserDetailViewModel::class.java)
-// authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
}
override fun initEvent() {
-// Constant.NEWS_PAGE.forEach {
-// WebCrawler.Builder()
-// .addLifecycleCoroutineScope(lifecycleScope)
-// .ignoreHttpErrors(true)
-// .setTimeout(15000)
-// .setTargetWebSite(it)
-// .addOnWebCrawlerCallback(object : WebCrawler.OnWebCrawlerCallback {
-// override fun onParseSuccess(model: BannerImageModel) {
-// imageModels.add(model)
-// SaveKeyValues.putValue(Constant.BANNER_MODEL, imageModels.toJson())
-// }
-//
-// override fun onParseFailure(e: Exception) {
-// Log.e(kTag, "onParseFailure: $e", e)
-// }
-// }).build().start()
-// }
countDownTimer.start()
}
@@ -49,19 +36,19 @@
/**
* 获取token之后保存用户信息
* */
-// userDetailViewModel.obtainUserDetail()
- /**
- * 根据用户有权查看的设备类型
- */
-// authenticateViewModel.obtainAuthorByDept()
-// userDetailViewModel.flag.observe(this@SplashScreenActivity, {
-// if (it) {
- navigatePageTo()
-// } else {
-// navigatePageTo(LoginActivity::class.java)
-// }
- finish()
-// })
+ userViewModel.obtainUserDetail()
+ userViewModel.userDetailModel.observe(this@SplashScreenActivity, {
+ if (it.code == 200) {
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ navigatePageTo()
+ } else {
+ navigatePageTo()
+ }
+ finish()
+ })
}
override fun onTick(millisUntilFinished: Long) {
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
new file mode 100644
index 0000000..d351713
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.*
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import org.json.JSONObject
+
+class AuthenticateViewModel : BaseViewModel() {
+
+ val keyModel = MutableLiveData()
+
+ fun obtainPublicKey() = launch({
+ loadState.value = LoadState.Loading
+ keyModel.value = RetrofitServiceManager.authenticate()
+ }, {
+ it.printStackTrace()
+ })
+
+ fun obtainAuthorByDept() = launch({
+ val response = RetrofitServiceManager.obtainAuthorByDept()
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ val jsonObject = JSONObject(response)
+ val data = jsonObject.getJSONObject("data")
+
+ val typeArray = data.getJSONArray("deviceTypes")
+ val types: MutableList = ArrayList()
+ for (i in 0 until typeArray.length()) {
+ types.add(typeArray.getString(i))
+ }
+ SaveKeyValues.putValue(Constant.USER_DEVICE_TYPE, types.toJson())
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
index 4784d72..2730058 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
@@ -1,16 +1,20 @@
package com.casic.app.smartwell.sanxi.view
+import android.annotation.SuppressLint
import android.os.CountDownTimer
+import androidx.lifecycle.ViewModelProvider
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseActivity
import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : BaseActivity() {
private val kTag = "SplashScreenActivity"
-// private lateinit var userDetailViewModel: UserDetailViewModel
-// private lateinit var authenticateViewModel: AuthenticateViewModel
-// private val imageModels: MutableList = ArrayList()
+ private lateinit var userViewModel: UserViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
override fun initLayoutView(): Int = R.layout.activity_splash
@@ -19,28 +23,11 @@
}
override fun initData() {
-// userDetailViewModel = ViewModelProvider(this).get(UserDetailViewModel::class.java)
-// authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
}
override fun initEvent() {
-// Constant.NEWS_PAGE.forEach {
-// WebCrawler.Builder()
-// .addLifecycleCoroutineScope(lifecycleScope)
-// .ignoreHttpErrors(true)
-// .setTimeout(15000)
-// .setTargetWebSite(it)
-// .addOnWebCrawlerCallback(object : WebCrawler.OnWebCrawlerCallback {
-// override fun onParseSuccess(model: BannerImageModel) {
-// imageModels.add(model)
-// SaveKeyValues.putValue(Constant.BANNER_MODEL, imageModels.toJson())
-// }
-//
-// override fun onParseFailure(e: Exception) {
-// Log.e(kTag, "onParseFailure: $e", e)
-// }
-// }).build().start()
-// }
countDownTimer.start()
}
@@ -49,19 +36,19 @@
/**
* 获取token之后保存用户信息
* */
-// userDetailViewModel.obtainUserDetail()
- /**
- * 根据用户有权查看的设备类型
- */
-// authenticateViewModel.obtainAuthorByDept()
-// userDetailViewModel.flag.observe(this@SplashScreenActivity, {
-// if (it) {
- navigatePageTo()
-// } else {
-// navigatePageTo(LoginActivity::class.java)
-// }
- finish()
-// })
+ userViewModel.obtainUserDetail()
+ userViewModel.userDetailModel.observe(this@SplashScreenActivity, {
+ if (it.code == 200) {
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ navigatePageTo()
+ } else {
+ navigatePageTo()
+ }
+ finish()
+ })
}
override fun onTick(millisUntilFinished: Long) {
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
new file mode 100644
index 0000000..d351713
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.*
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import org.json.JSONObject
+
+class AuthenticateViewModel : BaseViewModel() {
+
+ val keyModel = MutableLiveData()
+
+ fun obtainPublicKey() = launch({
+ loadState.value = LoadState.Loading
+ keyModel.value = RetrofitServiceManager.authenticate()
+ }, {
+ it.printStackTrace()
+ })
+
+ fun obtainAuthorByDept() = launch({
+ val response = RetrofitServiceManager.obtainAuthorByDept()
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ val jsonObject = JSONObject(response)
+ val data = jsonObject.getJSONObject("data")
+
+ val typeArray = data.getJSONArray("deviceTypes")
+ val types: MutableList = ArrayList()
+ for (i in 0 until typeArray.length()) {
+ types.add(typeArray.getString(i))
+ }
+ SaveKeyValues.putValue(Constant.USER_DEVICE_TYPE, types.toJson())
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
new file mode 100644
index 0000000..32384ad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
@@ -0,0 +1,51 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.launch
+import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
+import com.casic.app.smartwell.sanxi.model.LoginResultModel
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+
+class LoginViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val enterResultModel = MutableLiveData()
+// val outResultModel = MutableLiveData()
+
+ fun enter(sid: String, account: String, secretKey: String) = launch({
+ val response = RetrofitServiceManager.login(sid, account, secretKey)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ enterResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
+
+// fun out() = launch({
+// val response = RetrofitServiceManager.loginOut()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// outResultModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
index 4784d72..2730058 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
@@ -1,16 +1,20 @@
package com.casic.app.smartwell.sanxi.view
+import android.annotation.SuppressLint
import android.os.CountDownTimer
+import androidx.lifecycle.ViewModelProvider
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseActivity
import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : BaseActivity() {
private val kTag = "SplashScreenActivity"
-// private lateinit var userDetailViewModel: UserDetailViewModel
-// private lateinit var authenticateViewModel: AuthenticateViewModel
-// private val imageModels: MutableList = ArrayList()
+ private lateinit var userViewModel: UserViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
override fun initLayoutView(): Int = R.layout.activity_splash
@@ -19,28 +23,11 @@
}
override fun initData() {
-// userDetailViewModel = ViewModelProvider(this).get(UserDetailViewModel::class.java)
-// authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
}
override fun initEvent() {
-// Constant.NEWS_PAGE.forEach {
-// WebCrawler.Builder()
-// .addLifecycleCoroutineScope(lifecycleScope)
-// .ignoreHttpErrors(true)
-// .setTimeout(15000)
-// .setTargetWebSite(it)
-// .addOnWebCrawlerCallback(object : WebCrawler.OnWebCrawlerCallback {
-// override fun onParseSuccess(model: BannerImageModel) {
-// imageModels.add(model)
-// SaveKeyValues.putValue(Constant.BANNER_MODEL, imageModels.toJson())
-// }
-//
-// override fun onParseFailure(e: Exception) {
-// Log.e(kTag, "onParseFailure: $e", e)
-// }
-// }).build().start()
-// }
countDownTimer.start()
}
@@ -49,19 +36,19 @@
/**
* 获取token之后保存用户信息
* */
-// userDetailViewModel.obtainUserDetail()
- /**
- * 根据用户有权查看的设备类型
- */
-// authenticateViewModel.obtainAuthorByDept()
-// userDetailViewModel.flag.observe(this@SplashScreenActivity, {
-// if (it) {
- navigatePageTo()
-// } else {
-// navigatePageTo(LoginActivity::class.java)
-// }
- finish()
-// })
+ userViewModel.obtainUserDetail()
+ userViewModel.userDetailModel.observe(this@SplashScreenActivity, {
+ if (it.code == 200) {
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ navigatePageTo()
+ } else {
+ navigatePageTo()
+ }
+ finish()
+ })
}
override fun onTick(millisUntilFinished: Long) {
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
new file mode 100644
index 0000000..d351713
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.*
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import org.json.JSONObject
+
+class AuthenticateViewModel : BaseViewModel() {
+
+ val keyModel = MutableLiveData()
+
+ fun obtainPublicKey() = launch({
+ loadState.value = LoadState.Loading
+ keyModel.value = RetrofitServiceManager.authenticate()
+ }, {
+ it.printStackTrace()
+ })
+
+ fun obtainAuthorByDept() = launch({
+ val response = RetrofitServiceManager.obtainAuthorByDept()
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ val jsonObject = JSONObject(response)
+ val data = jsonObject.getJSONObject("data")
+
+ val typeArray = data.getJSONArray("deviceTypes")
+ val types: MutableList = ArrayList()
+ for (i in 0 until typeArray.length()) {
+ types.add(typeArray.getString(i))
+ }
+ SaveKeyValues.putValue(Constant.USER_DEVICE_TYPE, types.toJson())
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
new file mode 100644
index 0000000..32384ad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
@@ -0,0 +1,51 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.launch
+import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
+import com.casic.app.smartwell.sanxi.model.LoginResultModel
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+
+class LoginViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val enterResultModel = MutableLiveData()
+// val outResultModel = MutableLiveData()
+
+ fun enter(sid: String, account: String, secretKey: String) = launch({
+ val response = RetrofitServiceManager.login(sid, account, secretKey)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ enterResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
+
+// fun out() = launch({
+// val response = RetrofitServiceManager.loginOut()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// outResultModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/UserViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/UserViewModel.kt
new file mode 100644
index 0000000..1e35b0c
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/UserViewModel.kt
@@ -0,0 +1,91 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.launch
+import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
+import com.casic.app.smartwell.sanxi.model.UserDetailModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+
+class UserViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val userDetailModel = MutableLiveData()
+// val subordinateModel = MutableLiveData()
+// val versionResultModel = MutableLiveData()
+
+ fun obtainUserDetail() = launch({
+ val response = RetrofitServiceManager.obtainUserDetail()
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ val userDetail = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ userDetailModel.value = userDetail
+ SaveKeyValues.putValue(Constant.USER_DETAIL_MODEL, gson.toJson(userDetail.data))
+ } else {
+ val errorModel = UserDetailModel()
+ errorModel.code = responseCode
+ userDetailModel.value = errorModel
+ //如果此次获取不到用户信息,那么就清空之前的用户缓存,然后让用户重新登录
+ SaveKeyValues.removeKey(Constant.USER_DETAIL_MODEL)
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 转单下一级人员
+ * */
+// fun obtainSubordinate(hasMine: String?, roleTips: String?) = launch({
+// val response = RetrofitServiceManager.obtainSubordinate(hasMine, roleTips)
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// subordinateModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+
+// fun changePassword(oldPwd: String, newPwd: String) = launch({
+// loadState.value = LoadState.Loading
+// val response = RetrofitServiceManager.changePassword(oldPwd, newPwd)
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// loadState.value = LoadState.Success
+// "修改成功,请重新登录".show()
+// } else {
+// loadState.value = LoadState.Fail
+// response.toErrorMessage().show()
+// }
+// }, {
+// loadState.value = LoadState.Fail
+// it.printStackTrace()
+// })
+//
+// fun updateVersion() = launch({
+// loadState.value = LoadState.Loading
+// val response = RetrofitServiceManager.updateVersion()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// loadState.value = LoadState.Success
+// versionResultModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// ).data
+// } else {
+// loadState.value = LoadState.Fail
+// response.toErrorMessage().show()
+// }
+// }, {
+// loadState.value = LoadState.Fail
+// it.printStackTrace()
+// })
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 82a0cf2..3cce014 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
index 714b5fb..f062526 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/extensions/String.kt
@@ -4,7 +4,7 @@
import android.view.Gravity
import android.widget.TextView
import android.widget.Toast
-import com.casic.app.smartwell.model.ErrorMessageModel
+import com.casic.app.smartwell.sanxi.model.ErrorMessageModel
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseApplication
import com.casic.app.smartwell.sanxi.utils.Constant
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
new file mode 100644
index 0000000..fe2e9cf
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.java
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.model;
+
+/**
+ * 普通实体类,失败/成功数据结构一致
+ */
+public class CommonResultModel {
+ private int code;
+ private String data;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
deleted file mode 100644
index b6752b7..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/CommonResultModel.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.casic.app.smartwell.sanxi.model
-
-/**
- * 普通实体类,失败/成功数据结构一致
- */
-class CommonResultModel {
- var code = 0
- var data: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
new file mode 100644
index 0000000..e1c09f6
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.java
@@ -0,0 +1,49 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class ErrorMessageModel {
+ private int code;
+ private String data;
+ private String exceptionClazz;
+ private String message;
+ private boolean isSuccess;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getExceptionClazz() {
+ return exceptionClazz;
+ }
+
+ public void setExceptionClazz(String exceptionClazz) {
+ this.exceptionClazz = exceptionClazz;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(boolean success) {
+ isSuccess = success;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
deleted file mode 100644
index 0b56128..0000000
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/model/ErrorMessageModel.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.casic.app.smartwell.model
-
-class ErrorMessageModel {
- var code = 0
- var data: String? = null
- var exceptionClazz: String? = null
- var message: String? = null
- var isSuccess = false
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
new file mode 100644
index 0000000..5fe17df
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/LoginResultModel.java
@@ -0,0 +1,62 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class LoginResultModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String kaptcha;
+ private String token;
+
+ public String getKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(String kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
new file mode 100644
index 0000000..1a43cc1
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/PublicKeyModel.java
@@ -0,0 +1,80 @@
+package com.casic.app.smartwell.sanxi.model;
+
+public class PublicKeyModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private boolean appKaptcha;
+ private boolean kaptcha;
+ private String publicKey;
+ private String sid;
+
+ public boolean isAppKaptcha() {
+ return appKaptcha;
+ }
+
+ public void setAppKaptcha(boolean appKaptcha) {
+ this.appKaptcha = appKaptcha;
+ }
+
+ public boolean isKaptcha() {
+ return kaptcha;
+ }
+
+ public void setKaptcha(boolean kaptcha) {
+ this.kaptcha = kaptcha;
+ }
+
+ public String getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
new file mode 100644
index 0000000..264446d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/model/UserDetailModel.java
@@ -0,0 +1,227 @@
+package com.casic.app.smartwell.sanxi.model;
+
+
+import java.util.List;
+
+public class UserDetailModel {
+ private int code;
+ private Data data;
+ private String message;
+ private boolean success;
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public static class Data {
+
+ private String account;
+ private String attr1;
+ private String avatar;
+ private String bizData;
+ private List dataScope;
+ private String deptId;
+ private String deptName;
+ private List devices;
+ private String id;
+ private String ipAddr;
+ private String name;
+ private String phone;
+ private List roleList;
+ private List roleNames;
+ private List roleTips;
+ private String scopeType;
+ private String sysData;
+ private String targetId;
+ private String targetName;
+ private String tenantId;
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAvatar(String avatar) {
+ this.avatar = avatar;
+ }
+
+ public String getAvatar() {
+ return avatar;
+ }
+
+ public void setBizData(String bizData) {
+ this.bizData = bizData;
+ }
+
+ public String getBizData() {
+ return bizData;
+ }
+
+ public void setDataScope(List dataScope) {
+ this.dataScope = dataScope;
+ }
+
+ public List getDataScope() {
+ return dataScope;
+ }
+
+ public void setDeptId(String deptId) {
+ this.deptId = deptId;
+ }
+
+ public String getDeptId() {
+ return deptId;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDevices(List devices) {
+ this.devices = devices;
+ }
+
+ public List getDevices() {
+ return devices;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setRoleList(List roleList) {
+ this.roleList = roleList;
+ }
+
+ public List getRoleList() {
+ return roleList;
+ }
+
+ public void setRoleNames(List roleNames) {
+ this.roleNames = roleNames;
+ }
+
+ public List getRoleNames() {
+ return roleNames;
+ }
+
+ public void setRoleTips(List roleTips) {
+ this.roleTips = roleTips;
+ }
+
+ public List getRoleTips() {
+ return roleTips;
+ }
+
+ public void setScopeType(String scopeType) {
+ this.scopeType = scopeType;
+ }
+
+ public String getScopeType() {
+ return scopeType;
+ }
+
+ public void setSysData(String sysData) {
+ this.sysData = sysData;
+ }
+
+ public String getSysData() {
+ return sysData;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+ public String getTargetName() {
+ return targetName;
+ }
+
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
new file mode 100644
index 0000000..f9449b2
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/AuthenticationHelper.kt
@@ -0,0 +1,22 @@
+package com.casic.app.smartwell.sanxi.utils
+
+object AuthenticationHelper {
+
+ fun savePublicKey(key: String) {
+ SaveKeyValues.putValue("keyString", key)
+ }
+
+ val publicKey: String?
+ get() = SaveKeyValues.getValue("keyString", "") as String?
+
+ fun saveToken(token: String?) {
+ SaveKeyValues.putValue("token", token!!)
+ }
+
+ val token: String?
+ get() = SaveKeyValues.getValue("token", "") as String?
+
+ fun removeToken() {
+ SaveKeyValues.removeKey("token")
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
index 5f617b5..dc0ed84 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/Constant.kt
@@ -15,9 +15,10 @@
const val INTENT_PARAM = "intentParam"
const val DEFAULT_SERVER_CONFIG = "defaultServerConfig"
+ const val USER_DETAIL_MODEL = "userDetailModel"
+ const val USER_DEVICE_TYPE = "userDeviceType"
const val ACCOUNT = "account"
const val PASSWORD = "password"
- const val USER_DETAIL_MODEL = "userDetailModel"
const val APP_AUTHORITY = "com.casic.app.smartwell.fileprovider"
const val PERMISSIONS_CODE = 999
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
new file mode 100644
index 0000000..1938bde
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitFactory.kt
@@ -0,0 +1,48 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import android.util.Log
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
+import org.jetbrains.annotations.NotNull
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
+import java.util.concurrent.TimeUnit
+
+object RetrofitFactory {
+ private const val kTag = "RetrofitFactory"
+
+ val httpClient: OkHttpClient by lazy { createOKHttpClient() }
+
+ inline fun createRetrofit(): T {
+ val defaultValue = SaveKeyValues.getValue(
+ Constant.DEFAULT_SERVER_CONFIG,
+ "http://111.198.10.15:11304"
+ ) as String
+ return Retrofit.Builder()
+ .baseUrl(defaultValue)
+ .addConverterFactory(ScalarsConverterFactory.create()) //字符串转换器
+ .addConverterFactory(GsonConverterFactory.create()) //Gson转换器
+ .addCallAdapterFactory(CoroutineCallAdapterFactory.invoke()) //协程请求适配器
+ .client(httpClient) //log拦截器
+ .build().create(T::class.java)
+ }
+
+ private fun createOKHttpClient(): OkHttpClient { //日志显示级别
+ val interceptor =
+ HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger {
+ override fun log(@NotNull message: String) {
+ Log.d(kTag, ">>>>> $message")
+ }
+ })
+ interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
+ val builder = OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)// 连接时间:30s超时
+ .readTimeout(10, TimeUnit.SECONDS)// 读取时间:10s超时
+ .writeTimeout(10, TimeUnit.SECONDS)// 写入时间:10s超时
+ return builder.addInterceptor(interceptor).build()
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
new file mode 100644
index 0000000..0fb1635
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -0,0 +1,318 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import okhttp3.MultipartBody
+import retrofit2.http.*
+
+
+/**
+ * @JvmSuppressWildcards 用来注解类和方法,使得被标记元素的泛型参数不会被编译成通配符
+ * */
+@JvmSuppressWildcards
+interface RetrofitService {
+ /**
+ * PublicKey校验
+ */
+ @GET("/config/baseConfig")
+ suspend fun obtainPublicKey(): PublicKeyModel
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ @GET("/config/getAuthorByDept")
+ suspend fun obtainAuthorByDept(@Header("token") token: String): String
+
+ /**
+ * 登录并获取Token
+ *
+ * @param account 用户名
+ * @param secretKey 加密后的密码
+ */
+ @FormUrlEncoded
+ @POST("/user/login")
+ suspend fun obtainLoginResult(
+ @Field("sid") sid: String,
+ @Field("username") account: String,
+ @Field("password") secretKey: String
+ ): String
+
+ /**
+ * 根据布防状态统计闸井数量接口
+ */
+ @GET("/well/countByBfzt")
+ suspend fun countWellByState(@Header("token") token: String): String
+
+ /**
+ * 根据工单状态统计工单数量
+ */
+ @GET("/job/countByJobStatus")
+ suspend fun countWorkOrderByState(@Header("token") token: String): String
+
+ /**
+ * 获取闸井类别
+ */
+ @GET("/dict/code/sluicewellType")
+ suspend fun obtainWellType(@Header("token") token: String): String
+
+ /**
+ * 获取获取闸井列表
+ *
+ * @param keywords 关键字
+ * @param wellType 窨井类型
+ * @param deptid 部门ID
+ * @param isAlarm 是否报警
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/well/list")
+ suspend fun obtainWellList(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("wellType") wellType: String?,
+ @Query("deptid") deptid: String?,
+ @Query("isAlarm") isAlarm: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取获取闸井列表-不分页,地图用
+ */
+ @GET("/well/list")
+ suspend fun obtainAllWell(@Header("token") token: String): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 获取井下监控设备列表
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/watchDataByWell")
+ suspend fun obtainMonitorResult(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 闸井布防撤防
+ *
+ * @param wellId 窨井ID
+ * @param bfzt 0:撤防,1:布防
+ */
+ @FormUrlEncoded
+ @POST("/well/bfcf")
+ suspend fun obtainOperationResult(
+ @Header("token") token: String,
+ @Field("wellId") wellId: String,
+ @Field("bfzt") bfzt: String
+ ): String
+
+ /**
+ * 根据工单状态获取工单列表
+ *
+ * @param jobStatus 工单状态
+ * @param limit 每页数据条数
+ * @param offset 页码
+ */
+ @GET("/job/list")
+ suspend fun obtainWorkOrderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取工单详情
+ *
+ * @param id 工单id
+ */
+ @GET("/job/info")
+ suspend fun obtainWorkOrderDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 接单
+ *
+ * @param id 工单id
+ */
+ @FormUrlEncoded
+ @POST("/job/getJob")
+ suspend fun acceptWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String
+ ): String
+
+ /**
+ * 上传图片
+ * 系统路径static拼接图片返回路径
+ * http://xx.com/static/2019-10/8050891248624f2bbefedcb196ce89cb.jpeg
+ */
+ @Multipart
+ @POST("/imageUpload")
+ suspend fun uploadImage(
+ @Header("token") token: String,
+ @Part file: MultipartBody.Part
+ ): String
+
+ /**
+ * 查找同一单位下的用户
+ *
+ * @param hasMine 是否包含本人,1包含, 0不包含
+ * @param roleTips 角色类型,例:leader,member
+ */
+ @FormUrlEncoded
+ @POST("/mgr/simplelist")
+ suspend fun obtainSubordinate(
+ @Header("token") token: String,
+ @Field("hasMine") hasMine: String?,
+ @Field("roleTips") roleTips: String?
+ ): String
+
+ /**
+ * 转单
+ *
+ * @param id 工单id
+ * @param transferPerson 转单人,转给谁
+ */
+ @FormUrlEncoded
+ @POST("/job/transferJob")
+ suspend fun transferWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("transferPerson") transferPerson: String
+ ): String
+
+ /**
+ * 确认工单
+ * @param id 工单id
+ * @param firstState 现场情况描述
+ * @param firstStatePhotos 现场情况照片路径集合
+ * @param needHandle 是否需要处理,1是需要处理,0是不需要处理(决定转入处理中还是已完成)
+ */
+ @FormUrlEncoded
+ @POST("/job/confirmJob")
+ suspend fun confirmWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("firstState") firstState: String,
+ @Field("firstStatePhotos") firstStatePhotos: String,
+ @Field("needHandle") needHandle: String
+ ): String
+
+ /**
+ * 完成工单
+ *
+ * @param id 工单id
+ * @param handleMessage 现场情况描述
+ * @param handlePhotos 现场情况照片路径集合
+ */
+ @FormUrlEncoded
+ @POST("/job/overJob")
+ suspend fun completeWorkOrder(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("handleMessage") handleMessage: String,
+ @Field("handlePhotos") handlePhotos: String
+ ): String
+
+ /**
+ * 告警内容列表
+ * @param alarmType 告警类型
+ * */
+ @GET("/alarm/contentType")
+ suspend fun obtainAlarmContentType(
+ @Header("token") token: String,
+ @Query("alarmType") alarmType: String
+ ): String
+
+ /**
+ * 工单状态
+ * */
+ @GET("/dict/code/jobStatus")
+ suspend fun obtainOrderStatus(
+ @Header("token") token: String
+ ): String
+
+ /**
+ * 查询工单
+ * */
+ @GET("/job/searchList")
+ suspend fun obtainSearchResult(
+ @Header("token") token: String,
+ @Query("keywords") keywords: String?,
+ @Query("alarmContent") alarmContent: String?,
+ @Query("alarmLevel") alarmLevel: String?,
+ @Query("jobStatus") jobStatus: String?,
+ @Query("beginTime") beginTime: String?,
+ @Query("endTime") endTime: String?,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时工单列表
+ */
+ @GET("/job/overtimeGetList")
+ suspend fun obtainNotAcceptOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取超时未处理工单列表
+ */
+ @GET("/job/overtimeHandleList")
+ suspend fun obtainNotHandleOderList(
+ @Header("token") token: String,
+ @Query("jobStatus") jobStatus: String,
+ @Query("limit") limit: Int,
+ @Query("offset") offset: Int
+ ): String
+
+ /**
+ * 获取用户信息
+ */
+ @GET("/user/info")
+ suspend fun obtainUserDetail(@Header("token") token: String): String
+
+ /**
+ * 修改密码
+ *
+ * @param oldPwd 旧密码
+ * @param newPwd 新密码
+ */
+ @FormUrlEncoded
+ @POST("/mgr/changePwd")
+ suspend fun changePassword(
+ @Header("token") token: String,
+ @Field("oldPwd") oldPwd: String,
+ @Field("newPwd") newPwd: String
+ ): String
+
+ /**
+ * 退出登录
+ */
+ @GET("/user/logout")
+ suspend fun loginOut(@Header("token") token: String): String
+
+ /**
+ * 更新APK版本
+ */
+ @POST("/app/checkVersion")
+ suspend fun obtainVersionResult(@Header("token") token: String): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
new file mode 100644
index 0000000..922334d
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -0,0 +1,257 @@
+package com.casic.app.smartwell.sanxi.utils.retrofit
+
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.AuthenticationHelper
+
+
+object RetrofitServiceManager {
+
+ private val api by lazy { RetrofitFactory.createRetrofit() }
+
+ /**
+ * 验证PublicKey
+ */
+ suspend fun authenticate(): PublicKeyModel {
+ return api.obtainPublicKey()
+ }
+
+ /**
+ * 登录并获取Token
+ */
+ suspend fun login(sid: String, account: String, secretKey: String): String {
+ return api.obtainLoginResult(sid, account, secretKey)
+ }
+
+ /**
+ * 获取用户信息
+ */
+ suspend fun obtainUserDetail(): String {
+ return api.obtainUserDetail(AuthenticationHelper.token!!)
+ }
+
+ /**
+ * 根据部门获取支持的设备类型
+ */
+ suspend fun obtainAuthorByDept(): String {
+ return api.obtainAuthorByDept(AuthenticationHelper.token!!)
+ }
+
+// /**
+// * 根据布防状态统计闸井数量接口
+// */
+// suspend fun countWellByState(): String {
+// return api.countWellByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 根据工单状态统计工单数量
+// */
+// suspend fun countWorkOrderByState(): String {
+// return api.countWorkOrderByState(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井类别
+// */
+// suspend fun obtainWellType(): String {
+// return api.obtainWellType(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取获取闸井列表
+// */
+// suspend fun obtainWellList(
+// keywords: String?, wellType: String?, deptid: String?, isAlarm: String?, page: Int
+// ): String {
+// return api.obtainWellList(
+// AuthenticationHelper.token!!,
+// keywords,
+// wellType,
+// deptid,
+// isAlarm,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取获取闸井列表-不分页
+// */
+// suspend fun obtainAllWell(): String {
+// return api.obtainAllWell(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 获取闸井详情
+// */
+// suspend fun obtainWellDetail(id: String): String {
+// return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 获取井下监控设备列表
+// */
+// suspend fun obtainMonitorResult(id: String): String {
+// return api.obtainMonitorResult(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 闸井布防撤防
+// */
+// suspend fun obtainOperationResult(wellId: String, bfzt: String): String {
+// return api.obtainOperationResult(AuthenticationHelper.token!!, wellId, bfzt)
+// }
+//
+// /**
+// * 根据工单状态获取工单列表
+// */
+// suspend fun obtainWorkOrderList(jobStatus: String, page: Int): String {
+// return api.obtainWorkOrderList(
+// AuthenticationHelper.token!!,
+// jobStatus,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取工单详情
+// */
+// suspend fun obtainWorkOrderDetail(id: String): String {
+// return api.obtainWorkOrderDetail(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 接单
+// */
+// suspend fun acceptWorkOrder(id: String): String {
+// return api.acceptWorkOrder(AuthenticationHelper.token!!, id)
+// }
+//
+// /**
+// * 上传图片
+// */
+// suspend fun uploadImage(image: File): String {
+// val requestBody = RequestBody.create("image/png".toMediaTypeOrNull(), image)
+// val imagePart = MultipartBody.Part.createFormData("file", image.name, requestBody)
+// return api.uploadImage(AuthenticationHelper.token!!, imagePart)
+// }
+//
+// /**
+// * 查找同一单位下的用户
+// */
+// suspend fun obtainSubordinate(hasMine: String?, roleTips: String?): String {
+// return api.obtainSubordinate(AuthenticationHelper.token!!, hasMine, roleTips)
+// }
+//
+// /**
+// * 转单
+// */
+// suspend fun transferWorkOrder(id: String, userId: String): String {
+// return api.transferWorkOrder(AuthenticationHelper.token!!, id, userId)
+// }
+//
+// /**
+// * 确认工单
+// */
+// suspend fun confirmWorkOrder(
+// id: String, firstState: String,
+// firstStatePhotos: String, needHandle: String
+// ): String {
+// return api.confirmWorkOrder(
+// AuthenticationHelper.token!!,
+// id, firstState, firstStatePhotos, needHandle
+// )
+// }
+//
+// /**
+// * 完成工单
+// */
+// suspend fun completeWorkOrder(
+// id: String, handleMessage: String, handlePhotos: String
+// ): String {
+// return api.completeWorkOrder(
+// AuthenticationHelper.token!!, id, handleMessage, handlePhotos
+// )
+// }
+//
+// /**
+// * 告警内容列表
+// */
+// suspend fun obtainAlarmContentType(alarmType: String): String {
+// return api.obtainAlarmContentType(AuthenticationHelper.token!!, alarmType)
+// }
+//
+// /**
+// * 工单状态
+// */
+// suspend fun obtainOrderStatus(): String {
+// return api.obtainOrderStatus(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 查询工单
+// */
+// suspend fun obtainSearchResult(
+// keywords: String?,
+// alarmContent: String?,
+// alarmLevel: String?,
+// jobStatus: String?,
+// beginTime: String?,
+// endTime: String?,
+// page: Int
+// ): String {
+// return api.obtainSearchResult(
+// AuthenticationHelper.token!!,
+// keywords,
+// alarmContent,
+// alarmLevel,
+// jobStatus,
+// beginTime,
+// endTime,
+// Constant.PAGE_LIMIT,
+// page
+// )
+// }
+//
+// /**
+// * 获取超时未接单工单列表
+// */
+// suspend fun obtainNotAcceptOderList(page: Int): String {
+// return api.obtainNotAcceptOderList(
+// AuthenticationHelper.token!!, "0", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+// /**
+// * 获取超时未处理工单列表
+// */
+// suspend fun obtainNotHandleOderList(page: Int): String {
+// return api.obtainNotHandleOderList(
+// AuthenticationHelper.token!!, "2", Constant.PAGE_LIMIT, page
+// )
+// }
+//
+
+//
+// /**
+// * 修改密码
+// */
+// suspend fun changePassword(oldPwd: String, newPwd: String): String {
+// return api.changePassword(AuthenticationHelper.token!!, oldPwd, newPwd)
+// }
+//
+// /**
+// * 退出登录
+// */
+// suspend fun loginOut(): String {
+// return api.loginOut(AuthenticationHelper.token!!)
+// }
+//
+// /**
+// * 更新APK版本
+// */
+// suspend fun updateVersion(): String {
+// return api.obtainVersionResult(AuthenticationHelper.token!!)
+// }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
new file mode 100644
index 0000000..7b12962
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/LoginActivity.kt
@@ -0,0 +1,138 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.text.Editable
+import android.text.TextWatcher
+import android.view.KeyEvent
+import android.view.inputmethod.EditorInfo
+import android.widget.EditText
+import android.widget.TextView
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.utils.*
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.LoginViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+import kotlinx.android.synthetic.main.activity_login.*
+
+class LoginActivity : BaseActivity() {
+
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var loginViewModel: LoginViewModel
+ private lateinit var userViewModel: UserViewModel
+
+ private val textWatcher = object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ if (s.toString().trim { it <= ' ' }.length > 16) {
+ inputLayout.error = "密码长度超出限制"
+ } else {
+ inputLayout.error = null
+ }
+ }
+ }
+
+ override fun initLayoutView(): Int = R.layout.activity_login
+
+ override fun setupTopBarLayout() {
+// //设置状态栏黑色字体图标
+// QMUIStatusBarHelper.setStatusBarLightMode(this)
+ }
+
+ override fun initData() {
+ // 设置默认账号密码
+ userNameView.setText(SaveKeyValues.getValue(Constant.ACCOUNT, "") as String)
+ userPasswordView.setText(SaveKeyValues.getValue(Constant.PASSWORD, "") as String)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ loginViewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ }
+
+ override fun initEvent() {
+ val editText: EditText? = inputLayout.editText
+ editText?.addTextChangedListener(textWatcher)
+ //点击输入法键盘"完成"
+ editText?.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? ->
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ authenticateViewModel.obtainPublicKey()
+ return@setOnEditorActionListener true
+ }
+ false
+ }
+
+ loginButton.setOnClickListener {
+ val account = userNameView.text.toString().trim()
+ val userPassword = userPasswordView.text.toString().trim()
+ if (account.isBlank()) {
+ "用户名不能为空".show()
+ return@setOnClickListener
+ }
+ if (userPassword.isBlank()) {
+ "密码不能为空".show()
+ return@setOnClickListener
+ }
+ SaveKeyValues.putValue(Constant.ACCOUNT, account)
+ SaveKeyValues.putValue(Constant.PASSWORD, userPassword)
+ authenticateViewModel.obtainPublicKey()
+ }
+ authenticateViewModel.keyModel.observe(this, {
+ if (it.code == 200) {//用code判断,别的判断可能有坑
+ val keyString = it.data!!.publicKey!!
+ /**
+ * 修改密码需要用到key,先存着
+ * */
+ AuthenticationHelper.savePublicKey(keyString)
+ val publicKey = RSAUtils.keyStrToPublicKey(keyString)
+
+ val account = userNameView.text.toString()
+ val userPassword = userPasswordView.text.toString()
+ val dataByPublicKey =
+ RSAUtils.encryptDataByPublicKey(userPassword.toByteArray(), publicKey!!)
+ //登录并获取Token,POST请求
+ loginViewModel.enter(it.data!!.sid!!, account, dataByPublicKey)
+ loginViewModel.enterResultModel.observe(this, { loginResult ->
+ if (loginResult.code == 200) {
+ AuthenticationHelper.saveToken(loginResult.data!!.token!!)
+ /**
+ * 获取token之后保存用户信息
+ * */
+ userViewModel.obtainUserDetail()
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ //验证成功登录
+ this.navigatePageTo()
+ finish()
+ }
+ })
+ loginViewModel.loadState.observe(this, { loginState ->
+ when (loginState) {
+ is LoadState.Success -> {
+ "登录成功".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ else -> {
+ "登录失败,用户名或密码错误".show()
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ } else {
+ it.message!!.show()
+ }
+ })
+ authenticateViewModel.loadState.observe(this, {
+ DialogHelper.showLoadingDialog(this, "登录中,请稍后")
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
index 4784d72..2730058 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/SplashScreenActivity.kt
@@ -1,16 +1,20 @@
package com.casic.app.smartwell.sanxi.view
+import android.annotation.SuppressLint
import android.os.CountDownTimer
+import androidx.lifecycle.ViewModelProvider
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.base.BaseActivity
import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
+import com.casic.app.smartwell.sanxi.vm.AuthenticateViewModel
+import com.casic.app.smartwell.sanxi.vm.UserViewModel
+@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : BaseActivity() {
private val kTag = "SplashScreenActivity"
-// private lateinit var userDetailViewModel: UserDetailViewModel
-// private lateinit var authenticateViewModel: AuthenticateViewModel
-// private val imageModels: MutableList = ArrayList()
+ private lateinit var userViewModel: UserViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
override fun initLayoutView(): Int = R.layout.activity_splash
@@ -19,28 +23,11 @@
}
override fun initData() {
-// userDetailViewModel = ViewModelProvider(this).get(UserDetailViewModel::class.java)
-// authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+ userViewModel = ViewModelProvider(this).get(UserViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
}
override fun initEvent() {
-// Constant.NEWS_PAGE.forEach {
-// WebCrawler.Builder()
-// .addLifecycleCoroutineScope(lifecycleScope)
-// .ignoreHttpErrors(true)
-// .setTimeout(15000)
-// .setTargetWebSite(it)
-// .addOnWebCrawlerCallback(object : WebCrawler.OnWebCrawlerCallback {
-// override fun onParseSuccess(model: BannerImageModel) {
-// imageModels.add(model)
-// SaveKeyValues.putValue(Constant.BANNER_MODEL, imageModels.toJson())
-// }
-//
-// override fun onParseFailure(e: Exception) {
-// Log.e(kTag, "onParseFailure: $e", e)
-// }
-// }).build().start()
-// }
countDownTimer.start()
}
@@ -49,19 +36,19 @@
/**
* 获取token之后保存用户信息
* */
-// userDetailViewModel.obtainUserDetail()
- /**
- * 根据用户有权查看的设备类型
- */
-// authenticateViewModel.obtainAuthorByDept()
-// userDetailViewModel.flag.observe(this@SplashScreenActivity, {
-// if (it) {
- navigatePageTo()
-// } else {
-// navigatePageTo(LoginActivity::class.java)
-// }
- finish()
-// })
+ userViewModel.obtainUserDetail()
+ userViewModel.userDetailModel.observe(this@SplashScreenActivity, {
+ if (it.code == 200) {
+ /**
+ * 根据用户有权查看的设备类型
+ */
+ authenticateViewModel.obtainAuthorByDept()
+ navigatePageTo()
+ } else {
+ navigatePageTo()
+ }
+ finish()
+ })
}
override fun onTick(millisUntilFinished: Long) {
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
new file mode 100644
index 0000000..d351713
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/AuthenticateViewModel.kt
@@ -0,0 +1,43 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.*
+import com.casic.app.smartwell.sanxi.model.PublicKeyModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.SaveKeyValues
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import org.json.JSONObject
+
+class AuthenticateViewModel : BaseViewModel() {
+
+ val keyModel = MutableLiveData()
+
+ fun obtainPublicKey() = launch({
+ loadState.value = LoadState.Loading
+ keyModel.value = RetrofitServiceManager.authenticate()
+ }, {
+ it.printStackTrace()
+ })
+
+ fun obtainAuthorByDept() = launch({
+ val response = RetrofitServiceManager.obtainAuthorByDept()
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ val jsonObject = JSONObject(response)
+ val data = jsonObject.getJSONObject("data")
+
+ val typeArray = data.getJSONArray("deviceTypes")
+ val types: MutableList = ArrayList()
+ for (i in 0 until typeArray.length()) {
+ types.add(typeArray.getString(i))
+ }
+ SaveKeyValues.putValue(Constant.USER_DEVICE_TYPE, types.toJson())
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
new file mode 100644
index 0000000..32384ad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/LoginViewModel.kt
@@ -0,0 +1,51 @@
+package com.casic.app.smartwell.sanxi.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.app.smartwell.sanxi.base.BaseViewModel
+import com.casic.app.smartwell.sanxi.extensions.launch
+import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
+import com.casic.app.smartwell.sanxi.model.LoginResultModel
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+
+class LoginViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val enterResultModel = MutableLiveData()
+// val outResultModel = MutableLiveData()
+
+ fun enter(sid: String, account: String, secretKey: String) = launch({
+ val response = RetrofitServiceManager.login(sid, account, secretKey)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ enterResultModel.value = gson.fromJson(
+ response, object : TypeToken