Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sobot_android
Sobot_module_Dev
Commits
cae3f207
Commit
cae3f207
authored
Sep 06, 2023
by
zhengnw@sobot.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common 1.4.0 添加sdk 登录
parent
057b0bfd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
21 deletions
+154
-21
MainActivity.java
app/src/main/java/com/sobot/moduletest/MainActivity.java
+13
-0
sobot-common-publish-mavencentral.gradle
sobot_common/sobot-common-publish-mavencentral.gradle
+1
-1
SobotLoginTools.java
...src/main/java/com/sobot/common/login/SobotLoginTools.java
+125
-16
LoginUserManager.java
...main/java/com/sobot/common/login/db/LoginUserManager.java
+4
-3
SobotCallBaseCode.java
.../java/com/sobot/common/login/model/SobotCallBaseCode.java
+11
-1
No files found.
app/src/main/java/com/sobot/moduletest/MainActivity.java
View file @
cae3f207
...
...
@@ -8,6 +8,9 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.widget.ImageView
;
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.pictureframe.SobotBitmapUtil
;
import
com.sobot.utils.SobotLogUtils
;
...
...
@@ -220,6 +223,16 @@ public class MainActivity extends SobotBaseActivity {
// SobotLoginTools.getInstance().setLoginUser(sa);
// SobotServiceInfoModel ccc=new SobotServiceInfoModel();
// SobotLoginTools.getInstance().setServiceInfo(ccc);
// SobotLoginTools.getInstance().doLogin(MainActivity.this, MainActivity.this, "https://api-c.soboten.com/text", "zhengnawei@sobot.com", "znw123456","", 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()+"");
// }
// });
}
@Override
...
...
sobot_common/sobot-common-publish-mavencentral.gradle
View file @
cae3f207
...
...
@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'sobotcommon'
//项目名
// PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION
=
'1.3.9.
5
'
//版本号
PUBLISH_VERSION
=
'1.3.9.
6
'
//版本号
}
...
...
sobot_common/src/main/java/com/sobot/common/login/SobotLoginTools.java
View file @
cae3f207
...
...
@@ -11,6 +11,7 @@ import com.sobot.common.login.db.ServiceInfoManager;
import
com.sobot.common.login.model.HostModel
;
import
com.sobot.common.login.model.LoginUserEntity
;
import
com.sobot.common.login.model.ServiceFunctionVoModel
;
import
com.sobot.common.login.model.SobotCallBaseCode
;
import
com.sobot.common.login.model.SobotServiceInfoModel
;
import
com.sobot.gson.SobotGsonUtil
;
import
com.sobot.network.apiUtils.SobotBaseCode
;
...
...
@@ -151,7 +152,7 @@ public class SobotLoginTools {
//登录接口和获取坐席信息权限接口都成功才算真正登录成功
if
(
"1"
.
equals
(
baseModel
.
getCode
())
&&
baseModel
.
getData
()
!=
null
)
{
final
LoginUserEntity
userEntity
=
baseModel
.
getData
();
getLoginUserInfo
(
cancelTag
,
mContext
,
baseModel
.
getData
(),
host
,
baseModel
.
getData
().
getToken
(),
baseModel
.
getData
().
getLanguage
(),
new
SobotResultBlock
()
{
getLoginUserInfo
(
cancelTag
,
mContext
,
host
,
baseModel
.
getData
().
getToken
(),
baseModel
.
getData
().
getLanguage
(),
new
SobotResultBlock
()
{
@Override
public
void
resultBolok
(
SobotResultCode
code
,
String
msg
,
Object
obj
)
{
if
(
code
==
SobotResultCode
.
CODE_SUCCEEDED
)
{
...
...
@@ -184,11 +185,10 @@ public class SobotLoginTools {
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
else
{
userEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
setLoginUser
(
userEntity
);
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_SUCCEEDED
,
"登录成功"
,
userEntity
);
}
}
else
{
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
...
...
@@ -216,17 +216,127 @@ public class SobotLoginTools {
});
}
/**
* 调用座席接口
*
* @param cancelTag
* @param mContext
* @param host
* @param token
* @param resultBlock 返回坐席信息
*/
public
void
getLoginUserInfo
(
Object
cancelTag
,
Context
mContext
,
String
host
,
String
token
,
String
language
,
SobotResultBlock
resultBlock
)
{
getLoginUserInfo
(
cancelTag
,
mContext
,
null
,
host
,
token
,
language
,
resultBlock
);
// sdk 执行登录接口
public
void
doLogin
(
final
Object
cancelTag
,
final
Context
mContext
,
final
String
host
,
String
loginAcount
,
String
loginPwd
,
String
logintoken
,
final
SobotResultBlock
resultBlock
)
{
if
(
SobotStringUtils
.
isEmpty
(
logintoken
))
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"loginUser"
,
loginAcount
);
params
.
put
(
"loginPwd"
,
loginPwd
);
SobotHttpUtils
.
doPost
(
cancelTag
,
host
+
"/basic-login/serviceAppLogin/4"
,
8000
,
params
,
null
,
new
HttpBaseUtils
.
StringCallBack
()
{
@Override
public
void
onResponse
(
String
response
)
{
SobotCallBaseCode
result
=
SobotGsonUtil
.
jsonToBean
(
response
,
SobotCallBaseCode
.
class
);
if
(
result
!=
null
&&
!
TextUtils
.
isEmpty
(
result
.
getRetCode
())
&&
"000000"
.
equals
(
result
.
getRetCode
())
&&
!
SobotStringUtils
.
isEmpty
(
result
.
getItem
()))
{
final
LoginUserEntity
userEntity
=
new
LoginUserEntity
();
userEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
userEntity
.
setToken
((
String
)
result
.
getItem
());
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
)
{
if
(
userEntity
!=
null
&&
!
SobotStringUtils
.
isEmpty
(
userEntity
.
getToken
()))
{
//如果是v6呼叫
String
tempHost
=
host
;
if
(
tempHost
.
contains
(
"/text"
))
{
tempHost
=
tempHost
.
replace
(
"/text"
,
""
);
}
doAccessToken
(
cancelTag
,
tempHost
,
userEntity
.
getToken
(),
new
SobotResultBlock
()
{
@Override
public
void
resultBolok
(
SobotResultCode
code
,
String
msg
,
Object
obj
)
{
if
(
code
==
SobotResultCode
.
CODE_SUCCEEDED
)
{
LoginUserEntity
tempUserEntity
=
userEntity
;
String
accessToken
=
(
String
)
obj
;
tempUserEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
tempUserEntity
.
setAccess_token
(
accessToken
);
tempUserEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
setLoginUser
(
tempUserEntity
);
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_SUCCEEDED
,
"登录成功"
,
tempUserEntity
);
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
});
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
else
{
setLoginUser
(
userEntity
);
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_SUCCEEDED
,
"登录成功"
,
userEntity
);
}
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
}
});
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
@Override
public
void
onError
(
Exception
e
,
String
msg
,
int
responseCode
)
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
msg
,
null
);
}
@Override
public
void
inProgress
(
int
progress
)
{
}
});
}
else
{
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
)
{
if
(
userEntity
!=
null
&&
!
SobotStringUtils
.
isEmpty
(
userEntity
.
getToken
()))
{
//如果是v6呼叫
String
tempHost
=
host
;
if
(
tempHost
.
contains
(
"/text"
))
{
tempHost
=
tempHost
.
replace
(
"/text"
,
""
);
}
doAccessToken
(
cancelTag
,
tempHost
,
userEntity
.
getToken
(),
new
SobotResultBlock
()
{
@Override
public
void
resultBolok
(
SobotResultCode
code
,
String
msg
,
Object
obj
)
{
if
(
code
==
SobotResultCode
.
CODE_SUCCEEDED
)
{
LoginUserEntity
tempUserEntity
=
userEntity
;
String
accessToken
=
(
String
)
obj
;
tempUserEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
tempUserEntity
.
setAccess_token
(
accessToken
);
tempUserEntity
.
setLogin_time
(
System
.
currentTimeMillis
());
setLoginUser
(
tempUserEntity
);
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_SUCCEEDED
,
"登录成功"
,
tempUserEntity
);
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
});
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
else
{
setLoginUser
(
userEntity
);
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_SUCCEEDED
,
"登录成功"
,
userEntity
);
}
}
else
{
resultBlock
.
resultBolok
(
SobotResultCode
.
CODE_FAILED
,
"登录失败"
,
null
);
}
}
}
});
}
}
/**
...
...
@@ -234,12 +344,11 @@ public class SobotLoginTools {
*
* @param cancelTag
* @param mContext
* @param loginUser 如果不为空 resultBlock返回就是这个;如果为空,返回坐席信息
* @param host
* @param token
* @param resultBlock
*/
public
void
getLoginUserInfo
(
final
Object
cancelTag
,
final
Context
mContext
,
final
LoginUserEntity
loginUser
,
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"
;
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
if
(!
TextUtils
.
isEmpty
(
token
))
{
...
...
sobot_common/src/main/java/com/sobot/common/login/db/LoginUserManager.java
View file @
cae3f207
...
...
@@ -55,9 +55,10 @@ public class LoginUserManager extends SobotCommonDao<LoginUserEntity> {
model
.
setStaffName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"staffName"
)));
model
.
setMaxServiceCount
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"maxServiceCount"
)));
model
.
setBlackFunction
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"blackFunction"
)));
String
transferFunction
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"transferFunction"
));
if
(!
SobotStringUtils
.
isEmpty
(
transferFunction
)){
Map
<
String
,
Boolean
>
map
=
SobotGsonUtil
.
jsonToMaps
(
transferFunction
);
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"
)));
...
...
sobot_common/src/main/java/com/sobot/common/login/model/Sobot
BaseCodeThird
.java
→
sobot_common/src/main/java/com/sobot/common/login/model/Sobot
CallBaseCode
.java
View file @
cae3f207
...
...
@@ -2,11 +2,13 @@ package com.sobot.common.login.model;
import
java.io.Serializable
;
import
java.util.List
;
public
class
Sobot
BaseCodeThird
<
T
>
implements
Serializable
{
public
class
Sobot
CallBaseCode
<
T
>
implements
Serializable
{
public
T
item
;
public
List
<
T
>
items
;
public
String
retMsg
;
public
String
retCode
;
public
int
totalCount
;
...
...
@@ -15,6 +17,14 @@ public class SobotBaseCodeThird<T> implements Serializable {
return
item
;
}
public
List
<
T
>
getItems
()
{
return
items
;
}
public
void
setItems
(
List
<
T
>
items
)
{
this
.
items
=
items
;
}
public
void
setItem
(
T
item
)
{
this
.
item
=
item
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment