Files
terminal/server/service/operation_log.go
T
admin 1f7c491048 feat: 完善日志审计功能
- 实现文件系统日志(FilesystemLog)记录文件管理器操作
- 实现操作日志(OperationLog)记录用户操作行为
- 实现数据库SQL日志(DatabaseSQLLog)模型和API
- 实现SSH会话命令记录(SessionCommand)含命令输出和风险等级
- 添加IP提取服务支持X-Real-IP和X-Forwarded-For
- 添加日志自动清理功能
- 修复ProFormSwitch required验证问题
- 修复设置页面默认值问题
- 修复文件上传错误检测逻辑
- 修复资产树key前缀问题
- 添加VNC/RDP设置默认值
- 修复文件管理标题翻译
2026-04-19 06:57:42 +08:00

48 lines
1.1 KiB
Go

package service
import (
"context"
"next-terminal/server/common"
"next-terminal/server/model"
"next-terminal/server/repository"
"next-terminal/server/utils"
)
var OperationLogService = new(operationLogService)
type operationLogService struct {
baseService
}
type OperationLogParams struct {
AccountId string
AccountName string
Action string
Content string
IP string
Region string
UserAgent string
Status string
ErrorMessage string
Remark string
}
func (s operationLogService) Record(ctx context.Context, params OperationLogParams) error {
log := &model.OperationLog{
ID: utils.UUID(),
AccountId: params.AccountId,
AccountName: params.AccountName,
Action: params.Action,
Content: params.Content,
IP: params.IP,
Region: params.Region,
UserAgent: params.UserAgent,
Status: params.Status,
ErrorMessage: params.ErrorMessage,
Remark: params.Remark,
Created: common.NowJsonTime(),
}
return repository.OperationLogRepository.Create(ctx, log)
}