mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
43dc97e48c
- Moved cmd/, core/, plugins/, pkg/, downstream/, and main.go into backend/ directory - Batch updated all Go source files to import github.com/Rain-kl/Wavelet/backend/... - Updated Makefile, scripts/swagger.sh, architecture guards, and platform skills - Passed all quality gates (100% tests, 0 lint issues, clean build)
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package risk_control
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
userAccessLogTableName = "w_user_access_logs"
|
|
userAccessLogInsertColumns = "id, user_id, path, method, ip, user_agent, headers, status, latency, created_at"
|
|
)
|
|
|
|
// UserAccessLog stores HTTP access records in ClickHouse/database.
|
|
type UserAccessLog struct {
|
|
ID uint64 `gorm:"column:id"`
|
|
UserID uint64 `gorm:"column:user_id"`
|
|
Path string `gorm:"column:path"`
|
|
Method string `gorm:"column:method"`
|
|
IP string `gorm:"column:ip"`
|
|
UserAgent string `gorm:"column:user_agent"`
|
|
Headers string `gorm:"column:headers"`
|
|
Status int32 `gorm:"column:status"`
|
|
Latency int64 `gorm:"column:latency"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
}
|
|
|
|
// TableName returns the table name.
|
|
func (UserAccessLog) TableName() string {
|
|
return userAccessLogTableName
|
|
}
|
|
|
|
// InsertColumns returns comma-separated column names for batch insert.
|
|
func (UserAccessLog) InsertColumns() string {
|
|
return userAccessLogInsertColumns
|
|
}
|
|
|
|
// BatchInsertSQL returns the INSERT prefix used by native batch writers.
|
|
func (UserAccessLog) BatchInsertSQL() string {
|
|
return fmt.Sprintf("INSERT INTO %s (%s)", userAccessLogTableName, userAccessLogInsertColumns)
|
|
}
|