|
|
@@ -12,18 +12,18 @@ import java.util.Set;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import com.uas.account.entity.UserDetail;
|
|
|
+import com.uas.account.util.AccountUtils;
|
|
|
import com.uas.platform.b2b.dao.DistributeDao;
|
|
|
import com.uas.platform.b2b.dao.EnterpriseDao;
|
|
|
import com.uas.platform.b2b.dao.RoleDao;
|
|
|
import com.uas.platform.b2b.dao.UserDao;
|
|
|
import com.uas.platform.b2b.dao.VendorDao;
|
|
|
-import com.uas.platform.b2b.manage.model.AccountInfo;
|
|
|
import com.uas.platform.b2b.model.Distribute;
|
|
|
import com.uas.platform.b2b.model.Enterprise;
|
|
|
import com.uas.platform.b2b.model.SearchFilter;
|
|
|
@@ -40,10 +40,7 @@ import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.util.AgentUtils;
|
|
|
-import com.uas.platform.core.util.HttpUtil;
|
|
|
-import com.uas.platform.core.util.HttpUtil.Response;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
-import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
|
|
|
/**
|
|
|
* @since 2016-9-26 21:18:35 账户中心统一管理;部分功能保留,但转移到v2目录
|
|
|
@@ -88,12 +85,13 @@ 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()));
|
|
|
- }
|
|
|
+ // 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) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
@@ -173,19 +171,21 @@ public class UserServiceImpl implements UserService {
|
|
|
newUser.setRoles(user.getRoles());
|
|
|
}
|
|
|
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);
|
|
|
- }
|
|
|
+ // 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) {
|
|
|
System.out.println("ERRO:" + e.getMessage());
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
@@ -209,19 +209,21 @@ public class UserServiceImpl implements UserService {
|
|
|
if (user1.getEnterprise() == null)
|
|
|
user1.setCurrentEnterprise();// 随便绑定一个用户所属企业
|
|
|
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);
|
|
|
- }
|
|
|
+ // 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.dialectChangePassword(user1.getUserUU(), newPassword);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
@@ -231,27 +233,49 @@ 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());
|
|
|
- }
|
|
|
+ // /**
|
|
|
+ // * 用户信息修改同时,修改到管理平台
|
|
|
+ // *
|
|
|
+ // * @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());
|
|
|
+ detail.setIdCode(user.getUserIdcode());
|
|
|
+ detail.setMobile(user.getUserTel());
|
|
|
+ detail.setName(user.getUserName());
|
|
|
+ detail.setSex(user.getUserSex());
|
|
|
+ AccountUtils.saveUser(user.getUserUU(), SystemSession.getUser().getEnterprise().getUu(), detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void postToAccountCenter(User user, String password) throws Exception {
|
|
|
+ UserDetail detail = new UserDetail();
|
|
|
+ detail.setEmail(user.getUserEmail());
|
|
|
+ detail.setIdCode(user.getUserIdcode());
|
|
|
+ detail.setMobile(user.getUserTel());
|
|
|
+ detail.setName(user.getUserName());
|
|
|
+ detail.setSex(user.getUserSex());
|
|
|
+ AccountUtils.addUser(user.getUserUU(), SystemSession.getUser().getEnterprise().getUu(), detail, password);
|
|
|
+ }
|
|
|
+
|
|
|
+ static final String defaultPassword = "111111";
|
|
|
|
|
|
@Override
|
|
|
public User addUser(User user, HttpServletRequest request) {
|
|
|
@@ -267,21 +291,24 @@ public class UserServiceImpl implements UserService {
|
|
|
user.addEnterprise(SystemSession.getUser().getEnterprise());
|
|
|
user.setCurrentEnterprise();
|
|
|
user = userDao.save(user);
|
|
|
- user.setUserPwd(Md5Utils.encode("111111", user.getUserUU()));
|
|
|
+
|
|
|
+ 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);
|
|
|
- }
|
|
|
+ // 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) {
|
|
|
userDao.delete(user);
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
@@ -352,15 +379,16 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
user.setCurrentEnterprise();
|
|
|
user = userDao.save(user);
|
|
|
- user.setUserPwd(Md5Utils.encode("111111", user.getUserUU()));
|
|
|
+ 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()));
|
|
|
- }
|
|
|
+ // 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) {
|
|
|
userDao.delete(user);
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
@@ -444,13 +472,14 @@ 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()));
|
|
|
- }
|
|
|
+ // 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.dialectChangePassword(user.getUserUU(), newPwd);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
throw new RuntimeException(e.getMessage());
|