!251 fix 修复 判断条件写反问题

Merge pull request !251 from 疯狂的狮子Li/dev
This commit is contained in:
疯狂的狮子Li 2025-12-24 05:27:47 +00:00 committed by Gitee
commit 43e522e35c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 30 additions and 133 deletions

15
pom.xml
View File

@ -36,7 +36,8 @@
<satoken.version>1.44.0</satoken.version>
<lombok.version>1.18.40</lombok.version>
<logstash.version>7.4</logstash.version>
<easy-es.version>3.0.0</easy-es.version>
<easy-es.version>3.0.1</easy-es.version>
<elasticsearch-client.version>7.17.28</elasticsearch-client.version>
<skywalking-toolkit.version>9.3.0</skywalking-toolkit.version>
<bouncycastle.version>1.80</bouncycastle.version>
<mapstruct-plus.version>1.5.0</mapstruct-plus.version>
@ -279,6 +280,18 @@
<version>${easy-es.version}</version>
</dependency>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>${elasticsearch-client.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>${elasticsearch-client.version}</version>
</dependency>
<!-- skywalking 整合 logback -->
<dependency>
<groupId>org.apache.skywalking</groupId>

View File

@ -1,102 +0,0 @@
package org.dromara.easyes.spring.config;
import lombok.NonNull;
import lombok.Setter;
import org.dromara.easyes.common.constants.BaseEsConstants;
import org.dromara.easyes.common.property.EasyEsDynamicProperties;
import org.dromara.easyes.common.property.EasyEsProperties;
import org.dromara.easyes.common.strategy.AutoProcessIndexStrategy;
import org.dromara.easyes.common.utils.EsClientUtils;
import org.dromara.easyes.core.index.AutoProcessIndexNotSmoothlyStrategy;
import org.dromara.easyes.core.index.AutoProcessIndexSmoothlyStrategy;
import org.dromara.easyes.spring.factory.IndexStrategyFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
import java.util.Map;
/**
* Easy-Es Spring配置类
* @author MoJie
* @since 2.0
*/
@ConditionalOnProperty(value = "easy-es.enable", havingValue = "true")
@Configuration
public class EasyEsConfiguration implements InitializingBean, EnvironmentAware {
private Environment environment;
@Setter
@Autowired(required = false)
private EasyEsProperties easyEsProperties;
@Setter
@Autowired(required = false)
private EasyEsDynamicProperties easyEsDynamicProperties;
@Override
public void setEnvironment(@NonNull Environment environment) {
this.environment = environment;
}
/**
* 当当前配置类注册为bean完成后触发校验easy-es配置是否存在
* 如果easy-es.enable: false, 那么不进行校验和抛出异常
* 默认情况下引入了easy-es是需要配置的即easy-es.enable:true
* 如果不需要easy-es那么自行配置为false
* @author MoJie
*/
@Override
public void afterPropertiesSet() {
Boolean enable = environment.getProperty(BaseEsConstants.ENABLE_PREFIX, Boolean.class, Boolean.TRUE);
if (enable) {
Assert.notNull(this.easyEsProperties, "easyEsProperties must is A bean. easy-es配置类必须给配置一个bean");
}
}
@Bean
public IndexStrategyFactory indexStrategyFactory() {
return new IndexStrategyFactory();
}
@Bean
public EsClientUtils esClientUtils() {
EsClientUtils esClientUtils = new EsClientUtils();
if (this.easyEsDynamicProperties == null) {
this.easyEsDynamicProperties = new EasyEsDynamicProperties();
}
Map<String, EasyEsProperties> datasourceMap = this.easyEsDynamicProperties.getDatasource();
if (datasourceMap.isEmpty()) {
// 设置默认数据源,兼容不使用多数据源配置场景的老用户使用习惯
datasourceMap.put(EsClientUtils.DEFAULT_DS, this.easyEsProperties);
}
for (String key : datasourceMap.keySet()) {
EasyEsProperties easyEsConfigProperties = datasourceMap.get(key);
EsClientUtils.registerClient(key, () -> EsClientUtils.buildClient(easyEsConfigProperties));
}
return esClientUtils;
}
/**
* 索引策略注册
*
* @return {@link AutoProcessIndexStrategy}
* @author MoJie
*/
@Bean
public AutoProcessIndexStrategy autoProcessIndexSmoothlyStrategy() {
return new AutoProcessIndexSmoothlyStrategy();
}
@Bean
public AutoProcessIndexStrategy autoProcessIndexNotSmoothlyStrategy() {
return new AutoProcessIndexNotSmoothlyStrategy();
}
}

View File

@ -1,27 +0,0 @@
package org.dromara.easyes.starter.config;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import org.dromara.easyes.core.config.GeneratorConfig;
import org.dromara.easyes.core.toolkit.Generator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
/**
* 代码生成注册
* @author MoJie
* @since 2.0
*/
@ConditionalOnProperty(value = "easy-es.enable", havingValue = "true")
@Component
public class GeneratorConfiguration extends Generator {
@Autowired
private ElasticsearchClient client;
@Override
public Boolean generate(GeneratorConfig config) {
super.generateEntity(config, this.client);
return Boolean.TRUE;
}
}

View File

@ -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 格式出错时抛出
* 可能是请求体格式非法也可能是服务端反序列化失败

View File

@ -8,6 +8,7 @@ import org.dromara.common.websocket.utils.WebSocketUtils;
import org.dromara.system.api.model.LoginUser;
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());
}

View File

@ -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 {

View File

@ -77,7 +77,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);