Commit c0cd030d0fde1df50632b05260b8707d57a47896

Authored by RuoYi
1 parent 7604d59e

批量替换表前缀修改

ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java
... ... @@ -166,13 +166,33 @@ public class GenUtils
166 166 if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
167 167 {
168 168 String[] searchList = StringUtils.split(tablePrefix, ",");
169   - String[] replacementList = emptyList(searchList.length);
170   - tableName = StringUtils.replaceEach(tableName, searchList, replacementList);
  169 + tableName = replaceFirst(tableName, searchList);
171 170 }
172 171 return StringUtils.convertToCamelCase(tableName);
173 172 }
174 173  
175 174 /**
  175 + * 批量替换前缀
  176 + *
  177 + * @param replacementm 替换值
  178 + * @param searchList 替换列表
  179 + * @return
  180 + */
  181 + public static String replaceFirst(String replacementm, String[] searchList)
  182 + {
  183 + String text = StringUtils.EMPTY;
  184 + for (String searchString : searchList)
  185 + {
  186 + if (replacementm.startsWith(searchString))
  187 + {
  188 + text = replacementm.replaceFirst(searchString, "");
  189 + break;
  190 + }
  191 + }
  192 + return text;
  193 + }
  194 +
  195 + /**
176 196 * 关键字替换
177 197 *
178 198 * @param name 需要被替换的名字
... ... @@ -219,20 +239,4 @@ public class GenUtils
219 239 return 0;
220 240 }
221 241 }
222   -
223   - /**
224   - * 获取空数组列表
225   - *
226   - * @param length 长度
227   - * @return 数组信息
228   - */
229   - public static String[] emptyList(int length)
230   - {
231   - String[] values = new String[length];
232   - for (int i = 0; i < length; i++)
233   - {
234   - values[i] = StringUtils.EMPTY;
235   - }
236   - return values;
237   - }
238 242 }
239 243 \ No newline at end of file
... ...