Applied CollapseNestedIfStatements to 4 files

pull/794/head^2
refactoringjanitor[bot] 2023-05-25 18:20:43 +00:00 committed by GitHub
parent bbf00a7429
commit 5a9d31ad1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 24 deletions

View File

@ -198,10 +198,8 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
// getCanonicalFile 可解析正确各种路径 // getCanonicalFile 可解析正确各种路径
File dest = new File(path).getCanonicalFile(); File dest = new File(path).getCanonicalFile();
// 检测是否存在目录 // 检测是否存在目录
if (!dest.getParentFile().exists()) { if (!dest.getParentFile().exists() && !dest.getParentFile().mkdirs()) {
if (!dest.getParentFile().mkdirs()) { System.out.println("was not successful.");
System.out.println("was not successful.");
}
} }
// 文件写入 // 文件写入
file.transferTo(dest); file.transferTo(dest);

View File

@ -144,10 +144,8 @@ public class RoleController {
private int getLevels(Integer level) { private int getLevels(Integer level) {
List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()); List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList());
int min = Collections.min(levels); int min = Collections.min(levels);
if (level != null) { if (level != null && level < min) {
if (level < min) { throw new BadRequestException("权限不足,你的角色级别:" + min + ",低于操作的角色级别:" + level);
throw new BadRequestException("权限不足,你的角色级别:" + min + ",低于操作的角色级别:" + level);
}
} }
return min; return min;
} }

View File

@ -123,18 +123,14 @@ public class MenuServiceImpl implements MenuService {
if (menuRepository.findByTitle(resources.getTitle()) != null) { if (menuRepository.findByTitle(resources.getTitle()) != null) {
throw new EntityExistException(Menu.class, "title", resources.getTitle()); throw new EntityExistException(Menu.class, "title", resources.getTitle());
} }
if (StringUtils.isNotBlank(resources.getComponentName())) { if (StringUtils.isNotBlank(resources.getComponentName()) && menuRepository.findByComponentName(resources.getComponentName()) != null) {
if (menuRepository.findByComponentName(resources.getComponentName()) != null) { throw new EntityExistException(Menu.class, "componentName", resources.getComponentName());
throw new EntityExistException(Menu.class, "componentName", resources.getComponentName());
}
} }
if (Long.valueOf(0L).equals(resources.getPid())) { if (Long.valueOf(0L).equals(resources.getPid())) {
resources.setPid(null); resources.setPid(null);
} }
if (resources.getIFrame()) { if (resources.getIFrame() && !(resources.getPath().toLowerCase().startsWith(HTTP_PRE) || resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) {
if (!(resources.getPath().toLowerCase().startsWith(HTTP_PRE) || resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) { throw new BadRequestException(BAD_REQUEST);
throw new BadRequestException(BAD_REQUEST);
}
} }
menuRepository.save(resources); menuRepository.save(resources);
// 计算子节点数目 // 计算子节点数目
@ -151,10 +147,8 @@ public class MenuServiceImpl implements MenuService {
} }
Menu menu = menuRepository.findById(resources.getId()).orElseGet(Menu::new); Menu menu = menuRepository.findById(resources.getId()).orElseGet(Menu::new);
ValidationUtil.isNull(menu.getId(), "Permission", "id", resources.getId()); ValidationUtil.isNull(menu.getId(), "Permission", "id", resources.getId());
if (resources.getIFrame()) { if (resources.getIFrame() && !(resources.getPath().toLowerCase().startsWith(HTTP_PRE) || resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) {
if (!(resources.getPath().toLowerCase().startsWith(HTTP_PRE) || resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) { throw new BadRequestException(BAD_REQUEST);
throw new BadRequestException(BAD_REQUEST);
}
} }
Menu menu1 = menuRepository.findByTitle(resources.getTitle()); Menu menu1 = menuRepository.findByTitle(resources.getTitle());
if (menu1 != null && !menu1.getId().equals(menu.getId())) { if (menu1 != null && !menu1.getId().equals(menu.getId())) {

View File

@ -36,10 +36,8 @@ public class MultipartConfig {
MultipartConfigFactory factory = new MultipartConfigFactory(); MultipartConfigFactory factory = new MultipartConfigFactory();
String location = System.getProperty("user.home") + "/.eladmin/file/tmp"; String location = System.getProperty("user.home") + "/.eladmin/file/tmp";
File tmpFile = new File(location); File tmpFile = new File(location);
if (!tmpFile.exists()) { if (!tmpFile.exists() && !tmpFile.mkdirs()) {
if (!tmpFile.mkdirs()) { System.out.println("create was not successful.");
System.out.println("create was not successful.");
}
} }
factory.setLocation(location); factory.setLocation(location);
return factory.createMultipartConfig(); return factory.createMultipartConfig();