Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-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 a511b512
authored
Apr 26, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
2 parents
2b28194e
cdb78e6d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
src/main/java/com/glsx/smart/controller/UserRelationController.java
src/main/java/com/glsx/smart/service/SmartUserRelationService.java
src/main/java/com/glsx/smart/service/impl/SmartUserRelationServiceImpl.java
src/main/java/com/glsx/smart/controller/UserRelationController.java
View file @
a511b51
...
...
@@ -2,6 +2,7 @@ package com.glsx.smart.controller;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.nacos.common.utils.MD5Utils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.redis.utils.RedisUtils
;
import
com.glsx.smart.constant.Constants
;
...
...
@@ -58,6 +59,17 @@ public class UserRelationController {
}
@ResponseBody
@RequestMapping
(
value
=
"/getAqaraToken"
,
method
=
{
RequestMethod
.
POST
})
public
String
getAqaraToken
(
@RequestBody
SmartUserRelation
userRelation
){
log
.
info
(
"/user/getAqaraToken参数:{}"
,
JSON
.
toJSONString
(
userRelation
));
if
(
StringUtils
.
isEmpty
(
userRelation
.
getPhone
())){
return
null
;
}
Map
<
String
,
String
>
map
=
userRelationService
.
syncAqaraUserCore
(
userRelation
.
getPhone
());
return
map
!=
null
?
map
.
get
(
"accessToken"
)
:
null
;
}
@ResponseBody
@RequestMapping
(
value
=
"/login"
,
method
=
{
RequestMethod
.
POST
})
public
R
login
(
@RequestBody
SmartUserRelation
userRelation
){
log
.
info
(
"/user/login保存数据参数:{}"
,
JSON
.
toJSONString
(
userRelation
));
...
...
src/main/java/com/glsx/smart/service/SmartUserRelationService.java
View file @
a511b51
...
...
@@ -3,6 +3,7 @@ package com.glsx.smart.service;
import
com.glsx.smart.dao.entity.SmartUserRelation
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>Description:
...
...
@@ -33,4 +34,6 @@ public interface SmartUserRelationService {
String
syncAqaraUser
(
String
mobile
,
Long
userId
);
Map
<
String
,
String
>
syncAqaraUserCore
(
String
mobile
);
}
src/main/java/com/glsx/smart/service/impl/SmartUserRelationServiceImpl.java
View file @
a511b51
...
...
@@ -114,9 +114,11 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
@Override
public
String
syncAqaraUser
(
String
mobile
,
Long
userId
)
{
String
thirdId
=
this
.
syncAqaraUser
(
mobile
);
if
(
thirdId
!=
null
){
Map
<
String
,
String
>
returnMap
=
this
.
syncAqaraUserCore
(
mobile
);
String
thirdId
=
null
;
if
(
returnMap
!=
null
){
//保存绿米渠道用户数据
thirdId
=
returnMap
.
get
(
"openId"
);
this
.
saveUserChannel
(
userId
,
thirdId
,
Constants
.
USER_CHANNEL_AQARA
);
}
return
thirdId
;
...
...
@@ -172,10 +174,10 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
* @param mobile
* @return
*/
p
rivate
String
syncAqaraUser
(
String
mobile
){
p
ublic
Map
<
String
,
String
>
syncAqaraUserCore
(
String
mobile
){
Map
<
String
,
String
>
object
=
new
HashMap
<>();
object
.
put
(
"account"
,
mobile
);
object
.
put
(
"password"
,
mobile
);
object
.
put
(
"password"
,
mobile
+
"abc"
);
//默认密码涂鸦端
try
{
StringBuffer
syncUserUrl
=
new
StringBuffer
(
remoteUrl
);
syncUserUrl
.
append
(
aqaraSyncUser
);
...
...
@@ -185,7 +187,11 @@ public class SmartUserRelationServiceImpl implements SmartUserRelationService {
if
(!
StringUtils
.
isEmpty
(
result
))
{
JSONObject
json
=
JSON
.
parseObject
(
result
);
if
(
json
.
getInteger
(
"code"
).
equals
(
200
))
{
return
json
.
getJSONObject
(
"result"
).
getString
(
"openId"
);
Map
<
String
,
String
>
returnMap
=
new
HashMap
<>();
JSONObject
message
=
json
.
getJSONObject
(
"message"
);
returnMap
.
put
(
"openId"
,
message
.
getString
(
"openId"
));
returnMap
.
put
(
"accessToken"
,
message
.
getString
(
"accessToken"
));
return
returnMap
;
}
}
}
catch
(
Exception
e
)
{
...
...
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