feat: Agent CLI 与终端审计回放全面优化
- Agent CLI: 多轮对话、SSH 长连接、流式推理、Evolver 按用户隔离、历史侧栏 - 终端审计: 回放播放器、命令书签、筛选分页导出、命令输出统计、录制落盘修复 - 修复 session_commands 表迁移、Kill 竞态导致录制丢失、无录制会话回放提示 - 审计历史页只读(移除删除),移除回放弹框录制搜索
This commit is contained in:
1 parent
9a3dd304f7
commit
1acb0c49af
81 files changed
+3916
-1655
No files matched your search
@@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"ezops/model"
|
||||
|
||||
@@ -47,6 +48,16 @@ func (h *SessionCommandHandler) ListSessionCommands(c *gin.Context) {
|
||||
if req.Command != "" {
|
||||
query = query.Where("command LIKE ?", "%"+req.Command+"%")
|
||||
}
|
||||
if req.StartDate != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", req.StartDate, time.Local); err == nil {
|
||||
query = query.Where("timestamp >= ?", t)
|
||||
}
|
||||
}
|
||||
if req.EndDate != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", req.EndDate, time.Local); err == nil {
|
||||
query = query.Where("timestamp < ?", t.Add(24*time.Hour))
|
||||
}
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := query.Count(&total).Error; err != nil {
|
||||
@@ -54,17 +65,43 @@ func (h *SessionCommandHandler) ListSessionCommands(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var commands []model.SessionCommand
|
||||
if err := query.Order("id DESC").
|
||||
// 联表带出会话录制大小,前端可判断能否回放 // Logan.Li
|
||||
var items []model.SessionCommandItem
|
||||
listQuery := h.db.Table("sys_session_commands AS sc").
|
||||
Select("sc.*, COALESCE(ts.record_size, 0) AS session_record_size").
|
||||
Joins("LEFT JOIN sys_terminal_sessions AS ts ON ts.id = sc.session_id")
|
||||
if req.SessionID > 0 {
|
||||
listQuery = listQuery.Where("sc.session_id = ?", req.SessionID)
|
||||
}
|
||||
if req.Username != "" {
|
||||
listQuery = listQuery.Where("sc.username LIKE ?", "%"+req.Username+"%")
|
||||
}
|
||||
if req.ServerID > 0 {
|
||||
listQuery = listQuery.Where("sc.server_id = ?", req.ServerID)
|
||||
}
|
||||
if req.Command != "" {
|
||||
listQuery = listQuery.Where("sc.command LIKE ?", "%"+req.Command+"%")
|
||||
}
|
||||
if req.StartDate != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", req.StartDate, time.Local); err == nil {
|
||||
listQuery = listQuery.Where("sc.timestamp >= ?", t)
|
||||
}
|
||||
}
|
||||
if req.EndDate != "" {
|
||||
if t, err := time.ParseInLocation("2006-01-02", req.EndDate, time.Local); err == nil {
|
||||
listQuery = listQuery.Where("sc.timestamp < ?", t.Add(24*time.Hour))
|
||||
}
|
||||
}
|
||||
if err := listQuery.Order("sc.id DESC").
|
||||
Offset((req.Page - 1) * req.PageSize).
|
||||
Limit(req.PageSize).
|
||||
Find(&commands).Error; err != nil {
|
||||
Scan(&items).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, model.Response{Code: 500, Message: "查询失败"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.Response{Code: 200, Data: model.ListResponse{
|
||||
List: commands,
|
||||
List: items,
|
||||
Total: total,
|
||||
}})
|
||||
}
|
||||
Reference in new issue
Block a user