后台学员列表返回每个部门的学员数量

This commit is contained in:
xxx 2023-09-23 21:11:23 +08:00
parent 11fbf34b65
commit a1d5a9c648

View File

@ -106,7 +106,7 @@ public class UserController {
String createdAt = MapUtils.getString(params, "created_at"); String createdAt = MapUtils.getString(params, "created_at");
String depIdsStr = MapUtils.getString(params, "dep_ids"); String depIdsStr = MapUtils.getString(params, "dep_ids");
List<Integer> depIds = null; List<Integer> depIds = null;
if (depIdsStr != null && depIdsStr.trim().length() > 0) { if (depIdsStr != null && !depIdsStr.trim().isEmpty()) {
if ("0".equals(depIdsStr)) { if ("0".equals(depIdsStr)) {
depIds = new ArrayList<>(); depIds = new ArrayList<>();
} else { } else {
@ -131,7 +131,7 @@ public class UserController {
} }
}; };
if (createdAt != null && createdAt.trim().length() > 0) { if (createdAt != null && !createdAt.trim().isEmpty()) {
filter.setCreatedAt(createdAt.split(",")); filter.setCreatedAt(createdAt.split(","));
} }
@ -145,6 +145,7 @@ public class UserController {
userService.getDepIdsGroup(result.getData().stream().map(User::getId).toList())); userService.getDepIdsGroup(result.getData().stream().map(User::getId).toList()));
data.put("departments", departmentService.id2name()); data.put("departments", departmentService.id2name());
data.put("pure_total", userService.total()); data.put("pure_total", userService.total());
data.put("dep_user_count", departmentService.getDepartmentsUserCount());
return JsonResponse.data(data); return JsonResponse.data(data);
} }
@ -165,7 +166,7 @@ public class UserController {
return JsonResponse.error("邮箱已存在"); return JsonResponse.error("邮箱已存在");
} }
String password = req.getPassword(); String password = req.getPassword();
if (password.length() == 0) { if (password.isEmpty()) {
return JsonResponse.error("请输入密码"); return JsonResponse.error("请输入密码");
} }
userService.createWithDepIds( userService.createWithDepIds(
@ -233,7 +234,7 @@ public class UserController {
@Log(title = "学员-批量导入", businessType = BusinessTypeConstant.INSERT) @Log(title = "学员-批量导入", businessType = BusinessTypeConstant.INSERT)
public JsonResponse batchStore(@RequestBody @Validated UserImportRequest req) { public JsonResponse batchStore(@RequestBody @Validated UserImportRequest req) {
List<UserImportRequest.UserItem> users = req.getUsers(); List<UserImportRequest.UserItem> users = req.getUsers();
if (users.size() == 0) { if (users.isEmpty()) {
return JsonResponse.error("数据为空"); return JsonResponse.error("数据为空");
} }
if (users.size() > 1000) { if (users.size() > 1000) {
@ -257,7 +258,7 @@ public class UserController {
HashMap<String, Integer> depChainNameMap = new HashMap<>(); HashMap<String, Integer> depChainNameMap = new HashMap<>();
for (Department tmpDepItem : departments) { for (Department tmpDepItem : departments) {
// 一级部门 // 一级部门
if (tmpDepItem.getParentChain() == null || tmpDepItem.getParentChain().length() == 0) { if (tmpDepItem.getParentChain() == null || tmpDepItem.getParentChain().isEmpty()) {
depChainNameMap.put(tmpDepItem.getName(), tmpDepItem.getId()); depChainNameMap.put(tmpDepItem.getName(), tmpDepItem.getId());
continue; continue;
} }
@ -286,7 +287,7 @@ public class UserController {
for (UserImportRequest.UserItem userItem : users) { for (UserImportRequest.UserItem userItem : users) {
i++; // 索引值 i++; // 索引值
if (userItem.getEmail() == null || userItem.getEmail().trim().length() == 0) { if (userItem.getEmail() == null || userItem.getEmail().trim().isEmpty()) {
errorLines.add(new String[] {"" + (i + startLine) + "", "未输入邮箱账号"}); errorLines.add(new String[] {"" + (i + startLine) + "", "未输入邮箱账号"});
} else { } else {
// 邮箱重复判断 // 邮箱重复判断
@ -303,7 +304,7 @@ public class UserController {
} }
// 部门数据检测 // 部门数据检测
if (userItem.getDeps() == null || userItem.getDeps().trim().length() == 0) { if (userItem.getDeps() == null || userItem.getDeps().trim().isEmpty()) {
errorLines.add(new String[] {"" + (i + startLine) + "", "未选择部门"}); errorLines.add(new String[] {"" + (i + startLine) + "", "未选择部门"});
} else { } else {
String[] tmpDepList = userItem.getDeps().trim().split("\\|"); String[] tmpDepList = userItem.getDeps().trim().split("\\|");
@ -326,13 +327,13 @@ public class UserController {
// 姓名为空检测 // 姓名为空检测
String tmpName = userItem.getName(); String tmpName = userItem.getName();
if (tmpName == null || tmpName.trim().length() == 0) { if (tmpName == null || tmpName.trim().isEmpty()) {
errorLines.add(new String[] {"" + (i + startLine) + "", "昵称为空"}); errorLines.add(new String[] {"" + (i + startLine) + "", "昵称为空"});
} }
// 密码为空检测 // 密码为空检测
String tmpPassword = userItem.getPassword(); String tmpPassword = userItem.getPassword();
if (tmpPassword == null || tmpPassword.trim().length() == 0) { if (tmpPassword == null || tmpPassword.trim().isEmpty()) {
errorLines.add(new String[] {"" + (i + startLine) + "", "密码为空"}); errorLines.add(new String[] {"" + (i + startLine) + "", "密码为空"});
} }
@ -359,7 +360,7 @@ public class UserController {
// 邮箱是否注册检测 // 邮箱是否注册检测
List<String> existsEmails = userService.existsEmailsByEmails(emails); List<String> existsEmails = userService.existsEmailsByEmails(emails);
if (existsEmails.size() > 0) { if (!existsEmails.isEmpty()) {
for (String tmpEmail : existsEmails) { for (String tmpEmail : existsEmails) {
errorLines.add(new String[] {"" + emailRepeat.get(tmpEmail) + "", "邮箱已注册"}); errorLines.add(new String[] {"" + emailRepeat.get(tmpEmail) + "", "邮箱已注册"});
} }
@ -475,7 +476,7 @@ public class UserController {
HashMap<Integer, List<Course>> depCourses = new HashMap<>(); HashMap<Integer, List<Course>> depCourses = new HashMap<>();
List<Integer> courseIds = new ArrayList<>(); List<Integer> courseIds = new ArrayList<>();
if (depIds != null && depIds.size() > 0) { if (depIds != null && !depIds.isEmpty()) {
departments = departmentService.chunk(depIds); departments = departmentService.chunk(depIds);
depIds.forEach( depIds.forEach(
(depId) -> { (depId) -> {
@ -488,7 +489,7 @@ public class UserController {
}); });
depCourses.put(depId, tmpCourses); depCourses.put(depId, tmpCourses);
if (tmpCourses != null && tmpCourses.size() > 0) { if (tmpCourses != null && !tmpCourses.isEmpty()) {
courseIds.addAll(tmpCourses.stream().map(Course::getId).toList()); courseIds.addAll(tmpCourses.stream().map(Course::getId).toList());
} }
}); });
@ -496,13 +497,13 @@ public class UserController {
// 未关联部门课程 // 未关联部门课程
List<Course> openCourses = courseService.getOpenCoursesAndShow(1000); List<Course> openCourses = courseService.getOpenCoursesAndShow(1000);
if (openCourses != null && openCourses.size() > 0) { if (openCourses != null && !openCourses.isEmpty()) {
courseIds.addAll(openCourses.stream().map(Course::getId).toList()); courseIds.addAll(openCourses.stream().map(Course::getId).toList());
} }
// 读取学员的线上课学习记录 // 读取学员的线上课学习记录
List<UserCourseRecord> userCourseRecords = new ArrayList<>(); List<UserCourseRecord> userCourseRecords = new ArrayList<>();
if (courseIds.size() > 0) { if (!courseIds.isEmpty()) {
userCourseRecords = userCourseRecordService.chunk(id, courseIds); userCourseRecords = userCourseRecordService.chunk(id, courseIds);
} }