正在显示
1 个修改的文件
包含
22 行增加
和
18 行删除
| @@ -166,13 +166,33 @@ public class GenUtils | @@ -166,13 +166,33 @@ public class GenUtils | ||
| 166 | if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) | 166 | if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) |
| 167 | { | 167 | { |
| 168 | String[] searchList = StringUtils.split(tablePrefix, ","); | 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 | return StringUtils.convertToCamelCase(tableName); | 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 | * @param name 需要被替换的名字 | 198 | * @param name 需要被替换的名字 |
| @@ -219,20 +239,4 @@ public class GenUtils | @@ -219,20 +239,4 @@ public class GenUtils | ||
| 219 | return 0; | 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 | } |
-
请 注册 或 登录 后发表评论