格式化代码

This commit is contained in:
zhongzb
2023-05-28 19:39:51 +08:00
parent 53201465f2
commit 7a812cd9e4
113 changed files with 332 additions and 523 deletions

View File

@@ -1,6 +1,5 @@
package com.abin.mallchat.custom;
import com.abin.mallchat.custom.user.controller.WxPortalController;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -11,7 +10,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
* @date 2021/05/27
*/
@SpringBootApplication(scanBasePackages = {"com.abin.mallchat"})
@MapperScan({"com.abin.mallchat.common.**.mapper" })
@MapperScan({"com.abin.mallchat.common.**.mapper"})
@ServletComponentScan
public class MallchatCustomApplication {

View File

@@ -2,12 +2,10 @@ package com.abin.mallchat.custom.chat.controller;
import com.abin.mallchat.common.common.annotation.FrequencyControl;
import com.abin.mallchat.common.common.annotation.FrequencyControlContainer;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.ApiResult;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.common.domain.vo.response.IdRespVO;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.common.utils.RequestHolder;
import com.abin.mallchat.common.user.domain.enums.BlackTypeEnum;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageMarkReq;
@@ -18,17 +16,14 @@ import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp;
import com.abin.mallchat.custom.chat.service.ChatService;
import com.abin.mallchat.common.common.utils.RequestHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <p>
@@ -62,10 +57,11 @@ public class ChatController {
}
private void filterBlackMember(CursorPageBaseResp<ChatMemberResp> memberPage) {
memberPage.getList().removeIf(a->getBlackUidSet().contains(a.getUid().toString()));
memberPage.getList().removeIf(a -> getBlackUidSet().contains(a.getUid().toString()));
}
private Set<String> getBlackUidSet(){
return userCache.getBlackMap().get(BlackTypeEnum.UID.getType());
private Set<String> getBlackUidSet() {
return userCache.getBlackMap().getOrDefault(BlackTypeEnum.UID.getType(), new HashSet<>());
}
@GetMapping("public/member/statistic/")
@@ -81,10 +77,12 @@ public class ChatController {
filterBlackMsg(msgPage);
return ApiResult.success(msgPage);
}
private void filterBlackMsg(CursorPageBaseResp<ChatMessageResp> memberPage) {
memberPage.getList().removeIf(a->getBlackUidSet().contains(a.getFromUser().getUid().toString()));
memberPage.getList().removeIf(a -> getBlackUidSet().contains(a.getFromUser().getUid().toString()));
System.out.println(1);
}
@PostMapping("/msg")
@ApiOperation("发送消息")
@FrequencyControl(time = 5, count = 2, target = FrequencyControl.Target.UID)

View File

@@ -1,12 +1,10 @@
package com.abin.mallchat.custom.chat.domain.vo.request;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
@@ -19,7 +17,7 @@ import javax.validation.constraints.NotNull;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChatMessageMarkReq{
public class ChatMessageMarkReq {
@NotNull
@ApiModelProperty("消息id")
private Long msgId;

View File

@@ -6,7 +6,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;

View File

@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
@@ -23,7 +22,7 @@ import javax.validation.constraints.NotNull;
public class ChatMessageReq {
@NotNull
@Length( max = 10000,message = "消息内容过长服务器扛不住啊兄dei")
@Length(max = 10000, message = "消息内容过长服务器扛不住啊兄dei")
@ApiModelProperty("消息内容")
private String content;

View File

@@ -1,12 +1,10 @@
package com.abin.mallchat.custom.chat.domain.vo.response;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;

View File

@@ -5,9 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* Description: 群成员统计信息

View File

@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.Map;
@@ -47,7 +48,7 @@ public class ChatMessageResp {
@ApiModelProperty("消息内容")
private String content;
@ApiModelProperty("消息链接映射")
private Map<String,String> urlTitleMap;
private Map<String, String> urlTitleMap;
@ApiModelProperty("消息类型 1正常文本 2.爆赞 点赞超过103.危险发言举报超5")
private Integer type;
@ApiModelProperty("消息标记")
@@ -82,6 +83,7 @@ public class ChatMessageResp {
@ApiModelProperty("该用户是否已经举报 0否 1是")
private Integer userDislike;
}
@Data
public static class Badge {
@ApiModelProperty("徽章图像")

View File

@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;

View File

@@ -1,6 +1,5 @@
package com.abin.mallchat.custom.chat.service;
import com.abin.mallchat.common.chat.dao.MessageDao;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
@@ -11,10 +10,6 @@ import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp;
import com.abin.mallchat.custom.chat.service.adapter.MessageAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Nullable;
@@ -34,21 +29,25 @@ public interface ChatService {
/**
* 根据消息获取消息前端展示的物料
*
* @param message
* @param receiveUid 接受消息的uid可null
* @return
*/
ChatMessageResp getMsgResp(Message message,Long receiveUid);
ChatMessageResp getMsgResp(Message message, Long receiveUid);
/**
* 根据消息获取消息前端展示的物料
*
* @param msgId
* @param receiveUid 接受消息的uid可null
* @return
*/
ChatMessageResp getMsgResp(Long msgId,Long receiveUid);
ChatMessageResp getMsgResp(Long msgId, Long receiveUid);
/**
* 获取群成员列表
*
* @param request
* @return
*/
@@ -56,13 +55,15 @@ public interface ChatService {
/**
* 获取消息列表
*
* @param request
* @return
*/
CursorPageBaseResp<ChatMessageResp> getMsgPage(ChatMessagePageReq request,@Nullable Long receiveUid);
CursorPageBaseResp<ChatMessageResp> getMsgPage(ChatMessagePageReq request, @Nullable Long receiveUid);
/**
* 获取会话列表
*
* @param request
* @param uid
* @return

View File

@@ -1,23 +1,16 @@
package com.abin.mallchat.custom.chat.service.adapter;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Pair;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.domain.enums.ChatActiveStatusEnum;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageReq;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**

View File

@@ -6,7 +6,6 @@ import com.abin.mallchat.common.chat.domain.entity.MessageExtra;
import com.abin.mallchat.common.chat.domain.entity.MessageMark;
import com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum;
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
import com.abin.mallchat.common.common.utils.discover.PrioritizedUrlTitleDiscover;
import com.abin.mallchat.common.user.domain.entity.IpDetail;
@@ -15,8 +14,6 @@ import com.abin.mallchat.common.user.domain.entity.ItemConfig;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageReq;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.sun.org.apache.regexp.internal.RE;
import org.yaml.snakeyaml.error.Mark;
import java.util.*;
import java.util.stream.Collectors;

View File

@@ -1,17 +1,10 @@
package com.abin.mallchat.custom.chat.service.adapter;
import cn.hutool.core.bean.BeanUtil;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.entity.Room;
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.chat.domain.vo.request.ChatMessageReq;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**

View File

@@ -14,9 +14,10 @@ import com.abin.mallchat.common.common.annotation.RedissonLock;
import com.abin.mallchat.common.common.domain.enums.YesOrNoEnum;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.common.event.MessageMarkEvent;
import com.abin.mallchat.common.common.event.MessageSendEvent;
import com.abin.mallchat.common.common.exception.BusinessException;
import com.abin.mallchat.common.common.utils.AssertUtil;
import com.abin.mallchat.common.common.utils.discover.PrioritizedUrlTitleDiscover;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.ItemConfig;
import com.abin.mallchat.common.user.domain.entity.User;
@@ -30,13 +31,11 @@ import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatRoomResp;
import com.abin.mallchat.custom.chat.service.ChatService;
import com.abin.mallchat.custom.chat.service.adapter.MemberAdapter;
import com.abin.mallchat.custom.chat.service.adapter.MessageAdapter;
import com.abin.mallchat.custom.chat.service.adapter.RoomAdapter;
import com.abin.mallchat.custom.chat.service.helper.ChatMemberHelper;
import com.abin.mallchat.common.common.event.MessageMarkEvent;
import com.abin.mallchat.common.common.event.MessageSendEvent;
import com.abin.mallchat.custom.chat.service.ChatService;
import com.abin.mallchat.custom.chat.service.adapter.MessageAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -22,6 +22,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
private CollectorInterceptor collectorInterceptor;
@Autowired
private BlackInterceptor blackInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(tokenInterceptor)

View File

@@ -10,14 +10,9 @@ import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoints
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@@ -59,6 +54,7 @@ public class SwaggerConfig {
.paths(PathSelectors.any())
.build();
}
/**
* 增加如下配置可解决Spring Boot 6.x 与Swagger 3.0.0 不兼容问题
**/
@@ -74,6 +70,7 @@ public class SwaggerConfig {
boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
}
private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
}

View File

@@ -1,28 +1,24 @@
package com.abin.mallchat.custom.common.config;
import com.abin.mallchat.custom.user.service.handler.*;
import com.abin.mallchat.custom.user.service.handler.LogHandler;
import com.abin.mallchat.custom.user.service.handler.MsgHandler;
import com.abin.mallchat.custom.user.service.handler.ScanHandler;
import com.abin.mallchat.custom.user.service.handler.SubscribeHandler;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.redis.JedisWxRedisOps;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import me.chanjar.weixin.mp.config.impl.WxMpRedisConfigImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.List;
import java.util.stream.Collectors;
import static me.chanjar.weixin.common.api.WxConsts.EventType;
import static me.chanjar.weixin.common.api.WxConsts.EventType.SUBSCRIBE;
import static me.chanjar.weixin.common.api.WxConsts.EventType.UNSUBSCRIBE;
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT;
import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.*;
import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY;
/**
* wechat mp configuration

View File

@@ -1,12 +1,12 @@
package com.abin.mallchat.custom.common.event.listener;
import com.abin.mallchat.common.common.event.ItemReceiveEvent;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.ItemConfig;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.domain.entity.UserBackpack;
import com.abin.mallchat.common.user.domain.enums.ItemTypeEnum;
import com.abin.mallchat.common.user.service.cache.ItemCache;
import com.abin.mallchat.common.common.event.ItemReceiveEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;

View File

@@ -7,9 +7,9 @@ import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.enums.MessageMarkTypeEnum;
import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
import com.abin.mallchat.common.common.domain.enums.IdempotentEnum;
import com.abin.mallchat.common.common.event.MessageMarkEvent;
import com.abin.mallchat.common.user.domain.enums.ItemEnum;
import com.abin.mallchat.common.user.service.IUserBackpackService;
import com.abin.mallchat.common.common.event.MessageMarkEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;

View File

@@ -2,8 +2,8 @@ package com.abin.mallchat.custom.common.event.listener;
import com.abin.mallchat.common.chat.dao.MessageDao;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.common.common.event.MessageSendEvent;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.service.ChatService;
import com.abin.mallchat.custom.user.service.WebSocketService;
import com.abin.mallchat.custom.user.service.adapter.WSAdapter;

View File

@@ -1,9 +1,9 @@
package com.abin.mallchat.custom.common.event.listener;
import com.abin.mallchat.common.common.event.UserOfflineEvent;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.common.common.event.UserOfflineEvent;
import com.abin.mallchat.custom.user.service.WebSocketService;
import com.abin.mallchat.custom.user.service.adapter.WSAdapter;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,10 +1,10 @@
package com.abin.mallchat.custom.common.event.listener;
import com.abin.mallchat.common.common.event.UserOnlineEvent;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.service.IpService;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.common.common.event.UserOnlineEvent;
import com.abin.mallchat.custom.user.service.WebSocketService;
import com.abin.mallchat.custom.user.service.adapter.WSAdapter;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,12 +1,11 @@
package com.abin.mallchat.custom.common.event.listener;
import com.abin.mallchat.common.common.domain.enums.IdempotentEnum;
import com.abin.mallchat.common.common.event.UserRegisterEvent;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.domain.enums.ItemEnum;
import com.abin.mallchat.common.user.service.IUserBackpackService;
import com.abin.mallchat.common.common.event.UserOnlineEvent;
import com.abin.mallchat.common.common.event.UserRegisterEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;

View File

@@ -1,6 +1,5 @@
package com.abin.mallchat.custom.common.intecepter;
import cn.hutool.extra.servlet.ServletUtil;
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;
@@ -11,14 +10,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/**
@@ -27,7 +23,7 @@ import java.util.Set;
@Order(2)
@Slf4j
@Component
public class BlackInterceptor implements HandlerInterceptor{
public class BlackInterceptor implements HandlerInterceptor {
@Autowired
private UserCache userCache;
@@ -36,18 +32,19 @@ public class BlackInterceptor implements HandlerInterceptor{
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Map<Integer, Set<String>> blackMap = userCache.getBlackMap();
RequestInfo requestInfo = RequestHolder.get();
if(inBlackList(requestInfo.getUid(),blackMap.get(BlackTypeEnum.UID.getType()))){
if (inBlackList(requestInfo.getUid(), blackMap.get(BlackTypeEnum.UID.getType()))) {
HttpErrorEnum.ACCESS_DENIED.sendHttpError(response);
return false;
}
if(inBlackList(requestInfo.getIp(),blackMap.get(BlackTypeEnum.IP.getType()))){
if (inBlackList(requestInfo.getIp(), blackMap.get(BlackTypeEnum.IP.getType()))) {
HttpErrorEnum.ACCESS_DENIED.sendHttpError(response);
return false;
}
return true;
}
private boolean inBlackList(Object target, Set<String> blackSet){
if(Objects.isNull(target)||Objects.isNull(blackSet)){
private boolean inBlackList(Object target, Set<String> blackSet) {
if (Objects.isNull(target) || Objects.isNull(blackSet)) {
return false;
}
return blackSet.contains(target.toString());

View File

@@ -1,14 +1,12 @@
package com.abin.mallchat.custom.common.intecepter;
import cn.hutool.extra.servlet.ServletUtil;
import com.abin.mallchat.common.common.utils.RequestHolder;
import com.abin.mallchat.common.common.domain.dto.RequestInfo;
import com.abin.mallchat.common.common.utils.RequestHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -20,7 +18,7 @@ import java.util.Optional;
@Order(1)
@Slf4j
@Component
public class CollectorInterceptor implements HandlerInterceptor{
public class CollectorInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

View File

@@ -2,15 +2,10 @@ package com.abin.mallchat.custom.common.intecepter;
import com.abin.mallchat.common.common.constant.MDCKey;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.*;
import javax.servlet.FilterConfig;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.UUID;

View File

@@ -1,29 +1,17 @@
package com.abin.mallchat.custom.common.intecepter;
import cn.hutool.http.HttpUtil;
import com.abin.mallchat.common.common.constant.MDCKey;
import com.abin.mallchat.common.common.exception.HttpErrorEnum;
import com.abin.mallchat.custom.user.service.LoginService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

View File

@@ -2,8 +2,8 @@ package com.abin.mallchat.custom.common.intecepter;
import cn.hutool.core.date.StopWatch;
import cn.hutool.json.JSONUtil;
import com.abin.mallchat.common.common.utils.RequestHolder;
import com.abin.mallchat.common.common.domain.dto.RequestInfo;
import com.abin.mallchat.common.common.utils.RequestHolder;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

View File

@@ -6,8 +6,8 @@ import com.abin.mallchat.common.common.utils.RequestHolder;
import com.abin.mallchat.custom.user.domain.vo.request.user.ModifyNameReq;
import com.abin.mallchat.custom.user.domain.vo.request.user.WearingBadgeReq;
import com.abin.mallchat.custom.user.domain.vo.response.user.BadgeResp;
import com.abin.mallchat.custom.user.service.UserService;
import com.abin.mallchat.custom.user.domain.vo.response.user.UserInfoResp;
import com.abin.mallchat.custom.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,7 +53,7 @@ public class UserController {
@PutMapping("/badge")
@ApiOperation("佩戴徽章")
public ApiResult<Void> wearingBadge(@Valid @RequestBody WearingBadgeReq req) {
userService.wearingBadge(RequestHolder.get().getUid(),req);
userService.wearingBadge(RequestHolder.get().getUid(), req);
return ApiResult.success();
}
}

View File

@@ -55,8 +55,8 @@ public class WxPortalController {
WxOAuth2AccessToken accessToken = wxService.getOAuth2Service().getAccessToken(code);
WxOAuth2UserInfo userInfo = wxService.getOAuth2Service().getUserInfo(accessToken, "zh_CN");
wxMsgService.authorize(userInfo);
}catch (Exception e){
log.error("callBack error",e);
} catch (Exception e) {
log.error("callBack error", e);
}
RedirectView redirectView = new RedirectView();
redirectView.setUrl("https://mp.weixin.qq.com/s/m1SRsBG96kLJW5mPe4AVGA");

View File

@@ -4,9 +4,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* Description: 记录和前端连接的一些映射信息

View File

@@ -15,11 +15,11 @@ import java.util.stream.Collectors;
*/
@AllArgsConstructor
@Getter
public enum WSReqTypeEnum {
public enum WSReqTypeEnum {
LOGIN(1, "请求登录二维码"),
HEARTBEAT(2, "心跳包"),
AUTHORIZE(3, "登录认证"),
;
;
private final Integer type;
private final String desc;

View File

@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
@@ -23,7 +22,7 @@ import javax.validation.constraints.NotNull;
public class ModifyNameReq {
@NotNull
@Length(max = 6,message = "用户名可别取太长,不然我记不住噢")
@Length(max = 6, message = "用户名可别取太长,不然我记不住噢")
@ApiModelProperty("用户名")
private String name;

View File

@@ -5,8 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;

View File

@@ -4,7 +4,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Description:

View File

@@ -11,6 +11,7 @@ import lombok.Data;
public class WSBaseReq {
/**
* 请求类型 1.请求登录二维码2心跳检测
*
* @see com.abin.mallchat.custom.user.domain.enums.WSReqTypeEnum
*/
private Integer type;

View File

@@ -11,6 +11,7 @@ import lombok.Data;
public class WSBaseResp<T> {
/**
* ws推送给前端的消息
*
* @see com.abin.mallchat.custom.user.domain.enums.WSRespTypeEnum
*/
private Integer type;

View File

@@ -4,7 +4,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Description:

View File

@@ -4,7 +4,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Description:

View File

@@ -1,15 +1,7 @@
package com.abin.mallchat.custom.user.domain.vo.response.ws;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
/**
* Description: 用户消息推送

View File

@@ -5,8 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,8 +1,5 @@
package com.abin.mallchat.custom.user.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* Description: 登录相关处理类
* Author: <a href="https://github.com/zongzibinbin">abin</a>
@@ -36,6 +33,7 @@ public interface LoginService {
/**
* 如果token有效返回uid
*
* @param token
* @return
*/

View File

@@ -1,11 +1,9 @@
package com.abin.mallchat.custom.user.service;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.user.domain.vo.request.user.ModifyNameReq;
import com.abin.mallchat.custom.user.domain.vo.request.user.WearingBadgeReq;
import com.abin.mallchat.custom.user.domain.vo.response.user.BadgeResp;
import com.abin.mallchat.custom.user.domain.vo.response.user.UserInfoResp;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@@ -17,10 +15,11 @@ import java.util.List;
* @author <a href="https://github.com/zongzibinbin">abin</a>
* @since 2023-03-19
*/
public interface UserService {
public interface UserService {
/**
* 获取前端展示信息
*
* @param uid
* @return
*/
@@ -28,6 +27,7 @@ public interface UserService {
/**
* 修改用户名
*
* @param uid
* @param req
*/
@@ -35,12 +35,14 @@ public interface UserService {
/**
* 用户徽章列表
*
* @param uid
*/
List<BadgeResp> badges(Long uid);
/**
* 佩戴徽章
*
* @param uid
* @param req
*/
@@ -48,6 +50,7 @@ public interface UserService {
/**
* 用户注册
*
* @param openId
*/
void register(String openId);

View File

@@ -1,32 +1,25 @@
package com.abin.mallchat.custom.user.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.abin.mallchat.common.common.config.ThreadPoolConfig;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.user.service.adapter.TextBuilder;
import com.abin.mallchat.custom.user.service.adapter.UserAdapter;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.net.URLEncoder;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* Description: 处理与微信api的交互逻辑
@@ -91,7 +84,7 @@ public class WxMsgService {
public void authorize(WxOAuth2UserInfo userInfo) {
User user = userDao.getByOpenId(userInfo.getOpenid());
//更新用户信息
if(Objects.isNull(user.getName())){
if (Objects.isNull(user.getName())) {
fillUserInfo(user.getId(), userInfo);
}
//触发用户登录成功操作

View File

@@ -15,8 +15,8 @@ public class ImageBuilder extends AbstractBuilder {
WxMpService service) {
WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content)
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
return m;
}

View File

@@ -14,8 +14,8 @@ public class TextBuilder extends AbstractBuilder {
public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage,
WxMpService service) {
WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content)
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
.fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.build();
return m;
}
}

View File

@@ -11,7 +11,6 @@ import com.abin.mallchat.custom.user.domain.vo.response.user.BadgeResp;
import com.abin.mallchat.custom.user.domain.vo.response.user.UserInfoResp;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import java.util.Comparator;
import java.util.List;
@@ -38,9 +37,9 @@ public class UserAdapter {
user.setAvatar(userInfo.getHeadImgUrl());
user.setName(userInfo.getNickname());
user.setSex(userInfo.getSex());
if(userInfo.getNickname().length()>6){
user.setName("名字过长"+RandomUtil.randomInt(100000));
}else {
if (userInfo.getNickname().length() > 6) {
user.setName("名字过长" + RandomUtil.randomInt(100000));
} else {
user.setName(userInfo.getNickname());
}
return user;

View File

@@ -3,19 +3,20 @@ package com.abin.mallchat.custom.user.service.adapter;
import cn.hutool.core.bean.BeanUtil;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.user.domain.enums.ChatActiveStatusEnum;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.custom.chat.service.ChatService;
import com.abin.mallchat.custom.user.domain.enums.WSRespTypeEnum;
import com.abin.mallchat.custom.chat.domain.vo.response.ChatMemberResp;
import com.abin.mallchat.custom.user.domain.vo.response.ws.*;
import com.abin.mallchat.custom.user.domain.vo.response.ws.WSBaseResp;
import com.abin.mallchat.custom.user.domain.vo.response.ws.WSLoginSuccess;
import com.abin.mallchat.custom.user.domain.vo.response.ws.WSLoginUrl;
import com.abin.mallchat.custom.user.domain.vo.response.ws.WSOnlineOfflineNotify;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
/**
* Description: ws消息适配器

View File

@@ -9,7 +9,6 @@ import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -26,12 +25,13 @@ public class MsgHandler extends AbstractHandler {
@Autowired
private WxMsgDao wxMsgDao;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
Map<String, Object> context, WxMpService weixinService,
WxSessionManager sessionManager) {
if (true) {
WxMsg msg =new WxMsg();
WxMsg msg = new WxMsg();
msg.setOpenId(wxMessage.getFromUser());
msg.setMsg(wxMessage.getContent());
wxMsgDao.save(msg);

View File

@@ -1,26 +1,15 @@
package com.abin.mallchat.custom.user.service.handler;
import cn.hutool.core.util.URLUtil;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.custom.user.service.LoginService;
import com.abin.mallchat.custom.user.service.WebSocketService;
import com.abin.mallchat.custom.user.service.WxMsgService;
import com.abin.mallchat.custom.user.service.adapter.TextBuilder;
import com.abin.mallchat.custom.user.service.adapter.UserAdapter;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Objects;
@Component
public class ScanHandler extends AbstractHandler {
@@ -28,11 +17,12 @@ public class ScanHandler extends AbstractHandler {
@Autowired
private WxMsgService wxMsgService;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
// 扫码事件处理
return wxMsgService.scan(wxMpService,wxMpXmlMessage);
return wxMsgService.scan(wxMpService, wxMpXmlMessage);
}

View File

@@ -7,7 +7,6 @@ import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@@ -5,13 +5,11 @@ import com.abin.mallchat.common.common.constant.RedisKey;
import com.abin.mallchat.common.common.utils.JwtUtils;
import com.abin.mallchat.common.common.utils.RedisUtils;
import com.abin.mallchat.custom.user.service.LoginService;
import com.auth0.jwt.interfaces.Claim;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

View File

@@ -1,5 +1,6 @@
package com.abin.mallchat.custom.user.service.impl;
import com.abin.mallchat.common.common.event.UserRegisterEvent;
import com.abin.mallchat.common.common.utils.AssertUtil;
import com.abin.mallchat.common.user.dao.ItemConfigDao;
import com.abin.mallchat.common.user.dao.UserBackpackDao;
@@ -12,7 +13,6 @@ import com.abin.mallchat.common.user.domain.enums.ItemTypeEnum;
import com.abin.mallchat.common.user.service.IUserBackpackService;
import com.abin.mallchat.common.user.service.cache.ItemCache;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.common.common.event.UserRegisterEvent;
import com.abin.mallchat.custom.user.domain.vo.request.user.ModifyNameReq;
import com.abin.mallchat.custom.user.domain.vo.request.user.WearingBadgeReq;
import com.abin.mallchat.custom.user.domain.vo.response.user.BadgeResp;
@@ -64,7 +64,7 @@ public class UserServiceImpl implements UserService {
public void modifyName(Long uid, ModifyNameReq req) {
//判断名字是不是重复
User oldUser = userDao.getByName(req.getName());
AssertUtil.isEmpty(oldUser,"名字已经被抢占了,请换一个哦~~");
AssertUtil.isEmpty(oldUser, "名字已经被抢占了,请换一个哦~~");
//判断改名卡够不够
UserBackpack firstValidItem = userBackpackDao.getFirstValidItem(uid, ItemEnum.MODIFY_NAME_CARD.getId());
AssertUtil.isNotEmpty(firstValidItem, "改名次数不够了,等后续活动送改名卡哦");

View File

@@ -5,14 +5,14 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import com.abin.mallchat.common.common.config.ThreadPoolConfig;
import com.abin.mallchat.common.common.event.UserOfflineEvent;
import com.abin.mallchat.common.common.event.UserOnlineEvent;
import com.abin.mallchat.common.user.dao.UserDao;
import com.abin.mallchat.common.user.domain.entity.User;
import com.abin.mallchat.common.common.event.UserOfflineEvent;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.custom.user.domain.dto.ws.WSChannelExtraDTO;
import com.abin.mallchat.custom.user.domain.vo.request.ws.WSAuthorize;
import com.abin.mallchat.custom.user.domain.vo.response.ws.WSBaseResp;
import com.abin.mallchat.common.common.event.UserOnlineEvent;
import com.abin.mallchat.custom.user.service.LoginService;
import com.abin.mallchat.custom.user.service.WebSocketService;
import com.abin.mallchat.custom.user.service.adapter.WSAdapter;

View File

@@ -4,7 +4,6 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import java.net.InetSocketAddress;

View File

@@ -1,10 +1,8 @@
package com.abin.mallchat.custom.user.websocket;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import org.omg.CORBA.PUBLIC_MEMBER;
/**
* Description: netty工具类

View File

@@ -1,7 +1,10 @@
package com.abin.mallchat.custom.user.websocket;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
@@ -11,17 +14,12 @@ import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.net.InetSocketAddress;
@Slf4j
@Configuration

View File

@@ -6,7 +6,6 @@ import com.abin.mallchat.custom.user.domain.enums.WSReqTypeEnum;
import com.abin.mallchat.custom.user.domain.vo.request.ws.WSAuthorize;
import com.abin.mallchat.custom.user.domain.vo.request.ws.WSBaseReq;
import com.abin.mallchat.custom.user.service.WebSocketService;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
@@ -14,10 +13,6 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import java.net.SocketAddress;
import java.util.HashSet;
import java.util.Set;
@Slf4j
public class NettyWebSocketServerHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
@@ -75,7 +70,7 @@ public class NettyWebSocketServerHandler extends SimpleChannelInboundHandler<Tex
// 处理异常
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
log.warn("异常发生,异常消息 ={}" , cause.getMessage());
log.warn("异常发生,异常消息 ={}", cause.getMessage());
ctx.channel().close();
}