Merge remote-tracking branch 'origin/main'

This commit is contained in:
zhongzb
2023-06-04 17:20:29 +08:00
6 changed files with 11 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
package com.abin.mallchat.common.user.domain.entity; package com.abin.mallchat.common.user.domain.entity;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
@@ -28,7 +29,7 @@ public class IpInfo implements Serializable {
private IpDetail updateIpDetail; private IpDetail updateIpDetail;
public void refreshIp(String ip) { public void refreshIp(String ip) {
if (Objects.isNull(ip)) { if (StringUtils.isEmpty(ip)) {
return; return;
} }
updateIp = ip; updateIp = ip;
@@ -45,7 +46,7 @@ public class IpInfo implements Serializable {
public String needRefreshIp() { public String needRefreshIp() {
boolean notNeedRefresh = Optional.ofNullable(updateIpDetail) boolean notNeedRefresh = Optional.ofNullable(updateIpDetail)
.map(IpDetail::getIp) .map(IpDetail::getIp)
.filter(ip -> ip.equals(updateIp)) .filter(ip -> Objects.equals(ip, updateIp))
.isPresent(); .isPresent();
return notNeedRefresh ? null : updateIp; return notNeedRefresh ? null : updateIp;
} }

View File

@@ -85,9 +85,9 @@ public class MessageAdapter {
List<MessageMark> dislikeMarks = typeMap.getOrDefault(MessageMarkTypeEnum.DISLIKE.getType(), new ArrayList<>()); List<MessageMark> dislikeMarks = typeMap.getOrDefault(MessageMarkTypeEnum.DISLIKE.getType(), new ArrayList<>());
ChatMessageResp.MessageMark mark = new ChatMessageResp.MessageMark(); ChatMessageResp.MessageMark mark = new ChatMessageResp.MessageMark();
mark.setLikeCount(likeMarks.size()); 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.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; return mark;
} }

View File

@@ -24,6 +24,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* Description: * Description:
@@ -72,7 +73,7 @@ public class SwaggerConfig {
} }
private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) { 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));
} }
} }

View File

@@ -1,5 +1,6 @@
package com.abin.mallchat.custom.common.intecepter; 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.domain.dto.RequestInfo;
import com.abin.mallchat.common.common.exception.HttpErrorEnum; import com.abin.mallchat.common.common.exception.HttpErrorEnum;
import com.abin.mallchat.common.common.utils.RequestHolder; import com.abin.mallchat.common.common.utils.RequestHolder;
@@ -44,7 +45,7 @@ public class BlackInterceptor implements HandlerInterceptor {
} }
private boolean inBlackList(Object target, Set<String> blackSet) { private boolean inBlackList(Object target, Set<String> blackSet) {
if (Objects.isNull(target) || Objects.isNull(blackSet)) { if (Objects.isNull(target) || CollectionUtil.isEmpty(blackSet)) {
return false; return false;
} }
return blackSet.contains(target.toString()); return blackSet.contains(target.toString());

View File

@@ -44,7 +44,7 @@ public class LoginServiceImpl implements LoginService {
} }
String key = RedisKey.getKey(RedisKey.USER_TOKEN_STRING, uid); String key = RedisKey.getKey(RedisKey.USER_TOKEN_STRING, uid);
String realToken = RedisUtils.getStr(key); String realToken = RedisUtils.getStr(key);
return token.equals(realToken);//有可能token失效了需要校验是不是和最新token一致 return Objects.equals(token, realToken);//有可能token失效了需要校验是不是和最新token一致
} }
@Async @Async

View File

@@ -180,7 +180,7 @@ public class WebSocketServiceImpl implements WebSocketService {
if (uidOptional.isPresent()) { if (uidOptional.isPresent()) {
CopyOnWriteArrayList<Channel> channels = ONLINE_UID_MAP.get(uidOptional.get()); CopyOnWriteArrayList<Channel> channels = ONLINE_UID_MAP.get(uidOptional.get());
if (CollectionUtil.isNotEmpty(channels)) { 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())); return CollectionUtil.isEmpty(ONLINE_UID_MAP.get(uidOptional.get()));
} }