add Event related stuff and Group example
This commit is contained in:
@ -1,4 +0,0 @@
|
||||
package mops.gruppen2.DTO;
|
||||
|
||||
public class Event {
|
||||
}
|
||||
17
src/main/java/mops/gruppen2/Events/CreateGroupEvent.java
Normal file
17
src/main/java/mops/gruppen2/Events/CreateGroupEvent.java
Normal 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;
|
||||
}
|
||||
}
|
||||
15
src/main/java/mops/gruppen2/Events/Event.java
Normal file
15
src/main/java/mops/gruppen2/Events/Event.java
Normal 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;
|
||||
|
||||
}
|
||||
@ -2,8 +2,10 @@ package mops.gruppen2.controllers;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import mops.gruppen2.security.Account;
|
||||
import mops.gruppen2.services.GruppenService;
|
||||
import org.keycloak.KeycloakPrincipal;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -12,6 +14,8 @@ import org.springframework.web.context.annotation.SessionScope;
|
||||
@SessionScope
|
||||
@Controller
|
||||
public class Gruppen2Controller {
|
||||
@Autowired
|
||||
GruppenService gruppenService;
|
||||
/**
|
||||
* Creates an Account.
|
||||
*
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
public class Admin extends Teilnehmer{
|
||||
public class Admin extends Rolle {
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
import lombok.Data;
|
||||
import mops.gruppen2.Events.CreateGroupEvent;
|
||||
import mops.gruppen2.Events.Event;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,4 +14,16 @@ public class Gruppe {
|
||||
String titel;
|
||||
String beschreibung;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
src/main/java/mops/gruppen2/entities/Orga.java
Normal file
4
src/main/java/mops/gruppen2/entities/Orga.java
Normal file
@ -0,0 +1,4 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
public class Orga extends Rolle {
|
||||
}
|
||||
5
src/main/java/mops/gruppen2/entities/Rolle.java
Normal file
5
src/main/java/mops/gruppen2/entities/Rolle.java
Normal file
@ -0,0 +1,5 @@
|
||||
package mops.gruppen2.entities;
|
||||
|
||||
public class Rolle {
|
||||
|
||||
}
|
||||
@ -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{
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package mops.gruppen2.repositories;
|
||||
|
||||
import mops.gruppen2.DTO.Event;
|
||||
import mops.gruppen2.Events.Event;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface EventRepository extends CrudRepository<Event, Long> {
|
||||
|
||||
@ -1,10 +1,29 @@
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user