81 lines
3.1 KiB
Go
81 lines
3.1 KiB
Go
package botService
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"database/sql/driver"
|
|
"time"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
)
|
|
|
|
// ----------------------------------------
|
|
// COMMON
|
|
// ----------------------------------------
|
|
|
|
type loggerInstance interface {
|
|
Error(string, ...any)
|
|
Debug(string, ...any)
|
|
Info(string, ...any)
|
|
}
|
|
|
|
type pgDBInstance interface {
|
|
Begin() (*sql.Tx, error)
|
|
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
|
|
BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
|
|
Beginx() (*sqlx.Tx, error)
|
|
BindNamed(query string, arg interface{}) (string, []interface{}, error)
|
|
Close() error
|
|
Conn(ctx context.Context) (*sql.Conn, error)
|
|
Connx(ctx context.Context) (*sqlx.Conn, error)
|
|
Driver() driver.Driver
|
|
DriverName() string
|
|
Exec(query string, args ...any) (sql.Result, error)
|
|
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
|
|
Get(dest interface{}, query string, args ...interface{}) error
|
|
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
MapperFunc(mf func(string) string)
|
|
MustBegin() *sqlx.Tx
|
|
MustBeginTx(ctx context.Context, opts *sql.TxOptions) *sqlx.Tx
|
|
MustExec(query string, args ...interface{}) sql.Result
|
|
MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
|
|
NamedExec(query string, arg interface{}) (sql.Result, error)
|
|
NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
|
|
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
|
|
NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
|
|
Ping() error
|
|
PingContext(ctx context.Context) error
|
|
Prepare(query string) (*sql.Stmt, error)
|
|
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
|
|
PrepareNamed(query string) (*sqlx.NamedStmt, error)
|
|
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
|
|
Preparex(query string) (*sqlx.Stmt, error)
|
|
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
|
|
Query(query string, args ...any) (*sql.Rows, error)
|
|
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
|
|
QueryRow(query string, args ...any) *sql.Row
|
|
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
|
|
QueryRowx(query string, args ...interface{}) *sqlx.Row
|
|
QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
|
|
Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
|
|
QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
|
|
Rebind(query string) string
|
|
Select(dest interface{}, query string, args ...interface{}) error
|
|
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
|
|
SetConnMaxIdleTime(d time.Duration)
|
|
SetConnMaxLifetime(d time.Duration)
|
|
SetMaxIdleConns(n int)
|
|
SetMaxOpenConns(n int)
|
|
Stats() sql.DBStats
|
|
Unsafe() *sqlx.DB
|
|
}
|
|
|
|
type supportAPIInstance interface {
|
|
DefaultRequest(
|
|
ctx context.Context, acceptStatus int,
|
|
uri, httpMethod string,
|
|
body, result interface{},
|
|
queryParams map[string]string,
|
|
) (*int, error)
|
|
}
|