Ver código fonte

1.退群,默认是真实退群

yuanliang 1 ano atrás
pai
commit
1c66cc720e

+ 4 - 2
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ImGroupController.java

@@ -79,8 +79,10 @@ public class ImGroupController extends BaseController {
 
     @ApiOperation("退出群聊")
     @PostMapping(value = "/quit/{groupId}")
-    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId) throws Exception {
-        imGroupService.quit(groupId,sysUserService.getUserId(), ClientEnum.STUDENT);
+    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId,
+                                   @RequestParam(value = "quit",required = false, defaultValue = "false") boolean quit
+                                   ) throws Exception {
+        imGroupService.quit(groupId,sysUserService.getUserId(), ClientEnum.STUDENT, quit);
         return succeed();
     }
 

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ImGroupService.java

@@ -131,7 +131,7 @@ public interface ImGroupService extends IService<ImGroup> {
     void setTeacherFansGroup() throws Exception;
 
     //退群
-    void quit(String groupId, Long userId, ClientEnum clientType) throws Exception;
+    void quit(String groupId, Long userId, ClientEnum clientType,Boolean quit) throws Exception;
 
     /**
      * 用户群组信息

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/im/ImGroupCoreService.java

@@ -86,7 +86,7 @@ public interface ImGroupCoreService {
      * @param groupId 群组ID
      * @throws Exception Exception
      */
-    void groupQuit(GroupMemberWrapper.ImGroupMember groupMember, String groupId) throws Exception;
+    void groupQuit(GroupMemberWrapper.ImGroupMember groupMember, String groupId,Boolean quit) throws Exception;
 
     /**
      * 用户主动退出群聊
@@ -95,7 +95,7 @@ public interface ImGroupCoreService {
      * @param imGroupId 群组ID
      * @throws Exception Exception
      */
-    void groupQuit(Long userId, String clientType, String imGroupId) throws Exception;
+    void groupQuit(Long userId, String clientType, String imGroupId,Boolean quit) throws Exception;
 
     /**
      * 入群申请消息

+ 6 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/im/impl/ImGroupCoreServiceImpl.java

@@ -333,7 +333,7 @@ public class ImGroupCoreServiceImpl implements ImGroupCoreService {
      * @throws Exception Exception
      */
     @Override
-    public void groupQuit(GroupMemberWrapper.ImGroupMember imGroupMember, String groupId) throws Exception {
+    public void groupQuit(GroupMemberWrapper.ImGroupMember imGroupMember, String groupId,Boolean quit) throws Exception {
 
         // 判定登录用户是否为群主
         ImGroup imGroup = imGroupService.lambdaQuery().eq(ImGroup::getId, groupId).last("LIMIT 1").one();
@@ -369,7 +369,9 @@ public class ImGroupCoreServiceImpl implements ImGroupCoreService {
                 .clientType(imGroupMember.getClientType())
                 .build());
 
-        imPluginContext.getPluginService().groupQuit(imGroup.getId(), getImGroupMembers(groupMembers));
+        if (Optional.ofNullable(quit).orElse(true)) {
+            imPluginContext.getPluginService().groupQuit(imGroup.getId(), getImGroupMembers(groupMembers));
+        }
     }
 
     /**
@@ -381,7 +383,7 @@ public class ImGroupCoreServiceImpl implements ImGroupCoreService {
      * @throws Exception Exception
      */
     @Override
-    public void groupQuit(Long userId, String clientType, String imGroupId) throws Exception {
+    public void groupQuit(Long userId, String clientType, String imGroupId ,Boolean quit) throws Exception {
 
         ImGroup imGroup = imGroupService.getById(imGroupId);
         if (Objects.isNull(imGroup)) {
@@ -394,7 +396,7 @@ public class ImGroupCoreServiceImpl implements ImGroupCoreService {
                 .clientType(clientType)
                 .build();
         // 退出群聊
-        groupQuit(groupMember, imGroup.getId());
+        groupQuit(groupMember, imGroup.getId(),quit);
     }
 
     /**

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

@@ -438,8 +438,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void quit(String groupId, Long userId, ClientEnum clientType) throws Exception {
-        imGroupCoreService.groupQuit(userId, clientType.name(), groupId);
+    public void quit(String groupId, Long userId, ClientEnum clientType,Boolean quit) throws Exception {
+        imGroupCoreService.groupQuit(userId, clientType.name(), groupId, quit);
     }
 
     @Override
@@ -570,7 +570,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
                                 .count();
                         // 拥有老师身份,且非群主时,需要主动退出群聊
                         if (count > 0 && numbers <= 0) {
-                            quit(groupId, userId, ClientEnum.TEACHER);
+                            quit(groupId, userId, ClientEnum.TEACHER,true);
                         }
 
                         // 缓存重新入群标识, 默认有效期为120天

+ 4 - 2
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/ImGroupController.java

@@ -100,8 +100,10 @@ public class ImGroupController extends BaseController {
 
     @ApiOperation("退出群聊")
     @PostMapping(value = "/quit/{groupId}")
-    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId) throws Exception {
-        imGroupService.quit(groupId,sysUserService.getUserId(), ClientEnum.STUDENT);
+    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId,
+                                   @RequestParam(value = "quit",required = false,defaultValue = "false") boolean quit
+                                   ) throws Exception {
+        imGroupService.quit(groupId,sysUserService.getUserId(), ClientEnum.STUDENT,quit);
         return succeed();
     }
 

+ 4 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/ImGroupController.java

@@ -69,8 +69,10 @@ public class ImGroupController extends BaseController {
 
     @ApiOperation("退出群聊")
     @PostMapping(value = "/quit/{groupId}")
-    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId) throws Exception {
-        imGroupService.quit(groupId, sysUserService.getUserId(), ClientEnum.TEACHER);
+    public HttpResponseResult quit(@ApiParam(value = "群编号", required = true) @PathVariable("groupId") String groupId,
+                                   @RequestParam(value = "quit",required = false,defaultValue = "false") boolean quit
+                                   ) throws Exception {
+        imGroupService.quit(groupId, sysUserService.getUserId(), ClientEnum.TEACHER, quit);
         return succeed();
     }