From 238f581dffc975920134c4ba2d111ffede9809a4 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Fri, 19 Jul 2024 00:15:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BE=A4=E7=BB=84=E5=B0=81=E7=A6=81-?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/im-platfrom.sql | 4 +- .../bx/implatform/config/SwaggerConfig.java | 2 +- .../com/bx/implatform/contant/RedisKey.java | 2 +- .../controller/FriendController.java | 6 +- .../controller/GroupController.java | 10 +-- .../controller/GroupMessageController.java | 10 +-- .../controller/PrivateMessageController.java | 14 ++-- .../implatform/controller/UserController.java | 2 +- .../controller/WebrtcPrivateController.java | 16 ++-- .../bx/implatform/service/IGroupService.java | 2 +- .../service/impl/FriendServiceImpl.java | 13 ++-- .../service/impl/GroupMessageServiceImpl.java | 27 +++---- .../service/impl/GroupServiceImpl.java | 41 +++++----- .../impl/PrivateMessageServiceImpl.java | 10 +-- .../service/impl/UserServiceImpl.java | 4 +- .../service/impl/WebrtcGroupServiceImpl.java | 56 +++++++------ .../task/GroupBannedConsumerTask.java | 78 +++++++++++++++++++ .../task/GroupUnbanConsumerTask.java | 70 +++++++++++++++++ .../src/main/resources/application.yml | 8 +- im-server/src/main/resources/application.yml | 8 +- im-ui/src/components/setting/Setting.vue | 4 +- 21 files changed, 265 insertions(+), 122 deletions(-) create mode 100644 im-platform/src/main/java/com/bx/implatform/task/GroupBannedConsumerTask.java create mode 100644 im-platform/src/main/java/com/bx/implatform/task/GroupUnbanConsumerTask.java diff --git a/db/im-platfrom.sql b/db/im-platfrom.sql index a5b44a9..6959176 100644 --- a/db/im-platfrom.sql +++ b/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 '群'; diff --git a/im-platform/src/main/java/com/bx/implatform/config/SwaggerConfig.java b/im-platform/src/main/java/com/bx/implatform/config/SwaggerConfig.java index 9ab109a..3b2ae2a 100644 --- a/im-platform/src/main/java/com/bx/implatform/config/SwaggerConfig.java +++ b/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") diff --git a/im-platform/src/main/java/com/bx/implatform/contant/RedisKey.java b/im-platform/src/main/java/com/bx/implatform/contant/RedisKey.java index f6fbdd3..17ddd9f 100644 --- a/im-platform/src/main/java/com/bx/implatform/contant/RedisKey.java +++ b/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"; /** diff --git a/im-platform/src/main/java/com/bx/implatform/controller/FriendController.java b/im-platform/src/main/java/com/bx/implatform/controller/FriendController.java index cbc281c..8076fc4 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/FriendController.java +++ b/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 findFriend(@NotNull(message = "好友id不可为空") @PathVariable("friendId") Long friendId) { + public Result 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(); } diff --git a/im-platform/src/main/java/com/bx/implatform/controller/GroupController.java b/im-platform/src/main/java/com/bx/implatform/controller/GroupController.java index 9aa83c3..6398030 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/GroupController.java +++ b/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 findGroup(@NotNull(message = "群聊id不能为空") @PathVariable("groupId") Long groupId) { + public Result 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> 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(); diff --git a/im-platform/src/main/java/com/bx/implatform/controller/GroupMessageController.java b/im-platform/src/main/java/com/bx/implatform/controller/GroupMessageController.java index 2a54241..9117c0e 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/GroupMessageController.java +++ b/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 recallMessage(@NotNull(message = "消息id不能为空") @PathVariable("id") Long id) { + public Result 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> findReadedUsers(@RequestParam("groupId") Long groupId, - @RequestParam("messageId") Long messageId) { + public Result> findReadedUsers(@RequestParam Long groupId, + @RequestParam Long messageId) { return ResultUtils.success(groupMessageService.findReadedUsers(groupId, messageId)); } diff --git a/im-platform/src/main/java/com/bx/implatform/controller/PrivateMessageController.java b/im-platform/src/main/java/com/bx/implatform/controller/PrivateMessageController.java index 7cc3da1..2ae4b57 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/PrivateMessageController.java +++ b/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 recallMessage(@NotNull(message = "消息id不能为空") @PathVariable("id") Long id) { + public Result 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 getMaxReadedId(@RequestParam("friendId") Long friendId) { + public Result getMaxReadedId(@RequestParam Long friendId) { return ResultUtils.success(privateMessageService.getMaxReadedId(friendId)); } @GetMapping("/history") @Operation(summary = "查询聊天记录", description = "查询聊天记录") public Result> 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)); } diff --git a/im-platform/src/main/java/com/bx/implatform/controller/UserController.java b/im-platform/src/main/java/com/bx/implatform/controller/UserController.java index 422298f..bd2959f 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/UserController.java +++ b/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> findByName(@RequestParam("name") String name) { + public Result> findByName(@RequestParam String name) { return ResultUtils.success(userService.findUserByName(name)); } } diff --git a/im-platform/src/main/java/com/bx/implatform/controller/WebrtcPrivateController.java b/im-platform/src/main/java/com/bx/implatform/controller/WebrtcPrivateController.java index 9ae38e8..2b0f241 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/WebrtcPrivateController.java +++ b/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(); } diff --git a/im-platform/src/main/java/com/bx/implatform/service/IGroupService.java b/im-platform/src/main/java/com/bx/implatform/service/IGroupService.java index 6f58619..57c1e58 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/IGroupService.java +++ b/im-platform/src/main/java/com/bx/implatform/service/IGroupService.java @@ -68,7 +68,7 @@ public interface IGroupService extends IService { * @param groupId 群聊id * @return 群聊实体 */ - Group getById(Long groupId); + Group getAndCheckById(Long groupId); /** * 根据id查找群聊 diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java index 20ef491..0aa688d 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/FriendServiceImpl.java +++ b/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 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 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 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()); diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java index 5a8c45c..512241a 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java +++ b/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 userIds = groupMemberService.findUserIdsByGroupId(group.getId()); @@ -103,18 +96,18 @@ public class GroupMessageServiceImpl extends ServiceImpl 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 members = groupMemberService.findByUserId(session.getUserId()); @@ -315,12 +308,12 @@ public class GroupMessageServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupServiceImpl.java index 3055e25..6b9979a 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupServiceImpl.java +++ b/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 implements IGroupService { private final IUserService userService; private final IGroupMemberService groupMemberService; @@ -84,7 +83,7 @@ public class GroupServiceImpl extends ServiceImpl 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 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 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 userIds = groupMemberService.findUserIdsByGroupId(groupId); @@ -131,7 +130,7 @@ public class GroupServiceImpl extends ServiceImpl 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 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 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 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 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 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 friends = friendsService.findFriendByUserId(session.getUserId()); List 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 groupMembers = friendsList.stream().map(f -> { diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java index 0e10922..91d5bdd 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/PrivateMessageServiceImpl.java @@ -49,7 +49,7 @@ public class PrivateMessageServiceImpl extends ServiceImpl 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 friends = friendService.findFriendByUserId(session.getUserId()); diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java index 7f81724..2478731 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/UserServiceImpl.java @@ -141,11 +141,11 @@ public class UserServiceImpl extends ServiceImpl 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())) { diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java index 8851b32..6f91f4a 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/WebrtcGroupServiceImpl.java +++ b/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 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 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 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 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 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 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 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 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 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 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 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 recvIds, String content,Boolean sendSelf) { + private void sendRtcMessage1(MessageType messageType, Long groupId, List 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 userIds = groupMemberService.findUserIdsByGroupId(groupId); @@ -581,5 +579,5 @@ public class WebrtcGroupServiceImpl implements IWebrtcGroupService { sendMessage.setSendResult(false); sendMessage.setData(msgInfo); imClient.sendGroupMessage(sendMessage); - }; + } } diff --git a/im-platform/src/main/java/com/bx/implatform/task/GroupBannedConsumerTask.java b/im-platform/src/main/java/com/bx/implatform/task/GroupBannedConsumerTask.java new file mode 100644 index 0000000..3569cd6 --- /dev/null +++ b/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 { + + 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 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 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); + } +} diff --git a/im-platform/src/main/java/com/bx/implatform/task/GroupUnbanConsumerTask.java b/im-platform/src/main/java/com/bx/implatform/task/GroupUnbanConsumerTask.java new file mode 100644 index 0000000..feb9672 --- /dev/null +++ b/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 { + + private final IMClient imClient; + + private final IGroupMessageService groupMessageService; + + private final IGroupMemberService groupMemberService; + + @Override + public void onMessage(GroupUnbanDTO dto) { + log.info("群聊解除封禁处理,群id:{}",dto.getId()); + // 群聊成员列表 + List 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 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); + } +} diff --git a/im-platform/src/main/resources/application.yml b/im-platform/src/main/resources/application.yml index 0e70e38..f83affc 100644 --- a/im-platform/src/main/resources/application.yml +++ b/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: diff --git a/im-server/src/main/resources/application.yml b/im-server/src/main/resources/application.yml index 827343d..affb1dc 100644 --- a/im-server/src/main/resources/application.yml +++ b/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 diff --git a/im-ui/src/components/setting/Setting.vue b/im-ui/src/components/setting/Setting.vue index 410b05b..326874f 100644 --- a/im-ui/src/components/setting/Setting.vue +++ b/im-ui/src/components/setting/Setting.vue @@ -108,7 +108,9 @@