From c0cd030d0fde1df50632b05260b8707d57a47896 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 13 Mar 2020 21:41:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E6=8D=A2=E8=A1=A8?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/project/tool/gen/util/GenUtils.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java index 5904013..48bbe0b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java +++ b/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java @@ -166,12 +166,32 @@ public class GenUtils if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { String[] searchList = StringUtils.split(tablePrefix, ","); - String[] replacementList = emptyList(searchList.length); - tableName = StringUtils.replaceEach(tableName, searchList, replacementList); + tableName = replaceFirst(tableName, searchList); } return StringUtils.convertToCamelCase(tableName); } + /** + * 批量替换前缀 + * + * @param replacementm 替换值 + * @param searchList 替换列表 + * @return + */ + public static String replaceFirst(String replacementm, String[] searchList) + { + String text = StringUtils.EMPTY; + for (String searchString : searchList) + { + if (replacementm.startsWith(searchString)) + { + text = replacementm.replaceFirst(searchString, ""); + break; + } + } + return text; + } + /** * 关键字替换 * @@ -219,20 +239,4 @@ public class GenUtils return 0; } } - - /** - * 获取空数组列表 - * - * @param length 长度 - * @return 数组信息 - */ - public static String[] emptyList(int length) - { - String[] values = new String[length]; - for (int i = 0; i < length; i++) - { - values[i] = StringUtils.EMPTY; - } - return values; - } } \ No newline at end of file