xsx 1 год назад
Родитель
Сommit
238f581dff
21 измененных файлов с 265 добавлено и 122 удалено
  1. 2 2
      db/im-platfrom.sql
  2. 1 1
      im-platform/src/main/java/com/bx/implatform/config/SwaggerConfig.java
  3. 1 1
      im-platform/src/main/java/com/bx/implatform/contant/RedisKey.java
  4. 3 3
      im-platform/src/main/java/com/bx/implatform/controller/FriendController.java
  5. 5 5
      im-platform/src/main/java/com/bx/implatform/controller/GroupController.java
  6. 5 5
      im-platform/src/main/java/com/bx/implatform/controller/GroupMessageController.java
  7. 7 7
      im-platform/src/main/java/com/bx/implatform/controller/PrivateMessageController.java
  8. 1 1
      im-platform/src/main/java/com/bx/implatform/controller/UserController.java
  9. 8 8
      im-platform/src/main/java/com/bx/implatform/controller/WebrtcPrivateController.java
  10. 1 1
      im-platform/src/main/java/com/bx/implatform/service/IGroupService.java
  11. 6 7
      im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java
  12. 10 17
      im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java
  13. 20 21
      im-platform/src/main/java/com/bx/implatform/service/impl/GroupServiceImpl.java
  14. 5 5
      im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java
  15. 2 2
      im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java
  16. 27 29
      im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java
  17. 78 0
      im-platform/src/main/java/com/bx/implatform/task/GroupBannedConsumerTask.java
  18. 70 0
      im-platform/src/main/java/com/bx/implatform/task/GroupUnbanConsumerTask.java
  19. 5 3
      im-platform/src/main/resources/application.yml
  20. 5 3
      im-server/src/main/resources/application.yml
  21. 3 1
      im-ui/src/components/setting/Setting.vue

+ 2 - 2
db/im-platfrom.sql

