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
ce1e6c77
Commit
ce1e6c77
authored
Dec 01, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
f27f86a0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
9 deletions
+84
-9
DepartmentModule.cs
Edu.Module.User/DepartmentModule.cs
+74
-6
RB_DepartmentRepository.cs
Edu.Repository/User/RB_DepartmentRepository.cs
+3
-1
UserController.cs
Edu.WebApi/Controllers/User/UserController.cs
+7
-2
No files found.
Edu.Module.User/DepartmentModule.cs
View file @
ce1e6c77
...
@@ -132,15 +132,24 @@ namespace Edu.Module.User
...
@@ -132,15 +132,24 @@ namespace Edu.Module.User
/// 获取部门结构树
/// 获取部门结构树
/// </summary>
/// </summary>
/// <param name="query"></param>
/// <param name="query"></param>
/// <param name="query">是否查询员工</param>
/// <returns></returns>
/// <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
deptList
=
GetDepartmentListModule
(
query
);
var
schoolList
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
query
.
Group_Id
});
var
schoolList
=
schoolRepository
.
GetSchoolListRepository
(
new
RB_School_ViewModel
()
{
Group_Id
=
query
.
Group_Id
});
var
empList
=
new
List
<
Employee_ViewModel
>();
if
(
deptList
==
null
)
if
(
deptList
==
null
)
{
{
deptList
=
new
List
<
RB_Department_ViewModel
>();
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
>();
List
<
DepartmentTree_ViewModel
>
schoolDeptList
=
new
List
<
DepartmentTree_ViewModel
>();
if
(
schoolList
!=
null
)
if
(
schoolList
!=
null
)
...
@@ -149,22 +158,37 @@ namespace Edu.Module.User
...
@@ -149,22 +158,37 @@ namespace Edu.Module.User
{
{
DepartmentTree_ViewModel
tModel
=
new
DepartmentTree_ViewModel
()
DepartmentTree_ViewModel
tModel
=
new
DepartmentTree_ViewModel
()
{
{
DeptId
=
item
.
SId
+
item
.
Group_Id
,
DeptId
=
item
.
SId
,
DeptName
=
item
.
SName
,
DeptName
=
item
.
SName
,
ParentId
=
item
.
Dept_Id
,
ParentId
=
item
.
Dept_Id
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
};
};
#
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
();
var
currentSchoolDeptList
=
deptList
.
Where
(
qitem
=>
qitem
.
School_Id
==
item
.
SId
).
ToList
();
if
(
currentSchoolDeptList
!=
null
&&
currentSchoolDeptList
.
Count
>
0
)
if
(
currentSchoolDeptList
!=
null
&&
currentSchoolDeptList
.
Count
>
0
)
{
{
var
currentSchoolDeptId
=
currentSchoolDeptList
?.
Min
(
qitem
=>
qitem
.
ParentId
)
??
0
;
var
currentSchoolDeptId
=
currentSchoolDeptList
?.
Min
(
qitem
=>
qitem
.
ParentId
)
??
0
;
tModel
.
ChildList
=
GetDeptTreeList
(
currentSchoolDeptId
,
currentSchoolDeptList
,
SchoolId
:
item
.
SId
,
null
);
tModel
.
ChildList
=
GetDeptTreeList
(
currentSchoolDeptId
,
currentSchoolDeptList
,
SchoolId
:
item
.
SId
,
schoolDeptList
:
null
,
empList
:
empList
);
}
}
schoolDeptList
.
Add
(
tModel
);
schoolDeptList
.
Add
(
tModel
);
}
}
}
}
List
<
DepartmentTree_ViewModel
>
list
=
new
List
<
DepartmentTree_ViewModel
>();
if
(
deptList
!=
null
&&
deptList
.
Count
>
0
)
if
(
deptList
!=
null
&&
deptList
.
Count
>
0
)
{
{
var
firstList
=
deptList
.
Where
(
qitem
=>
qitem
.
ParentId
==
0
&&
qitem
.
School_Id
==
0
).
ToList
();
var
firstList
=
deptList
.
Where
(
qitem
=>
qitem
.
ParentId
==
0
&&
qitem
.
School_Id
==
0
).
ToList
();
...
@@ -179,7 +203,28 @@ namespace Edu.Module.User
...
@@ -179,7 +203,28 @@ namespace Edu.Module.User
ParentId
=
fItem
.
ParentId
,
ParentId
=
fItem
.
ParentId
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>()
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
)
if
(
schoolDeptList
!=
null
)
{
{
var
newSchoolDeptList
=
schoolDeptList
.
Where
(
qitem
=>
qitem
.
DeptId
==
fItem
.
DeptId
)?.
ToList
();
var
newSchoolDeptList
=
schoolDeptList
.
Where
(
qitem
=>
qitem
.
DeptId
==
fItem
.
DeptId
)?.
ToList
();
...
@@ -201,7 +246,10 @@ namespace Edu.Module.User
...
@@ -201,7 +246,10 @@ namespace Edu.Module.User
/// </summary>
/// </summary>
/// <param name="parentId">父节点编号</param>
/// <param name="parentId">父节点编号</param>
/// <param name="sourceList">数据源列表</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
>();
List
<
DepartmentTree_ViewModel
>
treeList
=
new
List
<
DepartmentTree_ViewModel
>();
foreach
(
var
item
in
sourceList
.
Where
(
qitem
=>
qitem
.
ParentId
==
parentId
&&
qitem
.
School_Id
==
SchoolId
))
foreach
(
var
item
in
sourceList
.
Where
(
qitem
=>
qitem
.
ParentId
==
parentId
&&
qitem
.
School_Id
==
SchoolId
))
...
@@ -213,6 +261,26 @@ namespace Edu.Module.User
...
@@ -213,6 +261,26 @@ namespace Edu.Module.User
ParentId
=
item
.
ParentId
,
ParentId
=
item
.
ParentId
,
ChildList
=
new
List
<
DepartmentTree_ViewModel
>(),
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
);
model
.
ChildList
=
GetDeptTreeList
(
item
.
DeptId
,
sourceList
,
SchoolId
,
schoolDeptList
);
if
(
schoolDeptList
!=
null
)
if
(
schoolDeptList
!=
null
)
{
{
...
...
Edu.Repository/User/RB_DepartmentRepository.cs
View file @
ce1e6c77
using
Edu.Model.Entity.User
;
using
Edu.Common.Enum
;
using
Edu.Model.Entity.User
;
using
Edu.Model.ViewModel.User
;
using
Edu.Model.ViewModel.User
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data
;
...
@@ -86,6 +87,7 @@ SELECT A.*
...
@@ -86,6 +87,7 @@ SELECT A.*
FROM rb_department AS A
FROM rb_department AS A
WHERE 1=1
WHERE 1=1
"
);
"
);
builder
.
Append
(
$" AND A.
{
nameof
(
RB_Department_ViewModel
.
Status
)}
=
{(
int
)
DateStateEnum
.
Normal
}
"
);
if
(
query
!=
null
)
if
(
query
!=
null
)
{
{
if
(
query
.
Group_Id
>
0
)
if
(
query
.
Group_Id
>
0
)
...
...
Edu.WebApi/Controllers/User/UserController.cs
View file @
ce1e6c77
...
@@ -978,13 +978,18 @@ namespace Edu.WebApi.Controllers.User
...
@@ -978,13 +978,18 @@ namespace Edu.WebApi.Controllers.User
}
}
/// <summary>
/// <summary>
/// 获取
员工通讯录
/// 获取
部门员工树形列表
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
[
HttpPost
]
[
HttpPost
]
public
ApiResult
GetEmployeeAddrBook
()
public
ApiResult
GetEmployeeAddrBook
()
{
{
return
ApiResult
.
Failed
();
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
#
endregion
...
...
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