|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2b.v2.service.impl;
|
|
|
|
|
|
+import com.uas.platform.b2b.model.Enterprise;
|
|
|
import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.sso.entity.UserView;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -12,6 +13,8 @@ import com.uas.platform.b2b.v2.service.UserService;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
+
|
|
|
@Service("v2.UserService")
|
|
|
public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@@ -25,10 +28,10 @@ public class UserServiceImpl implements UserService {
|
|
|
static final String defaultPassword = "111111";
|
|
|
|
|
|
@Override
|
|
|
- public UserView save(UserView user) {
|
|
|
+ public User save(UserView user) {
|
|
|
User oldUser = getUser(user);
|
|
|
if (oldUser == null) { // 如果是新用户,就新增一个user
|
|
|
- oldUser = new com.uas.platform.b2b.model.User();
|
|
|
+ oldUser = new com.uas.platform.b2b.model.User(user);
|
|
|
oldUser.setEnable(Constant.YES);
|
|
|
oldUser.setUserPwd(Md5Utils.encode(defaultPassword, oldUser.getUserUU()));
|
|
|
}
|
|
|
@@ -37,8 +40,6 @@ public class UserServiceImpl implements UserService {
|
|
|
oldUser.setUserName(user.getVipName());
|
|
|
oldUser.setUserSex(user.getSex());
|
|
|
oldUser.setUserTel(user.getMobile());
|
|
|
- oldUser.setUserSex(user.getSex());
|
|
|
- oldUser.setUserTel(user.getMobile());
|
|
|
if (user.getPassword() != null) {
|
|
|
if (user.getPassword().length() < 32) {// 传过来的是明文
|
|
|
oldUser.setUserPwd(Md5Utils.encode(user.getPassword(), user.getUserUU()));
|
|
|
@@ -46,8 +47,8 @@ public class UserServiceImpl implements UserService {
|
|
|
oldUser.setUserPwd(user.getPassword());// 传过来的是密文
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return user;
|
|
|
+ oldUser = userDao.save(oldUser);
|
|
|
+ return oldUser;
|
|
|
}
|
|
|
|
|
|
private com.uas.platform.b2b.model.User getUser(UserView user) {
|
|
|
@@ -67,4 +68,31 @@ public class UserServiceImpl implements UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void addUser(Long spaceUU, UserView userView) {
|
|
|
+ User user = userDao.findOne(userView.getUserUU());
|
|
|
+ Enterprise enterprise = enterpriseDao.findOne(spaceUU);
|
|
|
+ if (user == null) {
|
|
|
+ user = new User(userView);
|
|
|
+ user.setEnterprises(new HashSet<Enterprise>());
|
|
|
+ }
|
|
|
+ if (user == null || enterprise == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ user.getEnterprises().add(enterprise);
|
|
|
+ userDao.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUser(Long spaceUU, Long userUU) {
|
|
|
+ User user = userDao.findOne(userUU);
|
|
|
+ Enterprise enterprise = enterpriseDao.findOne(spaceUU);
|
|
|
+ if (user == null || enterprise == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ user.getEnterprises().remove(enterprise);
|
|
|
+ userDao.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
}
|