mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 04:31:52 +08:00
refactor(services): 统一数据库插件的DBWrapper
4个数据库插件(MySQL、PostgreSQL、MSSQL、Oracle)都有相同的sql.DB包装代码, 合并为通用的SQLDBWrapper,减少重复。
This commit is contained in:
@@ -106,7 +106,7 @@ func (p *OraclePlugin) doOracleAuth(ctx context.Context, info *common.HostInfo,
|
||||
|
||||
return &AuthResult{
|
||||
Success: true,
|
||||
Conn: &oracleDBWrapper{db},
|
||||
Conn: &SQLDBWrapper{db},
|
||||
ErrorType: ErrorTypeUnknown,
|
||||
Error: nil,
|
||||
}
|
||||
@@ -120,15 +120,6 @@ func (p *OraclePlugin) doOracleAuth(ctx context.Context, info *common.HostInfo,
|
||||
}
|
||||
}
|
||||
|
||||
// oracleDBWrapper 包装 sql.DB 以实现 io.Closer
|
||||
type oracleDBWrapper struct {
|
||||
*sql.DB
|
||||
}
|
||||
|
||||
func (w *oracleDBWrapper) Close() error {
|
||||
return w.DB.Close()
|
||||
}
|
||||
|
||||
// classifyOracleErrorType Oracle错误分类
|
||||
func classifyOracleErrorType(err error) ErrorType {
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user