sonarqube质量修复

This commit is contained in:
gaoqr
2024-10-09 12:04:54 +08:00
parent 2e96dd8173
commit 220d0ff28a
36 changed files with 242 additions and 513 deletions
@@ -1,6 +1,6 @@
package com.cf.imes.module.infra.api.websocket;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.websocket.core.sender.WebSocketMessageSender;
import com.cf.imes.module.infra.api.websocket.dto.WebSocketSendReqDTO;
@@ -20,7 +20,7 @@ public class WebSocketSenderApiImpl implements WebSocketSenderApi {
@Override
public CommonResult<Boolean> send(WebSocketSendReqDTO message) {
if (StrUtil.isNotEmpty(message.getSessionId())) {
if (CharSequenceUtil.isNotEmpty(message.getSessionId())) {
webSocketMessageSender.send(message.getSessionId(),
message.getMessageType(), message.getMessageContent());
} else if (message.getUserType() != null && message.getUserId() != null) {
@@ -1,7 +1,7 @@
package com.cf.imes.module.infra.controller.admin.file;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.URLUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -68,8 +68,8 @@ public class FileController {
HttpServletResponse response,
@PathVariable("configId") Long configId) throws Exception {
// 获取请求的路径
String path = StrUtil.subAfter(request.getRequestURI(), "/get/", false);
if (StrUtil.isEmpty(path)) {
String path = CharSequenceUtil.subAfter(request.getRequestURI(), "/get/", false);
if (CharSequenceUtil.isEmpty(path)) {
throw new IllegalArgumentException("结尾的 path 路径必须传递");
}
// 解码,解决中文路径的问题 https://gitee.com/zhijiantianya/ruoyi-vue-pro/pulls/807/
@@ -1,6 +1,6 @@
package com.cf.imes.module.infra.convert.redis;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.module.infra.controller.admin.redis.vo.RedisMonitorRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -18,9 +18,9 @@ public interface RedisConvert {
.commandStats(new ArrayList<>(commandStats.size())).build();
commandStats.forEach((key, value) -> {
respVO.getCommandStats().add(RedisMonitorRespVO.CommandStat.builder()
.command(StrUtil.subAfter((String) key, "cmdstat_", false))
.calls(Long.valueOf(StrUtil.subBetween((String) value, "calls=", ",")))
.usec(Long.valueOf(StrUtil.subBetween((String) value, "usec=", ",")))
.command(CharSequenceUtil.subAfter((String) key, "cmdstat_", false))
.calls(Long.valueOf(CharSequenceUtil.subBetween((String) value, "calls=", ",")))
.usec(Long.valueOf(CharSequenceUtil.subBetween((String) value, "usec=", ",")))
.build());
});
return respVO;
@@ -1,7 +1,7 @@
package com.cf.imes.module.infra.service.codegen;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.infra.controller.admin.codegen.vo.CodegenCreateListReqVO;
@@ -110,14 +110,14 @@ public class CodegenServiceImpl implements CodegenService {
if (tableInfo == null) {
throw exception(CODEGEN_IMPORT_TABLE_NULL);
}
if (StrUtil.isEmpty(tableInfo.getComment())) {
if (CharSequenceUtil.isEmpty(tableInfo.getComment())) {
throw exception(CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL);
}
if (CollUtil.isEmpty(tableInfo.getFields())) {
throw exception(CODEGEN_IMPORT_COLUMNS_NULL);
}
tableInfo.getFields().forEach(field -> {
if (StrUtil.isEmpty(field.getComment())) {
if (CharSequenceUtil.isEmpty(field.getComment())) {
throw exception(CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL, field.getName());
}
});
@@ -1,8 +1,8 @@
package com.cf.imes.module.infra.service.codegen.inner;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import com.cf.imes.module.infra.convert.codegen.CodegenConvert;
import com.cf.imes.module.infra.dal.dataobject.codegen.CodegenColumnDO;
@@ -118,7 +118,7 @@ public class CodegenBuilder {
// 驼峰 + 首字母大写;第一步,第一个 _ 前缀的后面,作为 class 名字;第二步,驼峰命名
table.setClassName(upperFirst(toCamelCase(subAfter(tableName, '_', false))));
// 去除结尾的表,作为类描述
table.setClassComment(StrUtil.removeSuffixIgnoreCase(table.getTableComment(), ""));
table.setClassComment(CharSequenceUtil.removeSuffixIgnoreCase(table.getTableComment(), ""));
table.setTemplateType(CodegenTemplateTypeEnum.ONE.getType());
}
@@ -152,7 +152,7 @@ public class CodegenBuilder {
&& !column.getPrimaryKey()); // 对于主键,列表过滤不需要传递
// 处理 listOperationCondition 字段
COLUMN_LIST_OPERATION_CONDITION_MAPPINGS.entrySet().stream()
.filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.filter(entry -> CharSequenceUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.findFirst().ifPresent(entry -> column.setListOperationCondition(entry.getValue().getCondition()));
if (column.getListOperationCondition() == null) {
column.setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition());
@@ -164,7 +164,7 @@ public class CodegenBuilder {
private void processColumnUI(CodegenColumnDO column) {
// 基于后缀进行匹配
COLUMN_HTML_TYPE_MAPPINGS.entrySet().stream()
.filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.filter(entry -> CharSequenceUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.findFirst().ifPresent(entry -> column.setHtmlType(entry.getValue().getType()));
// 如果是 Boolean 类型时,设置为 radio 类型.
if (Boolean.class.getSimpleName().equals(column.getJavaType())) {
@@ -187,32 +187,32 @@ public class CodegenBuilder {
*/
private void processColumnExample(CodegenColumnDO column) {
// id、price、count 等可能是整数的后缀
if (StrUtil.endWithAnyIgnoreCase(column.getJavaField(), "id", "price", "count")) {
if (CharSequenceUtil.endWithAnyIgnoreCase(column.getJavaField(), "id", "price", "count")) {
column.setExample(String.valueOf(randomInt(1, Short.MAX_VALUE)));
return;
}
// name
if (StrUtil.endWithIgnoreCase(column.getJavaField(), "name")) {
if (CharSequenceUtil.endWithIgnoreCase(column.getJavaField(), "name")) {
column.setExample(randomEle(new String[]{"张三", "李四", "王五", "赵六", "晨丰"}));
return;
}
// status
if (StrUtil.endWithAnyIgnoreCase(column.getJavaField(), "status", "type")) {
if (CharSequenceUtil.endWithAnyIgnoreCase(column.getJavaField(), "status", "type")) {
column.setExample(randomEle(new String[]{"1", "2"}));
return;
}
// url
if (StrUtil.endWithIgnoreCase(column.getColumnName(), "url")) {
if (CharSequenceUtil.endWithIgnoreCase(column.getColumnName(), "url")) {
column.setExample("https://www.cf.com");
return;
}
// reason
if (StrUtil.endWithIgnoreCase(column.getColumnName(), "reason")) {
if (CharSequenceUtil.endWithIgnoreCase(column.getColumnName(), "reason")) {
column.setExample(randomEle(new String[]{"不喜欢", "不对", "不好", "不香"}));
return;
}
// description、memo、remark
if (StrUtil.endWithAnyIgnoreCase(column.getColumnName(), "description", "memo", "remark")) {
if (CharSequenceUtil.endWithAnyIgnoreCase(column.getColumnName(), "description", "memo", "remark")) {
column.setExample(randomEle(new String[]{"你猜", "随便", "你说的对"}));
return;
}
@@ -2,12 +2,11 @@ package com.cf.imes.module.infra.service.codegen.inner;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.TemplateEngine;
import cn.hutool.extra.template.engine.velocity.VelocityEngine;
import cn.hutool.system.SystemUtil;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageParam;
@@ -57,6 +56,16 @@ import static cn.hutool.core.text.CharSequenceUtil.*;
@Component
public class CodegenEngine {
private static final String INDEX_VUE = "views/index.vue";
private static final String MODULE_INDEX_VUE = "views/${table.moduleName}/${table.businessName}/index.vue";
private static final String FORM_VUE = "views/form.vue";
private static final String MODULE_FORM_VUE = "views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue";
private static final String MODULE_COMPONENTS_FORM_VUE = "views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue";
private static final String MODULE_COMPONENTS_LIST_VUE = "views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue";
private static final String API_TS = "api/api.ts";
private static final String API_INDEX_TS = "api/${table.moduleName}/${table.businessName}/index.ts";
private static final String SUB_INDEX = "subIndex";
/**
* 后端的模板配置
*
@@ -102,57 +111,57 @@ public class CodegenEngine {
*/
private static final Table<Integer, String, String> FRONT_TEMPLATES = ImmutableTable.<Integer, String, String>builder()
// Vue2 标准模版
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/index.vue"),
vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath(INDEX_VUE),
vueFilePath(MODULE_INDEX_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"),
vueFilePath("api/${table.moduleName}/${table.businessName}/index.js"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/form.vue"),
vueFilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath(FORM_VUE),
vueFilePath(MODULE_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vueFilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vueFilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vueFilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
vueFilePath(MODULE_COMPONENTS_LIST_VUE))
.put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑
vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
vueFilePath(MODULE_COMPONENTS_LIST_VUE))
// Vue3 标准模版
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath(INDEX_VUE),
vue3FilePath(MODULE_INDEX_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath(FORM_VUE),
vue3FilePath(MODULE_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vue3FilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vue3FilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
vue3FilePath(MODULE_COMPONENTS_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
vue3FilePath(MODULE_COMPONENTS_LIST_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
vue3FilePath(MODULE_COMPONENTS_LIST_VUE))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath(API_TS),
vue3FilePath(API_INDEX_TS))
// Vue3 Schema 模版
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/form.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath(INDEX_VUE),
vue3FilePath(MODULE_INDEX_VUE))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath(FORM_VUE),
vue3FilePath(MODULE_FORM_VUE))
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath(API_TS),
vue3FilePath(API_INDEX_TS))
// Vue3 vben 模版
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/form.vue"),
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath(INDEX_VUE),
vue3FilePath(MODULE_INDEX_VUE))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath(FORM_VUE),
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Modal.vue"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
.put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath(API_TS),
vue3FilePath(API_INDEX_TS))
.build();
@Resource
@@ -290,10 +299,10 @@ public class CodegenEngine {
// 逐个生成
for (int i = 0; i < subTables.size(); i++) {
bindingMap.put("subIndex", i);
bindingMap.put(SUB_INDEX, i);
generateCode(result, vmPath, filePath, bindingMap);
}
bindingMap.remove("subIndex");
bindingMap.remove(SUB_INDEX);
}
/**
@@ -307,26 +316,26 @@ public class CodegenEngine {
*/
private String prettyCode(String content) {
// Vue 界面:去除字段后面多余的 , 逗号,解决前端的 Pretty 代码格式检查的报错
content = content.replaceAll(",\n}", "\n}").replaceAll(",\n }", "\n }");
content = content.replace(",\n}", "\n}").replace(",\n }", "\n }");
// Vue 界面:去除多的 dateFormatter,只有一个的情况下,说明没使用到
if (StrUtil.count(content, "dateFormatter") == 1) {
if (CharSequenceUtil.count(content, "dateFormatter") == 1) {
content = StrUtils.removeLineContains(content, "dateFormatter");
}
// Vue2 界面:修正 $refs
if (StrUtil.count(content, "this.refs") >= 1) {
if (CharSequenceUtil.count(content, "this.refs") >= 1) {
content = content.replace("this.refs", "this.$refs");
}
// Vue 界面:去除多的 dict 相关,只有一个的情况下,说明没使用到
if (StrUtil.count(content, "getIntDictOptions") == 1) {
if (CharSequenceUtil.count(content, "getIntDictOptions") == 1) {
content = content.replace("getIntDictOptions, ", "");
}
if (StrUtil.count(content, "getStrDictOptions") == 1) {
if (CharSequenceUtil.count(content, "getStrDictOptions") == 1) {
content = content.replace("getStrDictOptions, ", "");
}
if (StrUtil.count(content, "getBoolDictOptions") == 1) {
if (CharSequenceUtil.count(content, "getBoolDictOptions") == 1) {
content = content.replace("getBoolDictOptions, ", "");
}
if (StrUtil.count(content, "DICT_TYPE.") == 0) {
if (CharSequenceUtil.count(content, "DICT_TYPE.") == 0) {
content = StrUtils.removeLineContains(content, "DICT_TYPE");
}
return content;
@@ -412,29 +421,29 @@ public class CodegenEngine {
@SuppressWarnings("unchecked")
private String formatFilePath(String filePath, Map<String, Object> bindingMap) {
filePath = StrUtil.replace(filePath, "${basePackage}",
getStr(bindingMap, "basePackage").replaceAll("\\.", "/"));
filePath = StrUtil.replace(filePath, "${classNameVar}",
filePath = CharSequenceUtil.replace(filePath, "${basePackage}",
getStr(bindingMap, "basePackage").replace("\\.", "/"));
filePath = CharSequenceUtil.replace(filePath, "${classNameVar}",
getStr(bindingMap, "classNameVar"));
filePath = StrUtil.replace(filePath, "${simpleClassName}",
filePath = CharSequenceUtil.replace(filePath, "${simpleClassName}",
getStr(bindingMap, "simpleClassName"));
// sceneEnum 包含的字段
CodegenSceneEnum sceneEnum = (CodegenSceneEnum) bindingMap.get("sceneEnum");
filePath = StrUtil.replace(filePath, "${sceneEnum.prefixClass}", sceneEnum.getPrefixClass());
filePath = StrUtil.replace(filePath, "${sceneEnum.basePackage}", sceneEnum.getBasePackage());
filePath = CharSequenceUtil.replace(filePath, "${sceneEnum.prefixClass}", sceneEnum.getPrefixClass());
filePath = CharSequenceUtil.replace(filePath, "${sceneEnum.basePackage}", sceneEnum.getBasePackage());
// table 包含的字段
CodegenTableDO table = (CodegenTableDO) bindingMap.get("table");
filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName());
filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName());
filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName());
filePath = CharSequenceUtil.replace(filePath, "${table.moduleName}", table.getModuleName());
filePath = CharSequenceUtil.replace(filePath, "${table.businessName}", table.getBusinessName());
filePath = CharSequenceUtil.replace(filePath, "${table.className}", table.getClassName());
// 特殊:主子表专属逻辑
Integer subIndex = (Integer) bindingMap.get("subIndex");
Integer subIndex = (Integer) bindingMap.get(SUB_INDEX);
if (subIndex != null) {
CodegenTableDO subTable = ((List<CodegenTableDO>) bindingMap.get("subTables")).get(subIndex);
filePath = StrUtil.replace(filePath, "${subTable.moduleName}", subTable.getModuleName());
filePath = StrUtil.replace(filePath, "${subTable.businessName}", subTable.getBusinessName());
filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
filePath = StrUtil.replace(filePath, "${subSimpleClassName}",
filePath = CharSequenceUtil.replace(filePath, "${subTable.moduleName}", subTable.getModuleName());
filePath = CharSequenceUtil.replace(filePath, "${subTable.businessName}", subTable.getBusinessName());
filePath = CharSequenceUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
filePath = CharSequenceUtil.replace(filePath, "${subSimpleClassName}",
((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex));
}
return filePath;
@@ -1,41 +0,0 @@
package com.cf.imes.module.infra.service;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.generator.query.DefaultQuery;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class DefaultDatabaseQueryTest {
public static void main(String[] args) {
// DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:oracle:thin:@127.0.0.1:1521:xe",
// "root", "123456").build();
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder("jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro",
"root", "123456").build();
// StrategyConfig strategyConfig = new StrategyConfig.Builder().build();
ConfigBuilder builder = new ConfigBuilder(null, dataSourceConfig, null, null, null, null);
DefaultQuery query = new DefaultQuery(builder);
long time = System.currentTimeMillis();
List<TableInfo> tableInfos = query.queryTables();
assertNotEquals(0, tableInfos.size());
for (TableInfo tableInfo : tableInfos) {
if (StrUtil.startWithAny(tableInfo.getName().toLowerCase(), "act_", "flw_", "qrtz_")) {
continue;
}
System.out.println(String.format("CREATE SEQUENCE %s_seq MINVALUE 1;", tableInfo.getName()));
// System.out.println(String.format("DELETE FROM %s WHERE deleted = '1';", tableInfo.getName()));
}
System.out.println(tableInfos.size());
System.out.println(System.currentTimeMillis() - time);
}
}