@@ -8,7 +8,7 @@ create table `im_user`(
     `password` varchar(255) not null comment '密码(明文)',
     `sex`  tinyint(1) default 0 comment '性别 0:男 1:女',
     `is_banned` tinyint(1) default 0 comment '是否被封禁 0:否 1:是',
-    `reason` varchar(255) comment '被封禁原因',
+    `reason` varchar(255) default ''  comment '被封禁原因',
     `type`  smallint default 1 comment '用户类型 1:普通用户 2:审核账户',
     `signature` varchar(1024) default '' comment '个性签名',
     `last_login_time`  datetime DEFAULT null comment '最后登录时间',
@@ -48,7 +48,7 @@ create table `im_group`(
     `head_image_thumb` varchar(255) default '' comment '群头像缩略图',
     `notice` varchar(1024)  default '' comment '群公告',
     `is_banned` tinyint(1) default 0 comment '是否被封禁 0:否 1:是',
-    `reason` varchar(255) comment '被封禁原因',
+    `reason` varchar(255) default '' comment '被封禁原因',
     `deleted` tinyint(1) default 0   comment '是否已删除',
     `created_time` datetime default CURRENT_TIMESTAMP comment '创建时间'
 )ENGINE=InnoDB CHARSET=utf8mb3 comment '群';

+ 1 - 1
im-platform/src/main/java/com/bx/implatform/config/SwaggerConfig.java

@@ -26,7 +26,7 @@ public class SwaggerConfig {
         Contact contact = new Contact();
         contact.setName("Blue");
         return new OpenAPI().info(new Info()
-            .title("盒子IM")
+            .title("盒子IM接口文档")
             .description("盒子IM业务平台服务")
             .contact(contact)
             .version("3.0")

+ 1 - 1
im-platform/src/main/java/com/bx/implatform/contant/RedisKey.java

@@ -32,7 +32,7 @@ public final class RedisKey {
     /**
      * 群聊解封消息队列
      */
-    public static final String IM_QUEUE_GROUP_UNBAN = "im:queue:user:unban";
+    public static final String IM_QUEUE_GROUP_UNBAN = "im:queue:group:unban";
 
 
     /**

+ 3 - 3
im-platform/src/main/java/com/bx/implatform/controller/FriendController.java

@@ -41,21 +41,21 @@ public class FriendController {
 
     @PostMapping("/add")
     @Operation(summary = "添加好友", description = "双方建立好友关系")
-    public Result addFriend(@NotNull(message = "好友id不可为空") @RequestParam("friendId") Long friendId) {
+    public Result addFriend(@NotNull(message = "好友id不可为空") @RequestParam Long friendId) {
         friendService.addFriend(friendId);
         return ResultUtils.success();
     }
 
     @GetMapping("/find/{friendId}")
     @Operation(summary = "查找好友信息", description = "查找好友信息")
-    public Result<FriendVO> findFriend(@NotNull(message = "好友id不可为空") @PathVariable("friendId") Long friendId) {
+    public Result<FriendVO> findFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
         return ResultUtils.success(friendService.findFriend(friendId));
     }
 
 
     @DeleteMapping("/delete/{friendId}")
     @Operation(summary = "删除好友", description = "解除好友关系")
-    public Result delFriend(@NotNull(message = "好友id不可为空") @PathVariable("friendId") Long friendId) {
+    public Result delFriend(@NotNull(message = "好友id不可为空") @PathVariable Long friendId) {
         friendService.delFriend(friendId);
         return ResultUtils.success();
     }

+ 5 - 5
im-platform/src/main/java/com/bx/implatform/controller/GroupController.java

@@ -37,14 +37,14 @@ public class GroupController {
 
     @Operation(summary = "解散群聊", description = "解散群聊")
     @DeleteMapping("/delete/{groupId}")
-    public Result deleteGroup(@NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId) {
+    public Result deleteGroup(@NotNull(message = "群聊id不能为空") @PathVariable Long groupId) {
         groupService.deleteGroup(groupId);
         return ResultUtils.success();
     }
 
     @Operation(summary = "查询群聊", description = "查询单个群聊信息")
     @GetMapping("/find/{groupId}")
-    public Result<GroupVO> findGroup(@NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId) {
+    public Result<GroupVO> findGroup(@NotNull(message = "群聊id不能为空") @PathVariable Long groupId) {
         return ResultUtils.success(groupService.findById(groupId));
     }
 
@@ -64,20 +64,20 @@ public class GroupController {
     @Operation(summary = "查询群聊成员", description = "查询群聊成员")
     @GetMapping("/members/{groupId}")
     public Result<List<GroupMemberVO>> findGroupMembers(
-        @NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId) {
+        @NotNull(message = "群聊id不能为空") @PathVariable Long groupId) {
         return ResultUtils.success(groupService.findGroupMembers(groupId));
     }
 
     @Operation(summary = "退出群聊", description = "退出群聊")
     @DeleteMapping("/quit/{groupId}")
-    public Result quitGroup(@NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId) {
+    public Result quitGroup(@NotNull(message = "群聊id不能为空") @PathVariable Long groupId) {
         groupService.quitGroup(groupId);
         return ResultUtils.success();
     }
 
     @Operation(summary = "踢出群聊", description = "将用户踢出群聊")
     @DeleteMapping("/kick/{groupId}")
-    public Result kickGroup(@NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId,
+    public Result kickGroup(@NotNull(message = "群聊id不能为空") @PathVariable Long groupId,
         @NotNull(message = "用户id不能为空") @RequestParam Long userId) {
         groupService.kickGroup(groupId, userId);
         return ResultUtils.success();

+ 5 - 5
im-platform/src/main/java/com/bx/implatform/controller/GroupMessageController.java

@@ -30,29 +30,29 @@ public class GroupMessageController {
 
     @DeleteMapping("/recall/{id}")
     @Operation(summary = "撤回消息", description = "撤回群聊消息")
-    public Result<Long> recallMessage(@NotNull(message = "消息id不能为空") @PathVariable("id") Long id) {
+    public Result<Long> recallMessage(@NotNull(message = "消息id不能为空") @PathVariable Long id) {
         groupMessageService.recallMessage(id);
         return ResultUtils.success();
     }
 
     @GetMapping("/pullOfflineMessage")
     @Operation(summary = "拉取离线消息", description = "拉取离线消息,消息将通过webscoket异步推送")
-    public Result pullOfflineMessage(@RequestParam("minId") Long minId) {
+    public Result pullOfflineMessage(@RequestParam Long minId) {
         groupMessageService.pullOfflineMessage(minId);
         return ResultUtils.success();
     }
 
     @PutMapping("/readed")
     @Operation(summary = "消息已读", description = "将群聊中的消息状态置为已读")
-    public Result readedMessage(@RequestParam("groupId") Long groupId) {
+    public Result readedMessage(@RequestParam Long groupId) {
         groupMessageService.readedMessage(groupId);
         return ResultUtils.success();
     }
 
     @GetMapping("/findReadedUsers")
     @Operation(summary = "获取已读用户id", description = "获取消息已读用户列表")
-    public Result<List<Long>> findReadedUsers(@RequestParam("groupId") Long groupId,
-        @RequestParam("messageId") Long messageId) {
+    public Result<List<Long>> findReadedUsers(@RequestParam Long groupId,
+        @RequestParam Long messageId) {
         return ResultUtils.success(groupMessageService.findReadedUsers(groupId, messageId));
     }
 

+ 7 - 7
im-platform/src/main/java/com/bx/implatform/controller/PrivateMessageController.java

@@ -30,37 +30,37 @@ public class PrivateMessageController {
 
     @DeleteMapping("/recall/{id}")
     @Operation(summary = "撤回消息", description = "撤回私聊消息")
-    public Result<Long> recallMessage(@NotNull(message = "消息id不能为空") @PathVariable("id") Long id) {
+    public Result<Long> recallMessage(@NotNull(message = "消息id不能为空") @PathVariable Long id) {
         privateMessageService.recallMessage(id);
         return ResultUtils.success();
     }
 
     @GetMapping("/pullOfflineMessage")
     @Operation(summary = "拉取离线消息", description = "拉取离线消息,消息将通过webscoket异步推送")
-    public Result pullOfflineMessage(@RequestParam("minId") Long minId) {
+    public Result pullOfflineMessage(@RequestParam Long minId) {
         privateMessageService.pullOfflineMessage(minId);
         return ResultUtils.success();
     }
 
     @PutMapping("/readed")
     @Operation(summary = "消息已读", description = "将会话中接收的消息状态置为已读")
-    public Result readedMessage(@RequestParam("friendId") Long friendId) {
+    public Result readedMessage(@RequestParam Long friendId) {
         privateMessageService.readedMessage(friendId);
         return ResultUtils.success();
     }
 
     @GetMapping("/maxReadedId")
     @Operation(summary = "获取最大已读消息的id", description = "获取某个会话中已读消息的最大id")
-    public Result<Long> getMaxReadedId(@RequestParam("friendId") Long friendId) {
+    public Result<Long> getMaxReadedId(@RequestParam Long friendId) {
         return ResultUtils.success(privateMessageService.getMaxReadedId(friendId));
     }
 
     @GetMapping("/history")
     @Operation(summary = "查询聊天记录", description = "查询聊天记录")
     public Result<List<PrivateMessageVO>> recallMessage(
-        @NotNull(message = "好友id不能为空") @RequestParam("friendId") Long friendId,
-        @NotNull(message = "页码不能为空") @RequestParam("page") Long page,
-        @NotNull(message = "size不能为空") @RequestParam("size") Long size) {
+        @NotNull(message = "好友id不能为空") @RequestParam Long friendId,
+        @NotNull(message = "页码不能为空") @RequestParam Long page,
+        @NotNull(message = "size不能为空") @RequestParam Long size) {
         return ResultUtils.success(privateMessageService.findHistoryMessage(friendId, page, size));
     }
 

+ 1 - 1
im-platform/src/main/java/com/bx/implatform/controller/UserController.java

@@ -58,7 +58,7 @@ public class UserController {
 
     @GetMapping("/findByName")
     @Operation(summary = "查找用户", description = "根据用户名或昵称查找用户")
-    public Result<List<UserVO>> findByName(@RequestParam("name") String name) {
+    public Result<List<UserVO>> findByName(@RequestParam String name) {
         return ResultUtils.success(userService.findUserByName(name));
     }
 }

+ 8 - 8
im-platform/src/main/java/com/bx/implatform/controller/WebrtcPrivateController.java

@@ -20,7 +20,7 @@ public class WebrtcPrivateController {
     @OnlineCheck
     @Operation(summary = "呼叫视频通话")
     @PostMapping("/call")
-    public Result call(@RequestParam("uid") Long uid, @RequestParam(name = "mode", defaultValue = "video") String mode,
+    public Result call(@RequestParam Long uid, @RequestParam(defaultValue = "video") String mode,
         @RequestBody String offer) {
         webrtcPrivateService.call(uid, mode, offer);
         return ResultUtils.success();
@@ -28,49 +28,49 @@ public class WebrtcPrivateController {
 
     @Operation(summary = "接受视频通话")
     @PostMapping("/accept")
-    public Result accept(@RequestParam("uid") Long uid, @RequestBody String answer) {
+    public Result accept(@RequestParam Long uid, @RequestBody String answer) {
         webrtcPrivateService.accept(uid, answer);
         return ResultUtils.success();
     }
 
     @Operation(summary = "拒绝视频通话")
     @PostMapping("/reject")
-    public Result reject(@RequestParam("uid") Long uid) {
+    public Result reject(@RequestParam Long uid) {
         webrtcPrivateService.reject(uid);
         return ResultUtils.success();
     }
 
     @Operation(summary = "取消呼叫")
     @PostMapping("/cancel")
-    public Result cancel(@RequestParam("uid") Long uid) {
+    public Result cancel(@RequestParam Long uid) {
         webrtcPrivateService.cancel(uid);
         return ResultUtils.success();
     }
 
     @Operation(summary = "呼叫失败")
     @PostMapping("/failed")
-    public Result failed(@RequestParam("uid") Long uid, @RequestParam String reason) {
+    public Result failed(@RequestParam Long uid, @RequestParam String reason) {
         webrtcPrivateService.failed(uid, reason);
         return ResultUtils.success();
     }
 
     @Operation(summary = "挂断")
     @PostMapping("/handup")
-    public Result handup(@RequestParam("uid") Long uid) {
+    public Result handup(@RequestParam Long uid) {
         webrtcPrivateService.handup(uid);
         return ResultUtils.success();
     }
 
     @PostMapping("/candidate")
     @Operation(summary = "同步candidate")
-    public Result candidate(@RequestParam("uid") Long uid, @RequestBody String candidate) {
+    public Result candidate(@RequestParam Long uid, @RequestBody String candidate) {
         webrtcPrivateService.candidate(uid, candidate);
         return ResultUtils.success();
     }
 
     @Operation(summary = "获取通话信息")
     @PostMapping("/heartbeat")
-    public Result heartbeat(@RequestParam("uid") Long uid) {
+    public Result heartbeat(@RequestParam Long uid) {
         webrtcPrivateService.heartbeat(uid);
         return ResultUtils.success();
     }

+ 1 - 1
im-platform/src/main/java/com/bx/implatform/service/IGroupService.java

@@ -68,7 +68,7 @@ public interface IGroupService extends IService<Group> {
      * @param groupId 群聊id
      * @return 群聊实体
      */
-    Group getById(Long groupId);
+    Group getAndCheckById(Long groupId);
 
     /**
      * 根据id查找群聊

+ 6 - 7
im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Objects;
 
 @Slf4j
 @Service
@@ -47,7 +48,7 @@ public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> impleme
     public void addFriend(Long friendId) {
         long userId = SessionContext.getSession().getUserId();
         if (friendId.equals(userId)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "不允许添加自己为好友");
+            throw new GlobalException("不允许添加自己为好友");
         }
         // 互相绑定好友关系
         FriendServiceImpl proxy = (FriendServiceImpl) AopContext.currentProxy();
@@ -87,12 +88,10 @@ public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> impleme
         queryWrapper.lambda()
                 .eq(Friend::getUserId, userId)
                 .eq(Friend::getFriendId, vo.getId());
-
         Friend f = this.getOne(queryWrapper);
-        if (f == null) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "对方不是您的好友");
+        if (Objects.isNull(f)) {
+            throw new GlobalException("对方不是您的好友");
         }
-
         f.setFriendHeadImage(vo.getHeadImage());
         f.setFriendNickName(vo.getNickName());
         this.updateById(f);
@@ -148,8 +147,8 @@ public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> impleme
                 .eq(Friend::getUserId, session.getUserId())
                 .eq(Friend::getFriendId, friendId);
         Friend friend = this.getOne(wrapper);
-        if (friend == null) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "对方不是您的好友");
+        if (Objects.isNull(friend)) {
+            throw new GlobalException("对方不是您的好友");
         }
         FriendVO vo = new FriendVO();
         vo.setId(friend.getFriendId());

+ 10 - 17
im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java

@@ -21,7 +21,6 @@ import com.bx.implatform.entity.GroupMember;
 import com.bx.implatform.entity.GroupMessage;
 import com.bx.implatform.enums.MessageStatus;
 import com.bx.implatform.enums.MessageType;
-import com.bx.implatform.enums.ResultCode;
 import com.bx.implatform.exception.GlobalException;
 import com.bx.implatform.mapper.GroupMessageMapper;
 import com.bx.implatform.service.IGroupMemberService;
@@ -57,17 +56,11 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
     @Override
     public Long sendMessage(GroupMessageDTO dto) {
         UserSession session = SessionContext.getSession();
-        Group group = groupService.getById(dto.getGroupId());
-        if (Objects.isNull(group)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群聊不存在");
-        }
-        if (Boolean.TRUE.equals(group.getDeleted())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群聊已解散");
-        }
+        Group group = groupService.getAndCheckById(dto.getGroupId());
         // 是否在群聊里面
         GroupMember member = groupMemberService.findByGroupAndUserId(dto.getGroupId(), session.getUserId());
         if (Objects.isNull(member) || member.getQuit()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您已不在群聊里面,无法发送消息");
+            throw new GlobalException("您已不在群聊里面,无法发送消息");
         }
         // 群聊成员列表
         List<Long> userIds = groupMemberService.findUserIdsByGroupId(group.getId());
@@ -103,18 +96,18 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
         UserSession session = SessionContext.getSession();
         GroupMessage msg = this.getById(id);
         if (Objects.isNull(msg)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "消息不存在");
+            throw new GlobalException("消息不存在");
         }
         if (!msg.getSendId().equals(session.getUserId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "这条消息不是由您发送,无法撤回");
+            throw new GlobalException("这条消息不是由您发送,无法撤回");
         }
         if (System.currentTimeMillis() - msg.getSendTime().getTime() > IMConstant.ALLOW_RECALL_SECOND * 1000) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "消息已发送超过5分钟,无法撤回");
+            throw new GlobalException("消息已发送超过5分钟,无法撤回");
         }
         // 判断是否在群里
         GroupMember member = groupMemberService.findByGroupAndUserId(msg.getGroupId(), session.getUserId());
         if (Objects.isNull(member) || Boolean.TRUE.equals(member.getQuit())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您已不在群聊里面,无法撤回消息");
+            throw new GlobalException("您已不在群聊里面,无法撤回消息");
         }
         // 修改数据库
         msg.setStatus(MessageStatus.RECALL.code());
@@ -151,7 +144,7 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
     public void pullOfflineMessage(Long minId) {
         UserSession session = SessionContext.getSession();
         if(!imClient.isOnline(session.getUserId())){
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "网络连接失败,无法拉取离线消息");
+            throw new GlobalException("网络连接失败,无法拉取离线消息");
         }
         // 查询用户加入的群组
         List<GroupMember> members = groupMemberService.findByUserId(session.getUserId());
@@ -315,12 +308,12 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
         UserSession session = SessionContext.getSession();
         GroupMessage message = this.getById(messageId);
         if (Objects.isNull(message)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "消息不存在");
+            throw new GlobalException("消息不存在");
         }
         // 是否在群聊里面
         GroupMember member = groupMemberService.findByGroupAndUserId(groupId, session.getUserId());
         if (Objects.isNull(member) || member.getQuit()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您已不在群聊里面");
+            throw new GlobalException("您已不在群聊里面");
         }
             // 已读位置key
         String key = StrUtil.join(":", RedisKey.IM_GROUP_READED_POSITION, groupId);
@@ -339,7 +332,7 @@ public class GroupMessageServiceImpl extends ServiceImpl<GroupMessageMapper, Gro
         // 群聊成员信息
         GroupMember member = groupMemberService.findByGroupAndUserId(groupId, userId);
         if (Objects.isNull(member) || member.getQuit()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您已不在群聊中");
+            throw new GlobalException("您已不在群聊中");
         }
         // 查询聊天记录,只查询加入群聊时间之后的消息
         QueryWrapper<GroupMessage> wrapper = new QueryWrapper<>();

+ 20 - 21
im-platform/src/main/java/com/bx/implatform/service/impl/GroupServiceImpl.java

@@ -14,7 +14,6 @@ import com.bx.implatform.contant.RedisKey;
 import com.bx.implatform.entity.*;
 import com.bx.implatform.enums.MessageStatus;
 import com.bx.implatform.enums.MessageType;
-import com.bx.implatform.enums.ResultCode;
 import com.bx.implatform.exception.GlobalException;
 import com.bx.implatform.mapper.GroupMapper;
 import com.bx.implatform.mapper.GroupMessageMapper;
@@ -43,9 +42,9 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
-@CacheConfig(cacheManager = "cacheManager",cacheNames = RedisKey.IM_CACHE_GROUP)
 @Service
 @RequiredArgsConstructor
+@CacheConfig(cacheNames = RedisKey.IM_CACHE_GROUP)
 public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements IGroupService {
     private final IUserService userService;
     private final IGroupMemberService groupMemberService;
@@ -84,7 +83,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
     public GroupVO modifyGroup(GroupVO vo) {
         UserSession session = SessionContext.getSession();
         // 校验是不是群主,只有群主能改信息
-        Group group = this.getById(vo.getId());
+        Group group = this.getAndCheckById(vo.getId());
         // 群主有权修改群基本信息
         if (group.getOwnerId().equals(session.getUserId())) {
             group = BeanUtils.copyProperties(vo, Group.class);
@@ -93,7 +92,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
         // 更新成员信息
         GroupMember member = groupMemberService.findByGroupAndUserId(vo.getId(), session.getUserId());
         if (Objects.isNull(member) || member.getQuit()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您不是群聊的成员");
+            throw new GlobalException( "您不是群聊的成员");
         }
         member.setAliasName(StringUtils.isEmpty(vo.getAliasName()) ? session.getNickName() : vo.getAliasName());
         member.setRemark(StringUtils.isEmpty(vo.getRemark()) ? Objects.requireNonNull(group).getName() : vo.getRemark());
@@ -109,7 +108,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
         UserSession session = SessionContext.getSession();
         Group group = this.getById(groupId);
         if (!group.getOwnerId().equals(session.getUserId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "只有群主才有权限解除群聊");
+            throw new GlobalException("只有群主才有权限解除群聊");
         }
         // 群聊用户id
         List<Long> userIds = groupMemberService.findUserIdsByGroupId(groupId);
@@ -131,7 +130,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
         Long userId = SessionContext.getSession().getUserId();
         Group group = this.getById(groupId);
         if (group.getOwnerId().equals(userId)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您是群主,不可退出群聊");
+            throw new GlobalException( "您是群主,不可退出群聊");
         }
         // 删除群聊成员
         groupMemberService.removeByGroupAndUserId(groupId, userId);
@@ -146,12 +145,12 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
     @Override
     public void kickGroup(Long groupId, Long userId) {
         UserSession session = SessionContext.getSession();
-        Group group = this.getById(groupId);
+        Group group = this.getAndCheckById(groupId);
         if (!group.getOwnerId().equals(session.getUserId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您不是群主,没有权限踢人");
+            throw new GlobalException( "您不是群主,没有权限踢人");
         }
         if (userId.equals(session.getUserId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "亲,不能移除自己哟");
+            throw new GlobalException( "亲,不能移除自己哟");
         }
         // 删除群聊成员
         groupMemberService.removeByGroupAndUserId(groupId, userId);
@@ -168,11 +167,11 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
         UserSession session = SessionContext.getSession();
         Group group = super.getById(groupId);
         if (Objects.isNull(group)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群组不存在");
+            throw new GlobalException( "群组不存在");
         }
         GroupMember member = groupMemberService.findByGroupAndUserId(groupId, session.getUserId());
         if (Objects.isNull(member)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您未加入群聊");
+            throw new GlobalException( "您未加入群聊");
         }
         GroupVO vo = BeanUtils.copyProperties(group, GroupVO.class);
         vo.setAliasName(member.getAliasName());
@@ -183,13 +182,16 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
 
     @Cacheable(key = "#groupId")
     @Override
-    public Group getById(Long groupId) {
+    public Group getAndCheckById(Long groupId) {
         Group group = super.getById(groupId);
         if (Objects.isNull(group)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群组不存在");
+            throw new GlobalException( "群组不存在");
         }
         if (group.getDeleted()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群组'" + group.getName() + "'已解散");
+            throw new GlobalException( "群组'" + group.getName() + "'已解散");
+        }
+        if (group.getIsBanned()) {
+            throw new GlobalException( "群组'" + group.getName() + "'已被封禁,原因:"+group.getReason());
         }
         return group;
     }
@@ -223,26 +225,23 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements
     @Override
     public void invite(GroupInviteVO vo) {
         UserSession session = SessionContext.getSession();
-        Group group = this.getById(vo.getGroupId());
-        if (Objects.isNull(group)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群聊不存在");
-        }
+        Group group = this.getAndCheckById(vo.getGroupId());
         GroupMember member = groupMemberService.findByGroupAndUserId(vo.getGroupId(), session.getUserId());
         if (Objects.isNull(group) || member.getQuit()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您不在群聊中,邀请失败");
+            throw new GlobalException("您不在群聊中,邀请失败");
         }
         // 群聊人数校验
         List<GroupMember> members = groupMemberService.findByGroupId(vo.getGroupId());
         long size = members.stream().filter(m -> !m.getQuit()).count();
         if (vo.getFriendIds().size() + size > Constant.MAX_GROUP_MEMBER) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "群聊人数不能大于" + Constant.MAX_GROUP_MEMBER + "人");
+            throw new GlobalException("群聊人数不能大于" + Constant.MAX_GROUP_MEMBER + "人");
         }
         // 找出好友信息
         List<Friend> friends = friendsService.findFriendByUserId(session.getUserId());
         List<Friend> friendsList = vo.getFriendIds().stream().map(id -> friends.stream().filter(f -> f.getFriendId().equals(id)).findFirst().get())
                 .collect(Collectors.toList());
         if (friendsList.size() != vo.getFriendIds().size()) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "部分用户不是您的好友,邀请失败");
+            throw new GlobalException( "部分用户不是您的好友,邀请失败");
         }
         // 批量保存成员数据
         List<GroupMember> groupMembers = friendsList.stream().map(f -> {

+ 5 - 5
im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java

@@ -49,7 +49,7 @@ public class PrivateMessageServiceImpl extends ServiceImpl<PrivateMessageMapper,
         UserSession session = SessionContext.getSession();
         Boolean isFriends = friendService.isFriend(session.getUserId(), dto.getRecvId());
         if (Boolean.FALSE.equals(isFriends)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "您已不是对方好友,无法发送消息");
+            throw new GlobalException("您已不是对方好友,无法发送消息");
         }
         // 保存消息
         PrivateMessage msg = BeanUtils.copyProperties(dto, PrivateMessage.class);
@@ -78,13 +78,13 @@ public class PrivateMessageServiceImpl extends ServiceImpl<PrivateMessageMapper,
         UserSession session = SessionContext.getSession();
         PrivateMessage msg = this.getById(id);
         if (Objects.isNull(msg)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "消息不存在");
+            throw new GlobalException("消息不存在");
         }
         if (!msg.getSendId().equals(session.getUserId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "这条消息不是由您发送,无法撤回");
+            throw new GlobalException("这条消息不是由您发送,无法撤回");
         }
         if (System.currentTimeMillis() - msg.getSendTime().getTime() > IMConstant.ALLOW_RECALL_SECOND * 1000) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "消息已发送超过5分钟,无法撤回");
+            throw new GlobalException("消息已发送超过5分钟,无法撤回");
         }
         // 修改消息状态
         msg.setStatus(MessageStatus.RECALL.code());
@@ -138,7 +138,7 @@ public class PrivateMessageServiceImpl extends ServiceImpl<PrivateMessageMapper,
     public void pullOfflineMessage(Long minId) {
         UserSession session = SessionContext.getSession();
         if(!imClient.isOnline(session.getUserId())){
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "网络连接失败,无法拉取离线消息");
+            throw new GlobalException("网络连接失败,无法拉取离线消息");
         }
         // 查询用户好友列表
         List<Friend> friends = friendService.findFriendByUserId(session.getUserId());

+ 2 - 2
im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java

@@ -141,11 +141,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     public void update(UserVO vo) {
         UserSession session = SessionContext.getSession();
         if (!session.getUserId().equals(vo.getId())) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "不允许修改其他用户的信息!");
+            throw new GlobalException("不允许修改其他用户的信息!");
         }
         User user = this.getById(vo.getId());
         if (Objects.isNull(user)) {
-            throw new GlobalException(ResultCode.PROGRAM_ERROR, "用户不存在");
+            throw new GlobalException("用户不存在");
         }
         // 更新好友昵称和头像
         if (!user.getNickName().equals(vo.getNickName()) || !user.getHeadImageThumb().equals(vo.getHeadImageThumb())) {

+ 27 - 29
im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java

@@ -17,6 +17,7 @@ import com.bx.implatform.enums.MessageType;
 import com.bx.implatform.exception.GlobalException;
 import com.bx.implatform.service.IGroupMemberService;
 import com.bx.implatform.service.IGroupMessageService;
+import com.bx.implatform.service.IGroupService;
 import com.bx.implatform.service.IWebrtcGroupService;
 import com.bx.implatform.session.SessionContext;
 import com.bx.implatform.session.UserSession;
@@ -39,7 +40,7 @@ import java.util.stream.Collectors;
 /**
  * 群语音通话服务类,所有涉及修改webtcSession的方法都要挂分布式锁
  *
- * @author: blue
+ * @author:  blue
  * @date: 2024-06-01
  * @version: 1.0
  */
@@ -47,7 +48,7 @@ import java.util.stream.Collectors;
 @Service
 @RequiredArgsConstructor
 public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
-
+    private final IGroupService groupService;
     private final IGroupMemberService groupMemberService;
     private final IGroupMessageService groupMessageService;
     private final RedisTemplate<String, Object> redisTemplate;
@@ -55,15 +56,12 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
     private final UserStateUtils userStateUtils;
     private final WebrtcConfig webrtcConfig;
 
-
     @OnlineCheck
     @RedisLock(prefixKey = RedisKey.IM_LOCK_RTC_GROUP, key = "#dto.groupId")
     @Override
     public void setup(WebrtcGroupSetupDTO dto) {
         UserSession userSession = SessionContext.getSession();
-        if(!imClient.isOnline(userSession.getUserId())){
-            throw new GlobalException("您已断开连接,请重新登陆");
-        }
+        groupService.getAndCheckById(dto.getGroupId());
         if (dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) {
             throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话");
         }
@@ -72,7 +70,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
             throw new GlobalException("部分用户不在群聊中");
         }
         String key = buildWebrtcSessionKey(dto.getGroupId());
-        if (redisTemplate.hasKey(key)) {
+        if (Boolean.TRUE.equals(redisTemplate.hasKey(key))) {
             throw new GlobalException("该群聊已存在一个通话");
         }
         // 有效用户
@@ -116,11 +114,11 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         }
         // 向被邀请的用户广播消息,发起呼叫
         List<Long> recvIds = getRecvIds(userInfos);
-        sendRtcMessage1(MessageType.RTC_GROUP_SETUP, dto.getGroupId(), recvIds, JSON.toJSONString(userInfos),false);
+        sendRtcMessage1(MessageType.RTC_GROUP_SETUP, dto.getGroupId(), recvIds, JSON.toJSONString(userInfos), false);
         // 发送文字提示信息
-        WebrtcUserInfo mineInfo = findUserInfo(webrtcSession,userSession.getUserId());
+        WebrtcUserInfo mineInfo = findUserInfo(webrtcSession, userSession.getUserId());
         String content = mineInfo.getNickName() + " 发起了语音通话";
-        sendTipMessage(dto.getGroupId(),content);
+        sendTipMessage(dto.getGroupId(), content);
         log.info("发起群通话,userId:{},groupId:{}", userSession.getUserId(), dto.getGroupId());
     }
 
@@ -142,7 +140,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         saveWebrtcSession(groupId, webrtcSession);
         // 广播信令
         List<Long> recvIds = getRecvIds(webrtcSession.getUserInfos());
-        sendRtcMessage1(MessageType.RTC_GROUP_ACCEPT, groupId, recvIds, "",true);
+        sendRtcMessage1(MessageType.RTC_GROUP_ACCEPT, groupId, recvIds, "", true);
         log.info("加入群通话,userId:{},groupId:{}", userSession.getUserId(), groupId);
     }
 
@@ -169,7 +167,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         userStateUtils.setFree(userSession.getUserId());
         // 广播消息给的所有用户
         List<Long> recvIds = getRecvIds(userInfos);
-        sendRtcMessage1(MessageType.RTC_GROUP_REJECT, groupId, recvIds, "",true);
+        sendRtcMessage1(MessageType.RTC_GROUP_REJECT, groupId, recvIds, "", true);
         log.info("拒绝群通话,userId:{},groupId:{}", userSession.getUserId(), groupId);
     }
 
@@ -198,8 +196,8 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         vo.setUserIds(Arrays.asList(userSession.getUserId()));
         vo.setReason(dto.getReason());
         List<Long> recvIds = getRecvIds(userInfos);
-        sendRtcMessage1(MessageType.RTC_GROUP_FAILED, dto.getGroupId(), recvIds, JSON.toJSONString(vo),false);
-        log.info("群通话失败,userId:{},groupId:{},原因:{}", userSession.getUserId(), dto.getReason());
+        sendRtcMessage1(MessageType.RTC_GROUP_FAILED, dto.getGroupId(), recvIds, JSON.toJSONString(vo), false);
+        log.info("群通话失败,userId:{},groupId:{},原因:{}", userSession.getUserId(),dto.getGroupId(), dto.getReason());
     }
 
     @OnlineCheck
