add functionality for group_ids to User class
Co-Authored-By: tomvahl <tomvahl@users.noreply.github.com>
This commit is contained in:
26
src/main/java/mops/gruppen2/service/TeilnehmerService.java
Normal file
26
src/main/java/mops/gruppen2/service/TeilnehmerService.java
Normal file
@ -0,0 +1,26 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TeilnehmerService {
|
||||
GroupService groupService;
|
||||
EventService eventService;
|
||||
|
||||
public TeilnehmerService(GroupService groupService, EventService eventService){
|
||||
this.eventService = eventService;
|
||||
this.groupService = groupService;
|
||||
}
|
||||
|
||||
public void assignGroups(User user){
|
||||
List<Event> events = eventService.findAllEvents();
|
||||
|
||||
for (Event event: events) {
|
||||
if(user.getUser_id().equals(event.getUser_id())) user.addGroup(event.getGroup_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user