Add routers table, entity, repository and GET endpoint

This commit is contained in:
litoral05
2026-05-05 10:11:09 +01:00
parent 2b74db43dd
commit 5301ba1b28
4 changed files with 62 additions and 0 deletions
@@ -0,0 +1,24 @@
package com.litoralregas.openvpn.router;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;
@Entity
@Table(name = "routers")
public class Router {
@Id
private UUID id;
private String name;
private String serialNumber;
private String lanIp;
private String lanSubnet;
private String status;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
// getters and setters (for now, no Lombok)
}
@@ -0,0 +1,21 @@
package com.litoralregas.openvpn.router;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/routers")
public class RouterController {
private final RouterRepository repository;
public RouterController(RouterRepository repository) {
this.repository = repository;
}
@GetMapping
public List<Router> getAll() {
return repository.findAll();
}
}
@@ -0,0 +1,7 @@
package com.litoralregas.openvpn.router;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.UUID;
public interface RouterRepository extends JpaRepository<Router, UUID> {
}
@@ -0,0 +1,10 @@
CREATE TABLE routers (
id UUID PRIMARY KEY,
name VARCHAR(120) NOT NULL,
serial_number VARCHAR(120),
lan_ip VARCHAR(50) NOT NULL,
lan_subnet VARCHAR(50) NOT NULL,
status VARCHAR(40) NOT NULL DEFAULT 'PENDING',
created_at TIMESTAMP NOT NULL DEFAULT now(),
updated_at TIMESTAMP NOT NULL DEFAULT now()
);