@@ -216,7 +214,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
             throw new GlobalException("您不在群里中");
         }
         IMUserInfo mine = findInChatUser(webrtcSession, userSession.getUserId());
-        if(!Objects.isNull(mine) && mine.getTerminal() != userSession.getTerminal()){
+        if (!Objects.isNull(mine) && mine.getTerminal().equals(userSession.getTerminal())) {
             throw new GlobalException("已在其他设备加入通话");
         }
         WebrtcUserInfo userInfo = new WebrtcUserInfo();
@@ -238,7 +236,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         userStateUtils.setBusy(userSession.getUserId());
         // 广播信令
         List<Long> recvIds = getRecvIds(webrtcSession.getUserInfos());
-        sendRtcMessage1(MessageType.RTC_GROUP_JOIN, groupId, recvIds, JSON.toJSONString(userInfo),false);
+        sendRtcMessage1(MessageType.RTC_GROUP_JOIN, groupId, recvIds, JSON.toJSONString(userInfo), false);
         log.info("加入群通话,userId:{},groupId:{}", userSession.getUserId(), groupId);
     }
 
@@ -271,8 +269,6 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
             }
             if (!imClient.isOnline(userInfo.getId())) {
                 offlineUserIds.add(userInfo.getId());
-//                userStateUtils.setBusy(userInfo.getId());
-//                newUserInfos.add(userInfo);
             } else if (userStateUtils.isBusy(userInfo.getId())) {
                 busyUserIds.add(userInfo.getId());
             } else {
@@ -301,9 +297,10 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         }
         // 向被邀请的发起呼叫
         List<Long> newUserIds = getRecvIds(newUserInfos);
