Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Api("places")
@RestController
@RequestMapping("places")
public class PlaceController {

@Autowired
private PlaceService service;

@PostMapping
Expand All @@ -44,6 +47,16 @@ public ResponseEntity findAll() {
return ResponseEntity.ok(places);
}

@GetMapping("/")
public ResponseEntity findByName(@RequestParam(value = "name") String name) {
List<Place> result = service.findByName(name);
if (result.isEmpty()) {
return ResponseEntity.notFound().build();
} else {
return ResponseEntity.ok(result);
}
}

@PutMapping("/{id}")
public ResponseEntity alter(@PathVariable Long id, @RequestBody @Valid PlaceDTO placeDTO) {
Place place = service.findById(id).orElseThrow(null);
Expand Down