Security Check requested
This commit is contained in:
@@ -78,6 +78,16 @@ public class TerminalController {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<?> updateTerminal(@PathVariable Long id, @jakarta.validation.Valid @RequestBody Terminal terminalDetails) {
|
||||
Terminal updated = terminalService.updateTerminal(id, terminalDetails);
|
||||
if (updated != null) {
|
||||
return ResponseEntity.ok(updated);
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// Order Lookup (ESP32 uses X-API-KEY)
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -43,4 +43,16 @@ public class TerminalService {
|
||||
terminalRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
public Terminal updateTerminal(Long id, Terminal details) {
|
||||
if (id == null) return null;
|
||||
return terminalRepository.findById(id).map(existing -> {
|
||||
existing.setName(details.getName());
|
||||
existing.setLocation(details.getLocation());
|
||||
if (details.getPin() != null && !details.getPin().trim().isEmpty()) {
|
||||
existing.setPin(details.getPin().trim());
|
||||
}
|
||||
return terminalRepository.save(existing);
|
||||
}).orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user