提交 92382594 authored 作者: mry's avatar mry

feat(web): 增加了执行其中专门提示testcase的接口

上级 abf4b164
...@@ -9,14 +9,12 @@ import org.matrix.autotest.entity.GrammarTable; ...@@ -9,14 +9,12 @@ import org.matrix.autotest.entity.GrammarTable;
import org.matrix.autotest.entity.runSqlQuery; import org.matrix.autotest.entity.runSqlQuery;
import org.matrix.database.service.IConnectService; import org.matrix.database.service.IConnectService;
import org.matrix.exception.GlobalException; import org.matrix.exception.GlobalException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/** /**
* SqlController. * SqlController.
...@@ -31,6 +29,18 @@ import java.util.Set; ...@@ -31,6 +29,18 @@ import java.util.Set;
@RequestMapping("/db") @RequestMapping("/db")
public class SqlController { public class SqlController {
@Value("${spring.datasource.dynamic.datasource.master.driverClassName}")
private String driver;
@Value("${spring.datasource.dynamic.datasource.master.url}")
private String url;
@Value("${spring.datasource.dynamic.datasource.master.username}")
private String username;
@Value("${spring.datasource.dynamic.datasource.master.password}")
private String password;
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
private final IDataSourceService dataSourceService; private final IDataSourceService dataSourceService;
private final SqlExpActuator sqlActuator; private final SqlExpActuator sqlActuator;
...@@ -104,5 +114,21 @@ public class SqlController { ...@@ -104,5 +114,21 @@ public class SqlController {
dataSourceService.switchMainDataSource(); dataSourceService.switchMainDataSource();
return ResponseEntity.ok(grammarTables); return ResponseEntity.ok(grammarTables);
} }
}
@GetMapping("/actuator")
@ApiOperation("获得用例表kt_test_case的语法提示")
public ResponseEntity<List<GrammarTable>> getDBActuator() {
String tableSql = "SELECT a.table_name tableName,a.table_comment tableDes,b.COLUMN_NAME fieldName,b.column_comment fieldDes,b.column_type fieldType FROM information_schema. TABLES a LEFT JOIN information_schema. COLUMNS b ON a.table_name = b.TABLE_NAME WHERE a.table_name = 'kt_test_case' AND a.table_schema = 'key_stone' ORDER BY a.table_name";
DataSourceDTO dataSourceDTO = new DataSourceDTO();
dataSourceDTO.setPoolName("key_stone");
dataSourceDTO.setUsername(username);
dataSourceDTO.setPassword(password);
dataSourceDTO.setUrl(url);
dataSourceDTO.setDriverClassName(driver);
Set<String> dataSources = dataSourceService.switchDataSource(dataSourceDTO);
log.info("当前使用的的数据源 {}", dataSourceService.peek());
List<GrammarTable> grammarTables = new GrammarTable().trans2Table(jdbcTemplate.queryForList(tableSql));
dataSourceService.switchMainDataSource();
return ResponseEntity.ok(grammarTables);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论