|
@@ -52,17 +52,18 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
public List<OrgDto> listOrgTree() {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(SysOrg::getSchoolId, schoolId).orderByAsc(SysOrg::getParentId, SysOrg::getCode);
|
|
|
+ queryWrapper.lambda().eq(SysOrg::getSchoolId, schoolId).orderByAsc(SysOrg::getParentId);
|
|
|
List<SysOrg> orgList = this.list(queryWrapper);
|
|
|
Map<Long, OrgDto> map = new LinkedHashMap<>();
|
|
|
for (SysOrg sysOrg : orgList) {
|
|
|
OrgDto orgDto = new OrgDto();
|
|
|
- orgDto.setId(String.valueOf(sysOrg.getId()));
|
|
|
+ orgDto.setId(sysOrg.getId());
|
|
|
orgDto.setSchoolId(String.valueOf(sysOrg.getSchoolId()));
|
|
|
orgDto.setCode(sysOrg.getCode());
|
|
|
orgDto.setName(sysOrg.getName());
|
|
|
orgDto.setParentId(sysOrg.getParentId());
|
|
|
orgDto.setEnable(sysOrg.getEnable());
|
|
|
+ orgDto.setType(sysOrg.getType());
|
|
|
map.put(sysOrg.getId(), orgDto);
|
|
|
}
|
|
|
|
|
@@ -71,8 +72,10 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
while (iterator.hasNext()) {
|
|
|
Long parentId = iterator.next();
|
|
|
if (map.get(parentId).getParentId() != null) {
|
|
|
- map.get(map.get(parentId).getParentId()).getChildren().add(map.get(parentId));
|
|
|
- deleteKeys.add(parentId);
|
|
|
+ if (Objects.nonNull(map.get(map.get(parentId).getParentId()))) {
|
|
|
+ map.get(map.get(parentId).getParentId()).getChildren().add(map.get(parentId));
|
|
|
+ deleteKeys.add(parentId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
for (Long key : deleteKeys) {
|
|
@@ -129,17 +132,17 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
// 印刷厂不能设置子机构
|
|
|
if (Objects.nonNull(org.getParentId())) {
|
|
|
SysOrg parentOrg = this.getById(org.getParentId());
|
|
|
- if (OrgTypeEnum.COLLEGE.equals(parentOrg.getType())) {
|
|
|
+ if (Objects.nonNull(parentOrg) && OrgTypeEnum.COLLEGE.equals(parentOrg.getType())) {
|
|
|
if (!OrgTypeEnum.FACULTY.equals(org.getType()) && !OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("学院下只能设置院系或者教研室");
|
|
|
}
|
|
|
- } else if (OrgTypeEnum.FACULTY.equals(parentOrg.getType())) {
|
|
|
+ } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.FACULTY.equals(parentOrg.getType())) {
|
|
|
if (!OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("院系下只能设置教研室");
|
|
|
}
|
|
|
- } else if (OrgTypeEnum.TEACHING_ROOM.equals(parentOrg.getType())) {
|
|
|
+ } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.TEACHING_ROOM.equals(parentOrg.getType())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("教研室下不能设置子机构");
|
|
|
- } else if (OrgTypeEnum.PRINTING_HOUSE.equals(parentOrg.getType())) {
|
|
|
+ } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.PRINTING_HOUSE.equals(parentOrg.getType())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("印刷厂不能设置子机构");
|
|
|
}
|
|
|
} else {
|