Enforce ResponseEntity returns on controllers
This commit is contained in:
parent
8e89720f91
commit
da118b40d3
@ -19,8 +19,10 @@ public class GalleryController {
|
||||
private GalleryRepository galleryRepository;
|
||||
|
||||
@GetMapping()
|
||||
public List<Gallery> getAllGalleries() {
|
||||
return galleryRepository.findAll();
|
||||
public ResponseEntity<List<Gallery>> getAllGalleries() {
|
||||
List<Gallery> galleries = galleryRepository.findAll();
|
||||
|
||||
return ResponseEntity.ok(galleries);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ -31,8 +33,10 @@ public class GalleryController {
|
||||
}
|
||||
|
||||
@GetMapping("/server/{id}")
|
||||
public List<Gallery> getGalleriesByServer(@PathVariable(value = "id") String serverId) {
|
||||
return galleryRepository.findAllByServer(serverId);
|
||||
public ResponseEntity<List<Gallery>> getGalleriesByServer(@PathVariable(value = "id") String serverId) {
|
||||
List<Gallery> galleries = galleryRepository.findAllByServer(serverId);
|
||||
|
||||
return ResponseEntity.ok(galleries);
|
||||
}
|
||||
|
||||
@GetMapping("/server/{serverId}/channel/{channelId}")
|
||||
@ -43,8 +47,10 @@ public class GalleryController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
public Gallery createGallery(@Valid @RequestBody Gallery gallery) {
|
||||
return galleryRepository.save(gallery);
|
||||
public ResponseEntity<Gallery> createGallery(@Valid @RequestBody Gallery gallery) {
|
||||
Gallery createdGallery = galleryRepository.save(gallery);
|
||||
|
||||
return ResponseEntity.ok(createdGallery);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@ -63,7 +69,7 @@ public class GalleryController {
|
||||
return ResponseEntity.ok(updatedGallery);
|
||||
}
|
||||
|
||||
@DeleteMapping()
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Map<String, Boolean>> deleteGallery(@PathVariable(value = "id") Long galleryId) throws ResourceNotFoundException {
|
||||
Gallery gallery = galleryRepository.findById(galleryId).orElseThrow(() -> new ResourceNotFoundException("Gallery not found for id :: " + galleryId));
|
||||
|
||||
|
@ -20,8 +20,10 @@ public class OutfitController {
|
||||
private OutfitRepository outfitRepository;
|
||||
|
||||
@GetMapping()
|
||||
public List<Outfit> getAllOutfits() {
|
||||
return outfitRepository.findAll();
|
||||
public ResponseEntity<List<Outfit>> getAllOutfits() {
|
||||
List<Outfit> outfits = outfitRepository.findAll();
|
||||
|
||||
return ResponseEntity.ok(outfits);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ -39,8 +41,10 @@ public class OutfitController {
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
public Outfit createOutfit(@Valid @RequestBody Outfit outfit) {
|
||||
return outfitRepository.save(outfit);
|
||||
public ResponseEntity<Outfit> createOutfit(@Valid @RequestBody Outfit newOutfit) {
|
||||
Outfit outfit = outfitRepository.save(newOutfit);
|
||||
|
||||
return ResponseEntity.ok(outfit);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@ -66,12 +70,12 @@ public class OutfitController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public Map<String, Boolean> deleteOutfit(@PathVariable(value = "id") String outfitId) throws ResourceNotFoundException {
|
||||
public ResponseEntity<Map<String, Boolean>> deleteOutfit(@PathVariable(value = "id") String outfitId) throws ResourceNotFoundException {
|
||||
Outfit outfit = outfitRepository.findById(outfitId).orElseThrow(() -> new ResourceNotFoundException("Outfit not found for id :: " + outfitId));
|
||||
|
||||
outfitRepository.delete(outfit);
|
||||
Map<String, Boolean> response = new HashMap<>();
|
||||
response.put("deleted", Boolean.TRUE);
|
||||
return response;
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user