From b38ee09029bbf6ed99e84401a5afc0de5ddac29d Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 8 Jun 2017 11:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E4=BA=BA=E5=91=98=20?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/SimplePersonService.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/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 b/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 index 8c9ad1bd1..7e4be7118 100644 --- a/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 +++ b/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 @@ -30,6 +30,7 @@ import org.hswebframework.web.organizational.authorization.simple.SimplePersonne import org.hswebframework.web.organizational.authorization.simple.SimplePersonnelAuthorization; import org.hswebframework.web.service.DefaultDSLQueryService; import org.hswebframework.web.service.EnableCacheGernericEntityService; +import org.hswebframework.web.service.authorization.AuthorizationSettingTypeSupplier; import org.hswebframework.web.service.authorization.UserService; import org.hswebframework.web.service.organizational.PersonService; import org.springframework.beans.factory.annotation.Autowired; @@ -59,7 +60,11 @@ import static org.springframework.util.StringUtils.*; @Service("personService") @CacheConfig(cacheNames = "person") public class SimplePersonService extends EnableCacheGernericEntityService - implements PersonService, PersonnelAuthorizationManager { + implements PersonService, PersonnelAuthorizationManager, AuthorizationSettingTypeSupplier { + + private static String SETTING_TYPE_PERSON = "person"; + private static String SETTING_TYPE_POSITION = "position"; + @Autowired private PersonDao personDao; @@ -128,7 +133,7 @@ public class SimplePersonService extends EnableCacheGernericEntityService positionIds = DefaultDSLQueryService.createQuery(personPositionDao) .where(PersonPositionEntity.personId, id) - .list().stream() + .listNoPaging().stream() .map(PersonPositionEntity::getPositionId) .collect(Collectors.toSet()); @@ -167,7 +172,7 @@ public class SimplePersonService extends EnableCacheGernericEntityService positionEntities = DefaultDSLQueryService.createQuery(positionDao) .where().in(PositionEntity.id, positionIds) - .list(); + .listNoPaging(); if (positionEntities.isEmpty()) return; //获取用户是否存在 UserEntity oldUser = userService.selectByUsername(bindEntity.getPersonUser().getUsername()); @@ -227,7 +232,7 @@ public class SimplePersonService extends EnableCacheGernericEntityService positionIds = DefaultDSLQueryService.createQuery(personPositionDao) .where(PersonPositionEntity.personId, personId) - .list().stream() + .listNoPaging().stream() .map(PersonPositionEntity::getPositionId) .collect(Collectors.toSet()); //获取所有职位,并得到根职位(树结构) @@ -271,7 +276,7 @@ public class SimplePersonService extends EnableCacheGernericEntityService root = DefaultDSLQueryService.createQuery(dao) .where().in(TreeSupportEntity.id, rootIds) - .list(); + .listNoPaging(); //节点不存在? if (!root.isEmpty()) { //所有子节点,使用节点的path属性进行快速查询,查询结果包含了根节点 @@ -279,7 +284,7 @@ public class SimplePersonService extends EnableCacheGernericEntityService query.or().like$(TreeSupportEntity.path, data.getPath())) - .list(); + .listNoPaging(); //转为树形结构 List tree = TreeSupportEntity .list2tree(allNode, childAccepter, @@ -316,4 +321,25 @@ public class SimplePersonService extends EnableCacheGernericEntityService get(String userId) { + //支持职位和人员 设置权限 + PersonEntity entity = createQuery().where(PersonEntity.userId, userId).single(); + if (entity == null) return new HashSet<>(); + Set settingInfo = new HashSet<>(); + //岗位设置 + //TODO 2017/06/08 是否将子级岗位的设置也放进来?? + DefaultDSLQueryService.createQuery(personPositionDao) + .where(PersonPositionEntity.personId, entity.getId()) + .listNoPaging() + .stream() + .map(position -> new SettingInfo(SETTING_TYPE_POSITION, position.getPositionId())) + .forEach(settingInfo::add); + //其他设置支持? + + //人员配置 + settingInfo.add(new SettingInfo(SETTING_TYPE_PERSON, entity.getId())); + return settingInfo; + } }