李昊 4 gadi atpakaļ
vecāks
revīzija
e2ada1026e

+ 4 - 4
GxPress/Repository/GxPress.Repository.Implement/DepartmentRepository.cs

@@ -116,7 +116,7 @@ namespace GxPress.Repository.Implement
         public async Task<IEnumerable<Department>> GetListAsync(DepartmentUserRequest request)
         {
             return await _repository.GetAllAsync(Q.Where(nameof(Department.ParentId), request.DepartmentId)
-                .WhereNot(nameof(Department.Id), request.SourceDepartmentId));
+                .WhereNot(nameof(Department.Id), request.SourceDepartmentId).OrderByDesc(nameof(Department.Sort)));
         }
 
         /// <summary>
@@ -214,7 +214,7 @@ namespace GxPress.Repository.Implement
         /// <returns></returns>
         public async Task<List<DepartmentTreeResult>> GetTreeAsync()
         {
-            var departments = await GetAllAsync(Q.Where(nameof(Department.Id), ">", 0));
+            var departments = await GetAllAsync(Q.Where(nameof(Department.Id), ">", 0).OrderBy(nameof(Department.Sort)));
 
             var departmentParent = departments.Where(n => n.ParentId == 0);
             var list = _mapper.Map<List<DepartmentTreeResult>>(departmentParent);
@@ -285,7 +285,7 @@ namespace GxPress.Repository.Implement
             if (department != null)
             {
                 departments.Add(department);
-                var list = await _repository.GetAllAsync(Q.Where(nameof(Entity.Department.ParentId), department.Id));
+                var list = await _repository.GetAllAsync(Q.Where(nameof(Entity.Department.ParentId), department.Id).OrderBy(nameof(Department.Sort)));
                 foreach (var item in list)
                 {
                     departments.Add(item);
@@ -303,7 +303,7 @@ namespace GxPress.Repository.Implement
         /// <returns></returns>
         public async Task<List<Department>> GetDepartmentByPid(int Pid, List<Department> departments)
         {
-            var departmentList = await _repository.GetAllAsync(Q.Where(nameof(Entity.Department.ParentId), Pid));
+            var departmentList = await _repository.GetAllAsync(Q.Where(nameof(Entity.Department.ParentId), Pid).OrderBy(nameof(Department.Sort)));
             if (departmentList.Count == 0)
                 return departments;
             foreach (var item in departmentList)