correctif de bug

Maxime
Maxime POINT 1 year ago
parent e2cf019437
commit 9b528b8e95

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

@ -127,9 +127,9 @@ public class StubCollectionService implements ICollectionService {
// region Article // region Article
@Override @Override
public List<Article> getAllArticlesById(Integer id){ public List<Article> getAllArticlesById(Integer id){
List<Article> result = new ArrayList<>();
Collect collect = getCollectionById(id); Collect collect = getCollectionById(id);
if (result.addAll(collect.getAllArticles())){ List<Article> result = collect.getAllArticles();
if(!result.isEmpty()){
return result; return result;
} }
return null; return null;

Loading…
Cancel
Save