Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
176f2807
Commit
176f2807
authored
Dec 01, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/education
parents
686af568
ce1e6c77
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
11 deletions
+97
-11
DepartmentModule.cs
Edu.Module.User/DepartmentModule.cs
+79
-10
RB_DepartmentRepository.cs
Edu.Repository/User/RB_DepartmentRepository.cs
+3
-1
UserController.cs
Edu.WebApi/Controllers/User/UserController.cs
+15
-0
No files found.
Edu.Module.User/DepartmentModule.cs
View file @
176f2807
...
...
@@ -132,16 +132,24 @@ namespace Edu.Module.User
/// 获取部门结构树
/// </summary>
/// <param name="query"></param>
/// <param name="query">是否查询员工</param>
/// <returns></returns>
public
List
<
DepartmentTree_ViewModel
>
GetDepartmentTreeModule
(
RB_Department_ViewModel
query
)
public
List
<
DepartmentTree_ViewModel
>
GetDepartmentTreeModule
(
RB_Department_ViewModel
query
,
bool
isQueryEmployee
=
false
)
{
//树形结构列表
List
<
DepartmentTree_ViewModel
>
list
=
new
List
<
DepartmentTree_ViewModel
>();
//所有的部门列表
var
deptList
=
GetDepartmentListModule
(
query
);
var
schoolList
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
query
.
Group_Id
});
var
empList
=
new
List
<
Employee_ViewModel
>();
if
(
deptList
==
null
)
{
deptList
=
new
List
<
RB_Department_ViewModel
>();
}
if
(
isQueryEmployee
)
{
empList
=
accountRepository
.
GetEmployeeListRepository
(
new
Employee_ViewModel
()
{
Group_Id
=
query
.
Group_Id
});
}
//校区部门
List
<
DepartmentTree_ViewModel
>
schoolDeptList
=
new
List
<
DepartmentTree_ViewModel
>();
if
(
schoolList
!=
null
)
...
...
@@ -150,17 +158,37 @@ namespace Edu.Module.User
{
DepartmentTree_ViewModel
tModel
=
new
DepartmentTree_ViewModel
()
{
DeptId
=
item
.
SId
+
item
.
Group_Id
,
DeptId
=
item
.
SId
,
DeptName
=
item
.
SName
,
ParentId
=
item
.
Dept_Id
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
};
tModel
.
ChildList
=
GetDeptTreeList
(
0
,
deptList
.
Where
(
qitem
=>
qitem
.
School_Id
>
0
).
ToList
(),
SchoolId
:
item
.
SId
,
null
);
#
region
添加员工信息
if
(
isQueryEmployee
&&
item
.
ManagerId
>
0
)
{
var
empModel
=
empList
?.
Where
(
qitem
=>
qitem
.
Id
==
item
.
ManagerId
)?.
FirstOrDefault
();
if
(
empModel
!=
null
&&
!
string
.
IsNullOrEmpty
(
empModel
.
EmployeeName
))
{
tModel
.
ChildList
.
Add
(
new
DepartmentTree_ViewModel
()
{
DeptId
=
0
,
DeptName
=
empModel
.
EmployeeName
,
ParentId
=
0
});
}
}
#
endregion
var
currentSchoolDeptList
=
deptList
.
Where
(
qitem
=>
qitem
.
School_Id
==
item
.
SId
).
ToList
();
if
(
currentSchoolDeptList
!=
null
&&
currentSchoolDeptList
.
Count
>
0
)
{
var
currentSchoolDeptId
=
currentSchoolDeptList
?.
Min
(
qitem
=>
qitem
.
ParentId
)
??
0
;
tModel
.
ChildList
=
GetDeptTreeList
(
currentSchoolDeptId
,
currentSchoolDeptList
,
SchoolId
:
item
.
SId
,
schoolDeptList
:
null
,
empList
:
empList
);
}
schoolDeptList
.
Add
(
tModel
);
}
}
List
<
DepartmentTree_ViewModel
>
list
=
new
List
<
DepartmentTree_ViewModel
>();
if
(
deptList
!=
null
&&
deptList
.
Count
>
0
)
{
var
firstList
=
deptList
.
Where
(
qitem
=>
qitem
.
ParentId
==
0
&&
qitem
.
School_Id
==
0
).
ToList
();
...
...
@@ -175,7 +203,28 @@ namespace Edu.Module.User
ParentId
=
fItem
.
ParentId
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
};
tModel
.
ChildList
=
GetDeptTreeList
(
fItem
.
DeptId
,
deptList
.
Where
(
qitem
=>
qitem
.
School_Id
==
0
).
ToList
(),
SchoolId
:
0
,
schoolDeptList
);
#
region
添加员工信息
if
(
isQueryEmployee
)
{
var
tempEmpList
=
empList
?.
Where
(
qitem
=>
qitem
.
Dept_Id
==
fItem
.
DeptId
)?.
ToList
();
if
(
tempEmpList
!=
null
&&
tempEmpList
.
Count
>
0
)
{
foreach
(
var
eItem
in
tempEmpList
)
{
tModel
.
ChildList
.
Add
(
new
DepartmentTree_ViewModel
()
{
DeptId
=
0
,
DeptName
=
eItem
.
EmployeeName
,
ParentId
=
0
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
});
}
}
}
#
endregion
tModel
.
ChildList
=
GetDeptTreeList
(
fItem
.
DeptId
,
deptList
.
Where
(
qitem
=>
qitem
.
School_Id
==
0
).
ToList
(),
SchoolId
:
0
,
schoolDeptList
:
schoolDeptList
,
empList
:
empList
);
if
(
schoolDeptList
!=
null
)
{
var
newSchoolDeptList
=
schoolDeptList
.
Where
(
qitem
=>
qitem
.
DeptId
==
fItem
.
DeptId
)?.
ToList
();
...
...
@@ -192,17 +241,17 @@ namespace Edu.Module.User
}
/// <summary>
/// 递归生成树形结构
/// </summary>
/// <param name="parentId">父节点编号</param>
/// <param name="sourceList">数据源列表</param>
private
List
<
DepartmentTree_ViewModel
>
GetDeptTreeList
(
int
parentId
,
List
<
RB_Department_ViewModel
>
sourceList
,
int
SchoolId
=
0
,
List
<
DepartmentTree_ViewModel
>
schoolDeptList
=
null
)
/// <param name="SchoolId">学校编号</param>
/// <param name="schoolDeptList">学校部门列表</param>
/// <param name="empList">员工列表</param>
private
List
<
DepartmentTree_ViewModel
>
GetDeptTreeList
(
int
parentId
,
List
<
RB_Department_ViewModel
>
sourceList
,
int
SchoolId
=
0
,
List
<
DepartmentTree_ViewModel
>
schoolDeptList
=
null
,
List
<
Employee_ViewModel
>
empList
=
null
)
{
List
<
DepartmentTree_ViewModel
>
treeList
=
new
List
<
DepartmentTree_ViewModel
>();
foreach
(
var
item
in
sourceList
.
Where
(
qitem
=>
qitem
.
ParentId
==
parentId
&&
qitem
.
School_Id
==
SchoolId
))
{
DepartmentTree_ViewModel
model
=
new
DepartmentTree_ViewModel
()
...
...
@@ -212,6 +261,26 @@ namespace Edu.Module.User
ParentId
=
item
.
ParentId
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>(),
};
#
region
添加员工信息
if
(
empList
!=
null
&&
empList
.
Count
>
0
)
{
var
tempEmpList
=
empList
?.
Where
(
qitem
=>
qitem
.
Dept_Id
==
item
.
DeptId
)?.
ToList
();
if
(
tempEmpList
!=
null
&&
tempEmpList
.
Count
>
0
)
{
foreach
(
var
eItem
in
tempEmpList
)
{
model
.
ChildList
.
Add
(
new
DepartmentTree_ViewModel
()
{
DeptId
=
0
,
DeptName
=
eItem
.
EmployeeName
,
ParentId
=
0
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
});
}
}
}
#
endregion
model
.
ChildList
=
GetDeptTreeList
(
item
.
DeptId
,
sourceList
,
SchoolId
,
schoolDeptList
);
if
(
schoolDeptList
!=
null
)
{
...
...
Edu.Repository/User/RB_DepartmentRepository.cs
View file @
176f2807
using
Edu.Model.Entity.User
;
using
Edu.Common.Enum
;
using
Edu.Model.Entity.User
;
using
Edu.Model.ViewModel.User
;
using
System.Collections.Generic
;
using
System.Data
;
...
...
@@ -86,6 +87,7 @@ SELECT A.*
FROM rb_department AS A
WHERE 1=1
"
);
builder
.
Append
(
$" AND A.
{
nameof
(
RB_Department_ViewModel
.
Status
)}
=
{(
int
)
DateStateEnum
.
Normal
}
"
);
if
(
query
!=
null
)
{
if
(
query
.
Group_Id
>
0
)
...
...
Edu.WebApi/Controllers/User/UserController.cs
View file @
176f2807
...
...
@@ -976,6 +976,21 @@ namespace Edu.WebApi.Controllers.User
qitem
.
PostName
}));
}
/// <summary>
/// 获取部门员工树形列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetEmployeeAddrBook
()
{
var
query
=
new
RB_Department_ViewModel
()
{
Group_Id
=
base
.
ParmJObj
.
GetInt
(
"Group_Id"
),
};
var
list
=
departmentModule
.
GetDepartmentTreeModule
(
query
,
isQueryEmployee
:
true
);
return
ApiResult
.
Success
(
data
:
list
);
}
#
endregion
#
region
枚举相列表
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment