quick refactor
This commit is contained in:
@ -32,7 +32,7 @@ public class Gruppen2Application {
|
|||||||
public Docket productAPI() {
|
public Docket productAPI() {
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
.select()
|
.select()
|
||||||
.paths(PathSelectors.ant("/gruppen2/**"))
|
.paths(PathSelectors.ant("/gruppen2/api/**"))
|
||||||
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2"))
|
.apis(RequestHandlerSelectors.basePackage("mops.gruppen2"))
|
||||||
.build()
|
.build()
|
||||||
.apiInfo(apiMetadata());
|
.apiInfo(apiMetadata());
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
* Ein Beispiel für eine API mit Swagger.
|
* Ein Beispiel für eine API mit Swagger.
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/gruppen2")
|
@RequestMapping("/gruppen2/api")
|
||||||
public class APIController {
|
public class APIController {
|
||||||
|
|
||||||
private final SerializationService serializationService;
|
private final SerializationService serializationService;
|
||||||
@ -34,7 +34,7 @@ public class APIController {
|
|||||||
|
|
||||||
@GetMapping("/updateGroups/{status}")
|
@GetMapping("/updateGroups/{status}")
|
||||||
@ApiOperation(value = "Gibt alle Gruppen zurück in denen sich etwas geändert hat")
|
@ApiOperation(value = "Gibt alle Gruppen zurück in denen sich etwas geändert hat")
|
||||||
public UpdatedGroupRequestMapper updateGroup(@ApiParam("Status des Anfragestellers") @PathVariable Long status) throws EventException {
|
public UpdatedGroupRequestMapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException {
|
||||||
List<Event> events = eventService.getNewEvents(status);
|
List<Event> events = eventService.getNewEvents(status);
|
||||||
UpdatedGroupRequestMapper updatedGroupRequestMapper = APIFormatterService.wrapp(eventService.getMaxEvent_id(), groupService.projectEventList(events));
|
UpdatedGroupRequestMapper updatedGroupRequestMapper = APIFormatterService.wrapp(eventService.getMaxEvent_id(), groupService.projectEventList(events));
|
||||||
|
|
||||||
@ -43,13 +43,13 @@ public class APIController {
|
|||||||
|
|
||||||
@GetMapping("/getGroupIdsOfUser/{teilnehmer}")
|
@GetMapping("/getGroupIdsOfUser/{teilnehmer}")
|
||||||
@ApiOperation(value = "Gibt alle Gruppen zurück in denen sich ein Teilnehmer befindet")
|
@ApiOperation(value = "Gibt alle Gruppen zurück in denen sich ein Teilnehmer befindet")
|
||||||
public List<Long> getGroupsOfUser(@ApiParam("Der Teilnehmer") @PathVariable String teilnehmer) throws EventException {
|
public List<Long> getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) throws EventException {
|
||||||
return eventService.getGroupsOfUser(teilnehmer);
|
return eventService.getGroupsOfUser(teilnehmer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getGroup/{groupId}")
|
@GetMapping("/getGroup/{groupId}")
|
||||||
@ApiOperation(value = "Gibt alle die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
@ApiOperation(value = "Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück")
|
||||||
public Group getGroupFromId(@ApiParam("Die GruppenId der gefordeten Gruppe") @PathVariable Long groupId) throws EventException{
|
public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable Long groupId) throws EventException{
|
||||||
List<Event> eventList = eventService.getEventsOfGroup(groupId);
|
List<Event> eventList = eventService.getEventsOfGroup(groupId);
|
||||||
|
|
||||||
List<Group> groups = groupService.projectEventList(eventList);
|
List<Group> groups = groupService.projectEventList(eventList);
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class Group extends Aggregate {
|
|||||||
private String title;
|
private String title;
|
||||||
private String description;
|
private String description;
|
||||||
private final List<User> members;
|
private final List<User> members;
|
||||||
private final Map<User, Role> roles;
|
private final Map<String, Role> roles;
|
||||||
|
|
||||||
private GroupType type;
|
private GroupType type;
|
||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
@ -51,7 +51,7 @@ public class Group extends Aggregate {
|
|||||||
if (roles.containsKey(user) && event.getNewRole() == Role.MEMBER) {
|
if (roles.containsKey(user) && event.getNewRole() == Role.MEMBER) {
|
||||||
roles.remove(user);
|
roles.remove(user);
|
||||||
} else {
|
} else {
|
||||||
roles.put(user, event.getNewRole());
|
roles.put(user.getUser_id(), event.getNewRole());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,7 +115,7 @@ class GroupTest {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertThat(group.getRoles())
|
assertThat(group.getRoles())
|
||||||
.containsOnlyKeys(group.getMembers().get(0))
|
.containsOnlyKeys(group.getMembers().get(0).getUser_id())
|
||||||
.containsValue(Role.ADMIN);
|
.containsValue(Role.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user