mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2025-12-26 04:47:53 +08:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # docs/mallchat.sql
This commit is contained in:
commit
263c224576
@ -29,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description: 普通文本消息
|
||||
@ -68,9 +69,12 @@ public class TextMsgHandler extends AbstractMsgHandler {
|
||||
AssertUtil.equal(replyMsg.getRoomId(), request.getRoomId(), "只能回复相同会话内的消息");
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(body.getAtUidList())) {
|
||||
List<Long> atUidList = body.getAtUidList();
|
||||
//前端传入的@用户列表可能会重复,需要去重
|
||||
List<Long> atUidList = body.getAtUidList().stream().distinct().collect(Collectors.toList());
|
||||
Map<Long, User> batch = userInfoCache.getBatch(atUidList);
|
||||
AssertUtil.equal(atUidList.size(), batch.values().size(), "@用户不存在");
|
||||
//如果@用户不存在,userInfoCache 返回的map中依然存在该key,但是value为null,需要过滤掉再校验
|
||||
long batchCount = batch.values().stream().filter(Objects::nonNull).count();
|
||||
AssertUtil.equal((long)atUidList.size(), batchCount, "@用户不存在");
|
||||
boolean atAll = body.getAtUidList().contains(0L);
|
||||
if (atAll) {
|
||||
AssertUtil.isTrue(iRoleService.hasPower(uid, RoleEnum.CHAT_MANAGER), "没有权限");
|
||||
|
||||
@ -39,6 +39,8 @@ public class UserCache {
|
||||
private RoleDao roleDao;
|
||||
@Autowired
|
||||
private UserRoleDao userRoleDao;
|
||||
@Autowired
|
||||
private UserSummaryCache userSummaryCache;
|
||||
|
||||
public Long getOnlineNum() {
|
||||
String onlineKey = RedisKey.getKey(RedisKey.ONLINE_UID_ZET);
|
||||
@ -137,6 +139,8 @@ public class UserCache {
|
||||
|
||||
public void userInfoChange(Long uid) {
|
||||
delUserInfo(uid);
|
||||
//删除UserSummaryCache,前端下次懒加载的时候可以获取到最新的数据
|
||||
userSummaryCache.delete(uid);
|
||||
refreshUserModifyTime(uid);
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import javax.annotation.PreDestroy;
|
||||
@Configuration
|
||||
public class NettyWebSocketServer {
|
||||
public static final int WEB_SOCKET_PORT = 8090;
|
||||
public static final NettyWebSocketServerHandler NETTY_WEB_SOCKET_SERVER_HANDLER = new NettyWebSocketServerHandler();
|
||||
// 创建线程池执行器
|
||||
private EventLoopGroup bossGroup = new NioEventLoopGroup(1);
|
||||
private EventLoopGroup workerGroup = new NioEventLoopGroup(NettyRuntime.availableProcessors());
|
||||
@ -90,7 +91,7 @@ public class NettyWebSocketServer {
|
||||
*/
|
||||
pipeline.addLast(new WebSocketServerProtocolHandler("/"));
|
||||
// 自定义handler ,处理业务逻辑
|
||||
pipeline.addLast(new NettyWebSocketServerHandler());
|
||||
pipeline.addLast(NETTY_WEB_SOCKET_SERVER_HANDLER);
|
||||
}
|
||||
});
|
||||
// 启动服务器,监听端口,阻塞直到启动成功
|
||||
|
||||
@ -7,6 +7,7 @@ import com.abin.mallchat.common.user.domain.enums.WSReqTypeEnum;
|
||||
import com.abin.mallchat.common.user.domain.vo.request.ws.WSAuthorize;
|
||||
import com.abin.mallchat.common.user.domain.vo.request.ws.WSBaseReq;
|
||||
import com.abin.mallchat.common.user.service.WebSocketService;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Sharable
|
||||
public class NettyWebSocketServerHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
|
||||
|
||||
private WebSocketService webSocketService;
|
||||
|
||||
5
pom.xml
5
pom.xml
@ -49,11 +49,6 @@
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.abin.mallchat</groupId>
|
||||
<artifactId>mallchat-common</artifactId>
|
||||
<version>${version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.abin.mallchat</groupId>
|
||||
<artifactId>mallchat-common-starter</artifactId>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user