add functionality for group_ids to User class
Co-Authored-By: tomvahl <tomvahl@users.noreply.github.com>
This commit is contained in:
@ -5,6 +5,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Value
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
||||
@ -15,4 +17,10 @@ public class User {
|
||||
String givenname;
|
||||
String familyname;
|
||||
String email;
|
||||
|
||||
List<Long> group_ids;
|
||||
|
||||
public void addGroup(Long group_id){
|
||||
group_ids.add(group_id);
|
||||
}
|
||||
}
|
||||
|
||||
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