修复图表时间和查询区间不匹配问题
This commit is contained in:
39
backend/internal/db/db.go
Normal file
39
backend/internal/db/db.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
// DB 定义数据库连接接口
|
||||
type DB interface {
|
||||
// 获取原始数据库连接
|
||||
GetDB() *sql.DB
|
||||
|
||||
// 执行查询,返回多行结果
|
||||
Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
|
||||
|
||||
// 执行查询,返回单行结果
|
||||
QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
|
||||
|
||||
// 执行更新操作(INSERT、UPDATE、DELETE)
|
||||
Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
|
||||
|
||||
// 开始事务
|
||||
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
|
||||
|
||||
// 关闭数据库连接
|
||||
Close() error
|
||||
}
|
||||
|
||||
// Config 数据库配置结构体
|
||||
type Config struct {
|
||||
Type string
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
Password string
|
||||
Database string
|
||||
SSLMode string
|
||||
Charset string
|
||||
}
|
||||
Reference in New Issue
Block a user