1eae6fb6d4
- add /questions/combination-fill endpoint with AI-driven, IP-region-aware matrix fill - extract ip2region resolver from ops/app into shared/ipregion for cross-service use - thread question_id filter through dashboard composite, citation summary, and collect-now - switch template wizard from keyword inputs to brand-question selection (primary + supplemental) - pass brand_question and supplemental_questions through assist/title/outline prompts - add AiWaitingModal + 45s client timeout and request_timeout error mapping for long AI flows Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
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"
|
|
"github.com/geo-platform/tenant-api/internal/shared/ipregion"
|
|
)
|
|
|
|
type AuditService struct {
|
|
repo *repository.AuditRepository
|
|
logger *zap.Logger
|
|
ipRegions *ipregion.Resolver
|
|
}
|
|
|
|
func NewAuditService(repo *repository.AuditRepository, logger *zap.Logger) *AuditService {
|
|
return &AuditService{repo: repo, logger: logger}
|
|
}
|
|
|
|
func (s *AuditService) WithIPRegionResolver(resolver *ipregion.Resolver) *AuditService {
|
|
s.ipRegions = resolver
|
|
return s
|
|
}
|
|
|
|
func (s *AuditService) Append(ctx context.Context, e domain.AuditEvent) error {
|
|
if e.IPRegion == "" && s.ipRegions != nil {
|
|
e.IPRegion = s.ipRegions.Lookup(e.IP)
|
|
}
|
|
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)
|
|
}
|