zhou-hao 7 éve
szülő
commit
f94be7b39a

+ 9 - 8
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java

@@ -35,9 +35,9 @@ import java.util.function.Supplier;
  */
 @SuppressWarnings("unchecked")
 public class MapperEntityFactory implements EntityFactory {
-    private Map<Class, Mapper>          realTypeMapper = new HashMap<>();
-    private Logger                      logger         = LoggerFactory.getLogger(this.getClass());
-    private Map<String, PropertyCopier> copierCache    = new HashMap<>();
+    private Map<Class, Mapper> realTypeMapper = new HashMap<>();
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+    private Map<String, PropertyCopier> copierCache = new HashMap<>();
 
     private static final DefaultMapperFactory DEFAULT_MAPPER_FACTORY = clazz -> {
         String simpleClassName = clazz.getPackage().getName().concat(".Simple").concat(clazz.getSimpleName());
@@ -49,9 +49,10 @@ public class MapperEntityFactory implements EntityFactory {
         return null;
     };
 
-    private static final DefaultPropertyCopier DEFAULT_PROPERTY_COPIER = (source, target) -> {
-        return FastBeanCopier.copy(source, target);
-    };
+    /**
+     * 默认的属性复制器
+     */
+    private static final DefaultPropertyCopier DEFAULT_PROPERTY_COPIER = FastBeanCopier::copy;
 
     private DefaultMapperFactory defaultMapperFactory = DEFAULT_MAPPER_FACTORY;
 
@@ -125,7 +126,7 @@ public class MapperEntityFactory implements EntityFactory {
             realType = beanClass;
         }
         if (mapper == null && realType != null) {
-            if (logger.isDebugEnabled()) {
+            if (logger.isDebugEnabled() && realType != beanClass) {
                 logger.debug("use instance {} for {}", realType, beanClass);
             }
             mapper = new Mapper<>(realType, new DefaultInstanceGetter(realType));
@@ -188,7 +189,7 @@ public class MapperEntityFactory implements EntityFactory {
     }
 
     public static class Mapper<T> {
-        Class<T>    target;
+        Class<T> target;
         Supplier<T> instanceGetter;
 
         public Mapper(Class<T> target, Supplier<T> instanceGetter) {

+ 5 - 7
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-service/hsweb-system-organizational-service-simple/src/main/java/org/hswebframework/web/service/organizational/simple/SimplePersonService.java

@@ -274,9 +274,11 @@ public class SimplePersonService extends GenericEntityService<PersonEntity, Stri
     @Override
     @Cacheable(key = "'auth:persion-id'+#personId")
     public PersonnelAuthorization getPersonnelAuthorizationByPersonId(String personId) {
-        SimplePersonnelAuthorization authorization = new SimplePersonnelAuthorization();
         PersonEntity entity = selectByPk(personId);
-        assertNotNull(entity);
+        if (null == entity) {
+            return null;
+        }
+        SimplePersonnelAuthorization authorization = new SimplePersonnelAuthorization();
 
         Personnel personnel = entityFactory.newInstance(Personnel.class, SimplePersonnel.class, entity);
 
@@ -301,19 +303,15 @@ public class SimplePersonService extends GenericEntityService<PersonEntity, Stri
                     .peek(positionEntity -> positionCache.put(positionEntity.getId(), positionEntity))
                     .map(PositionEntity::getDepartmentId)
                     .collect(Collectors.toSet());
-//            rootPosList.forEach(positionEntity -> positionCache.put(positionEntity.getId(), positionEntity));
             if (!CollectionUtils.isEmpty(departmentIds)) {
                 List<DepartmentEntity> departmentEntities = getAllChildrenAndReturnRootNode(departmentDao, departmentIds, DepartmentEntity::setChildren, rootDepList -> {
-                    //rootDepList.forEach(departmentEntity -> departmentCache.put(departmentEntity.getId(), departmentEntity));
                     //根据部门获取机构
                     Set<String> orgIds = rootDepList.stream()
                             .peek(departmentEntity -> departmentCache.put(departmentEntity.getId(), departmentEntity))
                             .map(DepartmentEntity::getOrgId)
                             .collect(Collectors.toSet());
-
                     if (!CollectionUtils.isEmpty(orgIds)) {
                         List<OrganizationalEntity> orgEntities = getAllChildrenAndReturnRootNode(organizationalDao, orgIds, OrganizationalEntity::setChildren, rootOrgList -> {
-//                            rootOrgList.forEach(org -> orgCache.put(org.getId(), org));
                             //根据机构获取行政区域
                             Set<String> districtIds = rootOrgList.stream()
                                     .peek(org -> orgCache.put(org.getId(), org))
@@ -336,7 +334,7 @@ public class SimplePersonService extends GenericEntityService<PersonEntity, Stri
         });
         authorization.setPositionIds(transformationTreeNode(null, positionEntities));
 
-        Set<Position> positions = positionEntities.parallelStream()
+        Set<Position> positions = positionEntities.stream()
                 .map(positionEntity -> {
                     DepartmentEntity departmentEntity = departmentCache.get(positionEntity.getDepartmentId());
                     if (departmentEntity == null) {