Skip to content

Commit

Permalink
Remove get all groups endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fizzy-fifs committed Oct 25, 2024
1 parent 9ccf17b commit a712466
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
28 changes: 12 additions & 16 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public ResponseEntity<Object> create(@RequestBody @Valid Group group, Errors err
return groupService.create(group);
}

@GetMapping
@Operation(summary = "Get a list of all groups")
public List<Group> getAll() { return groupService.getAll();}


@DeleteMapping(path = "/{groupId}")
public ResponseEntity<String> delete(@PathVariable("groupId") String groupId) {
return groupService.delete(groupId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ResponseEntity<Object> create(Group group) throws JsonProcessingException

userIds.add(groupCreator.getId());

List<User> users = userRepository.findAllById(userIds);
List<User> users = userService.findMultipleUsersByIdInCacheOrDatabase(userIds);

if (users.size() != userIds.size()) {
return ResponseEntity.badRequest().body("One of the users added does not exist");
Expand Down Expand Up @@ -101,18 +101,14 @@ public ResponseEntity<Object> create(Group group) throws JsonProcessingException
}
}

userRepository.saveAll(users);
userService.updateMultipleUsersInCacheAndDatabase(users);

ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
String groupJson = mapper.writeValueAsString(newGroup);

return ResponseEntity.ok(groupJson);
}

public List<Group> getAll() {
return groupRepository.findAll();
}

public ResponseEntity<String> delete(String groupId) {

Group group = findSingleGroupByIdInCacheOrDatabase(groupId);
Expand Down

0 comments on commit a712466

Please sign in to comment.