mirror of https://github.com/elunez/eladmin
Applied CollapseNestedIfStatements to 4 files
parent
bbf00a7429
commit
5a9d31ad1e
|
@ -198,11 +198,9 @@ 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);
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -144,11 +144,9 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,19 +123,15 @@ 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);
|
||||||
// 计算子节点数目
|
// 计算子节点数目
|
||||||
resources.setSubCount(0);
|
resources.setSubCount(0);
|
||||||
|
@ -151,11 +147,9 @@ 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())) {
|
||||||
throw new EntityExistException(Menu.class, "title", resources.getTitle());
|
throw new EntityExistException(Menu.class, "title", resources.getTitle());
|
||||||
|
|
|
@ -36,11 +36,9 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue