diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/IpInfo.java b/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/IpInfo.java index 3480bd8..b30b541 100644 --- a/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/IpInfo.java +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/user/domain/entity/IpInfo.java @@ -1,6 +1,7 @@ package com.abin.mallchat.common.user.domain.entity; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.Objects; @@ -28,7 +29,7 @@ public class IpInfo implements Serializable { private IpDetail updateIpDetail; public void refreshIp(String ip) { - if (Objects.isNull(ip)) { + if (StringUtils.isEmpty(ip)) { return; } updateIp = ip; @@ -45,7 +46,7 @@ public class IpInfo implements Serializable { public String needRefreshIp() { boolean notNeedRefresh = Optional.ofNullable(updateIpDetail) .map(IpDetail::getIp) - .filter(ip -> ip.equals(updateIp)) + .filter(ip -> Objects.equals(ip, updateIp)) .isPresent(); return notNeedRefresh ? null : updateIp; } diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java index 13cbe76..25df8c6 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/adapter/MessageAdapter.java @@ -85,9 +85,9 @@ public class MessageAdapter { List dislikeMarks = typeMap.getOrDefault(MessageMarkTypeEnum.DISLIKE.getType(), new ArrayList<>()); ChatMessageResp.MessageMark mark = new ChatMessageResp.MessageMark(); mark.setLikeCount(likeMarks.size()); - mark.setUserLike(Optional.ofNullable(receiveUid).filter(uid -> likeMarks.stream().anyMatch(a -> a.getUid().equals(uid))).map(a -> YesOrNoEnum.YES.getStatus()).orElse(YesOrNoEnum.NO.getStatus())); + mark.setUserLike(Optional.ofNullable(receiveUid).filter(uid -> likeMarks.stream().anyMatch(a -> Objects.equals(a.getUid(), uid))).map(a -> YesOrNoEnum.YES.getStatus()).orElse(YesOrNoEnum.NO.getStatus())); mark.setDislikeCount(dislikeMarks.size()); - mark.setUserDislike(Optional.ofNullable(receiveUid).filter(uid -> dislikeMarks.stream().anyMatch(a -> a.getUid().equals(uid))).map(a -> YesOrNoEnum.YES.getStatus()).orElse(YesOrNoEnum.NO.getStatus())); + mark.setUserDislike(Optional.ofNullable(receiveUid).filter(uid -> dislikeMarks.stream().anyMatch(a -> Objects.equals(a.getUid(), uid))).map(a -> YesOrNoEnum.YES.getStatus()).orElse(YesOrNoEnum.NO.getStatus())); return mark; } diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/config/SwaggerConfig.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/config/SwaggerConfig.java index e7f810b..5682959 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/config/SwaggerConfig.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/config/SwaggerConfig.java @@ -24,6 +24,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; /** * Description: @@ -72,7 +73,7 @@ public class SwaggerConfig { } private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) { - return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT)); + return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || Objects.equals(ManagementPortType.get(environment), ManagementPortType.DIFFERENT)); } } diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/intecepter/BlackInterceptor.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/intecepter/BlackInterceptor.java index a289e13..9336b30 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/intecepter/BlackInterceptor.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/common/intecepter/BlackInterceptor.java @@ -1,5 +1,6 @@ package com.abin.mallchat.custom.common.intecepter; +import cn.hutool.core.collection.CollectionUtil; import com.abin.mallchat.common.common.domain.dto.RequestInfo; import com.abin.mallchat.common.common.exception.HttpErrorEnum; import com.abin.mallchat.common.common.utils.RequestHolder; @@ -44,7 +45,7 @@ public class BlackInterceptor implements HandlerInterceptor { } private boolean inBlackList(Object target, Set blackSet) { - if (Objects.isNull(target) || Objects.isNull(blackSet)) { + if (Objects.isNull(target) || CollectionUtil.isEmpty(blackSet)) { return false; } return blackSet.contains(target.toString()); diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/LoginServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/LoginServiceImpl.java index c21d3e1..d5beaa8 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/LoginServiceImpl.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/LoginServiceImpl.java @@ -44,7 +44,7 @@ public class LoginServiceImpl implements LoginService { } String key = RedisKey.getKey(RedisKey.USER_TOKEN_STRING, uid); String realToken = RedisUtils.getStr(key); - return token.equals(realToken);//有可能token失效了,需要校验是不是和最新token一致 + return Objects.equals(token, realToken);//有可能token失效了,需要校验是不是和最新token一致 } @Async diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java index c21f80a..dd43158 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/user/service/impl/WebSocketServiceImpl.java @@ -180,7 +180,7 @@ public class WebSocketServiceImpl implements WebSocketService { if (uidOptional.isPresent()) { CopyOnWriteArrayList channels = ONLINE_UID_MAP.get(uidOptional.get()); if (CollectionUtil.isNotEmpty(channels)) { - channels.removeIf(channel1 -> channel1.equals(channel)); + channels.removeIf(ch -> Objects.equals(ch, channel)); } return CollectionUtil.isEmpty(ONLINE_UID_MAP.get(uidOptional.get())); }