From dbca691746395d928a6f4ff1f2d8c49df8a53a90 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 12 Feb 2022 14:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/core/utils/ExceptionUtil.java | 3 +-- .../com/ruoyi/common/core/utils/ServletUtils.java | 14 +++-------- .../ruoyi/common/core/utils/file/ImageUtils.java | 2 +- .../com/ruoyi/common/core/utils/poi/ExcelUtil.java | 4 +-- .../com/ruoyi/common/core/utils/sql/SqlUtil.java | 4 +-- .../com/ruoyi/common/security/utils/DictUtils.java | 3 +-- .../java/com/ruoyi/file/utils/FileUploadUtils.java | 8 +++--- .../src/main/java/com/ruoyi/gen/util/GenUtils.java | 8 +++--- .../java/com/ruoyi/gen/util/VelocityUtils.java | 3 +-- .../system/service/impl/SysDeptServiceImpl.java | 3 +-- .../system/service/impl/SysMenuServiceImpl.java | 2 +- .../main/resources/mapper/system/SysMenuMapper.xml | 8 +++--- ruoyi-ui/src/components/FileUpload/index.vue | 2 +- ruoyi-ui/src/utils/generator/drawingDefalut.js | 29 ---------------------- ruoyi-ui/src/utils/generator/drawingDefault.js | 29 ++++++++++++++++++++++ ruoyi-ui/src/utils/generator/html.js | 4 +-- ruoyi-ui/src/utils/generator/js.js | 2 +- ruoyi-ui/src/views/tool/build/CodeTypeDialog.vue | 4 +-- ruoyi-ui/src/views/tool/build/TreeNodeDialog.vue | 4 +-- ruoyi-ui/src/views/tool/build/index.vue | 8 +++--- 20 files changed, 66 insertions(+), 78 deletions(-) delete mode 100644 ruoyi-ui/src/utils/generator/drawingDefalut.js create mode 100644 ruoyi-ui/src/utils/generator/drawingDefault.js diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ExceptionUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ExceptionUtil.java index 718305b..f75e559 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ExceptionUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ExceptionUtil.java @@ -18,8 +18,7 @@ public class ExceptionUtil { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw, true)); - String str = sw.toString(); - return str; + return sw.toString(); } public static String getRootErrorMessage(Exception e) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java index c7bec5d..be2817c 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java @@ -161,9 +161,8 @@ public class ServletUtils * * @param response 渲染对象 * @param string 待渲染的字符串 - * @return null */ - public static String renderString(HttpServletResponse response, String string) + public static void renderString(HttpServletResponse response, String string) { try { @@ -176,7 +175,6 @@ public class ServletUtils { e.printStackTrace(); } - return null; } /** @@ -187,13 +185,13 @@ public class ServletUtils public static boolean isAjaxRequest(HttpServletRequest request) { String accept = request.getHeader("accept"); - if (accept != null && accept.indexOf("application/json") != -1) + if (accept != null && accept.contains("application/json")) { return true; } String xRequestedWith = request.getHeader("X-Requested-With"); - if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) + if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) { return true; } @@ -205,11 +203,7 @@ public class ServletUtils } String ajax = request.getParameter("__ajax"); - if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) - { - return true; - } - return false; + return StringUtils.inStringIgnoreCase(ajax, "json", "xml"); } /** diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/ImageUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/ImageUtils.java index 061c2a7..9f0cfbd 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/ImageUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/ImageUtils.java @@ -55,7 +55,7 @@ public class ImageUtils /** * 读取文件为字节数据 * - * @param key 地址 + * @param url 地址 * @return 字节数据 */ public static byte[] readFile(String url) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java index c5c8d7a..a301425 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java @@ -944,7 +944,7 @@ public class ExcelUtil if (StringUtils.isNotEmpty(excel.targetAttr())) { String target = excel.targetAttr(); - if (target.indexOf(".") > -1) + if (target.contains(".")) { String[] targets = target.split("[.]"); for (String name : targets) @@ -1039,7 +1039,7 @@ public class ExcelUtil for (Object[] os : this.fields) { Excel excel = (Excel) os[1]; - maxHeight = maxHeight > excel.height() ? maxHeight : excel.height(); + maxHeight = Math.max(maxHeight, excel.height()); } return (short) (maxHeight * 20); } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java index 271b58d..7e095d9 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java @@ -50,9 +50,9 @@ public class SqlUtil return; } String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|"); - for (int i = 0; i < sqlKeywords.length; i++) + for (String sqlKeyword : sqlKeywords) { - if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1) + if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) { throw new UtilException("参数存在SQL注入风险"); } diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java index 7620639..9768c6d 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java @@ -37,8 +37,7 @@ public class DictUtils Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); if (StringUtils.isNotNull(cacheObj)) { - List dictDatas = StringUtils.cast(cacheObj); - return dictDatas; + return StringUtils.cast(cacheObj); } return null; } diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java index bf1171a..662b641 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java @@ -2,6 +2,7 @@ package com.ruoyi.file.utils; import java.io.File; import java.io.IOException; +import java.util.Objects; import org.apache.commons.io.FilenameUtils; import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException; @@ -65,7 +66,7 @@ public class FileUploadUtils throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { - int fileNamelength = file.getOriginalFilename().length(); + int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); @@ -77,8 +78,7 @@ public class FileUploadUtils File desc = getAbsoluteFile(baseDir, fileName); file.transferTo(desc); - String pathFileName = getPathFileName(fileName); - return pathFileName; + return getPathFileName(fileName); } /** @@ -186,7 +186,7 @@ public class FileUploadUtils String extension = FilenameUtils.getExtension(file.getOriginalFilename()); if (StringUtils.isEmpty(extension)) { - extension = MimeTypeUtils.getExtension(file.getContentType()); + extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType())); } return extension; } diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java index aa22ddb..ecbb362 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/GenUtils.java @@ -151,8 +151,7 @@ public class GenUtils { int lastIndex = packageName.lastIndexOf("."); int nameLength = packageName.length(); - String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); - return moduleName; + return StringUtils.substring(packageName, lastIndex + 1, nameLength); } /** @@ -165,8 +164,7 @@ public class GenUtils { int lastIndex = tableName.lastIndexOf("_"); int nameLength = tableName.length(); - String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); - return businessName; + return StringUtils.substring(tableName, lastIndex + 1, nameLength); } /** @@ -255,4 +253,4 @@ public class GenUtils return 0; } } -} \ No newline at end of file +} diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java index 1e830f4..125328a 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java @@ -228,8 +228,7 @@ public class VelocityUtils public static String getPackagePrefix(String packageName) { int lastIndex = packageName.lastIndexOf("."); - String basePackage = StringUtils.substring(packageName, 0, lastIndex); - return basePackage; + return StringUtils.substring(packageName, 0, lastIndex); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index d8db7e8..544b6b5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -63,9 +63,8 @@ public class SysDeptServiceImpl implements ISysDeptService { tempList.add(dept.getDeptId()); } - for (Iterator iterator = depts.iterator(); iterator.hasNext();) + for (SysDept dept : depts) { - SysDept dept = (SysDept) iterator.next(); // 如果是顶级节点, 遍历该父节点的所有子节点 if (!tempList.contains(dept.getParentId())) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index d74ff8d..76673e9 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -498,7 +498,7 @@ public class SysMenuServiceImpl implements ISysMenuService */ private boolean hasChild(List list, SysMenu t) { - return getChildList(list, t).size() > 0 ? true : false; + return getChildList(list, t).size() > 0; } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index 144adb1..fd5f6a3 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -28,7 +28,7 @@ - select menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time + select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time from sys_menu @@ -49,13 +49,13 @@