|
|
@@ -397,16 +397,24 @@ public class UserServiceImpl implements UserService {
|
|
|
@Override
|
|
|
public void bindUserspace(String appId, Long userUU, Long spaceUU) {
|
|
|
if (StringUtils.isEmpty(userUU) || StringUtils.isEmpty(spaceUU)) {
|
|
|
- throw new VisibleError("参数错误");
|
|
|
+ throw new VisibleError("参数错误", String.format("appId:%s,userUU:%d,spaceUU:%d", appId, userUU, spaceUU));
|
|
|
}
|
|
|
|
|
|
// 找到用户和企业
|
|
|
User user = findOne(userUU);
|
|
|
+ if (user == null) {
|
|
|
+ throw new VisibleError("未找到用户信息", String.format("appId:%s,userUU:%d,spaceUU:%d", appId, userUU, spaceUU));
|
|
|
+ }
|
|
|
Userspace userspace = userspaceService.findOne(spaceUU);
|
|
|
+ if (userspace == null) {
|
|
|
+ throw new VisibleError("未找到企业信息", String.format("appId:%s,userUU:%d,spaceUU:%d", appId, userUU, spaceUU));
|
|
|
+ }
|
|
|
|
|
|
// 将企业添加到用户列表上
|
|
|
Set<Userspace> userspaces = user.getUserSpaces();
|
|
|
- userspaces.add(userspace);
|
|
|
+ if (!userspaces.add(userspace)) {
|
|
|
+ throw new VisibleError("用户已绑定该企业", String.format("appId:%s,userUU:%d,spaceUU:%d", appId, userUU, spaceUU));
|
|
|
+ }
|
|
|
|
|
|
// 保存
|
|
|
userDao.save(user);
|
|
|
@@ -414,7 +422,7 @@ public class UserServiceImpl implements UserService {
|
|
|
syncUserBindSpace(userUU, spaceUU);
|
|
|
|
|
|
// 保存日志
|
|
|
- userLogger.info(user, Type.BIND_USERSPACE.getValue() + spaceUU);
|
|
|
+ userLogger.info(user, "从" + appId + "应用:" + Type.BIND_USERSPACE.getValue() + spaceUU);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -457,7 +465,8 @@ public class UserServiceImpl implements UserService {
|
|
|
executorService.execute(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- String url = app.getBackRelationUrl();
|
|
|
+ String url;
|
|
|
+ if (StringUtils.isEmpty(url = app.getBackRelationUrl())) { return; }
|
|
|
HttpUtil.ResponseWrap res = null;
|
|
|
try {
|
|
|
res = HttpUtil.doPost(url, formData, 10000);
|
|
|
@@ -478,22 +487,24 @@ public class UserServiceImpl implements UserService {
|
|
|
@Override
|
|
|
public void unbindUserspace(Long userUU, Long spaceUU) {
|
|
|
if (StringUtils.isEmpty(userUU) || StringUtils.isEmpty(spaceUU)) {
|
|
|
- throw new VisibleError("参数错误");
|
|
|
+ throw new VisibleError("参数错误", String.format("userUU:%d,spaceUU:%d", userUU, spaceUU));
|
|
|
}
|
|
|
|
|
|
// 找到用户和企业
|
|
|
User user = findOne(userUU);
|
|
|
if (user == null) {
|
|
|
- throw new VisibleError("未找到用户信息");
|
|
|
+ throw new VisibleError("未找到用户信息", String.format("userUU:%d,spaceUU:%d", userUU, spaceUU));
|
|
|
}
|
|
|
Userspace userspace = userspaceService.findOne(spaceUU);
|
|
|
if (userspace == null) {
|
|
|
- throw new VisibleError("未找到企业信息");
|
|
|
+ throw new VisibleError("未找到企业信息", String.format("userUU:%d,spaceUU:%d", userUU, spaceUU));
|
|
|
}
|
|
|
|
|
|
// 将企业添加到用户列表上
|
|
|
Set<Userspace> userspaces = user.getUserSpaces();
|
|
|
- userspaces.remove(userspace);
|
|
|
+ if (!userspaces.remove(userspace)) {
|
|
|
+ throw new VisibleError("用户不在该企业", String.format("userUU:%d,spaceUU:%d", userUU, spaceUU));
|
|
|
+ }
|
|
|
|
|
|
// 保存
|
|
|
userDao.save(user);
|