Phase1 Bearbeitung
This commit is contained in:
@@ -22,7 +22,7 @@ final class RfidService
|
||||
$token = bin2hex(random_bytes(20));
|
||||
$statement = $this->pdo->prepare(
|
||||
'INSERT INTO rfid_devices (tenant_id, name, location_label, device_token, status)
|
||||
VALUES (:tenant_id, :name, :location_label, :device_token, "planned")'
|
||||
VALUES (:tenant_id, :name, :location_label, :device_token, "active")'
|
||||
);
|
||||
$statement->execute([
|
||||
'tenant_id' => $tenantId,
|
||||
@@ -43,6 +43,18 @@ final class RfidService
|
||||
throw new RuntimeException('Die Karten-UID darf nicht leer sein.');
|
||||
}
|
||||
|
||||
$memberStatement = $this->pdo->prepare(
|
||||
'SELECT id FROM members WHERE tenant_id = :tenant_id AND id = :id AND status = "active" LIMIT 1'
|
||||
);
|
||||
$memberStatement->execute([
|
||||
'tenant_id' => $tenantId,
|
||||
'id' => $memberId,
|
||||
]);
|
||||
|
||||
if (!$memberStatement->fetchColumn()) {
|
||||
throw new RuntimeException('Das ausgewaehlte Mitglied ist fuer RFID nicht verfuegbar.');
|
||||
}
|
||||
|
||||
$statement = $this->pdo->prepare(
|
||||
'INSERT INTO rfid_tags (tenant_id, member_id, uid_hash, label, status)
|
||||
VALUES (:tenant_id, :member_id, :uid_hash, :label, "active")'
|
||||
@@ -80,6 +92,10 @@ final class RfidService
|
||||
throw new RuntimeException('Das RFID-Geraet ist unbekannt.');
|
||||
}
|
||||
|
||||
if (($device['status'] ?? '') !== 'active') {
|
||||
throw new RuntimeException('Das RFID-Geraet ist nicht aktiv.');
|
||||
}
|
||||
|
||||
$status = 'received';
|
||||
$tagStatement = $this->pdo->prepare(
|
||||
'SELECT id FROM rfid_tags WHERE tenant_id = :tenant_id AND uid_hash = :uid_hash LIMIT 1'
|
||||
|
||||
Reference in New Issue
Block a user