Skip to content
Snippets Groups Projects

Create endpoint for retrieving all tags. With test. All tests OK

Merged Håkon Fredrik Fjellanger requested to merge Make_endpoint_for_retrieving_all_tags into main
6 files
+ 125
0
Compare changes
  • Side-by-side
  • Inline
Files
6
package ntnu.idatt2105.quizbackend.controller;
import lombok.AllArgsConstructor;
import ntnu.idatt2105.quizbackend.dto.TagCollectionDTO;
import ntnu.idatt2105.quizbackend.dto.TagDTO;
import ntnu.idatt2105.quizbackend.entity.Tag;
import ntnu.idatt2105.quizbackend.service.TagService;
@@ -71,6 +72,23 @@ public class TagController {
return tagDTOs;
}
/**
* Method for retrieving all tags
* @return a list of TagDTOs belonging to the given question_id
*/
@GetMapping("/api/tag")
public TagCollectionDTO getAllTags() {
List<Tag> tags = tagService.getAllTags();
TagCollectionDTO tagDTOs = new TagCollectionDTO(new ArrayList<>());
for (Tag tag : tags)
tagDTOs.getTags().add(mapToDTO(tag));
return tagDTOs;
}
/**
* Method for mapping a Tag entity to a TagDTO
*
Loading