|
|
@@ -2,6 +2,7 @@ package com.zhongshu.card.server.core.service.org;
|
|
|
|
|
|
import com.zhongshu.card.client.model.org.DepartmentModel;
|
|
|
import com.zhongshu.card.client.model.org.DepartmentParam;
|
|
|
+import com.zhongshu.card.client.model.school.AreaModel;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
import com.zhongshu.card.client.service.org.DepartmentService;
|
|
|
@@ -11,6 +12,7 @@ import com.zhongshu.card.client.utils.type.DataState;
|
|
|
import com.zhongshu.card.server.core.dao.org.DepartmentDao;
|
|
|
import com.zhongshu.card.server.core.domain.org.Department;
|
|
|
import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.school.Area;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
@@ -20,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -142,6 +145,29 @@ public class DepartmentServiceImpl extends SuperService implements DepartmentSer
|
|
|
return ResultContent.buildSuccess(iTrees);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 加载当前部门的所有上级部门(包括自己)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<DepartmentModel> getParents(String id) {
|
|
|
+ List<Department> list = new ArrayList<>();
|
|
|
+ loopLoad(id, list);
|
|
|
+ List<DepartmentModel> models = list.stream().map(this::toModel).collect(Collectors.toList());
|
|
|
+ return models;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void loopLoad(String id, List<Department> list) {
|
|
|
+ Department entity = departmentDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ list.add(entity);
|
|
|
+ if (StringUtils.isNotEmpty(entity.getParentId()) && !entity.getParentId().equals(ITree.ROOT_ID)) {
|
|
|
+ loopLoad(entity.getParentId(), list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public DepartmentModel toModel(Department entity) {
|
|
|
DepartmentModel model = new DepartmentModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|