package com.njcn.gather.systemops.database.support.oracle;

import com.njcn.gather.systemops.database.component.OracleJdbcComponent;
import com.njcn.gather.systemops.database.constant.DatabaseOpsConst;
import com.njcn.gather.systemops.database.pojo.po.DatabaseConnection;
import com.njcn.gather.systemops.database.pojo.vo.DatabaseTableVO;
import com.njcn.gather.systemops.database.pojo.vo.DatabaseTestResultVO;
import com.njcn.gather.systemops.database.support.spi.DatabaseConnectionOperator;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Oracle 连接能力实现。
 */
@Component
@RequiredArgsConstructor
public class OracleConnectionOperator implements DatabaseConnectionOperator {

    private final OracleJdbcComponent oracleJdbcComponent;

    @Override
    public boolean support(String dbType) {
        return DatabaseOpsConst.DB_TYPE_ORACLE.equalsIgnoreCase(dbType);
    }

    @Override
    public DatabaseTestResultVO test(DatabaseConnection connection, String password) {
        return oracleJdbcComponent.test(connection, password);
    }

    @Override
    public List<DatabaseTableVO> listTables(DatabaseConnection connection, String password, String schemaOrDatabaseName) throws Exception {
        return oracleJdbcComponent.listTables(connection, password, schemaOrDatabaseName);
    }
}
