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 可解析正确各种路径
File dest = new File(path).getCanonicalFile();
// 检测是否存在目录
if (!dest.getParentFile().exists()) {
if (!dest.getParentFile().mkdirs()) {
System.out.println("was not successful.");
}
if (!dest.getParentFile().exists() && !dest.getParentFile().mkdirs()) {
System.out.println("was not successful.");
}
// 文件写入
file.transferTo(dest);

View File

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

View File

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

View File

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