35 lines
806 B
Go
35 lines
806 B
Go
|
|
package app
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"go.uber.org/zap"
|
||
|
|
|
||
|
|
"github.com/geo-platform/tenant-api/internal/ops/domain"
|
||
|
|
"github.com/geo-platform/tenant-api/internal/ops/repository"
|
||
|
|
)
|
||
|
|
|
||
|
|
type AuditService struct {
|
||
|
|
repo *repository.AuditRepository
|
||
|
|
logger *zap.Logger
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewAuditService(repo *repository.AuditRepository, logger *zap.Logger) *AuditService {
|
||
|
|
return &AuditService{repo: repo, logger: logger}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *AuditService) Append(ctx context.Context, e domain.AuditEvent) error {
|
||
|
|
if err := s.repo.Append(ctx, e); err != nil {
|
||
|
|
s.logger.Warn("ops audit append failed",
|
||
|
|
zap.String("action", e.Action),
|
||
|
|
zap.Error(err),
|
||
|
|
)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *AuditService) List(ctx context.Context, f domain.AuditLogFilter) ([]domain.AuditLog, int64, error) {
|
||
|
|
return s.repo.List(ctx, f)
|
||
|
|
}
|