mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-09 09:24:03 +08:00
优化jsr303验证
This commit is contained in:
@@ -8,24 +8,18 @@ import org.hswebframework.ezorm.rdb.metadata.RDBTableMetadata;
|
||||
import org.hswebframework.ezorm.rdb.operator.DatabaseOperator;
|
||||
import org.hswebframework.web.api.crud.entity.EntityFactory;
|
||||
import org.hswebframework.web.crud.entity.factory.MapperEntityFactory;
|
||||
import org.hswebframework.web.crud.events.EntityBeforeQueryEvent;
|
||||
import org.hswebframework.web.crud.events.EntityDDLEvent;
|
||||
import org.hswebframework.web.event.GenericsPayloadApplicationEvent;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.transaction.ReactiveTransactionManager;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@@ -69,7 +63,7 @@ public class AutoDDLProcessor implements InitializingBean {
|
||||
.doOnNext(type -> log.trace("auto ddl for {}", type))
|
||||
.map(type -> {
|
||||
RDBTableMetadata metadata = resolver.resolve(type);
|
||||
EntityDDLEvent event = new EntityDDLEvent(type,metadata);
|
||||
EntityDDLEvent event = new EntityDDLEvent(this,type,metadata);
|
||||
eventPublisher.publishEvent(new GenericsPayloadApplicationEvent<>(this, event, type));
|
||||
return metadata;
|
||||
})
|
||||
@@ -89,7 +83,7 @@ public class AutoDDLProcessor implements InitializingBean {
|
||||
log.trace("auto ddl for {}", type);
|
||||
try {
|
||||
RDBTableMetadata metadata = resolver.resolve(type);
|
||||
EntityDDLEvent event = new EntityDDLEvent(type,metadata);
|
||||
EntityDDLEvent event = new EntityDDLEvent(this,type,metadata);
|
||||
eventPublisher.publishEvent(new GenericsPayloadApplicationEvent<>(this, event, type));
|
||||
operator.ddl()
|
||||
.createOrAlter(metadata)
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package org.hswebframework.web.crud.events;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.hswebframework.ezorm.rdb.metadata.RDBTableMetadata;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class EntityDDLEvent<E> {
|
||||
private Class<E> type;
|
||||
public class EntityDDLEvent<E> extends ApplicationEvent {
|
||||
private final Class<E> type;
|
||||
|
||||
private RDBTableMetadata table;
|
||||
private final RDBTableMetadata table;
|
||||
|
||||
public EntityDDLEvent(Object source,Class<E> type,RDBTableMetadata table) {
|
||||
super(source);
|
||||
this.type=type;
|
||||
this.table=table;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ValidateEventListener implements EventListener {
|
||||
if (resultHolder.isPresent()) {
|
||||
resultHolder
|
||||
.ifPresent(holder -> holder
|
||||
.before(LocaleUtils
|
||||
.invoke(LocaleUtils
|
||||
.currentReactive()
|
||||
.doOnNext(locale -> LocaleUtils.doWith(locale, (l) -> tryValidate(type, context)))
|
||||
.then()
|
||||
|
||||
Reference in New Issue
Block a user