09061451:对数据库结构的数据量做一个实时

master
冷调 2024-09-06 14:51:41 +08:00
parent b911e8edeb
commit efc218a71a
3 changed files with 18 additions and 2 deletions

View File

@ -66,7 +66,6 @@ public class DataValueController {
Integer i = dataValueService.addTableValue(dataValueModel); Integer i = dataValueService.addTableValue(dataValueModel);
return Result.success(i); return Result.success(i);
} }
/** /**
* ID * ID
* *
@ -76,7 +75,7 @@ public class DataValueController {
*/ */
@PostMapping("/findTableValueByTableName") @PostMapping("/findTableValueByTableName")
@Operation(summary = "根据基础表ID和SQL语句查询数据", description = "根据基础表ID和SQL语句查询数据") @Operation(summary = "根据基础表ID和SQL语句查询数据", description = "根据基础表ID和SQL语句查询数据")
public Result findTableValueByTableName(@RequestParam("basicId") Long basicId, @RequestParam("tableName") String tableName) throws SQLException { public Result findTableValueByTableName(@RequestParam("basicId") Long basicId, @RequestParam("tableName") String tableName) {
List<DataValue> dataValueList = dataValueService.findTableValueByTableName(basicId, tableName); List<DataValue> dataValueList = dataValueService.findTableValueByTableName(basicId, tableName);
return Result.success(dataValueList); return Result.success(dataValueList);
} }

View File

@ -1,6 +1,8 @@
package com.muyu.source.controller; package com.muyu.source.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dtflys.forest.springboot.annotation.ForestScannerRegister; import com.dtflys.forest.springboot.annotation.ForestScannerRegister;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil; import com.muyu.common.core.utils.poi.ExcelUtil;
@ -10,6 +12,8 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.source.domain.Structure; import com.muyu.source.domain.Structure;
import com.muyu.source.domain.TableData; import com.muyu.source.domain.TableData;
import com.muyu.source.domain.TableInfo;
import com.muyu.source.service.StructureService;
import com.muyu.source.service.TableDataService; import com.muyu.source.service.TableDataService;
import com.muyu.source.service.TableInfoService; import com.muyu.source.service.TableInfoService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -44,6 +48,8 @@ public class TableDataController extends BaseController {
private TableDataService tableDataService; private TableDataService tableDataService;
@Autowired @Autowired
private TableInfoService tableInfoService; private TableInfoService tableInfoService;
@Autowired
private StructureService structureService;
/** /**
* childrenId * childrenId
* *
@ -63,6 +69,16 @@ public class TableDataController extends BaseController {
*/ */
@GetMapping("/selectStructureById/{id}") @GetMapping("/selectStructureById/{id}")
public Result<List<Structure>> selectStructureById(@PathVariable("id") Integer id) { public Result<List<Structure>> selectStructureById(@PathVariable("id") Integer id) {
//根据id查询表结构中的数据量
long count = structureService.count(new LambdaQueryWrapper<>() {{
eq(Structure::getTableId, id);
}});
if (count!=0L) {
boolean update = tableInfoService.update(new LambdaUpdateWrapper<>() {{
eq(TableInfo::getId, id)
.set(TableInfo::getDataNum, count);
}});
}
List<Structure> structureList =tableInfoService.selectTableInfoById(id); List<Structure> structureList =tableInfoService.selectTableInfoById(id);
return success(structureList); return success(structureList);
} }

View File

@ -45,6 +45,7 @@ public class TableServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> im
List<Structure> structureList = structureMapper.selectList(new LambdaQueryWrapper<>(Structure.class) {{ List<Structure> structureList = structureMapper.selectList(new LambdaQueryWrapper<>(Structure.class) {{
eq(Structure::getTableId, id); eq(Structure::getTableId, id);
}}); }});
return structureList; return structureList;
} }