|
@@ -138,8 +138,15 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
if (count > 0) {
|
|
|
throw new BizException("小组名称已存在");
|
|
|
}
|
|
|
- this.save(entity);
|
|
|
Long adminId = tenantGroup.getAdminId();
|
|
|
+ Teacher teacher = teacherDao.selectById(adminId);
|
|
|
+ if (!tenantGroup.getTenantId().equals(teacher.getTenantId())) {
|
|
|
+ throw new BizException("负责人机构已经变更,请重新选择");
|
|
|
+ }
|
|
|
+ List<Long> userIds = tenantGroup.getUserIds();
|
|
|
+ checkStudent(tenantGroup.getTenantId(), userIds,null);
|
|
|
+
|
|
|
+ this.save(entity);
|
|
|
if (adminId != null && Boolean.TRUE.equals(imGroupCreate)) {
|
|
|
// 建群
|
|
|
try {
|
|
@@ -156,7 +163,6 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
throw new BizException("创建机构小组群失败");
|
|
|
}
|
|
|
// 加群成员
|
|
|
- List<Long> userIds = tenantGroup.getUserIds();
|
|
|
if (CollectionUtils.isNotEmpty(userIds)) {
|
|
|
try {
|
|
|
imGroupService.addGroupMember(entity.getImGroupId(), new HashSet<>(userIds));
|
|
@@ -167,7 +173,6 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
}
|
|
|
}
|
|
|
// 加群成员
|
|
|
- List<Long> userIds = tenantGroup.getUserIds();
|
|
|
if (CollectionUtils.isNotEmpty(userIds)) {
|
|
|
studentDao.update(null, Wrappers.<Student>lambdaUpdate()
|
|
|
.in(Student::getUserId, userIds)
|
|
@@ -197,6 +202,13 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
throw new BizException("小组名称已经存在");
|
|
|
}
|
|
|
|
|
|
+ Long adminId = tenantGroup.getAdminId();
|
|
|
+ Teacher teacher = teacherDao.selectById(adminId);
|
|
|
+ if (!tenantGroup.getTenantId().equals(teacher.getTenantId())) {
|
|
|
+ throw new BizException("负责人机构已经变更,请重新选择");
|
|
|
+ }
|
|
|
+ checkStudent(tenantGroup.getTenantId(), tenantGroup.getUserIds(),tenantGroup.getId());
|
|
|
+
|
|
|
TenantGroup entity = JSON.parseObject(tenantGroup.jsonString(), TenantGroup.class);
|
|
|
entity.setImGroupId(oldGroup.getImGroupId());
|
|
|
// 是否建群
|
|
@@ -526,4 +538,26 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
|
|
|
.eq(Student::getTenantGroupId, tenantGroupId);
|
|
|
return studentDao.selectList(queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ private void checkStudent(Long tenantId, List<Long> userIds,Long tenantGroupId) {
|
|
|
+ if (CollectionUtils.isEmpty(userIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .in(Student::getUserId, userIds);
|
|
|
+ List<Student> students = studentDao.selectList(queryWrapper);
|
|
|
+ if (userIds.size() != students.size()) {
|
|
|
+ throw new BizException("参数错误");
|
|
|
+ }
|
|
|
+ for (Student student : students) {
|
|
|
+ if (!tenantId.equals(student.getTenantId())) {
|
|
|
+ throw new BizException("学生已经在其他机构");
|
|
|
+ }
|
|
|
+ Long groupId = student.getTenantGroupId();
|
|
|
+ if (groupId != -1L && !groupId.equals(tenantGroupId)) {
|
|
|
+ throw new BizException("学生已经在其他小组");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|