|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import io.swagger.models.auth.In;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -36,11 +37,13 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
@ServerEndpoint(value = "/socket/{sendId}")
|
|
|
+@RequiredArgsConstructor
|
|
|
public class WebSocketProcess {
|
|
|
|
|
|
- private final LifeMessageMapper lifeMessageMapper = SpringContext.getBean(LifeMessageMapper.class);
|
|
|
- private final BaseRedisService baseRedisService = SpringContext.getBean(BaseRedisService.class);
|
|
|
- private final LifeBlacklistMapper lifeBlacklistMapper = SpringContext.getBean(LifeBlacklistMapper.class);
|
|
|
+
|
|
|
+ private final LifeMessageMapper lifeMessageMapper;
|
|
|
+ private final BaseRedisService baseRedisService;
|
|
|
+ private final LifeBlacklistMapper lifeBlacklistMapper;
|
|
|
|
|
|
/*
|
|
|
* 持有每个webSocket对象,以key-value存储到线程安全ConcurrentHashMap,
|
|
@@ -66,11 +69,11 @@ public class WebSocketProcess {
|
|
|
LambdaQueryWrapper<LifeBlacklist> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(LifeBlacklist::getBlockedPhoneId, id);
|
|
|
List<String> blackList = lifeBlacklistMapper.selectList(wrapper).stream().map(LifeBlacklist::getBlockerPhoneId).collect(Collectors.toList());
|
|
|
- if (CollectionUtil.isNotEmpty(blackList)) baseRedisService.setSaveOrOverwriteScriptList("blackList_" + id, blackList);
|
|
|
+ if (CollectionUtil.isNotEmpty(blackList))
|
|
|
+ baseRedisService.setSaveOrOverwriteScriptList("blackList_" + id, blackList);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 客户端连接关闭时触发
|
|
|
**/
|