feat:增加一个获取数据库连接配置列表的远程下拉组件接口

This commit is contained in:
2368302435@qq.com 2024-02-29 00:34:22 +08:00
parent 77af084385
commit f9e10aa4ca

View File

@ -62,6 +62,27 @@ class Ajax extends Backend
return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/svg+xml');
}
/**
* 获取已脱敏的数据库连接配置列表
* @throws Throwable
*/
public function getDatabaseConnections(): void
{
$connections = config('database.connections');
$desensitization = [];
foreach ($connections as $key => $connection) {
$connection = TableManager::getConnectionConfig($key);
$desensitization[] = [
'type' => $connection['type'],
'database' => substr_replace($connection['database'], '****', 1, strlen($connection['database']) > 4 ? 2 : 1),
'key' => $key,
];
}
$this->success('', [
'list' => $desensitization,
]);
}
/**
* 获取表主键字段
* @param ?string $table