Commit d8c575b4 by zhengnw@sobot.com

common 1.4.0 登录添加openapihost 用于获取accesstoken,不传,不获取 直接登录

parent cae3f207
...@@ -200,7 +200,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -200,7 +200,7 @@ public class MainActivity extends SobotBaseActivity {
// } // }
Map<String, Object> map1 = new HashMap<>(); Map<String, Object> map1 = new HashMap<>();
map1.put("email", "zhengnawei@sobot.com"); map1.put("email", "zhengnw@sobot.com");
map1.put("passwd", "znw123456"); map1.put("passwd", "znw123456");
map1.put("loginStatus", "1"); map1.put("loginStatus", "1");
map1.put("from", 2 + ""); map1.put("from", 2 + "");
...@@ -209,7 +209,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -209,7 +209,7 @@ public class MainActivity extends SobotBaseActivity {
Map<String, String> headers1 = new HashMap<>(); Map<String, String> headers1 = new HashMap<>();
headers1.put("language", "zh"); headers1.put("language", "zh");
// SobotLoginTools.getInstance().doAppLogin(MainActivity.this, MainActivity.this, "https://api-c.soboten.com/text", 8000, map1, headers1, new SobotResultBlock() { // SobotLoginTools.getInstance().doAppLogin(MainActivity.this, MainActivity.this, "https://api-c.sobot.com/text","https://api-c.soboten.com/text", 8000, map1, headers1, new SobotResultBlock() {
// @Override // @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) { // public void resultBolok(SobotResultCode code, String msg, Object obj) {
// SobotLoginTools.getInstance().checkExpiresToken(); // SobotLoginTools.getInstance().checkExpiresToken();
...@@ -224,7 +224,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -224,7 +224,7 @@ public class MainActivity extends SobotBaseActivity {
// SobotServiceInfoModel ccc=new SobotServiceInfoModel(); // SobotServiceInfoModel ccc=new SobotServiceInfoModel();
// SobotLoginTools.getInstance().setServiceInfo(ccc); // SobotLoginTools.getInstance().setServiceInfo(ccc);
// SobotLoginTools.getInstance().doLogin(MainActivity.this, MainActivity.this, "https://api-c.soboten.com/text", "zhengnawei@sobot.com", "znw123456","", new SobotResultBlock() { // SobotLoginTools.getInstance().doLogin(MainActivity.this, MainActivity.this, "https://api-c.sobot.com/text","https://api-c.soboten.com", "zhengnw@sobot.com", "znw123456","", new SobotResultBlock() {
// @Override // @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) { // public void resultBolok(SobotResultCode code, String msg, Object obj) {
// SobotLoginTools.getInstance().checkExpiresToken(); // SobotLoginTools.getInstance().checkExpiresToken();
......
...@@ -13,7 +13,7 @@ ext { ...@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'sobotcommon' //项目名 PUBLISH_ARTIFACT_ID = 'sobotcommon' //项目名
// PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名 // PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION = '1.3.9.6' //版本号 PUBLISH_VERSION = '1.4.0' //版本号
} }
......
...@@ -88,6 +88,27 @@ public class SobotLoginTools { ...@@ -88,6 +88,27 @@ public class SobotLoginTools {
} }
} }
private HostModel mHostModel;
//获取域名
public HostModel getHostModel() {
if (mHostModel == null) {
mHostModel = HostManager.getInstance().getHost();
}
return mHostModel;
}
public void setServiceInfo(HostModel newHostModel) {
HostManager.getInstance().deleteAll();
mHostModel = newHostModel;
if (mHostModel != null) {
HostManager.getInstance().insert(mHostModel);
} else {
HostManager.getInstance().deleteAll();
}
}
//呼叫 v6 获取 accessToken //呼叫 v6 获取 accessToken
public String getAccessToken() { public String getAccessToken() {
if (getLoginUser() != null) { if (getLoginUser() != null) {
...@@ -133,15 +154,8 @@ public class SobotLoginTools { ...@@ -133,15 +154,8 @@ public class SobotLoginTools {
} }
/**
* 获取域名信息
*/
public HostModel getHostModel() {
return HostManager.getInstance().getHost();
}
// 执行APP登录接口 // 执行APP登录接口
public void doAppLogin(final Object cancelTag, final Context mContext, final String host, long timeout, Map<String, Object> params, Map<String, String> headers, final SobotResultBlock resultBlock) { public void doAppLogin(final Object cancelTag, final Context mContext, final String host, final String openApiHost, long timeout, Map<String, Object> params, Map<String, String> headers, final SobotResultBlock resultBlock) {
SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", timeout, params, headers, new HttpBaseUtils.StringCallBack() { SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", timeout, params, headers, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
...@@ -158,10 +172,10 @@ public class SobotLoginTools { ...@@ -158,10 +172,10 @@ public class SobotLoginTools {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj; SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj;
if (serviceInfoModel != null) { if (serviceInfoModel != null) {
if (serviceInfoModel.getCallV6Flag() == 1) { if (serviceInfoModel.getCallV6Flag() == 1 && !SobotStringUtils.isEmpty(openApiHost)) {
if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) { if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) {
//如果是v6呼叫 //如果是v6呼叫
String tempHost = host; String tempHost = openApiHost;
if (tempHost.contains("/text")) { if (tempHost.contains("/text")) {
tempHost = tempHost.replace("/text", ""); tempHost = tempHost.replace("/text", "");
} }
...@@ -216,8 +230,8 @@ public class SobotLoginTools { ...@@ -216,8 +230,8 @@ public class SobotLoginTools {
}); });
} }
// sdk 执行登录接口 // sdk 执行登录接口 会获取accesstoken
public void doLogin(final Object cancelTag, final Context mContext, final String host, String loginAcount, String loginPwd, String logintoken, final SobotResultBlock resultBlock) { public void doLogin(final Object cancelTag, final Context mContext, final String host, final String openApiHost, String loginAcount, String loginPwd, String logintoken, final SobotResultBlock resultBlock) {
if (SobotStringUtils.isEmpty(logintoken)) { if (SobotStringUtils.isEmpty(logintoken)) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("loginUser", loginAcount); params.put("loginUser", loginAcount);
...@@ -236,10 +250,10 @@ public class SobotLoginTools { ...@@ -236,10 +250,10 @@ public class SobotLoginTools {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj; SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj;
if (serviceInfoModel != null) { if (serviceInfoModel != null) {
if (serviceInfoModel.getCallV6Flag() == 1) { if (serviceInfoModel.getCallV6Flag() == 1 && !SobotStringUtils.isEmpty(openApiHost)) {
if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) { if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) {
//如果是v6呼叫 //如果是v6呼叫
String tempHost = host; String tempHost = openApiHost;
if (tempHost.contains("/text")) { if (tempHost.contains("/text")) {
tempHost = tempHost.replace("/text", ""); tempHost = tempHost.replace("/text", "");
} }
...@@ -339,6 +353,7 @@ public class SobotLoginTools { ...@@ -339,6 +353,7 @@ public class SobotLoginTools {
} }
} }
/** /**
* 调用座席接口 * 调用座席接口
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment