|
|
@@ -74,6 +74,16 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
static final String UU_REGEXP = "^\\d{4,}$";
|
|
|
|
|
|
+ /**
|
|
|
+ * 匹配中文正则式
|
|
|
+ */
|
|
|
+ private static final String CHINESE_REGEXP = "^[\u4e00-\u9fa5]*$";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 匹配英文正则式
|
|
|
+ */
|
|
|
+ private static final String ENGLISH_REGEXP = "^[A-Za-z]+$";
|
|
|
+
|
|
|
@Override
|
|
|
public boolean isEmailUseable(String email) {
|
|
|
return userDao.findUserByUserEmail(email).size() == 0;
|
|
|
@@ -85,12 +95,6 @@ public class UserServiceImpl implements UserService {
|
|
|
user.setUserPwd(Md5Utils.encode(user.getUserPwd(), user.getUserUU()));
|
|
|
user.setCurrentEnterprise();
|
|
|
try {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(user);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // user.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
postToAccountCenter(user);
|
|
|
return userDao.save(user);
|
|
|
} catch (Exception e) {
|
|
|
@@ -128,10 +132,6 @@ public class UserServiceImpl implements UserService {
|
|
|
} else {
|
|
|
return users.get(0);
|
|
|
}
|
|
|
-// if (!CollectionUtils.isEmpty(users)) {
|
|
|
-// user = users.get(0);
|
|
|
-// }
|
|
|
-// return user;
|
|
|
}
|
|
|
|
|
|
public boolean bindUser(String userUU, String enUU) {
|
|
|
@@ -225,21 +225,6 @@ public class UserServiceImpl implements UserService {
|
|
|
newUser.setRoles(existRoles);
|
|
|
}
|
|
|
try {
|
|
|
- // if
|
|
|
- // (isNotSaas(SystemSession.getUser().getEnterprise().getUu()))
|
|
|
- // {
|
|
|
- // if (newUser.getEnterprise() != null) {
|
|
|
- // newUser = userDao.save(newUser);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // if (newUser.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(newUser);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // newUser.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
- // newUser = userDao.save(newUser);
|
|
|
- // }
|
|
|
newUser = userDao.save(newUser);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
@@ -266,21 +251,6 @@ public class UserServiceImpl implements UserService {
|
|
|
user1.setCurrentEnterprise();// 随便绑定一个用户所属企业
|
|
|
Enterprise enterprise = user1.getEnterprise();
|
|
|
try {
|
|
|
- // if
|
|
|
- // (isNotSaas(SystemSession.getUser().getEnterprise().getUu()))
|
|
|
- // {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // user = userDao.save(user1);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // if (user1.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(user1);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // user1.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
- // user1 = userDao.save(user1);
|
|
|
- // }
|
|
|
user1 = userDao.save(user1);
|
|
|
AccountUtils.resetPassword(user1.getUserUU(), enterprise.getUu(), newPassword);
|
|
|
} catch (Exception e) {
|
|
|
@@ -292,31 +262,6 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // /**
|
|
|
- // * 用户信息修改同时,修改到管理平台
|
|
|
- // *
|
|
|
- // * @param newUserInfo
|
|
|
- // * @throws Exception
|
|
|
- // */
|
|
|
- // private Map<String, Object> sendUserToManage(User newUserInfo) throws
|
|
|
- // Exception {
|
|
|
- // Map<String, String> params = new HashMap<String, String>();
|
|
|
- // params.put("data", FlexJsonUtils.toJson(new AccountInfo(newUserInfo)));
|
|
|
- // Response response = HttpUtil.sendPostRequest(sysConf.getManageInner() +
|
|
|
- // "/public/account", params, true);
|
|
|
- // if (response.getStatusCode() == HttpStatus.OK.value()) {
|
|
|
- // List<Map<String, Object>> resultMap =
|
|
|
- // FlexJsonUtils.fromJsonArray(response.getResponseText(), HashMap.class);
|
|
|
- // if (resultMap.size() > 0) {
|
|
|
- // if ("true".equals(String.valueOf(resultMap.get(0).get("ok")))) {
|
|
|
- // return resultMap.get(0);
|
|
|
- // }
|
|
|
- // throw new Exception(String.valueOf(resultMap.get(0).get("error")));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // throw new Exception(response.getResponseText());
|
|
|
- // }
|
|
|
-
|
|
|
public void postToAccountCenter(User user) throws Exception {
|
|
|
UserDetail detail = new UserDetail();
|
|
|
detail.setEmail(user.getUserEmail());
|
|
|
@@ -367,19 +312,6 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
user.setUserPwd(Md5Utils.encode(defaultPassword, user.getUserUU()));
|
|
|
try {
|
|
|
- // if (isNotSaas(SystemSession.getUser().getEnterprise().getUu())) {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // user = userDao.save(user);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(user);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // user.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
- // user = userDao.save(user);
|
|
|
- // }
|
|
|
user = userDao.save(user);
|
|
|
postToAccountCenter(user, defaultPassword);
|
|
|
} catch (Exception e) {
|
|
|
@@ -459,12 +391,6 @@ public class UserServiceImpl implements UserService {
|
|
|
user = userDao.save(user);
|
|
|
user.setUserPwd(Md5Utils.encode(defaultPassword, user.getUserUU()));
|
|
|
try {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(user);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // user.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
user = userDao.save(user);
|
|
|
postToAccountCenter(user, defaultPassword);
|
|
|
} catch (Exception e) {
|
|
|
@@ -550,12 +476,6 @@ public class UserServiceImpl implements UserService {
|
|
|
if (user.getEnterprise() == null)
|
|
|
user.setCurrentEnterprise();
|
|
|
try {
|
|
|
- // if (user.getEnterprise() != null) {
|
|
|
- // Map<String, Object> res = sendUserToManage(user);
|
|
|
- // Object imid = res.get("userImid");
|
|
|
- // if (imid != null)
|
|
|
- // user.setUserIMId(Long.parseLong(imid.toString()));
|
|
|
- // }
|
|
|
user = userDao.save(user);
|
|
|
AccountUtils.resetPassword(user.getUserUU(), user.getEnterprise().getUu(), newPwd);
|
|
|
} catch (Exception e) {
|
|
|
@@ -588,6 +508,37 @@ public class UserServiceImpl implements UserService {
|
|
|
return simpleUser;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<User> findUsersByKeyWord(String keyword) {
|
|
|
+ List<User> users = new ArrayList<User>();
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ if (keyword.contains("@")) { // 按邮箱查找
|
|
|
+ users = userDao.findUserByUserEmailAndEnUU(keyword, enUU);
|
|
|
+ } else if (keyword.matches(TEL_REGEXP)) { // 按手机号查找
|
|
|
+ users = userDao.findUserByUserTelAndEnUU(keyword, enUU);
|
|
|
+ } else if (keyword.matches(UU_REGEXP)) { // 按UU号查找
|
|
|
+ users = userDao.findByEnUUAndUserUU(enUU, Long.parseLong(keyword));
|
|
|
+ } else if (!keyword.contains("@") && (keyword.matches(CHINESE_REGEXP) || keyword.matches(ENGLISH_REGEXP))) {// 按名字查找
|
|
|
+ users = userDao.findUserByUserNameAndEnUU(keyword, enUU);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(users)) {
|
|
|
+ for (User user : users) {
|
|
|
+ Set<Role> roles = user.getRoles();
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ if (!CollectionUtils.isEmpty(roles)) {
|
|
|
+ Iterator<Role> iterator = roles.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ Role role = iterator.next();
|
|
|
+ if (!role.getEnUU().equals(enuu)) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return users;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void bindUserToMyEnterprise(Long userUU) {
|
|
|
User user = userDao.findOne(userUU);
|
|
|
@@ -800,28 +751,4 @@ public class UserServiceImpl implements UserService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // /**
|
|
|
- // * 手机号更新
|
|
|
- // */
|
|
|
- // @Override
|
|
|
- // public User updateTel(String code, String tel, Long uu) {
|
|
|
- // User user = userDao.findOne(uu);
|
|
|
- // if (user == null) {
|
|
|
- // throw new IllegalOperatorException("该用户不存在");
|
|
|
- // }
|
|
|
- // boolean result = tokenService.isCertified("mobile", uu, code);
|
|
|
- // if (result) {
|
|
|
- // user.setUserTel(tel);
|
|
|
- // user = userDao.save(user);
|
|
|
- // user.setEnterprise(SystemSession.getUser().getEnterprise());
|
|
|
- // try {//更新同步到管理平台
|
|
|
- // sendUserToManage(user);
|
|
|
- // } catch (Exception e) {
|
|
|
- // e.printStackTrace();
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // throw new IllegalOperatorException("抱歉!输入验证码错误,请重新输入!!");
|
|
|
- // }
|
|
|
- // return user;
|
|
|
- // }
|
|
|
}
|