Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
smartDevices-platform-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1786ba45
authored
Mar 05, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]代码整改
1 parent
8ff8f943
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
32 deletions
src/main/java/cn/com/glsx/modules/service/UserService.java
src/main/java/cn/com/glsx/modules/utils/AccessTokenService.java
src/main/java/cn/com/glsx/modules/utils/HeaderParamUtils.java
src/main/java/cn/com/glsx/modules/utils/TuyaUtils.java
src/main/java/cn/com/glsx/modules/service/UserService.java
View file @
1786ba4
...
@@ -7,6 +7,7 @@ import cn.com.glsx.modules.model.param.ResponseBody;
...
@@ -7,6 +7,7 @@ import cn.com.glsx.modules.model.param.ResponseBody;
import
cn.com.glsx.modules.model.param.UserBo
;
import
cn.com.glsx.modules.model.param.UserBo
;
import
cn.com.glsx.modules.model.param.UserInfo
;
import
cn.com.glsx.modules.model.param.UserInfo
;
import
cn.com.glsx.modules.utils.AccessTokenService
;
import
cn.com.glsx.modules.utils.AccessTokenService
;
import
cn.com.glsx.modules.utils.HeaderParamUtils
;
import
cn.com.glsx.modules.utils.HttpUtil
;
import
cn.com.glsx.modules.utils.HttpUtil
;
import
cn.com.glsx.modules.utils.TuyaUtils
;
import
cn.com.glsx.modules.utils.TuyaUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -73,14 +74,7 @@ public class UserService {
...
@@ -73,14 +74,7 @@ public class UserService {
private
ResponseBody
sendRequestRegisterUser
(
String
accessToken
,
UserBo
userBo
)
{
private
ResponseBody
sendRequestRegisterUser
(
String
accessToken
,
UserBo
userBo
)
{
ResponseBody
responseBody
=
null
;
ResponseBody
responseBody
=
null
;
long
timeMillis
=
System
.
currentTimeMillis
();
Map
<
String
,
String
>
headerParams
=
HeaderParamUtils
.
buildHeaderParams
(
client_id
,
secret
,
accessToken
);
String
sign
=
TuyaUtils
.
getBussinessSign
(
timeMillis
,
client_id
,
secret
,
accessToken
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
sign
);
headerParams
.
put
(
"access_token"
,
accessToken
);
try
{
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendPost
(
registerUserUrl
,
JSONObject
.
toJSONString
(
userBo
),
headerParams
);
JSONObject
jsonObject
=
HttpUtil
.
sendPost
(
registerUserUrl
,
JSONObject
.
toJSONString
(
userBo
),
headerParams
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
...
@@ -115,14 +109,7 @@ public class UserService {
...
@@ -115,14 +109,7 @@ public class UserService {
private
ResponseBody
sendRequestGetUserInfo
(
String
id
,
String
accessToken
)
{
private
ResponseBody
sendRequestGetUserInfo
(
String
id
,
String
accessToken
)
{
ResponseBody
responseBody
=
null
;
ResponseBody
responseBody
=
null
;
long
timeMillis
=
System
.
currentTimeMillis
();
Map
<
String
,
String
>
headerParams
=
HeaderParamUtils
.
buildHeaderParams
(
client_id
,
secret
,
accessToken
);
String
sign
=
TuyaUtils
.
getBussinessSign
(
timeMillis
,
client_id
,
secret
,
accessToken
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
sign
);
headerParams
.
put
(
"access_token"
,
accessToken
);
try
{
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
getUserInfoUrl
.
replace
(
"{uid}"
,
id
),
null
,
headerParams
);
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
getUserInfoUrl
.
replace
(
"{uid}"
,
id
),
null
,
headerParams
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
...
...
src/main/java/cn/com/glsx/modules/utils/AccessTokenService.java
View file @
1786ba4
...
@@ -91,13 +91,7 @@ public class AccessTokenService {
...
@@ -91,13 +91,7 @@ public class AccessTokenService {
*/
*/
private
ResponseBody
sendRequestFlashToken
(
String
flashtoken
)
{
private
ResponseBody
sendRequestFlashToken
(
String
flashtoken
)
{
ResponseBody
responseBody
=
null
;
ResponseBody
responseBody
=
null
;
long
timeMillis
=
System
.
currentTimeMillis
();
Map
<
String
,
String
>
headerParams
=
HeaderParamUtils
.
buildHeaderParams
(
client_id
,
secret
);
String
sign
=
TuyaUtils
.
getLoginSign
(
timeMillis
,
client_id
,
secret
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
sign
);
try
{
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
tokenFlashUrl
+
flashtoken
,
null
,
headerParams
);
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
tokenFlashUrl
+
flashtoken
,
null
,
headerParams
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
...
@@ -115,13 +109,7 @@ public class AccessTokenService {
...
@@ -115,13 +109,7 @@ public class AccessTokenService {
*/
*/
private
ResponseBody
sendRequestGetToken
()
{
private
ResponseBody
sendRequestGetToken
()
{
ResponseBody
responseBody
=
null
;
ResponseBody
responseBody
=
null
;
long
timeMillis
=
System
.
currentTimeMillis
();
Map
<
String
,
String
>
headerParams
=
HeaderParamUtils
.
buildHeaderParams
(
client_id
,
secret
);
String
loginSign
=
TuyaUtils
.
getLoginSign
(
timeMillis
,
client_id
,
secret
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
loginSign
);
try
{
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
getTokenUrl
,
null
,
headerParams
);
JSONObject
jsonObject
=
HttpUtil
.
sendGet
(
getTokenUrl
,
null
,
headerParams
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
responseBody
=
JSON
.
toJavaObject
(
jsonObject
,
ResponseBody
.
class
);
...
@@ -131,4 +119,6 @@ public class AccessTokenService {
...
@@ -131,4 +119,6 @@ public class AccessTokenService {
}
}
return
responseBody
;
return
responseBody
;
}
}
}
}
src/main/java/cn/com/glsx/modules/utils/HeaderParamUtils.java
0 → 100644
View file @
1786ba4
package
cn
.
com
.
glsx
.
modules
.
utils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author zhouhaibao
* @date 2021/3/5 9:24
*/
public
class
HeaderParamUtils
{
public
static
Map
<
String
,
String
>
buildHeaderParams
(
String
client_id
,
String
secret
){
long
timeMillis
=
System
.
currentTimeMillis
();
String
loginSign
=
TuyaUtils
.
getLoginSign
(
timeMillis
,
client_id
,
secret
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
loginSign
);
return
headerParams
;
}
public
static
Map
<
String
,
String
>
buildHeaderParams
(
String
client_id
,
String
secret
,
String
accessToken
){
long
timeMillis
=
System
.
currentTimeMillis
();
String
sign
=
TuyaUtils
.
getBussinessSign
(
timeMillis
,
client_id
,
secret
,
accessToken
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
sign
);
headerParams
.
put
(
"access_token"
,
accessToken
);
return
headerParams
;
}
}
src/main/java/cn/com/glsx/modules/utils/TuyaUtils.java
View file @
1786ba4
...
@@ -58,6 +58,4 @@ public class TuyaUtils {
...
@@ -58,6 +58,4 @@ public class TuyaUtils {
}
}
return
hash
;
return
hash
;
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment