mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
Co-authored-by: lxwcodemonkey
This commit is contained in:
@@ -25,9 +25,6 @@ import com.tencent.supersonic.headless.server.service.DatabaseService;
|
||||
import com.tencent.supersonic.headless.server.service.ModelService;
|
||||
import com.tencent.supersonic.headless.server.utils.DatabaseConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||
import net.sf.jsqlparser.statement.Statement;
|
||||
import net.sf.jsqlparser.util.TablesNamesFinder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -200,26 +197,6 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseDOMapper, DatabaseD
|
||||
return dbColumns;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String sql = "SELECT * FROM mydatabase.mytable JOIN otherdatabase.othertable ON mytable.id = othertable.id";
|
||||
|
||||
// 解析SQL语句
|
||||
Statement statement = CCJSqlParserUtil.parse(sql);
|
||||
|
||||
// 提取库表名
|
||||
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
|
||||
List<String> tableNames = tablesNamesFinder.getTableList(statement);
|
||||
|
||||
// 打印库表名
|
||||
for (String tableName : tableNames) {
|
||||
System.out.println("Table Name: " + tableName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermission(DatabaseResp databaseResp, User user) {
|
||||
List<String> admins = databaseResp.getAdmins();
|
||||
List<String> viewers = databaseResp.getViewers();
|
||||
|
||||
@@ -67,11 +67,12 @@ public class DatabaseConverter {
|
||||
}
|
||||
|
||||
public static ConnectInfo getConnectInfo(DatabaseResp databaseResp) {
|
||||
Database database = convert(databaseResp);
|
||||
ConnectInfo connectInfo = new ConnectInfo();
|
||||
connectInfo.setUserName(databaseResp.getUsername());
|
||||
connectInfo.setPassword(databaseResp.getPassword());
|
||||
connectInfo.setUrl(databaseResp.getUrl());
|
||||
connectInfo.setDatabase(databaseResp.getDatabase());
|
||||
connectInfo.setUserName(database.getUsername());
|
||||
connectInfo.setPassword(database.passwordDecrypt());
|
||||
connectInfo.setUrl(database.getUrl());
|
||||
connectInfo.setDatabase(database.getDatabase());
|
||||
return connectInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user