Parcourir la source

优化entityFactory

zhouhao il y a 8 ans
Parent
commit
98a3eaefb3

+ 3 - 0
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java

@@ -35,6 +35,9 @@ import java.util.function.Supplier;
 public class MapperEntityFactory implements EntityFactory {
     private Map<Class, Mapper> realTypeMapper = new HashMap<>();
 
+    public MapperEntityFactory() {
+    }
+
     public <T extends Entity> MapperEntityFactory(Map<Class<T>, Mapper> realTypeMapper) {
         this.realTypeMapper.putAll(realTypeMapper);
     }

+ 0 - 1
hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/SpringBootExample.java

@@ -35,7 +35,6 @@ import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.TypeExcludeFilter;
 import org.springframework.context.annotation.*;
 import org.springframework.jdbc.datasource.DataSourceUtils;
 

+ 7 - 1
hsweb-examples/hsweb-examples-simple/src/main/resources/application.yml

@@ -11,4 +11,10 @@ spring:
 hsweb:
     app:
       name: hsweb示例
-      version: 3.0.0
+      version: 3.0.0
+    entity:
+      mappings:
+          -  source-base-package: org.hswebframework.web.entity.authorization
+             target-base-package: org.hswebframework.web.entity.authorization
+             mapping:
+                UserEntity: SimpleUserEntity

+ 0 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java

@@ -41,7 +41,6 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.io.IOException;
-import java.util.Date;
 import java.util.List;
 
 import static org.hswebframework.web.controller.message.ResponseMessage.ok;

+ 2 - 7
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-api/src/main/java/org/hswebframework/web/service/authorization/UserService.java

@@ -1,20 +1,19 @@
 package org.hswebframework.web.service.authorization;
 
-import org.hswebframework.web.authorization.Authorization;
+import org.hswebframework.web.authorization.AuthorizationInitializeService;
 import org.hswebframework.web.entity.authorization.UserEntity;
 import org.hswebframework.web.service.CreateEntityService;
 import org.hswebframework.web.service.InsertService;
 import org.hswebframework.web.service.QueryByEntityService;
 import org.hswebframework.web.service.QueryService;
 
-import java.util.Date;
-
 /**
  * TODO 完成注释
  *
  * @author zhouhao
  */
 public interface UserService extends
+        AuthorizationInitializeService,
         CreateEntityService<UserEntity>,
         QueryByEntityService<UserEntity>,
         QueryService<UserEntity, String>,
@@ -33,8 +32,4 @@ public interface UserService extends
     void updateLoginInfo(String userId, String ip, Long loginTime);
 
     void updatePassword(String userId, String oldPassword, String newPassword);
-
-    Authorization initUserAuthorization(String userId);
-
-    Authorization initAdminAuthorization(String userId);
 }

+ 0 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/UserTests.java

@@ -32,7 +32,6 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 import java.sql.SQLException;
-import java.util.Date;
 
 /**
  * TODO 完成注释

+ 0 - 13
hsweb-tests/src/main/java/org/hswebframework/web/tests/SimpleWebApplicationTests.java

@@ -122,19 +122,6 @@ public class SimpleWebApplicationTests {
     @WebAppConfiguration
     public static class Config {
 
-        @Bean(name = "validator")
-        @ConditionalOnMissingBean(Validator.class)
-        public Validator validator() {
-            ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
-            Validator validator = factory.getValidator();
-            return validator;
-        }
-
-        @Bean
-        public EntityFactory beanFactory() {
-            return new MapperEntityFactory();
-        }
-
         @Bean
         public SqlExecutor sqlExecutor(DataSource dataSource) throws SQLException {
             Connection connection = dataSource.getConnection();