-        sendRtcMessage1(MessageType.RTC_GROUP_SETUP, dto.getGroupId(), newUserIds, JSON.toJSONString(userInfos),false);
+        sendRtcMessage1(MessageType.RTC_GROUP_SETUP, dto.getGroupId(), newUserIds, JSON.toJSONString(userInfos), false);
         // 向已在通话中的用户同步新邀请的用户信息
-        sendRtcMessage1(MessageType.RTC_GROUP_INVITE, dto.getGroupId(), userIds, JSON.toJSONString(newUserInfos),false);
+        sendRtcMessage1(MessageType.RTC_GROUP_INVITE, dto.getGroupId(), userIds, JSON.toJSONString(newUserInfos),
+            false);
         log.info("邀请加入群通话,userId:{},groupId:{},邀请用户:{}", userSession.getUserId(), dto.getGroupId(),
             newUserIds);
     }
@@ -323,9 +320,9 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         webrtcSession.getUserInfos().forEach(user -> userStateUtils.setFree(user.getId()));
         // 广播消息给的所有用户
         List<Long> recvIds = getRecvIds(webrtcSession.getUserInfos());
-        sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "",false);
+        sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "", false);
         // 发送文字提示信息
-        sendTipMessage(groupId,"通话结束");
+        sendTipMessage(groupId, "通话结束");
         log.info("发起人取消群通话,userId:{},groupId:{}", userSession.getUserId(), groupId);
     }
 
