This commit is contained in:
duwenyuan 2025-10-17 09:36:20 +08:00
commit ad0a008820
3 changed files with 29 additions and 8 deletions

View File

@ -19,7 +19,9 @@ import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.base.entity.StasDataSource; import org.jeecg.modules.base.entity.StasDataSource;
import org.jeecg.dataSource.service.IStasDataSourceService; import org.jeecg.dataSource.service.IStasDataSourceService;
import org.jeecg.modules.base.entity.StasSyncStrategy; import org.jeecg.modules.base.entity.StasSyncStrategy;
import org.jeecg.modules.base.entity.StasTaskConfig;
import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.taskConfig.service.IStasTaskConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
@ -40,6 +42,8 @@ public class StasDataSourceController extends JeecgController<StasDataSource, IS
@Autowired @Autowired
private IStasDataSourceService stasDataSourceService; private IStasDataSourceService stasDataSourceService;
@Autowired
private IStasTaskConfigService stasTaskConfigService;
/** /**
* 分页列表查询 * 分页列表查询
@ -77,7 +81,7 @@ public class StasDataSourceController extends JeecgController<StasDataSource, IS
@AutoLog(value = "根据数据源名称查询所有表") @AutoLog(value = "根据数据源名称查询所有表")
@Operation(summary = "根据数据源名称查询所有表") @Operation(summary = "根据数据源名称查询所有表")
@GetMapping(value = "/userList") @GetMapping(value = "/userList")
public Result<?> queryTargetUserList(@RequestParam(name="sourceId",required=false) String sourceId) { public Result<?> queryUserList(@RequestParam(name="sourceId",required=false) String sourceId) {
List<String> tableNameList= stasDataSourceService.queryUserList(sourceId); List<String> tableNameList= stasDataSourceService.queryUserList(sourceId);
if (tableNameList != null && !"".equals(tableNameList)){ if (tableNameList != null && !"".equals(tableNameList)){
return Result.OK(tableNameList); return Result.OK(tableNameList);
@ -85,6 +89,24 @@ public class StasDataSourceController extends JeecgController<StasDataSource, IS
return Result.error("获取源端用户为空"); return Result.error("获取源端用户为空");
} }
/**
* 查询目标源所有用户
*
* @param taskId
* @return
*/
@AutoLog(value = "查询目标源所有用户")
@Operation(summary = "查询目标源所有用户")
@GetMapping(value = "/targetUser")
public Result<?> queryTargetUserList(@RequestParam(name="taskId",required=false) String taskId) {
StasTaskConfig taskConfig = stasTaskConfigService.getById(taskId);
List<String> tableNameList= stasDataSourceService.queryUserList(taskConfig.getSourceId());
if (tableNameList != null && !"".equals(tableNameList)){
return Result.OK(tableNameList);
}
return Result.error("获取源端用户为空");
}
/** /**
* 查询数据源表 * 查询数据源表
* *
@ -121,15 +143,15 @@ public class StasDataSourceController extends JeecgController<StasDataSource, IS
/** /**
* 数据库连接测试 * 数据库连接测试
* @param sourceId * @param stasDataSource
* @return * @return
*/ */
@AutoLog(value = "数据库连接测试") @AutoLog(value = "数据库连接测试")
@Operation(summary = "数据库连接测试") @Operation(summary = "数据库连接测试")
@RequestMapping(value = "/testConnection", method = RequestMethod.GET) @RequestMapping(value = "/testConnection", method = RequestMethod.GET)
public Result<StasDataSource> testConnection(String sourceId) { public Result<StasDataSource> testConnection(StasDataSource stasDataSource) {
try { try {
boolean isValue = stasDataSourceService.testConnection(sourceId); boolean isValue = stasDataSourceService.testConnection(stasDataSource);
if(isValue){ if(isValue){
return Result.OK("连接成功"); return Result.OK("连接成功");
} }

View File

@ -39,10 +39,10 @@ import java.util.List;
/** /**
* 测试数据库连接 * 测试数据库连接
* @param sourceId * @param stasDataSource
* @return * @return
*/ */
boolean testConnection(String sourceId); boolean testConnection(StasDataSource stasDataSource);
/** /**
* 查询所有用户信息 * 查询所有用户信息

View File

@ -57,8 +57,7 @@ public class StasDataSourceServiceImpl extends ServiceImpl<StasDataSourceMapper,
} }
@Override @Override
public boolean testConnection(String sourceId) { public boolean testConnection(StasDataSource stasDataSource) {
StasDataSource stasDataSource = this.baseMapper.selectById(sourceId);
Connection conn = null; Connection conn = null;
try { try {
String urlSource = ""; String urlSource = "";