|
|
@@ -3,9 +3,12 @@ package com.uas.sso.sso.backend.config;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.sso.common.util.HttpUtil;
|
|
|
+import com.uas.sso.dao.AppDao;
|
|
|
import com.uas.sso.dao.SyncLogDao;
|
|
|
+import com.uas.sso.dao.UserDao;
|
|
|
import com.uas.sso.entity.App;
|
|
|
import com.uas.sso.entity.SyncLog;
|
|
|
+import com.uas.sso.entity.User;
|
|
|
import com.uas.sso.entity.UserView;
|
|
|
import com.uas.sso.sso.backend.util.JacksonUtils;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -34,10 +37,16 @@ public class SyncThreadPool {
|
|
|
|
|
|
private final SyncLogDao syncLogDao;
|
|
|
|
|
|
+ private final UserDao userDao;
|
|
|
+
|
|
|
+ private final AppDao appDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public SyncThreadPool(ExecutorService executorService, SyncLogDao syncLogDao) {
|
|
|
+ public SyncThreadPool(ExecutorService executorService, SyncLogDao syncLogDao, UserDao userDao, AppDao appDao) {
|
|
|
this.executorService = executorService;
|
|
|
this.syncLogDao = syncLogDao;
|
|
|
+ this.userDao = userDao;
|
|
|
+ this.appDao = appDao;
|
|
|
}
|
|
|
|
|
|
public void transferDataToOtherPlatforms(BackInfoType type, List<App> appList, JSONObject data, String message) {
|
|
|
@@ -63,6 +72,10 @@ public class SyncThreadPool {
|
|
|
}
|
|
|
|
|
|
final boolean flag = isBackUser;
|
|
|
+ if (flag) {
|
|
|
+ syncToIm(data, message);
|
|
|
+
|
|
|
+ }
|
|
|
for (String backUrl : urls) {
|
|
|
executorService.execute(new Runnable() {
|
|
|
@Override
|
|
|
@@ -83,7 +96,7 @@ public class SyncThreadPool {
|
|
|
params.put("sex", data.getString("sex"));
|
|
|
params.put("mobile", data.getString("mobile"));
|
|
|
params.put("password", data.get("newPass"));
|
|
|
- params.put("dialectUID", data.getString("idCard"));
|
|
|
+ params.put("dialectUID", data.getString("userUU"));
|
|
|
}
|
|
|
|
|
|
HttpUtil.ResponseWrap res = HttpUtil.doPost(url, params, 30000);
|
|
|
@@ -93,6 +106,10 @@ public class SyncThreadPool {
|
|
|
JSON.toJSONString(params), res.getContent()));
|
|
|
} else {
|
|
|
if (flag && "im".equals(appId)) {
|
|
|
+ User user = userDao.findOne(data.getLong("userUU"));
|
|
|
+ JSONObject obj = JSON.parseObject(res.getContent());
|
|
|
+ user.setImId(obj.getString("dialectUID"));
|
|
|
+ userDao.save(user);
|
|
|
logger.info(String.format("IMID: %s", res.getContent()));
|
|
|
}
|
|
|
logInfo(appId, message + ", 同步信息成功", JSON.toJSONString(params));
|
|
|
@@ -109,6 +126,41 @@ public class SyncThreadPool {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void syncToIm(JSONObject data, String message) {
|
|
|
+ String appId = "im";
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("email", data.getString("email"));
|
|
|
+ params.put("idCard", data.getString("idCard"));
|
|
|
+ params.put("name", data.getString("vipName"));
|
|
|
+ params.put("sex", data.getString("sex"));
|
|
|
+ params.put("mobile", data.getString("mobile"));
|
|
|
+ params.put("password", data.get("newPass"));
|
|
|
+ params.put("dialectUID", data.getString("userUU"));
|
|
|
+ App app = appDao.findOne("im");
|
|
|
+ try {
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doPost(app.getBackUserUrl(), params, 30000);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ logError(appId, message + ", 同步信息失败", JSON.toJSONString(params), res.getContent());
|
|
|
+ logger.error(String.format("%s:同步信息失败, %s, %s, %s", message, appId,
|
|
|
+ JSON.toJSONString(params), res.getContent()));
|
|
|
+ } else {
|
|
|
+ User user = userDao.findOne(data.getLong("userUU"));
|
|
|
+ JSONObject obj = JSON.parseObject(res.getContent());
|
|
|
+ user.setImId(obj.getString("dialectUID"));
|
|
|
+ userDao.save(user);
|
|
|
+ logger.info(String.format("IMID: %s", res.getContent()));
|
|
|
+ logInfo(appId, message + ", 同步信息成功", JSON.toJSONString(params));
|
|
|
+ logger.info(String.format("%s:同步信息成功, %s, %s", message, appId,
|
|
|
+ JSON.toJSONString(params)));
|
|
|
+ data.put("imid", user.getImId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logError(appId, message + ", 同步信息失败", JSON.toJSONString(params), e.getMessage());
|
|
|
+ logger.error(String.format("%s:同步信息失败, %s, %s, %s", message, appId,
|
|
|
+ JSON.toJSONString(params), e.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public enum BackInfoType {
|
|
|
/**
|
|
|
* 同步用户信息
|