1

some uuid improvements

This commit is contained in:
Christoph
2020-03-24 14:12:32 +01:00
parent 2eca5e1849
commit c844f5d4fa
3 changed files with 91 additions and 53 deletions

View File

@ -10,7 +10,6 @@ import mops.gruppen2.domain.exception.EventException;
import mops.gruppen2.service.APIFormatterService;
import mops.gruppen2.service.EventService;
import mops.gruppen2.service.GroupService;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -18,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* Ein Beispiel für eine API mit Swagger.
@ -35,7 +35,7 @@ public class APIController {
}
@GetMapping("/updateGroups/{status}")
@Secured("ROLE_api_user")
//@Secured("ROLE_api_user")
@ApiOperation("Gibt alle Gruppen zurück in denen sich etwas geändert hat")
public GroupRequestWrapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException {
List<Event> events = eventService.getNewEvents(status);
@ -44,17 +44,19 @@ public class APIController {
}
@GetMapping("/getGroupIdsOfUser/{teilnehmer}")
@Secured("ROLE_api_user")
//@Secured("ROLE_api_user")
@ApiOperation("Gibt alle Gruppen zurück in denen sich ein Teilnehmer befindet")
public List<UUID> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) {
return eventService.findGroupIdsByUser(teilnehmer);
public List<String> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) {
return eventService.findGroupIdsByUser(teilnehmer).stream()
.map(UUID::toString)
.collect(Collectors.toList());
}
@GetMapping("/getGroup/{groupId}")
@Secured("ROLE_api_user")
//@Secured("ROLE_api_user")
@ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable UUID groupId) throws EventException {
List<Event> eventList = eventService.getEventsOfGroup(groupId);
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable String groupId) throws EventException {
List<Event> eventList = eventService.getEventsOfGroup(UUID.fromString(groupId));
List<Group> groups = groupService.projectEventList(eventList);
return groups.get(0);