mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-26 04:39:26 +08:00
部门列表api返回部门的学员数量
This commit is contained in:
@@ -21,6 +21,7 @@ import xyz.playedu.api.mapper.DepartmentMapper;
|
||||
import xyz.playedu.api.service.CourseDepartmentService;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
import xyz.playedu.api.types.mapper.DepartmentsUserCountMapRes;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -60,7 +61,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteById(Integer id) throws NotFoundException {
|
||||
public void destroy(Integer id) throws NotFoundException {
|
||||
Department department = findOrFail(id);
|
||||
updateParentChain(department.getParentChain(), childrenParentChain(department));
|
||||
removeById(department.getId());
|
||||
@@ -136,16 +137,6 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
updateBatchById(updateRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> allIds() {
|
||||
List<Department> departments = list(query().getWrapper().eq("1", "1").select("id"));
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
for (Department department : departments) {
|
||||
ids.add(department.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String compParentChain(Integer parentId) throws NotFoundException {
|
||||
String parentChain = "";
|
||||
@@ -257,4 +248,13 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getDepartmentsUserCount() {
|
||||
return getBaseMapper().getDepartmentsUserCount().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
DepartmentsUserCountMapRes::getDepId,
|
||||
DepartmentsUserCountMapRes::getTotal));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user