mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-13 21:53:41 +08:00
[fix] String类型判断使用StringUtils.isNotEmpty() 而不是Objects.isNull()
This commit is contained in:
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.Max;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
* @author <a href="https://github.com/zongzibinbin">abin</a>
|
||||||
@@ -34,6 +34,6 @@ public class CursorPageBaseReq {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public Boolean isFirstPage() {
|
public Boolean isFirstPage() {
|
||||||
return Objects.isNull(cursor);
|
return StringUtils.isNotEmpty(cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import com.auth0.jwt.interfaces.Claim;
|
|||||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||||
import com.auth0.jwt.interfaces.JWTVerifier;
|
import com.auth0.jwt.interfaces.JWTVerifier;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +59,7 @@ public class JwtUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Map<String, Claim> verifyToken(String token) {
|
public Map<String, Claim> verifyToken(String token) {
|
||||||
if (Objects.isNull(token)) {
|
if (StringUtils.isEmpty(token)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ReUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.abin.mallchat.common.common.utils.FutureUtils;
|
import com.abin.mallchat.common.common.utils.FutureUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jsoup.Connection;
|
import org.jsoup.Connection;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@@ -38,7 +39,7 @@ public abstract class AbstractUrlTitleDiscover implements UrlTitleDiscover {
|
|||||||
//并行请求
|
//并行请求
|
||||||
List<CompletableFuture<Pair<String, String>>> futures = matchList.stream().map(match -> CompletableFuture.supplyAsync(() -> {
|
List<CompletableFuture<Pair<String, String>>> futures = matchList.stream().map(match -> CompletableFuture.supplyAsync(() -> {
|
||||||
String title = getUrlTitle(match);
|
String title = getUrlTitle(match);
|
||||||
return Objects.nonNull(title) ? Pair.of(match, title) : null;
|
return StringUtils.isNotEmpty(title) ? Pair.of(match, title) : null;
|
||||||
})).collect(Collectors.toList());
|
})).collect(Collectors.toList());
|
||||||
CompletableFuture<List<Pair<String, String>>> future = FutureUtils.sequenceNonNull(futures);
|
CompletableFuture<List<Pair<String, String>>> future = FutureUtils.sequenceNonNull(futures);
|
||||||
//结果组装
|
//结果组装
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
|||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
@@ -53,7 +54,7 @@ public class WxMsgService {
|
|||||||
String fromUser = wxMpXmlMessage.getFromUser();
|
String fromUser = wxMpXmlMessage.getFromUser();
|
||||||
Integer eventKey = Integer.parseInt(getEventKey(wxMpXmlMessage));
|
Integer eventKey = Integer.parseInt(getEventKey(wxMpXmlMessage));
|
||||||
User user = userDao.getByOpenId(fromUser);
|
User user = userDao.getByOpenId(fromUser);
|
||||||
if (Objects.nonNull(user) && Objects.nonNull(user.getAvatar())) {
|
if (Objects.nonNull(user) && StringUtils.isNotEmpty(user.getAvatar())) {
|
||||||
//注册且已经授权的用户,直接登录成功
|
//注册且已经授权的用户,直接登录成功
|
||||||
login(user.getId(), eventKey);
|
login(user.getId(), eventKey);
|
||||||
return null;
|
return null;
|
||||||
@@ -84,7 +85,7 @@ public class WxMsgService {
|
|||||||
public void authorize(WxOAuth2UserInfo userInfo) {
|
public void authorize(WxOAuth2UserInfo userInfo) {
|
||||||
User user = userDao.getByOpenId(userInfo.getOpenid());
|
User user = userDao.getByOpenId(userInfo.getOpenid());
|
||||||
//更新用户信息
|
//更新用户信息
|
||||||
if (Objects.isNull(user.getName())) {
|
if (StringUtils.isNotEmpty(user.getName())) {
|
||||||
fillUserInfo(user.getId(), userInfo);
|
fillUserInfo(user.getId(), userInfo);
|
||||||
}
|
}
|
||||||
//触发用户登录成功操作
|
//触发用户登录成功操作
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
|
|||||||
import io.netty.handler.codec.http.FullHttpRequest;
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import io.netty.util.AttributeKey;
|
import io.netty.util.AttributeKey;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class HttpHeadersHandler extends ChannelInboundHandlerAdapter {
|
public class HttpHeadersHandler extends ChannelInboundHandlerAdapter {
|
||||||
private AttributeKey<String> key = AttributeKey.valueOf("Id");
|
private AttributeKey<String> key = AttributeKey.valueOf("Id");
|
||||||
@@ -17,7 +17,7 @@ public class HttpHeadersHandler extends ChannelInboundHandlerAdapter {
|
|||||||
if (msg instanceof FullHttpRequest) {
|
if (msg instanceof FullHttpRequest) {
|
||||||
HttpHeaders headers = ((FullHttpRequest) msg).headers();
|
HttpHeaders headers = ((FullHttpRequest) msg).headers();
|
||||||
String ip = headers.get("X-Real-IP");
|
String ip = headers.get("X-Real-IP");
|
||||||
if (Objects.isNull(ip)) {//如果没经过nginx,就直接获取远端地址
|
if (StringUtils.isNotEmpty(ip)) {//如果没经过nginx,就直接获取远端地址
|
||||||
InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress();
|
InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress();
|
||||||
ip = address.getAddress().getHostAddress();
|
ip = address.getAddress().getHostAddress();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user