Commit 01c647f6 by zhengnw@sobot.com

common 1.5.7

parent b4372306
...@@ -11,7 +11,7 @@ android { ...@@ -11,7 +11,7 @@ android {
//这里就是打jar包 //这里就是打jar包
task makeJar(type: Copy) { task makeJar(type: Copy) {
//删除旧的jar包 //删除旧的jar包
delete 'build/libs/sobot_common_1.5.3.jar' delete 'build/libs/sobot_common_1.5.7.jar'
//原地址 //原地址
from('build/intermediates/packaged-classes/release/') from('build/intermediates/packaged-classes/release/')
//导出jar包的地址 //导出jar包的地址
...@@ -19,7 +19,7 @@ android { ...@@ -19,7 +19,7 @@ android {
//包含的jar包 //包含的jar包
include('classes.jar') include('classes.jar')
//重命名jar包为mysdk //重命名jar包为mysdk
rename ('classes.jar', 'sobot_common_1.5.3.jar') rename ('classes.jar', 'sobot_common_1.5.7.jar')
} }
makeJar.dependsOn(build) makeJar.dependsOn(build)
} }
......
...@@ -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 = 'sobotcommon_x' //项目名 PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION = '1.5.3' //版本号 PUBLISH_VERSION = '1.5.7' //版本号
} }
......
...@@ -39,7 +39,7 @@ public class SobotLoginTools { ...@@ -39,7 +39,7 @@ public class SobotLoginTools {
} }
public static SobotLoginTools getInstance() { public static SobotLoginTools getInstance() {
return SobotLoginTools.SobotLoginToolsHolder.instance; return SobotLoginToolsHolder.instance;
} }
private static class SobotLoginToolsHolder { private static class SobotLoginToolsHolder {
...@@ -155,7 +155,18 @@ public class SobotLoginTools { ...@@ -155,7 +155,18 @@ public class SobotLoginTools {
} }
public boolean isLogin() { public boolean isLogin() {
if (getLoginUser() != null && !SobotStringUtils.isEmpty(getLoginUser().getToken()) && checkExpiresToken()) { //登录对象,客户对象不为空,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录
if (getLoginUser() != null && getServiceInfo() != null && !SobotStringUtils.isEmpty(getLoginUser().getToken()) && checkExpiresToken()) {
return true;
} else {
return false;
}
}
//判断是否已经登录
public boolean isLogin(String loginAccount) {
//登录对象,客户对象不为空,登录账号和登录对象里边账号一样,token 不为空,token 没过期 才判定已经登录成功,其它情况都是没登录
if (getLoginUser() != null && getServiceInfo() != null && !SobotStringUtils.isEmpty(loginAccount) && loginAccount.equals(getLoginUser().getLoginAccount()) && !SobotStringUtils.isEmpty(getLoginUser().getToken()) && checkExpiresToken()) {
return true; return true;
} else { } else {
return false; return false;
...@@ -164,11 +175,18 @@ public class SobotLoginTools { ...@@ -164,11 +175,18 @@ public class SobotLoginTools {
// 执行APP登录接口 // 执行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 SobotResultBlock resultBlock) { public void doAppLogin(final Object cancelTag, final Context mContext, final String host, final String openApiHost, long timeout, Map<String, Object> params, Map<String, String> headers, final String loginAccount, final String loginPwd, final SobotResultBlock resultBlock) {
if (isLogin(loginAccount)) {
SobotLogUtils.i("已经登录成功,不用重新登录");
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser());
}
return;
}
SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", timeout, params, headers, new HttpBaseUtils.StringCallBack() { SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", timeout, params, headers, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
if (!TextUtils.isEmpty(result)) { if (!SobotStringUtils.isEmpty(result)) {
final SobotBaseCode<LoginUserEntity> baseModel = SobotGsonUtil.jsonToBeans(result, new com.sobot.gson.reflect.TypeToken<SobotBaseCode<LoginUserEntity>>() { final SobotBaseCode<LoginUserEntity> baseModel = SobotGsonUtil.jsonToBeans(result, new com.sobot.gson.reflect.TypeToken<SobotBaseCode<LoginUserEntity>>() {
}.getType()); }.getType());
if (baseModel != null) { if (baseModel != null) {
...@@ -194,42 +212,63 @@ public class SobotLoginTools { ...@@ -194,42 +212,63 @@ public class SobotLoginTools {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity; LoginUserEntity tempUserEntity = userEntity;
String accessToken = (String) obj; String accessToken = (String) obj;
tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setAccess_token(accessToken); tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis()); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAccount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity); setLoginUser(tempUserEntity);
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
}
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
}); });
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} else { } else {
setLoginUser(userEntity); LoginUserEntity tempUserEntity = userEntity;
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAccount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity);
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
} }
}); });
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, baseModel.getMsg(), baseModel.getCode()); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, baseModel.getMsg(), baseModel.getCode());
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "接口请求结果为空", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "接口请求结果为空", null);
}
} }
} }
} }
@Override @Override
public void onError(Exception e, String msg, int responseCode) { public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
} }
@Override @Override
...@@ -240,8 +279,15 @@ public class SobotLoginTools { ...@@ -240,8 +279,15 @@ public class SobotLoginTools {
} }
// sdk 执行登录接口 会获取accesstoken // sdk 执行登录接口 会获取accesstoken
public void doLogin(final Object cancelTag, final Context mContext, final String host, final String openApiHost, String loginAcount, String loginPwd, String logintoken, final SobotResultBlock resultBlock) { 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)) { if (SobotStringUtils.isEmpty(logintoken)) {
if (isLogin(loginAcount)) {
SobotLogUtils.i("已经登录成功,不用重新登录");
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser());
}
return;
}
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("loginUser", loginAcount); params.put("loginUser", loginAcount);
params.put("loginPwd", loginPwd); params.put("loginPwd", loginPwd);
...@@ -249,7 +295,7 @@ public class SobotLoginTools { ...@@ -249,7 +295,7 @@ public class SobotLoginTools {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
SobotCallBaseCode result = SobotGsonUtil.jsonToBean(response, SobotCallBaseCode.class); SobotCallBaseCode result = SobotGsonUtil.jsonToBean(response, SobotCallBaseCode.class);
if (result != null && !TextUtils.isEmpty(result.getRetCode()) && "000000".equals(result.getRetCode()) && !SobotStringUtils.isEmpty(result.getItem())) { if (result != null && !SobotStringUtils.isEmpty(result.getRetCode()) && "000000".equals(result.getRetCode()) && !SobotStringUtils.isEmpty(result.getItem())) {
final LoginUserEntity userEntity = new LoginUserEntity(); final LoginUserEntity userEntity = new LoginUserEntity();
userEntity.setLogin_time(System.currentTimeMillis()); userEntity.setLogin_time(System.currentTimeMillis());
userEntity.setToken((String) result.getItem()); userEntity.setToken((String) result.getItem());
...@@ -272,38 +318,57 @@ public class SobotLoginTools { ...@@ -272,38 +318,57 @@ public class SobotLoginTools {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity; LoginUserEntity tempUserEntity = userEntity;
String accessToken = (String) obj; String accessToken = (String) obj;
tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setAccess_token(accessToken); tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis()); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity); setLoginUser(tempUserEntity);
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
}
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
}); });
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} else { } else {
setLoginUser(userEntity); LoginUserEntity tempUserEntity = userEntity;
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity);
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
} }
}); });
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
@Override @Override
public void onError(Exception e, String msg, int responseCode) { public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
} }
@Override @Override
...@@ -313,6 +378,13 @@ public class SobotLoginTools { ...@@ -313,6 +378,13 @@ public class SobotLoginTools {
}); });
} else { } else {
if (isLogin(loginAcount) && getToken().equals(logintoken)) {
SobotLogUtils.i("账号和token一样 token未过期 已经登录成功,不用重新登录");
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "已经登录成功", getLoginUser());
}
return;
}
final LoginUserEntity userEntity = new LoginUserEntity(); final LoginUserEntity userEntity = new LoginUserEntity();
userEntity.setLogin_time(System.currentTimeMillis()); userEntity.setLogin_time(System.currentTimeMillis());
userEntity.setToken(logintoken); userEntity.setToken(logintoken);
...@@ -335,25 +407,40 @@ public class SobotLoginTools { ...@@ -335,25 +407,40 @@ public class SobotLoginTools {
if (code == SobotResultCode.CODE_SUCCEEDED) { if (code == SobotResultCode.CODE_SUCCEEDED) {
LoginUserEntity tempUserEntity = userEntity; LoginUserEntity tempUserEntity = userEntity;
String accessToken = (String) obj; String accessToken = (String) obj;
tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setAccess_token(accessToken); tempUserEntity.setAccess_token(accessToken);
tempUserEntity.setLogin_time(System.currentTimeMillis()); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity); setLoginUser(tempUserEntity);
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", tempUserEntity);
}
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
}); });
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} else { } else {
setLoginUser(userEntity); LoginUserEntity tempUserEntity = userEntity;
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity); tempUserEntity.setLogin_time(System.currentTimeMillis());
tempUserEntity.setLoginAccount(loginAcount);
tempUserEntity.setLoginPwd(loginPwd);
setLoginUser(tempUserEntity);
if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", userEntity);
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "登录失败", null);
}
} }
} }
...@@ -375,16 +462,16 @@ public class SobotLoginTools { ...@@ -375,16 +462,16 @@ public class SobotLoginTools {
public void getLoginUserInfo(final Object cancelTag, final Context mContext, final String host, String token, String language, final SobotResultBlock resultBlock) { public void getLoginUserInfo(final Object cancelTag, final Context mContext, 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<>();
if (!TextUtils.isEmpty(token)) { if (!SobotStringUtils.isEmpty(token)) {
headerMap.put("temp-id", token); headerMap.put("temp-id", token);
} }
if (!TextUtils.isEmpty(language)) { if (!SobotStringUtils.isEmpty(language)) {
headerMap.put("language", language); headerMap.put("language", language);
} }
SobotHttpUtils.doGet(cancelTag, url, null, headerMap, new HttpBaseUtils.StringCallBack() { SobotHttpUtils.doGet(cancelTag, url, null, headerMap, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
if (!TextUtils.isEmpty(result)) { if (!SobotStringUtils.isEmpty(result)) {
try { try {
org.json.JSONObject resonseObj = new org.json.JSONObject(result); org.json.JSONObject resonseObj = new org.json.JSONObject(result);
String retCode = resonseObj.optString("retCode"); String retCode = resonseObj.optString("retCode");
...@@ -410,20 +497,28 @@ public class SobotLoginTools { ...@@ -410,20 +497,28 @@ public class SobotLoginTools {
//保存在数据库 //保存在数据库
setServiceInfo(serviceInfoModel); setServiceInfo(serviceInfoModel);
SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel); SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel);
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "获取成功", serviceInfoModel); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "获取成功", serviceInfoModel);
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, retMsg == null ? "" : retMsg, null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, retMsg == null ? "" : retMsg, null);
}
} }
} catch (Exception e) { } catch (Exception e) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null);
}
} }
} }
} }
@Override @Override
public void onError(Exception e, String msg, int responseCode) { public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
} }
@Override @Override
...@@ -464,28 +559,36 @@ public class SobotLoginTools { ...@@ -464,28 +559,36 @@ public class SobotLoginTools {
public void doAccessToken(Object cancelTag, String host, String token, final SobotResultBlock resultBlock) { public void doAccessToken(Object cancelTag, String host, String token, final SobotResultBlock resultBlock) {
Map<String, String> headerMap = new HashMap<>(); Map<String, String> headerMap = new HashMap<>();
if (!TextUtils.isEmpty(token)) { if (!SobotStringUtils.isEmpty(token)) {
headerMap.put("temp-id", token); headerMap.put("temp-id", token);
} }
SobotHttpUtils.doPost(cancelTag, host + "/tokens/getToken", null, headerMap, new HttpBaseUtils.StringCallBack() { SobotHttpUtils.doPost(cancelTag, host + "/tokens/getToken", null, headerMap, new HttpBaseUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
if (!TextUtils.isEmpty(result)) { if (!SobotStringUtils.isEmpty(result)) {
Map map = SobotGsonUtil.jsonToMaps((String) result); Map map = SobotGsonUtil.jsonToMaps((String) result);
if (map != null && map.containsKey("accessToken")) { if (map != null && map.containsKey("accessToken")) {
String accessToken = (String) map.get("accessToken"); String accessToken = (String) map.get("accessToken");
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "", accessToken); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "", accessToken);
}
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null);
}
} }
} else { } else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null);
}
} }
} }
@Override @Override
public void onError(Exception e, String msg, int responseCode) { public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null); if (resultBlock != null) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
} }
@Override @Override
......
...@@ -88,6 +88,8 @@ public class LoginUserManager extends SobotCommonDao<LoginUserEntity> { ...@@ -88,6 +88,8 @@ public class LoginUserManager extends SobotCommonDao<LoginUserEntity> {
model.setLanguage(cursor.getString(cursor.getColumnIndex("local_language"))); model.setLanguage(cursor.getString(cursor.getColumnIndex("local_language")));
model.setAccess_token(cursor.getString(cursor.getColumnIndex(LoginUserEntity.ACCESS_TOKEN))); model.setAccess_token(cursor.getString(cursor.getColumnIndex(LoginUserEntity.ACCESS_TOKEN)));
model.setLogin_time(cursor.getLong(cursor.getColumnIndex(LoginUserEntity.LOGIN_TIME))); 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")));
return model; return model;
} }
...@@ -133,6 +135,8 @@ public class LoginUserManager extends SobotCommonDao<LoginUserEntity> { ...@@ -133,6 +135,8 @@ public class LoginUserManager extends SobotCommonDao<LoginUserEntity> {
contentValues.put("local_language", userAccount.getLanguage()); contentValues.put("local_language", userAccount.getLanguage());
contentValues.put(LoginUserEntity.ACCESS_TOKEN, userAccount.getAccess_token()); contentValues.put(LoginUserEntity.ACCESS_TOKEN, userAccount.getAccess_token());
contentValues.put(LoginUserEntity.LOGIN_TIME, userAccount.getLogin_time()); contentValues.put(LoginUserEntity.LOGIN_TIME, userAccount.getLogin_time());
contentValues.put("login_account",userAccount.getLoginAccount());
contentValues.put("login_pwd",userAccount.getLoginPwd());
return contentValues; return contentValues;
} }
......
...@@ -17,7 +17,7 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -17,7 +17,7 @@ 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 = 3; private static final int DB_CACHE_VERSION = 4;
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";
...@@ -131,10 +131,10 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -131,10 +131,10 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
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 " + LoginUserEntity.ACCESS_TOKEN + " VARCHAR(700)";
db.execSQL(sql); // 执行修改表,添加字段的逻辑。 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 " + LoginUserEntity.LOGIN_TIME + " INTEGER";
db.execSQL(sql1); // 执行修改表,添加字段的逻辑。 db.execSQL(sql1); // 登录表添加登录时间
break; break;
case 2: case 2:
String sql2 = "ALTER TABLE " + TABLE_SERVICE_INFO String sql2 = "ALTER TABLE " + TABLE_SERVICE_INFO
...@@ -144,6 +144,14 @@ class SobotCommonDBHelper extends SQLiteOpenHelper { ...@@ -144,6 +144,14 @@ class SobotCommonDBHelper extends SQLiteOpenHelper {
+ " ADD COLUMN " + SobotServiceInfoModel.TIMEZONEID + " VARCHAR(30)"; + " ADD COLUMN " + SobotServiceInfoModel.TIMEZONEID + " VARCHAR(30)";
db.execSQL(sql3); // 执行修改表,添加字段的逻辑。 db.execSQL(sql3); // 执行修改表,添加字段的逻辑。
break; break;
case 3:
String sql4 = "ALTER TABLE " + TABLE_LOGIN_USER
+ " ADD COLUMN login_account VARCHAR(40)";
db.execSQL(sql4); // 登录表添加登录账号
String sql5 = "ALTER TABLE " + TABLE_LOGIN_USER
+ " ADD COLUMN login_pwd VARCHAR(40)";
db.execSQL(sql5); // 登录表添加登录密码
break;
default: default:
break; break;
} }
......
...@@ -10,7 +10,8 @@ import java.util.Map; ...@@ -10,7 +10,8 @@ import java.util.Map;
public class LoginUserEntity implements Serializable { public class LoginUserEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String loginAccount; //登录账号
private String loginPwd; //登录密码
private String tempId; //客服temp-id private String tempId; //客服temp-id
private String nickName; //客服昵称 private String nickName; //客服昵称
private String staffName; //客服名称 private String staffName; //客服名称
...@@ -335,4 +336,20 @@ public class LoginUserEntity implements Serializable { ...@@ -335,4 +336,20 @@ public class LoginUserEntity implements Serializable {
public void setLogin_time(long login_time) { public void setLogin_time(long login_time) {
this.login_time = 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;
}
} }
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