Initial commit with basic CRUD functionality:

* GET all properties
* GET one property by id
* CREATE one property
* DELETE one property by id
This commit is contained in:
2025-08-25 14:06:29 +02:00
commit 7be4c611b3
19 changed files with 867 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
package de.iwomm.propify_api.controller;
import de.iwomm.propify_api.entity.Property;
import de.iwomm.propify_api.service.PropertyService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@RestController
@RequestMapping("/api/v1/properties")
public class PropertyController {
private final PropertyService propertyService;
public PropertyController(PropertyService propertyService) {
this.propertyService = propertyService;
}
@GetMapping
public List<Property> getAllProperties() {
return propertyService.findAll();
}
@GetMapping("/{id}")
public Property getPropertyById(@PathVariable UUID id) {
return propertyService.findById(id).orElse(null);
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Property createProperty(@RequestBody Property property) {
return propertyService.save(property);
}
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteProperty(@PathVariable UUID id) {
Optional<Property> property = propertyService.findById(id);
if (property.isEmpty()) {
return;
}
propertyService.delete(property.get());
}
}