Browse Source

执法端-计划

dev-V1.0.1
庄锐波 5 months ago
parent
commit
23c6db69c5
  1. 31
      zdxt-modules/zdxt-generator/src/main/java/org/dromara/generator/service/GenTableServiceImpl.java

31
zdxt-modules/zdxt-generator/src/main/java/org/dromara/generator/service/GenTableServiceImpl.java

@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.anyline.metadata.Column;
import org.anyline.metadata.Table;
import org.anyline.metadata.View;
import org.anyline.proxy.ServiceProxy;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@ -123,7 +124,16 @@ public class GenTableServiceImpl implements IGenTableService {
String tableComment = genTable.getTableComment();
LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables();
if (CollUtil.isEmpty(tablesMap)) {
LinkedHashMap<String, View> viewsMap = ServiceProxy.metadata().views();
// 合并表与视图,统一展示
LinkedHashMap<String, Table<?>> allMap = new LinkedHashMap<>();
if (CollUtil.isNotEmpty(tablesMap)) {
allMap.putAll(tablesMap);
}
if (CollUtil.isNotEmpty(viewsMap)) {
allMap.putAll(viewsMap);
}
if (CollUtil.isEmpty(allMap)) {
return TableDataInfo.build();
}
List<String> tableNames = baseMapper.selectTableNameList(genTable.getDataName());
@ -134,7 +144,7 @@ public class GenTableServiceImpl implements IGenTableService {
tableArrays = new String[0];
}
// 过滤并转换表格数据
List<GenTable> tables = tablesMap.values().stream()
List<GenTable> tables = allMap.values().stream()
.filter(x -> !StringUtils.startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
.filter(x -> {
if (CollUtil.isEmpty(tableNames)) {
@ -181,12 +191,21 @@ public class GenTableServiceImpl implements IGenTableService {
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName) {
Set<String> tableNameSet = new HashSet<>(List.of(tableNames));
LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables();
LinkedHashMap<String, View> viewsMap = ServiceProxy.metadata().views();
// 合并表与视图,统一处理
LinkedHashMap<String, Table<?>> allMap = new LinkedHashMap<>();
if (CollUtil.isNotEmpty(tablesMap)) {
allMap.putAll(tablesMap);
}
if (CollUtil.isNotEmpty(viewsMap)) {
allMap.putAll(viewsMap);
}
if (CollUtil.isEmpty(tablesMap)) {
if (CollUtil.isEmpty(allMap)) {
return new ArrayList<>();
}
List<Table<?>> tableList = tablesMap.values().stream()
List<Table<?>> tableList = allMap.values().stream()
.filter(x -> !StringUtils.startWithAnyIgnoreCase(x.getName(), TABLE_IGNORE))
.filter(x -> tableNameSet.contains(x.getName())).toList();
@ -289,6 +308,10 @@ public class GenTableServiceImpl implements IGenTableService {
@Override
public List<GenTableColumn> selectDbTableColumnsByName(String tableName, String dataName) {
Table<?> table = ServiceProxy.metadata().table(tableName);
// 表查询为空时,回退尝试视图查询
if (ObjectUtil.isNull(table)) {
table = ServiceProxy.metadata().view(tableName);
}
if (ObjectUtil.isNull(table)) {
return new ArrayList<>();
}

Loading…
Cancel
Save