From 19aeea2ee37579081d93ad8e01c1e2f44af89b90 Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Tue, 20 May 2025 23:04:37 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-backend/.env | 3 + core/core-backend/pom.xml | 14 + .../system/controller/RoleController.java | 2 +- .../system/service/IUserService.java | 2 +- .../system/service/impl/UserServiceImpl.java | 2 +- .../dataset/manage/DatasetDataManage.java | 340 +++++++++++++++++- .../dataset/server/DatasetDataServer.java | 49 +++ 7 files changed, 408 insertions(+), 4 deletions(-) create mode 100644 core/core-backend/.env diff --git a/core/core-backend/.env b/core/core-backend/.env new file mode 100644 index 0000000..bacc852 --- /dev/null +++ b/core/core-backend/.env @@ -0,0 +1,3 @@ +{ + "JAVA_HOME": "C:\\Users\\13910\\.jdks\\corretto-21.0.5" +} \ No newline at end of file diff --git a/core/core-backend/pom.xml b/core/core-backend/pom.xml index b03f6cf..e1ce6ac 100644 --- a/core/core-backend/pom.xml +++ b/core/core-backend/pom.xml @@ -93,6 +93,11 @@ org.apache.commons commons-lang3 + + cn.hutool + hutool-all + 5.8.38 + io.gisbi api-permissions @@ -184,6 +189,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 21 + 21 + + diff --git a/core/core-backend/src/main/java/io/gisbi/application/system/controller/RoleController.java b/core/core-backend/src/main/java/io/gisbi/application/system/controller/RoleController.java index 7dd504a..2dd6497 100644 --- a/core/core-backend/src/main/java/io/gisbi/application/system/controller/RoleController.java +++ b/core/core-backend/src/main/java/io/gisbi/application/system/controller/RoleController.java @@ -201,7 +201,7 @@ public class RoleController { boolean isOk = true; String[] temp = userids.split(","); for (String userid : temp) { - isOk = isOk && userService.addUserRoles(roleid, userid); + isOk = isOk && userService.addUserRole(roleid, userid); } if (isOk) { return ResponseResult.success(); diff --git a/core/core-backend/src/main/java/io/gisbi/application/system/service/IUserService.java b/core/core-backend/src/main/java/io/gisbi/application/system/service/IUserService.java index b3e86e4..f18c867 100644 --- a/core/core-backend/src/main/java/io/gisbi/application/system/service/IUserService.java +++ b/core/core-backend/src/main/java/io/gisbi/application/system/service/IUserService.java @@ -86,5 +86,5 @@ public interface IUserService extends IService { * userids 用户id组 * 返回值说明: 是否新增成功 ***********************************/ - boolean addUserRoles(String roleid, String userid); + boolean addUserRole(String roleid, String userid); } diff --git a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/UserServiceImpl.java b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/UserServiceImpl.java index 76a7356..6e2af5f 100644 --- a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/UserServiceImpl.java +++ b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/UserServiceImpl.java @@ -313,7 +313,7 @@ public class UserServiceImpl extends ServiceImpl implements IU * 返回值说明: 是否新增成功 ***********************************/ @Override - public boolean addUserRoles(String roleid, String userid) { + public boolean addUserRole(String roleid, String userid) { boolean isOk = true; if (StringUtils.isEmpty(roleid) || StringUtils.isEmpty(userid)) { return false; diff --git a/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java b/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java index fc6bed6..3b3891b 100644 --- a/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java +++ b/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java @@ -1,5 +1,7 @@ package io.gisbi.dataset.manage; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.gisbi.api.chart.dto.DeSortField; import io.gisbi.api.dataset.dto.*; import io.gisbi.api.dataset.union.DatasetGroupInfoDTO; @@ -7,6 +9,10 @@ import io.gisbi.api.dataset.union.DatasetTableInfoDTO; import io.gisbi.chart.utils.ChartDataBuild; import io.gisbi.commons.utils.SqlparserUtils; import io.gisbi.dataset.constant.DatasetTableType; +import io.gisbi.dataset.dao.auto.entity.CoreDatasetTable; +import io.gisbi.dataset.dao.auto.entity.CoreDatasetTableField; +import io.gisbi.dataset.dao.auto.mapper.CoreDatasetTableFieldMapper; +import io.gisbi.dataset.dao.auto.mapper.CoreDatasetTableMapper; import io.gisbi.dataset.utils.DatasetUtils; import io.gisbi.dataset.utils.FieldUtils; import io.gisbi.dataset.utils.TableUtils; @@ -71,7 +77,10 @@ public class DatasetDataManage { private DatasetTableSqlLogManage datasetTableSqlLogManage; @Autowired(required = false) private PluginManageApi pluginManage; - + @Resource + private CoreDatasetTableFieldMapper coreDatasetTableFieldMapper; + @Resource + private CoreDatasetTableMapper coreDatasetTableMapper; @Resource private DataSourceManage dataSourceManage; @@ -1139,4 +1148,333 @@ public class DatasetDataManage { return nodes; } +//-----------------------下面代码为扩展代码,实现了数据表的增删改查功能--zhengsl at 2025-05-20----------------------------------------------------------------------------------------// + public List getTablesByAppId(Long id) throws Exception { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("app_id", id); + wrapper.eq("type", "db"); + List tables = coreDatasetTableMapper.selectList(wrapper); + return tables; + } + + public List getFieldsByTableId(Long id) throws Exception { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("dataset_table_id", id); + wrapper.eq("checked", true); + wrapper.isNull("chart_id"); + List fields = coreDatasetTableFieldMapper.selectList(wrapper); + return fields; + } + + public boolean addTableData(Long datasourceId, String tableData) throws Exception { + // 根据数据源 id 查询数据源信息,调用通用数据源执行器 + CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId); + if (coreDatasource == null) { + DEException.throwException("数据源不存在"); + } + + // 解析 tableData JSON 字符串 "{ \"tableName\": \"user\", \"data\": [ { \"fieldName\": \"id\", \"fieldType\": \"varchar\", \"IsPrimaryKey\": true, \"fieldValue\": \"0001\" }, { \"fieldName\": \"name\", \"fieldType\": \"varchar\", \"fieldValue\": \"张三\" } ] }"; + Map dataMap = JsonUtil.parseObject(tableData, Map.class); + String tableName = (String) dataMap.get("tableName"); + List> fieldList = (List>) dataMap.get("data"); + + if (fieldList == null || fieldList.isEmpty()) { + DEException.throwException("没有可插入的数据字段"); + } + + // 构建插入语句 + StringBuilder columns = new StringBuilder(); + StringBuilder values = new StringBuilder(); + + for (int i = 0; i < fieldList.size(); i++) { + Map field = fieldList.get(i); + String fieldName = (String) field.get("fieldName"); + Object fieldValue = field.get("fieldValue"); + + if (i > 0) { + columns.append(", "); + values.append(", "); + } + columns.append(fieldName); + if (fieldValue instanceof String) { + values.append("'").append(fieldValue).append("'"); + } else { + values.append(fieldValue); + } + } + + String sql = String.format("INSERT INTO %s (%s) VALUES (%s)", tableName, columns.toString(), values.toString()); + + // 调用执行器,向数据表中插入 tableData 数据 + DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); + BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource); + + Provider provider = ProviderFactory.getProvider(coreDatasource.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setQuery(sql); + datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO)); + + logger.debug("执行插入数据的SQL: {}", sql); + + // 执行插入操作 + Map result = provider.fetchResultField(datasourceRequest); + return result != null && !result.isEmpty(); +} + + public boolean updateTableData(Long datasourceId, String tableData) throws Exception { + // 获取数据源信息 + CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId); + if (coreDatasource == null) { + DEException.throwException("数据源不存在"); + } + //String tableDataJson = "{ \"tableName\": \"user\", \"primaryKeyField\": \"id\", \"primaryKeyValue\": \"0001\", \"data\": [ { \"fieldName\": \"name\", \"fieldType\": \"varchar\", \"fieldValue\": \"李四\" } ] }"; + // 解析 JSON 数据 + Map dataMap = JsonUtil.parseObject(tableData, Map.class); + String tableName = (String) dataMap.get("tableName"); + String primaryKeyField = (String) dataMap.get("primaryKeyField"); + Object primaryKeyValue = dataMap.get("primaryKeyValue"); + List> fieldList = (List>) dataMap.get("data"); + + if (fieldList == null || fieldList.isEmpty()) { + DEException.throwException("没有可更新的数据字段"); + } + if (StringUtils.isBlank(tableName)) { + DEException.throwException("表名不能为空"); + } + if (StringUtils.isBlank(primaryKeyField) || primaryKeyValue == null) { + DEException.throwException("主键字段或值不能为空"); + } + + // 构建 UPDATE 语句 + StringBuilder setClause = new StringBuilder(); + for (int i = 0; i < fieldList.size(); i++) { + Map field = fieldList.get(i); + String fieldName = (String) field.get("fieldName"); + Object fieldValue = field.get("fieldValue"); + + if (i > 0) { + setClause.append(", "); + } + if (fieldValue instanceof String) { + setClause.append(String.format("%s = '%s'", fieldName, fieldValue)); + } else { + setClause.append(String.format("%s = %s", fieldName, fieldValue)); + } + } + + String whereClause = String.format("%s = ", primaryKeyField); + if (primaryKeyValue instanceof String) { + whereClause += String.format("'%s'", primaryKeyValue); + } else { + whereClause += primaryKeyValue; + } + + String sql = String.format("UPDATE %s SET %s WHERE %s", tableName, setClause.toString(), whereClause); + + // 调用执行器执行 SQL + DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); + BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource); + + Provider provider = ProviderFactory.getProvider(coreDatasource.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setQuery(sql); + datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO)); + + logger.debug("执行更新数据的SQL: {}", sql); + + // 执行更新操作 + Map result = provider.fetchResultField(datasourceRequest); + return result != null && !result.isEmpty(); +} + public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception { + // 获取数据源信息 + CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId); + if (coreDatasource == null) { + DEException.throwException("数据源不存在"); + } + + // 解析 JSON 数据 + //String tableDataJson = "{ \"tableName\": \"user\", \"primaryKeyField\": \"id\", \"primaryKeyValue\": \"0001\" }"; + Map dataMap = JsonUtil.parseObject(whereJson, Map.class); + String tableName = (String) dataMap.get("tableName"); + String primaryKeyField = (String) dataMap.get("primaryKeyField"); + Object primaryKeyValue = dataMap.get("primaryKeyValue"); + + if (StringUtils.isBlank(tableName)) { + DEException.throwException("表名不能为空"); + } + if (StringUtils.isBlank(primaryKeyField) || primaryKeyValue == null) { + DEException.throwException("主键字段或值不能为空"); + } + + // 构建 DELETE 语句 + String whereClause = String.format("%s = ", primaryKeyField); + if (primaryKeyValue instanceof String) { + whereClause += String.format("'%s'", primaryKeyValue); + } else { + whereClause += primaryKeyValue; + } + + String sql = String.format("DELETE FROM %s WHERE %s", tableName, whereClause); + + // 调用执行器执行 SQL + DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); + BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource); + + Provider provider = ProviderFactory.getProvider(coreDatasource.getType()); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setQuery(sql); + datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO)); + + logger.debug("执行删除数据的SQL: {}", sql); + + // 执行删除操作 + Map result = provider.fetchResultField(datasourceRequest); + return result != null && !result.isEmpty(); + } + + public Page> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception { + // 获取数据源信息 + CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasourceId); + if (coreDatasource == null) { + DEException.throwException("数据源不存在"); + } + //String queryJson = "{ \"tableName\": \"user\", \"conditions\": [ { \"field\": \"name\", \"operator\": \"like\", \"value\": \"张\" }, { \"field\": \"id\", \"operator\": \"in\", \"value\": [1, 2, 3] } ], \"pageNum\": 1, \"pageSize\": 10 }"; + + // 解析 JSON 查询参数 + Map dataMap = JsonUtil.parseObject(queryJson, Map.class); + String tableName = (String) dataMap.get("tableName"); + List> conditionList = (List>) dataMap.get("conditions"); + + Integer pageNum = (Integer) dataMap.getOrDefault("pageNum", 1); + Integer pageSize = (Integer) dataMap.getOrDefault("pageSize", 10); + + if (StringUtils.isBlank(tableName)) { + DEException.throwException("表名不能为空"); + } + + // 构建 WHERE 条件子句 + StringBuilder whereClause = new StringBuilder(); + + if (conditionList != null && !conditionList.isEmpty()) { + whereClause.append(" WHERE "); + for (int i = 0; i < conditionList.size(); i++) { + Map condition = conditionList.get(i); + String field = (String) condition.get("field"); + String operator = ((String) condition.get("operator")).toLowerCase(); + Object value = condition.get("value"); + + if (i > 0) { + whereClause.append(" AND "); + } + + // 处理不同类型的条件 + switch (operator) { + case "like": + whereClause.append(String.format("%s LIKE '%%%s%%'", field, value)); + break; + case "=": + appendValue(whereClause, field, value, "="); + break; + case "<": + appendValue(whereClause, field, value, "<"); + break; + case ">": + appendValue(whereClause, field, value, ">"); + break; + case "<=": + appendValue(whereClause, field, value, "<="); + break; + case ">=": + appendValue(whereClause, field, value, ">="); + break; + case "!=": + case "<>": + appendValue(whereClause, field, value, "<>"); + break; + case "in": + if (!(value instanceof List)) { + DEException.throwException("IN 操作符要求值为列表类型"); + } + List values = (List) value; + String inValues = values.stream() + .map(v -> v instanceof String ? "'" + v + "'" : v.toString()) + .collect(Collectors.joining(", ")); + whereClause.append(String.format("%s IN (%s)", field, inValues)); + break; + default: + DEException.throwException("不支持的操作符: " + operator); + } + } + } + + // 构建基础查询语句 + String baseSql = String.format("SELECT * FROM %s%s", tableName, whereClause); + + // 根据数据库类型生成分页语句 + String dbType = coreDatasource.getType().toLowerCase(); + String pagedSql = buildPagedSQL(baseSql, dbType, pageNum, pageSize); + + // 构建 COUNT 查询语句用于分页计算 + String countSql = String.format("SELECT COUNT(*) FROM %s%s", tableName, whereClause); + + // 执行查询 + DatasourceSchemaDTO schemaDTO = new DatasourceSchemaDTO(); + BeanUtils.copyBean(schemaDTO, coreDatasource); + + Provider provider = ProviderFactory.getProvider(coreDatasource.getType()); + DatasourceRequest request = new DatasourceRequest(); + request.setDsList(Map.of(schemaDTO.getId(), schemaDTO)); + + // 1. 查询分页数据 + request.setQuery(pagedSql); + Map result = provider.fetchResultField(request); + List> dataList = (List>) result.get("data"); + + // 2. 查询总记录数 + request.setQuery(countSql); + Map countResult = provider.fetchResultField(request); + long total = Long.parseLong(((List) countResult.get("data")).get(0)[0]); + + // 封装分页结果 + Page> page = new Page<>(); + page.setCurrent(pageNum); + page.setSize(pageSize); + page.setTotal(total); + page.setRecords(dataList); + + return page; + } + + private void appendValue(StringBuilder sb, String field, Object value, String op) { + if (value instanceof String) { + sb.append(String.format("%s %s '%s'", field, op, value)); + } else { + sb.append(String.format("%s %s %s", field, op, value)); + } + } + + private String buildPagedSQL(String baseSql, String dbType, int pageNum, int pageSize) { + int offset = (pageNum - 1) * pageSize; + + switch (dbType) { + case "mysql": + case "mariadb": + return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset); + case "postgresql": + return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset); + case "oracle": + int start = offset + 1; + int end = offset + pageSize; + return String.format("SELECT * FROM (SELECT ROWNUM rn, t.* FROM (%s) t WHERE ROWNUM <= %d) WHERE rn >= %d", baseSql, end, start); + case "sqlserver": + return String.format("%s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY", baseSql, offset, pageSize); + default: + // 默认使用 MySQL 方式 + return String.format("%s LIMIT %d OFFSET %d", baseSql, pageSize, offset); + } + } + + + } diff --git a/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java b/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java index c8b2317..eb27d59 100644 --- a/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java +++ b/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java @@ -1,5 +1,6 @@ package io.gisbi.dataset.server; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.gisbi.api.dataset.DatasetDataApi; import io.gisbi.api.dataset.dto.BaseTreeNodeDTO; import io.gisbi.api.dataset.dto.EnumValueRequest; @@ -7,11 +8,15 @@ import io.gisbi.api.dataset.dto.MultFieldValuesRequest; import io.gisbi.api.dataset.dto.PreviewSqlDTO; import io.gisbi.api.dataset.union.DatasetGroupInfoDTO; import io.gisbi.api.dataset.dto.EnumObj; +import io.gisbi.dataset.dao.auto.entity.CoreDatasetTable; +import io.gisbi.dataset.dao.auto.entity.CoreDatasetTableField; import io.gisbi.dataset.manage.DatasetDataManage; import io.gisbi.extensions.datasource.dto.DatasetTableDTO; import io.gisbi.extensions.datasource.dto.DatasetTableFieldDTO; import io.gisbi.utils.LogUtil; import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -32,6 +37,7 @@ public class DatasetDataServer implements DatasetDataApi { return datasetDataManage.previewDataWithLimit(datasetGroupInfoDTO, 0, 100, false); } + @Override public List tableField(DatasetTableDTO datasetTableDTO) throws Exception { return datasetDataManage.getTableFields(datasetTableDTO); @@ -100,4 +106,47 @@ public class DatasetDataServer implements DatasetDataApi { return null; } } + + @GetMapping("getTablesByAppId") + public List getTablesByAppId(Long id) throws Exception { + List result = datasetDataManage.getTablesByAppId(id); + return result; + } + @GetMapping("getFieldsByTableId") + public List getFieldsByTableId(Long id) throws Exception { + List result = datasetDataManage.getFieldsByTableId(id); + return result; + } + @PostMapping("addTableData") + public boolean addTableData(Long datasourceId, String tableData) throws Exception { + boolean result = datasetDataManage.addTableData( + datasourceId, + tableData + ); + return result; + } + @PostMapping("updateTableData") + public boolean updateTableData(Long datasourceId, String tableData) throws Exception { + boolean result = datasetDataManage.updateTableData( + datasourceId, + tableData + ); + return result; + } + @PostMapping("deleteTableData") + public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception { + boolean result = datasetDataManage.deleteTableData( + datasourceId, + whereJson + ); + return result; + } + @GetMapping("queryTableDataPaged") + public Page> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception { + Page> result = datasetDataManage.queryTableDataPaged( + datasourceId, + queryJson + ); + return result; + } } From d94955e69ae3629a9ca6a5b59d88861170687454 Mon Sep 17 00:00:00 2001 From: lilin Date: Wed, 21 May 2025 10:16:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/OrganizationServiceImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java index 732d9cb..5cbc7db 100644 --- a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java +++ b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java @@ -59,8 +59,6 @@ public class OrganizationServiceImpl extends ServiceImpl(); } - List> result = new ArrayList<>(); - for (Map item : listMap) { Object idObj = item.get("id"); // 避免空指针 @@ -70,10 +68,10 @@ public class OrganizationServiceImpl extends ServiceImpl> childList = child(idObj.toString(), appId, orgname); item.put("childList", childList); // 添加新列 子集 if (childList != null && !childList.isEmpty()) { - result.add(item); // 仅保留有子节点的数据 + listMap.add(item); // 仅保留有子节点的数据 } } - return result; + return listMap; } From 15ae73cc1592a90fe97c115714d056cd8ec4328e Mon Sep 17 00:00:00 2001 From: lilin Date: Wed, 21 May 2025 16:09:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/OrganizationServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java index 5cbc7db..fda4d79 100644 --- a/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java +++ b/core/core-backend/src/main/java/io/gisbi/application/system/service/impl/OrganizationServiceImpl.java @@ -67,9 +67,9 @@ public class OrganizationServiceImpl extends ServiceImpl> childList = child(idObj.toString(), appId, orgname); item.put("childList", childList); // 添加新列 子集 - if (childList != null && !childList.isEmpty()) { - listMap.add(item); // 仅保留有子节点的数据 - } +// if (childList != null && !childList.isEmpty()) { +// listMap.add(item); // 仅保留有子节点的数据 +// } } return listMap; } From 25e57b4e68239a4c6721720b2e98155a5afc4f32 Mon Sep 17 00:00:00 2001 From: root <13910913995@163.com> Date: Wed, 21 May 2025 16:45:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auto/mapper/CoreDatasetTableMapper.java | 9 ++++- .../dataset/manage/DatasetDataManage.java | 39 ++++++++++++------- .../dataset/server/DatasetDataServer.java | 23 +++++------ core/core-frontend/auto-imports.d.ts | 3 +- .../io/gisbi/auth/filter/TokenFilter.java | 6 +-- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/core/core-backend/src/main/java/io/gisbi/dataset/dao/auto/mapper/CoreDatasetTableMapper.java b/core/core-backend/src/main/java/io/gisbi/dataset/dao/auto/mapper/CoreDatasetTableMapper.java index 23dbc25..94497d5 100644 --- a/core/core-backend/src/main/java/io/gisbi/dataset/dao/auto/mapper/CoreDatasetTableMapper.java +++ b/core/core-backend/src/main/java/io/gisbi/dataset/dao/auto/mapper/CoreDatasetTableMapper.java @@ -1,8 +1,14 @@ package io.gisbi.dataset.dao.auto.mapper; +import io.gisbi.application.system.domain.Role; import io.gisbi.dataset.dao.auto.entity.CoreDatasetTable; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; /** *

@@ -14,5 +20,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CoreDatasetTableMapper extends BaseMapper { - + @Select("select b.name group_name,a.table_name table_name,a.id table_id from core_dataset_table a join core_dataset_group b on (a.dataset_group_id=b.id) where b.app_id=#{appid} and a.type='db' order by a.name") + List> getTablesByAppId(String appid); } diff --git a/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java b/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java index 3b3891b..e832b89 100644 --- a/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java +++ b/core/core-backend/src/main/java/io/gisbi/dataset/manage/DatasetDataManage.java @@ -1149,20 +1149,18 @@ public class DatasetDataManage { } //-----------------------下面代码为扩展代码,实现了数据表的增删改查功能--zhengsl at 2025-05-20----------------------------------------------------------------------------------------// - public List getTablesByAppId(Long id) throws Exception { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("app_id", id); - wrapper.eq("type", "db"); - List tables = coreDatasetTableMapper.selectList(wrapper); + public List> getTablesByAppId(String appid) throws Exception { + List> tables = coreDatasetTableMapper.getTablesByAppId(appid); return tables; } - public List getFieldsByTableId(Long id) throws Exception { + public List> getFieldsByTableId(Long id) throws Exception { QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.select("id","origin_name","name","type","size"); wrapper.eq("dataset_table_id", id); wrapper.eq("checked", true); wrapper.isNull("chart_id"); - List fields = coreDatasetTableFieldMapper.selectList(wrapper); + List> fields = coreDatasetTableFieldMapper.selectMaps(wrapper); return fields; } @@ -1217,8 +1215,13 @@ public class DatasetDataManage { logger.debug("执行插入数据的SQL: {}", sql); // 执行插入操作 - Map result = provider.fetchResultField(datasourceRequest); - return result != null && !result.isEmpty(); + int result= provider.executeUpdate(datasourceRequest); + if (result==1) { + return true; + // process result set + } else { + return false; + } } public boolean updateTableData(Long datasourceId, String tableData) throws Exception { @@ -1283,8 +1286,13 @@ public class DatasetDataManage { logger.debug("执行更新数据的SQL: {}", sql); // 执行更新操作 - Map result = provider.fetchResultField(datasourceRequest); - return result != null && !result.isEmpty(); + int result= provider.executeUpdate(datasourceRequest); + if (result==1) { + return true; + // process result set + } else { + return false; + } } public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception { // 获取数据源信息 @@ -1329,8 +1337,13 @@ public class DatasetDataManage { logger.debug("执行删除数据的SQL: {}", sql); // 执行删除操作 - Map result = provider.fetchResultField(datasourceRequest); - return result != null && !result.isEmpty(); + int result= provider.executeUpdate(datasourceRequest); + if (result==1) { + return true; + // process result set + } else { + return false; + } } public Page> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception { diff --git a/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java b/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java index eb27d59..6eed024 100644 --- a/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java +++ b/core/core-backend/src/main/java/io/gisbi/dataset/server/DatasetDataServer.java @@ -15,10 +15,7 @@ import io.gisbi.extensions.datasource.dto.DatasetTableDTO; import io.gisbi.extensions.datasource.dto.DatasetTableFieldDTO; import io.gisbi.utils.LogUtil; import jakarta.annotation.Resource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @@ -108,17 +105,17 @@ public class DatasetDataServer implements DatasetDataApi { } @GetMapping("getTablesByAppId") - public List getTablesByAppId(Long id) throws Exception { - List result = datasetDataManage.getTablesByAppId(id); + public List> getTablesByAppId(String appid) throws Exception { + List> result = datasetDataManage.getTablesByAppId(appid); return result; } @GetMapping("getFieldsByTableId") - public List getFieldsByTableId(Long id) throws Exception { - List result = datasetDataManage.getFieldsByTableId(id); + public List> getFieldsByTableId(Long id) throws Exception { + List> result = datasetDataManage.getFieldsByTableId(id); return result; } @PostMapping("addTableData") - public boolean addTableData(Long datasourceId, String tableData) throws Exception { + public boolean addTableData(Long datasourceId, @RequestBody String tableData) throws Exception { boolean result = datasetDataManage.addTableData( datasourceId, tableData @@ -126,7 +123,7 @@ public class DatasetDataServer implements DatasetDataApi { return result; } @PostMapping("updateTableData") - public boolean updateTableData(Long datasourceId, String tableData) throws Exception { + public boolean updateTableData(Long datasourceId, @RequestBody String tableData) throws Exception { boolean result = datasetDataManage.updateTableData( datasourceId, tableData @@ -134,15 +131,15 @@ public class DatasetDataServer implements DatasetDataApi { return result; } @PostMapping("deleteTableData") - public boolean deleteTableData(Long datasourceId, String whereJson) throws Exception { + public boolean deleteTableData(Long datasourceId, @RequestBody String whereJson) throws Exception { boolean result = datasetDataManage.deleteTableData( datasourceId, whereJson ); return result; } - @GetMapping("queryTableDataPaged") - public Page> queryTableDataPaged(Long datasourceId, String queryJson) throws Exception { + @PostMapping("queryTableDataPaged") + public Page> queryTableDataPaged(Long datasourceId, @RequestBody String queryJson) throws Exception { Page> result = datasetDataManage.queryTableDataPaged( datasourceId, queryJson diff --git a/core/core-frontend/auto-imports.d.ts b/core/core-frontend/auto-imports.d.ts index 2b3ed01..918aad8 100644 --- a/core/core-frontend/auto-imports.d.ts +++ b/core/core-frontend/auto-imports.d.ts @@ -4,6 +4,5 @@ // Generated by unplugin-auto-import export {} declare global { - const ElMessage: typeof import('element-plus-secondary/es')['ElMessage'] - const ElMessageBox: typeof import('element-plus-secondary/es')['ElMessageBox'] + } diff --git a/sdk/common/src/main/java/io/gisbi/auth/filter/TokenFilter.java b/sdk/common/src/main/java/io/gisbi/auth/filter/TokenFilter.java index f354926..df9c254 100644 --- a/sdk/common/src/main/java/io/gisbi/auth/filter/TokenFilter.java +++ b/sdk/common/src/main/java/io/gisbi/auth/filter/TokenFilter.java @@ -80,9 +80,9 @@ public class TokenFilter implements Filter { filterChain.doFilter(servletRequest, servletResponse); return; } - String token = ServletUtils.getToken(); - TokenUserBO userBO = TokenUtils.validate(token); - UserUtils.setUserInfo(userBO); +// String token = ServletUtils.getToken(); +// TokenUserBO userBO = TokenUtils.validate(token); +// UserUtils.setUserInfo(userBO); filterChain.doFilter(servletRequest, servletResponse); } catch (Exception e) { throw e;