Commit a511b512 by tyfanchz

Merge remote-tracking branch 'origin/dev' into dev

2 parents 2b28194e cdb78e6d
......@@ -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));
......
......@@ -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);
}
......@@ -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
*/
private String syncAqaraUser(String mobile){
public 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) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!