|
|
|
@ -60,15 +60,18 @@ public class CollectController {
|
|
|
|
|
).withRel("getAllCollection"));
|
|
|
|
|
}
|
|
|
|
|
@GetMapping(value = "/getAllCollectionsByName/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
public @ResponseBody EntityModel<List<Collect>> getAllCollectionsByName(@PathVariable(value = "name") String name){
|
|
|
|
|
public @ResponseBody CollectionModel<EntityModel<Collect>> getAllCollectionsByName(@PathVariable(value = "name") String name){
|
|
|
|
|
List<Collect> results = collectionService.getAllCollectionsByName(name);
|
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
|
throw new CollectException("No collections available");
|
|
|
|
|
}
|
|
|
|
|
return EntityModel.of(results,
|
|
|
|
|
List<EntityModel<Collect>> collectModels = results.stream()
|
|
|
|
|
.map(collect -> EntityModel.of(collect,
|
|
|
|
|
linkTo(methodOn(CollectController.class).getAllCollectionsByName(name)).withSelfRel(),
|
|
|
|
|
linkTo(methodOn(CollectController.class).getAllCollection()
|
|
|
|
|
).withRel("getAllCollection"));
|
|
|
|
|
).withRel("getAllCollection")))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return CollectionModel.of(collectModels);
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|