修复图表时间和查询区间不匹配问题

This commit is contained in:
Alex Yang
2025-12-02 23:20:10 +08:00
commit 4d66bdf633
49 changed files with 16275 additions and 0 deletions

39
backend/internal/db/db.go Normal file
View 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
}