|
|
@@ -97,6 +97,7 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@Override
|
|
|
public User register(User user) {
|
|
|
+ String noEncryPwd = user.getPassword();
|
|
|
// 校验手机号是否被注册
|
|
|
if (mobileHasRegistered(user.getMobile())) {
|
|
|
throw new VisibleError("该手机号已被注册");
|
|
|
@@ -124,7 +125,7 @@ public class UserServiceImpl implements UserService {
|
|
|
userLog.info(user, Type.UPDATE_REGISTER.getValue());
|
|
|
|
|
|
// 同步到各个应用
|
|
|
- syncUserInfo(user.getUserUU(), "个人注册");
|
|
|
+ syncUserInfo(user.getUserUU(), noEncryPwd, "个人注册");
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
@@ -149,7 +150,7 @@ public class UserServiceImpl implements UserService {
|
|
|
public User save(User user) {
|
|
|
user = userDao.save(user);
|
|
|
/// 数据同步,先注释
|
|
|
- syncUserInfo(user.toView(), "修改用户信息");
|
|
|
+ syncUserInfo(user, null, "修改用户信息");
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
@@ -308,7 +309,7 @@ public class UserServiceImpl implements UserService {
|
|
|
userLog.info(user, Type.UPDATE_MOBILE.getValue());
|
|
|
|
|
|
// 同步到各个应用
|
|
|
- syncUserInfo(user.getUserUU(), "个人注册");
|
|
|
+ syncUserInfo(user.getUserUU(), null, "个人注册");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -330,7 +331,7 @@ public class UserServiceImpl implements UserService {
|
|
|
userLog.info(user, Type.UPDATE_EMAIL.getValue());
|
|
|
|
|
|
// 同步信息到各应用
|
|
|
- syncUserInfo(user.getUserUU(), "个人注册");
|
|
|
+ syncUserInfo(user.getUserUU(), null, "修改邮箱");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -487,6 +488,8 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
user.setPassword(getEncryPassword(Const.ENCRY_FORMAT, noEncryPwd, user.getSalt()));
|
|
|
|
|
|
+ syncUserInfo(user , noEncryPwd, "用户修改密码");
|
|
|
+
|
|
|
return userDao.save(user);
|
|
|
}
|
|
|
|
|
|
@@ -498,20 +501,31 @@ public class UserServiceImpl implements UserService {
|
|
|
/**
|
|
|
* 同步用户信息到各个应用
|
|
|
* @param userUU 用户uu号
|
|
|
+ * @param noEncryPwd 未加密密码,用于同步im
|
|
|
* @param msg 同步信息描述,用户区分同步类型
|
|
|
*/
|
|
|
- private void syncUserInfo(Long userUU, String msg) {
|
|
|
- syncUserInfo(findOneView(userUU), msg);
|
|
|
+ private void syncUserInfo(Long userUU, String noEncryPwd, String msg) {
|
|
|
+ syncUserInfo(findOne(userUU), noEncryPwd, msg);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 同步用户信息到各个应用
|
|
|
- * @param userView 用户信息视图
|
|
|
+ * @param user 用户信息
|
|
|
+ * @param noEncryPwd 未加密密码,用于同步im
|
|
|
* @param msg 同步信息描述,用户区分同步类型
|
|
|
*/
|
|
|
- private void syncUserInfo(final UserView userView, final String msg) {
|
|
|
+ private void syncUserInfo(User user, String noEncryPwd, final String msg) {
|
|
|
List<String> apps = appService.findUid();
|
|
|
|
|
|
+ try {
|
|
|
+ // 同步信息到im
|
|
|
+ String imId = syncUserToIm(user, noEncryPwd);
|
|
|
+ user.setImId(imId);
|
|
|
+ user = userDao.save(user);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ User finalUser = user;
|
|
|
ExecuteUtils.execute(new ICallable<Void, String>() {
|
|
|
|
|
|
@Override
|
|
|
@@ -520,18 +534,18 @@ public class UserServiceImpl implements UserService {
|
|
|
if (tempApp != null && StringUtils.isEmpty(tempApp.getUserControl())
|
|
|
&& !StringUtils.isEmpty(tempApp.getBackUserUrl())) {
|
|
|
String url = tempApp.getBackUserUrl();
|
|
|
- JSONObject formData = JSON.parseObject(JSON.toJSONString(userView));
|
|
|
- formData.put("password", userView.getPassword());
|
|
|
+ JSONObject formData = JSON.parseObject(JSON.toJSONString(finalUser));
|
|
|
+ formData.put("password", finalUser.getPassword());
|
|
|
HttpUtil.ResponseWrap res = null;
|
|
|
try {
|
|
|
res = HttpUtil.doPost(url, formData, 30000);
|
|
|
if (!res.isSuccess()) {
|
|
|
- syncLog.error(appId, msg + ",同步用户信息失败", JSON.toJSONString(userView), res.getContent());
|
|
|
+ syncLog.error(appId, msg + ",同步用户信息失败", JSON.toJSONString(finalUser), res.getContent());
|
|
|
} else {
|
|
|
- syncLog.info(appId, msg + ",同步用户信息成功", JSON.toJSONString(userView));
|
|
|
+ syncLog.info(appId, msg + ",同步用户信息成功", JSON.toJSONString(finalUser));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- syncLog.error(appId, msg + ",同步用户信息失败", JSON.toJSONString(userView), e.getMessage());
|
|
|
+ syncLog.error(appId, msg + ",同步用户信息失败", JSON.toJSONString(finalUser), e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
@@ -539,6 +553,31 @@ public class UserServiceImpl implements UserService {
|
|
|
}, apps);
|
|
|
}
|
|
|
|
|
|
+ private String syncUserToIm(User user, String noEncryPwd) throws Exception {
|
|
|
+ String appId = "im";
|
|
|
+ App app = appService.findOne(appId);
|
|
|
+ if (!StringUtils.isEmpty(app.getBackUserUrl())) {
|
|
|
+ String url = app.getBackUserUrl();
|
|
|
+ HttpUtil.ResponseWrap res = null;
|
|
|
+ ModelMap formData = new ModelMap();
|
|
|
+ formData.put("email", user.getEmail());
|
|
|
+ formData.put("idCard", user.getIdCard());
|
|
|
+ formData.put("name", user.getVipName());
|
|
|
+ formData.put("sex", user.getSex());
|
|
|
+ formData.put("mobile", user.getMobile());
|
|
|
+ formData.put("password", noEncryPwd);
|
|
|
+ formData.put("dialectUID", user.getImId());
|
|
|
+ res = HttpUtil.doPost(url, formData, 30000);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new Exception(res.getContent());
|
|
|
+ } else {
|
|
|
+ JSONObject obj = JSON.parseObject(res.getContent());
|
|
|
+ return String.valueOf(obj.get("dialectUID"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public UserView findOneView(Long userUU) {
|
|
|
User user = findOne(userUU);
|
|
|
return user.toView();
|