mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-14 06:03:42 +08:00
[fix] String类型判断使用StringUtils.isNotEmpty() 而不是Objects.isNull()
This commit is contained in:
@@ -10,6 +10,7 @@ import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
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.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -53,7 +54,7 @@ public class WxMsgService {
|
||||
String fromUser = wxMpXmlMessage.getFromUser();
|
||||
Integer eventKey = Integer.parseInt(getEventKey(wxMpXmlMessage));
|
||||
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);
|
||||
return null;
|
||||
@@ -84,7 +85,7 @@ public class WxMsgService {
|
||||
public void authorize(WxOAuth2UserInfo userInfo) {
|
||||
User user = userDao.getByOpenId(userInfo.getOpenid());
|
||||
//更新用户信息
|
||||
if (Objects.isNull(user.getName())) {
|
||||
if (StringUtils.isNotEmpty(user.getName())) {
|
||||
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.HttpHeaders;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Objects;
|
||||
|
||||
public class HttpHeadersHandler extends ChannelInboundHandlerAdapter {
|
||||
private AttributeKey<String> key = AttributeKey.valueOf("Id");
|
||||
@@ -17,7 +17,7 @@ public class HttpHeadersHandler extends ChannelInboundHandlerAdapter {
|
||||
if (msg instanceof FullHttpRequest) {
|
||||
HttpHeaders headers = ((FullHttpRequest) msg).headers();
|
||||
String ip = headers.get("X-Real-IP");
|
||||
if (Objects.isNull(ip)) {//如果没经过nginx,就直接获取远端地址
|
||||
if (StringUtils.isNotEmpty(ip)) {//如果没经过nginx,就直接获取远端地址
|
||||
InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress();
|
||||
ip = address.getAddress().getHostAddress();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user