@@ -351,9 +348,9 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
             webrtcSession.getUserInfos().forEach(user -> userStateUtils.setFree(user.getId()));
             // 广播给还在呼叫中的用户,取消通话
             List<Long> recvIds = getRecvIds(webrtcSession.getUserInfos());
-            sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "",false);
+            sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "", false);
             // 发送文字提示信息
-            sendTipMessage(groupId,"通话结束");
+            sendTipMessage(groupId, "通话结束");
             log.info("群通话结束,groupId:{}", groupId);
         } else {
             // 更新会话信息
@@ -364,7 +361,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
             userStateUtils.setFree(userSession.getUserId());
             // 广播信令
             List<Long> recvIds = getRecvIds(userInfos);
-            sendRtcMessage1(MessageType.RTC_GROUP_QUIT, groupId, recvIds, "",false);
+            sendRtcMessage1(MessageType.RTC_GROUP_QUIT, groupId, recvIds, "", false);
             log.info("用户退出群通话,userId:{},groupId:{}", userSession.getUserId(), groupId);
         }
     }
@@ -434,7 +431,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         saveWebrtcSession(dto.getGroupId(), webrtcSession);
         // 广播信令
         List<Long> recvIds = getRecvIds(webrtcSession.getUserInfos());
-        sendRtcMessage1(MessageType.RTC_GROUP_DEVICE, dto.getGroupId(), recvIds, JSON.toJSONString(dto),false);
+        sendRtcMessage1(MessageType.RTC_GROUP_DEVICE, dto.getGroupId(), recvIds, JSON.toJSONString(dto), false);
         log.info("设备操作,userId:{},groupId:{},摄像头:{}", userSession.getUserId(), dto.getGroupId(),
             dto.getIsCamera());
     }
