|
|
@@ -12,6 +12,7 @@ import com.zhongshu.card.server.core.dao.org.UserGroupDao;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserGroupToUserDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.*;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissEventService;
|
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -25,6 +26,7 @@ import org.springframework.util.Assert;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 用户分组
|
|
|
@@ -51,6 +53,9 @@ public class UserGroupService extends SuperService {
|
|
|
@Autowired
|
|
|
private OrganizationUserDao organizationUserDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DevicePermissEventService devicePermissEventService;
|
|
|
+
|
|
|
public ResultContent saveInfo(UserGroupParam param) {
|
|
|
Assert.hasText(param.getProjectOid(), "projectOid不能为空");
|
|
|
|
|
|
@@ -67,6 +72,8 @@ public class UserGroupService extends SuperService {
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
userGroupDao.save(entity);
|
|
|
+
|
|
|
+ // 权限变化
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -80,13 +87,25 @@ public class UserGroupService extends SuperService {
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除设备分组
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultContent deleteInfo(String id) {
|
|
|
UserGroup entity = userGroupDao.findTopById(id);
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ List<UserGroupToUser> list = userGroupToUserDao.findByUserGroup(entity);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ userIds = list.stream().map(it -> it.getUserId()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
userGroupDao.delete(entity);
|
|
|
userGroupToUserDao.deleteByUserGroup(entity);
|
|
|
+ devicePermissEventService.sendUserInfoChangeEvent(userIds, entity.getProjectOid(), "deleteInfo userGroup");
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -105,6 +124,12 @@ public class UserGroupService extends SuperService {
|
|
|
}
|
|
|
entity.setState(state);
|
|
|
userGroupDao.save(entity);
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ List<UserGroupToUser> list = userGroupToUserDao.findByUserGroup(entity);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ userIds = list.stream().map(it -> it.getUserId()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ devicePermissEventService.sendUserInfoChangeEvent(userIds, entity.getProjectOid(), "changeState userGroup");
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -120,6 +145,7 @@ public class UserGroupService extends SuperService {
|
|
|
}
|
|
|
List<OrganizationUser> list = organizationUserDao.findByIdIn(param.getOrgUserId());
|
|
|
if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
List<UserGroupToUser> saveList = new ArrayList<>();
|
|
|
for (OrganizationUser organizationUser : list) {
|
|
|
UserGroupToUser userGroupToUser = userGroupToUserDao.findTopByUserGroupAndOrganizationUser(userGroup, organizationUser);
|
|
|
@@ -134,6 +160,7 @@ public class UserGroupService extends SuperService {
|
|
|
UserAccount userAccount = organizationUser.getUser();
|
|
|
userGroupToUser.setUserName(userAccount.getName());
|
|
|
userGroupToUser.setUserId(userAccount.getUserId());
|
|
|
+ userIds.add(userAccount.getUserId());
|
|
|
|
|
|
initEntity(userGroupToUser);
|
|
|
saveList.add(userGroupToUser);
|
|
|
@@ -142,6 +169,7 @@ public class UserGroupService extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(saveList)) {
|
|
|
userGroupToUserDao.saveAll(saveList);
|
|
|
initGroupNumber(userGroup);
|
|
|
+ devicePermissEventService.sendUserInfoChangeEvent(userIds, userGroup.getProjectOid(), "groupBindUser userGroup");
|
|
|
}
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
@@ -154,6 +182,7 @@ public class UserGroupService extends SuperService {
|
|
|
}
|
|
|
userGroupToUserDao.delete(entity);
|
|
|
initGroupNumber(entity.getUserGroup());
|
|
|
+ devicePermissEventService.sendUserInfoChangeEvent(entity.getUserId(), entity.getProjectOid(), "deleteGroupUserInfo userGroup");
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -167,6 +196,9 @@ public class UserGroupService extends SuperService {
|
|
|
}
|
|
|
userGroupToUserDao.deleteAllById(param.getIds());
|
|
|
initGroupNumber(list.get(0).getUserGroup());
|
|
|
+
|
|
|
+ List<String> userIds = list.stream().map(it -> it.getUserId()).collect(Collectors.toList());
|
|
|
+ devicePermissEventService.sendUserInfoChangeEvent(userIds, list.get(0).getProjectOid(), "deleteGroupUsersInfo userGroup");
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|