@ -1,22 +1,29 @@
|
|||||||
package mops.gruppen2.controller;
|
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 mops.gruppen2.service.KeyCloakService;
|
||||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||||
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.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/gruppen2")
|
@RequestMapping("/gruppen2")
|
||||||
public class Gruppen2Controller {
|
public class Gruppen2Controller {
|
||||||
|
|
||||||
private final KeyCloakService keyCloakService;
|
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.keyCloakService = keyCloakService;
|
||||||
|
this.eventService = eventService;
|
||||||
|
this.groupService = groupService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Zeigt die index.html an.
|
/**Zeigt die index.html an.
|
||||||
@ -31,4 +38,32 @@ public class Gruppen2Controller {
|
|||||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||||
return "index";
|
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:/";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package mops.gruppen2.domain;
|
package mops.gruppen2.domain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Value;
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.relational.core.mapping.Table;
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
@ -9,8 +8,8 @@ import org.springframework.data.relational.core.mapping.Table;
|
|||||||
@Data
|
@Data
|
||||||
public class EventDTO {
|
public class EventDTO {
|
||||||
@Id
|
@Id
|
||||||
long event_id;
|
Long event_id;
|
||||||
long group_id;
|
Long group_id;
|
||||||
String user_id;
|
String user_id;
|
||||||
String event_payload;
|
String event_payload;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,14 +16,14 @@ public class AddUserEvent extends Event {
|
|||||||
String familyname;
|
String familyname;
|
||||||
String email;
|
String email;
|
||||||
|
|
||||||
public AddUserEvent(long event_id, long group_id, String user_id, String givenname, String familyname, String email) {
|
public AddUserEvent(Long event_id, Long group_id, String user_id, String givenname, String familyname, String email) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
this.givenname = givenname;
|
this.givenname = givenname;
|
||||||
this.familyname = familyname;
|
this.familyname = familyname;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddUserEvent(long event_id, long group_id, User user) {
|
public AddUserEvent(Long event_id, Long group_id, User user) {
|
||||||
super(event_id, group_id, user.getUser_id());
|
super(event_id, group_id, user.getUser_id());
|
||||||
this.givenname = user.getGivenname();
|
this.givenname = user.getGivenname();
|
||||||
this.familyname = user.getFamilyname();
|
this.familyname = user.getFamilyname();
|
||||||
|
|||||||
@ -11,9 +11,14 @@ public class CreateGroupEvent extends Event {
|
|||||||
String groupTitle;
|
String groupTitle;
|
||||||
String groupDescription;
|
String groupDescription;
|
||||||
|
|
||||||
public CreateGroupEvent(long event_id, long group_id, String user_id, String groupTitle, String groupDescription) {
|
public CreateGroupEvent(long event_id, Long group_id, String user_id, String groupTitle, String groupDescription) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
this.groupTitle = groupTitle;
|
this.groupTitle = groupTitle;
|
||||||
this.groupDescription = groupDescription;
|
this.groupDescription = groupDescription;
|
||||||
}
|
}
|
||||||
|
public CreateGroupEvent(Long group_id, String user_id, String groupTitle, String groupDescription) {
|
||||||
|
super(group_id, user_id);
|
||||||
|
this.groupTitle = groupTitle;
|
||||||
|
this.groupDescription = groupDescription;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import lombok.*;
|
|||||||
@Getter
|
@Getter
|
||||||
public class DeleteUserEvent extends Event {
|
public class DeleteUserEvent extends Event {
|
||||||
|
|
||||||
public DeleteUserEvent(long event_id, long group_id, String user_id) {
|
public DeleteUserEvent(Long event_id, Long group_id, String user_id) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,14 +17,19 @@ import lombok.NoArgsConstructor;
|
|||||||
)
|
)
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "AddUserEvent"),
|
@JsonSubTypes.Type(value = AddUserEvent.class, name = "AddUserEvent"),
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "CreateGroupEvent"),
|
@JsonSubTypes.Type(value = CreateGroupEvent.class, name = "CreateGroupEvent"),
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "DeleteUserEvent"),
|
@JsonSubTypes.Type(value = DeleteUserEvent.class, name = "DeleteUserEvent"),
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "UpdateGroupDescriptionEvent"),
|
@JsonSubTypes.Type(value = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "UpdateGroupTitleEvent"),
|
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "UpdateRoleEvent"),
|
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||||
})
|
})
|
||||||
public class Event {
|
public class Event {
|
||||||
long event_id;
|
Long event_id;
|
||||||
long group_id;
|
Long group_id;
|
||||||
String user_id;
|
String user_id;
|
||||||
|
|
||||||
|
public Event(Long group_id,String user_id){
|
||||||
|
this.group_id = group_id;
|
||||||
|
this.user_id = user_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||||||
public class UpdateGroupDescriptionEvent extends Event {
|
public class UpdateGroupDescriptionEvent extends Event {
|
||||||
String newGroupDescription;
|
String newGroupDescription;
|
||||||
|
|
||||||
public UpdateGroupDescriptionEvent(long event_id, long group_id, String user_id, String newGroupDescription) {
|
public UpdateGroupDescriptionEvent(Long event_id, Long group_id, String user_id, String newGroupDescription) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
this.newGroupDescription = newGroupDescription;
|
this.newGroupDescription = newGroupDescription;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||||||
public class UpdateGroupTitleEvent extends Event {
|
public class UpdateGroupTitleEvent extends Event {
|
||||||
String newGroupTitle;
|
String newGroupTitle;
|
||||||
|
|
||||||
public UpdateGroupTitleEvent(long event_id, long group_id, String user_id, String newGroupTitle) {
|
public UpdateGroupTitleEvent(Long event_id, Long group_id, String user_id, String newGroupTitle) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
this.newGroupTitle = newGroupTitle;
|
this.newGroupTitle = newGroupTitle;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ public class UpdateRoleEvent extends Event {
|
|||||||
|
|
||||||
Role newRole;
|
Role newRole;
|
||||||
|
|
||||||
public UpdateRoleEvent(long event_id, long group_id, String user_id, Role newRole) {
|
public UpdateRoleEvent(Long event_id, Long group_id, String user_id, Role newRole) {
|
||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
|
|
||||||
this.newRole = newRole;
|
this.newRole = newRole;
|
||||||
|
|||||||
51
src/main/java/mops/gruppen2/service/EventService.java
Normal file
51
src/main/java/mops/gruppen2/service/EventService.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package mops.gruppen2.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import mops.gruppen2.domain.EventDTO;
|
||||||
|
import mops.gruppen2.domain.event.Event;
|
||||||
|
import mops.gruppen2.repository.EventRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EventService {
|
||||||
|
private final SerializationService serializationService;
|
||||||
|
private final EventRepository eventStore;
|
||||||
|
|
||||||
|
public EventService(SerializationService serializationService, EventRepository eventStore) {
|
||||||
|
this.serializationService = serializationService;
|
||||||
|
this.eventStore = eventStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void saveEvent(Event event){
|
||||||
|
EventDTO eventDTO = getDTO(event);
|
||||||
|
eventStore.save(eventDTO);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventDTO getDTO(Event event){
|
||||||
|
EventDTO eventDTO = new EventDTO();
|
||||||
|
eventDTO.setGroup_id(event.getGroup_id());
|
||||||
|
eventDTO.setUser_id(event.getUser_id());
|
||||||
|
try {
|
||||||
|
eventDTO.setEvent_payload(serializationService.serializeEvent(event));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return eventDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long checkGroup() {
|
||||||
|
Long tmpId = 1L;
|
||||||
|
Iterable<EventDTO> eventDTOS = eventStore.findAll();
|
||||||
|
for (EventDTO event : eventDTOS) {
|
||||||
|
if (event.getGroup_id() == null) {
|
||||||
|
return tmpId;
|
||||||
|
}
|
||||||
|
if (tmpId <= event.getGroup_id()) {
|
||||||
|
tmpId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmpId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import mops.gruppen2.domain.Group;
|
|||||||
import mops.gruppen2.domain.event.Event;
|
import mops.gruppen2.domain.event.Event;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -15,9 +16,17 @@ public class GroupService {
|
|||||||
* @param eventList Die Events für diese Gruppe
|
* @param eventList Die Events für diese Gruppe
|
||||||
* @return Gruppe auf aktuellem Stand
|
* @return Gruppe auf aktuellem Stand
|
||||||
*/
|
*/
|
||||||
Group buildGroupFromEvents(List<Event> eventList) {
|
public Group buildGroupFromEvents(List<Event> eventList) {
|
||||||
Group newGroup = new Group();
|
Group newGroup = new Group();
|
||||||
newGroup.apply(eventList);
|
newGroup.apply(eventList);
|
||||||
return newGroup;
|
return newGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Group buildGroupFromEvent(Event event){
|
||||||
|
Group newGroup = new Group();
|
||||||
|
List<Event> eventList = new ArrayList<>();
|
||||||
|
eventList.add(event);
|
||||||
|
newGroup.apply(eventList);
|
||||||
|
return newGroup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,21 +27,6 @@ public class SerializationService {
|
|||||||
return mapper.writeValueAsString(event);
|
return mapper.writeValueAsString(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// create DTO methode schreiben also kurz auslagern
|
|
||||||
public void saveEvent(Event event){
|
|
||||||
try {
|
|
||||||
EventDTO eventDTO = new EventDTO();
|
|
||||||
eventDTO.setGroup_id(event.getGroup_id());
|
|
||||||
eventDTO.setUser_id(event.getUser_id());
|
|
||||||
eventDTO.setEvent_payload(serializeEvent(event));
|
|
||||||
eventStore.save(eventDTO);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Event deserializeEvent(String json) throws JsonProcessingException {
|
public Event deserializeEvent(String json) throws JsonProcessingException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
return mapper.readValue(json, Event.class);
|
return mapper.readValue(json, Event.class);
|
||||||
|
|||||||
50
src/main/resources/templates/create.html
Normal file
50
src/main/resources/templates/create.html
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||||
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Name des Subsystems</title>
|
||||||
|
<th:block th:fragment="headcontent">
|
||||||
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
|
</th:block>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||||
|
</li>
|
||||||
|
<li class="active">
|
||||||
|
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main th:fragment="bodycontent">
|
||||||
|
<h1>Gruppenerstellung</h1>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<form method="post" action="/gruppen2/createGroup">
|
||||||
|
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="titel">Name der Gruppe</label>
|
||||||
|
<input type="text" class="form-control" id="titel" th:name="title">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="beschreibung">Beschreibung der Gruppe</label>
|
||||||
|
<textarea type="text" class="form-control" id="beschreibung" th:name="beschreibung">
|
||||||
|
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit">Erstellen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||||
th:replace="~{mopslayout :: html(name='Name des Subsystems', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Name des Subsystems</title>
|
<title>Name des Subsystems</title>
|
||||||
@ -10,12 +10,30 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||||
<!-- Navigation als ungeordnete Liste mit einfachen Links hier einfügen! -->
|
<ul>
|
||||||
</nav>
|
<li class="active">
|
||||||
|
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main th:fragment="bodycontent">
|
<main th:fragment="bodycontent">
|
||||||
<!-- Restlichen Inhalt hier einfügen! -->
|
<h1>Meine Gruppen</h1>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<form action="/" method="get">
|
||||||
|
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
|
<h4 style="color: dodgerblue; font-weight: bold">Titel der Gruppe</h4>
|
||||||
|
<p>Beschreibung der Gruppe ...</p>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
81
src/main/resources/templates/search.html
Normal file
81
src/main/resources/templates/search.html
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||||
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Name des Subsystems</title>
|
||||||
|
<th:block th:fragment="headcontent">
|
||||||
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
|
</th:block>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||||
|
</li>
|
||||||
|
<li class="active">
|
||||||
|
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main th:fragment="bodycontent">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<h1>Gruppensuche</h1>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<form action="/findGroup" method="get">
|
||||||
|
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Suchbegriff:</label>
|
||||||
|
<input class="form-control" type="text" value="" name="suchbegriff" placeholder="z.B. Programmieren, Lerngruppe, ...">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" style="margin-left: 10px;"> Öffentliche Gruppen
|
||||||
|
<input type="checkbox" style="margin-left: 24px;"> Private Gruppen
|
||||||
|
<br>
|
||||||
|
<input type="checkbox" style="margin-left: 10px;"> Suchbegriff im Namen
|
||||||
|
<input type="checkbox" style="margin-left: 10px;"> Suchbegriff in der Beschreibung
|
||||||
|
<input type="checkbox" style="margin-left: 10px;"> Suchbegriff in der Veranstaltung
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button type="button" class="btn btn-primary" style="background: dodgerblue">Suchen</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<table class="table">
|
||||||
|
<!-- Erscheint dann, wenn man "Suchen" Button klickt und Ergebnisse angezeigt werden, aber so solls aussehen -->
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Gruppenname</th>
|
||||||
|
<th scope="col">Beschreibung</th>
|
||||||
|
<th scope="col">Öffentlich/Privat</th>
|
||||||
|
<th scope="col">Mitgliederanzahl</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">LA1 Kursgruppe</th>
|
||||||
|
<td>Gruppe für den Kurs LA1</td>
|
||||||
|
<td>Öffentlich</td>
|
||||||
|
<td>318</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Lerngruppe LA1</th>
|
||||||
|
<td>Lerngruppe zur Bearbeitung von Übungszetteln</td>
|
||||||
|
<td>Privat</td>
|
||||||
|
<td>6</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -23,25 +23,25 @@ class GroupTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void createSingleGroup() {
|
void createSingleGroup() {
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,2, "asd", "hello", "foo");
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,2L, "asd", "hello", "foo");
|
||||||
|
|
||||||
Group group = new Group();
|
Group group = new Group();
|
||||||
group.apply(createGroupEvent);
|
group.apply(createGroupEvent);
|
||||||
|
|
||||||
assertThat(group.getDescription()).isEqualTo("foo");
|
assertThat(group.getDescription()).isEqualTo("foo");
|
||||||
assertThat(group.getTitle()).isEqualTo("hello");
|
assertThat(group.getTitle()).isEqualTo("hello");
|
||||||
assertThat(group.getId()).isEqualTo(2);
|
assertThat(group.getId()).isEqualTo(2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verwendet CreateGroupEvent
|
// Verwendet CreateGroupEvent
|
||||||
@Test
|
@Test
|
||||||
void addSingleUser() {
|
void addSingleUser() {
|
||||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1,1,"prof1", "hi", "foo");
|
CreateGroupEvent createGroupEvent = new CreateGroupEvent(1L,1L,"prof1", "hi", "foo");
|
||||||
Group group = new Group();
|
Group group = new Group();
|
||||||
group.apply(createGroupEvent);
|
group.apply(createGroupEvent);
|
||||||
|
|
||||||
User user = new User("prof", "jens", "bendi", "hi@gmail.com");
|
User user = new User("prof", "jens", "bendi", "hi@gmail.com");
|
||||||
AddUserEvent addUserEvent = new AddUserEvent(1,1, user);
|
AddUserEvent addUserEvent = new AddUserEvent(1L,1L, user);
|
||||||
group.apply(addUserEvent);
|
group.apply(addUserEvent);
|
||||||
|
|
||||||
assertThat(group.getMembers().get(0)).isEqualTo(user);
|
assertThat(group.getMembers().get(0)).isEqualTo(user);
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
package mops.gruppen2.service;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class EventServiceTest {
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,8 +22,10 @@ class SerializationServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void serializeEventTest() {
|
void serializeEventTest() {
|
||||||
Event event = new Event(1,1,"1");
|
event = new Event(1L,1L,"1");
|
||||||
SerializationService serializationService = new SerializationService(mock(EventRepository.class));
|
|
||||||
|
SerializationService serializationService = new SerializationService(eventRepository);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"Event\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}");
|
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"Event\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}");
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user