Commit 626141c5 by zhengnw@sobot.com

common 登录方式调整

parent 73da01cf
...@@ -17,6 +17,9 @@ import com.sobot.album.AlbumFile; ...@@ -17,6 +17,9 @@ import com.sobot.album.AlbumFile;
import com.sobot.album.SobotAlbum; import com.sobot.album.SobotAlbum;
import com.sobot.album.SobotMediaLoader; import com.sobot.album.SobotMediaLoader;
import com.sobot.album.api.widget.Widget; import com.sobot.album.api.widget.Widget;
import com.sobot.common.login.SobotLoginTools;
import com.sobot.common.login.callback.SobotResultBlock;
import com.sobot.common.login.callback.SobotResultCode;
import com.sobot.common.utils.SobotImageUtils; import com.sobot.common.utils.SobotImageUtils;
import com.sobot.pictureframe.SobotBitmapUtil; import com.sobot.pictureframe.SobotBitmapUtil;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
...@@ -65,7 +68,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -65,7 +68,7 @@ public class MainActivity extends SobotBaseActivity {
img2 = findViewById(R.id.img2); img2 = findViewById(R.id.img2);
// img2.setScaleType(ImageView.ScaleType.FIT_XY); // img2.setScaleType(ImageView.ScaleType.FIT_XY);
SobotBitmapUtil.display(this, "https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", img2); // SobotBitmapUtil.display(this, "https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", img2);
// File save=new File(SobotSDCardUtils.getSDCardRootPath(MainActivity.this)+"/9410b53be86b4d589c61c60f6aee2461.jpeg"); // File save=new File(SobotSDCardUtils.getSDCardRootPath(MainActivity.this)+"/9410b53be86b4d589c61c60f6aee2461.jpeg");
// HttpBaseUtils.getInstance().download("https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", save, new HttpBaseUtils.FileCallBack() { // HttpBaseUtils.getInstance().download("https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", save, new HttpBaseUtils.FileCallBack() {
// @Override // @Override
...@@ -212,31 +215,37 @@ public class MainActivity extends SobotBaseActivity { ...@@ -212,31 +215,37 @@ public class MainActivity extends SobotBaseActivity {
// } // }
Map<String, Object> map1 = new HashMap<>(); Map<String, Object> map1 = new HashMap<>();
map1.put("email", "zhengnw@zhichi.com");
map1.put("passwd", "znw123456");
map1.put("loginStatus", "1"); map1.put("loginStatus", "1");
map1.put("from", 2 + ""); map1.put("from", 2 + "");
map1.put("way", "10"); map1.put("way", "10");
map1.put("ack", "1"); map1.put("ack", "1");
Map<String, String> headers1 = new HashMap<>();
headers1.put("language", "zh");
// SobotLoginTools.getInstance().doAppLogin(MainActivity.this, getSobotBaseContext(), "https://api-c.sobot.com/text","https://api-c.soboten.com/text", 8000, map1, headers1,"zhengnw@sobot.com","znw123456", new SobotResultBlock() { // SobotLoginTools.getInstance().doLogin(MainActivity.this, getSobotBaseContext(), true, "https://test-branche1.sobot.com/text", "https://test-branche1.sobot.com/text", "zhengnw@zhichi.com", "znw123456", map1, 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();
// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken()+""); // SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken() + "");
// SobotLogUtils.i(SobotLoginTools.getInstance().getTempId()); // SobotLogUtils.i(SobotLoginTools.getInstance().getTempId());
// SobotLogUtils.i(SobotLoginTools.getInstance().getToken()+""); // SobotLogUtils.i(SobotLoginTools.getInstance().getToken() + "");
// SobotLoginTools.getInstance().logOut(MainActivity.this, "https://api-c.sobot.com/text", "zhengnw@sobot.com", new SobotResultBlock() { //// SobotLoginTools.getInstance().logOut(MainActivity.this, "https://api-c.sobot.com/text", "zhengnw@zhichi.com", new SobotResultBlock() {
// @Override //// @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) { //// public void resultBolok(SobotResultCode code, String msg, Object obj) {
// ////
// } //// }
// }); //// });
// } // }
// }); // });
SobotLoginTools.getInstance().loginWithAppkey(MainActivity.this, getSobotBaseContext(), true, "https://test-branche1.sobot.com/text", "https://test.sobot.com", "zhengnw@zhichi.com", "UaH4q8JHj708", "615abf5432134e4992d4da2ba6f460db", map1, new SobotResultBlock() {
@Override
public void resultBolok(SobotResultCode code, String msg, Object obj) {
SobotLoginTools.getInstance().checkExpiresToken();
SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken() + "");
SobotLogUtils.i(SobotLoginTools.getInstance().getTempId());
SobotLogUtils.i(SobotLoginTools.getInstance().getToken() + "");
}
});
// LoginUserEntity sa=new LoginUserEntity(); // LoginUserEntity sa=new LoginUserEntity();
// sa.setLogin_time(System.currentTimeMillis()); // sa.setLogin_time(System.currentTimeMillis());
...@@ -261,19 +270,19 @@ public class MainActivity extends SobotBaseActivity { ...@@ -261,19 +270,19 @@ public class MainActivity extends SobotBaseActivity {
//// 是否隐藏底部工具栏 默认false显示, true 隐藏 //// 是否隐藏底部工具栏 默认false显示, true 隐藏
// intent.putExtra("isHideToolBar", true); // intent.putExtra("isHideToolBar", true);
// startActivity(intent); // startActivity(intent);
permissionListener = new SobotPermissionListenerImpl() { // permissionListener = new SobotPermissionListenerImpl() {
@Override // @Override
public void onPermissionSuccessListener() { // public void onPermissionSuccessListener() {
openAlbum(); // openAlbum();
} // }
}; // };
if (checkIsShowPermissionPop(getString(R.string.sobot_memory_card), getString(R.string.sobot_memory_card_yongtu), 1, 4)) { // if (checkIsShowPermissionPop(getString(R.string.sobot_memory_card), getString(R.string.sobot_memory_card_yongtu), 1, 4)) {
return; // return;
} // }
if (!checkStoragePermission(4)) { // if (!checkStoragePermission(4)) {
return; // return;
} // }
openAlbum(); // openAlbum();
} }
......
...@@ -16,3 +16,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 ...@@ -16,3 +16,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# AndroidX package structure to make it clearer which packages are bundled with the # AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK # Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn # https://developer.android.com/topic/libraries/support-library/androidx-rn
android.injected.testOnly=false
\ No newline at end of file
...@@ -4,20 +4,23 @@ import android.content.Context; ...@@ -4,20 +4,23 @@ import android.content.Context;
import com.sobot.common.login.callback.SobotResultBlock; import com.sobot.common.login.callback.SobotResultBlock;
import com.sobot.common.login.callback.SobotResultCode; import com.sobot.common.login.callback.SobotResultCode;
import com.sobot.common.login.db.FunctionManager;
import com.sobot.common.login.db.HostManager; import com.sobot.common.login.db.HostManager;
import com.sobot.common.login.db.LoginUserManager;
import com.sobot.common.login.db.ServiceInfoManager; import com.sobot.common.login.db.ServiceInfoManager;
import com.sobot.common.login.model.HostModel; import com.sobot.common.login.model.HostModel;
import com.sobot.common.login.model.LoginUserEntity; import com.sobot.common.login.model.OnlineUserEntity;
import com.sobot.common.login.model.ServiceFunctionVoModel; import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.login.model.SobotCallBaseCode; import com.sobot.common.login.model.SobotCallBaseCode;
import com.sobot.common.login.model.SobotServiceInfoModel; import com.sobot.common.login.model.SobotServiceInfoModel;
import com.sobot.common.login.model.TokenModel;
import com.sobot.common.login.permission.SobotPermissionApi;
import com.sobot.common.login.permission.SobotPermissionManager; import com.sobot.common.login.permission.SobotPermissionManager;
import com.sobot.gson.SobotGsonUtil; import com.sobot.gson.SobotGsonUtil;
import com.sobot.network.apiUtils.SobotBaseCode; import com.sobot.network.apiUtils.SobotBaseCode;
import com.sobot.network.apiUtils.SobotHttpUtils; import com.sobot.network.apiUtils.SobotHttpUtils;
import com.sobot.network.http.HttpBaseUtils; import com.sobot.network.http.HttpBaseUtils;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotMD5Util;
import com.sobot.utils.SobotSharedPreferencesUtil; import com.sobot.utils.SobotSharedPreferencesUtil;
import com.sobot.utils.SobotStringUtils; import com.sobot.utils.SobotStringUtils;
...@@ -46,27 +49,6 @@ public class SobotLoginTools { ...@@ -46,27 +49,6 @@ public class SobotLoginTools {
} }
private LoginUserEntity user;
public LoginUserEntity getLoginUser() {
if (user == null || user.getAid() == null) {
user = LoginUserManager.getInstance().getCurUser();
}
return user;
}
public void setLoginUser(LoginUserEntity newUser) {
LoginUserManager.getInstance().deleteAll();
user = newUser;
if (user != null) {
user.setLogin_time(System.currentTimeMillis());
LoginUserManager.getInstance().insert(user);
} else {
ServiceInfoManager.getInstance().deleteAll();
}
}
private SobotServiceInfoModel mServiceInfoModel; private SobotServiceInfoModel mServiceInfoModel;
public SobotServiceInfoModel getServiceInfo() { public SobotServiceInfoModel getServiceInfo() {
...@@ -76,6 +58,19 @@ public class SobotLoginTools { ...@@ -76,6 +58,19 @@ public class SobotLoginTools {
return mServiceInfoModel; return mServiceInfoModel;
} }
private List<ServiceFunctionVoModel> functionVoModelList;
//获取权限列表
public List<ServiceFunctionVoModel> getServiceFunctionVoModel() {
if (functionVoModelList == null && ServiceInfoManager.getInstance().getInfo() != null) {
functionVoModelList = ServiceInfoManager.getInstance().getInfo().getFunctionStr();
}
if (functionVoModelList == null) {
functionVoModelList = new ArrayList<>();
}
return functionVoModelList;
}
public void setServiceInfo(SobotServiceInfoModel newServiceInfo) { public void setServiceInfo(SobotServiceInfoModel newServiceInfo) {
ServiceInfoManager.getInstance().deleteAll(); ServiceInfoManager.getInstance().deleteAll();
mServiceInfoModel = newServiceInfo; mServiceInfoModel = newServiceInfo;
...@@ -119,33 +114,33 @@ public class SobotLoginTools { ...@@ -119,33 +114,33 @@ public class SobotLoginTools {
//呼叫 v6 获取 accessToken //呼叫 v6 获取 accessToken
public String getAccessToken() { public String getAccessToken() {
if (getLoginUser() != null) { if (getServiceInfo() != null) {
return SobotStringUtils.checkStringIsNull(getLoginUser().getAccess_token()); return SobotStringUtils.checkStringIsNull(getServiceInfo().getAccess_token());
} }
return ""; return "";
} }
//呼叫 v6 获取 accessToken //呼叫 v6 获取 accessToken
public String getTempId() { public String getTempId() {
if (getLoginUser() != null) { if (getServiceInfo() != null) {
return SobotStringUtils.checkStringIsNull(getLoginUser().getTempId()); return SobotStringUtils.checkStringIsNull(getServiceInfo().getTempId());
} }
return ""; return "";
} }
//呼叫 v6 获取 accessToken //呼叫 v6 获取 accessToken
public String getToken() { public String getToken() {
if (getLoginUser() != null) { if (getServiceInfo() != null) {
return SobotStringUtils.checkStringIsNull(getLoginUser().getToken()); return SobotStringUtils.checkStringIsNull(getServiceInfo().getToken());
} }
return ""; return "";
} }
// 检查token是否过期 12个小时 返回true 有效; false 过期 // 检查token是否过期 12个小时 返回true 有效; false 过期
public boolean checkExpiresToken() { public boolean checkExpiresToken() {
if (getLoginUser() != null) { if (getServiceInfo() != null) {
long difference = System.currentTimeMillis() - getLoginUser().getLogin_time(); long difference = System.currentTimeMillis() - getServiceInfo().getLogin_time();
if (getLoginUser().getLogin_time() > 0 && (difference > 12 * 60 * 60 * 1000)) { if (getServiceInfo().getLogin_time() > 0 && (difference > 12 * 60 * 60 * 1000)) {
SobotLogUtils.d("上次登录距离当前的时间:" + difference + "ms,已经超过12小时,token已经过期"); SobotLogUtils.d("上次登录距离当前的时间:" + difference + "ms,已经超过12小时,token已经过期");
return false; return false;
} }
...@@ -154,8 +149,8 @@ public class SobotLoginTools { ...@@ -154,8 +149,8 @@ public class SobotLoginTools {
} }
public boolean isLogin() { public boolean isLogin() {
//登录对象,客户对象不为空,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录 //登录客户对象不为空,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录
if (getLoginUser() != null && getServiceInfo() != null && !SobotStringUtils.isEmpty(getLoginUser().getToken()) && checkExpiresToken()) { if (getServiceInfo() != null && !SobotStringUtils.isEmpty(getServiceInfo().getToken()) && checkExpiresToken()) {
return true; return true;
} else { } else {
return false; return false;
...@@ -164,8 +159,8 @@ public class SobotLoginTools { ...@@ -164,8 +159,8 @@ public class SobotLoginTools {
//判断是否已经登录 //判断是否已经登录
public boolean isLogin(String loginAccount) { public boolean isLogin(String loginAccount) {
//登录对象,客户对象不为空,登录账号和登录对象里边账号一样,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录 //登录客户对象不为空,登录账号和登录对象里边账号一样,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录
if (getLoginUser() != null && getServiceInfo() != null && !SobotStringUtils.isEmpty(loginAccount) && loginAccount.equals(getLoginUser().getLoginAccount()) && !SobotStringUtils.isEmpty(getLoginUser().getToken()) && checkExpiresToken()) { if (getServiceInfo() != null && !SobotStringUtils.isEmpty(loginAccount) && loginAccount.equals(getServiceInfo().getLoginAccount()) && !SobotStringUtils.isEmpty(getServiceInfo().getToken()) && checkExpiresToken()) {
return true; return true;
} else { } else {
return false; return false;
...@@ -174,11 +169,11 @@ public class SobotLoginTools { ...@@ -174,11 +169,11 @@ public class SobotLoginTools {
//清除登录token //清除登录token
public void clearLoginToken() { public void clearLoginToken() {
LoginUserEntity tempUserEntity = getLoginUser(); SobotServiceInfoModel tempUserEntity = getServiceInfo();
if (tempUserEntity!=null){ if (tempUserEntity != null) {
tempUserEntity.setAccess_token(""); tempUserEntity.setAccess_token("");
tempUserEntity.setToken(""); tempUserEntity.setToken("");
setLoginUser(tempUserEntity); setServiceInfo(tempUserEntity);
} }
} }
...@@ -189,85 +184,113 @@ public class SobotLoginTools { ...@@ -189,85 +184,113 @@ public class SobotLoginTools {
/** /**
* 清除登录信息 * 清除登录信息
*
* @param isClearHost 是否清理域名 * @param isClearHost 是否清理域名
*/ */
public void clearLoginInfo(boolean isClearHost) { public void clearLoginInfo(boolean isClearHost) {
LoginUserManager.getInstance().deleteAll();
ServiceInfoManager.getInstance().deleteAll(); ServiceInfoManager.getInstance().deleteAll();
user = null;
mServiceInfoModel = null; mServiceInfoModel = null;
if (isClearHost){ if (isClearHost) {
HostManager.getInstance().deleteAll(); HostManager.getInstance().deleteAll();
} }
} }
/**
// 执行APP登录接口 * 执行登录操作
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 String loginAccount, final String loginPwd, final SobotResultBlock resultBlock) { * 1、通过账号密码登录获取token;2、根据token获取客服角色权限等信息;3、如果是呼叫V6或者电销,先获取AccessToken;4、再根据客服app或者客服SDK登录同时又买了在线产品判断是否执行在线操作逻辑
if (isLogin(loginAccount)) { *
* @param cancelTag
* @param mContext
* @param isAppOrOnlineLogin 客服app或者客服SDK登录传true 工单或呼叫Sdk 传false
* @param host
* @param openApiHost
* @param loginAcount 登录账号
* @param loginPwd 登录密码
* @param paramsMap 单独执行在线登录逻辑 参数
* @param resultBlock
*/
public void doLogin(final Object cancelTag, final Context mContext, final boolean isAppOrOnlineLogin, final String host, final String openApiHost, final String loginAcount, final String loginPwd, final Map<String, Object> paramsMap, final SobotResultBlock resultBlock) {
if (SobotStringUtils.isEmpty(host) || SobotStringUtils.isEmpty(openApiHost)) {
SobotLogUtils.i("域名不能为空");
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "域名不能为空", getServiceInfo());
}
return;
}
if (isLogin(loginAcount)) {
SobotLogUtils.i("已经登录成功,不用重新登录"); SobotLogUtils.i("已经登录成功,不用重新登录");
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser()); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getServiceInfo());
} }
return; return;
} }
SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", timeout, params, headers, new HttpBaseUtils.StringCallBack() { final Map<String, Object> params = new HashMap<>();
params.put("userEntity", loginAcount);
params.put("loginPwd", loginPwd);
SobotHttpUtils.doPost(cancelTag, host + "/basic-login/serviceAppLogin/4", 8000, params, null, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String response) {
if (!SobotStringUtils.isEmpty(result)) { SobotCallBaseCode result = SobotGsonUtil.jsonToBean(response, SobotCallBaseCode.class);
final SobotBaseCode<LoginUserEntity> baseModel = SobotGsonUtil.jsonToBeans(result, new com.sobot.gson.reflect.TypeToken<SobotBaseCode<LoginUserEntity>>() { if (result != null && !SobotStringUtils.isEmpty(result.getRetCode()) && "000000".equals(result.getRetCode()) && !SobotStringUtils.isEmpty(result.getItem())) {
}.getType()); final long login_time = System.currentTimeMillis();
if (baseModel != null) { final String token = (String) result.getItem();
//登录接口和获取坐席信息权限接口都成功才算真正登录成功 getuserEntityInfo(cancelTag, mContext, host, token, "", new SobotResultBlock() {
if ("1".equals(baseModel.getCode()) && baseModel.getData() != null) {
final LoginUserEntity userEntity = baseModel.getData();
getLoginUserInfo(cancelTag, mContext, host, baseModel.getData().getToken(), baseModel.getData().getLanguage(), new SobotResultBlock() {
@Override @Override
public void resultBolok(SobotResultCode code, String msg, Object obj) { public void resultBolok(SobotResultCode code, String msg, Object obj) {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj; SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj;
if (serviceInfoModel != null) { if (serviceInfoModel != null) {
serviceInfoModel.setLogin_time(login_time);
serviceInfoModel.setToken(token);
serviceInfoModel.setLoginAccount(loginAcount);
serviceInfoModel.setLoginPwd(loginPwd);
if ((serviceInfoModel.getCallV6Flag() == 1 || SobotPermissionManager.isHasNewPermission(SobotPermissionManager.SCC)) && !SobotStringUtils.isEmpty(openApiHost)) { if ((serviceInfoModel.getCallV6Flag() == 1 || SobotPermissionManager.isHasNewPermission(SobotPermissionManager.SCC)) && !SobotStringUtils.isEmpty(openApiHost)) {
if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) {
//如果是v6呼叫 //如果是v6呼叫
String tempHost = openApiHost; String tempHost = openApiHost;
if (tempHost.contains("/text")) { if (tempHost.contains("/text")) {
tempHost = tempHost.replace("/text", ""); tempHost = tempHost.replace("/text", "");
} }
doAccessToken(cancelTag, tempHost, userEntity.getToken(), new SobotResultBlock() { final SobotServiceInfoModel tempServiceInfoModel = serviceInfoModel;
doAccessToken(cancelTag, tempHost, serviceInfoModel.getToken(), new SobotResultBlock() {
@Override @Override
public void resultBolok(SobotResultCode code, String msg, Object obj) { public void resultBolok(SobotResultCode code, String msg, Object obj) {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity; SobotServiceInfoModel tempUserEntity = tempServiceInfoModel;
if (obj != null && obj instanceof String && SobotStringUtils.isNoEmpty((String) obj)) {
String accessToken = (String) obj; String accessToken = (String) obj;
tempUserEntity.setAccess_token(accessToken); tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis()); //判断是否有对话功能
tempUserEntity.setLoginAccount(loginAccount); if (SobotPermissionManager.checkPermission(SobotPermissionApi.USER_PERMISSION_TYPE_TALK) && isAppOrOnlineLogin) {
tempUserEntity.setLoginPwd(loginPwd); doOnline(cancelTag, mContext, host, paramsMap, tempUserEntity, resultBlock);
setLoginUser(tempUserEntity); } else {
setServiceInfo(tempUserEntity);
SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, tempUserEntity);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
} }
}
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败 accessToken获取失败", null);
} }
} }
}
});
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
} }
} }
}
});
} else {
//判断是否有对话功能
if (SobotPermissionManager.checkPermission(SobotPermissionApi.USER_PERMISSION_TYPE_TALK) && isAppOrOnlineLogin) {
doOnline(cancelTag, mContext, host, paramsMap, serviceInfoModel, resultBlock);
} else { } else {
LoginUserEntity tempUserEntity = userEntity; setServiceInfo(serviceInfoModel);
tempUserEntity.setLogin_time(System.currentTimeMillis()); SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel);
tempUserEntity.setLoginAccount(loginAccount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", serviceInfoModel);
}
} }
} }
} else { } else {
...@@ -285,13 +308,7 @@ public class SobotLoginTools { ...@@ -285,13 +308,7 @@ public class SobotLoginTools {
}); });
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, baseModel.getMsg(), baseModel.getCode()); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, (result != null && SobotStringUtils.isNoEmpty(result.getRetMsg())) ? result.getRetMsg() : "登录失败", "");
}
}
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "接口请求结果为空", null);
}
} }
} }
} }
...@@ -310,74 +327,116 @@ public class SobotLoginTools { ...@@ -310,74 +327,116 @@ public class SobotLoginTools {
}); });
} }
// sdk 执行登录接口 会获取accesstoken /**
public void doLogin(final Object cancelTag, final Context mContext, final String host, final String openApiHost, final String loginAcount, final String loginPwd, String logintoken, final SobotResultBlock resultBlock) { * 执行登录操作
if (SobotStringUtils.isEmpty(logintoken)) { * 1、通过账号密码登录获取token;2、根据token获取客服角色权限等信息;3、如果是呼叫V6或者电销,先获取AccessToken;4、再根据客服app或者客服SDK登录同时又买了在线产品判断是否执行在线操作逻辑
*
* @param cancelTag
* @param mContext
* @param isAppOrOnlineLogin true 客服app或者客服SDK登录,如果有在线产品,再单独执行在线登录逻辑
* @param host
* @param openApiHost
* @param loginAcount 登录账号
* @param appkey 客户开通时生成,可以找智齿售后同时获取
* @param appId 客户开通时生成,可以找智齿售后同时获取
* @param paramsMap 单独执行在线登录逻辑 参数
* @param resultBlock
*/
public void loginWithAppkey(final Object cancelTag, final Context mContext, final boolean isAppOrOnlineLogin, final String host, final String openApiHost, final String loginAcount, final String appkey, final String appId, final Map<String, Object> paramsMap, final SobotResultBlock resultBlock) {
if (SobotStringUtils.isEmpty(host) || SobotStringUtils.isEmpty(openApiHost)) {
SobotLogUtils.i("域名不能为空");
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "域名不能为空", getServiceInfo());
}
return;
}
if (isLogin(loginAcount)) { if (isLogin(loginAcount)) {
SobotLogUtils.i("已经登录成功,不用重新登录"); SobotLogUtils.i("已经登录成功,不用重新登录");
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser()); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getServiceInfo());
} }
return; return;
} }
Map<String, Object> tokebMap = new HashMap<>();
String nowMills = System.currentTimeMillis() + "";
tokebMap.put("appid", appId);
tokebMap.put("create_time", nowMills);
tokebMap.put("sign", SobotMD5Util.encode(appId + nowMills + appkey));
//获取 公司token
SobotHttpUtils.doGet(cancelTag, openApiHost.replace("/text", "") + "/api/get_token", 8000, tokebMap, null, new HttpBaseUtils.StringCallBack() {
@Override
public void onResponse(String response) {
TokenModel result = SobotGsonUtil.jsonToBean(response, TokenModel.class);
if (result != null && !SobotStringUtils.isEmpty(result.getRet_code()) && "000000".equals(result.getRet_code()) && result.getItem() != null && SobotStringUtils.isNoEmpty(result.getItem().getToken())) {
String ctoken = result.getItem().getToken();
Map<String, String> headerMap = new HashMap<>();
headerMap.put("token", ctoken);
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("loginUser", loginAcount); params.put("agent_email", loginAcount);
params.put("loginPwd", loginPwd); //获取 个人座席token
SobotHttpUtils.doPost(cancelTag, host + "/basic-login/serviceAppLogin/4", 8000, params, null, new HttpBaseUtils.StringCallBack() { SobotHttpUtils.doPost(cancelTag, openApiHost.replace("/text", "") + "/api/public/sso/5/login", 8000, params, headerMap, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
SobotCallBaseCode result = SobotGsonUtil.jsonToBean(response, SobotCallBaseCode.class); TokenModel result = SobotGsonUtil.jsonToBean(response, TokenModel.class);
if (result != null && !SobotStringUtils.isEmpty(result.getRetCode()) && "000000".equals(result.getRetCode()) && !SobotStringUtils.isEmpty(result.getItem())) { if (result != null && !SobotStringUtils.isEmpty(result.getRet_code()) && "000000".equals(result.getRet_code()) && result.getItem() != null && SobotStringUtils.isNoEmpty(result.getItem().getToken())) {
final LoginUserEntity userEntity = new LoginUserEntity(); final long login_time = System.currentTimeMillis();
userEntity.setLogin_time(System.currentTimeMillis()); final String token = result.getItem().getToken();
userEntity.setToken((String) result.getItem()); getuserEntityInfo(cancelTag, mContext, host, token, "", new SobotResultBlock() {
getLoginUserInfo(cancelTag, mContext, host, userEntity.getToken(), userEntity.getLanguage(), new SobotResultBlock() {
@Override @Override
public void resultBolok(SobotResultCode code, String msg, Object obj) { public void resultBolok(SobotResultCode code, String msg, Object obj) {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj; SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj;
if (serviceInfoModel != null) { if (serviceInfoModel != null) {
serviceInfoModel.setLogin_time(login_time);
serviceInfoModel.setToken(token);
serviceInfoModel.setLoginAccount(loginAcount);
if ((serviceInfoModel.getCallV6Flag() == 1 || SobotPermissionManager.isHasNewPermission(SobotPermissionManager.SCC)) && !SobotStringUtils.isEmpty(openApiHost)) { if ((serviceInfoModel.getCallV6Flag() == 1 || SobotPermissionManager.isHasNewPermission(SobotPermissionManager.SCC)) && !SobotStringUtils.isEmpty(openApiHost)) {
if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) {
//如果是v6呼叫 //如果是v6呼叫
String tempHost = openApiHost; String tempHost = openApiHost;
if (tempHost.contains("/text")) { if (tempHost.contains("/text")) {
tempHost = tempHost.replace("/text", ""); tempHost = tempHost.replace("/text", "");
} }
doAccessToken(cancelTag, tempHost, userEntity.getToken(), new SobotResultBlock() { final SobotServiceInfoModel tempServiceInfoModel = serviceInfoModel;
doAccessToken(cancelTag, tempHost, serviceInfoModel.getToken(), new SobotResultBlock() {
@Override @Override
public void resultBolok(SobotResultCode code, String msg, Object obj) { public void resultBolok(SobotResultCode code, String msg, Object obj) {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity; SobotServiceInfoModel tempUserEntity = tempServiceInfoModel;
if (obj != null && obj instanceof String && SobotStringUtils.isNoEmpty((String) obj)) {
String accessToken = (String) obj; String accessToken = (String) obj;
tempUserEntity.setAccess_token(accessToken); tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis()); //判断是否有对话功能
tempUserEntity.setLoginAccount(loginAcount); if (SobotPermissionManager.checkPermission(SobotPermissionApi.USER_PERMISSION_TYPE_TALK) && isAppOrOnlineLogin) {
tempUserEntity.setLoginPwd(loginPwd); doOnline(cancelTag, mContext, host, paramsMap, tempUserEntity, resultBlock);
setLoginUser(tempUserEntity); } else {
setServiceInfo(tempUserEntity);
SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, tempUserEntity);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
} }
}
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败 accessToken获取失败", null);
} }
} }
}
});
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
} }
} }
}
});
} else {
//判断是否有对话功能
if (SobotPermissionManager.checkPermission(SobotPermissionApi.USER_PERMISSION_TYPE_TALK) && isAppOrOnlineLogin) {
doOnline(cancelTag, mContext, host, paramsMap, serviceInfoModel, resultBlock);
} else { } else {
LoginUserEntity tempUserEntity = userEntity; setServiceInfo(serviceInfoModel);
tempUserEntity.setLogin_time(System.currentTimeMillis()); SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel);
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", serviceInfoModel);
}
} }
} }
} else { } else {
...@@ -395,7 +454,7 @@ public class SobotLoginTools { ...@@ -395,7 +454,7 @@ public class SobotLoginTools {
}); });
} else { } else {
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, (result != null && SobotStringUtils.isNoEmpty(result.getRetMsg())) ? result.getRetMsg() : "登录失败", ""); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, (result != null && SobotStringUtils.isNoEmpty(result.getRet_msg())) ? result.getRet_msg() : "登录失败", "");
} }
} }
} }
...@@ -412,82 +471,26 @@ public class SobotLoginTools { ...@@ -412,82 +471,26 @@ public class SobotLoginTools {
} }
}); });
} else { } else {
if (getToken().equals(logintoken)) {
SobotLogUtils.i("账号和token一样 token未过期 已经登录成功,不用重新登录");
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser()); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, (result != null && SobotStringUtils.isNoEmpty(result.getRet_msg())) ? result.getRet_msg() : "登录失败", "");
} }
return;
} }
final LoginUserEntity userEntity = new LoginUserEntity();
userEntity.setLogin_time(System.currentTimeMillis());
userEntity.setToken(logintoken);
getLoginUserInfo(cancelTag, mContext, host, userEntity.getToken(), userEntity.getLanguage(), new SobotResultBlock() {
@Override
public void resultBolok(SobotResultCode code, String msg, Object obj) {
if (code == SobotResultCode.CODE_SUCCEEDED) {
SobotServiceInfoModel serviceInfoModel = (SobotServiceInfoModel) obj;
if (serviceInfoModel != null) {
if ((serviceInfoModel.getCallV6Flag() == 1 || SobotPermissionManager.isHasNewPermission(SobotPermissionManager.SCC)) && !SobotStringUtils.isEmpty(openApiHost)) {
if (userEntity != null && !SobotStringUtils.isEmpty(userEntity.getToken())) {
//如果是v6呼叫
String tempHost = openApiHost;
if (tempHost.contains("/text")) {
tempHost = tempHost.replace("/text", "");
} }
doAccessToken(cancelTag, tempHost, userEntity.getToken(), new SobotResultBlock() {
@Override @Override
public void resultBolok(SobotResultCode code, String msg, Object obj) { public void onError(Exception e, String msg, int responseCode) {
if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity;
String accessToken = (String) obj;
tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
}
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
}
}
});
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
}
} else {
LoginUserEntity tempUserEntity = userEntity;
tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
} }
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
} }
} @Override
} else { public void inProgress(int progress) {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, SobotStringUtils.isNoEmpty(msg) ? msg : "登录失败", "");
}
}
} }
}); });
} }
}
// sdk 执行退出登录 // sdk 执行退出登录
public void logOut(Object cancelTag, String host, String loginAcount, final SobotResultBlock resultBlock) { public void logOut(Object cancelTag, String host, String loginAcount, final SobotResultBlock resultBlock) {
...@@ -504,7 +507,7 @@ public class SobotLoginTools { ...@@ -504,7 +507,7 @@ public class SobotLoginTools {
return; return;
} }
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("loginUser", loginAcount); params.put("userEntity", loginAcount);
Map<String, String> headerParams = new HashMap<>(); Map<String, String> headerParams = new HashMap<>();
headerParams.put("temp-id", getToken()); headerParams.put("temp-id", getToken());
headerParams.put("from", 2 + ""); headerParams.put("from", 2 + "");
...@@ -548,7 +551,7 @@ public class SobotLoginTools { ...@@ -548,7 +551,7 @@ public class SobotLoginTools {
* @param token * @param token
* @param resultBlock * @param resultBlock
*/ */
public void getLoginUserInfo(final Object cancelTag, final Context mContext, public void getuserEntityInfo(final Object cancelTag, final Context mContext,
final String host, String token, String language, final SobotResultBlock resultBlock) { final String host, String token, String language, final SobotResultBlock resultBlock) {
final String url = host + "/basic-config-service/consoleAuth/queryAppAgentMenus"; final String url = host + "/basic-config-service/consoleAuth/queryAppAgentMenus";
Map<String, String> headerMap = new HashMap<>(); Map<String, String> headerMap = new HashMap<>();
...@@ -570,8 +573,15 @@ public class SobotLoginTools { ...@@ -570,8 +573,15 @@ public class SobotLoginTools {
SobotServiceInfoModel serviceInfoModel = SobotGsonUtil.jsonToBean(resonseObj.optString("item"), SobotServiceInfoModel.class); SobotServiceInfoModel serviceInfoModel = SobotGsonUtil.jsonToBean(resonseObj.optString("item"), SobotServiceInfoModel.class);
List<ServiceFunctionVoModel> functions = new ArrayList<>(); List<ServiceFunctionVoModel> functions = new ArrayList<>();
JSONArray items = resonseObj.optJSONArray("items"); JSONArray items = resonseObj.optJSONArray("items");
getListByObj(functions, items); getListByObj(functions, items);//添加新版权限
if (serviceInfoModel != null) { if (serviceInfoModel != null) {
if (serviceInfoModel.getFunctionStr() != null && serviceInfoModel.getFunctionStr().size() > 0) {
for (int i = 0; i < serviceInfoModel.getFunctionStr().size(); i++) {
ServiceFunctionVoModel functionVoModel = serviceInfoModel.getFunctionStr().get(i);
functionVoModel.setCheckedCode(functionVoModel.isChecked() ? 1 : 0);
functions.add(functionVoModel);//添加旧版权限
}
}
if (serviceInfoModel.getGlobalPermissions() != null) { if (serviceInfoModel.getGlobalPermissions() != null) {
//全局权限 //全局权限
for (int i = 0; i < serviceInfoModel.getGlobalPermissions().size(); i++) { for (int i = 0; i < serviceInfoModel.getGlobalPermissions().size(); i++) {
...@@ -580,13 +590,13 @@ public class SobotLoginTools { ...@@ -580,13 +590,13 @@ public class SobotLoginTools {
functionVoModel.setCode(serviceInfoModel.getGlobalPermissions().get(i)); functionVoModel.setCode(serviceInfoModel.getGlobalPermissions().get(i));
functions.add(functionVoModel); functions.add(functionVoModel);
} }
} }
} }
serviceInfoModel.setFunctionStr(functions); serviceInfoModel.setFunctionStr(functions);
//保存在数据库 //权限保存入库
FunctionManager.getInstance().setFunctionVos(functions);
//先保存一次
setServiceInfo(serviceInfoModel); setServiceInfo(serviceInfoModel);
SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel);
if (resultBlock != null) { if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "获取成功", serviceInfoModel); resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "获取成功", serviceInfoModel);
} }
...@@ -689,4 +699,74 @@ public class SobotLoginTools { ...@@ -689,4 +699,74 @@ public class SobotLoginTools {
}); });
} }
// 如果是智齿客服APP 或者客服SDK 并且有对话模块,需要请求在线逻辑接口
public void doOnline(final Object cancelTag, final Context context, final String host, Map<String, Object> params, final SobotServiceInfoModel infoModel, final SobotResultBlock resultBlock) {
if (infoModel != null) {
Map<String, String> headers = new HashMap<>();
headers.put("token", SobotStringUtils.checkStringIsNull(infoModel.getToken()));
headers.put("language", SobotStringUtils.checkStringIsNull(infoModel.getLanguage()));
SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/appLogin", 8000, params, headers, new HttpBaseUtils.StringCallBack() {
@Override
public void onResponse(String result) {
if (!SobotStringUtils.isEmpty(result)) {
final SobotBaseCode<OnlineUserEntity> baseModel = SobotGsonUtil.jsonToBeans(result, new com.sobot.gson.reflect.TypeToken<SobotBaseCode<OnlineUserEntity>>() {
}.getType());
if (baseModel != null) {
//登录接口和获取坐席信息权限接口都成功才算真正登录成功
if ("1".equals(baseModel.getCode()) && baseModel.getData() != null) {
OnlineUserEntity userEntity = baseModel.getData();
SobotServiceInfoModel tempServiceInfoModel = infoModel;
tempServiceInfoModel.setPu(SobotStringUtils.checkStringIsNull(userEntity.getPu()));
tempServiceInfoModel.setPuid(SobotStringUtils.checkStringIsNull(userEntity.getPuid()));
tempServiceInfoModel.setTempId(SobotStringUtils.checkStringIsNull(userEntity.getTempId()));
tempServiceInfoModel.setWslinkDefault(SobotStringUtils.checkStringIsNull(userEntity.getWslinkDefault()));
tempServiceInfoModel.setImFlag(userEntity.getImFlag());
tempServiceInfoModel.setCenterNumber(SobotStringUtils.checkStringIsNull(userEntity.getCenterNumber()));
tempServiceInfoModel.setKbVersion(SobotStringUtils.checkStringIsNull(userEntity.getKbVersion()));
tempServiceInfoModel.setRobotVersion(SobotStringUtils.checkStringIsNull(userEntity.getRobotVersion()));
tempServiceInfoModel.setOnlineVersion(SobotStringUtils.checkStringIsNull(userEntity.getOnlineVersion()));
tempServiceInfoModel.setBlackFunction(userEntity.getBlackFunction());
tempServiceInfoModel.setStatus(userEntity.getStatus());
tempServiceInfoModel.setFuseWork(userEntity.getFuseWork());
tempServiceInfoModel.setWslinkBak(userEntity.getWslinkBak());
tempServiceInfoModel.setTopFlag(userEntity.getTopFlag());
tempServiceInfoModel.setTransferAuditFlag(userEntity.getTransferAuditFlag());
tempServiceInfoModel.setSortFlag(userEntity.getSortFlag());
tempServiceInfoModel.setTransferFunction(userEntity.getTransferFunction());
setServiceInfo(tempServiceInfoModel);
SobotSharedPreferencesUtil.getInstance(context).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, tempServiceInfoModel);
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempServiceInfoModel);
}
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, baseModel.getMsg(), baseModel.getCode());
}
}
} else {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "appLogin 接口请求结果为空,登录失败", null);
}
}
}
}
@Override
public void onError(Exception e, String msg, int responseCode) {
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
}
@Override
public void inProgress(int progress) {
}
});
} else {
}
}
} }
package com.sobot.common.login.db;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.utils.SobotGlobalContext;
import java.util.List;
/**
* 权限信息 操作类
*/
public class FunctionManager extends SobotCommonDao<ServiceFunctionVoModel> {
private FunctionManager(Context context) {
super(new SobotCommonDBHelper(context));
}
//volatile关键字确保多线程下正确处理
private volatile static FunctionManager mInstance;
public static FunctionManager getInstance() {
//第一次判空
if (mInstance == null) {
//进入同步区域
synchronized (FunctionManager.class) {
//第二次判空
if (mInstance == null) {
mInstance = new FunctionManager(SobotGlobalContext.getAppContext());
}
}
}
return mInstance;
}
@Override
public String getTableName() {
return SobotCommonDBHelper.TABLE_LOGIN_USER_FUN_INFO;
}
@Override
public void unInit() {
}
@SuppressLint("Range")
@Override
public ServiceFunctionVoModel parseCursorToBean(Cursor cursor) {
ServiceFunctionVoModel model = new ServiceFunctionVoModel();
model.setId(cursor.getString(cursor.getColumnIndex("id")));
model.setCheckedCode(cursor.getInt(cursor.getColumnIndex("checkedCode")));
model.setCode(cursor.getString(cursor.getColumnIndex("code")));
return model;
}
@Override
public ContentValues getContentValues(ServiceFunctionVoModel functionVoModel) {
ContentValues contentValues = new ContentValues();
contentValues.put("id", functionVoModel.getId());
contentValues.put("code", functionVoModel.getCode());
contentValues.put("checkedCode", functionVoModel.getCheckedCode());
return contentValues;
}
public void setFunctionVos(List<ServiceFunctionVoModel> list) {
deleteAll();
insert(list);
}
/**
* 获取权限信息类
*/
public List<ServiceFunctionVoModel> getFunctionVos() {
List<ServiceFunctionVoModel> list = query(null, null, null, null, null, null, null);
return list;
}
}
package com.sobot.common.login.db;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.sobot.common.login.model.LoginUserEntity;
import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.gson.SobotGsonUtil;
import com.sobot.utils.SobotStringUtils;
import java.util.List;
import java.util.Map;
/**
* 登录用户信息 操作类
*/
public class LoginUserManager extends SobotCommonDao<LoginUserEntity> {
private LoginUserManager(Context context) {
super(new SobotCommonDBHelper(context));
}
//volatile关键字确保多线程下正确处理
private volatile static LoginUserManager mInstance;
public static LoginUserManager getInstance() {
//第一次判空
if (mInstance == null) {
//进入同步区域
synchronized (LoginUserManager.class) {
//第二次判空
if (mInstance == null) {
mInstance = new LoginUserManager(SobotGlobalContext.getAppContext());
}
}
}
return mInstance;
}
@Override
public String getTableName() {
return SobotCommonDBHelper.TABLE_LOGIN_USER;
}
@Override
public void unInit() {
}
@SuppressLint("Range")
@Override
public LoginUserEntity parseCursorToBean(Cursor cursor) {
LoginUserEntity model = new LoginUserEntity();
model.setTempId(cursor.getString(cursor.getColumnIndex("tempId")));
model.setNickName(cursor.getString(cursor.getColumnIndex("nickName")));
model.setStaffName(cursor.getString(cursor.getColumnIndex("staffName")));
model.setMaxServiceCount(cursor.getInt(cursor.getColumnIndex("maxServiceCount")));
model.setBlackFunction(cursor.getInt(cursor.getColumnIndex("blackFunction")));
model.setTransferFunction(cursor.getInt(cursor.getColumnIndex("transferFunction")));
String ticketFunction = cursor.getString(cursor.getColumnIndex("ticketFunction"));
if (!SobotStringUtils.isEmpty(ticketFunction)){
Map<String, Boolean> map = SobotGsonUtil.jsonToMaps(ticketFunction);
model.setTicketFunction(map);
}
model.setFace(cursor.getString(cursor.getColumnIndex("face")));
model.setCompanyName(cursor.getString(cursor.getColumnIndex("companyName")));
model.setAppKey(cursor.getString(cursor.getColumnIndex("appKey")));
model.setSid(cursor.getString(cursor.getColumnIndex("sid")));
model.setPu(cursor.getString(cursor.getColumnIndex("pu")));
model.setPuid(cursor.getString(cursor.getColumnIndex("puid")));
model.setToken(cursor.getString(cursor.getColumnIndex("token")));
model.setCusRoleName(cursor.getString(cursor.getColumnIndex("cusRoleName")));
model.setAid(cursor.getString(cursor.getColumnIndex("aid")));
model.setCenterNumber(cursor.getString(cursor.getColumnIndex("centerNumber")));
model.setAccountStatus(cursor.getString(cursor.getColumnIndex("accountStatus")));
model.setImFlag(cursor.getInt(cursor.getColumnIndex("imFlag")));
model.setCusRoleId(cursor.getInt(cursor.getColumnIndex("cusRoleId")));
model.setStatus(cursor.getInt(cursor.getColumnIndex("status")));
model.setTopFlag(cursor.getInt(cursor.getColumnIndex("topFlag")));
model.setSortFlag(cursor.getInt(cursor.getColumnIndex("sortFlag")));
model.setFuseWork(cursor.getInt(cursor.getColumnIndex("fuseWork")));
model.setCallV6Flag(cursor.getInt(cursor.getColumnIndex("callV6Flag")));
model.setCallV1Flag(cursor.getInt(cursor.getColumnIndex("callV1Flag")));
model.setTransferAuditFlag(cursor.getInt(cursor.getColumnIndex("transferAuditFlag")));
model.setKbVersion(cursor.getInt(cursor.getColumnIndex("kbVersion")) + "");
model.setCompanyId(cursor.getString(cursor.getColumnIndex("companyId")));
model.setLanguage(cursor.getString(cursor.getColumnIndex("local_language")));
model.setAccess_token(cursor.getString(cursor.getColumnIndex(LoginUserEntity.ACCESS_TOKEN)));
model.setLogin_time(cursor.getLong(cursor.getColumnIndex(LoginUserEntity.LOGIN_TIME)));
model.setLoginAccount(cursor.getString(cursor.getColumnIndex("login_account")));
model.setLoginPwd(cursor.getString(cursor.getColumnIndex("login_pwd")));
model.setWslinkDefault(cursor.getString(cursor.getColumnIndex("wslinkDefault")));
return model;
}
@Override
public ContentValues getContentValues(LoginUserEntity userAccount) {
ContentValues contentValues = new ContentValues();
contentValues.put("_id", 8888);
contentValues.put("tempId", userAccount.getTempId());
contentValues.put("nickName", userAccount.getNickName());
contentValues.put("staffName", userAccount.getStaffName());
contentValues.put("maxServiceCount", userAccount.getMaxServiceCount());
contentValues.put("blackFunction", userAccount.getBlackFunction());
contentValues.put("transferFunction", userAccount.getTransferFunction());
if (userAccount.getTicketFunction() != null) {
contentValues.put("ticketFunction", SobotGsonUtil.beanToJson(userAccount.getTicketFunction()));
}
contentValues.put("face", userAccount.getFace());
contentValues.put("companyName", userAccount.getCompanyName());
contentValues.put("appKey", userAccount.getAppKey());
contentValues.put("sid", userAccount.getSid());
contentValues.put("pu", userAccount.getPu());
contentValues.put("puid", userAccount.getPuid());
contentValues.put("token", userAccount.getToken());
contentValues.put("cusRoleName", userAccount.getCusRoleName());
contentValues.put("aid", userAccount.getAid());
contentValues.put("centerNumber", userAccount.getCenterNumber());
contentValues.put("accountStatus", userAccount.getAccountStatus());
contentValues.put("imFlag", userAccount.isImFlag());
contentValues.put("cusRoleId", userAccount.getCusRoleId());
contentValues.put("status", userAccount.getStatus());
contentValues.put("topFlag", userAccount.getTopFlag());
contentValues.put("sortFlag", userAccount.getSortFlag());
contentValues.put("fuseWork", userAccount.getFuseWork());
contentValues.put("callV6Flag", userAccount.getCallV6Flag());
contentValues.put("callV1Flag", userAccount.getCallV1Flag());
contentValues.put("transferAuditFlag", userAccount.getTransferAuditFlag());
int kbVersion = 1;
if ("6".contains(SobotStringUtils.checkStringIsNull(userAccount.getKbVersion()))) {
kbVersion = 6;
}
contentValues.put("kbVersion", kbVersion);
contentValues.put("companyId", userAccount.getCompanyId());
contentValues.put("local_language", userAccount.getLanguage());
contentValues.put(LoginUserEntity.ACCESS_TOKEN, userAccount.getAccess_token());
contentValues.put(LoginUserEntity.LOGIN_TIME, userAccount.getLogin_time());
contentValues.put("login_account",userAccount.getLoginAccount());
contentValues.put("login_pwd",userAccount.getLoginPwd());
contentValues.put("wslinkDefault",userAccount.getWslinkDefault());
return contentValues;
}
public void saveUser(LoginUserEntity user) {
insert(user);
}
/**
* 获取最近用户记录 按日期倒序
*/
public LoginUserEntity getCurUser() {
List<LoginUserEntity> list = query(null, null, null, null, null, null, null);
return list.size() > 0 ? list.get(0) : null;
}
}
...@@ -6,7 +6,6 @@ import android.content.ContentValues; ...@@ -6,7 +6,6 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.login.model.SobotServiceInfoModel; import com.sobot.common.login.model.SobotServiceInfoModel;
import com.sobot.common.utils.SobotGlobalContext; import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.gson.SobotGsonUtil; import com.sobot.gson.SobotGsonUtil;
...@@ -30,7 +29,7 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> { ...@@ -30,7 +29,7 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> {
//第一次判空 //第一次判空
if (mInstance == null) { if (mInstance == null) {
//进入同步区域 //进入同步区域
synchronized (LoginUserManager.class) { synchronized (ServiceInfoManager.class) {
//第二次判空 //第二次判空
if (mInstance == null) { if (mInstance == null) {
mInstance = new ServiceInfoManager(SobotGlobalContext.getAppContext()); mInstance = new ServiceInfoManager(SobotGlobalContext.getAppContext());
...@@ -42,7 +41,7 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> { ...@@ -42,7 +41,7 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> {
@Override @Override
public String getTableName() { public String getTableName() {
return SobotCommonDBHelper.TABLE_SERVICE_INFO; return SobotCommonDBHelper.TABLE_LOGIN_USER_INFO;
} }
@Override @Override
...@@ -54,22 +53,44 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> { ...@@ -54,22 +53,44 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> {
@Override @Override
public SobotServiceInfoModel parseCursorToBean(Cursor cursor) { public SobotServiceInfoModel parseCursorToBean(Cursor cursor) {
SobotServiceInfoModel model = new SobotServiceInfoModel(); SobotServiceInfoModel model = new SobotServiceInfoModel();
model.setTempId(cursor.getString(cursor.getColumnIndex("tempId")));
model.setServiceNick(cursor.getString(cursor.getColumnIndex("nickName")));
model.setMaxAccept(cursor.getInt(cursor.getColumnIndex("maxAccept")));
model.setBlackFunction(cursor.getInt(cursor.getColumnIndex("blackFunction")));
model.setTransferFunction(cursor.getInt(cursor.getColumnIndex("transferFunction")));
model.setCompanyName(cursor.getString(cursor.getColumnIndex("companyName")));
model.setPu(cursor.getString(cursor.getColumnIndex("pu")));
model.setPuid(cursor.getString(cursor.getColumnIndex("puid")));
model.setToken(cursor.getString(cursor.getColumnIndex("token")));
model.setCusRoleName(cursor.getString(cursor.getColumnIndex("cusRoleName")));
model.setCenterNumber(cursor.getString(cursor.getColumnIndex("centerNumber")));
model.setAccountStatus(cursor.getString(cursor.getColumnIndex("accountStatus")));
model.setImFlag(cursor.getInt(cursor.getColumnIndex("imFlag")));
model.setCusRoleId(cursor.getInt(cursor.getColumnIndex("cusRoleId")));
model.setStatus(cursor.getInt(cursor.getColumnIndex("status")));
model.setTopFlag(cursor.getInt(cursor.getColumnIndex("topFlag")));
model.setSortFlag(cursor.getInt(cursor.getColumnIndex("sortFlag")));
model.setFuseWork(cursor.getInt(cursor.getColumnIndex("fuseWork")));
model.setCallV6Flag(cursor.getInt(cursor.getColumnIndex("callV6Flag")));
model.setCallV1Flag(cursor.getInt(cursor.getColumnIndex("callV1Flag")));
model.setTransferAuditFlag(cursor.getInt(cursor.getColumnIndex("transferAuditFlag")));
model.setKbVersion(cursor.getInt(cursor.getColumnIndex("kbVersion")) + "");
model.setRobotVersion(cursor.getInt(cursor.getColumnIndex("robotVersion")) + "");
model.setOnlineVersion(cursor.getInt(cursor.getColumnIndex("onlineVersion")) + "");
model.setCompanyId(cursor.getString(cursor.getColumnIndex("companyId")));
model.setLanguage(cursor.getString(cursor.getColumnIndex("local_language")));
model.setAccess_token(cursor.getString(cursor.getColumnIndex(SobotServiceInfoModel.ACCESS_TOKEN)));
model.setLogin_time(cursor.getLong(cursor.getColumnIndex(SobotServiceInfoModel.LOGIN_TIME)));
model.setLoginAccount(cursor.getString(cursor.getColumnIndex("login_account")));
model.setLoginPwd(cursor.getString(cursor.getColumnIndex("login_pwd")));
model.setWslinkDefault(cursor.getString(cursor.getColumnIndex("wslinkDefault")));
model.setServiceId(cursor.getString(cursor.getColumnIndex("serviceId"))); model.setServiceId(cursor.getString(cursor.getColumnIndex("serviceId")));
model.setServiceName(cursor.getString(cursor.getColumnIndex("serviceName"))); model.setServiceName(cursor.getString(cursor.getColumnIndex("serviceName")));
model.setCusRoleId(cursor.getString(cursor.getColumnIndex("cusRoleId")));
model.setCusRoleName(cursor.getString(cursor.getColumnIndex("cusRoleName")));
model.setServiceLanguage(cursor.getString(cursor.getColumnIndex("serviceLanguage"))); model.setServiceLanguage(cursor.getString(cursor.getColumnIndex("serviceLanguage")));
model.setNewBossSwitch(cursor.getInt(cursor.getColumnIndex("newBossSwitch"))); model.setNewBossSwitch(cursor.getInt(cursor.getColumnIndex("newBossSwitch")));
model.setRegion(cursor.getInt(cursor.getColumnIndex("region"))); model.setRegion(cursor.getInt(cursor.getColumnIndex("region")));
String functionStr = cursor.getString(cursor.getColumnIndex("functionStr"));
if (!SobotStringUtils.isEmpty(functionStr)) {
List<ServiceFunctionVoModel> list = SobotGsonUtil.jsonToBeans(functionStr, new TypeToken<List<ServiceFunctionVoModel>>() {
}.getType());
model.setFunctionStr(list);
}
model.setCompanyId(cursor.getString(cursor.getColumnIndex("companyId")));
model.setCallV6Flag(cursor.getInt(cursor.getColumnIndex("callV6Flag")));
model.setLanguage(cursor.getString(cursor.getColumnIndex("language")));
model.setTimezone(cursor.getString(cursor.getColumnIndex("timezone"))); model.setTimezone(cursor.getString(cursor.getColumnIndex("timezone")));
model.setTimezoneId(cursor.getString(cursor.getColumnIndex("timezoneId"))); model.setTimezoneId(cursor.getString(cursor.getColumnIndex("timezoneId")));
model.setPhoneNo(cursor.getString(cursor.getColumnIndex("phoneNo"))); model.setPhoneNo(cursor.getString(cursor.getColumnIndex("phoneNo")));
...@@ -85,19 +106,49 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> { ...@@ -85,19 +106,49 @@ public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> {
@Override @Override
public ContentValues getContentValues(SobotServiceInfoModel infoModel) { public ContentValues getContentValues(SobotServiceInfoModel infoModel) {
ContentValues contentValues = new ContentValues(); ContentValues contentValues = new ContentValues();
contentValues.put("_id", 8888);
contentValues.put("tempId", infoModel.getTempId());
contentValues.put("serviceNick", infoModel.getServiceNick());
contentValues.put("maxAccept", infoModel.getMaxAccept());
contentValues.put("blackFunction", infoModel.getBlackFunction());
contentValues.put("transferFunction", infoModel.getTransferFunction());
contentValues.put("faceImg", infoModel.getFaceImg());
contentValues.put("companyName", infoModel.getCompanyName());
contentValues.put("pu", infoModel.getPu());
contentValues.put("puid", infoModel.getPuid());
contentValues.put("token", infoModel.getToken());
contentValues.put("cusRoleName", infoModel.getCusRoleName());
contentValues.put("centerNumber", infoModel.getCenterNumber());
contentValues.put("accountStatus", infoModel.getAccountStatus());
contentValues.put("imFlag", infoModel.isImFlag());
contentValues.put("cusRoleId", infoModel.getCusRoleId());
contentValues.put("status", infoModel.getStatus());
contentValues.put("topFlag", infoModel.getTopFlag());
contentValues.put("sortFlag", infoModel.getSortFlag());
contentValues.put("fuseWork", infoModel.getFuseWork());
contentValues.put("callV6Flag", infoModel.getCallV6Flag());
contentValues.put("callV1Flag", infoModel.getCallV1Flag());
contentValues.put("transferAuditFlag", infoModel.getTransferAuditFlag());
int kbVersion = 1;
if ("6".contains(SobotStringUtils.checkStringIsNull(infoModel.getKbVersion()))) {
kbVersion = 6;
}
contentValues.put("kbVersion", kbVersion);
contentValues.put("robotVersion", infoModel.getRobotVersion());
contentValues.put("onlineVersion", infoModel.getOnlineVersion());
contentValues.put("companyId", infoModel.getCompanyId());
contentValues.put("local_language", infoModel.getLanguage());
contentValues.put(SobotServiceInfoModel.ACCESS_TOKEN, infoModel.getAccess_token());
contentValues.put(SobotServiceInfoModel.LOGIN_TIME, infoModel.getLogin_time());
contentValues.put("login_account", infoModel.getLoginAccount());
contentValues.put("login_pwd", infoModel.getLoginPwd());
contentValues.put("wslinkDefault", infoModel.getWslinkDefault());
contentValues.put("serviceId", infoModel.getServiceId()); contentValues.put("serviceId", infoModel.getServiceId());
contentValues.put("serviceName", infoModel.getServiceName()); contentValues.put("serviceName", infoModel.getServiceName());
contentValues.put("cusRoleId", infoModel.getCusRoleId());
contentValues.put("cusRoleName", infoModel.getCusRoleName());
contentValues.put("serviceLanguage", infoModel.getServiceLanguage()); contentValues.put("serviceLanguage", infoModel.getServiceLanguage());
contentValues.put("newBossSwitch", infoModel.getNewBossSwitch()); contentValues.put("newBossSwitch", infoModel.getNewBossSwitch());
contentValues.put("region", infoModel.getRegion()); contentValues.put("region", infoModel.getRegion());
if (!SobotStringUtils.isEmpty(infoModel.getFunctionStr())) {
contentValues.put("functionStr", SobotGsonUtil.beanToJson(infoModel.getFunctionStr()));
}
contentValues.put("companyId", infoModel.getCompanyId());
contentValues.put("callV6Flag", infoModel.getCallV6Flag());
contentValues.put("language", infoModel.getLanguage());
contentValues.put("timezone", infoModel.getTimezone()); contentValues.put("timezone", infoModel.getTimezone());
contentValues.put("timezoneId", infoModel.getTimezoneId()); contentValues.put("timezoneId", infoModel.getTimezoneId());
contentValues.put("phoneNo", infoModel.getPhoneNo()); contentValues.put("phoneNo", infoModel.getPhoneNo());
......
...@@ -4,7 +4,6 @@ import android.content.Context; ...@@ -4,7 +4,6 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import com.sobot.common.login.model.LoginUserEntity;
import com.sobot.common.login.model.SobotServiceInfoModel; import com.sobot.common.login.model.SobotServiceInfoModel;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
...@@ -17,10 +16,12 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -17,10 +16,12 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
private static final String DB_CACHE_NAME = "sobot_common.db"; private static final String DB_CACHE_NAME = "sobot_common.db";
// private static final int DB_CACHE_VERSION = 1; // private static final int DB_CACHE_VERSION = 1;
private static final int DB_CACHE_VERSION = 5; private static final int DB_CACHE_VERSION = 6;
static final String TABLE_LOGIN_USER = "login_user"; static final String TABLE_LOGIN_USER = "login_user";//废弃
static final String TABLE_SOBOT_HOST = "sobot_host"; static final String TABLE_SOBOT_HOST = "sobot_host";
static final String TABLE_SERVICE_INFO = "sobot_service"; static final String TABLE_SERVICE_INFO = "sobot_service";//废弃
static final String TABLE_LOGIN_USER_INFO = "login_user_info";//登录信息表
static final String TABLE_LOGIN_USER_FUN_INFO = "login_user_fun_info";//权限表
static final Lock lock = new ReentrantLock(); static final Lock lock = new ReentrantLock();
...@@ -69,7 +70,6 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -69,7 +70,6 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
"transferFunction INTEGER DEFAULT 1, " + "transferFunction INTEGER DEFAULT 1, " +
"face varchar(300), " + "face varchar(300), " +
"companyName varchar(300), " + "companyName varchar(300), " +
"appKey varchar(40), " +
"sid varchar(40), " + "sid varchar(40), " +
"pu varchar(40), " + "pu varchar(40), " +
"puid varchar(40), " + "puid varchar(40), " +
...@@ -130,10 +130,10 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -130,10 +130,10 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
switch (oldVersion) { switch (oldVersion) {
case 1: case 1:
String sql = "ALTER TABLE " + TABLE_LOGIN_USER String sql = "ALTER TABLE " + TABLE_LOGIN_USER
+ " ADD COLUMN " + LoginUserEntity.ACCESS_TOKEN + " VARCHAR(700)"; + " ADD COLUMN " + SobotServiceInfoModel.ACCESS_TOKEN + " VARCHAR(700)";
db.execSQL(sql); // 登录表添加ACCESS_TOKEN db.execSQL(sql); // 登录表添加ACCESS_TOKEN
String sql1 = "ALTER TABLE " + TABLE_LOGIN_USER String sql1 = "ALTER TABLE " + TABLE_LOGIN_USER
+ " ADD COLUMN " + LoginUserEntity.LOGIN_TIME + " INTEGER"; + " ADD COLUMN " + SobotServiceInfoModel.LOGIN_TIME + " INTEGER";
db.execSQL(sql1); // 登录表添加登录时间 db.execSQL(sql1); // 登录表添加登录时间
break; break;
case 2: case 2:
...@@ -157,6 +157,62 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -157,6 +157,62 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
+ " ADD COLUMN wslinkDefault VARCHAR(40)"; + " ADD COLUMN wslinkDefault VARCHAR(40)";
db.execSQL(sql6); // 登录表添加通道信息2 db.execSQL(sql6); // 登录表添加通道信息2
break; break;
case 5:
// 删除表的SQL语句
String LOGIN_USER_TABLE = "DROP TABLE IF EXISTS " + TABLE_LOGIN_USER;
db.execSQL(LOGIN_USER_TABLE);
// 删除表的SQL语句
String SERVICE_INFO_TABLE = "DROP TABLE IF EXISTS " + TABLE_SERVICE_INFO;
db.execSQL(SERVICE_INFO_TABLE);
String sql7 = "CREATE TABLE IF NOT EXISTS " + TABLE_LOGIN_USER_INFO + "(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"tempId VARCHAR(80)," +
"serviceNick VARCHAR(300)," +
"faceImg VARCHAR(300)," +
"maxAccept INTEGER," +
"blackFunction INTEGER DEFAULT 1," +
"transferFunction INTEGER DEFAULT 1, " +
"companyName VARCHAR(300), " +
"pu VARCHAR(40), " +
"puid VARCHAR(40), " +
"token VARCHAR(500), " +
"cusRoleName VARCHAR(200), " +
"centerNumber VARCHAR(40), " +
"accountStatus VARCHAR(2), " +
"imFlag INTEGER, " +
"cusRoleId INTEGER, " +
"status INTEGER DEFAULT 1, " +
"topFlag INTEGER, " +
"sortFlag INTEGER , " +
"fuseWork INTEGER , " +
"callV6Flag INTEGER , " +
"callV1Flag INTEGER , " +
"transferAuditFlag INTEGER , " +
"kbVersion INTEGER , " +
"robotVersion INTEGER , " +
"onlineVersion INTEGER , " +
"local_language VARCHAR(10) , " +
"serviceId VARCHAR(40)," +
"serviceName VARCHAR(600)," +
"newBossSwitch INTEGER," +
"region INTEGER," +
"serviceLanguage VARCHAR(12)," +
"phoneNo VARCHAR(20)," +
"globalPermissions VARCHAR(300)," +
"access_token VARCHAR(700)," +
"login_time INTEGER," +
"login_account VARCHAR(40)," +
"login_pwd VARCHAR(40)," +
"wslinkDefault VARCHAR(40)," +
"timezone VARCHAR(15)," +
"timezoneId VARCHAR(30)," +
"companyId VARCHAR(40))";
db.execSQL(sql7);
String sql8 = "CREATE TABLE IF NOT EXISTS " + TABLE_LOGIN_USER_FUN_INFO + "(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"id VARCHAR(20)," +
"checkedCode INTEGER," +
"code VARCHAR(40))";
db.execSQL(sql8);
break;
default: default:
break; break;
} }
......
package com.sobot.common.login.model;
import com.sobot.gson.annotations.Expose;
import com.sobot.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class LoginUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String loginAccount; //登录账号
private String loginPwd; //登录密码
private String tempId; //客服temp-id
private String nickName; //客服昵称
private String staffName; //客服名称
private int maxServiceCount; //最大接待量
private int blackFunction = 1; //是否有拉黑权限 0 没有 1 有
private int transferFunction = 1; //是否有转接权限 0 没有 1 有
private String face; //头像url
private int status; //账号状态 1正常0登录邮箱或密码不正确 2用户已在pc端登录
private String companyId;//sysNum
private String appKey;
private String sid;
private String pu;
private String puid;
private String token;
private int imFlag;//0是工单客服 1是在线客服
private int cusRoleId;//身份id 3333:超级管理员;1111:在线客服;2222:管理员
private String cusRoleName;//身份名称 客服身份
private String aid;//userid
private int topFlag;//星标置顶 0不置顶 1置顶
private int sortFlag;//会话排序 0 按接入顺序 1 按新消息时间
private String centerNumber;//如果不为空,说明开通了呼叫功能
private int fuseWork;//1-存在融合工作台,使用新版服务总计 0-没有融合工作台
/**
* 1 账号开通v6;其它是v1
*/
private int callV6Flag;
private int callV1Flag;//是否是V1,方便做那个呼叫v1/v6切换的功能
private Map<String, Boolean> ticketFunction;//1222 可删除工单 ;1223 可删除工单回复;1224 可关闭工单; 1225 可激活工单 1230 工单操作历史权限
// 1231-工单状态 ; 1611-查看App客户中心
private int transferAuditFlag;//转接审核开关 0关闭 1开启
private String companyName;//公司名称
private String accountStatus;//企业账号版本:旗舰版
private String kbVersion;//智能回复,查询版本v6/v1
private String language;//国际化指定语言 3.1.3新增 为空时,默认中文
private String access_token;//呼叫v6
public static final String ACCESS_TOKEN = "access_token";//呼叫v6 accessToken
private long login_time;//登录时间戳
public static final String LOGIN_TIME = "login_time";
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getAccountStatus() {
return accountStatus;
}
public void setAccountStatus(String accountStatus) {
this.accountStatus = accountStatus;
}
@Expose
@SerializedName("wslink.bak")
private List<String> wslinkBak;//通道地址
@Expose
@SerializedName("wslink.default")
private String wslinkDefault;//通道默认地址
public String getAid() {
return aid;
}
public void setAid(String aid) {
this.aid = aid;
}
public int getBlackFunction() {
return blackFunction;
}
public void setBlackFunction(int blackFunction) {
this.blackFunction = blackFunction;
}
public int getTransferFunction() {
return transferFunction;
}
public void setTransferFunction(int transferFunction) {
this.transferFunction = transferFunction;
}
public List<String> getWslinkBak() {
return wslinkBak;
}
public void setWslinkBak(List<String> wslinkBak) {
this.wslinkBak = wslinkBak;
}
public String getWslinkDefault() {
return wslinkDefault;
}
public void setWslinkDefault(String wslinkDefault) {
this.wslinkDefault = wslinkDefault;
}
public int getCusRoleId() {
return cusRoleId;
}
public void setCusRoleId(int cusRoleId) {
this.cusRoleId = cusRoleId;
}
public String getCusRoleName() {
return cusRoleName;
}
public void setCusRoleName(String cusRoleName) {
this.cusRoleName = cusRoleName;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public int isImFlag() {
return imFlag;
}
public void setImFlag(int imFlag) {
this.imFlag = imFlag;
}
public String getPu() {
return pu;
}
public void setPu(String pu) {
this.pu = pu;
}
public String getPuid() {
return puid;
}
public void setPuid(String puid) {
this.puid = puid;
}
public String getTempId() {
return tempId;
}
public void setTempId(String tempId) {
this.tempId = tempId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public int getMaxServiceCount() {
return maxServiceCount;
}
public void setMaxServiceCount(int maxServiceCount) {
this.maxServiceCount = maxServiceCount;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
public int getTopFlag() {
return topFlag;
}
public void setTopFlag(int topFlag) {
this.topFlag = topFlag;
}
public int getSortFlag() {
return sortFlag;
}
public void setSortFlag(int sortFlag) {
this.sortFlag = sortFlag;
}
public String getCenterNumber() {
return centerNumber;
}
public void setCenterNumber(String centerNumber) {
this.centerNumber = centerNumber;
}
public Map<String, Boolean> getTicketFunction() {
return ticketFunction;
}
public void setTicketFunction(Map<String, Boolean> ticketFunction) {
this.ticketFunction = ticketFunction;
}
public boolean getTransferAuditFlag() {
return transferAuditFlag == 1 ? true : false;
}
public void setTransferAuditFlag(int transferAuditFlag) {
this.transferAuditFlag = transferAuditFlag;
}
public int getFuseWork() {
return fuseWork;
}
public void setFuseWork(int fuseWork) {
this.fuseWork = fuseWork;
}
public int getCallV6Flag() {
return callV6Flag;
}
public void setCallV6Flag(int callV6Flag) {
this.callV6Flag = callV6Flag;
}
public int getCallV1Flag() {
return callV1Flag;
}
public void setCallV1Flag(int callV1Flag) {
this.callV1Flag = callV1Flag;
}
public String getKbVersion() {
return kbVersion;
}
public void setKbVersion(String kbVersion) {
this.kbVersion = kbVersion;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getAccess_token() {
return access_token;
}
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public long getLogin_time() {
return login_time;
}
public void setLogin_time(long login_time) {
this.login_time = login_time;
}
public String getLoginAccount() {
return loginAccount;
}
public void setLoginAccount(String loginAccount) {
this.loginAccount = loginAccount;
}
public String getLoginPwd() {
return loginPwd;
}
public void setLoginPwd(String loginPwd) {
this.loginPwd = loginPwd;
}
@Override
public String toString() {
return "LoginUserEntity{" +
"loginAccount='" + loginAccount + '\'' +
", loginPwd='" + loginPwd + '\'' +
", tempId='" + tempId + '\'' +
", nickName='" + nickName + '\'' +
", staffName='" + staffName + '\'' +
", maxServiceCount=" + maxServiceCount +
", blackFunction=" + blackFunction +
", transferFunction=" + transferFunction +
", face='" + face + '\'' +
", status=" + status +
", companyId='" + companyId + '\'' +
", appKey='" + appKey + '\'' +
", sid='" + sid + '\'' +
", pu='" + pu + '\'' +
", puid='" + puid + '\'' +
", token='" + token + '\'' +
", imFlag=" + imFlag +
", cusRoleId=" + cusRoleId +
", cusRoleName='" + cusRoleName + '\'' +
", aid='" + aid + '\'' +
", topFlag=" + topFlag +
", sortFlag=" + sortFlag +
", centerNumber='" + centerNumber + '\'' +
", fuseWork=" + fuseWork +
", callV6Flag=" + callV6Flag +
", callV1Flag=" + callV1Flag +
", ticketFunction=" + ticketFunction +
", transferAuditFlag=" + transferAuditFlag +
", companyName='" + companyName + '\'' +
", accountStatus='" + accountStatus + '\'' +
", kbVersion='" + kbVersion + '\'' +
", language='" + language + '\'' +
", access_token='" + access_token + '\'' +
", login_time=" + login_time +
", wslinkBak=" + wslinkBak +
", wslinkDefault='" + wslinkDefault + '\'' +
'}';
}
}
package com.sobot.common.login.model;
import com.sobot.gson.annotations.Expose;
import com.sobot.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
//在线接口返回的客服信息
public class OnlineUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String tempId; //客服temp-id
private int blackFunction = 1; //是否有拉黑权限 0 没有 1 有
private int transferFunction = 1; //是否有转接权限 0 没有 1 有
private int status; //账号状态 1正常0登录邮箱或密码不正确 2用户已在pc端登录
private String pu;
private String puid;
private int imFlag;//0是工单客服 1是在线客服
private int topFlag;//星标置顶 0不置顶 1置顶
private int sortFlag;//会话排序 0 按接入顺序 1 按新消息时间
private String centerNumber;//如果不为空,说明开通了呼叫功能
private int fuseWork;//1-存在融合工作台,使用新版服务总计 0-没有融合工作台
private int transferAuditFlag;//转接审核开关 0关闭 1开启
private String kbVersion;//智能回复,查询版本v6/v1
private String robotVersion;//机器人,查询版本v6/v1
private String onlineVersion;//在线,查询版本v6/v1
@Expose
@SerializedName("wslink.bak")
private List<String> wslinkBak;//通道地址
@Expose
@SerializedName("wslink.default")
private String wslinkDefault;//通道默认地址
public String getTempId() {
return tempId;
}
public void setTempId(String tempId) {
this.tempId = tempId;
}
public int getBlackFunction() {
return blackFunction;
}
public void setBlackFunction(int blackFunction) {
this.blackFunction = blackFunction;
}
public int getTransferFunction() {
return transferFunction;
}
public void setTransferFunction(int transferFunction) {
this.transferFunction = transferFunction;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getPu() {
return pu;
}
public void setPu(String pu) {
this.pu = pu;
}
public String getPuid() {
return puid;
}
public void setPuid(String puid) {
this.puid = puid;
}
public int getImFlag() {
return imFlag;
}
public void setImFlag(int imFlag) {
this.imFlag = imFlag;
}
public int getTopFlag() {
return topFlag;
}
public void setTopFlag(int topFlag) {
this.topFlag = topFlag;
}
public int getSortFlag() {
return sortFlag;
}
public void setSortFlag(int sortFlag) {
this.sortFlag = sortFlag;
}
public String getCenterNumber() {
return centerNumber;
}
public void setCenterNumber(String centerNumber) {
this.centerNumber = centerNumber;
}
public int getFuseWork() {
return fuseWork;
}
public void setFuseWork(int fuseWork) {
this.fuseWork = fuseWork;
}
public int getTransferAuditFlag() {
return transferAuditFlag;
}
public void setTransferAuditFlag(int transferAuditFlag) {
this.transferAuditFlag = transferAuditFlag;
}
public String getKbVersion() {
return kbVersion;
}
public void setKbVersion(String kbVersion) {
this.kbVersion = kbVersion;
}
public List<String> getWslinkBak() {
return wslinkBak;
}
public void setWslinkBak(List<String> wslinkBak) {
this.wslinkBak = wslinkBak;
}
public String getWslinkDefault() {
return wslinkDefault;
}
public void setWslinkDefault(String wslinkDefault) {
this.wslinkDefault = wslinkDefault;
}
public String getRobotVersion() {
return robotVersion;
}
public void setRobotVersion(String robotVersion) {
this.robotVersion = robotVersion;
}
public String getOnlineVersion() {
return onlineVersion;
}
public void setOnlineVersion(String onlineVersion) {
this.onlineVersion = onlineVersion;
}
}
...@@ -6,6 +6,10 @@ import java.io.Serializable; ...@@ -6,6 +6,10 @@ import java.io.Serializable;
public class ServiceFunctionVoModel implements Serializable { public class ServiceFunctionVoModel implements Serializable {
//旧版console权限标识 //旧版console权限标识
private String id; private String id;
//旧版console权限是否开启
private boolean checked;
//旧版console权限是否开启(入库使用) 0 没有,1开启 值从checked来
private int checkedCode;
//新版console权限标识 //新版console权限标识
private String code; private String code;
//是否有子类权限 //是否有子类权限
...@@ -38,12 +42,30 @@ public class ServiceFunctionVoModel implements Serializable { ...@@ -38,12 +42,30 @@ public class ServiceFunctionVoModel implements Serializable {
this.hasChildren = hasChildren; this.hasChildren = hasChildren;
} }
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public int getCheckedCode() {
return checkedCode;
}
public void setCheckedCode(int checkedCode) {
this.checkedCode = checkedCode;
}
@Override @Override
public String toString() { public String toString() {
return "SobotCusFunctionVoModel{" + return "ServiceFunctionVoModel{" +
"id='" + id + '\'' + "id='" + id + '\'' +
"code='" + code + '\'' + ", checked=" + checked +
"cohasChildrende='" + hasChildren + '\'' + ", checkedCode=" + checkedCode +
", code='" + code + '\'' +
", hasChildren=" + hasChildren +
'}'; '}';
} }
} }
package com.sobot.common.login.model; package com.sobot.common.login.model;
import com.sobot.gson.annotations.Expose;
import com.sobot.gson.annotations.SerializedName;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 登录后的客服信息 * 登录后的客服信息
...@@ -17,13 +21,13 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -17,13 +21,13 @@ public class SobotServiceInfoModel implements Serializable {
*/ */
private String serviceName; private String serviceName;
/** /**
* 角色id * 客服昵称
*/ */
private String cusRoleId; private String serviceNick;
/** /**
* 角色名称 * 客服头像
*/ */
private String cusRoleName; private String faceImg;
/** /**
* 0 只用旧console 其他都是新console; * 0 只用旧console 其他都是新console;
*/ */
...@@ -37,7 +41,6 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -37,7 +41,6 @@ public class SobotServiceInfoModel implements Serializable {
//区域环境(0国内 1国外) //区域环境(0国内 1国外)
private int region; private int region;
/** /**
* 公司id * 公司id
*/ */
...@@ -68,7 +71,6 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -68,7 +71,6 @@ public class SobotServiceInfoModel implements Serializable {
public static final String TIMEZONEID = "timezoneId"; public static final String TIMEZONEID = "timezoneId";
/** /**
* 手机号 * 手机号
*/ */
...@@ -84,6 +86,261 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -84,6 +86,261 @@ public class SobotServiceInfoModel implements Serializable {
//是否是号码脱敏,true 脱敏,false 明文 //是否是号码脱敏,true 脱敏,false 明文
private boolean hideFlag; private boolean hideFlag;
private static final long serialVersionUID = 1L;
private String loginAccount; //登录账号
private String loginPwd; //登录密码
private String tempId; //客服temp-id
private int maxAccept; //最大接待量
private int blackFunction = 1; //是否有拉黑权限 0 没有 1 有
private int transferFunction = 1; //是否有转接权限 0 没有 1 有
private int status; //账号状态 1正常0登录邮箱或密码不正确 2用户已在pc端登录
private String pu;
private String puid;
private String token;
private int imFlag;//0是工单客服 1是在线客服
private int cusRoleId;//身份id 3333:超级管理员;1111:在线客服;2222:管理员
private String cusRoleName;//身份名称 客服身份
private int topFlag;//星标置顶 0不置顶 1置顶
private int sortFlag;//会话排序 0 按接入顺序 1 按新消息时间
private String centerNumber;//如果不为空,说明开通了呼叫功能
private int fuseWork;//1-存在融合工作台,使用新版服务总计 0-没有融合工作台
private int callV1Flag;//是否是V1,方便做那个呼叫v1/v6切换的功能
private int transferAuditFlag;//转接审核开关 0关闭 1开启
private String companyName;//公司名称
private String accountStatus;//企业账号版本:旗舰版
private String kbVersion;//智能回复,查询版本v6/v1
private String robotVersion;//机器人,查询版本v6/v1
private String onlineVersion;//在线,查询版本v6/v1
private String access_token;//呼叫v6
public static final String ACCESS_TOKEN = "access_token";//呼叫v6 accessToken
private long login_time;//登录时间戳
public static final String LOGIN_TIME = "login_time";
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getAccountStatus() {
return accountStatus;
}
public void setAccountStatus(String accountStatus) {
this.accountStatus = accountStatus;
}
@Expose
@SerializedName("wslink.bak")
private List<String> wslinkBak;//通道地址
@Expose
@SerializedName("wslink.default")
private String wslinkDefault;//通道默认地址
public int getBlackFunction() {
return blackFunction;
}
public void setBlackFunction(int blackFunction) {
this.blackFunction = blackFunction;
}
public int getTransferFunction() {
return transferFunction;
}
public void setTransferFunction(int transferFunction) {
this.transferFunction = transferFunction;
}
public List<String> getWslinkBak() {
return wslinkBak;
}
public void setWslinkBak(List<String> wslinkBak) {
this.wslinkBak = wslinkBak;
}
public String getWslinkDefault() {
return wslinkDefault;
}
public void setWslinkDefault(String wslinkDefault) {
this.wslinkDefault = wslinkDefault;
}
public int getCusRoleId() {
return cusRoleId;
}
public void setCusRoleId(int cusRoleId) {
this.cusRoleId = cusRoleId;
}
public String getCusRoleName() {
return cusRoleName;
}
public void setCusRoleName(String cusRoleName) {
this.cusRoleName = cusRoleName;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public int isImFlag() {
return imFlag;
}
public void setImFlag(int imFlag) {
this.imFlag = imFlag;
}
public String getPu() {
return pu;
}
public void setPu(String pu) {
this.pu = pu;
}
public String getPuid() {
return puid;
}
public void setPuid(String puid) {
this.puid = puid;
}
public String getTempId() {
return tempId;
}
public void setTempId(String tempId) {
this.tempId = tempId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getTopFlag() {
return topFlag;
}
public void setTopFlag(int topFlag) {
this.topFlag = topFlag;
}
public int getSortFlag() {
return sortFlag;
}
public void setSortFlag(int sortFlag) {
this.sortFlag = sortFlag;
}
public String getCenterNumber() {
return centerNumber;
}
public void setCenterNumber(String centerNumber) {
this.centerNumber = centerNumber;
}
public boolean getTransferAuditFlag() {
return transferAuditFlag == 1 ? true : false;
}
public void setTransferAuditFlag(int transferAuditFlag) {
this.transferAuditFlag = transferAuditFlag;
}
public int getFuseWork() {
return fuseWork;
}
public void setFuseWork(int fuseWork) {
this.fuseWork = fuseWork;
}
public int getCallV6Flag() {
return callV6Flag;
}
public void setCallV6Flag(int callV6Flag) {
this.callV6Flag = callV6Flag;
}
public int getCallV1Flag() {
return callV1Flag;
}
public void setCallV1Flag(int callV1Flag) {
this.callV1Flag = callV1Flag;
}
public String getKbVersion() {
return kbVersion;
}
public void setKbVersion(String kbVersion) {
this.kbVersion = kbVersion;
}
public String getAccess_token() {
return access_token;
}
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public long getLogin_time() {
return login_time;
}
public void setLogin_time(long login_time) {
this.login_time = login_time;
}
public String getLoginAccount() {
return loginAccount;
}
public void setLoginAccount(String loginAccount) {
this.loginAccount = loginAccount;
}
public String getLoginPwd() {
return loginPwd;
}
public void setLoginPwd(String loginPwd) {
this.loginPwd = loginPwd;
}
public List<String> getGlobalPermissions() { public List<String> getGlobalPermissions() {
return globalPermissions; return globalPermissions;
} }
...@@ -107,14 +364,6 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -107,14 +364,6 @@ public class SobotServiceInfoModel implements Serializable {
this.companyId = companyId; this.companyId = companyId;
} }
public int getCallV6Flag() {
return callV6Flag;
}
public void setCallV6Flag(int callV6Flag) {
this.callV6Flag = callV6Flag;
}
public String getPhoneNo() { public String getPhoneNo() {
return phoneNo; return phoneNo;
} }
...@@ -131,22 +380,6 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -131,22 +380,6 @@ public class SobotServiceInfoModel implements Serializable {
this.serviceId = serviceId; this.serviceId = serviceId;
} }
public String getCusRoleId() {
return cusRoleId;
}
public void setCusRoleId(String cusRoleId) {
this.cusRoleId = cusRoleId;
}
public String getCusRoleName() {
return cusRoleName;
}
public void setCusRoleName(String cusRoleName) {
this.cusRoleName = cusRoleName;
}
public List<ServiceFunctionVoModel> getFunctionStr() { public List<ServiceFunctionVoModel> getFunctionStr() {
return functionStr; return functionStr;
} }
...@@ -211,25 +444,51 @@ public class SobotServiceInfoModel implements Serializable { ...@@ -211,25 +444,51 @@ public class SobotServiceInfoModel implements Serializable {
this.timezoneId = timezoneId; this.timezoneId = timezoneId;
} }
@Override public String getServiceNick() {
public String toString() { return serviceNick;
return "SobotServiceInfoModel{" + }
"serviceId='" + serviceId + '\'' +
", serviceName='" + serviceName + '\'' + public void setServiceNick(String serviceNick) {
", cusRoleId='" + cusRoleId + '\'' + this.serviceNick = serviceNick;
", cusRoleName='" + cusRoleName + '\'' + }
", newBossSwitch=" + newBossSwitch +
", functionStr=" + functionStr + public String getFaceImg() {
", serviceLanguage='" + serviceLanguage + '\'' + return faceImg;
", region=" + region + }
", companyId='" + companyId + '\'' +
", callV6Flag=" + callV6Flag + public void setFaceImg(String faceImg) {
", language='" + language + '\'' + this.faceImg = faceImg;
", timezone='" + timezone + '\'' + }
", timezoneId='" + timezoneId + '\'' +
", phoneNo='" + phoneNo + '\'' + public void setHideFlag(boolean hideFlag) {
", globalPermissions=" + globalPermissions + this.hideFlag = hideFlag;
", hideFlag=" + hideFlag + }
'}';
public int getMaxAccept() {
return maxAccept;
}
public void setMaxAccept(int maxAccept) {
this.maxAccept = maxAccept;
}
public int getImFlag() {
return imFlag;
}
public String getRobotVersion() {
return robotVersion;
}
public void setRobotVersion(String robotVersion) {
this.robotVersion = robotVersion;
}
public String getOnlineVersion() {
return onlineVersion;
}
public void setOnlineVersion(String onlineVersion) {
this.onlineVersion = onlineVersion;
} }
} }
package com.sobot.common.login.model;
import java.io.Serializable;
/**
* 开放平台token
*/
public class TokenModel implements Serializable {
private static final long serialVersionUID = 1L;
private Token item;
private String ret_code;
private String ret_msg;
public Token getItem() {
return item;
}
public void setItem(Token item) {
this.item = item;
}
public String getRet_code() {
return ret_code;
}
public void setRet_code(String ret_code) {
this.ret_code = ret_code;
}
public String getRet_msg() {
return ret_msg;
}
public void setRet_msg(String ret_msg) {
this.ret_msg = ret_msg;
}
public class Token implements Serializable {
private static final long serialVersionUID = 1L;
//token编码
private String token;
//凭证有效时间 单位:秒
private String expires_in;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getExpires_in() {
return expires_in;
}
public void setExpires_in(String expires_in) {
this.expires_in = expires_in;
}
}
@Override
public String toString() {
return "OnlineTokenModel{" +
"item=" + item +
", ret_code='" + ret_code + '\'' +
", ret_msg='" + ret_msg + '\'' +
'}';
}
}
\ No newline at end of file
...@@ -3,10 +3,12 @@ package com.sobot.common.login.permission; ...@@ -3,10 +3,12 @@ package com.sobot.common.login.permission;
import android.text.TextUtils; import android.text.TextUtils;
import com.sobot.common.login.SobotLoginTools; import com.sobot.common.login.SobotLoginTools;
import com.sobot.common.login.model.LoginUserEntity; import com.sobot.common.login.db.FunctionManager;
import com.sobot.common.login.model.ServiceFunctionVoModel; import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.login.model.SobotServiceInfoModel; import com.sobot.common.login.model.SobotServiceInfoModel;
import java.util.List;
/** /**
* 权限管理类 * 权限管理类
*/ */
...@@ -26,8 +28,8 @@ public class SobotPermissionManager { ...@@ -26,8 +28,8 @@ public class SobotPermissionManager {
private static SobotPermissionApi getInstance() { private static SobotPermissionApi getInstance() {
if (instance == null) { if (instance == null) {
if (SobotLoginTools.getInstance().getLoginUser() != null) { if (SobotLoginTools.getInstance().getServiceInfo() != null) {
switch (SobotLoginTools.getInstance().getLoginUser().getCusRoleId()) { switch (SobotLoginTools.getInstance().getServiceInfo().getCusRoleId()) {
case ONLINE_CUSTOMER_SERVICE://在线客服 case ONLINE_CUSTOMER_SERVICE://在线客服
instance = new PermissionOnLineCustomerService(); instance = new PermissionOnLineCustomerService();
break; break;
...@@ -95,7 +97,22 @@ public class SobotPermissionManager { ...@@ -95,7 +97,22 @@ public class SobotPermissionManager {
public static final String USER_PERMISSION_TYPE_WORK_HISTORY = "1230";// 工单操作历史权限 public static final String USER_PERMISSION_TYPE_WORK_HISTORY = "1230";// 工单操作历史权限
public static final String USER_PERMISSION_TYPE_WORK_STATUS = "1231";// 工单状态 可见/不可见 public static final String USER_PERMISSION_TYPE_WORK_STATUS = "1231";// 工单状态 可见/不可见
/**
* 查看App客户中心
*/
public static String ADMIN_APP_TICKET_CUSTOMER_FUNCTION_CODE = "1611";
/**
* 拉黑权限编码
*/
public static String BLACK_FUNCTION_CODE = "220201";
/**
* 转接权限编码
*/
public static String TRANSFER_FUNCTION_CODE = "220202";
/**
* 客服自定义欢迎语权限编码
*/
public static String DIY_ADMIN_CONFIG_FUNCTION_CODE = "220204";
//会话 //会话
public static final String MODULE_CHAT = "module_chat"; public static final String MODULE_CHAT = "module_chat";
...@@ -233,21 +250,21 @@ public class SobotPermissionManager { ...@@ -233,21 +250,21 @@ public class SobotPermissionManager {
public static final String SCC_DXRW_RWZJBJ = "scc-dxrw-rwzjbj"; public static final String SCC_DXRW_RWZJBJ = "scc-dxrw-rwzjbj";
//电销 电话条 //电销 电话条
public static final String SCC_DHT="scc-dht"; public static final String SCC_DHT = "scc-dht";
//修改绑定电话号码 //修改绑定电话号码
public static final String SCC_DHT_XGBDDHHM="scc-dht-xgbddhhm"; public static final String SCC_DHT_XGBDDHHM = "scc-dht-xgbddhhm";
//修改分机账号 //修改分机账号
public static final String SCC_DHT_XGFJZH="scc-dht-xgfjzh"; public static final String SCC_DHT_XGFJZH = "scc-dht-xgfjzh";
//离线后自动解绑 //离线后自动解绑
public static final String SCC_DHT_LXHZDJB="scc-dht-lxhzdjb"; public static final String SCC_DHT_LXHZDJB = "scc-dht-lxhzdjb";
//保持和保持取消 //保持和保持取消
public static final String SCC_DHT_BCHBCQX="scc-dht-bchbcqx"; public static final String SCC_DHT_BCHBCQX = "scc-dht-bchbcqx";
//静音和静音取消 //静音和静音取消
public static final String SCC_DHT_JYHJYQX="scc-dht-jyhjyqx"; public static final String SCC_DHT_JYHJYQX = "scc-dht-jyhjyqx";
//延长整理时长 //延长整理时长
public static final String SCC_DHT_YCZLSC="scc-dht-yczlsc"; public static final String SCC_DHT_YCZLSC = "scc-dht-yczlsc";
//结束整理并置忙 //结束整理并置忙
public static final String SCC_DHT_JSZLBZM="scc-dht-jszlbzm"; public static final String SCC_DHT_JSZLBZM = "scc-dht-jszlbzm";
public static String getCodeByType(String type) { public static String getCodeByType(String type) {
if (!TextUtils.isEmpty(type)) { if (!TextUtils.isEmpty(type)) {
...@@ -331,9 +348,15 @@ public class SobotPermissionManager { ...@@ -331,9 +348,15 @@ public class SobotPermissionManager {
} }
} }
} else { } else {
LoginUserEntity customerServiceInfoModel = SobotLoginTools.getInstance().getLoginUser(); List<ServiceFunctionVoModel> functionVoModelList = FunctionManager.getInstance().getFunctionVos();
if (!TextUtils.isEmpty(type) && customerServiceInfoModel != null && customerServiceInfoModel.getTicketFunction() != null && customerServiceInfoModel.getTicketFunction().containsKey(type)) { if (!TextUtils.isEmpty(type) && functionVoModelList != null) {
return customerServiceInfoModel.getTicketFunction().get(type); for (int i = 0; i < functionVoModelList.size(); i++) {
ServiceFunctionVoModel cusFunctionVoModel = functionVoModelList.get(i);
if (getCodeByType(type).equals(cusFunctionVoModel.getId())) {
//1开启了 0 没有开启
return cusFunctionVoModel.getCheckedCode() == 1 ? true : false;
}
}
} }
} }
} }
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget_x' //项目名 PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.2.3' //版本号 PUBLISH_VERSION = '1.2.4' //版本号
} }
......
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