mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-13 21:53:41 +08:00
单聊群聊功能提交
This commit is contained in:
@@ -5,19 +5,17 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.abin.mallchat.common.chat.dao.ContactDao;
|
||||
import com.abin.mallchat.common.chat.dao.MessageDao;
|
||||
import com.abin.mallchat.common.chat.dao.MessageMarkDao;
|
||||
import com.abin.mallchat.common.chat.dao.RoomDao;
|
||||
import com.abin.mallchat.common.chat.dao.*;
|
||||
import com.abin.mallchat.common.chat.domain.dto.MsgReadInfoDTO;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Contact;
|
||||
import com.abin.mallchat.common.chat.domain.entity.Message;
|
||||
import com.abin.mallchat.common.chat.domain.entity.MessageMark;
|
||||
import com.abin.mallchat.common.chat.domain.entity.*;
|
||||
import com.abin.mallchat.common.chat.domain.enums.MessageMarkActTypeEnum;
|
||||
import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
|
||||
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageResp;
|
||||
import com.abin.mallchat.common.chat.service.ContactService;
|
||||
import com.abin.mallchat.common.chat.service.cache.RoomCache;
|
||||
import com.abin.mallchat.common.chat.service.cache.RoomGroupCache;
|
||||
import com.abin.mallchat.common.common.annotation.RedissonLock;
|
||||
import com.abin.mallchat.common.common.domain.enums.NormalOrNoEnum;
|
||||
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
|
||||
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
|
||||
import com.abin.mallchat.common.common.event.MessageSendEvent;
|
||||
@@ -28,7 +26,6 @@ import com.abin.mallchat.common.user.domain.enums.ChatActiveStatusEnum;
|
||||
import com.abin.mallchat.common.user.domain.enums.RoleEnum;
|
||||
import com.abin.mallchat.common.user.domain.vo.response.ws.ChatMemberResp;
|
||||
import com.abin.mallchat.common.user.service.IRoleService;
|
||||
import com.abin.mallchat.common.user.service.cache.ItemCache;
|
||||
import com.abin.mallchat.common.user.service.cache.UserCache;
|
||||
import com.abin.mallchat.custom.chat.domain.vo.request.*;
|
||||
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberListResp;
|
||||
@@ -81,7 +78,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
@Autowired
|
||||
private MessageMarkDao messageMarkDao;
|
||||
@Autowired
|
||||
private ItemCache itemCache;
|
||||
private RoomFriendDao roomFriendDao;
|
||||
@Autowired
|
||||
private IRoleService iRoleService;
|
||||
@Autowired
|
||||
@@ -90,6 +87,12 @@ public class ChatServiceImpl implements ChatService {
|
||||
private ContactService contactService;
|
||||
@Autowired
|
||||
private ContactDao contactDao;
|
||||
@Autowired
|
||||
private RoomCache roomCache;
|
||||
@Autowired
|
||||
private GroupMemberDao groupMemberDao;
|
||||
@Autowired
|
||||
private RoomGroupCache roomGroupCache;
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
@@ -97,6 +100,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
@Override
|
||||
@Transactional
|
||||
public Long sendMsg(ChatMessageReq request, Long uid) {
|
||||
check(request, uid);
|
||||
AbstractMsgHandler msgHandler = MsgHandlerFactory.getStrategyNoNull(request.getMsgType());//todo 这里先不扩展,后续再改
|
||||
msgHandler.checkMsg(request, uid);
|
||||
//同步获取消息的跳转链接标题
|
||||
@@ -108,6 +112,24 @@ public class ChatServiceImpl implements ChatService {
|
||||
return insert.getId();
|
||||
}
|
||||
|
||||
private void check(ChatMessageReq request, Long uid) {
|
||||
Room room = roomCache.get(request.getRoomId());
|
||||
if (room.isHotRoom()) {//全员群跳过校验
|
||||
return;
|
||||
}
|
||||
if (room.isRoomFriend()) {
|
||||
RoomFriend roomFriend = roomFriendDao.getByRoomId(request.getRoomId());
|
||||
AssertUtil.equal(NormalOrNoEnum.NORMAL.getStatus(), roomFriend.getStatus(), "您已经被对方拉黑");
|
||||
AssertUtil.isTrue(uid.equals(roomFriend.getUid1()) || uid.equals(roomFriend.getUid2()), "您已经被对方拉黑");
|
||||
}
|
||||
if (room.isRoomGroup()) {
|
||||
RoomGroup roomGroup = roomGroupCache.get(request.getRoomId());
|
||||
GroupMember member = groupMemberDao.getMember(roomGroup.getId(), uid);
|
||||
AssertUtil.isNotEmpty(member, "您已经被移除该群");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessageResp getMsgResp(Message message, Long receiveUid) {
|
||||
return CollUtil.getFirst(getMsgRespBatch(Collections.singletonList(message), receiveUid));
|
||||
|
||||
@@ -178,6 +178,7 @@ public class RoomAppServiceImpl implements RoomAppService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delMember(Long uid, MemberDelReq request) {
|
||||
Room room = roomCache.get(request.getRoomId());
|
||||
AssertUtil.isNotEmpty(room, "房间号有误");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.abin.mallchat.custom.user.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.abin.mallchat.common.chat.dao.RoomFriendDao;
|
||||
import com.abin.mallchat.common.chat.domain.entity.RoomFriend;
|
||||
import com.abin.mallchat.common.chat.service.ContactService;
|
||||
import com.abin.mallchat.common.chat.service.RoomService;
|
||||
@@ -67,9 +68,10 @@ public class FriendServiceImpl implements FriendService {
|
||||
private ContactService contactService;
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
@Autowired
|
||||
private RoomFriendDao roomFriendDao;
|
||||
|
||||
/**
|
||||
* 检查
|
||||
@@ -176,6 +178,7 @@ public class FriendServiceImpl implements FriendService {
|
||||
* @param friendUid 朋友uid
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteFriend(Long uid, Long friendUid) {
|
||||
List<UserFriend> userFriends = userFriendDao.getUserFriend(uid, friendUid);
|
||||
if (CollectionUtil.isEmpty(userFriends)) {
|
||||
@@ -184,6 +187,8 @@ public class FriendServiceImpl implements FriendService {
|
||||
}
|
||||
List<Long> friendRecordIds = userFriends.stream().map(UserFriend::getId).collect(Collectors.toList());
|
||||
userFriendDao.removeByIds(friendRecordIds);
|
||||
//禁用房间
|
||||
roomService.disableFriendRoom(friendRecordIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user