This commit is contained in:
tfl
2024-08-21 17:35:50 +08:00
parent 34ea7472b7
commit dd5b38b4e3
24 changed files with 328 additions and 133 deletions

View File

@@ -4,7 +4,7 @@ import (
"fmt"
)
const connectTableName = "events"
const connectTableName = "device_events"
type Events struct {
Ts string `json:"ts"`

View File

@@ -7,7 +7,7 @@ import (
"github.com/kakuilan/kgo"
)
const logTableName = "logs"
const logTableName = "device_logs"
// 日志 TDengine
type TdLog struct {
@@ -39,7 +39,7 @@ func (s *TdEngine) InsertLog(log *TdLog) (err error) {
func (s *TdEngine) ClearLog() (err error) {
ts := time.Now().Add(-7 * 24 * time.Hour).Format("2006-01-02")
sql := fmt.Sprintf("DELETE FROM %s WHERE ts < ?", logTableName)
sql := fmt.Sprintf("DELETE FROM %s.%s WHERE ts < ?", s.dbName, logTableName)
_, err = s.db.Exec(sql, ts)
return