|
@@ -126,7 +126,7 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Boolean add(TenantGroupWrapper.TenantGroup tenantGroup) {
|
|
|
+ public Boolean add(TenantGroupWrapper.TenantGroup tenantGroup, Boolean imGroupCreate) {
|
|
|
TenantGroup entity = JSON.parseObject(tenantGroup.jsonString(), TenantGroup.class);
|
|
|
Integer count = this.lambdaQuery()
|
|
|
.eq(TenantGroup::getTenantId, tenantGroup.getTenantId())
|
|
@@ -137,7 +137,7 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
}
|
|
|
this.save(entity);
|
|
|
Long adminId = tenantGroup.getAdminId();
|
|
|
- if (adminId != null) {
|
|
|
+ if (adminId != null && Boolean.TRUE.equals(imGroupCreate)) {
|
|
|
// 建群
|
|
|
try {
|
|
|
ImGroupWrapper.ImGroup imGroup = new ImGroupWrapper.ImGroup();
|
|
@@ -201,6 +201,22 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
SysUser sysUser = sysUserService.getByUserId(entity.getAdminId());
|
|
|
String imGroupId = createImGroup(entity.getAdminId(), sysUser.getUsername());
|
|
|
entity.setImGroupId(imGroupId);
|
|
|
+
|
|
|
+ // 添加群成员
|
|
|
+ List<Long> userIds = tenantGroup.getUserIds();
|
|
|
+ if (CollectionUtils.isNotEmpty(userIds)) {
|
|
|
+ // 加群成员
|
|
|
+ try {
|
|
|
+ imGroupService.addGroupMember(oldGroup.getImGroupId(), new HashSet<>(userIds));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("加入机构小组群失败", e);
|
|
|
+ throw new BizException("加入机构小组群失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ studentDao.update(null, Wrappers.<Student>lambdaUpdate()
|
|
|
+ .in(Student::getUserId, userIds)
|
|
|
+ .eq(Student::getTenantId, tenantGroup.getTenantId())
|
|
|
+ .set(Student::getTenantGroupId, entity.getId()));
|
|
|
}
|
|
|
}
|
|
|
// 修改小组负责人,调整群主,更换群主需要新的群主为该群成员
|
|
@@ -217,20 +233,20 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
List<Long> removeGroupUsers = oldGroupUsers.stream()
|
|
|
.filter(next -> !newGroupUsers.contains(next)).collect(Collectors.toList());
|
|
|
// 移除的群成员,退群
|
|
|
- ImGroup imGroup = imGroupService.getById(Optional.ofNullable(entity.getImGroupId()).orElse("-1"));
|
|
|
+// ImGroup imGroup = imGroupService.getById(Optional.ofNullable(entity.getImGroupId()).orElse("-1"));
|
|
|
if (!removeGroupUsers.isEmpty()) {
|
|
|
- if (imGroup != null) {
|
|
|
- try {
|
|
|
- for (Long removeUserId : removeGroupUsers) {
|
|
|
- imGroupCoreService.groupQuit(removeUserId, ClientEnum.STUDENT.getCode(),
|
|
|
- oldGroup.getImGroupId(),
|
|
|
- true);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("群成员移出群失败", e);
|
|
|
- throw new BizException("群成员移出群失败");
|
|
|
- }
|
|
|
- }
|
|
|
+// if (imGroup != null) {
|
|
|
+// try {
|
|
|
+// for (Long removeUserId : removeGroupUsers) {
|
|
|
+// imGroupCoreService.groupQuit(removeUserId, ClientEnum.STUDENT.getCode(),
|
|
|
+// oldGroup.getImGroupId(),
|
|
|
+// true);
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("群成员移出群失败", e);
|
|
|
+// throw new BizException("群成员移出群失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
studentDao.update(null, Wrappers.<Student>lambdaUpdate()
|
|
|
.in(Student::getUserId, removeGroupUsers)
|
|
|
.eq(Student::getTenantId, tenantGroup.getTenantId())
|
|
@@ -241,14 +257,14 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
.collect(Collectors.toList());
|
|
|
if (!newAddGroupUsers.isEmpty()) {
|
|
|
// 加群成员
|
|
|
- if (imGroup != null) {
|
|
|
- try {
|
|
|
- imGroupService.addGroupMember(oldGroup.getImGroupId(), new HashSet<>(newAddGroupUsers));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("加入机构小组群失败", e);
|
|
|
- throw new BizException("加入机构小组群失败");
|
|
|
- }
|
|
|
- }
|
|
|
+// if (imGroup != null) {
|
|
|
+// try {
|
|
|
+// imGroupService.addGroupMember(oldGroup.getImGroupId(), new HashSet<>(newAddGroupUsers));
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("加入机构小组群失败", e);
|
|
|
+// throw new BizException("加入机构小组群失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
studentDao.update(null, Wrappers.<Student>lambdaUpdate()
|
|
|
.in(Student::getUserId, newAddGroupUsers)
|
|
|
.eq(Student::getTenantId, tenantGroup.getTenantId())
|