1

add leaving group

Co-Authored-By: xxnitram <xxnitram@users.noreply.github.com>
This commit is contained in:
killerber4t
2020-03-17 14:36:55 +01:00
parent 1acfcc449f
commit 61e007e4d8
5 changed files with 46 additions and 20 deletions

View File

@ -2,13 +2,14 @@ package mops.gruppen2.service;
import mops.gruppen2.domain.Exceptions.EventException;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
//Hallo
@Service
public class UserService {
@ -22,10 +23,17 @@ public class UserService {
//Test nötig??
public List<Group> getUserGroups(String user_id) throws EventException {
List<Long> group_ids = eventRepository.findGroup_idsWhereUser_id(user_id);
public List<Group> getUserGroups(User user) throws EventException {
List<Long> group_ids = eventRepository.findGroup_idsWhereUser_id(user.getUser_id());
List<Event> events = groupService.getGroupEvents(group_ids);
return groupService.projectEventList(events);
List<Group> groups = groupService.projectEventList(events);
List<Group> newGroups = new ArrayList<>();
for (Group group: groups) {
if(group.getMembers().contains(user)){
newGroups.add(group);
}
}
return newGroups;
}
public Group getGroupById(Long group_id) throws EventException {