@@ -526,7 +523,8 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         return webrtcSession.getUserInfos().stream().anyMatch(user -> user.getId().equals(userId));
     }
 
-    private void sendRtcMessage1(MessageType messageType, Long groupId, List<Long> recvIds, String content,Boolean sendSelf) {
+    private void sendRtcMessage1(MessageType messageType, Long groupId, List<Long> recvIds, String content,
+        Boolean sendSelf) {
         UserSession userSession = SessionContext.getSession();
         GroupMessageVO messageInfo = new GroupMessageVO();
         messageInfo.setType(messageType.code());
@@ -559,7 +557,7 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         imClient.sendGroupMessage(sendMessage);
     }
 
-    private void sendTipMessage(Long groupId,String content){
+    private void sendTipMessage(Long groupId, String content) {
         UserSession userSession = SessionContext.getSession();
         // 群聊成员列表
         List<Long> userIds = groupMemberService.findUserIdsByGroupId(groupId);
@@ -581,5 +579,5 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService {
         sendMessage.setSendResult(false);
         sendMessage.setData(msgInfo);
         imClient.sendGroupMessage(sendMessage);
-    };
+    }
 }

+ 78 - 0
im-platform/src/main/java/com/bx/implatform/task/GroupBannedConsumerTask.java

@@ -0,0 +1,78 @@
+package com.bx.implatform.task;
+
+import cn.hutool.core.util.StrUtil;
+import com.bx.imclient.IMClient;
+import com.bx.imcommon.enums.IMTerminalType;
+import com.bx.imcommon.model.IMGroupMessage;
+import com.bx.imcommon.model.IMSystemMessage;
+import com.bx.imcommon.model.IMUserInfo;
+import com.bx.imcommon.mq.RedisMQConsumer;
+import com.bx.imcommon.mq.RedisMQListener;
+import com.bx.implatform.contant.Constant;
+import com.bx.implatform.contant.RedisKey;
+import com.bx.implatform.dto.GroupBanDTO;
+import com.bx.implatform.dto.UserBanDTO;
+import com.bx.implatform.entity.Group;
+import com.bx.implatform.entity.GroupMessage;
+import com.bx.implatform.enums.MessageStatus;
+import com.bx.implatform.enums.MessageType;
+import com.bx.implatform.service.IGroupMemberService;
+import com.bx.implatform.service.IGroupMessageService;
+import com.bx.implatform.service.IGroupService;
+import com.bx.implatform.util.BeanUtils;
+import com.bx.implatform.vo.GroupMessageVO;
+import com.bx.implatform.vo.SystemMessageVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.logging.log4j.util.Strings;
+import org.springframework.boot.context.properties.source.ConfigurationPropertyState;
+import org.springframework.stereotype.Component;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author: 谢绍许
+ * @date: 2024-07-15
+ * @version: 1.0
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+@RedisMQListener(queue = RedisKey.IM_QUEUE_GROUP_BANNED)
+public class GroupBannedConsumerTask extends RedisMQConsumer<GroupBanDTO> {
+
+    private final IMClient imClient;
+
+    private final IGroupMessageService groupMessageService;
+
+    private final IGroupMemberService groupMemberService;
+
+    @Override
+    public void onMessage(GroupBanDTO dto) {
+        log.info("群聊被封禁处理,群id:{},原因:{}", dto.getId(), dto.getReason());
+        // 群聊成员列表
+        List<Long> userIds = groupMemberService.findUserIdsByGroupId(dto.getId());
+        // 保存消息
+        GroupMessage msg = new GroupMessage();
+        msg.setGroupId(dto.getId());
+        String tip = "本群聊已被管理员封禁,原因:" + dto.getReason();
+        msg.setContent(tip);
+        msg.setSendId(Constant.SYS_USER_ID);
+        msg.setSendTime(new Date());
+        msg.setStatus(MessageStatus.UNSEND.code());
+        msg.setSendNickName("系统管理员");
+        msg.setType(MessageType.TIP_TEXT.code());
+        groupMessageService.save(msg);
+        // 推送提示语到群聊中
+        GroupMessageVO msgInfo = BeanUtils.copyProperties(msg, GroupMessageVO.class);
+        IMGroupMessage<GroupMessageVO> sendMessage = new IMGroupMessage<>();
+        sendMessage.setSender(new IMUserInfo(Constant.SYS_USER_ID, IMTerminalType.PC.code()));
+        sendMessage.setRecvIds(userIds);
+        sendMessage.setSendResult(true);
+        sendMessage.setSendToSelf(false);
+        sendMessage.setData(msgInfo);
+        imClient.sendGroupMessage(sendMessage);
+    }
+}

+ 70 - 0
im-platform/src/main/java/com/bx/implatform/task/GroupUnbanConsumerTask.java

@@ -0,0 +1,70 @@
+package com.bx.implatform.task;
+
+import cn.hutool.core.util.StrUtil;
+import com.bx.imclient.IMClient;
+import com.bx.imcommon.enums.IMTerminalType;
+import com.bx.imcommon.model.IMGroupMessage;
+import com.bx.imcommon.model.IMUserInfo;
+import com.bx.imcommon.mq.RedisMQConsumer;
+import com.bx.imcommon.mq.RedisMQListener;
+import com.bx.implatform.contant.Constant;
+import com.bx.implatform.contant.RedisKey;
+import com.bx.implatform.dto.GroupBanDTO;
+import com.bx.implatform.dto.GroupUnbanDTO;
+import com.bx.implatform.entity.GroupMessage;
+import com.bx.implatform.enums.MessageStatus;
+import com.bx.implatform.enums.MessageType;
+import com.bx.implatform.service.IGroupMemberService;
+import com.bx.implatform.service.IGroupMessageService;
+import com.bx.implatform.util.BeanUtils;
+import com.bx.implatform.vo.GroupMessageVO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author: 谢绍许
+ * @date: 2024-07-15
+ * @version: 1.0
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+@RedisMQListener(queue = RedisKey.IM_QUEUE_GROUP_UNBAN)
+public class GroupUnbanConsumerTask extends RedisMQConsumer<GroupUnbanDTO> {
+
+    private final IMClient imClient;
+
+    private final IGroupMessageService groupMessageService;
+
+    private final IGroupMemberService groupMemberService;
+
+    @Override
+    public void onMessage(GroupUnbanDTO dto) {
+        log.info("群聊解除封禁处理,群id:{}",dto.getId());
+        // 群聊成员列表
+        List<Long> userIds = groupMemberService.findUserIdsByGroupId(dto.getId());
+        // 保存消息
+        GroupMessage msg = new GroupMessage();
+        msg.setGroupId(dto.getId());
+        msg.setContent("已解除封禁");
+        msg.setSendId(Constant.SYS_USER_ID);
+        msg.setSendTime(new Date());
+        msg.setStatus(MessageStatus.UNSEND.code());
+        msg.setSendNickName("系统管理员");
+        msg.setType(MessageType.TIP_TEXT.code());
+        groupMessageService.save(msg);
+        // 推送提示语到群聊中
+        GroupMessageVO msgInfo = BeanUtils.copyProperties(msg, GroupMessageVO.class);
+        IMGroupMessage<GroupMessageVO> sendMessage = new IMGroupMessage<>();
+        sendMessage.setSender(new IMUserInfo(Constant.SYS_USER_ID, IMTerminalType.PC.code()));
+        sendMessage.setRecvIds(userIds);
+        sendMessage.setSendResult(true);
+        sendMessage.setSendToSelf(false);
+        sendMessage.setData(msgInfo);
+        imClient.sendGroupMessage(sendMessage);
+    }
+}

+ 5 - 3
im-platform/src/main/resources/application.yml

@@ -12,9 +12,11 @@ spring:
     username: root
     password: root
 
-  redis:
-    host: 127.0.0.1
-    port: 6379
+  data:
+    redis:
+      host: localhost
+      port: 6379
+      database: 2
 
   servlet:
     multipart:

+ 5 - 3
im-server/src/main/resources/application.yml

@@ -1,7 +1,9 @@
 spring:
-  redis:
-    host: 127.0.0.1
-    port: 6379
+  data:
+    redis:
+      host: localhost
+      port: 6379
+      database: 2
 
 websocket:
   enable: true

+ 3 - 1
im-ui/src/components/setting/Setting.vue

@@ -108,7 +108,9 @@
 
 <style lang="scss" >
 	.setting {
-		
+		.el-form {
+			padding: 30px;
+		}
 		.avatar-uploader {
 			
 			.el-upload {