1

Merge remote-tracking branch 'origin/event-db'

# Conflicts:
#	src/main/java/mops/gruppen2/domain/Aggregate.java
#	src/main/java/mops/gruppen2/service/GroupService.java
#	src/test/java/mops/gruppen2/domain/GroupTest.java
This commit is contained in:
Christoph
2020-03-10 13:24:29 +01:00
20 changed files with 520 additions and 48 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.
@ -31,4 +38,32 @@ public class Gruppen2Controller {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
return "index";
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@GetMapping("/createGroup")
public String createGroup(KeycloakAuthenticationToken token, Model model) {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
return "create";
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@GetMapping("/findGroup")
public String findGroup(KeycloakAuthenticationToken token, Model model) {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
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:/";
}
}

View File

@ -1,10 +1,13 @@
package mops.gruppen2.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.javafaker.Faker;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import mops.gruppen2.domain.ProductSwaggerExample;
import mops.gruppen2.domain.event.AddUserEvent;
import mops.gruppen2.service.SerializationService;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@ -19,6 +22,11 @@ public class SwaggerAPIController {
private final Faker faker = new Faker();
private final List<ProductSwaggerExample> products = new ArrayList<>();
private final SerializationService serializationService;
public SwaggerAPIControllerExample(SerializationService serializationService) {
this.serializationService = serializationService;
}
@GetMapping("/get/all")
@ApiOperation(value = "Erzeugt eine Liste mit allen gespeicherten Produkten")
@ -44,4 +52,5 @@ public class SwaggerAPIController {
return "Product saved successfully";
}
}