From abffaeee52a928d7da43dc91befa07a6feb4ad70 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 23 May 2025 14:55:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/EasyormConfiguration.java | 9 ------- .../EntityFactoryConfiguration.java | 24 +++++++++++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 3 ++- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EntityFactoryConfiguration.java diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java index 68d48c0bd..0c0c47729 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java @@ -57,15 +57,6 @@ public class EasyormConfiguration { } - @Bean - @ConditionalOnMissingBean - public EntityFactory entityFactory(ObjectProvider customizers) { - MapperEntityFactory factory = new MapperEntityFactory(); - for (EntityMappingCustomizer customizer : customizers) { - customizer.custom(factory); - } - return factory; - } @Bean @Primary diff --git a/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EntityFactoryConfiguration.java b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EntityFactoryConfiguration.java new file mode 100644 index 000000000..3c75b74f8 --- /dev/null +++ b/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EntityFactoryConfiguration.java @@ -0,0 +1,24 @@ +package org.hswebframework.web.crud.configuration; + +import org.hswebframework.web.api.crud.entity.EntityFactory; +import org.hswebframework.web.crud.entity.factory.EntityMappingCustomizer; +import org.hswebframework.web.crud.entity.factory.MapperEntityFactory; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; + +@AutoConfiguration +public class EntityFactoryConfiguration { + + @Bean + @ConditionalOnMissingBean + public EntityFactory entityFactory(ObjectProvider customizers) { + MapperEntityFactory factory = new MapperEntityFactory(); + for (EntityMappingCustomizer customizer : customizers) { + customizer.custom(factory); + } + return factory; + } + +} diff --git a/hsweb-commons/hsweb-commons-crud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/hsweb-commons/hsweb-commons-crud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index b54296e48..30062031c 100644 --- a/hsweb-commons/hsweb-commons-crud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/hsweb-commons/hsweb-commons-crud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -2,4 +2,5 @@ org.hswebframework.web.crud.configuration.EasyormConfiguration org.hswebframework.web.crud.configuration.JdbcSqlExecutorConfiguration org.hswebframework.web.crud.configuration.R2dbcSqlExecutorConfiguration org.hswebframework.web.crud.web.CommonWebFluxConfiguration -org.hswebframework.web.crud.web.CommonWebMvcConfiguration \ No newline at end of file +org.hswebframework.web.crud.web.CommonWebMvcConfiguration +org.hswebframework.web.crud.configuration.EntityFactoryConfiguration \ No newline at end of file