package service import ( "context" "next-terminal/server/common" "next-terminal/server/model" "next-terminal/server/repository" "next-terminal/server/utils" ) var DatabaseSQLLogService = new(databaseSQLLogService) type databaseSQLLogService struct { baseService } type DatabaseSQLLogParams struct { AssetId string Database string UserId string ClientIP string SQL string DurationMs int RowsAffected int Status string ErrorMessage string Source string } func (s databaseSQLLogService) Record(ctx context.Context, params DatabaseSQLLogParams) error { log := &model.DatabaseSQLLog{ ID: utils.UUID(), AssetId: params.AssetId, Database: params.Database, UserId: params.UserId, ClientIP: params.ClientIP, SQL: params.SQL, DurationMs: params.DurationMs, RowsAffected: params.RowsAffected, Status: params.Status, ErrorMessage: params.ErrorMessage, Source: params.Source, Created: common.NowJsonTime(), } return repository.DatabaseSQLLogRepository.Create(ctx, log) }