瀏覽代碼

!816 fix 修复 判断条件写反问题
Merge pull request !816 from 疯狂的狮子Li/dev

疯狂的狮子Li 6 月之前
父節點
當前提交
88f871002c

+ 12 - 0
ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java

@@ -14,6 +14,7 @@ import org.dromara.common.core.exception.SseException;
 import org.dromara.common.core.exception.base.BaseException;
 import org.dromara.common.core.utils.StreamUtils;
 import org.dromara.common.json.utils.JsonUtils;
+import org.springframework.context.MessageSourceResolvable;
 import org.springframework.context.support.DefaultMessageSourceResolvable;
 import org.springframework.expression.ExpressionException;
 import org.springframework.http.converter.HttpMessageNotReadableException;
@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseStatus;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
+import org.springframework.web.method.annotation.HandlerMethodValidationException;
 import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
 import org.springframework.web.servlet.NoHandlerFoundException;
 
@@ -191,6 +193,16 @@ public class GlobalExceptionHandler {
         return R.fail(message);
     }
 
+    /**
+     * 方法参数校验异常 用于处理 @Validated 注解
+     */
+    @ExceptionHandler(HandlerMethodValidationException.class)
+    public R<Void> handlerMethodValidationException(HandlerMethodValidationException e) {
+        log.error(e.getMessage());
+        String message = StreamUtils.join(e.getAllErrors(), MessageSourceResolvable::getDefaultMessage, ", ");
+        return R.fail(message);
+    }
+
     /**
      * JSON 解析异常(Jackson 在处理 JSON 格式出错时抛出)
      * 可能是请求体格式非法,也可能是服务端反序列化失败

+ 2 - 1
ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/handler/PlusWebSocketHandler.java

@@ -8,6 +8,7 @@ import org.dromara.common.websocket.holder.WebSocketSessionHolder;
 import org.dromara.common.websocket.utils.WebSocketUtils;
 import org.springframework.web.socket.*;
 import org.springframework.web.socket.handler.AbstractWebSocketHandler;
+import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
 
 import java.io.IOException;
 import java.util.List;
@@ -33,7 +34,7 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
             log.info("[connect] invalid token received. sessionId: {}", session.getId());
             return;
         }
-        WebSocketSessionHolder.addSession(loginUser.getUserId(), session);
+        WebSocketSessionHolder.addSession(loginUser.getUserId(), new ConcurrentWebSocketSessionDecorator(session, 10 * 1000, 64000));
         log.info("[connect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
     }
 

+ 1 - 1
ruoyi-common/ruoyi-common-websocket/src/main/java/org/dromara/common/websocket/utils/WebSocketUtils.java

@@ -113,7 +113,7 @@ public class WebSocketUtils {
      * @param session WebSocket会话
      * @param message 要发送的WebSocket消息对象
      */
-    private synchronized static void sendMessage(WebSocketSession session, WebSocketMessage<?> message) {
+    private static void sendMessage(WebSocketSession session, WebSocketMessage<?> message) {
         if (session == null || !session.isOpen()) {
             log.warn("[send] session会话已经关闭");
         } else {

+ 1 - 1
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/WorkflowGlobalListener.java

@@ -74,7 +74,7 @@ public class WorkflowGlobalListener implements GlobalListener {
         String ext = listenerVariable.getNode().getExt();
         if (StringUtils.isNotBlank(ext)) {
             Map<String, Object> variable = listenerVariable.getVariable();
-            if (CollUtil.isNotEmpty(variable)) {
+            if (CollUtil.isEmpty(variable)) {
                 variable = new HashMap<>();
             }
             NodeExtVo nodeExt = nodeExtService.parseNodeExt(ext, variable);