Browse Source

1.调整机构小组群删除,适配学生老师调整机构接口

yuanliang 1 năm trước cách đây
mục cha
commit
6b868eeb54

+ 1 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupController.java

@@ -47,7 +47,7 @@ public class TenantGroupController {
         return R.from(wrapper);
     }
 
-    @ApiOperation(value = "详情", notes = "机构小组表-根据详情ID查询单条, 传入id")
+    @ApiOperation(value = "查询机构群成员", notes = "查询机构群成员")
     @GetMapping("/queryGroupMember/{tenantGroupId}")
     public R<List<TenantGroupWrapper.TenantGroupMember>> queryGroupMember(@PathVariable("tenantGroupId") Long tenantGroupId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();

+ 14 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -726,10 +726,21 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
                 throw new BizException("创建机构小组群失败");
             }
         }
+        if ("-1".equals(imGroupId)) {
+            // 群已经解散,改为-1标志
+            log.info("群已经解散,不再添加机构小组群:" + imGroupId);
+            return;
+        }
         try {
-            Set<Long> userIds = new HashSet<>();
-            userIds.add(studentId);
-            imGroupService.addGroupMember(imGroupId, userIds);
+            ImGroup imGroup = imGroupService.getById(imGroupId);
+            if (imGroup != null) {
+                Set<Long> userIds = new HashSet<>();
+                userIds.add(studentId);
+                imGroupService.addGroupMember(imGroupId, userIds);
+            } else {
+                tenantGroup.setImGroupId("-1");
+                tenantGroupMapper.updateById(tenantGroup);
+            }
         } catch (Exception e) {
             log.error("加入机构小组群失败", e);
             throw new BizException("加入机构小组群失败");

+ 0 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -566,16 +566,6 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
                 log.error("导入IM账号到三方 teacherId={}", teacher.getUserId(), e);
             }
 
-            // 机构老师与学生互加好友关系
-//            if (Optional.ofNullable(teacher.getTenantId()).orElse(-1L) > 0) {
-//                // 自动与机构老师成为好友
-//                Set<Long> collect = studentService.lambdaQuery()
-//                        .eq(Student::getTenantId, teacher.getTenantId()).list().stream()
-//                        .map(Student::getUserId).collect(Collectors.toSet());
-//
-//                imUserFriendService.saveUserFriend(teacher.getUserId(), collect);
-//            }
-
             //插入老师账户表
             UserAccount oldAcc = userAccountService.getById(teacherSubmitReq.getUserId());
             if (null == oldAcc) {

+ 5 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantGroupServiceImpl.java

@@ -45,6 +45,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -367,9 +368,10 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
                 continue;
             }
             String imGroupId = groupBy.get(detail.getTenantGroupId());
+            ImGroup imGroup = imGroupService.getById(Optional.ofNullable(imGroupId).orElse("-1"));
             if (toTeacher != null) {
                 // 更换群主
-                if (!StringUtils.isEmpty(imGroupId)) {
+                if (imGroup != null) {
                     // 新负责人加入群
                     try {
                         SysUser newTeacher = sysUserService.getByUserId(toTeacher);
@@ -400,11 +402,12 @@ public class TenantGroupServiceImpl extends ServiceImpl<TenantGroupMapper, Tenan
                 }
                 this.lambdaUpdate()
                         .set(TenantGroup::getAdminId, toTeacher)
+                        .set(imGroup == null, TenantGroup::getImGroupId, "-1")
                         .eq(TenantGroup::getId, detail.getTenantGroupId())
                         .update();
             } else if (Boolean.TRUE.equals(detail.getDismiss())) {
                 // 解散群
-                if (!StringUtils.isEmpty(imGroupId)) {
+                if (imGroup != null) {
                     try {
                         imGroupCoreService.groupDismiss(imGroupId);
                     } catch (Exception e) {

+ 1 - 1
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupController.java

@@ -48,7 +48,7 @@ public class TenantGroupController {
         return R.from(wrapper);
     }
 
-    @ApiOperation(value = "详情", notes = "机构小组表-根据详情ID查询单条, 传入id")
+    @ApiOperation(value = "查询机构群成员", notes = "查询机构群成员")
     @GetMapping("/queryGroupMember/{tenantGroupId}")
     public R<List<TenantGroupWrapper.TenantGroupMember>> queryGroupMember(@PathVariable("tenantGroupId") Long tenantGroupId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();