修改任务需要的字段添加

master
lwj 2024-09-03 19:03:16 +08:00
parent 7ec90b2673
commit cd96dd36bd
6 changed files with 71 additions and 33 deletions

View File

@ -56,6 +56,7 @@ public class TableInfo extends BaseEntity {
public static TableInfoResp toTableInfoResp(TableInfo tableInfo) {
return TableInfoResp.builder()
.id(tableInfo.id)
.parentId(tableInfo.parentId)
.basicId(tableInfo.basicId)
.tableName(tableInfo.tableName)
.tableRemark(tableInfo.tableRemark)

View File

@ -38,6 +38,9 @@ public class TableInfoResp {
/** 是否核心 'Y'是 'N'不是 */
private String isCenter;
//父级ID
private Long parentId;
/**
*
*/

View File

@ -22,6 +22,7 @@ public class DataValueController {
return Result.success(list);
}
//获取字段值
@PostMapping("/findTableValueList")
public Result findTableValueList(@RequestParam("basicId") Long basicId,@RequestParam("tableName") String tableName ) {
@ -30,6 +31,15 @@ public class DataValueController {
}
//添加数据库
//根据值添加的表中
@PostMapping("/addTable")
public Result addTableDataValue(@RequestParam Long basicId,@RequestParam Long tableId, @RequestBody List<List<DataValue>> dataValue) {
Integer i = dataValueService.addTableDataValue(basicId,tableId,dataValue);
return Result.success(i);
}
}

View File

@ -25,6 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/tableInfo")
public class TableInfoController {
@Autowired
private TableInfoService tableInfoService;
@Autowired
@ -36,33 +37,6 @@ public class TableInfoController {
private HttpServletRequest request;
// @Autowired
// private SysUserService sysUserService;
// @GetMapping("/findTableInfo")
// public Result<List<TableInfoTreeRep>> findTableInfo() {
// List<TableInfo> tableInfoList= tableInfoService.findSourceList();
//
// List<TableInfoTreeRep> tableInfoTreeReps = new ArrayList<TableInfoTreeRep>();
//
// for (TableInfo tableInfo : tableInfoList) {
// TableInfoTreeRep tableInfoTreeRep = new TableInfoTreeRep();
// tableInfoTreeRep.setTableInfo(tableInfo);
// List<TableInfoRep> tableInfoRepList= tableInfoService.findTablesList(tableInfo.getId());
// tableInfoTreeRep.setChildren(tableInfoRepList);
// for (TableInfoRep tableInfoRep : tableInfoRepList) {
// List<Structure> structureList=structureService.findStructureList(tableInfoRep.getId());
// tableInfoRep.setStructureList(structureList);
// }
// tableInfoTreeReps.add(tableInfoTreeRep);
// }
//
// return Result.success(tableInfoTreeReps);
//
// }
@GetMapping("/findTableInfoList")
public Result findByTableName() {
List<TableInfo> list = tableInfoService.list();
@ -159,6 +133,7 @@ public class TableInfoController {
return Result.success(tableInfoResps);
}
@NotNull
private static List<TableInfoResp> getSetChildren(TableInfo tableInfo, HashSet<TableInfo> tableInfoHashSet) {
List<TableInfoResp> list = tableInfoHashSet.stream().filter(tableInfo1 -> tableInfo1.getParentId()
@ -169,12 +144,6 @@ public class TableInfoController {
}
//
//
// @PostMapping("/findTableValueS")
// public List<DataValue> findTableValueS(@RequestParam Long basicId,@RequestParam String tableName ) {
// return tableInfoService.findTableValues(basicId,tableName);
// }
}

View File

@ -8,4 +8,7 @@ public interface DataValueService {
List< List<DataValue> >findTableValue(Long basicId, String sql);
List<DataValue> findTableValueList(Long basicId, String tableName);
Integer addTableDataValue(Long basicId, Long tableId, List<List<DataValue>> dataValue);
}

View File

@ -2,8 +2,10 @@ package com.muyu.cloud.etl.service.impl;
import com.muyu.cloud.etl.service.DataValueService;
import com.muyu.cloud.etl.service.SourceService;
import com.muyu.cloud.etl.service.TableInfoService;
import com.muyu.domain.DataValue;
import com.muyu.domain.Source;
import com.muyu.domain.TableInfo;
import com.muyu.domain.enums.DataType;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +20,8 @@ import java.util.List;
public class DataValueServiceImpl implements DataValueService {
@Autowired
private SourceService sourceService;
@Autowired
private TableInfoService tableInfoService;
@Override
public List<List<DataValue>> findTableValue(Long basicId, String sql) {
@ -131,4 +135,52 @@ public class DataValueServiceImpl implements DataValueService {
return dataValues;
}
//供连接数据库调用公共方法
private Connection getConnection(Source source) {
Connection conn = null;
String host = source.getHost();
String port = source.getPort();
String databaseName = source.getDatabaseName();
String databaseType = source.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + source.getConnectionParams();
String user = source.getUsername();
String password = source.getPassword();
try {
return DriverManager.getConnection(url,user,password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public Integer addTableDataValue(Long basicId, Long tableId, List<List<DataValue>> dataValue) {
Source source = sourceService.getInfo(basicId);
TableInfo tableInfo = tableInfoService.getById(tableId);
String host = source.getHost();
String port = source.getPort();
String databaseName = source.getDatabaseName();
String databaseType = source.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + source.getConnectionParams();
String user = source.getUsername();
String password = source.getPassword();
String tableName = tableInfo.getTableName();
Connection conn=null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return 0;
}
}