mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-25 20:35:35 +08:00
部门列表api返回部门的学员数量
This commit is contained in:
@@ -25,13 +25,11 @@ public interface DepartmentService extends IService<Department> {
|
||||
|
||||
Department findOrFail(Integer id) throws NotFoundException;
|
||||
|
||||
void deleteById(Integer id) throws NotFoundException;
|
||||
void destroy(Integer id) throws NotFoundException;
|
||||
|
||||
void update(Department department, String name, Integer parentId, Integer sort)
|
||||
throws NotFoundException;
|
||||
|
||||
List<Integer> allIds();
|
||||
|
||||
String compParentChain(Integer parentId) throws NotFoundException;
|
||||
|
||||
String childrenParentChain(Department department);
|
||||
@@ -53,4 +51,6 @@ public interface DepartmentService extends IService<Department> {
|
||||
Map<Integer, String> id2name();
|
||||
|
||||
Long total();
|
||||
|
||||
Map<Integer, Integer> getDepartmentsUserCount();
|
||||
}
|
||||
|
||||
@@ -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