feat: 添加访问日志分页功能,优化相关接口和前端组件

This commit is contained in:
ryan
2026-03-14 23:18:49 +08:00
parent b7d38590ba
commit 8d406f5ade
8 changed files with 184 additions and 23 deletions
+4 -1
View File
@@ -14,7 +14,7 @@ type NodeAccessLog struct {
CreatedAt time.Time `json:"created_at"`
}
func ListNodeAccessLogs(nodeID string, since time.Time, limit int) (logs []*NodeAccessLog, err error) {
func ListNodeAccessLogs(nodeID string, since time.Time, offset int, limit int) (logs []*NodeAccessLog, err error) {
query := DB.Order("logged_at desc, id desc")
if nodeID != "" {
query = query.Where("node_id = ?", nodeID)
@@ -22,6 +22,9 @@ func ListNodeAccessLogs(nodeID string, since time.Time, limit int) (logs []*Node
if !since.IsZero() {
query = query.Where("logged_at >= ?", since)
}
if offset > 0 {
query = query.Offset(offset)
}
if limit > 0 {
query = query.Limit(limit)
}