1

add Event related stuff and Group example

This commit is contained in:
killerber4t
2020-03-06 14:20:04 +01:00
parent 2ba8176500
commit 75143b33c0
11 changed files with 82 additions and 18 deletions

View File

@ -1,4 +0,0 @@
package mops.gruppen2.DTO;
public class Event {
}

View File

@ -0,0 +1,17 @@
package mops.gruppen2.Events;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
@Getter
public class CreateGroupEvent extends Event{
String titel;
String beschreibung;
public CreateGroupEvent(Long id, Long gruppe_id, Long user_id, String titel,String beschreibung) {
super(id, gruppe_id, user_id);
this.titel = titel;
this.beschreibung = beschreibung;
}
}

View File

@ -0,0 +1,15 @@
package mops.gruppen2.Events;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.data.annotation.Id;
@Getter
@AllArgsConstructor
public class Event {
@Id
Long id;
Long gruppe_id;
Long user_id;
}

View File

@ -2,8 +2,10 @@ package mops.gruppen2.controllers;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import mops.gruppen2.security.Account; import mops.gruppen2.security.Account;
import mops.gruppen2.services.GruppenService;
import org.keycloak.KeycloakPrincipal; import org.keycloak.KeycloakPrincipal;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -12,6 +14,8 @@ import org.springframework.web.context.annotation.SessionScope;
@SessionScope @SessionScope
@Controller @Controller
public class Gruppen2Controller { public class Gruppen2Controller {
@Autowired
GruppenService gruppenService;
/** /**
* Creates an Account. * Creates an Account.
* *

View File

@ -1,4 +1,4 @@
package mops.gruppen2.entities; package mops.gruppen2.entities;
public class Admin extends Teilnehmer{ public class Admin extends Rolle {
} }

View File

@ -1,6 +1,8 @@
package mops.gruppen2.entities; package mops.gruppen2.entities;
import lombok.Data; import lombok.Data;
import mops.gruppen2.Events.CreateGroupEvent;
import mops.gruppen2.Events.Event;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import java.util.List; import java.util.List;
@ -12,4 +14,16 @@ public class Gruppe {
String titel; String titel;
String beschreibung; String beschreibung;
List<Teilnehmer> teilnehmersList; List<Teilnehmer> teilnehmersList;
public void applyEvent(Event event){
}
public void applyEvent(CreateGroupEvent event){
this.id = event.getId();
this.titel = event.getTitel();
this.beschreibung = event.getBeschreibung();
this.teilnehmersList= null;
}
} }

View File

@ -0,0 +1,4 @@
package mops.gruppen2.entities;
public class Orga extends Rolle {
}

View File

@ -0,0 +1,5 @@
package mops.gruppen2.entities;
public class Rolle {
}

View File

@ -1,10 +0,0 @@
package mops.gruppen2.entities;
import lombok.Data;
import org.springframework.data.annotation.Id;
import java.util.List;
public class Student extends Teilnehmer{
}

View File

@ -1,6 +1,6 @@
package mops.gruppen2.repositories; package mops.gruppen2.repositories;
import mops.gruppen2.DTO.Event; import mops.gruppen2.Events.Event;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
public interface EventRepository extends CrudRepository<Event, Long> { public interface EventRepository extends CrudRepository<Event, Long> {

View File

@ -1,10 +1,29 @@
package mops.gruppen2.services; package mops.gruppen2.services;
import mops.gruppen2.Events.CreateGroupEvent;
import mops.gruppen2.Events.Event;
import mops.gruppen2.entities.Gruppe;
import mops.gruppen2.repositories.EventRepository; import mops.gruppen2.repositories.EventRepository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class GruppenService { public class GruppenService {
public GruppenService(EventRepository eventRepository){ CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,1L,"hello", "foo");
public GruppenService(){
List<Event> eventList = new ArrayList<>();
eventList.add(createGroupEvent);
Gruppe newGroup = buildGroup(eventList);
System.out.println(newGroup.toString());
}
Gruppe buildGroup(List<Event> eventList){
Gruppe newGroup = new Gruppe();
eventList.forEach(newGroup::applyEvent);
return newGroup;
} }
} }