xushengqiang 6 years ago
parent
commit
0b7b73e5bc

+ 2 - 0
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/repository/DepartmentRepository.java

@@ -18,4 +18,6 @@ public interface DepartmentRepository extends BasicRepository<Department> {
     List<Department> findSelect();
 
     Department findByName(String name);
+
+    List<Department> findByPathAndStatusInOrderByCodeAsc(Long cid, List<BaseStatusEnum> status);
 }

+ 2 - 4
efunbox-base/efunbox-base-api/src/main/java/cn/efunbox/manage/base/service/impl/DepartmentServiceImpl.java

@@ -7,8 +7,6 @@ import cn.efunbox.manage.base.service.DepartmentService;
 import cn.efunbox.manage.base.vo.DeptTreeVO;
 import cn.efunbox.manage.common.result.ApiCode;
 import cn.efunbox.manage.common.result.ApiResult;
-import cn.efunbox.manage.common.utils.SnowflakeIdUtil;
-import com.sun.xml.internal.rngom.parse.host.Base;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -119,7 +117,7 @@ public class DepartmentServiceImpl implements DepartmentService {
         DeptTreeVO node = new DeptTreeVO();
         node.setLabel(department.getName());
         node.setId(department.getId());
-        List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderBySortAsc(cid, status);
+        List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderByCodeAsc(cid, status);
         for(Department child : childTreeNodes){
             DeptTreeVO n = recursiveTree(child.getId(), status); //递归
             node.getChildren().add(n);
@@ -128,7 +126,7 @@ public class DepartmentServiceImpl implements DepartmentService {
     }
 
     private List<Department> deptChild(Long cid, List<Department> departments, List<BaseStatusEnum> status) {
-        List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderBySortAsc(cid, status);
+        List<Department> childTreeNodes = departmentRepository.findByPathAndStatusInOrderByCodeAsc(cid, status);
         departments.addAll(childTreeNodes);
         for(Department child : childTreeNodes){
             deptChild(child.getId(), departments, status); //递归