CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (pull_request) Canceled after 0s
CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (push) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (push) Canceled after 0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (push) Canceled after 0s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (pull_request) Canceled after 0s
CI / Web (dms-browser) (pull_request) Canceled after 0s
Core-Pflichttest-Gate / pflichttest-gate (pull_request) Canceled after 0s
Supply-Chain-Scan (npm) / npm-audit (push) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (pull_request) Canceled after 0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (pull_request) Canceled after 0s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (push) Canceled after 0s
CI / Web (dms-browser) (push) Canceled after 0s
CI / Web (pdf-viewer) (push) Canceled after 0s
CI / Web (shl) (push) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (push) Canceled after 0s
RBAC-Rollenhierarchie-Pflichtgate / rbac-policy-invariant (pull_request) Canceled after 0s
CI / Web (pdf-viewer) (pull_request) Canceled after 0s
CI / Web (shl) (pull_request) Canceled after 0s
Core-Schnittstellen-Vertragstests / contract-tests (pull_request) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (pull_request) Canceled after 0s
Supply-Chain-Scan (npm) / npm-audit (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (push) Canceled after 0s
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
// RTE-03: additive Erweiterungen für den Regel-Editor (Priorisierung,
|
|
// vollständige Liste inkl. deaktivierter Regeln). Verändert keinen
|
|
// bestehenden Code aus RTE-01.
|
|
package routingrule
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// ListAll liefert alle Regeln (aktiviert und deaktiviert), sortiert nach
|
|
// Priorität absteigend — für die Editor-Oberfläche, die im Gegensatz zur
|
|
// Ausführung (RTE-02) auch deaktivierte Regeln zeigen und verwalten muss.
|
|
func (s *Store) ListAll(ctx context.Context) ([]Rule, error) {
|
|
rows, err := s.pool.Query(ctx, `
|
|
SELECT rr.id, rr.name, rr.priority, rr.enabled, rr.active_version, rv.conditions, rv.actions
|
|
FROM routing_rules rr
|
|
JOIN routing_rule_versions rv ON rv.rule_id = rr.id AND rv.version = rr.active_version
|
|
ORDER BY rr.priority DESC, rr.created_at ASC
|
|
`)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("routingrule: regeln auflisten: %w", err)
|
|
}
|
|
defer rows.Close()
|
|
|
|
var out []Rule
|
|
for rows.Next() {
|
|
var r Rule
|
|
var condJSON, actJSON []byte
|
|
if err := rows.Scan(&r.ID, &r.Name, &r.Priority, &r.Enabled, &r.ActiveVersion, &condJSON, &actJSON); err != nil {
|
|
return nil, fmt.Errorf("routingrule: zeile lesen: %w", err)
|
|
}
|
|
if err := json.Unmarshal(condJSON, &r.Conditions); err != nil {
|
|
return nil, fmt.Errorf("routingrule: bedingungen dekodieren: %w", err)
|
|
}
|
|
if err := json.Unmarshal(actJSON, &r.Actions); err != nil {
|
|
return nil, fmt.Errorf("routingrule: aktionen dekodieren: %w", err)
|
|
}
|
|
out = append(out, r)
|
|
}
|
|
return out, rows.Err()
|
|
}
|
|
|
|
// SetPriority ändert nur die Priorität einer Regel (Drag&Drop-Umsortierung
|
|
// in der Oberfläche) ohne eine neue Version anzulegen — Priorität ist keine
|
|
// versionierte Regeleigenschaft, anders als Bedingungen/Aktionen.
|
|
func (s *Store) SetPriority(ctx context.Context, id string, priority int) error {
|
|
tag, err := s.pool.Exec(ctx, `UPDATE routing_rules SET priority = $1 WHERE id = $2`, priority, id)
|
|
if err != nil {
|
|
return fmt.Errorf("routingrule: prioritaet setzen: %w", err)
|
|
}
|
|
if tag.RowsAffected() == 0 {
|
|
return ErrNotFound
|
|
}
|
|
return nil
|
|
}
|