提升系统稳定性

This commit is contained in:
none 2023-04-19 11:18:32 +08:00
parent ea80ddc61a
commit de47dd3af7
2 changed files with 23 additions and 28 deletions

View File

@ -52,6 +52,7 @@ import java.util.stream.Collectors;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/2/23 09:48
*/
@RestController
@ -59,32 +60,23 @@ import java.util.stream.Collectors;
@RequestMapping("/backend/v1/user")
public class UserController {
@Autowired
private UserService userService;
@Autowired private UserService userService;
@Autowired
private UserDepartmentService userDepartmentService;
@Autowired private UserDepartmentService userDepartmentService;
@Autowired
private DepartmentService departmentService;
@Autowired private DepartmentService departmentService;
@Autowired
private ApplicationContext context;
@Autowired private ApplicationContext context;
@Autowired
private UserCourseHourRecordService userCourseHourRecordService;
@Autowired private UserCourseHourRecordService userCourseHourRecordService;
@Autowired
private UserCourseRecordService userCourseRecordService;
@Autowired private UserCourseRecordService userCourseRecordService;
@Autowired
private CourseHourService courseHourService;
@Autowired private CourseHourService courseHourService;
@Autowired
private CourseService courseService;
@Autowired private CourseService courseService;
@Autowired
private UserLearnDurationStatsService userLearnDurationStatsService;
@Autowired private UserLearnDurationStatsService userLearnDurationStatsService;
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_INDEX)
@GetMapping("/index")
@ -230,7 +222,7 @@ public class UserController {
String defaultAvatar = BCtx.getConfig().get(CConfig.MEMBER_DEFAULT_AVATAR);
List<String[]> errorLines = new ArrayList<>();
errorLines.add(new String[]{"错误行", "错误信息"}); // 错误表-表头
errorLines.add(new String[] {"错误行", "错误信息"}); // 错误表-表头
// 读取存在的部门
List<Department> departments = departmentService.all();
@ -270,14 +262,14 @@ public class UserController {
i++; // 索引值
if (userItem.getEmail() == null || userItem.getEmail().trim().length() == 0) {
errorLines.add(new String[]{"" + (i + startLine) + "", "未输入邮箱账号"});
errorLines.add(new String[] {"" + (i + startLine) + "", "未输入邮箱账号"});
} else {
// 邮箱重复判断
Integer repeatLine = emailRepeat.get(userItem.getEmail());
if (repeatLine != null) {
errorLines.add(
new String[]{
"" + (i + startLine) + "", "与第" + repeatLine + "行邮箱重复"
new String[] {
"" + (i + startLine) + "", "与第" + repeatLine + "行邮箱重复"
});
} else {
emailRepeat.put(userItem.getEmail(), i + startLine);
@ -287,7 +279,7 @@ public class UserController {
// 部门数据检测
if (userItem.getDeps() == null || userItem.getDeps().trim().length() == 0) {
errorLines.add(new String[]{"" + (i + startLine) + "", "未选择部门"});
errorLines.add(new String[] {"" + (i + startLine) + "", "未选择部门"});
} else {
String[] tmpDepList = userItem.getDeps().trim().split("\\|");
Integer[] tmpDepIds = new Integer[tmpDepList.length];
@ -297,8 +289,8 @@ public class UserController {
// 判断部门id是否存在
if (tmpDepId == null || tmpDepId == 0) {
errorLines.add(
new String[]{
"" + (i + startLine) + "", "部门『" + tmpDepList[j] + "』不存在"
new String[] {
"" + (i + startLine) + "", "部门『" + tmpDepList[j] + "』不存在"
});
continue;
}
@ -310,13 +302,13 @@ public class UserController {
// 姓名为空检测
String tmpName = userItem.getName();
if (tmpName == null || tmpName.trim().length() == 0) {
errorLines.add(new String[]{"" + (i + startLine) + "", "昵称为空"});
errorLines.add(new String[] {"" + (i + startLine) + "", "昵称为空"});
}
// 密码为空检测
String tmpPassword = userItem.getPassword();
if (tmpPassword == null || tmpPassword.trim().length() == 0) {
errorLines.add(new String[]{"" + (i + startLine) + "", "密码为空"});
errorLines.add(new String[] {"" + (i + startLine) + "", "密码为空"});
}
// 待插入数据
@ -344,7 +336,7 @@ public class UserController {
List<String> existsEmails = userService.existsEmailsByEmails(emails);
if (existsEmails.size() > 0) {
for (String tmpEmail : existsEmails) {
errorLines.add(new String[]{"" + emailRepeat.get(tmpEmail) + "", "邮箱已注册"});
errorLines.add(new String[] {"" + emailRepeat.get(tmpEmail) + "", "邮箱已注册"});
}
}
if (errorLines.size() > 1) {

View File

@ -136,6 +136,9 @@ public class CourseHourServiceImpl extends ServiceImpl<CourseHourMapper, CourseH
@Override
public List<CourseHour> chunk(List<Integer> hourIds) {
if (hourIds == null || hourIds.size() == 0) {
return new ArrayList<>();
}
return list(query().getWrapper().in("id", hourIds));
}
}