1

added Creating Groups to frontend and saving them in Database. Also prepared some Methods for Snapshot db

This commit is contained in:
killerber4t
2020-03-09 23:21:29 +01:00
parent 006822b57d
commit 61e2d0edba
16 changed files with 120 additions and 38 deletions

View File

@ -1,22 +1,29 @@
package mops.gruppen2.controller;
import mops.gruppen2.domain.event.CreateGroupEvent;
import mops.gruppen2.service.EventService;
import mops.gruppen2.service.GroupService;
import mops.gruppen2.service.KeyCloakService;
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.RolesAllowed;
import javax.swing.*;
@Controller
@RequestMapping("/gruppen2")
public class Gruppen2Controller {
private final KeyCloakService keyCloakService;
private final EventService eventService;
private final GroupService groupService;
public Gruppen2Controller(KeyCloakService keyCloakService) {
public Gruppen2Controller(KeyCloakService keyCloakService, EventService eventService, GroupService groupService) {
this.keyCloakService = keyCloakService;
this.eventService = eventService;
this.groupService = groupService;
}
/**Zeigt die index.html an.
@ -46,5 +53,17 @@ public class Gruppen2Controller {
return "search";
}
@PostMapping("/createGroup")
public String pCreateGroup(KeycloakAuthenticationToken token,
@RequestParam(value = "title") String title,
@RequestParam(value = "beschreibung") String beschreibung) {
//Hier muss alles in eine separate Klasse
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "faker", title, beschreibung);
eventService.saveEvent(createGroupEvent);
groupService.buildGroupFromEvent(createGroupEvent);
return "redirect:/";
}
}